@sentry/react-native 5.0.0-alpha.4 → 5.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.0.0-alpha.5
4
+
5
+ ### Fixes
6
+
7
+ - Make `configureScope` callback safe [#2510](https://github.com/getsentry/sentry-react-native/pull/2510)
8
+
9
+ ### Dependencies
10
+
11
+ - Bump JavaScript SDK from v7.14.0 to v7.14.1 ([#2511](https://github.com/getsentry/sentry-react-native/pull/2511))
12
+ - [changelog](https://github.com/getsentry/sentry-javascript/blob/master/CHANGELOG.md#7141)
13
+ - [diff](https://github.com/getsentry/sentry-javascript/compare/7.14.0...7.14.1)
14
+ - Bump Cocoa SDK from v7.27.0 to v7.27.1 ([#2521](https://github.com/getsentry/sentry-react-native/pull/2521))
15
+ - [changelog](https://github.com/getsentry/sentry-cocoa/blob/master/CHANGELOG.md#7271)
16
+ - [diff](https://github.com/getsentry/sentry-cocoa/compare/7.27.0...7.27.1)
17
+ - Bump Android SDK from v6.4.2 to v6.4.3 ([#2520](https://github.com/getsentry/sentry-react-native/pull/2520))
18
+ - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#643)
19
+ - [diff](https://github.com/getsentry/sentry-java/compare/6.4.2...6.4.3)
20
+
21
+ ## 4.6.0
22
+
23
+ ### Fixes
24
+
25
+ - SDK Gracefully downgrades when callback throws an error ([#2502](https://github.com/getsentry/sentry-react-native/pull/2502))
26
+ - React Navigation v5 ignores when current route is undefined after state changed. ([#2484](https://github.com/getsentry/sentry-react-native/pull/2484))
27
+
28
+ ### Features
29
+
30
+ - Add ClientReports ([#2496](https://github.com/getsentry/sentry-react-native/pull/2496))
31
+
32
+ ### Sentry Self-hosted Compatibility
33
+
34
+ - Starting with version `4.6.0` of the `@sentry/react-native` package, [Sentry's self hosted version >= v21.9.0](https://github.com/getsentry/self-hosted/releases) is required or you have to manually disable sending client reports via the `sendClientReports` option. This only applies to self-hosted Sentry. If you are using [sentry.io](https://sentry.io), no action is needed.
35
+
36
+ ### Dependencies
37
+
38
+ - Bump Cocoa SDK from v7.25.1 to v7.27.0 ([#2500](https://github.com/getsentry/sentry-react-native/pull/2500), [#2506](https://github.com/getsentry/sentry-react-native/pull/2506))
39
+ - [changelog](https://github.com/getsentry/sentry-cocoa/blob/master/CHANGELOG.md#7270)
40
+ - [diff](https://github.com/getsentry/sentry-cocoa/compare/7.25.1...7.27.0)
41
+ - Bump JavaScript SDK from v7.13.0 to v7.14.0 ([#2504](https://github.com/getsentry/sentry-react-native/pull/2504))
42
+ - [changelog](https://github.com/getsentry/sentry-javascript/blob/master/CHANGELOG.md#7140)
43
+ - [diff](https://github.com/getsentry/sentry-javascript/compare/7.13.0...7.14.0)
44
+
3
45
  ## 5.0.0-alpha.4
4
46
 
5
47
  - Latest changes from 4.5.0
package/RNSentry.podspec CHANGED
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
17
17
  s.preserve_paths = '*.js'
18
18
 
19
19
  s.dependency 'React-Core'
20
- s.dependency 'Sentry', '7.25.1'
20
+ s.dependency 'Sentry', '7.27.1'
21
21
 
22
22
  s.source_files = 'ios/RNSentry.{h,m}'
23
23
  s.public_header_files = 'ios/RNSentry.h'
@@ -24,5 +24,5 @@ android {
24
24
 
25
25
  dependencies {
26
26
  implementation 'com.facebook.react:react-native:+'
27
- api 'io.sentry:sentry-android:6.4.2'
27
+ api 'io.sentry:sentry-android:6.4.3'
28
28
  }
@@ -99,6 +99,9 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
99
99
  // SentryAndroid needs an empty string fallback for the dsn.
100
100
  options.setDsn("");
101
101
  }
102
+ if (rnOptions.hasKey("sendClientReports")) {
103
+ options.setSendClientReports(rnOptions.getBoolean("sendClientReports"));
104
+ }
102
105
  if (rnOptions.hasKey("maxBreadcrumbs")) {
103
106
  options.setMaxBreadcrumbs(rnOptions.getInt("maxBreadcrumbs"));
104
107
  }
@@ -1,5 +1,5 @@
1
1
  import { BaseClient } from '@sentry/core';
2
- import { Event, EventHint, SeverityLevel, UserFeedback } from '@sentry/types';
2
+ import { Envelope, Event, EventHint, SeverityLevel, UserFeedback } from '@sentry/types';
3
3
  import { ReactNativeClientOptions } from './options';
4
4
  /**
5
5
  * The Sentry React Native SDK Client.
@@ -8,6 +8,7 @@ import { ReactNativeClientOptions } from './options';
8
8
  * @see SentryClient for usage documentation.
9
9
  */
10
10
  export declare class ReactNativeClient extends BaseClient<ReactNativeClientOptions> {
11
+ private _outcomesBuffer;
11
12
  private readonly _browserClient;
12
13
  /**
13
14
  * Creates a new React Native SDK instance.
@@ -36,12 +37,20 @@ export declare class ReactNativeClient extends BaseClient<ReactNativeClientOptio
36
37
  */
37
38
  captureUserFeedback(feedback: UserFeedback): void;
38
39
  /**
39
- * Starts native client with dsn and options
40
- */
40
+ * @inheritdoc
41
+ */
42
+ protected _sendEnvelope(envelope: Envelope): void;
43
+ /**
44
+ * Starts native client with dsn and options
45
+ */
41
46
  private _initNativeSdk;
42
47
  /**
43
48
  * If the user is in development mode, and the native nagger is enabled then it will show an alert.
44
49
  */
45
50
  private _showCannotConnectDialog;
51
+ /**
52
+ * Attaches a client report from outcomes to the envelope.
53
+ */
54
+ private _attachClientReportTo;
46
55
  }
47
56
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/js/client.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,KAAK,EACL,SAAS,EACT,aAAa,EAEb,YAAY,EACb,MAAM,eAAe,CAAC;AAKvB,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAKrD;;;;;GAKG;AACH,qBAAa,iBAAkB,SAAQ,UAAU,CAAC,wBAAwB,CAAC;IAEzE,OAAO,CAAC,QAAQ,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,GAAG,WAAW,CAAC,KAAK,CAAC;IAIxG;;;OAGG;IACI,WAAW,IAAI,IAAI;IAI1B;;OAEG;IACI,KAAK,IAAI,WAAW,CAAC,OAAO,CAAC;IAOpC;;OAEG;IACI,mBAAmB,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI;IAYxD;;OAEG;IACH,SAAS,CAAC,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IA6BjD;;OAEG;YACW,cAAc;IAgB5B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAShC;;OAEG;IACH,OAAO,CAAC,qBAAqB;CAa9B"}
package/dist/js/client.js CHANGED
@@ -1,11 +1,13 @@
1
1
  import { __awaiter } from "tslib";
2
2
  import { BrowserClient, defaultStackParser, makeFetchTransport } from '@sentry/browser';
3
3
  import { BaseClient } from '@sentry/core';
4
+ import { dateTimestampInSeconds, logger, SentryError } from '@sentry/utils';
4
5
  // @ts-ignore LogBox introduced in RN 0.63
5
6
  import { Alert, LogBox, YellowBox } from 'react-native';
6
7
  import { defaultSdkInfo } from './integrations/sdkinfo';
7
8
  import { NativeTransport } from './transports/native';
8
- import { createUserFeedbackEnvelope } from './utils/envelope';
9
+ import { createUserFeedbackEnvelope, items } from './utils/envelope';
10
+ import { mergeOutcomes } from './utils/outcome';
9
11
  import { NATIVE } from './wrapper';
10
12
  /**
11
13
  * The Sentry React Native SDK Client.
@@ -30,6 +32,7 @@ export class ReactNativeClient extends BaseClient {
30
32
  options._metadata = options._metadata || {};
31
33
  options._metadata.sdk = options._metadata.sdk || defaultSdkInfo;
32
34
  super(options);
35
+ this._outcomesBuffer = [];
33
36
  // This is a workaround for now using fetch on RN, this is a known issue in react-native and only generates a warning
34
37
  // YellowBox deprecated and replaced with with LogBox in RN 0.63
35
38
  if (LogBox) {
@@ -90,10 +93,40 @@ export class ReactNativeClient extends BaseClient {
90
93
  this._sendEnvelope(envelope);
91
94
  }
92
95
  /**
93
- * Starts native client with dsn and options
94
- */
96
+ * @inheritdoc
97
+ */
98
+ _sendEnvelope(envelope) {
99
+ const outcomes = this._clearOutcomes();
100
+ this._outcomesBuffer = mergeOutcomes(this._outcomesBuffer, outcomes);
101
+ if (this._options.sendClientReports) {
102
+ this._attachClientReportTo(this._outcomesBuffer, envelope);
103
+ }
104
+ let shouldClearOutcomesBuffer = true;
105
+ if (this._transport && this._dsn) {
106
+ this._transport.send(envelope)
107
+ .then(null, reason => {
108
+ if (reason instanceof SentryError) { // SentryError is thrown by SyncPromise
109
+ shouldClearOutcomesBuffer = false;
110
+ // If this is called asynchronously we want the _outcomesBuffer to be cleared
111
+ logger.error('SentryError while sending event, keeping outcomes buffer:', reason);
112
+ }
113
+ else {
114
+ logger.error('Error while sending event:', reason);
115
+ }
116
+ });
117
+ }
118
+ else {
119
+ logger.error('Transport disabled');
120
+ }
121
+ if (shouldClearOutcomesBuffer) {
122
+ this._outcomesBuffer = []; // if send fails synchronously the _outcomesBuffer will stay intact
123
+ }
124
+ }
125
+ /**
126
+ * Starts native client with dsn and options
127
+ */
95
128
  _initNativeSdk() {
96
- var _a, _b, _c, _d;
129
+ var _a, _b;
97
130
  return __awaiter(this, void 0, void 0, function* () {
98
131
  let didCallNativeInit = false;
99
132
  try {
@@ -101,10 +134,15 @@ export class ReactNativeClient extends BaseClient {
101
134
  }
102
135
  catch (_) {
103
136
  this._showCannotConnectDialog();
104
- (_b = (_a = this._options).onReady) === null || _b === void 0 ? void 0 : _b.call(_a, { didCallNativeInit: false });
105
- return;
106
137
  }
107
- (_d = (_c = this._options).onReady) === null || _d === void 0 ? void 0 : _d.call(_c, { didCallNativeInit });
138
+ finally {
139
+ try {
140
+ (_b = (_a = this._options).onReady) === null || _b === void 0 ? void 0 : _b.call(_a, { didCallNativeInit });
141
+ }
142
+ catch (error) {
143
+ logger.error('The OnReady callback threw an error: ', error);
144
+ }
145
+ }
108
146
  });
109
147
  }
110
148
  /**
@@ -115,5 +153,20 @@ export class ReactNativeClient extends BaseClient {
115
153
  Alert.alert('Sentry', 'Warning, could not connect to Sentry native SDK.\nIf you do not want to use the native component please pass `enableNative: false` in the options.\nVisit: https://docs.sentry.io/platforms/react-native/#linking for more details.');
116
154
  }
117
155
  }
156
+ /**
157
+ * Attaches a client report from outcomes to the envelope.
158
+ */
159
+ _attachClientReportTo(outcomes, envelope) {
160
+ if (outcomes.length > 0) {
161
+ const clientReportItem = [
162
+ { type: 'client_report' },
163
+ {
164
+ timestamp: dateTimestampInSeconds(),
165
+ discarded_events: outcomes,
166
+ },
167
+ ];
168
+ envelope[items].push(clientReportItem);
169
+ }
170
+ }
118
171
  }
119
172
  //# sourceMappingURL=client.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/js/client.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGxF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAQ1C,0CAA0C;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;;;GAKG;AACH,MAAM,OAAO,iBAAkB,SAAQ,UAAoC;IAIzE;;;OAGG;IACF,YAAmB,OAAiC;QAClD,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE;YACtB,OAAO,CAAC,SAAS,GAAG,CAAC,OAAgC,EAAE,WAAuB,EAAa,EAAE;gBAC3F,IAAI,MAAM,CAAC,0BAA0B,EAAE,EAAE;oBACvC,OAAO,IAAI,eAAe,EAAE,CAAC;iBAC9B;gBACD,OAAO,kBAAkB,CAAC,OAAO,EAAE,WAA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G,OAAO,KAAK,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,MAAe,EAAE,EAAE;YAC5C,OAAO,MAAM,CAAC,cAAc,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAyB,CAAC;QAC5E,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACI,mBAAmB,CAAC,QAAsB;QAC/C,MAAM,QAAQ,GAAG,0BAA0B,CACzC,QAAQ,EACR;YACE,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS;YACjC,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE;YAClB,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM;SAC7B,CACF,CAAC;QACF,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC;IAED;;KAEC;IACa,cAAc;;;YAC1B,IAAI,iBAAiB,GAAG,KAAK,CAAC;YAE9B,IAAI;gBACF,iBAAiB,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;aAC/D;YAAC,OAAO,CAAC,EAAE;gBACV,IAAI,CAAC,wBAAwB,EAAE,CAAC;gBAEhC,MAAA,MAAA,IAAI,CAAC,QAAQ,EAAC,OAAO,mDAAG,EAAE,iBAAiB,EAAE,KAAK,EAAE,EAAE;gBAEtD,OAAO;aACR;YACD,MAAA,MAAA,IAAI,CAAC,QAAQ,EAAC,OAAO,mDAAG,EAAE,iBAAiB,EAAE,EAAE;;KAChD;IAED;;OAEG;IACK,wBAAwB;QAC9B,IAAI,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,EAAE;YAC/C,KAAK,CAAC,KAAK,CACT,QAAQ,EACR,qOAAqO,CACtO,CAAC;SACH;IACH,CAAC;CACF","sourcesContent":["import { BrowserClient, defaultStackParser, makeFetchTransport } from '@sentry/browser';\nimport { BrowserTransportOptions } from '@sentry/browser/types/transports/types';\nimport { FetchImpl } from '@sentry/browser/types/transports/utils';\nimport { BaseClient } from '@sentry/core';\nimport {\n Event,\n EventHint,\n SeverityLevel,\n Transport,\n UserFeedback,\n} from '@sentry/types';\n// @ts-ignore LogBox introduced in RN 0.63\nimport { Alert, LogBox, YellowBox } from 'react-native';\n\nimport { defaultSdkInfo } from './integrations/sdkinfo';\nimport { ReactNativeClientOptions } from './options';\nimport { NativeTransport } from './transports/native';\nimport { createUserFeedbackEnvelope } from './utils/envelope';\nimport { NATIVE } from './wrapper';\n\n/**\n * The Sentry React Native SDK Client.\n *\n * @see ReactNativeClientOptions for documentation on configuration options.\n * @see SentryClient for usage documentation.\n */\nexport class ReactNativeClient extends BaseClient<ReactNativeClientOptions> {\n\n private readonly _browserClient: BrowserClient;\n\n /**\n * Creates a new React Native SDK instance.\n * @param options Configuration options for this SDK.\n */\n public constructor(options: ReactNativeClientOptions) {\n if (!options.transport) {\n options.transport = (options: BrowserTransportOptions, nativeFetch?: FetchImpl): Transport => {\n if (NATIVE.isNativeTransportAvailable()) {\n return new NativeTransport();\n }\n return makeFetchTransport(options, nativeFetch);\n };\n }\n options._metadata = options._metadata || {};\n options._metadata.sdk = options._metadata.sdk || defaultSdkInfo;\n super(options);\n\n // This is a workaround for now using fetch on RN, this is a known issue in react-native and only generates a warning\n // YellowBox deprecated and replaced with with LogBox in RN 0.63\n if (LogBox) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n LogBox.ignoreLogs(['Require cycle:']);\n } else {\n // eslint-disable-next-line deprecation/deprecation\n YellowBox.ignoreWarnings(['Require cycle:']);\n }\n\n this._browserClient = new BrowserClient({\n dsn: options.dsn,\n transport: options.transport,\n transportOptions: options.transportOptions,\n stackParser: options.stackParser || defaultStackParser,\n integrations: [],\n _metadata: options._metadata,\n });\n\n void this._initNativeSdk();\n }\n\n\n /**\n * @inheritDoc\n */\n public eventFromException(_exception: unknown, _hint?: EventHint): PromiseLike<Event> {\n return this._browserClient.eventFromException(_exception, _hint);\n }\n\n /**\n * @inheritDoc\n */\n public eventFromMessage(_message: string, _level?: SeverityLevel, _hint?: EventHint): PromiseLike<Event> {\n return this._browserClient.eventFromMessage(_message, _level, _hint);\n }\n\n /**\n * If native client is available it will trigger a native crash.\n * Use this only for testing purposes.\n */\n public nativeCrash(): void {\n NATIVE.nativeCrash();\n }\n\n /**\n * @inheritDoc\n */\n public close(): PromiseLike<boolean> {\n // As super.close() flushes queued events, we wait for that to finish before closing the native SDK.\n return super.close().then((result: boolean) => {\n return NATIVE.closeNativeSdk().then(() => result) as PromiseLike<boolean>;\n });\n }\n\n /**\n * Sends user feedback to Sentry.\n */\n public captureUserFeedback(feedback: UserFeedback): void {\n const envelope = createUserFeedbackEnvelope(\n feedback,\n {\n metadata: this._options._metadata,\n dsn: this.getDsn(),\n tunnel: this._options.tunnel,\n },\n );\n this._sendEnvelope(envelope);\n }\n\n /**\n * Starts native client with dsn and options\n */\n private async _initNativeSdk(): Promise<void> {\n let didCallNativeInit = false;\n\n try {\n didCallNativeInit = await NATIVE.initNativeSdk(this._options);\n } catch (_) {\n this._showCannotConnectDialog();\n\n this._options.onReady?.({ didCallNativeInit: false });\n\n return;\n }\n this._options.onReady?.({ didCallNativeInit });\n }\n\n /**\n * If the user is in development mode, and the native nagger is enabled then it will show an alert.\n */\n private _showCannotConnectDialog(): void {\n if (__DEV__ && this._options.enableNativeNagger) {\n Alert.alert(\n 'Sentry',\n 'Warning, could not connect to Sentry native SDK.\\nIf you do not want to use the native component please pass `enableNative: false` in the options.\\nVisit: https://docs.sentry.io/platforms/react-native/#linking for more details.'\n );\n }\n }\n}\n"]}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/js/client.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGxF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAY1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,EAAE,WA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jC;oBAAS;gBACR,IAAI;oBACF,MAAA,MAAA,IAAI,CAAC,QAAQ,EAAC,OAAO,mDAAG,EAAE,iBAAiB,EAAE,EAAE;iBAChD;gBAAC,OAAO,KAAK,EAAE;oBACd,MAAM,CAAC,KAAK,CAAC,uCAAuC,EAAE,KAAK,CAAC,CAAC;iBAC9D;aACF;;KACF;IAED;;OAEG;IACK,wBAAwB;QAC9B,IAAI,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,EAAE;YAC/C,KAAK,CAAC,KAAK,CACT,QAAQ,EACR,qOAAqO,CACtO,CAAC;SACH;IACH,CAAC;IAED;;OAEG;IACK,qBAAqB,CAAC,QAAmB,EAAE,QAA8B;QAC/E,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;YACvB,MAAM,gBAAgB,GAAqB;gBACzC,EAAE,IAAI,EAAE,eAAe,EAAE;gBACzB;oBACE,SAAS,EAAE,sBAAsB,EAAE;oBACnC,gBAAgB,EAAE,QAAQ;iBAC3B;aACF,CAAC;YAEF,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;SACxC;IACH,CAAC;CACF","sourcesContent":["import { BrowserClient, defaultStackParser, makeFetchTransport } from '@sentry/browser';\nimport { BrowserTransportOptions } from '@sentry/browser/types/transports/types';\nimport { FetchImpl } from '@sentry/browser/types/transports/utils';\nimport { BaseClient } from '@sentry/core';\nimport {\n ClientReportEnvelope,\n ClientReportItem,\n Envelope,\n Event,\n EventHint,\n Outcome,\n SeverityLevel,\n Transport,\n UserFeedback,\n} from '@sentry/types';\nimport { dateTimestampInSeconds, logger, SentryError } from '@sentry/utils';\n// @ts-ignore LogBox introduced in RN 0.63\nimport { Alert, LogBox, YellowBox } from 'react-native';\n\nimport { defaultSdkInfo } from './integrations/sdkinfo';\nimport { ReactNativeClientOptions } from './options';\nimport { NativeTransport } from './transports/native';\nimport { createUserFeedbackEnvelope, items } from './utils/envelope';\nimport { mergeOutcomes } from './utils/outcome';\nimport { NATIVE } from './wrapper';\n\n/**\n * The Sentry React Native SDK Client.\n *\n * @see ReactNativeClientOptions for documentation on configuration options.\n * @see SentryClient for usage documentation.\n */\nexport class ReactNativeClient extends BaseClient<ReactNativeClientOptions> {\n\n private _outcomesBuffer: Outcome[];\n\n private readonly _browserClient: BrowserClient;\n\n /**\n * Creates a new React Native SDK instance.\n * @param options Configuration options for this SDK.\n */\n public constructor(options: ReactNativeClientOptions) {\n if (!options.transport) {\n options.transport = (options: BrowserTransportOptions, nativeFetch?: FetchImpl): Transport => {\n if (NATIVE.isNativeTransportAvailable()) {\n return new NativeTransport();\n }\n return makeFetchTransport(options, nativeFetch);\n };\n }\n options._metadata = options._metadata || {};\n options._metadata.sdk = options._metadata.sdk || defaultSdkInfo;\n super(options);\n\n this._outcomesBuffer = [];\n\n // This is a workaround for now using fetch on RN, this is a known issue in react-native and only generates a warning\n // YellowBox deprecated and replaced with with LogBox in RN 0.63\n if (LogBox) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n LogBox.ignoreLogs(['Require cycle:']);\n } else {\n // eslint-disable-next-line deprecation/deprecation\n YellowBox.ignoreWarnings(['Require cycle:']);\n }\n\n this._browserClient = new BrowserClient({\n dsn: options.dsn,\n transport: options.transport,\n transportOptions: options.transportOptions,\n stackParser: options.stackParser || defaultStackParser,\n integrations: [],\n _metadata: options._metadata,\n });\n\n void this._initNativeSdk();\n }\n\n\n /**\n * @inheritDoc\n */\n public eventFromException(_exception: unknown, _hint?: EventHint): PromiseLike<Event> {\n return this._browserClient.eventFromException(_exception, _hint);\n }\n\n /**\n * @inheritDoc\n */\n public eventFromMessage(_message: string, _level?: SeverityLevel, _hint?: EventHint): PromiseLike<Event> {\n return this._browserClient.eventFromMessage(_message, _level, _hint);\n }\n\n /**\n * If native client is available it will trigger a native crash.\n * Use this only for testing purposes.\n */\n public nativeCrash(): void {\n NATIVE.nativeCrash();\n }\n\n /**\n * @inheritDoc\n */\n public close(): PromiseLike<boolean> {\n // As super.close() flushes queued events, we wait for that to finish before closing the native SDK.\n return super.close().then((result: boolean) => {\n return NATIVE.closeNativeSdk().then(() => result) as PromiseLike<boolean>;\n });\n }\n\n /**\n * Sends user feedback to Sentry.\n */\n public captureUserFeedback(feedback: UserFeedback): void {\n const envelope = createUserFeedbackEnvelope(\n feedback,\n {\n metadata: this._options._metadata,\n dsn: this.getDsn(),\n tunnel: this._options.tunnel,\n },\n );\n this._sendEnvelope(envelope);\n }\n\n /**\n * @inheritdoc\n */\n protected _sendEnvelope(envelope: Envelope): void {\n const outcomes = this._clearOutcomes();\n this._outcomesBuffer = mergeOutcomes(this._outcomesBuffer, outcomes);\n\n if (this._options.sendClientReports) {\n this._attachClientReportTo(this._outcomesBuffer, envelope as ClientReportEnvelope);\n }\n\n let shouldClearOutcomesBuffer = true;\n if (this._transport && this._dsn) {\n this._transport.send(envelope)\n .then(null, reason => {\n if (reason instanceof SentryError) { // SentryError is thrown by SyncPromise\n shouldClearOutcomesBuffer = false;\n // If this is called asynchronously we want the _outcomesBuffer to be cleared\n logger.error('SentryError while sending event, keeping outcomes buffer:', reason);\n } else {\n logger.error('Error while sending event:', reason);\n }\n });\n } else {\n logger.error('Transport disabled');\n }\n\n if (shouldClearOutcomesBuffer) {\n this._outcomesBuffer = []; // if send fails synchronously the _outcomesBuffer will stay intact\n }\n }\n\n /**\n * Starts native client with dsn and options\n */\n private async _initNativeSdk(): Promise<void> {\n let didCallNativeInit = false;\n\n try {\n didCallNativeInit = await NATIVE.initNativeSdk(this._options);\n } catch (_) {\n this._showCannotConnectDialog();\n } finally {\n try {\n this._options.onReady?.({ didCallNativeInit });\n } catch (error) {\n logger.error('The OnReady callback threw an error: ', error);\n }\n }\n }\n\n /**\n * If the user is in development mode, and the native nagger is enabled then it will show an alert.\n */\n private _showCannotConnectDialog(): void {\n if (__DEV__ && this._options.enableNativeNagger) {\n Alert.alert(\n 'Sentry',\n 'Warning, could not connect to Sentry native SDK.\\nIf you do not want to use the native component please pass `enableNative: false` in the options.\\nVisit: https://docs.sentry.io/platforms/react-native/#linking for more details.'\n );\n }\n }\n\n /**\n * Attaches a client report from outcomes to the envelope.\n */\n private _attachClientReportTo(outcomes: Outcome[], envelope: ClientReportEnvelope): void {\n if (outcomes.length > 0) {\n const clientReportItem: ClientReportItem = [\n { type: 'client_report' },\n {\n timestamp: dateTimestampInSeconds(),\n discarded_events: outcomes,\n },\n ];\n\n envelope[items].push(clientReportItem);\n }\n }\n}\n"]}
@@ -1,12 +1,12 @@
1
1
  export { Breadcrumb, Request, SdkInfo, Event, Exception, StackFrame, Stacktrace, Thread, User, UserFeedback, } from '@sentry/types';
2
- export { addGlobalEventProcessor, addBreadcrumb, captureException, captureEvent, captureMessage, configureScope, getHubFromCarrier, getCurrentHub, Hub, Scope, setContext, setExtra, setExtras, setTag, setTags, setUser, startTransaction, withScope, } from '@sentry/core';
2
+ export { addGlobalEventProcessor, addBreadcrumb, captureException, captureEvent, captureMessage, getHubFromCarrier, getCurrentHub, Hub, Scope, setContext, setExtra, setExtras, setTag, setTags, setUser, startTransaction, } from '@sentry/core';
3
3
  import '@sentry/tracing';
4
4
  export { Integrations as BrowserIntegrations, ErrorBoundary, withErrorBoundary, createReduxEnhancer, Profiler, useProfiler, withProfiler, } from '@sentry/react';
5
5
  import * as Integrations from './integrations';
6
6
  import { SDK_NAME, SDK_VERSION } from './version';
7
7
  export { ReactNativeOptions } from './options';
8
8
  export { ReactNativeClient } from './client';
9
- export { init, wrap, setDist, setRelease, nativeCrash, flush, close, captureUserFeedback, } from './sdk';
9
+ export { init, wrap, setDist, setRelease, nativeCrash, flush, close, captureUserFeedback, withScope, configureScope, } from './sdk';
10
10
  export { TouchEventBoundary, withTouchEventBoundary } from './touchevents';
11
11
  export { ReactNativeTracing, ReactNavigationV4Instrumentation, ReactNavigationV5Instrumentation, ReactNavigationInstrumentation, ReactNativeNavigationInstrumentation, RoutingInstrumentation, ReactNavigationTransactionContext, } from './tracing';
12
12
  export { Integrations, SDK_NAME, SDK_VERSION };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/js/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,OAAO,EACP,OAAO,EACP,KAAK,EACL,SAAS,EACT,UAAU,EACV,UAAU,EACV,MAAM,EACN,IAAI,EACJ,YAAY,GACb,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,uBAAuB,EACvB,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,GAAG,EACH,KAAK,EACL,UAAU,EACV,QAAQ,EACR,SAAS,EACT,MAAM,EACN,OAAO,EACP,OAAO,EACP,gBAAgB,EAChB,SAAS,GACV,MAAM,cAAc,CAAC;AAItB,OAAO,iBAAiB,CAAC;AAMzB,OAAO,EACL,YAAY,IAAI,mBAAmB,EACnC,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,QAAQ,EACR,WAAW,EACX,YAAY,GACb,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,YAAY,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,OAAO,EACL,IAAI,EACJ,IAAI,EAEJ,OAAO,EAEP,UAAU,EACV,WAAW,EACX,KAAK,EACL,KAAK,EACL,mBAAmB,GACpB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAE3E,OAAO,EACL,kBAAkB,EAClB,gCAAgC,EAEhC,gCAAgC,EAChC,8BAA8B,EAC9B,oCAAoC,EACpC,sBAAsB,EACtB,iCAAiC,GAClC,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,Y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YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC"}
package/dist/js/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { addGlobalEventProcessor, addBreadcrumb, captureException, captureEvent, captureMessage, configureScope, getHubFromCarrier, getCurrentHub, Hub, Scope, setContext, setExtra, setExtras, setTag, setTags, setUser, startTransaction, withScope, } from '@sentry/core';
1
+ export { addGlobalEventProcessor, addBreadcrumb, captureException, captureEvent, captureMessage, getHubFromCarrier, getCurrentHub, Hub, Scope, setContext, setExtra, setExtras, setTag, setTags, setUser, startTransaction, } from '@sentry/core';
2
2
  // We need to import it so we patch the hub with global functions
3
3
  // aka. this has side effects
4
4
  import '@sentry/tracing';
@@ -13,7 +13,7 @@ export { init, wrap,
13
13
  // eslint-disable-next-line deprecation/deprecation
14
14
  setDist,
15
15
  // eslint-disable-next-line deprecation/deprecation
16
- setRelease, nativeCrash, flush, close, captureUserFeedback, } from './sdk';
16
+ setRelease, nativeCrash, flush, close, captureUserFeedback, withScope, configureScope, } from './sdk';
17
17
  export { TouchEventBoundary, withTouchEventBoundary } from './touchevents';
18
18
  export { ReactNativeTracing, ReactNavigationV4Instrumentation,
19
19
  // eslint-disable-next-line deprecation/deprecation
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/js/index.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,uBAAuB,EACvB,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,GAAG,EACH,KAAK,EACL,UAAU,EACV,QAAQ,EACR,SAAS,EACT,MAAM,EACN,OAAO,EACP,OAAO,EACP,gBAAgB,EAChB,SAAS,GACV,MAAM,cAAc,CAAC;AAEtB,iEAAiE;AACjE,6BAA6B;AAC7B,OAAO,iBAAiB,CAAC;AAEzB,kGAAkG;AAClG,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,qBAAqB,EAAE,CAAC;AAExB,OAAO,EACL,YAAY,IAAI,mBAAmB,EACnC,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,QAAQ,EACR,WAAW,EACX,YAAY,GACb,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,YAAY,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAElD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,OAAO,EACL,IAAI,EACJ,IAAI;AACJ,mDAAmD;AACnD,OAAO;AACP,mDAAmD;AACnD,UAAU,EACV,WAAW,EACX,KAAK,EACL,KAAK,EACL,mBAAmB,GACpB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAE3E,OAAO,EACL,kBAAkB,EAClB,gCAAgC;AAChC,mDAAmD;AACnD,gCAAgC,EAChC,8BAA8B,EAC9B,oCAAoC,EACpC,sBAAsB,GAEvB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC","sourcesContent":["export {\n Breadcrumb,\n Request,\n SdkInfo,\n Event,\n Exception,\n StackFrame,\n Stacktrace,\n Thread,\n User,\n UserFeedback,\n} from '@sentry/types';\n\nexport {\n addGlobalEventProcessor,\n addBreadcrumb,\n captureException,\n captureEvent,\n captureMessage,\n configureScope,\n getHubFromCarrier,\n getCurrentHub,\n Hub,\n Scope,\n setContext,\n setExtra,\n setExtras,\n setTag,\n setTags,\n setUser,\n startTransaction,\n withScope,\n} from '@sentry/core';\n\n// We need to import it so we patch the hub with global functions\n// aka. this has side effects\nimport '@sentry/tracing';\n\n// Add the React Native SDK's own tracing extensions, this needs to happen AFTER @sentry/tracing's\nimport { _addTracingExtensions } from './measurements';\n_addTracingExtensions();\n\nexport {\n Integrations as BrowserIntegrations,\n ErrorBoundary,\n withErrorBoundary,\n createReduxEnhancer,\n Profiler,\n useProfiler,\n withProfiler,\n} from '@sentry/react';\n\nimport * as Integrations from './integrations';\nimport { SDK_NAME, SDK_VERSION } from './version';\nexport { ReactNativeOptions } from './options';\nexport { ReactNativeClient } from './client';\n\nexport {\n init,\n wrap,\n // eslint-disable-next-line deprecation/deprecation\n setDist,\n // eslint-disable-next-line deprecation/deprecation\n setRelease,\n nativeCrash,\n flush,\n close,\n captureUserFeedback,\n} from './sdk';\nexport { TouchEventBoundary, withTouchEventBoundary } from './touchevents';\n\nexport {\n ReactNativeTracing,\n ReactNavigationV4Instrumentation,\n // eslint-disable-next-line deprecation/deprecation\n ReactNavigationV5Instrumentation,\n ReactNavigationInstrumentation,\n ReactNativeNavigationInstrumentation,\n RoutingInstrumentation,\n ReactNavigationTransactionContext,\n} from './tracing';\n\nexport { Integrations, SDK_NAME, SDK_VERSION };\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/js/index.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,uBAAuB,EACvB,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,GAAG,EACH,KAAK,EACL,UAAU,EACV,QAAQ,EACR,SAAS,EACT,MAAM,EACN,OAAO,EACP,OAAO,EACP,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAEtB,iEAAiE;AACjE,6BAA6B;AAC7B,OAAO,iBAAiB,CAAC;AAEzB,kGAAkG;AAClG,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,qBAAqB,EAAE,CAAC;AAExB,OAAO,EACL,YAAY,IAAI,mBAAmB,EACnC,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,QAAQ,EACR,WAAW,EACX,YAAY,GACb,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,YAAY,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAElD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,OAAO,EACL,IAAI,EACJ,IAAI;AACJ,mDAAmD;AACnD,OAAO;AACP,mDAAmD;AACnD,UAAU,EACV,WAAW,EACX,KAAK,EACL,KAAK,EACL,mBAAmB,EACnB,SAAS,EACT,cAAc,GACf,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAE3E,OAAO,EACL,kBAAkB,EAClB,gCAAgC;AAChC,mDAAmD;AACnD,gCAAgC,EAChC,8BAA8B,EAC9B,oCAAoC,EACpC,sBAAsB,GAEvB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC","sourcesContent":["export {\n Breadcrumb,\n Request,\n SdkInfo,\n Event,\n Exception,\n StackFrame,\n Stacktrace,\n Thread,\n User,\n UserFeedback,\n} from '@sentry/types';\n\nexport {\n addGlobalEventProcessor,\n addBreadcrumb,\n captureException,\n captureEvent,\n captureMessage,\n getHubFromCarrier,\n getCurrentHub,\n Hub,\n Scope,\n setContext,\n setExtra,\n setExtras,\n setTag,\n setTags,\n setUser,\n startTransaction,\n} from '@sentry/core';\n\n// We need to import it so we patch the hub with global functions\n// aka. this has side effects\nimport '@sentry/tracing';\n\n// Add the React Native SDK's own tracing extensions, this needs to happen AFTER @sentry/tracing's\nimport { _addTracingExtensions } from './measurements';\n_addTracingExtensions();\n\nexport {\n Integrations as BrowserIntegrations,\n ErrorBoundary,\n withErrorBoundary,\n createReduxEnhancer,\n Profiler,\n useProfiler,\n withProfiler,\n} from '@sentry/react';\n\nimport * as Integrations from './integrations';\nimport { SDK_NAME, SDK_VERSION } from './version';\nexport { ReactNativeOptions } from './options';\nexport { ReactNativeClient } from './client';\n\nexport {\n init,\n wrap,\n // eslint-disable-next-line deprecation/deprecation\n setDist,\n // eslint-disable-next-line deprecation/deprecation\n setRelease,\n nativeCrash,\n flush,\n close,\n captureUserFeedback,\n withScope,\n configureScope,\n} from './sdk';\nexport { TouchEventBoundary, withTouchEventBoundary } from './touchevents';\n\nexport {\n ReactNativeTracing,\n ReactNavigationV4Instrumentation,\n // eslint-disable-next-line deprecation/deprecation\n ReactNavigationV5Instrumentation,\n ReactNavigationInstrumentation,\n ReactNativeNavigationInstrumentation,\n RoutingInstrumentation,\n ReactNavigationTransactionContext,\n} from './tracing';\n\nexport { Integrations, SDK_NAME, SDK_VERSION };\n"]}
package/dist/js/sdk.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { UserFeedback } from '@sentry/types';
1
+ import { Hub } from '@sentry/hub';
2
+ import { Scope, UserFeedback } from '@sentry/types';
2
3
  import * as React from 'react';
3
4
  import { ReactNativeOptions, ReactNativeWrapperOptions } from './options';
4
5
  /**
@@ -39,4 +40,23 @@ export declare function close(): Promise<void>;
39
40
  * Captures user feedback and sends it to Sentry.
40
41
  */
41
42
  export declare function captureUserFeedback(feedback: UserFeedback): void;
43
+ /**
44
+ * Creates a new scope with and executes the given operation within.
45
+ * The scope is automatically removed once the operation
46
+ * finishes or throws.
47
+ *
48
+ * This is essentially a convenience function for:
49
+ *
50
+ * pushScope();
51
+ * callback();
52
+ * popScope();
53
+ *
54
+ * @param callback that will be enclosed into push/popScope.
55
+ */
56
+ export declare function withScope(callback: (scope: Scope) => void): ReturnType<Hub['withScope']>;
57
+ /**
58
+ * Callback to set context information onto the scope.
59
+ * @param callback Callback function that receives Scope.
60
+ */
61
+ export declare function configureScope(callback: (scope: Scope) => void): ReturnType<Hub['configureScope']>;
42
62
  //# sourceMappingURL=sdk.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/js/sdk.tsx"],"names":[],"mappings":"AAQA,OAAO,EAA2B,YAAY,EAAE,MAAM,eAAe,CAAC;AAEtE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAW/B,OAAO,EAA4B,kBAAkB,EAAE,yB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K,CAAC,aAAa,CAAC,CAAC,CAAC,CAsBxB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEhD;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE1C;AAED;;;GAGG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAKlC;AAED;;;GAGG;AACH,wBAAsB,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,CAe9C;AAED;;GAEG;AACH,wBAAsB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAU3C;AAED;;GAEG;AACF,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAEhE;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CASxF;AAED;;;GAGG;AACF,wBAAgB,cAAc,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CASnG"}
package/dist/js/sdk.js CHANGED
@@ -12,6 +12,7 @@ import { TouchEventBoundary } from './touchevents';
12
12
  import { ReactNativeProfiler, ReactNativeTracing } from './tracing';
13
13
  import { makeReactNativeTransport } from './transports/native';
14
14
  import { makeUtf8TextEncoder } from './transports/TextEncoder';
15
+ import { safeFactory, safeTracesSampler } from './utils/safe';
15
16
  const IGNORED_DEFAULT_INTEGRATIONS = [
16
17
  'GlobalHandlers',
17
18
  'TryCatch',
@@ -27,6 +28,7 @@ const DEFAULT_OPTIONS = {
27
28
  transportOptions: {
28
29
  textEncoder: makeUtf8TextEncoder(),
29
30
  },
31
+ sendClientReports: true,
30
32
  };
31
33
  /**
32
34
  * Inits the SDK and returns the final options.
@@ -35,7 +37,9 @@ export function init(passedOptions) {
35
37
  var _a;
36
38
  const reactNativeHub = new Hub(undefined, new ReactNativeScope());
37
39
  makeMain(reactNativeHub);
38
- const options = Object.assign(Object.assign(Object.assign({}, DEFAULT_OPTIONS), passedOptions), { transport: passedOptions.transport || makeReactNativeTransport, transportOptions: Object.assign(Object.assign({}, DEFAULT_OPTIONS.transportOptions), ((_a = passedOptions.transportOptions) !== null && _a !== void 0 ? _a : {})), integrations: [], stackParser: stackParserFromStackParserOptions(passedOptions.stackParser || defaultStackParser) });
40
+ const options = Object.assign(Object.assign(Object.assign({}, DEFAULT_OPTIONS), passedOptions), {
41
+ // If custom transport factory fails the SDK won't initialize
42
+ transport: passedOptions.transport || makeReactNativeTransport, transportOptions: Object.assign(Object.assign({}, DEFAULT_OPTIONS.transportOptions), ((_a = passedOptions.transportOptions) !== null && _a !== void 0 ? _a : {})), integrations: [], stackParser: stackParserFromStackParserOptions(passedOptions.stackParser || defaultStackParser), beforeBreadcrumb: safeFactory(passedOptions.beforeBreadcrumb, { loggerMessage: 'The beforeBreadcrumb threw an error' }), initialScope: safeFactory(passedOptions.initialScope, { loggerMessage: 'The initialScope threw an error' }), tracesSampler: safeTracesSampler(passedOptions.tracesSampler) });
39
43
  // As long as tracing is opt in with either one of these options, then this is how we determine tracing is enabled.
40
44
  const tracingEnabled = typeof options.tracesSampler !== 'undefined' ||
41
45
  typeof options.tracesSampleRate !== 'undefined';
@@ -83,7 +87,7 @@ export function init(passedOptions) {
83
87
  }
84
88
  }
85
89
  options.integrations = getIntegrationsToSetup({
86
- integrations: passedOptions.integrations,
90
+ integrations: safeFactory(passedOptions.integrations, { loggerMessage: 'The integrations threw an error' }),
87
91
  defaultIntegrations,
88
92
  });
89
93
  initAndBind(ReactNativeClient, options);
@@ -180,4 +184,43 @@ export function captureUserFeedback(feedback) {
180
184
  var _a;
181
185
  (_a = getCurrentHub().getClient()) === null || _a === void 0 ? void 0 : _a.captureUserFeedback(feedback);
182
186
  }
187
+ /**
188
+ * Creates a new scope with and executes the given operation within.
189
+ * The scope is automatically removed once the operation
190
+ * finishes or throws.
191
+ *
192
+ * This is essentially a convenience function for:
193
+ *
194
+ * pushScope();
195
+ * callback();
196
+ * popScope();
197
+ *
198
+ * @param callback that will be enclosed into push/popScope.
199
+ */
200
+ export function withScope(callback) {
201
+ const safeCallback = (scope) => {
202
+ try {
203
+ callback(scope);
204
+ }
205
+ catch (e) {
206
+ logger.error('Error while running withScope callback', e);
207
+ }
208
+ };
209
+ getCurrentHub().withScope(safeCallback);
210
+ }
211
+ /**
212
+ * Callback to set context information onto the scope.
213
+ * @param callback Callback function that receives Scope.
214
+ */
215
+ export function configureScope(callback) {
216
+ const safeCallback = (scope) => {
217
+ try {
218
+ callback(scope);
219
+ }
220
+ catch (e) {
221
+ logger.error('Error while running configureScope callback', e);
222
+ }
223
+ };
224
+ getCurrentHub().configureScope(safeCallback);
225
+ }
183
226
  //# sourceMappingURL=sdk.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/js/sdk.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EACL,mBAAmB,IAAI,wBAAwB,EAC/C,kBAAkB,EAClB,aAAa,GACd,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,iCAAiC,EAAE,MAAM,eAAe,CAAC;AAC3F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,wBAAwB,EACxB,OAAO,EACP,OAAO,GACR,MAAM,gBAAgB,CAAC;AAExB,OAA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AAM,CAAC,KAAK,EAAE,CAAC;aACtB;SACF;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;SACzC;IACH,CAAC;CAAA;AAED;;GAEG;AACF,MAAM,UAAU,mBAAmB,CAAC,QAAsB;;IACzD,MAAA,aAAa,EAAE,CAAC,SAAS,EAAqB,0CAAE,mBAAmB,CAAC,QAAQ,EAAE;AAChF,CAAC","sourcesContent":["import { getIntegrationsToSetup, initAndBind, setExtra } from '@sentry/core';\nimport { Hub, makeMain } from '@sentry/hub';\nimport { RewriteFrames } from '@sentry/integrations';\nimport {\n defaultIntegrations as reactDefaultIntegrations,\n defaultStackParser,\n getCurrentHub,\n} from '@sentry/react';\nimport { Integration, StackFrame, UserFeedback } from '@sentry/types';\nimport { getGlobalObject, logger, stackParserFromStackParserOptions } from '@sentry/utils';\nimport * as React from 'react';\n\nimport { ReactNativeClient } from './client';\nimport {\n DebugSymbolicator,\n DeviceContext,\n EventOrigin,\n ReactNativeErrorHandlers,\n Release,\n SdkInfo,\n} from './integrations';\nimport { ReactNativeClientOptions, ReactNativeOptions, ReactNativeWrapperOptions } from './options';\nimport { ReactNativeScope } from './scope';\nimport { TouchEventBoundary } from './touchevents';\nimport { ReactNativeProfiler, ReactNativeTracing } from './tracing';\nimport { makeReactNativeTransport } from './transports/native';\nimport { makeUtf8TextEncoder } from './transports/TextEncoder';\n\nconst IGNORED_DEFAULT_INTEGRATIONS = [\n 'GlobalHandlers', // We will use the react-native internal handlers\n 'TryCatch', // We don't need this\n];\nconst DEFAULT_OPTIONS: ReactNativeOptions = {\n enableNative: true,\n enableNativeCrashHandling: true,\n enableNativeNagger: true,\n autoInitializeNativeSdk: true,\n enableAutoPerformanceTracking: true,\n enableOutOfMemoryTracking: true,\n patchGlobalPromise: true,\n transportOptions: {\n textEncoder: makeUtf8TextEncoder(),\n },\n};\n\n/**\n * Inits the SDK and returns the final options.\n */\nexport function init(passedOptions: ReactNativeOptions): void {\n const reactNativeHub = new Hub(undefined, new ReactNativeScope());\n makeMain(reactNativeHub);\n\n const options: ReactNativeClientOptions = {\n ...DEFAULT_OPTIONS,\n ...passedOptions,\n transport: passedOptions.transport || makeReactNativeTransport,\n transportOptions: {\n ...DEFAULT_OPTIONS.transportOptions,\n ...(passedOptions.transportOptions ?? {}),\n },\n integrations: [],\n stackParser: stackParserFromStackParserOptions(passedOptions.stackParser || defaultStackParser)\n };\n\n // As long as tracing is opt in with either one of these options, then this is how we determine tracing is enabled.\n const tracingEnabled =\n typeof options.tracesSampler !== 'undefined' ||\n typeof options.tracesSampleRate !== 'undefined';\n\n const defaultIntegrations: Integration[] = passedOptions.defaultIntegrations || [];\n if (passedOptions.defaultIntegrations === undefined) {\n defaultIntegrations.push(new ReactNativeErrorHandlers({\n patchGlobalPromise: options.patchGlobalPromise,\n }));\n defaultIntegrations.push(new Release());\n defaultIntegrations.push(...[\n ...reactDefaultIntegrations.filter(\n (i) => !IGNORED_DEFAULT_INTEGRATIONS.includes(i.name)\n ),\n ]);\n\n defaultIntegrations.push(new EventOrigin());\n defaultIntegrations.push(new SdkInfo());\n\n if (__DEV__) {\n defaultIntegrations.push(new DebugSymbolicator());\n }\n\n defaultIntegrations.push(new RewriteFrames({\n iteratee: (frame: StackFrame) => {\n if (frame.filename) {\n frame.filename = frame.filename\n .replace(/^file:\\/\\//, '')\n .replace(/^address at /, '')\n .replace(/^.*\\/[^.]+(\\.app|CodePush|.*(?=\\/))/, '');\n\n if (\n frame.filename !== '[native code]' &&\n frame.filename !== 'native'\n ) {\n const appPrefix = 'app://';\n // We always want to have a triple slash\n frame.filename =\n frame.filename.indexOf('/') === 0\n ? `${appPrefix}${frame.filename}`\n : `${appPrefix}/${frame.filename}`;\n }\n }\n return frame;\n },\n }));\n if (options.enableNative) {\n defaultIntegrations.push(new DeviceContext());\n }\n if (tracingEnabled) {\n if (options.enableAutoPerformanceTracking) {\n defaultIntegrations.push(new ReactNativeTracing());\n }\n }\n }\n\n options.integrations = getIntegrationsToSetup({\n integrations: passedOptions.integrations,\n defaultIntegrations,\n });\n initAndBind(ReactNativeClient, options);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-explicit-any\n if (getGlobalObject<any>().HermesInternal) {\n getCurrentHub().setTag('hermes', 'true');\n }\n}\n\n/**\n * Inits the Sentry React Native SDK with automatic instrumentation and wrapped features.\n */\nexport function wrap<P>(\n RootComponent: React.ComponentType<P>,\n options?: ReactNativeWrapperOptions\n): React.ComponentType<P> {\n const tracingIntegration = getCurrentHub().getIntegration(ReactNativeTracing);\n if (tracingIntegration) {\n tracingIntegration.useAppStartWithProfiler = true;\n }\n\n const profilerProps = {\n ...(options?.profilerProps ?? {}),\n name: RootComponent.displayName ?? 'Root',\n };\n\n const RootApp: React.FC<P> = (appProps) => {\n return (\n <TouchEventBoundary {...(options?.touchEventBoundaryProps ?? {})}>\n <ReactNativeProfiler {...profilerProps}>\n <RootComponent {...appProps} />\n </ReactNativeProfiler>\n </TouchEventBoundary>\n );\n };\n\n return RootApp;\n}\n\n/**\n * Deprecated. Sets the release on the event.\n * NOTE: Does not set the release on sessions.\n * @deprecated\n */\nexport function setRelease(release: string): void {\n setExtra('__sentry_release', release);\n}\n\n/**\n * Deprecated. Sets the dist on the event.\n * NOTE: Does not set the dist on sessions.\n * @deprecated\n */\nexport function setDist(dist: string): void {\n setExtra('__sentry_dist', dist);\n}\n\n/**\n * If native client is available it will trigger a native crash.\n * Use this only for testing purposes.\n */\nexport function nativeCrash(): void {\n const client = getCurrentHub().getClient<ReactNativeClient>();\n if (client) {\n client.nativeCrash();\n }\n}\n\n/**\n * Flushes all pending events in the queue to disk.\n * Use this before applying any realtime updates such as code-push or expo updates.\n */\nexport async function flush(): Promise<boolean> {\n try {\n const client = getCurrentHub().getClient<ReactNativeClient>();\n\n if (client) {\n const result = await client.flush();\n\n return result;\n }\n // eslint-disable-next-line no-empty\n } catch (_) { }\n\n logger.error('Failed to flush the event queue.');\n\n return false;\n}\n\n/**\n * Closes the SDK, stops sending events.\n */\nexport async function close(): Promise<void> {\n try {\n const client = getCurrentHub().getClient<ReactNativeClient>();\n\n if (client) {\n await client.close();\n }\n } catch (e) {\n logger.error('Failed to close the SDK');\n }\n}\n\n/**\n * Captures user feedback and sends it to Sentry.\n */\n export function captureUserFeedback(feedback: UserFeedback): void {\n getCurrentHub().getClient<ReactNativeClient>()?.captureUserFeedback(feedback);\n}\n"]}
1
+ {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/js/sdk.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EACL,mBAAmB,IAAI,wBAAwB,EAC/C,kBAAkB,EAClB,aAAa,GACd,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,iCAAiC,EAAE,MAAM,eAAe,CAAC;AAC3F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,wBAAwB,EACxB,OAAO,EACP,OAAO,GACR,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,iBAAiB,E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zB,IAAI;YACF,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC,SAAS,EAAqB,CAAC;YAE9D,IAAI,MAAM,EAAE;gBACV,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;aACtB;SACF;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;SACzC;IACH,CAAC;CAAA;AAED;;GAEG;AACF,MAAM,UAAU,mBAAmB,CAAC,QAAsB;;IACzD,MAAA,aAAa,EAAE,CAAC,SAAS,EAAqB,0CAAE,mBAAmB,CAAC,QAAQ,EAAE;AAC/E,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,SAAS,CAAC,QAAgC;IACxD,MAAM,YAAY,GAAG,CAAC,KAAY,EAAQ,EAAE;QAC1C,IAAI;YACF,QAAQ,CAAC,KAAK,CAAC,CAAC;SACjB;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,KAAK,CAAC,wCAAwC,EAAE,CAAC,CAAC,CAAC;SAC3D;IACH,CAAC,CAAC;IACF,aAAa,EAAE,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;AAC1C,CAAC;AAED;;;GAGG;AACF,MAAM,UAAU,cAAc,CAAC,QAAgC;IAC9D,MAAM,YAAY,GAAG,CAAC,KAAY,EAAQ,EAAE;QAC1C,IAAI;YACF,QAAQ,CAAC,KAAK,CAAC,CAAC;SACjB;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,KAAK,CAAC,6CAA6C,EAAE,CAAC,CAAC,CAAC;SAChE;IACH,CAAC,CAAC;IACF,aAAa,EAAE,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import { getIntegrationsToSetup, initAndBind, setExtra } from '@sentry/core';\nimport { Hub, makeMain } from '@sentry/hub';\nimport { RewriteFrames } from '@sentry/integrations';\nimport {\n defaultIntegrations as reactDefaultIntegrations,\n defaultStackParser,\n getCurrentHub,\n} from '@sentry/react';\nimport { Integration, Scope, StackFrame, UserFeedback } from '@sentry/types';\nimport { getGlobalObject, logger, stackParserFromStackParserOptions } from '@sentry/utils';\nimport * as React from 'react';\n\nimport { ReactNativeClient } from './client';\nimport {\n DebugSymbolicator,\n DeviceContext,\n EventOrigin,\n ReactNativeErrorHandlers,\n Release,\n SdkInfo,\n} from './integrations';\nimport { ReactNativeClientOptions, ReactNativeOptions, ReactNativeWrapperOptions } from './options';\nimport { ReactNativeScope } from './scope';\nimport { TouchEventBoundary } from './touchevents';\nimport { ReactNativeProfiler, ReactNativeTracing } from './tracing';\nimport { makeReactNativeTransport } from './transports/native';\nimport { makeUtf8TextEncoder } from './transports/TextEncoder';\nimport { safeFactory, safeTracesSampler } from './utils/safe';\n\nconst IGNORED_DEFAULT_INTEGRATIONS = [\n 'GlobalHandlers', // We will use the react-native internal handlers\n 'TryCatch', // We don't need this\n];\nconst DEFAULT_OPTIONS: ReactNativeOptions = {\n enableNative: true,\n enableNativeCrashHandling: true,\n enableNativeNagger: true,\n autoInitializeNativeSdk: true,\n enableAutoPerformanceTracking: true,\n enableOutOfMemoryTracking: true,\n patchGlobalPromise: true,\n transportOptions: {\n textEncoder: makeUtf8TextEncoder(),\n },\n sendClientReports: true,\n};\n\n/**\n * Inits the SDK and returns the final options.\n */\nexport function init(passedOptions: ReactNativeOptions): void {\n const reactNativeHub = new Hub(undefined, new ReactNativeScope());\n makeMain(reactNativeHub);\n\n const options: ReactNativeClientOptions = {\n ...DEFAULT_OPTIONS,\n ...passedOptions,\n // If custom transport factory fails the SDK won't initialize\n transport: passedOptions.transport || makeReactNativeTransport,\n transportOptions: {\n ...DEFAULT_OPTIONS.transportOptions,\n ...(passedOptions.transportOptions ?? {}),\n },\n integrations: [],\n stackParser: stackParserFromStackParserOptions(passedOptions.stackParser || defaultStackParser),\n beforeBreadcrumb: safeFactory(passedOptions.beforeBreadcrumb, { loggerMessage: 'The beforeBreadcrumb threw an error' }),\n initialScope: safeFactory(passedOptions.initialScope, { loggerMessage: 'The initialScope threw an error' }),\n tracesSampler: safeTracesSampler(passedOptions.tracesSampler),\n };\n\n // As long as tracing is opt in with either one of these options, then this is how we determine tracing is enabled.\n const tracingEnabled =\n typeof options.tracesSampler !== 'undefined' ||\n typeof options.tracesSampleRate !== 'undefined';\n\n const defaultIntegrations: Integration[] = passedOptions.defaultIntegrations || [];\n if (passedOptions.defaultIntegrations === undefined) {\n defaultIntegrations.push(new ReactNativeErrorHandlers({\n patchGlobalPromise: options.patchGlobalPromise,\n }));\n defaultIntegrations.push(new Release());\n defaultIntegrations.push(...[\n ...reactDefaultIntegrations.filter(\n (i) => !IGNORED_DEFAULT_INTEGRATIONS.includes(i.name)\n ),\n ]);\n\n defaultIntegrations.push(new EventOrigin());\n defaultIntegrations.push(new SdkInfo());\n\n if (__DEV__) {\n defaultIntegrations.push(new DebugSymbolicator());\n }\n\n defaultIntegrations.push(new RewriteFrames({\n iteratee: (frame: StackFrame) => {\n if (frame.filename) {\n frame.filename = frame.filename\n .replace(/^file:\\/\\//, '')\n .replace(/^address at /, '')\n .replace(/^.*\\/[^.]+(\\.app|CodePush|.*(?=\\/))/, '');\n\n if (\n frame.filename !== '[native code]' &&\n frame.filename !== 'native'\n ) {\n const appPrefix = 'app://';\n // We always want to have a triple slash\n frame.filename =\n frame.filename.indexOf('/') === 0\n ? `${appPrefix}${frame.filename}`\n : `${appPrefix}/${frame.filename}`;\n }\n }\n return frame;\n },\n }));\n if (options.enableNative) {\n defaultIntegrations.push(new DeviceContext());\n }\n if (tracingEnabled) {\n if (options.enableAutoPerformanceTracking) {\n defaultIntegrations.push(new ReactNativeTracing());\n }\n }\n }\n\n options.integrations = getIntegrationsToSetup({\n integrations: safeFactory(passedOptions.integrations, { loggerMessage: 'The integrations threw an error' }),\n defaultIntegrations,\n });\n initAndBind(ReactNativeClient, options);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-explicit-any\n if (getGlobalObject<any>().HermesInternal) {\n getCurrentHub().setTag('hermes', 'true');\n }\n}\n\n/**\n * Inits the Sentry React Native SDK with automatic instrumentation and wrapped features.\n */\nexport function wrap<P>(\n RootComponent: React.ComponentType<P>,\n options?: ReactNativeWrapperOptions\n): React.ComponentType<P> {\n const tracingIntegration = getCurrentHub().getIntegration(ReactNativeTracing);\n if (tracingIntegration) {\n tracingIntegration.useAppStartWithProfiler = true;\n }\n\n const profilerProps = {\n ...(options?.profilerProps ?? {}),\n name: RootComponent.displayName ?? 'Root',\n };\n\n const RootApp: React.FC<P> = (appProps) => {\n return (\n <TouchEventBoundary {...(options?.touchEventBoundaryProps ?? {})}>\n <ReactNativeProfiler {...profilerProps}>\n <RootComponent {...appProps} />\n </ReactNativeProfiler>\n </TouchEventBoundary>\n );\n };\n\n return RootApp;\n}\n\n/**\n * Deprecated. Sets the release on the event.\n * NOTE: Does not set the release on sessions.\n * @deprecated\n */\nexport function setRelease(release: string): void {\n setExtra('__sentry_release', release);\n}\n\n/**\n * Deprecated. Sets the dist on the event.\n * NOTE: Does not set the dist on sessions.\n * @deprecated\n */\nexport function setDist(dist: string): void {\n setExtra('__sentry_dist', dist);\n}\n\n/**\n * If native client is available it will trigger a native crash.\n * Use this only for testing purposes.\n */\nexport function nativeCrash(): void {\n const client = getCurrentHub().getClient<ReactNativeClient>();\n if (client) {\n client.nativeCrash();\n }\n}\n\n/**\n * Flushes all pending events in the queue to disk.\n * Use this before applying any realtime updates such as code-push or expo updates.\n */\nexport async function flush(): Promise<boolean> {\n try {\n const client = getCurrentHub().getClient<ReactNativeClient>();\n\n if (client) {\n const result = await client.flush();\n\n return result;\n }\n // eslint-disable-next-line no-empty\n } catch (_) { }\n\n logger.error('Failed to flush the event queue.');\n\n return false;\n}\n\n/**\n * Closes the SDK, stops sending events.\n */\nexport async function close(): Promise<void> {\n try {\n const client = getCurrentHub().getClient<ReactNativeClient>();\n\n if (client) {\n await client.close();\n }\n } catch (e) {\n logger.error('Failed to close the SDK');\n }\n}\n\n/**\n * Captures user feedback and sends it to Sentry.\n */\n export function captureUserFeedback(feedback: UserFeedback): void {\n getCurrentHub().getClient<ReactNativeClient>()?.captureUserFeedback(feedback);\n }\n\n/**\n * Creates a new scope with and executes the given operation within.\n * The scope is automatically removed once the operation\n * finishes or throws.\n *\n * This is essentially a convenience function for:\n *\n * pushScope();\n * callback();\n * popScope();\n *\n * @param callback that will be enclosed into push/popScope.\n */\nexport function withScope(callback: (scope: Scope) => void): ReturnType<Hub['withScope']> {\n const safeCallback = (scope: Scope): void => {\n try {\n callback(scope);\n } catch (e) {\n logger.error('Error while running withScope callback', e);\n }\n };\n getCurrentHub().withScope(safeCallback);\n}\n\n/**\n * Callback to set context information onto the scope.\n * @param callback Callback function that receives Scope.\n */\n export function configureScope(callback: (scope: Scope) => void): ReturnType<Hub['configureScope']> {\n const safeCallback = (scope: Scope): void => {\n try {\n callback(scope);\n } catch (e) {\n logger.error('Error while running configureScope callback', e);\n }\n };\n getCurrentHub().configureScope(safeCallback);\n}\n"]}
@@ -140,10 +140,10 @@ export class ReactNavigationInstrumentation extends InternalRoutingInstrumentati
140
140
  }
141
141
  this._pushRecentRouteKey(route.key);
142
142
  this._latestRoute = route;
143
+ // Clear the latest transaction as it has been handled.
144
+ this._latestTransaction = undefined;
143
145
  }
144
146
  }
145
- // Clear the latest transaction as it has been handled.
146
- this._latestTransaction = undefined;
147
147
  }
148
148
  /** Creates final transaction context before confirmation */
149
149
  _prepareFinalContext(updatedContext) {
@@ -1 +1 @@
1
- {"version":3,"file":"reactnavigation.js","sourceRoot":"","sources":["../../../src/js/tracing/reactnavigation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,EACL,8BAA8B,GAG/B,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAqBxG,MAAM,cAAc,GAA2B;IAC7C,o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AM;YACL,+DAA+D;YAC/D,IAAI,CAAC,wBAAwB,EAAE,CAAC;SACjC;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;IAaD,wEAAwE;IAChE,yBAAyB;QAC/B,IAAI,IAAI,CAAC,kBAAkB,EAAE;YAC3B,IAAI,CAAC,kBAAkB,CAAC,OAAO,GAAG,KAAK,CAAC;YACxC,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,CAAC;YACjC,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;SACrC;IACH,CAAC;IAED;;OAEG;IACK,wBAAwB;QAC9B,IAAI,OAAO,IAAI,CAAC,mBAAmB,KAAK,WAAW,EAAE;YACnD,YAAY,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;YACvC,IAAI,CAAC,mBAAmB,GAAG,SAAS,CAAC;SACtC;IACH,CAAC;;AApQa,kDAAmB,GAAW,qBAAqB,CAAC;AAuQpE;;;GAGG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,8BAA8B,CAAC;AAE/E,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,IAAI,EAAE,cAAc;IACpB,EAAE,EAAE,YAAY;IAChB,IAAI,EAAE;QACJ,yBAAyB,EACvB,8BAA8B,CAAC,mBAAmB;KACrD;IACD,IAAI,EAAE,EAAE;CACT,CAAC","sourcesContent":["/* eslint-disable max-lines */\nimport { Transaction as TransactionType, TransactionContext } from '@sentry/types';\nimport { getGlobalObject, logger } from '@sentry/utils';\n\nimport {\n InternalRoutingInstrumentation,\n OnConfirmRoute,\n TransactionCreator,\n} from './routingInstrumentation';\nimport {\n BeforeNavigate,\n ReactNavigationTransactionContext,\n RouteChangeContextData,\n} from './types';\nimport { customTransactionSource, defaultTransactionSource, getBlankTransactionContext } from './utils';\n\nexport interface NavigationRoute {\n name: string;\n key: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n params?: Record<string, any>;\n}\n\ninterface NavigationContainer {\n addListener: (type: string, listener: () => void) => void;\n getCurrentRoute: () => NavigationRoute;\n}\n\ninterface ReactNavigationOptions {\n /**\n * The time the transaction will wait for route to mount before it is discarded.\n */\n routeChangeTimeoutMs: number;\n}\n\nconst defaultOptions: ReactNavigationOptions = {\n routeChangeTimeoutMs: 1000,\n};\n\n/**\n * Instrumentation for React-Navigation V5 and above. See docs or sample app for usage.\n *\n * How this works:\n * - `_onDispatch` is called every time a dispatch happens and sets an IdleTransaction on the scope without any route context.\n * - `_onStateChange` is then called AFTER the state change happens due to a dispatch and sets the route context onto the active transaction.\n * - If `_onStateChange` isn't called within `STATE_CHANGE_TIMEOUT_DURATION` of the dispatch, then the transaction is not sampled and finished.\n */\nexport class ReactNavigationInstrumentation extends InternalRoutingInstrumentation {\n public static instrumentationName: string = 'react-navigation-v5';\n\n private _navigationContainer: NavigationContainer | null = null;\n\n private readonly _maxRecentRouteLen: number = 200;\n\n private _latestRoute?: NavigationRoute;\n private _latestTransaction?: TransactionType;\n private _initialStateHandled: boolean = false;\n private _stateChangeTimeout?: number | undefined;\n private _recentRouteKeys: string[] = [];\n\n private _options: ReactNavigationOptions;\n\n public constructor(options: Partial<ReactNavigationOptions> = {}) {\n super();\n\n this._options = {\n ...defaultOptions,\n ...options,\n };\n }\n\n /**\n * Extends by calling _handleInitialState at the end.\n */\n public registerRoutingInstrumentation(\n listener: TransactionCreator,\n beforeNavigate: BeforeNavigate,\n onConfirmRoute: OnConfirmRoute\n ): void {\n super.registerRoutingInstrumentation(\n listener,\n beforeNavigate,\n onConfirmRoute\n );\n\n // We create an initial state here to ensure a transaction gets created before the first route mounts.\n if (!this._initialStateHandled) {\n this._onDispatch();\n if (this._navigationContainer) {\n // Navigation container already registered, just populate with route state\n this._onStateChange();\n\n this._initialStateHandled = true;\n }\n }\n }\n\n /**\n * Pass the ref to the navigation container to register it to the instrumentation\n * @param navigationContainerRef Ref to a `NavigationContainer`\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types\n public registerNavigationContainer(navigationContainerRef: any): void {\n const _global = getGlobalObject<{ __sentry_rn_v5_registered?: boolean }>();\n\n /* We prevent duplicate routing instrumentation to be initialized on fast refreshes\n\n Explanation: If the user triggers a fast refresh on the file that the instrumentation is\n initialized in, it will initialize a new instance and will cause undefined behavior.\n */\n if (!_global.__sentry_rn_v5_registered) {\n if ('current' in navigationContainerRef) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n this._navigationContainer = navigationContainerRef.current;\n } else {\n this._navigationContainer = navigationContainerRef;\n }\n\n if (this._navigationContainer) {\n this._navigationContainer.addListener(\n '__unsafe_action__', // This action is emitted on every dispatch\n this._onDispatch.bind(this)\n );\n this._navigationContainer.addListener(\n 'state', // This action is emitted on every state change\n this._onStateChange.bind(this)\n );\n\n if (!this._initialStateHandled) {\n if (this._latestTransaction) {\n // If registerRoutingInstrumentation was called first _onDispatch has already been called\n this._onStateChange();\n\n this._initialStateHandled = true;\n } else {\n logger.log(\n '[ReactNavigationInstrumentation] Navigation container registered, but integration has not been setup yet.'\n );\n }\n }\n\n _global.__sentry_rn_v5_registered = true;\n } else {\n logger.warn(\n '[ReactNavigationInstrumentation] Received invalid navigation container ref!'\n );\n }\n } else {\n logger.log(\n '[ReactNavigationInstrumentation] Instrumentation already exists, but register has been called again, doing nothing.'\n );\n }\n }\n\n /**\n * To be called on every React-Navigation action dispatch.\n * It does not name the transaction or populate it with route information. Instead, it waits for the state to fully change\n * and gets the route information from there, @see _onStateChange\n */\n private _onDispatch(): void {\n if (this._latestTransaction) {\n logger.log(\n '[ReactNavigationInstrumentation] A transaction was detected that turned out to be a noop, discarding.'\n );\n this._discardLatestTransaction();\n this._clearStateChangeTimeout();\n }\n\n this._latestTransaction = this.onRouteWillChange(\n getBlankTransactionContext(\n ReactNavigationInstrumentation.instrumentationName\n )\n );\n\n this._stateChangeTimeout = setTimeout(\n this._discardLatestTransaction.bind(this),\n this._options.routeChangeTimeoutMs\n );\n }\n\n /**\n * To be called AFTER the state has been changed to populate the transaction with the current route.\n */\n private _onStateChange(): void {\n // Use the getCurrentRoute method to be accurate.\n const previousRoute = this._latestRoute;\n\n if (!this._navigationContainer) {\n logger.warn(\n '[ReactNavigationInstrumentation] Missing navigation container ref. Route transactions will not be sent.'\n );\n\n return;\n }\n\n const route = this._navigationContainer.getCurrentRoute();\n\n if (route) {\n if (this._latestTransaction) {\n if (!previousRoute || previousRoute.key !== route.key) {\n const originalContext = this._latestTransaction.toContext() as typeof BLANK_TRANSACTION_CONTEXT;\n const routeHasBeenSeen = this._recentRouteKeys.includes(route.key);\n\n const data: RouteChangeContextData = {\n ...originalContext.data,\n route: {\n name: route.name,\n key: route.key,\n params: route.params ?? {},\n hasBeenSeen: routeHasBeenSeen,\n },\n previousRoute: previousRoute\n ? {\n name: previousRoute.name,\n key: previousRoute.key,\n params: previousRoute.params ?? {},\n }\n : null,\n };\n\n const updatedContext: ReactNavigationTransactionContext = {\n ...originalContext,\n name: route.name,\n tags: {\n ...originalContext.tags,\n 'routing.route.name': route.name,\n },\n data,\n };\n\n const finalContext = this._prepareFinalContext(updatedContext);\n this._latestTransaction.updateWithContext(finalContext);\n\n const isCustomName = updatedContext.name !== finalContext.name;\n this._latestTransaction.setName(\n finalContext.name,\n isCustomName ? customTransactionSource : defaultTransactionSource,\n );\n\n this._onConfirmRoute?.(finalContext);\n }\n\n this._pushRecentRouteKey(route.key);\n this._latestRoute = route;\n }\n }\n\n // Clear the latest transaction as it has been handled.\n this._latestTransaction = undefined;\n }\n\n /** Creates final transaction context before confirmation */\n private _prepareFinalContext(updatedContext: TransactionContext): TransactionContext {\n let finalContext = this._beforeNavigate?.({ ...updatedContext });\n\n // This block is to catch users not returning a transaction context\n if (!finalContext) {\n logger.error(\n `[ReactNavigationInstrumentation] beforeNavigate returned ${finalContext}, return context.sampled = false to not send transaction.`\n );\n\n finalContext = {\n ...updatedContext,\n sampled: false,\n };\n }\n\n // Note: finalContext.sampled will be false at this point only if the user sets it to be so in beforeNavigate.\n if (finalContext.sampled === false) {\n logger.log(\n `[ReactNavigationInstrumentation] Will not send transaction \"${finalContext.name}\" due to beforeNavigate.`\n );\n } else {\n // Clear the timeout so the transaction does not get cancelled.\n this._clearStateChangeTimeout();\n }\n\n return finalContext;\n }\n\n /** Pushes a recent route key, and removes earlier routes when there is greater than the max length */\n private _pushRecentRouteKey = (key: string): void => {\n this._recentRouteKeys.push(key);\n\n if (this._recentRouteKeys.length > this._maxRecentRouteLen) {\n this._recentRouteKeys = this._recentRouteKeys.slice(\n this._recentRouteKeys.length - this._maxRecentRouteLen\n );\n }\n };\n\n /** Cancels the latest transaction so it does not get sent to Sentry. */\n private _discardLatestTransaction(): void {\n if (this._latestTransaction) {\n this._latestTransaction.sampled = false;\n this._latestTransaction.finish();\n this._latestTransaction = undefined;\n }\n }\n\n /**\n *\n */\n private _clearStateChangeTimeout(): void {\n if (typeof this._stateChangeTimeout !== 'undefined') {\n clearTimeout(this._stateChangeTimeout);\n this._stateChangeTimeout = undefined;\n }\n }\n}\n\n/**\n * Backwards compatibility alias for ReactNavigationInstrumentation\n * @deprecated Use ReactNavigationInstrumentation\n */\nexport const ReactNavigationV5Instrumentation = ReactNavigationInstrumentation;\n\nexport const BLANK_TRANSACTION_CONTEXT = {\n name: 'Route Change',\n op: 'navigation',\n tags: {\n 'routing.instrumentation':\n ReactNavigationInstrumentation.instrumentationName,\n },\n data: {},\n};\n"]}
1
+ {"version":3,"file":"reactnavigation.js","sourceRoot":"","sources":["../../../src/js/tracing/reactnavigation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,EACL,8BAA8B,GAG/B,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAqBxG,MAAM,cAAc,GAA2B;IAC7C,oBAAoB,EAAE,IAAI;CAC3B,CAAC;AAEF;;;;;;;GAOG;AACH,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C;SACjC;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;IAaD,wEAAwE;IAChE,yBAAyB;QAC/B,IAAI,IAAI,CAAC,kBAAkB,EAAE;YAC3B,IAAI,CAAC,kBAAkB,CAAC,OAAO,GAAG,KAAK,CAAC;YACxC,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,CAAC;YACjC,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;SACrC;IACH,CAAC;IAED;;OAEG;IACK,wBAAwB;QAC9B,IAAI,OAAO,IAAI,CAAC,mBAAmB,KAAK,WAAW,EAAE;YACnD,YAAY,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;YACvC,IAAI,CAAC,mBAAmB,GAAG,SAAS,CAAC;SACtC;IACH,CAAC;;AApQa,kDAAmB,GAAW,qBAAqB,CAAC;AAuQpE;;;GAGG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,8BAA8B,CAAC;AAE/E,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,IAAI,EAAE,cAAc;IACpB,EAAE,EAAE,YAAY;IAChB,IAAI,EAAE;QACJ,yBAAyB,EACvB,8BAA8B,CAAC,mBAAmB;KACrD;IACD,IAAI,EAAE,EAAE;CACT,CAAC","sourcesContent":["/* eslint-disable max-lines */\nimport { Transaction as TransactionType, TransactionContext } from '@sentry/types';\nimport { getGlobalObject, logger } from '@sentry/utils';\n\nimport {\n InternalRoutingInstrumentation,\n OnConfirmRoute,\n TransactionCreator,\n} from './routingInstrumentation';\nimport {\n BeforeNavigate,\n ReactNavigationTransactionContext,\n RouteChangeContextData,\n} from './types';\nimport { customTransactionSource, defaultTransactionSource, getBlankTransactionContext } from './utils';\n\nexport interface NavigationRoute {\n name: string;\n key: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n params?: Record<string, any>;\n}\n\ninterface NavigationContainer {\n addListener: (type: string, listener: () => void) => void;\n getCurrentRoute: () => NavigationRoute;\n}\n\ninterface ReactNavigationOptions {\n /**\n * The time the transaction will wait for route to mount before it is discarded.\n */\n routeChangeTimeoutMs: number;\n}\n\nconst defaultOptions: ReactNavigationOptions = {\n routeChangeTimeoutMs: 1000,\n};\n\n/**\n * Instrumentation for React-Navigation V5 and above. See docs or sample app for usage.\n *\n * How this works:\n * - `_onDispatch` is called every time a dispatch happens and sets an IdleTransaction on the scope without any route context.\n * - `_onStateChange` is then called AFTER the state change happens due to a dispatch and sets the route context onto the active transaction.\n * - If `_onStateChange` isn't called within `STATE_CHANGE_TIMEOUT_DURATION` of the dispatch, then the transaction is not sampled and finished.\n */\nexport class ReactNavigationInstrumentation extends InternalRoutingInstrumentation {\n public static instrumentationName: string = 'react-navigation-v5';\n\n private _navigationContainer: NavigationContainer | null = null;\n\n private readonly _maxRecentRouteLen: number = 200;\n\n private _latestRoute?: NavigationRoute;\n private _latestTransaction?: TransactionType;\n private _initialStateHandled: boolean = false;\n private _stateChangeTimeout?: number | undefined;\n private _recentRouteKeys: string[] = [];\n\n private _options: ReactNavigationOptions;\n\n public constructor(options: Partial<ReactNavigationOptions> = {}) {\n super();\n\n this._options = {\n ...defaultOptions,\n ...options,\n };\n }\n\n /**\n * Extends by calling _handleInitialState at the end.\n */\n public registerRoutingInstrumentation(\n listener: TransactionCreator,\n beforeNavigate: BeforeNavigate,\n onConfirmRoute: OnConfirmRoute\n ): void {\n super.registerRoutingInstrumentation(\n listener,\n beforeNavigate,\n onConfirmRoute\n );\n\n // We create an initial state here to ensure a transaction gets created before the first route mounts.\n if (!this._initialStateHandled) {\n this._onDispatch();\n if (this._navigationContainer) {\n // Navigation container already registered, just populate with route state\n this._onStateChange();\n\n this._initialStateHandled = true;\n }\n }\n }\n\n /**\n * Pass the ref to the navigation container to register it to the instrumentation\n * @param navigationContainerRef Ref to a `NavigationContainer`\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types\n public registerNavigationContainer(navigationContainerRef: any): void {\n const _global = getGlobalObject<{ __sentry_rn_v5_registered?: boolean }>();\n\n /* We prevent duplicate routing instrumentation to be initialized on fast refreshes\n\n Explanation: If the user triggers a fast refresh on the file that the instrumentation is\n initialized in, it will initialize a new instance and will cause undefined behavior.\n */\n if (!_global.__sentry_rn_v5_registered) {\n if ('current' in navigationContainerRef) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n this._navigationContainer = navigationContainerRef.current;\n } else {\n this._navigationContainer = navigationContainerRef;\n }\n\n if (this._navigationContainer) {\n this._navigationContainer.addListener(\n '__unsafe_action__', // This action is emitted on every dispatch\n this._onDispatch.bind(this)\n );\n this._navigationContainer.addListener(\n 'state', // This action is emitted on every state change\n this._onStateChange.bind(this)\n );\n\n if (!this._initialStateHandled) {\n if (this._latestTransaction) {\n // If registerRoutingInstrumentation was called first _onDispatch has already been called\n this._onStateChange();\n\n this._initialStateHandled = true;\n } else {\n logger.log(\n '[ReactNavigationInstrumentation] Navigation container registered, but integration has not been setup yet.'\n );\n }\n }\n\n _global.__sentry_rn_v5_registered = true;\n } else {\n logger.warn(\n '[ReactNavigationInstrumentation] Received invalid navigation container ref!'\n );\n }\n } else {\n logger.log(\n '[ReactNavigationInstrumentation] Instrumentation already exists, but register has been called again, doing nothing.'\n );\n }\n }\n\n /**\n * To be called on every React-Navigation action dispatch.\n * It does not name the transaction or populate it with route information. Instead, it waits for the state to fully change\n * and gets the route information from there, @see _onStateChange\n */\n private _onDispatch(): void {\n if (this._latestTransaction) {\n logger.log(\n '[ReactNavigationInstrumentation] A transaction was detected that turned out to be a noop, discarding.'\n );\n this._discardLatestTransaction();\n this._clearStateChangeTimeout();\n }\n\n this._latestTransaction = this.onRouteWillChange(\n getBlankTransactionContext(\n ReactNavigationInstrumentation.instrumentationName\n )\n );\n\n this._stateChangeTimeout = setTimeout(\n this._discardLatestTransaction.bind(this),\n this._options.routeChangeTimeoutMs\n );\n }\n\n /**\n * To be called AFTER the state has been changed to populate the transaction with the current route.\n */\n private _onStateChange(): void {\n // Use the getCurrentRoute method to be accurate.\n const previousRoute = this._latestRoute;\n\n if (!this._navigationContainer) {\n logger.warn(\n '[ReactNavigationInstrumentation] Missing navigation container ref. Route transactions will not be sent.'\n );\n\n return;\n }\n\n const route = this._navigationContainer.getCurrentRoute();\n\n if (route) {\n if (this._latestTransaction) {\n if (!previousRoute || previousRoute.key !== route.key) {\n const originalContext = this._latestTransaction.toContext() as typeof BLANK_TRANSACTION_CONTEXT;\n const routeHasBeenSeen = this._recentRouteKeys.includes(route.key);\n\n const data: RouteChangeContextData = {\n ...originalContext.data,\n route: {\n name: route.name,\n key: route.key,\n params: route.params ?? {},\n hasBeenSeen: routeHasBeenSeen,\n },\n previousRoute: previousRoute\n ? {\n name: previousRoute.name,\n key: previousRoute.key,\n params: previousRoute.params ?? {},\n }\n : null,\n };\n\n const updatedContext: ReactNavigationTransactionContext = {\n ...originalContext,\n name: route.name,\n tags: {\n ...originalContext.tags,\n 'routing.route.name': route.name,\n },\n data,\n };\n\n const finalContext = this._prepareFinalContext(updatedContext);\n this._latestTransaction.updateWithContext(finalContext);\n\n const isCustomName = updatedContext.name !== finalContext.name;\n this._latestTransaction.setName(\n finalContext.name,\n isCustomName ? customTransactionSource : defaultTransactionSource,\n );\n\n this._onConfirmRoute?.(finalContext);\n }\n\n this._pushRecentRouteKey(route.key);\n this._latestRoute = route;\n\n // Clear the latest transaction as it has been handled.\n this._latestTransaction = undefined;\n }\n }\n }\n\n /** Creates final transaction context before confirmation */\n private _prepareFinalContext(updatedContext: TransactionContext): TransactionContext {\n let finalContext = this._beforeNavigate?.({ ...updatedContext });\n\n // This block is to catch users not returning a transaction context\n if (!finalContext) {\n logger.error(\n `[ReactNavigationInstrumentation] beforeNavigate returned ${finalContext}, return context.sampled = false to not send transaction.`\n );\n\n finalContext = {\n ...updatedContext,\n sampled: false,\n };\n }\n\n // Note: finalContext.sampled will be false at this point only if the user sets it to be so in beforeNavigate.\n if (finalContext.sampled === false) {\n logger.log(\n `[ReactNavigationInstrumentation] Will not send transaction \"${finalContext.name}\" due to beforeNavigate.`\n );\n } else {\n // Clear the timeout so the transaction does not get cancelled.\n this._clearStateChangeTimeout();\n }\n\n return finalContext;\n }\n\n /** Pushes a recent route key, and removes earlier routes when there is greater than the max length */\n private _pushRecentRouteKey = (key: string): void => {\n this._recentRouteKeys.push(key);\n\n if (this._recentRouteKeys.length > this._maxRecentRouteLen) {\n this._recentRouteKeys = this._recentRouteKeys.slice(\n this._recentRouteKeys.length - this._maxRecentRouteLen\n );\n }\n };\n\n /** Cancels the latest transaction so it does not get sent to Sentry. */\n private _discardLatestTransaction(): void {\n if (this._latestTransaction) {\n this._latestTransaction.sampled = false;\n this._latestTransaction.finish();\n this._latestTransaction = undefined;\n }\n }\n\n /**\n *\n */\n private _clearStateChangeTimeout(): void {\n if (typeof this._stateChangeTimeout !== 'undefined') {\n clearTimeout(this._stateChangeTimeout);\n this._stateChangeTimeout = undefined;\n }\n }\n}\n\n/**\n * Backwards compatibility alias for ReactNavigationInstrumentation\n * @deprecated Use ReactNavigationInstrumentation\n */\nexport const ReactNavigationV5Instrumentation = ReactNavigationInstrumentation;\n\nexport const BLANK_TRANSACTION_CONTEXT = {\n name: 'Route Change',\n op: 'navigation',\n tags: {\n 'routing.instrumentation':\n ReactNavigationInstrumentation.instrumentationName,\n },\n data: {},\n};\n"]}
@@ -1,4 +1,6 @@
1
1
  import { DsnComponents, EventEnvelope, SdkMetadata, UserFeedback } from '@sentry/types';
2
+ export declare const header = 0;
3
+ export declare const items = 1;
2
4
  /**
3
5
  * Creates an envelope from a user feedback.
4
6
  */
@@ -1 +1 @@
1
- {"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../../../src/js/utils/envelope.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EACb,aAAa,EAEb,WAAW,EACX,YAAY,EAEb,MAAM,eAAe,CAAC;AAGvB;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,YAAY,EACtB,EACE,QAAQ,EACR,MAAM,EACN,GAAG,GACJ,EAAE;IACD,QAAQ,EAAE,WAAW,GAAG,SAAS,CAAC;IAClC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,GAAG,EAAE,aAAa,GAAG,SAAS,CAAC;CAChC,GACA,aAAa,CAcf"}
1
+ {"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../../../src/js/utils/envelope.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,aAAa,EACb,WAAW,EACX,YAAY,EAEb,MAAM,eAAe,CAAC;AAGvB,eAAO,MAAM,MAAM,IAAI,CAAC;AACxB,eAAO,MAAM,KAAK,IAAI,CAAC;AAEvB;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,YAAY,EACtB,EACE,QAAQ,EACR,MAAM,EACN,GAAG,GACJ,EAAE;IACD,QAAQ,EAAE,WAAW,GAAG,SAAS,CAAC;IAClC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,GAAG,EAAE,aAAa,GAAG,SAAS,CAAC;CAChC,GACA,aAAa,CAaf"}
@@ -1,9 +1,10 @@
1
1
  import { createEnvelope, dsnToString } from '@sentry/utils';
2
+ export const header = 0;
3
+ export const items = 1;
2
4
  /**
3
5
  * Creates an envelope from a user feedback.
4
6
  */
5
7
  export function createUserFeedbackEnvelope(feedback, { metadata, tunnel, dsn, }) {
6
- // TODO: Use EventEnvelope[0] when JS sdk fix is released
7
8
  const headers = Object.assign(Object.assign({ event_id: feedback.event_id, sent_at: new Date().toISOString() }, (metadata && metadata.sdk && { sdk: {
8
9
  name: metadata.sdk.name,
9
10
  version: metadata.sdk.version,
@@ -1 +1 @@
1
- {"version":3,"file":"envelope.js","sourceRoot":"","sources":["../../../src/js/utils/envelope.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5D;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACxC,QAAsB,EACtB,EACE,QAAQ,EACR,MAAM,EACN,GAAG,GAKJ;IAED,yDAAyD;IACzD,MAAM,OAAO,iCACX,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAC3B,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,IAC9B,CAAC,QAAQ,IAAI,QAAQ,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;YACrC,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,IAAI;YACvB,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO;SAC9B,EAAC,CAAC,GACA,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CACpD,CAAC;IACF,MAAM,IAAI,GAAG,8BAA8B,CAAC,QAAQ,CAAC,CAAC;IAEtD,OAAO,cAAc,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,8BAA8B,CACrC,QAAsB;IAEtB,MAAM,eAAe,GAAwB;QAC3C,IAAI,EAAE,aAAa;KACpB,CAAC;IACF,OAAO,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;AACrC,CAAC","sourcesContent":["import {\n BaseEnvelopeHeaders,\n DsnComponents,\n EventEnvelope,\n EventEnvelopeHeaders,\n SdkMetadata,\n UserFeedback,\n UserFeedbackItem,\n} from '@sentry/types';\nimport { createEnvelope, dsnToString } from '@sentry/utils';\n\n/**\n * Creates an envelope from a user feedback.\n */\nexport function createUserFeedbackEnvelope(\n feedback: UserFeedback,\n {\n metadata,\n tunnel,\n dsn,\n }: {\n metadata: SdkMetadata | undefined,\n tunnel: string | undefined,\n dsn: DsnComponents | undefined,\n },\n): EventEnvelope {\n // TODO: Use EventEnvelope[0] when JS sdk fix is released\n const headers: EventEnvelopeHeaders & BaseEnvelopeHeaders = {\n event_id: feedback.event_id,\n sent_at: new Date().toISOString(),\n ...(metadata && metadata.sdk && { sdk: {\n name: metadata.sdk.name,\n version: metadata.sdk.version,\n }}),\n ...(!!tunnel && !!dsn && { dsn: dsnToString(dsn) }),\n };\n const item = createUserFeedbackEnvelopeItem(feedback);\n\n return createEnvelope(headers, [item]);\n}\n\nfunction createUserFeedbackEnvelopeItem(\n feedback: UserFeedback\n): UserFeedbackItem {\n const feedbackHeaders: UserFeedbackItem[0] = {\n type: 'user_report',\n };\n return [feedbackHeaders, feedback];\n}\n"]}
1
+ {"version":3,"file":"envelope.js","sourceRoot":"","sources":["../../../src/js/utils/envelope.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5D,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC;AACxB,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC;AAEvB;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACxC,QAAsB,EACtB,EACE,QAAQ,EACR,MAAM,EACN,GAAG,GAKJ;IAED,MAAM,OAAO,iCACX,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAC3B,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,IAC9B,CAAC,QAAQ,IAAI,QAAQ,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;YACrC,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,IAAI;YACvB,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO;SAC9B,EAAC,CAAC,GACA,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CACpD,CAAC;IACF,MAAM,IAAI,GAAG,8BAA8B,CAAC,QAAQ,CAAC,CAAC;IAEtD,OAAO,cAAc,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,8BAA8B,CACrC,QAAsB;IAEtB,MAAM,eAAe,GAAwB;QAC3C,IAAI,EAAE,aAAa;KACpB,CAAC;IACF,OAAO,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;AACrC,CAAC","sourcesContent":["import {\n DsnComponents,\n EventEnvelope,\n SdkMetadata,\n UserFeedback,\n UserFeedbackItem,\n} from '@sentry/types';\nimport { createEnvelope, dsnToString } from '@sentry/utils';\n\nexport const header = 0;\nexport const items = 1;\n\n/**\n * Creates an envelope from a user feedback.\n */\nexport function createUserFeedbackEnvelope(\n feedback: UserFeedback,\n {\n metadata,\n tunnel,\n dsn,\n }: {\n metadata: SdkMetadata | undefined,\n tunnel: string | undefined,\n dsn: DsnComponents | undefined,\n },\n): EventEnvelope {\n const headers: EventEnvelope[0] = {\n event_id: feedback.event_id,\n sent_at: new Date().toISOString(),\n ...(metadata && metadata.sdk && { sdk: {\n name: metadata.sdk.name,\n version: metadata.sdk.version,\n }}),\n ...(!!tunnel && !!dsn && { dsn: dsnToString(dsn) }),\n };\n const item = createUserFeedbackEnvelopeItem(feedback);\n\n return createEnvelope(headers, [item]);\n}\n\nfunction createUserFeedbackEnvelopeItem(\n feedback: UserFeedback\n): UserFeedbackItem {\n const feedbackHeaders: UserFeedbackItem[0] = {\n type: 'user_report',\n };\n return [feedbackHeaders, feedback];\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import { Outcome } from '@sentry/types';
2
+ /**
3
+ * Merges buffer with new outcomes.
4
+ */
5
+ export declare function mergeOutcomes(...merge: Outcome[][]): Outcome[];
6
+ //# sourceMappingURL=outcome.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../../../src/js/utils/outcome.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,KAAK,EAAE,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,CAgB9D"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Merges buffer with new outcomes.
3
+ */
4
+ export function mergeOutcomes(...merge) {
5
+ const map = new Map();
6
+ const process = (outcome) => {
7
+ const key = `${outcome.reason}:${outcome.category}`;
8
+ const existing = map.get(key);
9
+ if (existing) {
10
+ existing.quantity += outcome.quantity;
11
+ }
12
+ else {
13
+ map.set(key, outcome);
14
+ }
15
+ };
16
+ merge.forEach((outcomes) => outcomes.forEach(process));
17
+ return [...map.values()];
18
+ }
19
+ //# sourceMappingURL=outcome.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outcome.js","sourceRoot":"","sources":["../../../src/js/utils/outcome.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,GAAG,KAAkB;IACjD,MAAM,GAAG,GAAG,IAAI,GAAG,EAAmB,CAAC;IAEvC,MAAM,OAAO,GAAG,CAAC,OAAgB,EAAQ,EAAE;QACzC,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACpD,MAAM,QAAQ,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC9B,IAAI,QAAQ,EAAE;YACZ,QAAQ,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC;SACvC;aAAM;YACL,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;SACvB;IACH,CAAC,CAAC;IAEF,KAAK,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAEvD,OAAO,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["import { Outcome } from '@sentry/types';\n\n/**\n * Merges buffer with new outcomes.\n */\nexport function mergeOutcomes(...merge: Outcome[][]): Outcome[] {\n const map = new Map<string, Outcome>();\n\n const process = (outcome: Outcome): void => {\n const key = `${outcome.reason}:${outcome.category}`;\n const existing = map.get(key);\n if (existing) {\n existing.quantity += outcome.quantity;\n } else {\n map.set(key, outcome);\n }\n };\n\n merge.forEach((outcomes) => outcomes.forEach(process));\n\n return [...map.values()];\n}\n"]}
@@ -0,0 +1,18 @@
1
+ import { ReactNativeOptions } from '../options';
2
+ declare type DangerTypesWithoutCallSignature = Object | null | undefined;
3
+ /**
4
+ * Returns callback factory wrapped with try/catch
5
+ * or the original passed value is it's not a function.
6
+ *
7
+ * If the factory fails original data are returned as it.
8
+ * They might be partially modified by the failed function.
9
+ */
10
+ export declare function safeFactory<A extends [R, ...unknown[]], R, T extends DangerTypesWithoutCallSignature>(danger: ((...args: A) => R) | T, options?: {
11
+ loggerMessage?: string;
12
+ }): ((...args: A) => R) | T;
13
+ /**
14
+ * Returns sage tracesSampler that returns 0 if the original failed.
15
+ */
16
+ export declare function safeTracesSampler(tracesSampler: ReactNativeOptions['tracesSampler']): ReactNativeOptions['tracesSampler'];
17
+ export {};
18
+ //# sourceMappingURL=safe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe.d.ts","sourceRoot":"","sources":["../../../src/js/utils/safe.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,aAAK,+BAA+B,GAEhC,MAAM,GACN,IAAI,GACJ,SAAS,CAAC;AAEd;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,+BAA+B,EACnG,MAAM,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAC/B,OAAO,GAAE;IACP,aAAa,CAAC,EAAE,MAAM,CAAC;CACnB,GACL,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAkBzB;AAID;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,kBAAkB,CAAC,eAAe,CAAC,GACjD,kBAAkB,CAAC,eAAe,CAAC,CAerC"}
@@ -0,0 +1,46 @@
1
+ import { logger } from '@sentry/utils';
2
+ /**
3
+ * Returns callback factory wrapped with try/catch
4
+ * or the original passed value is it's not a function.
5
+ *
6
+ * If the factory fails original data are returned as it.
7
+ * They might be partially modified by the failed function.
8
+ */
9
+ export function safeFactory(danger, options = {}) {
10
+ if (typeof danger === 'function') {
11
+ return (...args) => {
12
+ try {
13
+ return danger(...args);
14
+ }
15
+ catch (error) {
16
+ logger.error(options.loggerMessage
17
+ ? options.loggerMessage
18
+ : `The ${danger.name} callback threw an error`, error);
19
+ return args[0];
20
+ }
21
+ };
22
+ }
23
+ else {
24
+ return danger;
25
+ }
26
+ }
27
+ /**
28
+ * Returns sage tracesSampler that returns 0 if the original failed.
29
+ */
30
+ export function safeTracesSampler(tracesSampler) {
31
+ if (tracesSampler) {
32
+ return (...args) => {
33
+ try {
34
+ return tracesSampler(...args);
35
+ }
36
+ catch (error) {
37
+ logger.error('The tracesSampler callback threw an error', error);
38
+ return 0;
39
+ }
40
+ };
41
+ }
42
+ else {
43
+ return tracesSampler;
44
+ }
45
+ }
46
+ //# sourceMappingURL=safe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe.js","sourceRoot":"","sources":["../../../src/js/utils/safe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAUvC;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CACzB,MAA+B,EAC/B,UAEI,EAAE;IAEN,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE;QAChC,OAAO,CAAC,GAAG,IAAI,EAAE,EAAE;YACjB,IAAI;gBACF,OAAO,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;aACxB;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,CAAC,KAAK,CACV,OAAO,CAAC,aAAa;oBACnB,CAAC,CAAC,OAAO,CAAC,aAAa;oBACvB,CAAC,CAAC,OAAO,MAAM,CAAC,IAAI,0BAA0B,EAChD,KAAK,CACN,CAAC;gBACF,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC;aAChB;QACH,CAAC,CAAC;KACH;SAAM;QACL,OAAO,MAAM,CAAC;KACf;AACH,CAAC;AAID;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,aAAkD;IAElD,IAAI,aAAa,EAAE;QACjB,OAAO,CACL,GAAG,IAA+B,EACP,EAAE;YAC7B,IAAI;gBACF,OAAO,aAAa,CAAC,GAAG,IAAI,CAAC,CAAC;aAC/B;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,CAAC,KAAK,CAAC,2CAA2C,EAAE,KAAK,CAAC,CAAC;gBACjE,OAAO,CAAC,CAAC;aACV;QACH,CAAC,CAAA;KACF;SAAM;QACL,OAAO,aAAa,CAAC;KACtB;AACH,CAAC","sourcesContent":["import { logger } from '@sentry/utils';\n\nimport { ReactNativeOptions } from '../options';\n\ntype DangerTypesWithoutCallSignature =\n// eslint-disable-next-line @typescript-eslint/ban-types\n | Object\n | null\n | undefined;\n\n/**\n * Returns callback factory wrapped with try/catch\n * or the original passed value is it's not a function.\n *\n * If the factory fails original data are returned as it.\n * They might be partially modified by the failed function.\n */\nexport function safeFactory<A extends [R, ...unknown[]], R, T extends DangerTypesWithoutCallSignature>(\n danger: ((...args: A) => R) | T,\n options: {\n loggerMessage?: string;\n } = {},\n): ((...args: A) => R) | T {\n if (typeof danger === 'function') {\n return (...args) => {\n try {\n return danger(...args);\n } catch (error) {\n logger.error(\n options.loggerMessage\n ? options.loggerMessage\n : `The ${danger.name} callback threw an error`,\n error,\n );\n return args[0];\n }\n };\n } else {\n return danger;\n }\n}\n\ntype TracesSampler = Required<ReactNativeOptions>['tracesSampler'];\n\n/**\n * Returns sage tracesSampler that returns 0 if the original failed.\n */\nexport function safeTracesSampler(\n tracesSampler: ReactNativeOptions['tracesSampler'],\n): ReactNativeOptions['tracesSampler'] {\n if (tracesSampler) {\n return (\n ...args: Parameters<TracesSampler>\n ): ReturnType<TracesSampler> => {\n try {\n return tracesSampler(...args);\n } catch (error) {\n logger.error('The tracesSampler callback threw an error', error);\n return 0;\n }\n }\n } else {\n return tracesSampler;\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
1
  export declare const SDK_PACKAGE_NAME = "npm:@sentry/react-native";
2
2
  export declare const SDK_NAME = "sentry.javascript.react-native";
3
- export declare const SDK_VERSION = "5.0.0-alpha.4";
3
+ export declare const SDK_VERSION = "5.0.0-alpha.5";
4
4
  //# sourceMappingURL=version.d.ts.map
@@ -1,4 +1,4 @@
1
1
  export const SDK_PACKAGE_NAME = 'npm:@sentry/react-native';
2
2
  export const SDK_NAME = 'sentry.javascript.react-native';
3
- export const SDK_VERSION = '5.0.0-alpha.4';
3
+ export const SDK_VERSION = '5.0.0-alpha.5';
4
4
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/js/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAC3D,MAAM,CAAC,MAAM,QAAQ,GAAG,gCAAgC,CAAC;AACzD,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAC","sourcesContent":["export const SDK_PACKAGE_NAME = 'npm:@sentry/react-native';\nexport const SDK_NAME = 'sentry.javascript.react-native';\nexport const SDK_VERSION = '5.0.0-alpha.4';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/js/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAC3D,MAAM,CAAC,MAAM,QAAQ,GAAG,gCAAgC,CAAC;AACzD,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAC","sourcesContent":["export const SDK_PACKAGE_NAME = 'npm:@sentry/react-native';\nexport const SDK_NAME = 'sentry.javascript.react-native';\nexport const SDK_VERSION = '5.0.0-alpha.5';\n"]}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@sentry/react-native",
3
3
  "homepage": "https://github.com/getsentry/sentry-react-native",
4
4
  "repository": "https://github.com/getsentry/sentry-react-native",
5
- "version": "5.0.0-alpha.4",
5
+ "version": "5.0.0-alpha.5",
6
6
  "description": "Official Sentry SDK for react-native",
7
7
  "typings": "dist/js/index.d.ts",
8
8
  "types": "dist/js/index.d.ts",
@@ -40,19 +40,19 @@
40
40
  "react-native": ">=0.56.0"
41
41
  },
42
42
  "dependencies": {
43
- "@sentry/browser": "7.13.0",
43
+ "@sentry/browser": "7.14.1",
44
44
  "@sentry/cli": "1.74.4",
45
- "@sentry/core": "7.13.0",
46
- "@sentry/hub": "7.13.0",
47
- "@sentry/integrations": "7.13.0",
48
- "@sentry/react": "7.13.0",
49
- "@sentry/tracing": "7.13.0",
50
- "@sentry/types": "7.13.0",
51
- "@sentry/utils": "7.13.0"
45
+ "@sentry/core": "7.14.1",
46
+ "@sentry/hub": "7.14.1",
47
+ "@sentry/integrations": "7.14.1",
48
+ "@sentry/react": "7.14.1",
49
+ "@sentry/tracing": "7.14.1",
50
+ "@sentry/types": "7.14.1",
51
+ "@sentry/utils": "7.14.1"
52
52
  },
53
53
  "devDependencies": {
54
- "@sentry-internal/eslint-config-sdk": "7.13.0",
55
- "@sentry-internal/eslint-plugin-sdk": "7.13.0",
54
+ "@sentry-internal/eslint-config-sdk": "7.14.1",
55
+ "@sentry-internal/eslint-plugin-sdk": "7.14.1",
56
56
  "@sentry/typescript": "^5.20.1",
57
57
  "@sentry/wizard": "2.2.0",
58
58
  "@types/jest": "^26.0.15",