Sentry-react-native: wanted: do not upload sourcemaps on release build for test environment.

Created on 6 Jul 2017  路  11Comments  路  Source: getsentry/sentry-react-native

Hello!

I am running e2e testing using Appium within my project.

During our test process we have to create a new build of iOS or Android at release version.

During this phase we noticed that the sentry-cli builds and sends the sourcemaps.

This is only happening on our staging server at the moment, but it might be making redundant uploads/falsely tagged uploads.

Is it possible to add a flag somewhere in the deployment process that would be picked up and would disable sending the sourcemaps?

Example:

export SENTRY_TEST_ENV=true

scripts/test.sh ... ...

and React-Native-Sentry would be aware of this variable?

Thanks!

Most helpful comment

Thanks @HazAT for your help, got it working :)

If someone wants to take help in this problem they can view this PR https://github.com/zulip/zulip-mobile/pull/940

All 11 comments

Would you consider setting the environment tag to e.g.: staging and use the setDist function to separate builds on Sentry.
Every dist (Distribution) will have its own source map files.

I am pretty sure we will not add this specific feature because you could check in the run script phase or gradle build step for the current environment and just don't call sentry-cli.

Would the solution with distributions work for you?

Yeah this sounds more reasonable, I was unaware that is why I requested something.

I will work that into our workflow, thank you.

@HazAT just a quick follow up... my intention is to NOT upload any sourcemaps or files to sentry during this test, but am unsure how I could setDist to NONE... I need to cancel the sentry-cli thing in general.

I see, but since sentry-cli will be called in the run script phase, it should be possible to not call it for specific build types. I thought it would make sense to also get the correct stacktraces on the staging env.

You do make a good point! Thanks for the insights and letting me bounce this off of you. I am satisfied with this paradigm 馃憤

@HazAT I'm also facing a similar problem where I'm using detox for e2e tests, I need to disable the sentry as the key is not public and the project is an open source

Jul 27 11:30:20 asd ZulipMobile[27355]: Sentry Started -- Version: 3.1.3
Jul 27 11:30:20 asd ZulipMobile[27355]: Sentry - Error:: Project ID path component of DSN is missing
Jul 27 11:30:20 asd ZulipMobile[27355]: *** Terminating app due to uncaught exception 'SentryReactNative', reason: 'Project ID path component of DSN is missing'
    *** First throw call stack:

I used some scripts in the bundle phase, where the the sentry was being bundled

if [[ $SDKROOT == *"iPhoneSimulator10"* ]]; then
    export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh
else
export SENTRY_PROPERTIES=sentry.properties
export NODE_BINARY=node
../node_modules/sentry-cli-binary/bin/sentry-cli react-native xcode ../node_modules/react-native/scripts/react-native-xcode.sh
fi

I also disabled it in the AppDelegate (this line [RNSentry installWithRootView:rootView]; )

It will be fine (for now) if the sentry is bundled with the App, but how can I disable the auto start of the sentry on the native side, as I don't want to include the key?

@kunall17 I would disable it in javascript with something like

if (__DEV__) { // Check for env here
    Sentry.config({}).install();
}

@HazAT The above stacktrace

Jul 27 20:23:21 asd ZulipMobile[2849]: assertion failed: 16F73 14E269: libxpc.dylib + 64131 [624BAF4F-2E03-34F8-ACBA-970B04637786]: 0x7d
Jul 27 20:23:21 asd ZulipMobile[2849]: Sentry Started -- Version: 3.1.3
Jul 27 20:23:21 asd ZulipMobile[2849]: Sentry - Error:: Project ID path component of DSN is missing
Jul 27 20:23:21 asd ZulipMobile[2849]: *** Terminating app due to uncaught exception 'SentryReactNative', reason: 'Project ID path component of DSN is missing'
    *** First throw call stack:
    (
        0   CoreFoundation                      0x000000010cd8eb0b __exceptionPreprocess + 171
        1   libobjc.A.dylib                     0x000000010b8ab141 objc_exception_throw + 48
        2   CoreFoundation                      0x000000010cdf7625 +[NSException raise:format:] + 197
        3   ZulipMobile                         0x000000010af17308 __31-[RNSentry startWithDsnString:]_block_invoke + 276
        4   libdispatch.dylib                   0x0000000111109792 _dispatch_client_callout + 8
        5   libdispatch.dylib                   0x00000001110f4a8d dispatch_once_f + 69
        6   ZulipMobile                         0x000000010af171ee -[RNSentry startWithDsnString:] + 159
        7   CoreFoundation                      0x000000010cd16c6c __invoking___ + 140
        8   CoreFoundation                      0x000000010cd16b40 -[NSInvocation invoke] + 320
        9   CoreFoundation                      0x000000010cd2e956 -[NSInvocation invokeWithTarget:] + 54
        10  ZulipMobile                         0x000000010ae417dd -[RCTModuleMethod invokeWithBridge:module:arguments:] + 553
        11  ZulipMobile                         0x000000010ae920d6 _ZN8facebook5react15RCTNativeModule11invokeInnerEjOKN5folly7dynamicE + 270
        12  ZulipMobile                         0x000000010ae91f2f ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 46
        13  libdispatch.dylib                   0x00000001110e8585 _dispatch_call_block_and_release + 12
        14  libdispatch.dylib                   0x0000000111109792 _dispatch_client_callout + 8
        15  libdispatch.dylib                   0x00000001110ef237 _dispatch_queue_serial_drain + 1022
        16  libdispatch.dylib                   0x00000001110ef98f _dispatch_queue_invoke + 1053
        17  libdispatch.dylib                   0x00000001110efd31 _dispatch_queue_override_invoke + 374
        18  libdispatch.dylib                   0x00000001110f1899 _dispatch_root_queue_drain + 813
        19  libdispatch.dylib                   0x00000001110f150d _dispatch_worker_thread3 + 113
        20  libsystem_pthread.dylib             0x00000001114955a2 _pthread_wqthread + 1299
        21  libsystem_pthread.dylib             0x000000011149507d start_wqthread + 13
    )

sentry.properties

defaults.url=https://sentry.io
defaults.org=zulip
defaults.project=zulip-mobile
auth.token=ADD-DSN-HERE

is for the start of the application, and I'm already not calling the Sentry.config in the js side!
Apologies, I forgot to mention this above!

Any other way I can prevent the sentry initialization?

Ok there was some problem with the packager, @HazAT is there any way I can avoid this error message
error: http error: Invalid token (401) for auth.token=ADD-DSN-HERE

@kunall17 Just to clear things up: auth.token=ADD-DSN-HERE you don't need the DSN here you need an auth token, created in the Sentry Backend https://sentry.io/api/

And if you don't want to upload anything, just don't provide the properties in the Sentry.properties file.

Thanks @HazAT for your help, got it working :)

If someone wants to take help in this problem they can view this PR https://github.com/zulip/zulip-mobile/pull/940

Was this page helpful?
0 / 5 - 0 ratings