Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Refactor fetchNativeDeviceContexts for testability
  • Loading branch information
antonis committed Nov 8, 2024
commit 98c47cf223f0c2d512855cbbecd063530c76f273
Original file line number Diff line number Diff line change
Expand Up @@ -888,18 +888,24 @@ private String readStringFromFile(File path) throws IOException {

public void fetchNativeDeviceContexts(Promise promise) {
final @NotNull SentryOptions options = HubAdapter.getInstance().getOptions();
final @Nullable Context context = this.getReactApplicationContext().getApplicationContext();
final @Nullable IScope currentScope = InternalSentrySdk.getCurrentScope();
fetchNativeDeviceContexts(promise, options, context, currentScope);
}

protected void fetchNativeDeviceContexts(
Promise promise,
final @NotNull SentryOptions options,
final @Nullable Context context,
final @Nullable IScope currentScope) {
if (!(options instanceof SentryAndroidOptions)) {
promise.resolve(null);
return;
}

final @Nullable Context context = this.getReactApplicationContext().getApplicationContext();
if (context == null) {
promise.resolve(null);
return;
}

final @Nullable IScope currentScope = InternalSentrySdk.getCurrentScope();
if (currentScope != null) {
// Remove react-native breadcrumbs
Iterator<Breadcrumb> breadcrumbsIterator = currentScope.getBreadcrumbs().iterator();
Expand Down