@sentry/react-native 5.11.1 → 5.13.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.
- package/CHANGELOG.md +61 -4
- package/RNSentry.podspec +1 -1
- package/android/build.gradle +1 -1
- package/dist/js/index.d.ts +1 -1
- package/dist/js/index.d.ts.map +1 -1
- package/dist/js/index.js +1 -1
- package/dist/js/index.js.map +1 -1
- package/dist/js/integrations/debugsymbolicator.d.ts.map +1 -1
- package/dist/js/integrations/debugsymbolicator.js +1 -5
- package/dist/js/integrations/debugsymbolicator.js.map +1 -1
- package/dist/js/integrations/devicecontext.d.ts.map +1 -1
- package/dist/js/integrations/devicecontext.js +3 -0
- package/dist/js/integrations/devicecontext.js.map +1 -1
- package/dist/js/profiling/convertHermesProfile.d.ts +6 -1
- package/dist/js/profiling/convertHermesProfile.d.ts.map +1 -1
- package/dist/js/profiling/convertHermesProfile.js +38 -13
- package/dist/js/profiling/convertHermesProfile.js.map +1 -1
- package/dist/js/profiling/hermes.d.ts +3 -6
- package/dist/js/profiling/hermes.d.ts.map +1 -1
- package/dist/js/profiling/hermes.js +3 -10
- package/dist/js/profiling/hermes.js.map +1 -1
- package/dist/js/profiling/types.d.ts +3 -1
- package/dist/js/profiling/types.d.ts.map +1 -1
- package/dist/js/profiling/types.js.map +1 -1
- package/dist/js/profiling/utils.d.ts +5 -1
- package/dist/js/profiling/utils.d.ts.map +1 -1
- package/dist/js/profiling/utils.js +35 -5
- package/dist/js/profiling/utils.js.map +1 -1
- package/dist/js/sdk.d.ts.map +1 -1
- package/dist/js/sdk.js +4 -0
- package/dist/js/sdk.js.map +1 -1
- package/dist/js/tracing/reactnativetracing.d.ts +6 -0
- package/dist/js/tracing/reactnativetracing.d.ts.map +1 -1
- package/dist/js/tracing/reactnativetracing.js +15 -0
- package/dist/js/tracing/reactnativetracing.js.map +1 -1
- package/dist/js/utils/environment.d.ts +2 -0
- package/dist/js/utils/environment.d.ts.map +1 -1
- package/dist/js/utils/environment.js +4 -0
- package/dist/js/utils/environment.js.map +1 -1
- package/dist/js/version.d.ts +1 -1
- package/dist/js/version.js +1 -1
- package/dist/js/version.js.map +1 -1
- package/package.json +12 -12
- package/ts3.8/dist/js/index.d.ts +1 -1
- package/ts3.8/dist/js/profiling/convertHermesProfile.d.ts +6 -1
- package/ts3.8/dist/js/profiling/hermes.d.ts +3 -6
- package/ts3.8/dist/js/profiling/types.d.ts +3 -1
- package/ts3.8/dist/js/profiling/utils.d.ts +5 -1
- package/ts3.8/dist/js/tracing/reactnativetracing.d.ts +6 -0
- package/ts3.8/dist/js/utils/environment.d.ts +2 -0
- package/ts3.8/dist/js/version.d.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,65 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 5.13.0
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- Export New JS Performance API ([#3371](https://github.com/getsentry/sentry-react-native/pull/3371))
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
// Start a span that tracks the duration of expensiveFunction
|
|
11
|
+
const result = Sentry.startSpan({ name: 'important function' }, () => {
|
|
12
|
+
return expensiveFunction();
|
|
13
|
+
});
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Read more at https://github.com/getsentry/sentry-javascript/blob/develop/CHANGELOG.md#7690
|
|
17
|
+
|
|
18
|
+
- Report current screen in `contexts.app.view_names` ([#3339](https://github.com/getsentry/sentry-react-native/pull/3339))
|
|
19
|
+
|
|
20
|
+
### Fixes
|
|
21
|
+
|
|
22
|
+
- Remove `platform: node` from Debug Builds Events ([#3377](https://github.com/getsentry/sentry-react-native/pull/3377))
|
|
23
|
+
|
|
24
|
+
### Dependencies
|
|
25
|
+
|
|
26
|
+
- Bump Android SDK from v6.32.0 to v6.33.1 ([#3374](https://github.com/getsentry/sentry-react-native/pull/3374))
|
|
27
|
+
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#6331)
|
|
28
|
+
- [diff](https://github.com/getsentry/sentry-java/compare/6.32.0...6.33.1)
|
|
29
|
+
- Bump Cocoa SDK from v8.14.2 to v8.15.2 ([#3376](https://github.com/getsentry/sentry-react-native/pull/3376))
|
|
30
|
+
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8152)
|
|
31
|
+
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.14.2...8.15.2)
|
|
32
|
+
- Bump CLI from v2.21.2 to v2.21.3 ([#3381](https://github.com/getsentry/sentry-react-native/pull/3381))
|
|
33
|
+
- [changelog](https://github.com/getsentry/sentry-cli/blob/master/CHANGELOG.md#2213)
|
|
34
|
+
- [diff](https://github.com/getsentry/sentry-cli/compare/2.21.2...2.21.3)
|
|
35
|
+
- Bump JavaScript SDK from v7.76.0 to v7.80.0 ([#3372](https://github.com/getsentry/sentry-react-native/pull/3372))
|
|
36
|
+
- [changelog](https://github.com/getsentry/sentry-javascript/blob/develop/CHANGELOG.md#7800)
|
|
37
|
+
- [diff](https://github.com/getsentry/sentry-javascript/compare/7.76.0...7.80.0)
|
|
38
|
+
|
|
39
|
+
## 5.12.0
|
|
40
|
+
|
|
41
|
+
### Features
|
|
42
|
+
|
|
43
|
+
- Automatically detect environment if not set ([#3362](https://github.com/getsentry/sentry-react-native/pull/3362))
|
|
44
|
+
- Send Source Maps Debug ID for symbolicated Profiles ([#3343](https://github.com/getsentry/sentry-react-native/pull/3343))
|
|
45
|
+
|
|
46
|
+
### Fixes
|
|
47
|
+
|
|
48
|
+
- Add actual `activeThreadId` to Profiles ([#3338](https://github.com/getsentry/sentry-react-native/pull/3338))
|
|
49
|
+
- Parse Hermes Profiling Bytecode Frames ([#3342](https://github.com/getsentry/sentry-react-native/pull/3342))
|
|
50
|
+
|
|
51
|
+
### Dependencies
|
|
52
|
+
|
|
53
|
+
- Bump JavaScript SDK from v7.73.0 to v7.76.0 ([#3344](https://github.com/getsentry/sentry-react-native/pull/3344), [#3365](https://github.com/getsentry/sentry-react-native/pull/3365))
|
|
54
|
+
- [changelog](https://github.com/getsentry/sentry-javascript/blob/develop/CHANGELOG.md#7760)
|
|
55
|
+
- [diff](https://github.com/getsentry/sentry-javascript/compare/7.73.0...7.76.0)
|
|
56
|
+
- Bump Cocoa SDK from v8.13.0 to v8.14.2 ([#3340](https://github.com/getsentry/sentry-react-native/pull/3340))
|
|
57
|
+
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8142)
|
|
58
|
+
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.13.0...8.14.2)
|
|
59
|
+
- Bump Android SDK from v6.30.0 to v6.32.0 ([#3341](https://github.com/getsentry/sentry-react-native/pull/3341))
|
|
60
|
+
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#6320)
|
|
61
|
+
- [diff](https://github.com/getsentry/sentry-java/compare/6.30.0...6.32.0)
|
|
62
|
+
|
|
3
63
|
## 5.11.1
|
|
4
64
|
|
|
5
65
|
### Fixes
|
|
@@ -65,6 +125,7 @@
|
|
|
65
125
|
- Ignore defaults when warning about duplicate definition of trace propagation targets ([#3327](https://github.com/getsentry/sentry-react-native/pull/3327))
|
|
66
126
|
- Screenshots are not taken when the SDK is disabled ([#3333](https://github.com/getsentry/sentry-react-native/pull/3333))
|
|
67
127
|
- Use deprecated `ReactNativeTracingOptions.tracingOrigins` if set in the options ([#3331](https://github.com/getsentry/sentry-react-native/pull/3331))
|
|
128
|
+
- Cancel auto instrumentation transaction when app goes to background ([#3307](https://github.com/getsentry/sentry-react-native/pull/3307))
|
|
68
129
|
|
|
69
130
|
### Dependencies
|
|
70
131
|
|
|
@@ -89,10 +150,6 @@
|
|
|
89
150
|
- This flag equals `true` when Hermes Bundle contains Debug Info (Hermes Source Map was not emitted)
|
|
90
151
|
- Add `enableNdk` property to ReactNativeOptions for Android. ([#3304](https://github.com/getsentry/sentry-react-native/pull/3304))
|
|
91
152
|
|
|
92
|
-
### Fixes
|
|
93
|
-
|
|
94
|
-
- Cancel auto instrumentation transaction when app goes to background ([#3307])(https://github.com/getsentry/sentry-react-native/pull/3307)
|
|
95
|
-
|
|
96
153
|
## 5.9.2
|
|
97
154
|
|
|
98
155
|
### Fixes
|
package/RNSentry.podspec
CHANGED
package/android/build.gradle
CHANGED
package/dist/js/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Breadcrumb, Request, SdkInfo, Event, Exception, StackFrame, Stacktrace, Thread, User, UserFeedback, } from '@sentry/types';
|
|
2
|
-
export { addGlobalEventProcessor, addBreadcrumb, captureException, captureEvent, captureMessage, getHubFromCarrier, getCurrentHub, Hub, Scope, setContext, setExtra, setExtras, setTag, setTags, setUser, startTransaction, } from '@sentry/core';
|
|
2
|
+
export { addGlobalEventProcessor, addBreadcrumb, captureException, captureEvent, captureMessage, getHubFromCarrier, getCurrentHub, Hub, Scope, setContext, setExtra, setExtras, setTag, setTags, setUser, startTransaction, startInactiveSpan, startSpan, startSpanManual, getActiveSpan, } from '@sentry/core';
|
|
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';
|
package/dist/js/index.d.ts.map
CHANGED
|
@@ -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,iBAAiB,EACjB,aAAa,EACb,GAAG,EACH,KAAK,EACL,UAAU,EACV,QAAQ,EACR,SAAS,EACT,MAAM,EACN,OAAO,EACP,OAAO,EACP,gBAAgB,
|
|
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,iBAAiB,EACjB,aAAa,EACb,GAAG,EACH,KAAK,EACL,UAAU,EACV,QAAQ,EACR,SAAS,EACT,MAAM,EACN,OAAO,EACP,OAAO,EACP,gBAAgB,EAChB,iBAAiB,EACjB,SAAS,EACT,eAAe,EACf,aAAa,GACd,MAAM,cAAc,CAAC;AAKtB,OAAO,EACL,YAAY,IAAI,mBAAmB,EACnC,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,QAAQ,EACR,WAAW,EACX,YAAY,GACb,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,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,EACnB,SAAS,EACT,cAAc,GACf,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,EACjC,kBAAkB,GACnB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC"}
|
package/dist/js/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { addGlobalEventProcessor, addBreadcrumb, captureException, captureEvent, captureMessage, getHubFromCarrier, getCurrentHub, Hub, Scope, setContext, setExtra, setExtras, setTag, setTags, setUser, startTransaction, } from '@sentry/core';
|
|
1
|
+
export { addGlobalEventProcessor, addBreadcrumb, captureException, captureEvent, captureMessage, getHubFromCarrier, getCurrentHub, Hub, Scope, setContext, setExtra, setExtras, setTag, setTags, setUser, startTransaction, startInactiveSpan, startSpan, startSpanManual, getActiveSpan, } from '@sentry/core';
|
|
2
2
|
import { _addTracingExtensions } from './measurements';
|
|
3
3
|
_addTracingExtensions();
|
|
4
4
|
export { Integrations as BrowserIntegrations, ErrorBoundary, withErrorBoundary, createReduxEnhancer, Profiler, useProfiler, withProfiler, } from '@sentry/react';
|
package/dist/js/index.js.map
CHANGED
|
@@ -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,iBAAiB,EACjB,aAAa,EACb,GAAG,EACH,KAAK,EACL,UAAU,EACV,QAAQ,EACR,SAAS,EACT,MAAM,EACN,OAAO,EACP,OAAO,EACP,gBAAgB,
|
|
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,EAChB,iBAAiB,EACjB,SAAS,EACT,eAAe,EACf,aAAa,GACd,MAAM,cAAc,CAAC;AAEtB,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,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,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,EAEtB,kBAAkB,GACnB,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 startInactiveSpan,\n startSpan,\n startSpanManual,\n getActiveSpan,\n} from '@sentry/core';\n\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\nexport { lastEventId } from '@sentry/browser';\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 sentryTraceGesture,\n} from './tracing';\n\nexport { Integrations, SDK_NAME, SDK_VERSION };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debugsymbolicator.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/debugsymbolicator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAoB,WAAW,EAAc,MAAM,eAAe,CAAC;AAoB/E;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,6DAA6D;AAC7D,qBAAa,iBAAkB,YAAW,WAAW;IACnD;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAAuB;IAC/C;;OAEG;IACI,IAAI,EAAE,MAAM,CAAwB;IAE3C;;OAEG;IACI,SAAS,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"debugsymbolicator.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/debugsymbolicator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAoB,WAAW,EAAc,MAAM,eAAe,CAAC;AAoB/E;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,6DAA6D;AAC7D,qBAAa,iBAAkB,YAAW,WAAW;IACnD;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAAuB;IAC/C;;OAEG;IACI,IAAI,EAAE,MAAM,CAAwB;IAE3C;;OAEG;IACI,SAAS,IAAI,IAAI;IA2BxB;;;OAGG;YACW,YAAY;IAiC1B;;;OAGG;YACW,uCAAuC;IA4CrD;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IAW7B;;;;;OAKG;YACW,iBAAiB;CA0BhC"}
|
|
@@ -31,7 +31,6 @@ export class DebugSymbolicator {
|
|
|
31
31
|
stack = parseErrorStack(reactError.stack);
|
|
32
32
|
}
|
|
33
33
|
yield self._symbolicate(event, stack);
|
|
34
|
-
event.platform = 'node'; // Setting platform node makes sure we do not show source maps errors
|
|
35
34
|
return event;
|
|
36
35
|
}));
|
|
37
36
|
}
|
|
@@ -84,8 +83,6 @@ export class DebugSymbolicator {
|
|
|
84
83
|
catch (_oO) {
|
|
85
84
|
// We can't load devserver URL
|
|
86
85
|
}
|
|
87
|
-
// Below you will find lines marked with :HACK to prevent showing errors in the sentry ui
|
|
88
|
-
// But since this is a debug only feature: This is Fine (TM)
|
|
89
86
|
return Promise.all(frames.map((frame) => __awaiter(this, void 0, void 0, function* () {
|
|
90
87
|
let inApp = !!frame.column && !!frame.lineNumber;
|
|
91
88
|
inApp =
|
|
@@ -94,12 +91,11 @@ export class DebugSymbolicator {
|
|
|
94
91
|
!frame.file.includes('node_modules') &&
|
|
95
92
|
!frame.file.includes('native code');
|
|
96
93
|
const newFrame = {
|
|
94
|
+
lineno: frame.lineNumber,
|
|
97
95
|
colno: frame.column,
|
|
98
96
|
filename: frame.file,
|
|
99
97
|
function: frame.methodName,
|
|
100
98
|
in_app: inApp,
|
|
101
|
-
lineno: inApp ? frame.lineNumber : undefined,
|
|
102
|
-
platform: inApp ? 'javascript' : 'node', // :HACK
|
|
103
99
|
};
|
|
104
100
|
// The upstream `react-native@0.61` delegates parsing of stacks to `stacktrace-parser`, which is buggy and
|
|
105
101
|
// leaves a trailing `(address at` in the function name.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debugsymbolicator.js","sourceRoot":"","sources":["../../../src/js/integrations/debugsymbolicator.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,wBAAwB,GAAG,IAAI,MAAM,CAAC,CAAC,+BAA+B,EAAE,oBAAoB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AA2B/G,6DAA6D;AAC7D,MAAM,OAAO,iBAAiB;IAA9B;QAKE;;WAEG;QACI,SAAI,GAAW,iBAAiB,CAAC,EAAE,CAAC;IA0K7C,CAAC;IAxKC;;OAEG;IACI,SAAS;QACd,uBAAuB,CAAC,CAAO,KAAY,EAAE,IAAgB,EAAE,EAAE;YAC/D,MAAM,IAAI,GAAG,aAAa,EAAE,CAAC,cAAc,CAAC,iBAAiB,CAAC,CA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AElD,IAAI,YAAY,EAAE;gBAChB,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE;oBAC1B,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE;wBACvD,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,YAAY,EAAE,CAAC,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE;4BAC/E,MAAM,EAAE,KAAK;yBACd,CAAC,CAAC;wBAEH,IAAI,QAAQ,CAAC,EAAE,EAAE;4BACf,MAAM;yBACP;qBACF;iBACF;aACF;YAED,IAAI,QAAQ,IAAI,QAAQ,CAAC,EAAE,EAAE;gBAC3B,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;gBACtC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAElC,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;aACjC;;KACF;;AAhLD;;GAEG;AACW,oBAAE,GAAW,mBAAmB,CAAC","sourcesContent":["import { addGlobalEventProcessor, getCurrentHub } from '@sentry/core';\nimport type { Event, EventHint, Integration, StackFrame } from '@sentry/types';\nimport { addContextToFrame, logger } from '@sentry/utils';\n\nconst INTERNAL_CALLSITES_REGEX = new RegExp(['ReactNativeRenderer-dev\\\\.js$', 'MessageQueue\\\\.js$'].join('|'));\n\ninterface GetDevServer {\n (): { url: string };\n}\n\n/**\n * React Native Stack Frame\n */\ninterface ReactNativeFrame {\n // arguments: []\n column: number;\n file: string;\n lineNumber: number;\n methodName: string;\n}\n\n/**\n * React Native Error\n */\nexport type ReactNativeError = Error & {\n framesToPop?: number;\n jsEngine?: string;\n preventSymbolication?: boolean;\n componentStack?: string;\n};\n\n/** Tries to symbolicate the JS stack trace on the device. */\nexport class DebugSymbolicator implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'DebugSymbolicator';\n /**\n * @inheritDoc\n */\n public name: string = DebugSymbolicator.id;\n\n /**\n * @inheritDoc\n */\n public setupOnce(): void {\n addGlobalEventProcessor(async (event: Event, hint?: EventHint) => {\n const self = getCurrentHub().getIntegration(DebugSymbolicator);\n\n if (!self || hint === undefined || hint.originalException === undefined) {\n return event;\n }\n\n const reactError = hint.originalException as ReactNativeError;\n\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const parseErrorStack = require('react-native/Libraries/Core/Devtools/parseErrorStack');\n\n let stack;\n try {\n stack = parseErrorStack(reactError);\n } catch (e) {\n // In RN 0.64 `parseErrorStack` now only takes a string\n stack = parseErrorStack(reactError.stack);\n }\n\n await self._symbolicate(event, stack);\n\n event.platform = 'node'; // Setting platform node makes sure we do not show source maps errors\n\n return event;\n });\n }\n\n /**\n * Symbolicates the stack on the device talking to local dev server.\n * Mutates the passed event.\n */\n private async _symbolicate(event: Event, stack: string | undefined): Promise<void> {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const symbolicateStackTrace = require('react-native/Libraries/Core/Devtools/symbolicateStackTrace');\n const prettyStack = await symbolicateStackTrace(stack);\n\n if (prettyStack) {\n let newStack = prettyStack;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (prettyStack.stack) {\n // This has been changed in an react-native version so stack is contained in here\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n newStack = prettyStack.stack;\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const stackWithoutInternalCallsites = newStack.filter(\n (frame: { file?: string }) =>\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n frame.file && frame.file.match(INTERNAL_CALLSITES_REGEX) === null,\n );\n\n const symbolicatedFrames = await this._convertReactNativeFramesToSentryFrames(stackWithoutInternalCallsites);\n this._replaceFramesInEvent(event, symbolicatedFrames);\n } else {\n logger.error('The stack is null');\n }\n } catch (error) {\n if (error instanceof Error) {\n logger.warn(`Unable to symbolicate stack trace: ${error.message}`);\n }\n }\n }\n\n /**\n * Converts ReactNativeFrames to frames in the Sentry format\n * @param frames ReactNativeFrame[]\n */\n private async _convertReactNativeFramesToSentryFrames(frames: ReactNativeFrame[]): Promise<StackFrame[]> {\n let getDevServer: GetDevServer;\n try {\n getDevServer = require('react-native/Libraries/Core/Devtools/getDevServer');\n } catch (_oO) {\n // We can't load devserver URL\n }\n // Below you will find lines marked with :HACK to prevent showing errors in the sentry ui\n // But since this is a debug only feature: This is Fine (TM)\n return Promise.all(\n frames.map(async (frame: ReactNativeFrame): Promise<StackFrame> => {\n let inApp = !!frame.column && !!frame.lineNumber;\n inApp =\n inApp &&\n frame.file !== undefined &&\n !frame.file.includes('node_modules') &&\n !frame.file.includes('native code');\n\n const newFrame: StackFrame = {\n colno: frame.column,\n filename: frame.file,\n function: frame.methodName,\n in_app: inApp,\n lineno: inApp ? frame.lineNumber : undefined, // :HACK\n platform: inApp ? 'javascript' : 'node', // :HACK\n };\n\n // The upstream `react-native@0.61` delegates parsing of stacks to `stacktrace-parser`, which is buggy and\n // leaves a trailing `(address at` in the function name.\n // `react-native@0.62` seems to have custom logic to parse hermes frames specially.\n // Anyway, all we do here is throw away the bogus suffix.\n if (newFrame.function) {\n const addressAtPos = newFrame.function.indexOf('(address at');\n if (addressAtPos >= 0) {\n newFrame.function = newFrame.function.substring(0, addressAtPos).trim();\n }\n }\n\n if (inApp) {\n await this._addSourceContext(newFrame, getDevServer);\n }\n\n return newFrame;\n }),\n );\n }\n\n /**\n * Replaces the frames in the exception of a error.\n * @param event Event\n * @param frames StackFrame[]\n */\n private _replaceFramesInEvent(event: Event, frames: StackFrame[]): void {\n if (\n event.exception &&\n event.exception.values &&\n event.exception.values[0] &&\n event.exception.values[0].stacktrace\n ) {\n event.exception.values[0].stacktrace.frames = frames.reverse();\n }\n }\n\n /**\n * This tries to add source context for in_app Frames\n *\n * @param frame StackFrame\n * @param getDevServer function from RN to get DevServer URL\n */\n private async _addSourceContext(frame: StackFrame, getDevServer?: GetDevServer): Promise<void> {\n let response;\n\n const segments = frame.filename?.split('/') ?? [];\n\n if (getDevServer) {\n for (const idx in segments) {\n if (Object.prototype.hasOwnProperty.call(segments, idx)) {\n response = await fetch(`${getDevServer().url}${segments.slice(-idx).join('/')}`, {\n method: 'GET',\n });\n\n if (response.ok) {\n break;\n }\n }\n }\n }\n\n if (response && response.ok) {\n const content = await response.text();\n const lines = content.split('\\n');\n\n addContextToFrame(lines, frame);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"debugsymbolicator.js","sourceRoot":"","sources":["../../../src/js/integrations/debugsymbolicator.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,wBAAwB,GAAG,IAAI,MAAM,CAAC,CAAC,+BAA+B,EAAE,oBAAoB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AA2B/G,6DAA6D;AAC7D,MAAM,OAAO,iBAAiB;IAA9B;QAKE;;WAEG;QACI,SAAI,GAAW,iBAAiB,CAAC,EAAE,CAAC;IAqK7C,CAAC;IAnKC;;OAEG;IACI,SAAS;QACd,uBAAuB,CAAC,CAAO,KAAY,EAAE,IAAgB,EAAE,EAAE;YAC/D,MAAM,IAAI,GAAG,aAAa,EAAE,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;YAE/D,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,iBAAiB,KAAK,SAAS,EAAE;gBACvE,OAAO,KAAK,CAAC;aACd;YAED,MAAM,UAAU,GAAG,IAAI,CAAC,iBAAqC,CAAC;YAE9D,8DAA8D;YAC9D,MAAM,eAAe,GAAG,OAAO,CAAC,sDAAsD,CAAC,CAAC;YAExF,IAAI,KAAK,CAAC;YACV,IAAI;gBACF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AAM,QAAQ,CAAC,IAAI,EAAE,CAAC;gBACtC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAElC,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;aACjC;;KACF;;AA3KD;;GAEG;AACW,oBAAE,GAAW,mBAAmB,CAAC","sourcesContent":["import { addGlobalEventProcessor, getCurrentHub } from '@sentry/core';\nimport type { Event, EventHint, Integration, StackFrame } from '@sentry/types';\nimport { addContextToFrame, logger } from '@sentry/utils';\n\nconst INTERNAL_CALLSITES_REGEX = new RegExp(['ReactNativeRenderer-dev\\\\.js$', 'MessageQueue\\\\.js$'].join('|'));\n\ninterface GetDevServer {\n (): { url: string };\n}\n\n/**\n * React Native Stack Frame\n */\ninterface ReactNativeFrame {\n // arguments: []\n column: number;\n file: string;\n lineNumber: number;\n methodName: string;\n}\n\n/**\n * React Native Error\n */\nexport type ReactNativeError = Error & {\n framesToPop?: number;\n jsEngine?: string;\n preventSymbolication?: boolean;\n componentStack?: string;\n};\n\n/** Tries to symbolicate the JS stack trace on the device. */\nexport class DebugSymbolicator implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'DebugSymbolicator';\n /**\n * @inheritDoc\n */\n public name: string = DebugSymbolicator.id;\n\n /**\n * @inheritDoc\n */\n public setupOnce(): void {\n addGlobalEventProcessor(async (event: Event, hint?: EventHint) => {\n const self = getCurrentHub().getIntegration(DebugSymbolicator);\n\n if (!self || hint === undefined || hint.originalException === undefined) {\n return event;\n }\n\n const reactError = hint.originalException as ReactNativeError;\n\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const parseErrorStack = require('react-native/Libraries/Core/Devtools/parseErrorStack');\n\n let stack;\n try {\n stack = parseErrorStack(reactError);\n } catch (e) {\n // In RN 0.64 `parseErrorStack` now only takes a string\n stack = parseErrorStack(reactError.stack);\n }\n\n await self._symbolicate(event, stack);\n\n return event;\n });\n }\n\n /**\n * Symbolicates the stack on the device talking to local dev server.\n * Mutates the passed event.\n */\n private async _symbolicate(event: Event, stack: string | undefined): Promise<void> {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const symbolicateStackTrace = require('react-native/Libraries/Core/Devtools/symbolicateStackTrace');\n const prettyStack = await symbolicateStackTrace(stack);\n\n if (prettyStack) {\n let newStack = prettyStack;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (prettyStack.stack) {\n // This has been changed in an react-native version so stack is contained in here\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n newStack = prettyStack.stack;\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const stackWithoutInternalCallsites = newStack.filter(\n (frame: { file?: string }) =>\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n frame.file && frame.file.match(INTERNAL_CALLSITES_REGEX) === null,\n );\n\n const symbolicatedFrames = await this._convertReactNativeFramesToSentryFrames(stackWithoutInternalCallsites);\n this._replaceFramesInEvent(event, symbolicatedFrames);\n } else {\n logger.error('The stack is null');\n }\n } catch (error) {\n if (error instanceof Error) {\n logger.warn(`Unable to symbolicate stack trace: ${error.message}`);\n }\n }\n }\n\n /**\n * Converts ReactNativeFrames to frames in the Sentry format\n * @param frames ReactNativeFrame[]\n */\n private async _convertReactNativeFramesToSentryFrames(frames: ReactNativeFrame[]): Promise<StackFrame[]> {\n let getDevServer: GetDevServer;\n try {\n getDevServer = require('react-native/Libraries/Core/Devtools/getDevServer');\n } catch (_oO) {\n // We can't load devserver URL\n }\n return Promise.all(\n frames.map(async (frame: ReactNativeFrame): Promise<StackFrame> => {\n let inApp = !!frame.column && !!frame.lineNumber;\n inApp =\n inApp &&\n frame.file !== undefined &&\n !frame.file.includes('node_modules') &&\n !frame.file.includes('native code');\n\n const newFrame: StackFrame = {\n lineno: frame.lineNumber,\n colno: frame.column,\n filename: frame.file,\n function: frame.methodName,\n in_app: inApp,\n };\n\n // The upstream `react-native@0.61` delegates parsing of stacks to `stacktrace-parser`, which is buggy and\n // leaves a trailing `(address at` in the function name.\n // `react-native@0.62` seems to have custom logic to parse hermes frames specially.\n // Anyway, all we do here is throw away the bogus suffix.\n if (newFrame.function) {\n const addressAtPos = newFrame.function.indexOf('(address at');\n if (addressAtPos >= 0) {\n newFrame.function = newFrame.function.substring(0, addressAtPos).trim();\n }\n }\n\n if (inApp) {\n await this._addSourceContext(newFrame, getDevServer);\n }\n\n return newFrame;\n }),\n );\n }\n\n /**\n * Replaces the frames in the exception of a error.\n * @param event Event\n * @param frames StackFrame[]\n */\n private _replaceFramesInEvent(event: Event, frames: StackFrame[]): void {\n if (\n event.exception &&\n event.exception.values &&\n event.exception.values[0] &&\n event.exception.values[0].stacktrace\n ) {\n event.exception.values[0].stacktrace.frames = frames.reverse();\n }\n }\n\n /**\n * This tries to add source context for in_app Frames\n *\n * @param frame StackFrame\n * @param getDevServer function from RN to get DevServer URL\n */\n private async _addSourceContext(frame: StackFrame, getDevServer?: GetDevServer): Promise<void> {\n let response;\n\n const segments = frame.filename?.split('/') ?? [];\n\n if (getDevServer) {\n for (const idx in segments) {\n if (Object.prototype.hasOwnProperty.call(segments, idx)) {\n response = await fetch(`${getDevServer().url}${segments.slice(-idx).join('/')}`, {\n method: 'GET',\n });\n\n if (response.ok) {\n break;\n }\n }\n }\n }\n\n if (response && response.ok) {\n const content = await response.text();\n const lines = content.split('\\n');\n\n addContextToFrame(lines, frame);\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devicecontext.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/devicecontext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAS,cAAc,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAQ7E,uCAAuC;AACvC,qBAAa,aAAc,YAAW,WAAW;IAC/C;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAAmB;IAE3C;;OAEG;IACI,IAAI,EAAE,MAAM,CAAoB;IAEvC;;OAEG;IACI,SAAS,CAAC,uBAAuB,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,EAAE,aAAa,EAAE,MAAM,GAAG,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"devicecontext.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/devicecontext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAS,cAAc,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAQ7E,uCAAuC;AACvC,qBAAa,aAAc,YAAW,WAAW;IAC/C;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAAmB;IAE3C;;OAEG;IACI,IAAI,EAAE,MAAM,CAAoB;IAEvC;;OAEG;IACI,SAAS,CAAC,uBAAuB,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,EAAE,aAAa,EAAE,MAAM,GAAG,GAAG,IAAI;CA2E9G"}
|
|
@@ -42,6 +42,9 @@ export class DeviceContext {
|
|
|
42
42
|
}
|
|
43
43
|
if (nativeContexts) {
|
|
44
44
|
event.contexts = Object.assign(Object.assign({}, nativeContexts), event.contexts);
|
|
45
|
+
if (nativeContexts.app) {
|
|
46
|
+
event.contexts.app = Object.assign(Object.assign({}, nativeContexts.app), event.contexts.app);
|
|
47
|
+
}
|
|
45
48
|
}
|
|
46
49
|
const nativeTags = native.tags;
|
|
47
50
|
if (nativeTags) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devicecontext.js","sourceRoot":"","sources":["../../../src/js/integrations/devicecontext.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,uCAAuC;AACvC,MAAM,OAAO,aAAa;IAA1B;QAME;;WA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I,CAAC,KAAK,CAAC,KAAK,IAAI,WAAW,EAAE;gBAC/B,KAAK,CAAC,KAAK,GAAG,WAAW,CAAC;aAC3B;YAED,MAAM,iBAAiB,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;YAChD,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,iBAAiB,EAAE;gBAC3C,KAAK,CAAC,WAAW,GAAG,iBAAiB,CAAC;aACvC;YAED,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;gBAC5D,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,oBAAoB,CAAC;gBACjD,CAAC,CAAC,SAAS,CAAC;YACd,IAAI,iBAAiB,EAAE;gBACrB,KAAK,CAAC,WAAW,GAAG,iBAAiB,CAAC;aACvC;YAED,OAAO,KAAK,CAAC;QACf,CAAC,CAAA,CAAC,CAAC;IACL,CAAC;;AAvFD;;GAEG;AACW,gBAAE,GAAW,eAAe,CAAC","sourcesContent":["/* eslint-disable complexity */\nimport type { Event, EventProcessor, Hub, Integration } from '@sentry/types';\nimport { logger, severityLevelFromString } from '@sentry/utils';\nimport { AppState } from 'react-native';\n\nimport { breadcrumbFromObject } from '../breadcrumb';\nimport type { NativeDeviceContextsResponse } from '../NativeRNSentry';\nimport { NATIVE } from '../wrapper';\n\n/** Load device context from native. */\nexport class DeviceContext implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'DeviceContext';\n\n /**\n * @inheritDoc\n */\n public name: string = DeviceContext.id;\n\n /**\n * @inheritDoc\n */\n public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void {\n addGlobalEventProcessor(async (event: Event) => {\n const self = getCurrentHub().getIntegration(DeviceContext);\n if (!self) {\n return event;\n }\n\n let native: NativeDeviceContextsResponse | null = null;\n try {\n native = await NATIVE.fetchNativeDeviceContexts();\n } catch (e) {\n logger.log(`Failed to get device context from native: ${e}`);\n }\n\n if (!native) {\n return event;\n }\n\n const nativeUser = native.user;\n if (!event.user && nativeUser) {\n event.user = nativeUser;\n }\n\n let nativeContexts = native.contexts;\n if (AppState.currentState !== 'unknown') {\n nativeContexts = nativeContexts || {};\n nativeContexts.app = {\n ...nativeContexts.app,\n in_foreground: AppState.currentState === 'active',\n };\n }\n if (nativeContexts) {\n event.contexts = { ...nativeContexts, ...event.contexts };\n if (nativeContexts.app) {\n event.contexts.app = { ...nativeContexts.app, ...event.contexts.app };\n }\n }\n\n const nativeTags = native.tags;\n if (nativeTags) {\n event.tags = { ...nativeTags, ...event.tags };\n }\n\n const nativeExtra = native.extra;\n if (nativeExtra) {\n event.extra = { ...nativeExtra, ...event.extra };\n }\n\n const nativeFingerprint = native.fingerprint;\n if (nativeFingerprint) {\n event.fingerprint = (event.fingerprint ?? []).concat(\n nativeFingerprint.filter(item => (event.fingerprint ?? []).indexOf(item) < 0),\n );\n }\n\n const nativeLevel = typeof native['level'] === 'string' ? severityLevelFromString(native['level']) : undefined;\n if (!event.level && nativeLevel) {\n event.level = nativeLevel;\n }\n\n const nativeEnvironment = native['environment'];\n if (!event.environment && nativeEnvironment) {\n event.environment = nativeEnvironment;\n }\n\n const nativeBreadcrumbs = Array.isArray(native['breadcrumbs'])\n ? native['breadcrumbs'].map(breadcrumbFromObject)\n : undefined;\n if (nativeBreadcrumbs) {\n event.breadcrumbs = nativeBreadcrumbs;\n }\n\n return event;\n });\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ThreadCpuSample, ThreadId } from '@sentry/types';
|
|
1
|
+
import type { ThreadCpuFrame, ThreadCpuSample, ThreadId } from '@sentry/types';
|
|
2
2
|
import type * as Hermes from './hermes';
|
|
3
3
|
import type { RawThreadCpuProfile } from './types';
|
|
4
4
|
/**
|
|
@@ -24,4 +24,9 @@ export declare function mapSamples(hermesSamples: Hermes.Sample[], maxElapsedSin
|
|
|
24
24
|
hermesStacks: Set<Hermes.StackFrameId>;
|
|
25
25
|
jsThreads: Set<ThreadId>;
|
|
26
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* Parses Hermes StackFrame to Sentry StackFrame.
|
|
29
|
+
* For native frames only function name is returned, for Hermes bytecode the line and column are calculated.
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseHermesJSStackFrame(frame: Hermes.StackFrame): ThreadCpuFrame;
|
|
27
32
|
//# sourceMappingURL=convertHermesProfile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertHermesProfile.d.ts","sourceRoot":"","sources":["../../../src/js/profiling/convertHermesProfile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"convertHermesProfile.d.ts","sourceRoot":"","sources":["../../../src/js/profiling/convertHermesProfile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoB,cAAc,EAAE,eAAe,EAAkB,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGjH,OAAO,KAAK,KAAK,MAAM,MAAM,UAAU,CAAC;AAGxC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AASnD;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,MAAM,CAAC,OAAO,GAAG,mBAAmB,GAAG,IAAI,CA0ChG;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,EAC9B,sBAAsB,GAAE,MAAgC,GACvD;IACD,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACvC,SAAS,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;CAC1B,CA+BA;AA8DD;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,CAAC,UAAU,GAAG,cAAc,CA8BhF"}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { logger } from '@sentry/utils';
|
|
2
|
-
import {
|
|
3
|
-
import { ANDROID_DEFAULT_BUNDLE_NAME, IOS_DEFAULT_BUNDLE_NAME } from '../integrations/rewriteframes';
|
|
4
|
-
import { parseHermesStackFrameFunctionName } from './hermes';
|
|
2
|
+
import { DEFAULT_BUNDLE_NAME } from './hermes';
|
|
5
3
|
import { MAX_PROFILE_DURATION_MS } from './integration';
|
|
4
|
+
const PLACEHOLDER_THREAD_ID_STRING = '0';
|
|
6
5
|
const MS_TO_NS = 1e6;
|
|
7
6
|
const MAX_PROFILE_DURATION_NS = MAX_PROFILE_DURATION_MS * MS_TO_NS;
|
|
8
|
-
const ANONYMOUS_FUNCTION_NAME = 'anonymous';
|
|
9
7
|
const UNKNOWN_STACK_ID = -1;
|
|
10
8
|
const JS_THREAD_NAME = 'JavaScriptThread';
|
|
11
9
|
const JS_THREAD_PRIORITY = 1;
|
|
12
|
-
const DEFAULT_BUNDLE_NAME = Platform.OS === 'android' ? ANDROID_DEFAULT_BUNDLE_NAME : Platform.OS === 'ios' ? IOS_DEFAULT_BUNDLE_NAME : undefined;
|
|
13
10
|
/**
|
|
14
11
|
* Converts a Hermes profile to a Sentry profile.
|
|
15
12
|
*
|
|
@@ -46,11 +43,13 @@ export function convertToSentryProfile(hermesProfile) {
|
|
|
46
43
|
priority: JS_THREAD_PRIORITY,
|
|
47
44
|
};
|
|
48
45
|
}
|
|
46
|
+
const active_thread_id = Object.keys(thread_metadata)[0] || PLACEHOLDER_THREAD_ID_STRING;
|
|
49
47
|
return {
|
|
50
48
|
samples,
|
|
51
49
|
frames,
|
|
52
50
|
stacks,
|
|
53
51
|
thread_metadata,
|
|
52
|
+
active_thread_id,
|
|
54
53
|
};
|
|
55
54
|
}
|
|
56
55
|
/**
|
|
@@ -99,14 +98,7 @@ function mapFrames(hermesStackFrames) {
|
|
|
99
98
|
continue;
|
|
100
99
|
}
|
|
101
100
|
hermesStackFrameIdToSentryFrameIdMap.set(Number(key), frames.length);
|
|
102
|
-
|
|
103
|
-
const functionName = parseHermesStackFrameFunctionName(hermesFrame.name);
|
|
104
|
-
frames.push({
|
|
105
|
-
function: functionName || ANONYMOUS_FUNCTION_NAME,
|
|
106
|
-
file: hermesFrame.category == 'JavaScript' ? DEFAULT_BUNDLE_NAME : undefined,
|
|
107
|
-
lineno: hermesFrame.line !== undefined ? Number(hermesFrame.line) : undefined,
|
|
108
|
-
colno: hermesFrame.column !== undefined ? Number(hermesFrame.column) : undefined,
|
|
109
|
-
});
|
|
101
|
+
frames.push(parseHermesJSStackFrame(hermesStackFrames[key]));
|
|
110
102
|
}
|
|
111
103
|
return {
|
|
112
104
|
frames,
|
|
@@ -138,4 +130,37 @@ function mapStacks(hermesStacks, hermesStackFrames, hermesStackFrameIdToSentryFr
|
|
|
138
130
|
hermesStackToSentryStackMap,
|
|
139
131
|
};
|
|
140
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Parses Hermes StackFrame to Sentry StackFrame.
|
|
135
|
+
* For native frames only function name is returned, for Hermes bytecode the line and column are calculated.
|
|
136
|
+
*/
|
|
137
|
+
export function parseHermesJSStackFrame(frame) {
|
|
138
|
+
if (frame.category !== 'JavaScript') {
|
|
139
|
+
// Native
|
|
140
|
+
if (frame.name === '[root]') {
|
|
141
|
+
return { function: frame.name, in_app: false };
|
|
142
|
+
}
|
|
143
|
+
return { function: frame.name };
|
|
144
|
+
}
|
|
145
|
+
if (frame.funcVirtAddr !== undefined && frame.offset !== undefined) {
|
|
146
|
+
// Hermes Bytecode
|
|
147
|
+
return {
|
|
148
|
+
function: frame.name,
|
|
149
|
+
abs_path: DEFAULT_BUNDLE_NAME,
|
|
150
|
+
// https://github.com/krystofwoldrich/metro/blob/417e6f276ff9422af6039fc4d1bce41fcf7d9f46/packages/metro-symbolicate/src/Symbolication.js#L298-L301
|
|
151
|
+
// Hermes lineno is hardcoded 1, currently only one bundle symbolication is supported by metro-symbolicate and thus by us.
|
|
152
|
+
lineno: 1,
|
|
153
|
+
// Hermes colno is 0-based, while Sentry is 1-based
|
|
154
|
+
colno: Number(frame.funcVirtAddr) + Number(frame.offset) + 1,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
// JavaScript
|
|
158
|
+
const indexOfLeftParenthesis = frame.name.indexOf('(');
|
|
159
|
+
return {
|
|
160
|
+
function: indexOfLeftParenthesis !== -1 ? frame.name.substring(0, indexOfLeftParenthesis) || undefined : frame.name,
|
|
161
|
+
abs_path: DEFAULT_BUNDLE_NAME,
|
|
162
|
+
lineno: frame.line !== undefined ? Number(frame.line) : undefined,
|
|
163
|
+
colno: frame.column !== undefined ? Number(frame.column) : undefined,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
141
166
|
//# sourceMappingURL=convertHermesProfile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertHermesProfile.js","sourceRoot":"","sources":["../../../src/js/profiling/convertHermesProfile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAErG,OAAO,EAAE,iCAAiC,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAGxD,MAAM,QAAQ,GAAG,GAAG,CAAC;AACrB,MAAM,uBAAuB,GAAG,uBAAuB,GAAG,QAAQ,CAAC;AACnE,MAAM,uBAAuB,GAAG,WAAW,CAAC;AAC5C,MAAM,gBAAgB,GAAG,CAAC,CAAC,CAAC;AAC5B,MAAM,cAAc,GAAG,kBAAkB,CAAC;AAC1C,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,mBAAmB,GACvB,QAAQ,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,KAAK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BAAoB,CAAC,CAAC;YACrF,aAAa,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YACzD,oBAAoB,GAAG,iBAAiB,CAAC,oBAAoB,CAAC,IAAI,iBAAiB,CAAC,oBAAoB,CAAC,CAAC,MAAM,CAAC;SAClH;QACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KACpB;IAED,OAAO;QACL,MAAM;QACN,2BAA2B;KAC5B,CAAC;AACJ,CAAC","sourcesContent":["import type { FrameId, StackId, ThreadCpuFrame, ThreadCpuSample, ThreadCpuStack, ThreadId } from '@sentry/types';\nimport { logger } from '@sentry/utils';\nimport { Platform } from 'react-native';\n\nimport { ANDROID_DEFAULT_BUNDLE_NAME, IOS_DEFAULT_BUNDLE_NAME } from '../integrations/rewriteframes';\nimport type * as Hermes from './hermes';\nimport { parseHermesStackFrameFunctionName } from './hermes';\nimport { MAX_PROFILE_DURATION_MS } from './integration';\nimport type { RawThreadCpuProfile } from './types';\n\nconst MS_TO_NS = 1e6;\nconst MAX_PROFILE_DURATION_NS = MAX_PROFILE_DURATION_MS * MS_TO_NS;\nconst ANONYMOUS_FUNCTION_NAME = 'anonymous';\nconst UNKNOWN_STACK_ID = -1;\nconst JS_THREAD_NAME = 'JavaScriptThread';\nconst JS_THREAD_PRIORITY = 1;\nconst DEFAULT_BUNDLE_NAME =\n Platform.OS === 'android' ? ANDROID_DEFAULT_BUNDLE_NAME : Platform.OS === 'ios' ? IOS_DEFAULT_BUNDLE_NAME : undefined;\n\n/**\n * Converts a Hermes profile to a Sentry profile.\n *\n * Maps Hermes samples to Sentry samples.\n * Maps Hermes stack frames to Sentry frames.\n * Hermes stack frame is an object representing a function call in the stack\n * with a link to its parent stack frame. Root of the represented stack tree\n * is main function call in Hermes that is [root] stack frame.\n *\n * @returns Sentry profile or null if no samples are found.\n */\nexport function convertToSentryProfile(hermesProfile: Hermes.Profile): RawThreadCpuProfile | null {\n if (hermesProfile.samples.length === 0) {\n logger.warn('[Profiling] No samples found in profile.');\n return null;\n }\n\n const { samples, hermesStacks, jsThreads } = mapSamples(hermesProfile.samples);\n\n const { frames, hermesStackFrameIdToSentryFrameIdMap } = mapFrames(hermesProfile.stackFrames);\n\n const { stacks, hermesStackToSentryStackMap } = mapStacks(\n hermesStacks,\n hermesProfile.stackFrames,\n hermesStackFrameIdToSentryFrameIdMap,\n );\n\n for (const sample of samples) {\n const sentryStackId = hermesStackToSentryStackMap.get(sample.stack_id);\n if (sentryStackId === undefined) {\n logger.error(`[Profiling] Hermes Stack ID ${sample.stack_id} not found when mapping to Sentry Stack ID.`);\n sample.stack_id = UNKNOWN_STACK_ID;\n } else {\n sample.stack_id = sentryStackId;\n }\n }\n\n const thread_metadata: Record<ThreadId, { name?: string; priority?: number }> = {};\n for (const jsThreadId of jsThreads) {\n thread_metadata[jsThreadId] = {\n name: JS_THREAD_NAME,\n priority: JS_THREAD_PRIORITY,\n };\n }\n\n return {\n samples,\n frames,\n stacks,\n thread_metadata,\n };\n}\n\n/**\n * Maps Hermes samples to Sentry samples.\n * Calculates the elapsed time since the first sample based on the absolute timestamps of the Hermes samples.\n * Hermes stack frame IDs represent the last (leaf, furthest from the main func) frame of the call stack.\n * @returns the mapped Sentry samples, the set of Hermes stack frame IDs, and the set of JS thread IDs\n */\nexport function mapSamples(\n hermesSamples: Hermes.Sample[],\n maxElapsedSinceStartNs: number = MAX_PROFILE_DURATION_NS,\n): {\n samples: ThreadCpuSample[];\n hermesStacks: Set<Hermes.StackFrameId>;\n jsThreads: Set<ThreadId>;\n} {\n const jsThreads = new Set<ThreadId>();\n const hermesStacks = new Set<Hermes.StackFrameId>();\n\n const start = Number(hermesSamples[0].ts);\n const samples: ThreadCpuSample[] = [];\n for (const hermesSample of hermesSamples) {\n jsThreads.add(hermesSample.tid);\n hermesStacks.add(hermesSample.sf);\n\n const elapsed_since_start_ns = (Number(hermesSample.ts) - start) * 1e3;\n if (elapsed_since_start_ns >= maxElapsedSinceStartNs) {\n logger.warn(\n `[Profiling] Sample has elapsed time since start ${elapsed_since_start_ns}ns ` +\n `greater than the max elapsed time ${maxElapsedSinceStartNs}ns.`,\n );\n break;\n }\n\n samples.push({\n stack_id: hermesSample.sf,\n thread_id: hermesSample.tid,\n elapsed_since_start_ns: elapsed_since_start_ns.toFixed(0),\n });\n }\n\n return {\n samples,\n hermesStacks,\n jsThreads,\n };\n}\n\n/**\n * Maps Hermes StackFrames tree represented as an JS object to a Sentry frames array.\n * Converts line and columns strings to numbers.\n * @returns the mapped Sentry frames\n */\nfunction mapFrames(hermesStackFrames: Record<Hermes.StackFrameId, Hermes.StackFrame>): {\n frames: ThreadCpuFrame[];\n hermesStackFrameIdToSentryFrameIdMap: Map<Hermes.StackFrameId, FrameId>;\n} {\n const frames: ThreadCpuFrame[] = [];\n const hermesStackFrameIdToSentryFrameIdMap = new Map<Hermes.StackFrameId, FrameId>();\n for (const key in hermesStackFrames) {\n // asc order based on the key is not guaranteed\n if (!Object.prototype.hasOwnProperty.call(hermesStackFrames, key)) {\n continue;\n }\n hermesStackFrameIdToSentryFrameIdMap.set(Number(key), frames.length);\n const hermesFrame = hermesStackFrames[key];\n\n const functionName = parseHermesStackFrameFunctionName(hermesFrame.name);\n frames.push({\n function: functionName || ANONYMOUS_FUNCTION_NAME,\n file: hermesFrame.category == 'JavaScript' ? DEFAULT_BUNDLE_NAME : undefined,\n lineno: hermesFrame.line !== undefined ? Number(hermesFrame.line) : undefined,\n colno: hermesFrame.column !== undefined ? Number(hermesFrame.column) : undefined,\n });\n }\n\n return {\n frames,\n hermesStackFrameIdToSentryFrameIdMap,\n };\n}\n\n/**\n * Maps Hermes stack frame IDs to Sentry stack arrays.\n * Hermes stack frame IDs represent the last (leaf, furthest from the main func) frame of the call stack.\n * @returns the mapped Sentry stacks and a map from Hermes stack IDs to Sentry stack IDs (indices in the stacks array)\n */\nfunction mapStacks(\n hermesStacks: Set<Hermes.StackFrameId>,\n hermesStackFrames: Record<Hermes.StackFrameId, Hermes.StackFrame>,\n hermesStackFrameIdToSentryFrameIdMap: Map<Hermes.StackFrameId, FrameId>,\n): {\n stacks: ThreadCpuStack[];\n hermesStackToSentryStackMap: Map<Hermes.StackFrameId, StackId>;\n} {\n const hermesStackToSentryStackMap = new Map<Hermes.StackFrameId, StackId>();\n const stacks: ThreadCpuStack[] = [];\n for (const hermesStackFunctionFrameId of hermesStacks) {\n const stackId = stacks.length;\n hermesStackToSentryStackMap.set(hermesStackFunctionFrameId, stackId);\n const stack: ThreadCpuStack = [];\n let currentHermesFrameId: Hermes.StackFrameId | undefined = hermesStackFunctionFrameId;\n while (currentHermesFrameId !== undefined) {\n const sentryFrameId = hermesStackFrameIdToSentryFrameIdMap.get(currentHermesFrameId);\n sentryFrameId !== undefined && stack.push(sentryFrameId);\n currentHermesFrameId = hermesStackFrames[currentHermesFrameId] && hermesStackFrames[currentHermesFrameId].parent;\n }\n stacks.push(stack);\n }\n\n return {\n stacks,\n hermesStackToSentryStackMap,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"convertHermesProfile.js","sourceRoot":"","sources":["../../../src/js/profiling/convertHermesProfile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAGxD,MAAM,4BAA4B,GAAG,GAAG,CAAC;AACzC,MAAM,QAAQ,GAAG,GAAG,CAAC;AACrB,MAAM,uBAAuB,GAAG,uBAAuB,GAAG,QAAQ,CAAC;AACnE,MAAM,gBAAgB,GAAG,CAAC,CAAC,CAAC;AAC5B,MAAM,cAAc,GAAG,kBAAkB,CAAC;AAC1C,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAE7B;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB,CAAC,aAA6B;IAClE,IAAI,aAAa,CAAC,OAAO,CAAC,MAAM,K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,MAAM,EAAE,KAAK,EAAE,CAAC;SAChD;QACD,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;KACjC;IAED,IAAI,KAAK,CAAC,YAAY,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE;QAClE,kBAAkB;QAClB,OAAO;YACL,QAAQ,EAAE,KAAK,CAAC,IAAI;YACpB,QAAQ,EAAE,mBAAmB;YAC7B,mJAAmJ;YACnJ,0HAA0H;YAC1H,MAAM,EAAE,CAAC;YACT,mDAAmD;YACnD,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC;SAC7D,CAAC;KACH;IAED,aAAa;IACb,MAAM,sBAAsB,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACvD,OAAO;QACL,QAAQ,EAAE,sBAAsB,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,sBAAsB,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI;QACnH,QAAQ,EAAE,mBAAmB;QAC7B,MAAM,EAAE,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;QACjE,KAAK,EAAE,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;KACrE,CAAC;AACJ,CAAC","sourcesContent":["import type { FrameId, StackId, ThreadCpuFrame, ThreadCpuSample, ThreadCpuStack, ThreadId } from '@sentry/types';\nimport { logger } from '@sentry/utils';\n\nimport type * as Hermes from './hermes';\nimport { DEFAULT_BUNDLE_NAME } from './hermes';\nimport { MAX_PROFILE_DURATION_MS } from './integration';\nimport type { RawThreadCpuProfile } from './types';\n\nconst PLACEHOLDER_THREAD_ID_STRING = '0';\nconst MS_TO_NS = 1e6;\nconst MAX_PROFILE_DURATION_NS = MAX_PROFILE_DURATION_MS * MS_TO_NS;\nconst UNKNOWN_STACK_ID = -1;\nconst JS_THREAD_NAME = 'JavaScriptThread';\nconst JS_THREAD_PRIORITY = 1;\n\n/**\n * Converts a Hermes profile to a Sentry profile.\n *\n * Maps Hermes samples to Sentry samples.\n * Maps Hermes stack frames to Sentry frames.\n * Hermes stack frame is an object representing a function call in the stack\n * with a link to its parent stack frame. Root of the represented stack tree\n * is main function call in Hermes that is [root] stack frame.\n *\n * @returns Sentry profile or null if no samples are found.\n */\nexport function convertToSentryProfile(hermesProfile: Hermes.Profile): RawThreadCpuProfile | null {\n if (hermesProfile.samples.length === 0) {\n logger.warn('[Profiling] No samples found in profile.');\n return null;\n }\n\n const { samples, hermesStacks, jsThreads } = mapSamples(hermesProfile.samples);\n\n const { frames, hermesStackFrameIdToSentryFrameIdMap } = mapFrames(hermesProfile.stackFrames);\n\n const { stacks, hermesStackToSentryStackMap } = mapStacks(\n hermesStacks,\n hermesProfile.stackFrames,\n hermesStackFrameIdToSentryFrameIdMap,\n );\n\n for (const sample of samples) {\n const sentryStackId = hermesStackToSentryStackMap.get(sample.stack_id);\n if (sentryStackId === undefined) {\n logger.error(`[Profiling] Hermes Stack ID ${sample.stack_id} not found when mapping to Sentry Stack ID.`);\n sample.stack_id = UNKNOWN_STACK_ID;\n } else {\n sample.stack_id = sentryStackId;\n }\n }\n\n const thread_metadata: Record<ThreadId, { name?: string; priority?: number }> = {};\n for (const jsThreadId of jsThreads) {\n thread_metadata[jsThreadId] = {\n name: JS_THREAD_NAME,\n priority: JS_THREAD_PRIORITY,\n };\n }\n const active_thread_id = Object.keys(thread_metadata)[0] || PLACEHOLDER_THREAD_ID_STRING;\n\n return {\n samples,\n frames,\n stacks,\n thread_metadata,\n active_thread_id,\n };\n}\n\n/**\n * Maps Hermes samples to Sentry samples.\n * Calculates the elapsed time since the first sample based on the absolute timestamps of the Hermes samples.\n * Hermes stack frame IDs represent the last (leaf, furthest from the main func) frame of the call stack.\n * @returns the mapped Sentry samples, the set of Hermes stack frame IDs, and the set of JS thread IDs\n */\nexport function mapSamples(\n hermesSamples: Hermes.Sample[],\n maxElapsedSinceStartNs: number = MAX_PROFILE_DURATION_NS,\n): {\n samples: ThreadCpuSample[];\n hermesStacks: Set<Hermes.StackFrameId>;\n jsThreads: Set<ThreadId>;\n} {\n const jsThreads = new Set<ThreadId>();\n const hermesStacks = new Set<Hermes.StackFrameId>();\n\n const start = Number(hermesSamples[0].ts);\n const samples: ThreadCpuSample[] = [];\n for (const hermesSample of hermesSamples) {\n jsThreads.add(hermesSample.tid);\n hermesStacks.add(hermesSample.sf);\n\n const elapsed_since_start_ns = (Number(hermesSample.ts) - start) * 1e3;\n if (elapsed_since_start_ns >= maxElapsedSinceStartNs) {\n logger.warn(\n `[Profiling] Sample has elapsed time since start ${elapsed_since_start_ns}ns ` +\n `greater than the max elapsed time ${maxElapsedSinceStartNs}ns.`,\n );\n break;\n }\n\n samples.push({\n stack_id: hermesSample.sf,\n thread_id: hermesSample.tid,\n elapsed_since_start_ns: elapsed_since_start_ns.toFixed(0),\n });\n }\n\n return {\n samples,\n hermesStacks,\n jsThreads,\n };\n}\n\n/**\n * Maps Hermes StackFrames tree represented as an JS object to a Sentry frames array.\n * Converts line and columns strings to numbers.\n * @returns the mapped Sentry frames\n */\nfunction mapFrames(hermesStackFrames: Record<Hermes.StackFrameId, Hermes.StackFrame>): {\n frames: ThreadCpuFrame[];\n hermesStackFrameIdToSentryFrameIdMap: Map<Hermes.StackFrameId, FrameId>;\n} {\n const frames: ThreadCpuFrame[] = [];\n const hermesStackFrameIdToSentryFrameIdMap = new Map<Hermes.StackFrameId, FrameId>();\n for (const key in hermesStackFrames) {\n // asc order based on the key is not guaranteed\n if (!Object.prototype.hasOwnProperty.call(hermesStackFrames, key)) {\n continue;\n }\n hermesStackFrameIdToSentryFrameIdMap.set(Number(key), frames.length);\n frames.push(parseHermesJSStackFrame(hermesStackFrames[key]));\n }\n\n return {\n frames,\n hermesStackFrameIdToSentryFrameIdMap,\n };\n}\n\n/**\n * Maps Hermes stack frame IDs to Sentry stack arrays.\n * Hermes stack frame IDs represent the last (leaf, furthest from the main func) frame of the call stack.\n * @returns the mapped Sentry stacks and a map from Hermes stack IDs to Sentry stack IDs (indices in the stacks array)\n */\nfunction mapStacks(\n hermesStacks: Set<Hermes.StackFrameId>,\n hermesStackFrames: Record<Hermes.StackFrameId, Hermes.StackFrame>,\n hermesStackFrameIdToSentryFrameIdMap: Map<Hermes.StackFrameId, FrameId>,\n): {\n stacks: ThreadCpuStack[];\n hermesStackToSentryStackMap: Map<Hermes.StackFrameId, StackId>;\n} {\n const hermesStackToSentryStackMap = new Map<Hermes.StackFrameId, StackId>();\n const stacks: ThreadCpuStack[] = [];\n for (const hermesStackFunctionFrameId of hermesStacks) {\n const stackId = stacks.length;\n hermesStackToSentryStackMap.set(hermesStackFunctionFrameId, stackId);\n const stack: ThreadCpuStack = [];\n let currentHermesFrameId: Hermes.StackFrameId | undefined = hermesStackFunctionFrameId;\n while (currentHermesFrameId !== undefined) {\n const sentryFrameId = hermesStackFrameIdToSentryFrameIdMap.get(currentHermesFrameId);\n sentryFrameId !== undefined && stack.push(sentryFrameId);\n currentHermesFrameId = hermesStackFrames[currentHermesFrameId] && hermesStackFrames[currentHermesFrameId].parent;\n }\n stacks.push(stack);\n }\n\n return {\n stacks,\n hermesStackToSentryStackMap,\n };\n}\n\n/**\n * Parses Hermes StackFrame to Sentry StackFrame.\n * For native frames only function name is returned, for Hermes bytecode the line and column are calculated.\n */\nexport function parseHermesJSStackFrame(frame: Hermes.StackFrame): ThreadCpuFrame {\n if (frame.category !== 'JavaScript') {\n // Native\n if (frame.name === '[root]') {\n return { function: frame.name, in_app: false };\n }\n return { function: frame.name };\n }\n\n if (frame.funcVirtAddr !== undefined && frame.offset !== undefined) {\n // Hermes Bytecode\n return {\n function: frame.name,\n abs_path: DEFAULT_BUNDLE_NAME,\n // https://github.com/krystofwoldrich/metro/blob/417e6f276ff9422af6039fc4d1bce41fcf7d9f46/packages/metro-symbolicate/src/Symbolication.js#L298-L301\n // Hermes lineno is hardcoded 1, currently only one bundle symbolication is supported by metro-symbolicate and thus by us.\n lineno: 1,\n // Hermes colno is 0-based, while Sentry is 1-based\n colno: Number(frame.funcVirtAddr) + Number(frame.offset) + 1,\n };\n }\n\n // JavaScript\n const indexOfLeftParenthesis = frame.name.indexOf('(');\n return {\n function: indexOfLeftParenthesis !== -1 ? frame.name.substring(0, indexOfLeftParenthesis) || undefined : frame.name,\n abs_path: DEFAULT_BUNDLE_NAME,\n lineno: frame.line !== undefined ? Number(frame.line) : undefined,\n colno: frame.column !== undefined ? Number(frame.column) : undefined,\n };\n}\n"]}
|
|
@@ -22,6 +22,8 @@ export interface Sample {
|
|
|
22
22
|
sf: StackFrameId;
|
|
23
23
|
}
|
|
24
24
|
export interface StackFrame {
|
|
25
|
+
funcVirtAddr?: string;
|
|
26
|
+
offset?: string;
|
|
25
27
|
line?: string;
|
|
26
28
|
column?: string;
|
|
27
29
|
funcLine?: string;
|
|
@@ -35,12 +37,7 @@ export interface Profile {
|
|
|
35
37
|
samples: Sample[];
|
|
36
38
|
stackFrames: Record<string, StackFrame>;
|
|
37
39
|
}
|
|
38
|
-
|
|
39
|
-
* Hermes Profile Stack Frame Name contains function name and file path.
|
|
40
|
-
*
|
|
41
|
-
* `foo(/path/to/file.js:1:2)` -> `foo`
|
|
42
|
-
*/
|
|
43
|
-
export declare function parseHermesStackFrameFunctionName(hermesName: string): string;
|
|
40
|
+
export declare const DEFAULT_BUNDLE_NAME: string | undefined;
|
|
44
41
|
/**
|
|
45
42
|
* Starts Hermes Sampling Profiler and returns the timestamp when profiling started in nanoseconds.
|
|
46
43
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hermes.d.ts","sourceRoot":"","sources":["../../../src/js/profiling/hermes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hermes.d.ts","sourceRoot":"","sources":["../../../src/js/profiling/hermes.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAClC,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAE3C,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,qBAAqB,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE;QACJ,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAED,MAAM,WAAW,MAAM;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,qBAAqB,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,YAAY,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IAEzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAGhB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IAGpB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,OAAO;IACtB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACzC;AAED,eAAO,MAAM,mBAAmB,oBACuF,CAAC;AAIxH;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,GAAG,IAAI,CAQ9C;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,mBAAmB,GAAG,IAAI,CAM1D"}
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import { ANDROID_DEFAULT_BUNDLE_NAME, IOS_DEFAULT_BUNDLE_NAME } from '../integrations/rewriteframes';
|
|
1
3
|
import { NATIVE } from '../wrapper';
|
|
2
4
|
import { convertToSentryProfile } from './convertHermesProfile';
|
|
3
|
-
|
|
4
|
-
* Hermes Profile Stack Frame Name contains function name and file path.
|
|
5
|
-
*
|
|
6
|
-
* `foo(/path/to/file.js:1:2)` -> `foo`
|
|
7
|
-
*/
|
|
8
|
-
export function parseHermesStackFrameFunctionName(hermesName) {
|
|
9
|
-
const indexOfLeftParenthesis = hermesName.indexOf('(');
|
|
10
|
-
const name = indexOfLeftParenthesis !== -1 ? hermesName.substring(0, indexOfLeftParenthesis) : hermesName;
|
|
11
|
-
return name;
|
|
12
|
-
}
|
|
5
|
+
export const DEFAULT_BUNDLE_NAME = Platform.OS === 'android' ? ANDROID_DEFAULT_BUNDLE_NAME : Platform.OS === 'ios' ? IOS_DEFAULT_BUNDLE_NAME : undefined;
|
|
13
6
|
const MS_TO_NS = 1e6;
|
|
14
7
|
/**
|
|
15
8
|
* Starts Hermes Sampling Profiler and returns the timestamp when profiling started in nanoseconds.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hermes.js","sourceRoot":"","sources":["../../../src/js/profiling/hermes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"hermes.js","sourceRoot":"","sources":["../../../src/js/profiling/hermes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACrG,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAmDhE,MAAM,CAAC,MAAM,mBAAmB,GAC9B,QAAQ,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,SAAS,CAAC;AAExH,MAAM,QAAQ,GAAW,GAAG,CAAC;AAE7B;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,OAAO,GAAG,MAAM,CAAC,cAAc,EAAE,CAAC;IACxC,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,IAAI,CAAC;KACb;IAED,MAAM,uBAAuB,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC;IACtD,OAAO,uBAAuB,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;IAC7C,IAAI,CAAC,aAAa,EAAE;QAClB,OAAO,IAAI,CAAC;KACb;IACD,OAAO,sBAAsB,CAAC,aAAa,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import { Platform } from 'react-native';\n\nimport { ANDROID_DEFAULT_BUNDLE_NAME, IOS_DEFAULT_BUNDLE_NAME } from '../integrations/rewriteframes';\nimport { NATIVE } from '../wrapper';\nimport { convertToSentryProfile } from './convertHermesProfile';\nimport type { RawThreadCpuProfile } from './types';\n\nexport type StackFrameId = number;\nexport type MicrosecondsSinceBoot = string;\n\nexport interface TraceEvent {\n name: string;\n ph: string;\n cat: string;\n pid: number;\n ts: MicrosecondsSinceBoot;\n tid: string;\n args: {\n name?: string;\n };\n}\n\nexport interface Sample {\n cpu: string;\n name: string;\n ts: MicrosecondsSinceBoot;\n pid: number;\n tid: string;\n weight: string;\n sf: StackFrameId;\n}\n\nexport interface StackFrame {\n // Hermes Bytecode\n funcVirtAddr?: string;\n offset?: string;\n\n // JavaScript\n line?: string;\n column?: string;\n funcLine?: string;\n funcColumn?: string;\n\n // Common\n name: string;\n category: string;\n parent?: number;\n}\n\nexport interface Profile {\n traceEvents: TraceEvent[];\n samples: Sample[];\n stackFrames: Record<string, StackFrame>;\n}\n\nexport const DEFAULT_BUNDLE_NAME =\n Platform.OS === 'android' ? ANDROID_DEFAULT_BUNDLE_NAME : Platform.OS === 'ios' ? IOS_DEFAULT_BUNDLE_NAME : undefined;\n\nconst MS_TO_NS: number = 1e6;\n\n/**\n * Starts Hermes Sampling Profiler and returns the timestamp when profiling started in nanoseconds.\n */\nexport function startProfiling(): number | null {\n const started = NATIVE.startProfiling();\n if (!started) {\n return null;\n }\n\n const profileStartTimestampNs = Date.now() * MS_TO_NS;\n return profileStartTimestampNs;\n}\n\n/**\n * Stops Hermes Sampling Profiler and returns the profile.\n */\nexport function stopProfiling(): RawThreadCpuProfile | null {\n const hermesProfile = NATIVE.stopProfiling();\n if (!hermesProfile) {\n return null;\n }\n return convertToSentryProfile(hermesProfile);\n}\n"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type { ThreadCpuProfile } from '@sentry/types';
|
|
1
|
+
import type { ThreadCpuFrame, ThreadCpuProfile } from '@sentry/types';
|
|
2
2
|
export interface RawThreadCpuProfile extends ThreadCpuProfile {
|
|
3
|
+
frames: ThreadCpuFrame[];
|
|
3
4
|
profile_id?: string;
|
|
5
|
+
active_thread_id: string;
|
|
4
6
|
}
|
|
5
7
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/js/profiling/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/js/profiling/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtE,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAC3D,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;CAC1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/js/profiling/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ThreadCpuProfile } from '@sentry/types';\n\nexport interface RawThreadCpuProfile extends ThreadCpuProfile {\n profile_id?: string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/js/profiling/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ThreadCpuFrame, ThreadCpuProfile } from '@sentry/types';\n\nexport interface RawThreadCpuProfile extends ThreadCpuProfile {\n frames: ThreadCpuFrame[];\n profile_id?: string;\n active_thread_id: string;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Envelope, Event, Profile } from '@sentry/types';
|
|
1
|
+
import type { DebugImage, Envelope, Event, Profile } from '@sentry/types';
|
|
2
2
|
import type { RawThreadCpuProfile } from './types';
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
@@ -18,6 +18,10 @@ export declare function findProfiledTransactionsFromEnvelope(envelope: Envelope)
|
|
|
18
18
|
* @returns {Profile | null}
|
|
19
19
|
*/
|
|
20
20
|
export declare function createProfilingEvent(profile: RawThreadCpuProfile, event: Event): Profile | null;
|
|
21
|
+
/**
|
|
22
|
+
* Returns debug meta images of the loaded bundle.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getDebugMetadata(): DebugImage[];
|
|
21
25
|
/**
|
|
22
26
|
* Adds items to envelope if they are not already present - mutates the envelope.
|
|
23
27
|
* @param envelope
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/js/profiling/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/js/profiling/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAK1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,IAAI,mBAAmB,GAAG;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CAgBpH;AAED;;;;GAIG;AACH,wBAAgB,oCAAoC,CAAC,QAAQ,EAAE,QAAQ,GAAG,KAAK,EAAE,CAqBhF;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,GAAG,IAAI,CAuB/F;AA2FD;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,UAAU,EAAE,CA4B/C;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,QAAQ,CAUvF"}
|