@sentry/react-native 5.13.1-beta.1 → 5.14.0

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 (59) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/android/build.gradle +1 -1
  3. package/dist/js/NativeRNSentry.d.ts +1 -0
  4. package/dist/js/NativeRNSentry.d.ts.map +1 -1
  5. package/dist/js/NativeRNSentry.js.map +1 -1
  6. package/dist/js/profiling/cache.d.ts +3 -3
  7. package/dist/js/profiling/cache.d.ts.map +1 -1
  8. package/dist/js/profiling/cache.js.map +1 -1
  9. package/dist/js/profiling/debugid.d.ts +6 -0
  10. package/dist/js/profiling/debugid.d.ts.map +1 -0
  11. package/dist/js/profiling/debugid.js +29 -0
  12. package/dist/js/profiling/debugid.js.map +1 -0
  13. package/dist/js/profiling/hermes.d.ts +0 -9
  14. package/dist/js/profiling/hermes.d.ts.map +1 -1
  15. package/dist/js/profiling/hermes.js +0 -24
  16. package/dist/js/profiling/hermes.js.map +1 -1
  17. package/dist/js/profiling/integration.d.ts +19 -1
  18. package/dist/js/profiling/integration.d.ts.map +1 -1
  19. package/dist/js/profiling/integration.js +81 -8
  20. package/dist/js/profiling/integration.js.map +1 -1
  21. package/dist/js/profiling/nativeTypes.d.ts +43 -0
  22. package/dist/js/profiling/nativeTypes.d.ts.map +1 -0
  23. package/dist/js/profiling/nativeTypes.js +2 -0
  24. package/dist/js/profiling/nativeTypes.js.map +1 -0
  25. package/dist/js/profiling/types.d.ts +12 -1
  26. package/dist/js/profiling/types.d.ts.map +1 -1
  27. package/dist/js/profiling/types.js.map +1 -1
  28. package/dist/js/profiling/utils.d.ts +6 -6
  29. package/dist/js/profiling/utils.d.ts.map +1 -1
  30. package/dist/js/profiling/utils.js +33 -89
  31. package/dist/js/profiling/utils.js.map +1 -1
  32. package/dist/js/tools/sentryMetroSerializer.d.ts.map +1 -1
  33. package/dist/js/tools/sentryMetroSerializer.js +1 -2
  34. package/dist/js/tools/sentryMetroSerializer.js.map +1 -1
  35. package/dist/js/tools/utils.d.ts +2 -0
  36. package/dist/js/tools/utils.d.ts.map +1 -1
  37. package/dist/js/tools/utils.js +22 -1
  38. package/dist/js/tools/utils.js.map +1 -1
  39. package/dist/js/version.d.ts +1 -1
  40. package/dist/js/version.d.ts.map +1 -1
  41. package/dist/js/version.js +1 -1
  42. package/dist/js/version.js.map +1 -1
  43. package/dist/js/wrapper.d.ts +5 -1
  44. package/dist/js/wrapper.d.ts.map +1 -1
  45. package/dist/js/wrapper.js +8 -2
  46. package/dist/js/wrapper.js.map +1 -1
  47. package/ios/RNSentry.mm +70 -7
  48. package/package.json +11 -10
  49. package/src/js/NativeRNSentry.ts +1 -1
  50. package/ts3.8/dist/js/NativeRNSentry.d.ts +1 -0
  51. package/ts3.8/dist/js/profiling/cache.d.ts +3 -3
  52. package/ts3.8/dist/js/profiling/debugid.d.ts +6 -0
  53. package/ts3.8/dist/js/profiling/hermes.d.ts +0 -9
  54. package/ts3.8/dist/js/profiling/integration.d.ts +19 -1
  55. package/ts3.8/dist/js/profiling/nativeTypes.d.ts +43 -0
  56. package/ts3.8/dist/js/profiling/types.d.ts +12 -1
  57. package/ts3.8/dist/js/profiling/utils.d.ts +6 -6
  58. package/ts3.8/dist/js/version.d.ts +1 -1
  59. package/ts3.8/dist/js/wrapper.d.ts +5 -1
package/ios/RNSentry.mm CHANGED
@@ -7,6 +7,14 @@
7
7
  #import "RCTConvert.h"
8
8
  #endif
9
9
 
10
+ #if __has_include(<hermes/hermes.h>)
11
+ #define SENTRY_PROFILING_ENABLED 1
12
+ #import <Sentry/SentryProfilingConditionals.h>
13
+ #else
14
+ #define SENTRY_PROFILING_ENABLED 0
15
+ #define SENTRY_TARGET_PROFILING_SUPPORTED 0
16
+ #endif
17
+
10
18
  #import <Sentry/Sentry.h>
11
19
  #import <Sentry/PrivateSentrySDKOnly.h>
12
20
  #import <Sentry/SentryScreenFrames.h>
@@ -14,12 +22,7 @@
14
22
  #import <Sentry/SentryBinaryImageCache.h>
15
23
  #import <Sentry/SentryDependencyContainer.h>
16
24
  #import <Sentry/SentryFormatter.h>
17
-
18
- #if __has_include(<hermes/hermes.h>)
19
- #define SENTRY_PROFILING_ENABLED 1
20
- #else
21
- #define SENTRY_PROFILING_ENABLED 0
22
- #endif
25
+ #import <Sentry/SentryCurrentDateProvider.h>
23
26
 
24
27
  // This guard prevents importing Hermes in JSC apps
25
28
  #if SENTRY_PROFILING_ENABLED
@@ -594,16 +597,40 @@ RCT_EXPORT_METHOD(enableNativeFramesTracking)
594
597
  }
595
598
 
596
599
  static NSString* const enabledProfilingMessage = @"Enable Hermes to use Sentry Profiling.";
600
+ static SentryId* nativeProfileTraceId = nil;
601
+ static uint64_t nativeProfileStartTime = 0;
597
602
 
598
603
  RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSDictionary *, startProfiling)
599
604
  {
600
605
  #if SENTRY_PROFILING_ENABLED
601
606
  try {
602
607
  facebook::hermes::HermesRuntime::enableSamplingProfiler();
608
+ if (nativeProfileTraceId == nil && nativeProfileStartTime == 0) {
609
+ #if SENTRY_TARGET_PROFILING_SUPPORTED
610
+ nativeProfileTraceId = [[SentryId alloc] init];
611
+ nativeProfileStartTime = [PrivateSentrySDKOnly startProfilerForTrace: nativeProfileTraceId];
612
+ #endif
613
+ } else {
614
+ NSLog(@"Native profiling already in progress. Currently existing trace: %@", nativeProfileTraceId);
615
+ }
603
616
  return @{ @"started": @YES };
604
617
  } catch (const std::exception& ex) {
618
+ if (nativeProfileTraceId != nil) {
619
+ #if SENTRY_TARGET_PROFILING_SUPPORTED
620
+ [PrivateSentrySDKOnly discardProfilerForTrace: nativeProfileTraceId];
621
+ #endif
622
+ nativeProfileTraceId = nil;
623
+ }
624
+ nativeProfileStartTime = 0;
605
625
  return @{ @"error": [NSString stringWithCString: ex.what() encoding:[NSString defaultCStringEncoding]] };
606
626
  } catch (...) {
627
+ if (nativeProfileTraceId != nil) {
628
+ #if SENTRY_TARGET_PROFILING_SUPPORTED
629
+ [PrivateSentrySDKOnly discardProfilerForTrace: nativeProfileTraceId];
630
+ #endif
631
+ nativeProfileTraceId = nil;
632
+ }
633
+ nativeProfileStartTime = 0;
607
634
  return @{ @"error": @"Failed to start profiling" };
608
635
  }
609
636
  #else
@@ -615,6 +642,17 @@ RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSDictionary *, stopProfiling)
615
642
  {
616
643
  #if SENTRY_PROFILING_ENABLED
617
644
  try {
645
+ NSDictionary<NSString *, id> * nativeProfile = nil;
646
+ if (nativeProfileTraceId != nil && nativeProfileStartTime != 0) {
647
+ #if SENTRY_TARGET_PROFILING_SUPPORTED
648
+ uint64_t nativeProfileStopTime = [[[SentryDependencyContainer sharedInstance] dateProvider] systemTime];
649
+ nativeProfile = [PrivateSentrySDKOnly collectProfileBetween:nativeProfileStartTime and:nativeProfileStopTime forTrace:nativeProfileTraceId];
650
+ #endif
651
+ }
652
+ // Cleanup native profiles
653
+ nativeProfileTraceId = nil;
654
+ nativeProfileStartTime = 0;
655
+
618
656
  facebook::hermes::HermesRuntime::disableSamplingProfiler();
619
657
  std::stringstream ss;
620
658
  facebook::hermes::HermesRuntime::dumpSampledTraceToStream(ss);
@@ -633,10 +671,35 @@ RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSDictionary *, stopProfiling)
633
671
  }
634
672
  #endif
635
673
 
636
- return @{ @"profile": data };
674
+ if (data == nil) {
675
+ return @{ @"error": @"Failed to retrieve Hermes profile." };
676
+ }
677
+
678
+ if (nativeProfile == nil) {
679
+ return @{ @"profile": data };
680
+ }
681
+
682
+ return @{
683
+ @"profile": data,
684
+ @"nativeProfile": nativeProfile,
685
+ };
637
686
  } catch (const std::exception& ex) {
687
+ if (nativeProfileTraceId != nil) {
688
+ #if SENTRY_TARGET_PROFILING_SUPPORTED
689
+ [PrivateSentrySDKOnly discardProfilerForTrace: nativeProfileTraceId];
690
+ #endif
691
+ nativeProfileTraceId = nil;
692
+ }
693
+ nativeProfileStartTime = 0;
638
694
  return @{ @"error": [NSString stringWithCString: ex.what() encoding:[NSString defaultCStringEncoding]] };
639
695
  } catch (...) {
696
+ if (nativeProfileTraceId != nil) {
697
+ #if SENTRY_TARGET_PROFILING_SUPPORTED
698
+ [PrivateSentrySDKOnly discardProfilerForTrace: nativeProfileTraceId];
699
+ #endif
700
+ nativeProfileTraceId = nil;
701
+ }
702
+ nativeProfileStartTime = 0;
640
703
  return @{ @"error": @"Failed to stop profiling" };
641
704
  }
642
705
  #else
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.13.1-beta.1",
5
+ "version": "5.14.0",
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",
@@ -58,21 +58,22 @@
58
58
  "react-native": ">=0.65.0"
59
59
  },
60
60
  "dependencies": {
61
- "@sentry/browser": "7.80.0",
61
+ "@sentry/browser": "7.81.1",
62
62
  "@sentry/cli": "2.21.3",
63
- "@sentry/core": "7.80.0",
64
- "@sentry/hub": "7.80.0",
65
- "@sentry/integrations": "7.80.0",
66
- "@sentry/react": "7.80.0",
67
- "@sentry/types": "7.80.0",
68
- "@sentry/utils": "7.80.0"
63
+ "@sentry/core": "7.81.1",
64
+ "@sentry/hub": "7.81.1",
65
+ "@sentry/integrations": "7.81.1",
66
+ "@sentry/react": "7.81.1",
67
+ "@sentry/types": "7.81.1",
68
+ "@sentry/utils": "7.81.1"
69
69
  },
70
70
  "devDependencies": {
71
- "@sentry-internal/eslint-config-sdk": "7.80.0",
72
- "@sentry-internal/eslint-plugin-sdk": "7.80.0",
71
+ "@sentry-internal/eslint-config-sdk": "7.81.1",
72
+ "@sentry-internal/eslint-plugin-sdk": "7.81.1",
73
73
  "@sentry/typescript": "^5.20.1",
74
74
  "@sentry/wizard": "3.16.3",
75
75
  "@types/jest": "^29.5.3",
76
+ "@types/node": "^20.9.3",
76
77
  "@types/react": "^18.2.14",
77
78
  "@types/uglify-js": "^3.17.2",
78
79
  "@types/uuid": "^9.0.4",
@@ -32,7 +32,7 @@ export interface Spec extends TurboModule {
32
32
  fetchModules(): Promise<string | undefined | null>;
33
33
  fetchViewHierarchy(): Promise<number[] | undefined | null>;
34
34
  startProfiling(): { started?: boolean; error?: string };
35
- stopProfiling(): { profile?: string; error?: string };
35
+ stopProfiling(): { profile?: string; nativeProfile?: UnsafeObject; error?: string };
36
36
  fetchNativePackageName(): Promise<string | undefined | null>;
37
37
  fetchNativeStackFramesBy(instructionsAddr: number[]): Promise<NativeStackFrames | undefined | null>;
38
38
  }
@@ -30,6 +30,7 @@ export interface Spec extends TurboModule {
30
30
  };
31
31
  stopProfiling(): {
32
32
  profile?: string;
33
+ nativeProfile?: UnsafeObject;
33
34
  error?: string;
34
35
  };
35
36
  fetchNativePackageName(): Promise<string | undefined | null>;
@@ -1,7 +1,7 @@
1
- import type { RawThreadCpuProfile } from './types';
1
+ import type { CombinedProfileEvent } from './types';
2
2
  export declare const PROFILE_QUEUE: {
3
- get: (key: string) => RawThreadCpuProfile | undefined;
4
- add: (key: string, value: RawThreadCpuProfile) => void;
3
+ get: (key: string) => CombinedProfileEvent | undefined;
4
+ add: (key: string, value: CombinedProfileEvent) => void;
5
5
  delete: (key: string) => boolean;
6
6
  clear: () => void;
7
7
  size: () => number;
@@ -0,0 +1,6 @@
1
+ import type { DebugImage } from '@sentry/types';
2
+ /**
3
+ * Returns debug meta images of the loaded bundle.
4
+ */
5
+ export declare function getDebugMetadata(): DebugImage[];
6
+ //# sourceMappingURL=debugid.d.ts.map
@@ -1,4 +1,3 @@
1
- import type { RawThreadCpuProfile } from './types';
2
1
  export type StackFrameId = number;
3
2
  export type MicrosecondsSinceBoot = string;
4
3
  export interface TraceEvent {
@@ -38,12 +37,4 @@ export interface Profile {
38
37
  stackFrames: Record<string, StackFrame>;
39
38
  }
40
39
  export declare const DEFAULT_BUNDLE_NAME: string | undefined;
41
- /**
42
- * Starts Hermes Sampling Profiler and returns the timestamp when profiling started in nanoseconds.
43
- */
44
- export declare function startProfiling(): number | null;
45
- /**
46
- * Stops Hermes Sampling Profiler and returns the profile.
47
- */
48
- export declare function stopProfiling(): RawThreadCpuProfile | null;
49
40
  //# sourceMappingURL=hermes.d.ts.map
@@ -1,5 +1,7 @@
1
1
  import type { Hub } from '@sentry/core';
2
- import type { EventProcessor, Integration } from '@sentry/types';
2
+ import type { EventProcessor, Integration, ThreadCpuProfile } from '@sentry/types';
3
+ import type { NativeProfileEvent } from './nativeTypes';
4
+ import type { CombinedProfileEvent, HermesProfileEvent } from './types';
3
5
  export declare const MAX_PROFILE_DURATION_MS: number;
4
6
  /**
5
7
  * Profiling integration creates a profile for each transaction and adds it to the event envelope.
@@ -36,4 +38,20 @@ export declare class HermesProfiling implements Integration {
36
38
  private _createProfileEventFor;
37
39
  private _clearCurrentProfileTimeout;
38
40
  }
41
+ /**
42
+ * Starts Profilers and returns the timestamp when profiling started in nanoseconds.
43
+ */
44
+ export declare function startProfiling(): number | null;
45
+ /**
46
+ * Stops Profilers and returns collected combined profile.
47
+ */
48
+ export declare function stopProfiling(): CombinedProfileEvent | null;
49
+ /**
50
+ * Merges Hermes and Native profile events into one.
51
+ */
52
+ export declare function addNativeProfileToHermesProfile(hermes: HermesProfileEvent, native: NativeProfileEvent): CombinedProfileEvent;
53
+ /**
54
+ * Merges Hermes And Native profiles into one.
55
+ */
56
+ export declare function addNativeThreadCpuProfileToHermes(hermes: ThreadCpuProfile, native: ThreadCpuProfile, hermes_active_thread_id: string | undefined): CombinedProfileEvent['profile'];
39
57
  //# sourceMappingURL=integration.d.ts.map
@@ -0,0 +1,43 @@
1
+ export interface NativeProfileEvent {
2
+ profile_id: string;
3
+ profile: {
4
+ samples: {
5
+ stack_id: number;
6
+ thread_id: string;
7
+ queue_address?: string;
8
+ elapsed_since_start_ns: string;
9
+ }[];
10
+ stacks: number[][];
11
+ frames: {
12
+ function?: string;
13
+ instruction_addr?: string;
14
+ }[];
15
+ thread_metadata: Record<string, {
16
+ name?: string;
17
+ priority?: number;
18
+ }>;
19
+ queue_metadata?: Record<string, {
20
+ label: string;
21
+ }>;
22
+ };
23
+ transaction: {
24
+ active_thread_id: string;
25
+ };
26
+ measurements: Record<string, {
27
+ values: {
28
+ elapsed_since_start_ns: number;
29
+ value: number;
30
+ }[];
31
+ unit: string;
32
+ }>;
33
+ debug_meta: {
34
+ images: {
35
+ type: 'macho';
36
+ debug_id: string;
37
+ image_addr: string;
38
+ image_size: number;
39
+ code_file: string;
40
+ }[];
41
+ };
42
+ }
43
+ //# sourceMappingURL=nativeTypes.d.ts.map
@@ -1,7 +1,18 @@
1
- import type { ThreadCpuFrame, ThreadCpuProfile } from '@sentry/types';
1
+ import type { Profile, ThreadCpuFrame, ThreadCpuProfile } from '@sentry/types';
2
+ import type { NativeProfileEvent } from './nativeTypes';
2
3
  export interface RawThreadCpuProfile extends ThreadCpuProfile {
3
4
  frames: ThreadCpuFrame[];
4
5
  profile_id?: string;
5
6
  active_thread_id: string;
6
7
  }
8
+ export type HermesProfileEvent = {
9
+ platform: 'javascript';
10
+ version: '1';
11
+ profile: ThreadCpuProfile;
12
+ transaction: {
13
+ active_thread_id: string;
14
+ };
15
+ };
16
+ export type ProfileEvent = Profile;
17
+ export type CombinedProfileEvent = HermesProfileEvent & Partial<NativeProfileEvent>;
7
18
  //# sourceMappingURL=types.d.ts.map
@@ -1,9 +1,9 @@
1
- import type { DebugImage, Envelope, Event, Profile } from '@sentry/types';
2
- import type { RawThreadCpuProfile } from './types';
1
+ import type { Envelope, Event, Profile, ThreadCpuProfile } from '@sentry/types';
2
+ import type { CombinedProfileEvent, HermesProfileEvent, RawThreadCpuProfile } from './types';
3
3
  /**
4
4
  *
5
5
  */
6
- export declare function isValidProfile(profile: RawThreadCpuProfile): profile is RawThreadCpuProfile & {
6
+ export declare function isValidProfile(profile: ThreadCpuProfile): profile is RawThreadCpuProfile & {
7
7
  profile_id: string;
8
8
  };
9
9
  /**
@@ -17,11 +17,11 @@ export declare function findProfiledTransactionsFromEnvelope(envelope: Envelope)
17
17
  * @param event
18
18
  * @returns {Profile | null}
19
19
  */
20
- export declare function createProfilingEvent(profile: RawThreadCpuProfile, event: Event): Profile | null;
20
+ export declare function enrichCombinedProfileWithEventContext(profile_id: string, profile: CombinedProfileEvent, event: Event): Profile | null;
21
21
  /**
22
- * Returns debug meta images of the loaded bundle.
22
+ * Creates profiling event compatible carrier Object from raw Hermes profile.
23
23
  */
24
- export declare function getDebugMetadata(): DebugImage[];
24
+ export declare function createHermesProfilingEvent(profile: RawThreadCpuProfile): HermesProfileEvent;
25
25
  /**
26
26
  * Adds items to envelope if they are not already present - mutates the envelope.
27
27
  * @param envelope
@@ -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.13.1-beta.1";
3
+ export declare const SDK_VERSION = "5.14.0";
4
4
  //# sourceMappingURL=version.d.ts.map
@@ -3,6 +3,7 @@ import { Platform } from 'react-native';
3
3
  import type { NativeAppStartResponse, NativeDeviceContextsResponse, NativeFramesResponse, NativeReleaseResponse, NativeStackFrames, Spec } from './NativeRNSentry';
4
4
  import type { ReactNativeClientOptions } from './options';
5
5
  import type * as Hermes from './profiling/hermes';
6
+ import type { NativeProfileEvent } from './profiling/nativeTypes';
6
7
  export interface Screenshot {
7
8
  data: Uint8Array;
8
9
  contentType: string;
@@ -47,7 +48,10 @@ interface SentryNativeWrapper {
47
48
  fetchModules(): Promise<Record<string, string> | null>;
48
49
  fetchViewHierarchy(): PromiseLike<Uint8Array | null>;
49
50
  startProfiling(): boolean;
50
- stopProfiling(): Hermes.Profile | null;
51
+ stopProfiling(): {
52
+ hermesProfile: Hermes.Profile;
53
+ nativeProfile?: NativeProfileEvent;
54
+ } | null;
51
55
  fetchNativePackageName(): Promise<string | null>;
52
56
  /**
53
57
  * Fetches native stack frames and debug images for the instructions addresses.