Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MobileReplay not sampled even though replaysSessionSampleRate is set to 1 #4199

Open
dusanristic opened this issue Oct 22, 2024 · 6 comments

Comments

@dusanristic
Copy link

dusanristic commented Oct 22, 2024

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.

@krystofwoldrich
Copy link
Member

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.

@krystofwoldrich krystofwoldrich moved this from Needs Discussion to Needs More Information in Mobile & Cross Platform SDK Oct 23, 2024
@getsantry getsantry bot moved this from Waiting for: Product Owner to Waiting for: Community in GitHub Issues with 👀 3 Oct 23, 2024
@dusanristic
Copy link
Author

dusanristic commented Oct 28, 2024

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"];
  }];

@getsantry getsantry bot moved this from Waiting for: Community to Waiting for: Product Owner in GitHub Issues with 👀 3 Oct 28, 2024
@krystofwoldrich
Copy link
Member

krystofwoldrich commented Oct 29, 2024

@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.

@dusanristic
Copy link
Author

dusanristic commented Oct 30, 2024

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'.

Image

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.

@getsantry getsantry bot moved this from Waiting for: Community to Waiting for: Product Owner in GitHub Issues with 👀 3 Oct 30, 2024
@dusanristic
Copy link
Author

dusanristic commented Nov 1, 2024

I've checked the Sentry SDK, and the experimental parameter is of type SentryExperimentalOptions, which contains a public sessionReplay variable.

@krystofwoldrich
Copy link
Member

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;.

@getsantry getsantry bot moved this to Waiting for: Community in GitHub Issues with 👀 3 Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Waiting for: Community
Status: Needs More Information
Development

No branches or pull requests

3 participants