Skip to content

Commit

Permalink
fix: prevent crash when using setExtra/setTag with a null value
Browse files Browse the repository at this point in the history
  • Loading branch information
farfromrefug committed Oct 22, 2024
1 parent 87e1e16 commit d01e345
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/sentry/wrapper.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,11 @@ export namespace NATIVE {
return;
}
runOnScope((scope) => {
scope.setTag(key, value);
if (value){
scope.setTag(key, value);
} else {
scope.removeTag(key);
}
});
}

Expand All @@ -878,7 +882,11 @@ export namespace NATIVE {
return;
}
runOnScope((scope) => {
scope.setExtra(key, extra);
if (extra) {
scope.setExtra(key, extra);
} else {
scope.removeExtra(key);
}
});
}

Expand Down
12 changes: 10 additions & 2 deletions src/sentry/wrapper.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,11 @@ export namespace NATIVE {
return;
}
NSSentrySDK.configureScope((scope: SentryScope) => {
scope.setTagValueForKey(value, key);
if (value){
scope.setTagValueForKey(key, value);
} else {
scope.removeTagForKey(key);
}
});
}

Expand All @@ -545,7 +549,11 @@ export namespace NATIVE {
return;
}
NSSentrySDK.configureScope((scope: SentryScope) => {
scope.setExtraValueForKey(extra, key);
if (extra) {
scope.setExtraValueForKey(key, extra);
} else {
scope.removeContextForKey(key);
}
});
}

Expand Down

0 comments on commit d01e345

Please sign in to comment.