Skip to content

Commit

Permalink
Merge branch 'main' into kw/fix/ios-replay-redact
Browse files Browse the repository at this point in the history
  • Loading branch information
krystofwoldrich authored Nov 7, 2024
2 parents bb4e1ac + dde9191 commit a06f6b1
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 26 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@

### Fixes

- Ignore JavascriptException to filter out obfuscated duplicate JS Errors on Android ([#4232](https://github.com/getsentry/sentry-react-native/pull/4232))
- Skips ignoring require cycle logs for RN 0.70 or newer ([#4214](https://github.com/getsentry/sentry-react-native/pull/4214))
- Enhanced accuracy of time-to-display spans. ([#4189](https://github.com/getsentry/sentry-react-native/pull/4189))
- Fix Replay redacting of RN Classes on iOS ([#4243](https://github.com/getsentry/sentry-react-native/pull/4243))
- Speed up getBinaryImages for finishing transactions and capturing events ([#4194](https://github.com/getsentry/sentry-react-native/pull/4194))

### Features

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import com.facebook.react.bridge.JavaOnlyMap
import com.facebook.react.bridge.Promise
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.WritableMap
import com.facebook.react.common.JavascriptException
import io.sentry.ILogger
import io.sentry.SentryLevel
import io.sentry.android.core.SentryAndroidOptions
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
Expand Down Expand Up @@ -125,4 +127,11 @@ class RNSentryModuleImplTest {
module.getSentryAndroidOptions(actualOptions, options, logger)
assertFalse(actualOptions.isEnableSpotlight)
}

@Test
fun `the JavascriptException is added to the ignoredExceptionsForType list on initialisation`() {
val actualOptions = SentryAndroidOptions()
module.getSentryAndroidOptions(actualOptions, JavaOnlyMap.of(), logger)
assertTrue(actualOptions.ignoredExceptionsForType.contains(JavascriptException::class.java))
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#import "RNSentryTests.h"
#import <OCMock/OCMock.h>
#import <RNSentry/RNSentry.h>
#import <Sentry/SentryDebugImageProvider+HybridSDKs.h>
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>

Expand Down Expand Up @@ -327,9 +328,9 @@ - (void)prepareNativeFrameMocksWithLocalSymbolication:(BOOL)debug
OCMStub([sentryDebugImageMock serialize]).andReturn(serializedDebugImage);

id sentryDebugImageProviderMock = OCMClassMock([SentryDebugImageProvider class]);
OCMStub([sentryDebugImageProviderMock
getDebugImagesForAddresses:[NSSet setWithObject:@"0x000000000001b669"]
isCrash:false])
OCMStub(
[sentryDebugImageProviderMock
getDebugImagesForImageAddressesFromCache:[NSSet setWithObject:@"0x000000000001b669"]])
.andReturn(@[ sentryDebugImageMock ]);

OCMStub([sentryDependencyContainerMock debugImageProvider])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeArray;
import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.common.JavascriptException;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import io.sentry.HubAdapter;
import io.sentry.ILogger;
Expand Down Expand Up @@ -58,7 +59,6 @@
import io.sentry.android.core.internal.util.SentryFrameMetricsCollector;
import io.sentry.android.core.performance.AppStartMetrics;
import io.sentry.protocol.SdkVersion;
import io.sentry.protocol.SentryException;
import io.sentry.protocol.SentryId;
import io.sentry.protocol.SentryPackage;
import io.sentry.protocol.User;
Expand Down Expand Up @@ -274,20 +274,13 @@ protected void getSentryAndroidOptions(
options.getExperimental().setSessionReplay(getReplayOptions(rnOptions));
options.getReplayController().setBreadcrumbConverter(new RNSentryReplayBreadcrumbConverter());
}

// React native internally throws a JavascriptException.
// we want to ignore it on the native side to avoid sending it twice.
options.addIgnoredExceptionForType(JavascriptException.class);

options.setBeforeSend(
(event, hint) -> {
// React native internally throws a JavascriptException
// Since we catch it before that, we don't want to send this one
// because we would send it twice
try {
SentryException ex = event.getExceptions().get(0);
if (null != ex && ex.getType().contains("JavascriptException")) {
return null;
}
} catch (Throwable ignored) { // NOPMD - We don't want to crash in any case
// We do nothing
}

setEventOriginTag(event);
addPackages(event, options.getSdkVersion());

Expand Down
7 changes: 0 additions & 7 deletions packages/core/ios/RNSentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@

typedef int (*SymbolicateCallbackType)(const void *, Dl_info *);

@interface
SentryDebugImageProvider ()
- (NSArray<SentryDebugMeta *> *_Nonnull)getDebugImagesForAddresses:
(NSSet<NSString *> *_Nonnull)addresses
isCrash:(BOOL)isCrash;
@end

@interface
SentrySDK (Private)
@property (nonatomic, nullable, readonly, class) SentryOptions *options;
Expand Down
7 changes: 4 additions & 3 deletions packages/core/ios/RNSentry.mm
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#import <Sentry/PrivateSentrySDKOnly.h>
#import <Sentry/SentryAppStartMeasurement.h>
#import <Sentry/SentryBinaryImageCache.h>
#import <Sentry/SentryDebugImageProvider+HybridSDKs.h>
#import <Sentry/SentryDependencyContainer.h>
#import <Sentry/SentryFormatter.h>
#import <Sentry/SentryOptions+HybridSDKs.h>
Expand Down Expand Up @@ -368,9 +369,9 @@ - (NSDictionary *)fetchNativeStackFramesBy:(NSArray<NSNumber *> *)instructionsAd
NSMutableArray<NSDictionary<NSString *, id> *> *_Nonnull serializedDebugMetaImages =
[[NSMutableArray alloc] init];

NSArray<SentryDebugMeta *> *debugMetaImages = [[[SentryDependencyContainer sharedInstance]
debugImageProvider] getDebugImagesForAddresses:imagesAddrToRetrieveDebugMetaImages
isCrash:false];
NSArray<SentryDebugMeta *> *debugMetaImages =
[[[SentryDependencyContainer sharedInstance] debugImageProvider]
getDebugImagesForImageAddressesFromCache:imagesAddrToRetrieveDebugMetaImages];

for (SentryDebugMeta *debugImage in debugMetaImages) {
[serializedDebugMetaImages addObject:[debugImage serialize]];
Expand Down

0 comments on commit a06f6b1

Please sign in to comment.