sentry-react-native
sentry-react-native copied to clipboard
MobileReplay not sampled even though replaysSessionSampleRate is set to 1
What React Native libraries do you use?
Hermes, React Navigation
Are you using sentry.io or on-premise?
sentry.io (SaS)
@sentry/react-native SDK Version
5.34.0
How does your development environment look like?
OS: Sonoma 14.1.1 Node: 18.7.1 yarn: 1.22.22 react-native: 0.72.7 hermesEnabled: true newArchEnabled: false
Sentry.init()
Sentry.init({
debug: true,
autoInitializeNativeSdk: false,
dsn: SENTRY_DSN,
_experiments: {
replaysSessionSampleRate: 1.0,
replaysOnErrorSampleRate: 1.0,
},
integrations: [Sentry.mobileReplayIntegration()],
environment: NativeConfig.loggerEnvironment,
release: releaseName,
dist: getBuildNumber(),
attachScreenshot: true,
attachViewHierarchy: true,
enabled,
enableNative: enabled,
ignoreErrors: [...ignoreErrors],
});
};
Steps to Reproduce
/
Expected Result
Because the replaysSessionSampleRate parameter is set to 1, I expect that every session is recorded and sent to Sentry. Additionally, when I dispatch an error, that replay is not logged to Sentry either.
My Replay dashboard is empty.
Actual Result
Nothing is logged to Sentry, and my Replay session dashboard is empty. When I run the app, this is my output:
LOG Sentry Logger [log]: Unhandled promise rejections will be caught by Sentry.
LOG Sentry Logger [log]: Integration installed: ReactNativeErrorHandlers
LOG Sentry Logger [log]: Integration installed: NativeLinkedErrors
LOG Sentry Logger [log]: Integration installed: InboundFilters
LOG Sentry Logger [log]: Integration installed: FunctionToString
LOG Sentry Logger [log]: Integration installed: Breadcrumbs
LOG Sentry Logger [log]: Integration installed: Dedupe
LOG Sentry Logger [log]: Integration installed: HttpContext
LOG Sentry Logger [log]: Integration installed: Release
LOG Sentry Logger [log]: Integration installed: EventOrigin
LOG Sentry Logger [log]: Integration installed: SdkInfo
LOG Sentry Logger [log]: Integration installed: ReactNativeInfo
LOG Sentry Logger [log]: Integration installed: DebugSymbolicator
LOG Sentry Logger [log]: Integration installed: RewriteFrames
LOG Sentry Logger [log]: Integration installed: DeviceContext
LOG Sentry Logger [log]: Integration installed: ModulesLoader
LOG Sentry Logger [log]: Integration installed: Screenshot
LOG Sentry Logger [log]: Integration installed: ViewHierarchy
LOG Sentry Logger [log]: Integration installed: MobileReplay
WARN Sentry Logger [warn]: Note: Native Sentry SDK was not initialized automatically, you will need to initialize it manually. If you wish to disable the native SDK and get rid of this warning, pass enableNative: false
LOG Sentry Logger [log]: Integration installed: ReactNativeProfiler
LOG Sentry Logger [log]: Integration installed: TouchEventBoundary
LOG Sentry Logger [log]: [ReactNavigationInstrumentation] Navigation container registered, but integration has not been setup yet.
LOG [Error: Error: 400: An update check must include a valid deployment key - please check that your app has been configured correctly. To view available deployment keys, run 'code-push deployment ls <appName> -k'.]
DEBUG Sentry Logger [debug]: [Sentry] MobileReplay not sampled for event 9f45775265274cd794fbdc23aa5d5306.
I am getting that MobileReplay is not sampled even though replaysSessionSampleRate is set to 1.
Hi @dusanristic, thank you for the message,
from the Sentry.init I see that you have set autoInitializeNativeSdk: false which means you initialize the platform SDK manually.
For Session Replay to work in RN, it has to be enabled in the platform SDK as well.
Please add the replay sample rates to iOS and Android inits.
Hey @krystofwoldrich, I do have these params on native side as well (apologise for not adding them in the first place). Below is the snippet code for iOS in AppDelegate.mm file:
[SentrySDK startWithConfigureOptions:^(SentryOptions *options) {
options.dsn = @"https://63b8941d39cb0367e993da924c5f21e1@o4506870128181248.ingest.us.sentry.io/4506904420286464";
options.debug = true;
options.tracesSampleRate = [NSNumber numberWithDouble:1.0];
options.profilesSampleRate = [NSNumber numberWithDouble:1.0];
// Load values from Info.plist as dictionary
NSDictionary* infoDict = [[NSBundle mainBundle] infoDictionary];
// Extract version and dist from dictonary
NSString* version = [infoDict objectForKey:@"CFBundleShortVersionString"];
NSString* dist = [infoDict objectForKey:@"CFBundleVersion"];
options.releaseName = [NSString stringWithFormat:@"%@%@", @"XXXXXXX@", version];
options.dist = dist;
options.environment = [infoDict objectForKey:@"logger_environment"];
}];
@dusanristic No worries, thank you for sharing the iOS init.
For Session replay to work, you need to add the following to your iOS init.
options.experimental.sessionReplay.onErrorSampleRate = 1.0
options.experimental.sessionReplay.sessionSampleRate = 1.0
Let us know if this fixed the issue.
Thanks for your help and fast response! I have one more question though.
When I add the mentioned lines to iOS init, I get the following error:
Property 'sessionReplay' cannot be found in forward class object 'SentryExperimentalOptions'.
Is there anything else I need to do to enable experimental features on iOS? I went through the documentation, and the only thing I found is that I need to have at least Sentry Cocoa SDK v8.31.1, but my Sentry pod version is already v8.37.0.
I've checked the Sentry SDK, and the experimental parameter is of type SentryExperimentalOptions, which contains a public sessionReplay variable.
Hi @dusanristic, thank you for the message, could you share with us how do you import Sentry in your project?
The code example above should work when Sentry is imported as @import Sentry;.
This issue has gone three weeks without activity. In another week, I will close it.
But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!
"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀
Closing this due to inactivity. If this is still an issue feel free to comment here or open a new issue if the context changed.
We have noticed this same issue. Session Replay only works when autoInitializeNativeSdk is enabled but when we set it to false we see the following log:
(NOBRIDGE) DEBUG Sentry Logger [debug]: [Sentry] MobileReplay not sampled for event 110a58018b31414d880ed5d47d0ac6e9.
Since we have a hybrid SDK configuration, also tried to enable this within our AppDelegate.mm file but it seems the properties do not exist.
Is there another way to configure this? I assumed it would be similar to the iOS setup documentation: https://docs.sentry.io/platforms/apple/guides/ios/session-replay/#set-up
Looks like the SentryReplayOption class is written in swift and there is no bridge to Object-C (which our RN app is currently using). RN just started shipping a swift template with v0.77 but we still need to convert our old code.