@sentry/react-native 5.22.2 → 5.23.0-alpha.1

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.
Files changed (60) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/RNSentry.podspec +1 -1
  3. package/android/build.gradle +1 -1
  4. package/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java +54 -1
  5. package/android/src/newarch/java/io/sentry/react/RNSentryModule.java +10 -0
  6. package/android/src/oldarch/java/io/sentry/react/RNSentryModule.java +10 -0
  7. package/dist/js/NativeRNSentry.d.ts +2 -0
  8. package/dist/js/NativeRNSentry.d.ts.map +1 -1
  9. package/dist/js/NativeRNSentry.js.map +1 -1
  10. package/dist/js/client.d.ts +8 -0
  11. package/dist/js/client.d.ts.map +1 -1
  12. package/dist/js/client.js +19 -3
  13. package/dist/js/client.js.map +1 -1
  14. package/dist/js/index.d.ts +1 -0
  15. package/dist/js/index.d.ts.map +1 -1
  16. package/dist/js/index.js +1 -0
  17. package/dist/js/index.js.map +1 -1
  18. package/dist/js/integrations/default.d.ts.map +1 -1
  19. package/dist/js/integrations/default.js +11 -1
  20. package/dist/js/integrations/default.js.map +1 -1
  21. package/dist/js/integrations/index.d.ts +1 -0
  22. package/dist/js/integrations/index.d.ts.map +1 -1
  23. package/dist/js/integrations/index.js +1 -0
  24. package/dist/js/integrations/index.js.map +1 -1
  25. package/dist/js/integrations/mobilereplay.d.ts +36 -0
  26. package/dist/js/integrations/mobilereplay.d.ts.map +1 -0
  27. package/dist/js/integrations/mobilereplay.js +97 -0
  28. package/dist/js/integrations/mobilereplay.js.map +1 -0
  29. package/dist/js/options.d.ts +24 -2
  30. package/dist/js/options.d.ts.map +1 -1
  31. package/dist/js/options.js.map +1 -1
  32. package/dist/js/utils/clientutils.d.ts +8 -0
  33. package/dist/js/utils/clientutils.d.ts.map +1 -0
  34. package/dist/js/utils/clientutils.js +7 -0
  35. package/dist/js/utils/clientutils.js.map +1 -0
  36. package/dist/js/utils/environment.d.ts +4 -0
  37. package/dist/js/utils/environment.d.ts.map +1 -1
  38. package/dist/js/utils/environment.js +8 -0
  39. package/dist/js/utils/environment.js.map +1 -1
  40. package/dist/js/version.d.ts +1 -1
  41. package/dist/js/version.d.ts.map +1 -1
  42. package/dist/js/version.js +1 -1
  43. package/dist/js/version.js.map +1 -1
  44. package/dist/js/wrapper.d.ts +7 -1
  45. package/dist/js/wrapper.d.ts.map +1 -1
  46. package/dist/js/wrapper.js +24 -0
  47. package/dist/js/wrapper.js.map +1 -1
  48. package/ios/RNSentry.mm +47 -1
  49. package/package.json +2 -2
  50. package/src/js/NativeRNSentry.ts +2 -0
  51. package/ts3.8/dist/js/NativeRNSentry.d.ts +2 -0
  52. package/ts3.8/dist/js/client.d.ts +8 -0
  53. package/ts3.8/dist/js/index.d.ts +1 -0
  54. package/ts3.8/dist/js/integrations/index.d.ts +1 -0
  55. package/ts3.8/dist/js/integrations/mobilereplay.d.ts +36 -0
  56. package/ts3.8/dist/js/options.d.ts +24 -2
  57. package/ts3.8/dist/js/utils/clientutils.d.ts +8 -0
  58. package/ts3.8/dist/js/utils/environment.d.ts +4 -0
  59. package/ts3.8/dist/js/version.d.ts +1 -1
  60. package/ts3.8/dist/js/wrapper.d.ts +7 -1
package/ios/RNSentry.mm CHANGED
@@ -116,7 +116,6 @@ RCT_EXPORT_METHOD(initNativeSdk:(NSDictionary *_Nonnull)options
116
116
  // Because we sent it already before the app crashed.
117
117
  if (nil != event.exceptions.firstObject.type &&
118
118
  [event.exceptions.firstObject.type rangeOfString:@"Unhandled JS Exception"].location != NSNotFound) {
119
- NSLog(@"Unhandled JS Exception");
120
119
  return nil;
121
120
  }
122
121
 
@@ -135,6 +134,28 @@ RCT_EXPORT_METHOD(initNativeSdk:(NSDictionary *_Nonnull)options
135
134
  [mutableOptions removeObjectForKey:@"tracesSampler"];
136
135
  [mutableOptions removeObjectForKey:@"enableTracing"];
137
136
 
137
+ if ([mutableOptions valueForKey:@"_experiments"] != nil) {
138
+ NSDictionary *experiments = mutableOptions[@"_experiments"];
139
+ if (experiments[@"replaysSessionSampleRate"] != nil || experiments[@"replaysOnErrorSampleRate"] != nil) {
140
+ [mutableOptions setValue:@{
141
+ @"sessionReplay": @{
142
+ @"sessionSampleRate": experiments[@"replaysSessionSampleRate"] ?: [NSNull null],
143
+ @"errorSampleRate": experiments[@"replaysOnErrorSampleRate"] ?: [NSNull null],
144
+ @"redactAllImages": mutableOptions[@"mobileReplayOptions"] != nil &&
145
+ mutableOptions[@"mobileReplayOptions"][@"maskAllImages"] != nil
146
+ ? mutableOptions[@"mobileReplayOptions"][@"maskAllImages"]
147
+ : [NSNull null],
148
+ @"redactAllText": mutableOptions[@"mobileReplayOptions"] != nil &&
149
+ mutableOptions[@"mobileReplayOptions"][@"maskAllText"] != nil
150
+ ? mutableOptions[@"mobileReplayOptions"][@"maskAllText"]
151
+ : [NSNull null],
152
+ }
153
+ } forKey:@"experimental"];
154
+ [self addReplayRNRedactClasses: mutableOptions[@"mobileReplayOptions"]];
155
+ }
156
+ [mutableOptions removeObjectForKey:@"_experiments"];
157
+ }
158
+
138
159
  SentryOptions *sentryOptions = [[SentryOptions alloc] initWithDict:mutableOptions didFailWithError:errorPointer];
139
160
  if (*errorPointer != nil) {
140
161
  return nil;
@@ -644,6 +665,31 @@ RCT_EXPORT_METHOD(enableNativeFramesTracking)
644
665
  // the 'tracesSampleRate' or 'tracesSampler' option.
645
666
  }
646
667
 
668
+ RCT_EXPORT_METHOD(startReplay: (BOOL)isHardCrash
669
+ resolver:(RCTPromiseResolveBlock)resolve
670
+ rejecter:(RCTPromiseRejectBlock)reject)
671
+ {
672
+ [PrivateSentrySDKOnly captureReplay];
673
+ resolve([PrivateSentrySDKOnly getReplayId]);
674
+ }
675
+
676
+ RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSString *, getCurrentReplayId)
677
+ {
678
+ return [PrivateSentrySDKOnly getReplayId];
679
+ }
680
+
681
+ - (void) addReplayRNRedactClasses: (NSDictionary *_Nullable)replayOptions
682
+ {
683
+ NSMutableArray *_Nonnull classesToRedact = [[NSMutableArray alloc] init];
684
+ if ([replayOptions[@"maskAllImages"] boolValue] == YES) {
685
+ [classesToRedact addObject: NSClassFromString(@"RCTImageView")];
686
+ }
687
+ if ([replayOptions[@"maskAllText"] boolValue] == YES) {
688
+ [classesToRedact addObject: NSClassFromString(@"RCTTextView")];
689
+ }
690
+ [PrivateSentrySDKOnly addReplayRedactClasses: classesToRedact];
691
+ }
692
+
647
693
  static NSString* const enabledProfilingMessage = @"Enable Hermes to use Sentry Profiling.";
648
694
  static SentryId* nativeProfileTraceId = nil;
649
695
  static uint64_t nativeProfileStartTime = 0;
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.22.2",
5
+ "version": "5.23.0-alpha.1",
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",
@@ -68,7 +68,7 @@
68
68
  },
69
69
  "dependencies": {
70
70
  "@sentry/browser": "7.113.0",
71
- "@sentry/cli": "2.30.4",
71
+ "@sentry/cli": "2.31.2",
72
72
  "@sentry/core": "7.113.0",
73
73
  "@sentry/hub": "7.113.0",
74
74
  "@sentry/integrations": "7.113.0",
@@ -44,6 +44,8 @@ export interface Spec extends TurboModule {
44
44
  fetchNativePackageName(): string | undefined | null;
45
45
  fetchNativeStackFramesBy(instructionsAddr: number[]): NativeStackFrames | undefined | null;
46
46
  initNativeReactNavigationNewFrameTracking(): Promise<void>;
47
+ startReplay(isHardCrash: boolean): Promise<string | undefined | null>;
48
+ getCurrentReplayId(): string | undefined | null;
47
49
  }
48
50
 
49
51
  export type NativeStackFrame = {
@@ -39,6 +39,8 @@ export interface Spec extends TurboModule {
39
39
  fetchNativePackageName(): string | undefined | null;
40
40
  fetchNativeStackFramesBy(instructionsAddr: number[]): NativeStackFrames | undefined | null;
41
41
  initNativeReactNavigationNewFrameTracking(): Promise<void>;
42
+ startReplay(isHardCrash: boolean): Promise<string | undefined | null>;
43
+ getCurrentReplayId(): string | undefined | null;
42
44
  }
43
45
  export type NativeStackFrame = {
44
46
  platform: string;
@@ -39,6 +39,14 @@ export declare class ReactNativeClient extends BaseClient<ReactNativeClientOptio
39
39
  * Sets up the integrations
40
40
  */
41
41
  setupIntegrations(): void;
42
+ /**
43
+ * @inheritDoc
44
+ */
45
+ init(): void;
46
+ /**
47
+ * @inheritdoc
48
+ */
49
+ protected _setupIntegrations(): void;
42
50
  /**
43
51
  * @inheritdoc
44
52
  */
@@ -3,6 +3,7 @@ export { addGlobalEventProcessor, addBreadcrumb, captureException, captureEvent,
3
3
  export { Integrations as BrowserIntegrations, ErrorBoundary, withErrorBoundary, createReduxEnhancer, Profiler, useProfiler, withProfiler, } from '@sentry/react';
4
4
  export { lastEventId } from '@sentry/browser';
5
5
  import * as Integrations from './integrations';
6
+ export { mobileReplayIntegration } from './integrations';
6
7
  import { SDK_NAME, SDK_VERSION } from './version';
7
8
  export type { ReactNativeOptions } from './options';
8
9
  export { ReactNativeClient } from './client';
@@ -8,4 +8,5 @@ export { ReactNativeInfo } from './reactnativeinfo';
8
8
  export { ModulesLoader } from './modulesloader';
9
9
  export { HermesProfiling } from '../profiling/integration';
10
10
  export { Spotlight } from './spotlight';
11
+ export { mobileReplayIntegration } from './mobilereplay';
11
12
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,36 @@
1
+ import type { IntegrationFnResult } from '@sentry/types';
2
+ export declare const MOBILE_REPLAY_INTEGRATION_NAME = "MobileReplay";
3
+ export interface MobileReplayOptions {
4
+ /**
5
+ * Mask all text in recordings
6
+ */
7
+ maskAllText?: boolean;
8
+ /**
9
+ * Mask all text in recordings
10
+ */
11
+ maskAllImages?: boolean;
12
+ }
13
+ type MobileReplayIntegration = IntegrationFnResult & {
14
+ options: Required<MobileReplayOptions>;
15
+ };
16
+ /**
17
+ * The Mobile Replay Integration, let's you adjust the default mobile replay options.
18
+ * To be passed to `Sentry.init` with `replaysOnErrorSampleRate` or `replaysSessionSampleRate`.
19
+ *
20
+ * ```javascript
21
+ * Sentry.init({
22
+ * _experiments: {
23
+ * replaysOnErrorSampleRate: 1.0,
24
+ * replaysSessionSampleRate: 1.0,
25
+ * },
26
+ * integrations: [mobileReplayIntegration({
27
+ * // Adjust the default options
28
+ * })],
29
+ * });
30
+ * ```
31
+ *
32
+ * @experimental
33
+ */
34
+ export declare const mobileReplayIntegration: (initOptions?: MobileReplayOptions) => MobileReplayIntegration;
35
+ export {};
36
+ //# sourceMappingURL=mobilereplay.d.ts.map
@@ -159,6 +159,28 @@ export interface BaseReactNativeOptions {
159
159
  * from the function, no screenshot will be attached.
160
160
  */
161
161
  beforeScreenshot?: (event: Event, hint: EventHint) => boolean;
162
+ /**
163
+ * Options which are in beta, or otherwise not guaranteed to be stable.
164
+ */
165
+ _experiments?: {
166
+ [key: string]: unknown;
167
+ /**
168
+ * The sample rate for profiling
169
+ * 1.0 will profile all transactions and 0 will profile none.
170
+ */
171
+ profilesSampleRate?: number;
172
+ /**
173
+ * The sample rate for session-long replays.
174
+ * 1.0 will record all sessions and 0 will record none.
175
+ */
176
+ replaysSessionSampleRate?: number;
177
+ /**
178
+ * The sample rate for sessions that has had an error occur.
179
+ * This is independent of `sessionSampleRate`.
180
+ * 1.0 will record all sessions and 0 will record none.
181
+ */
182
+ replaysOnErrorSampleRate?: number;
183
+ };
162
184
  }
163
185
  export interface ReactNativeTransportOptions extends BrowserTransportOptions {
164
186
  /**
@@ -170,9 +192,9 @@ export interface ReactNativeTransportOptions extends BrowserTransportOptions {
170
192
  * Configuration options for the Sentry ReactNative SDK.
171
193
  * @see ReactNativeFrontend for more information.
172
194
  */
173
- export interface ReactNativeOptions extends Options<ReactNativeTransportOptions>, BaseReactNativeOptions {
195
+ export interface ReactNativeOptions extends Omit<Options<ReactNativeTransportOptions>, '_experiments'>, BaseReactNativeOptions {
174
196
  }
175
- export interface ReactNativeClientOptions extends Omit<ClientOptions<ReactNativeTransportOptions>, 'tunnel'>, BaseReactNativeOptions {
197
+ export interface ReactNativeClientOptions extends Omit<ClientOptions<ReactNativeTransportOptions>, 'tunnel' | '_experiments'>, BaseReactNativeOptions {
176
198
  }
177
199
  export interface ReactNativeWrapperOptions {
178
200
  /** Props for the root React profiler */
@@ -0,0 +1,8 @@
1
+ import type { Client } from '@sentry/types';
2
+ /**
3
+ *
4
+ */
5
+ export declare function hasHooks(client: Client): client is Client & {
6
+ on: Required<Client>['on'];
7
+ };
8
+ //# sourceMappingURL=clientutils.d.ts.map
@@ -16,6 +16,10 @@ export declare function getExpoGoVersion(): string | undefined;
16
16
  export declare function getExpoSdkVersion(): string | undefined;
17
17
  /** Checks if the current platform is not web */
18
18
  export declare function notWeb(): boolean;
19
+ /** Checks if the current platform is supported mobile platform (iOS or Android) */
20
+ export declare function isMobileOs(): boolean;
21
+ /** Checks if the current platform is not supported mobile platform (iOS or Android) */
22
+ export declare function notMobileOs(): boolean;
19
23
  /** Returns Hermes Version if hermes is present in the runtime */
20
24
  export declare function getHermesVersion(): string | undefined;
21
25
  /** Returns default environment based on __DEV__ */
@@ -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.22.2";
3
+ export declare const SDK_VERSION = "5.23.0-alpha.1";
4
4
  //# sourceMappingURL=version.d.ts.map
@@ -1,5 +1,6 @@
1
1
  import type { Breadcrumb, Envelope, EnvelopeItem, Event, Package, SeverityLevel, User } from '@sentry/types';
2
2
  import { Platform } from 'react-native';
3
+ import type { MobileReplayOptions } from './integrations/mobilereplay';
3
4
  import type { NativeAppStartResponse, NativeDeviceContextsResponse, NativeFramesResponse, NativeReleaseResponse, NativeStackFrames, Spec } from './NativeRNSentry';
4
5
  import type { ReactNativeClientOptions } from './options';
5
6
  import type * as Hermes from './profiling/hermes';
@@ -13,6 +14,9 @@ export interface Screenshot {
13
14
  contentType: string;
14
15
  filename: string;
15
16
  }
17
+ export type NativeSdkOptions = Partial<ReactNativeClientOptions> & {
18
+ mobileReplayOptions: MobileReplayOptions | undefined;
19
+ };
16
20
  interface SentryNativeWrapper {
17
21
  enableNative: boolean;
18
22
  nativeIsReady: boolean;
@@ -29,7 +33,7 @@ interface SentryNativeWrapper {
29
33
  };
30
34
  _isModuleLoaded(module: Spec | undefined): module is Spec;
31
35
  isNativeAvailable(): boolean;
32
- initNativeSdk(options: Partial<ReactNativeClientOptions>): PromiseLike<boolean>;
36
+ initNativeSdk(options: NativeSdkOptions): PromiseLike<boolean>;
33
37
  closeNativeSdk(): PromiseLike<void>;
34
38
  sendEnvelope(envelope: Envelope): Promise<void>;
35
39
  captureScreenshot(): Promise<Screenshot[] | null>;
@@ -63,6 +67,8 @@ interface SentryNativeWrapper {
63
67
  */
64
68
  fetchNativeStackFramesBy(instructionsAddr: number[]): NativeStackFrames | null;
65
69
  initNativeReactNavigationNewFrameTracking(): Promise<void>;
70
+ startReplay(isHardCrash: boolean): Promise<string | null>;
71
+ getCurrentReplayId(): string | null;
66
72
  }
67
73
  /**
68
74
  * Our internal interface for calling native functions