@sentry/react-native 6.20.0 → 6.22.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/RNSentry.podspec +1 -1
- package/android/src/main/java/io/sentry/react/RNSentryVersion.java +1 -1
- package/dist/js/integrations/sdkinfo.d.ts.map +1 -1
- package/dist/js/integrations/sdkinfo.js +21 -5
- package/dist/js/integrations/sdkinfo.js.map +1 -1
- package/dist/js/tools/sentryMetroSerializer.d.ts.map +1 -1
- package/dist/js/tools/sentryMetroSerializer.js +2 -8
- package/dist/js/tools/sentryMetroSerializer.js.map +1 -1
- package/dist/js/tools/vendor/metro/countLines.d.ts +3 -0
- package/dist/js/tools/vendor/metro/countLines.d.ts.map +1 -0
- package/dist/js/tools/vendor/metro/countLines.js +26 -0
- package/dist/js/tools/vendor/metro/countLines.js.map +1 -0
- package/dist/js/tools/vendor/metro/utils.d.ts.map +1 -1
- package/dist/js/tools/vendor/metro/utils.js +17 -8
- package/dist/js/tools/vendor/metro/utils.js.map +1 -1
- package/dist/js/tracing/timetodisplay.d.ts.map +1 -1
- package/dist/js/tracing/timetodisplay.js +1 -11
- package/dist/js/tracing/timetodisplay.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/ios/RNSentry+fetchNativeStack.m +98 -0
- package/ios/RNSentry.h +5 -5
- package/ios/RNSentry.mm +50 -89
- package/ios/RNSentryVersion.m +1 -1
- package/package.json +4 -5
- package/plugin/build/withSentryAndroid.js +7 -7
- package/plugin/build/withSentryAndroidGradlePlugin.d.ts +2 -1
- package/plugin/build/withSentryAndroidGradlePlugin.js +10 -21
- package/scripts/expo-upload-sourcemaps.js +1 -1
- package/ts3.8/dist/js/version.d.ts +1 -1
package/RNSentry.podspec
CHANGED
|
@@ -46,7 +46,7 @@ Pod::Spec.new do |s|
|
|
|
46
46
|
|
|
47
47
|
s.compiler_flags = other_cflags
|
|
48
48
|
|
|
49
|
-
s.dependency 'Sentry/HybridSDK', '8.
|
|
49
|
+
s.dependency 'Sentry/HybridSDK', '8.56.2'
|
|
50
50
|
|
|
51
51
|
if defined? install_modules_dependencies
|
|
52
52
|
# Default React Native dependencies for 0.71 and above (new and legacy architecture)
|
|
@@ -2,7 +2,7 @@ package io.sentry.react;
|
|
|
2
2
|
|
|
3
3
|
class RNSentryVersion {
|
|
4
4
|
static final String REACT_NATIVE_SDK_PACKAGE_NAME = "npm:@sentry/react-native";
|
|
5
|
-
static final String REACT_NATIVE_SDK_PACKAGE_VERSION = "6.
|
|
5
|
+
static final String REACT_NATIVE_SDK_PACKAGE_VERSION = "6.22.0";
|
|
6
6
|
static final String NATIVE_SDK_NAME = "sentry.native.android.react-native";
|
|
7
7
|
static final String ANDROID_SDK_NAME = "sentry.java.android.react-native";
|
|
8
8
|
static final String REACT_NATIVE_SDK_NAME = "sentry.javascript.react-native";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdkinfo.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/sdkinfo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,WAAW,EAAW,OAAO,IAAI,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"sdkinfo.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/sdkinfo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,WAAW,EAAW,OAAO,IAAI,WAAW,EAAE,MAAM,cAAc,CAAC;AAgBxF,KAAK,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC,CAAC;AAEnF,eAAO,MAAM,cAAc,EAAE,cAS5B,CAAC;AAGF,sCAAsC;AACtC,eAAO,MAAM,kBAAkB,QAAO,WAqBrC,CAAC"}
|
|
@@ -22,11 +22,24 @@ export const defaultSdkInfo = {
|
|
|
22
22
|
],
|
|
23
23
|
version: SDK_VERSION,
|
|
24
24
|
};
|
|
25
|
+
let DefaultPii = undefined;
|
|
25
26
|
/** Default SdkInfo instrumentation */
|
|
26
27
|
export const sdkInfoIntegration = () => {
|
|
27
28
|
const fetchNativeSdkInfo = createCachedFetchNativeSdkInfo();
|
|
28
29
|
return {
|
|
29
30
|
name: INTEGRATION_NAME,
|
|
31
|
+
setup(client) {
|
|
32
|
+
const options = client.getOptions();
|
|
33
|
+
DefaultPii = options.sendDefaultPii;
|
|
34
|
+
if (DefaultPii) {
|
|
35
|
+
client.on('beforeSendEvent', event => {
|
|
36
|
+
var _a;
|
|
37
|
+
if (((_a = event.user) === null || _a === void 0 ? void 0 : _a.ip_address) === '{{auto}}') {
|
|
38
|
+
delete event.user.ip_address;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
},
|
|
30
43
|
setupOnce: () => {
|
|
31
44
|
// noop
|
|
32
45
|
},
|
|
@@ -37,14 +50,17 @@ function processEvent(event, fetchNativeSdkInfo) {
|
|
|
37
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
51
|
const nativeSdkPackage = yield fetchNativeSdkInfo();
|
|
39
52
|
event.platform = event.platform || 'javascript';
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
53
|
+
const sdk = (event.sdk || {});
|
|
54
|
+
sdk.name = sdk.name || defaultSdkInfo.name;
|
|
55
|
+
sdk.version = sdk.version || defaultSdkInfo.version;
|
|
56
|
+
sdk.packages = [
|
|
44
57
|
// default packages are added by baseclient and should not be added here
|
|
45
|
-
...(
|
|
58
|
+
...(sdk.packages || []),
|
|
46
59
|
...((nativeSdkPackage && [nativeSdkPackage]) || []),
|
|
47
60
|
];
|
|
61
|
+
// Patch missing infer_ip.
|
|
62
|
+
sdk.settings = Object.assign({ infer_ip: DefaultPii ? 'auto' : 'never' }, sdk.settings);
|
|
63
|
+
event.sdk = sdk;
|
|
48
64
|
return event;
|
|
49
65
|
});
|
|
50
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdkinfo.js","sourceRoot":"","sources":["../../../src/js/integrations/sdkinfo.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"sdkinfo.js","sourceRoot":"","sources":["../../../src/js/integrations/sdkinfo.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AASpC,MAAM,gBAAgB,GAAG,SAAS,CAAC;AAInC,MAAM,CAAC,MAAM,cAAc,GAAmB;IAC5C,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE;QACR;YACE,IAAI,EAAE,gBAAgB;YACtB,OAAO,EAAE,WAAW;SACrB;KACF;IACD,OAAO,EAAE,WAAW;CACrB,CAAC;AACF,IAAI,UAAU,GAAwB,SAAS,CAAC;AAEhD,sCAAsC;AACtC,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAgB,EAAE;IAClD,MAAM,kBAAkB,GAAG,8BAA8B,EAAE,CAAC;IAE5D,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,KAAK,CAAC,MAAM;YACV,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;YACpC,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC;YACp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CAAC;IACf,CAAC;CAAA;AAED,SAAS,8BAA8B;IACrC,IAAI,CAAC,MAAM,EAAE,IAAI,QAAQ,EAAE,EAAE;QAC3B,OAAO,GAAG,EAAE;YACV,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC,CAAC;KACH;IAED,IAAI,QAAQ,GAAY,KAAK,CAAC;IAC9B,IAAI,qBAAqB,GAAmB,IAAI,CAAC;IAEjD,OAAO,GAAS,EAAE;QAChB,IAAI,QAAQ,EAAE;YACZ,OAAO,qBAAqB,CAAC;SAC9B;QAED,IAAI;YACF,qBAAqB,GAAG,MAAM,MAAM,CAAC,kBAAkB,EAAE,CAAC;YAC1D,QAAQ,GAAG,IAAI,CAAC;SACjB;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,IAAI,CAAC,kCAAkC,EAAE,CAAC,CAAC,CAAC;SACpD;QAED,OAAO,qBAAqB,CAAC;IAC/B,CAAC,CAAA,CAAC;AACJ,CAAC","sourcesContent":["import type { Event, Integration, Package, SdkInfo as SdkInfoType } from '@sentry/core';\nimport { logger } from '@sentry/core';\n\nimport { isExpoGo, notWeb } from '../utils/environment';\nimport { SDK_NAME, SDK_PACKAGE_NAME, SDK_VERSION } from '../version';\nimport { NATIVE } from '../wrapper';\n\n// TODO: Remove this on JS V10.\ninterface IpPatchedSdkInfo extends SdkInfoType {\n settings?: {\n infer_ip?: 'auto' | 'never';\n };\n}\n\nconst INTEGRATION_NAME = 'SdkInfo';\n\ntype DefaultSdkInfo = Pick<Required<SdkInfoType>, 'name' | 'packages' | 'version'>;\n\nexport const defaultSdkInfo: DefaultSdkInfo = {\n name: SDK_NAME,\n packages: [\n {\n name: SDK_PACKAGE_NAME,\n version: SDK_VERSION,\n },\n ],\n version: SDK_VERSION,\n};\nlet DefaultPii: boolean | undefined = undefined;\n\n/** Default SdkInfo instrumentation */\nexport const sdkInfoIntegration = (): Integration => {\n const fetchNativeSdkInfo = createCachedFetchNativeSdkInfo();\n\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n const options = client.getOptions();\n DefaultPii = options.sendDefaultPii;\n if (DefaultPii) {\n client.on('beforeSendEvent', event => {\n if (event.user?.ip_address === '{{auto}}') {\n delete event.user.ip_address;\n }\n });\n }\n },\n setupOnce: () => {\n // noop\n },\n processEvent: (event: Event) => processEvent(event, fetchNativeSdkInfo),\n };\n};\n\nasync function processEvent(event: Event, fetchNativeSdkInfo: () => Promise<Package | null>): Promise<Event> {\n const nativeSdkPackage = await fetchNativeSdkInfo();\n\n event.platform = event.platform || 'javascript';\n const sdk = (event.sdk || {}) as IpPatchedSdkInfo;\n sdk.name = sdk.name || defaultSdkInfo.name;\n sdk.version = sdk.version || defaultSdkInfo.version;\n sdk.packages = [\n // default packages are added by baseclient and should not be added here\n ...(sdk.packages || []),\n ...((nativeSdkPackage && [nativeSdkPackage]) || []),\n ];\n\n // Patch missing infer_ip.\n sdk.settings = {\n infer_ip: DefaultPii ? 'auto' : 'never',\n // purposefully allowing already passed settings to override the default\n ...sdk.settings,\n };\n\n event.sdk = sdk;\n\n return event;\n}\n\nfunction createCachedFetchNativeSdkInfo(): () => Promise<Package | null> {\n if (!notWeb() || isExpoGo()) {\n return () => {\n return Promise.resolve(null);\n };\n }\n\n let isCached: boolean = false;\n let nativeSdkPackageCache: Package | null = null;\n\n return async () => {\n if (isCached) {\n return nativeSdkPackageCache;\n }\n\n try {\n nativeSdkPackageCache = await NATIVE.fetchNativeSdkInfo();\n isCached = true;\n } catch (e) {\n logger.warn('Could not fetch native sdk info.', e);\n }\n\n return nativeSdkPackageCache;\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentryMetroSerializer.d.ts","sourceRoot":"","sources":["../../../src/js/tools/sentryMetroSerializer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"sentryMetroSerializer.d.ts","sourceRoot":"","sources":["../../../src/js/tools/sentryMetroSerializer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEhE,OAAO,KAAK,EAAU,eAAe,EAA4D,MAAM,SAAS,CAAC;AAajH;;GAEG;AACH,wBAAgB,uCAAuC,CAAC,EACtD,UAAU,EACV,OAAO,GACR,EAAE;IACD,KAAK,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IAClC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG,MAAM,EAAE,CAcX;AAED;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,sBAAuB,eAAe,KAAG,eAsDhF,CAAC"}
|
|
@@ -11,14 +11,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
11
11
|
exports.createSentryMetroSerializer = exports.unstable_beforeAssetSerializationPlugin = void 0;
|
|
12
12
|
const crypto = require("crypto");
|
|
13
13
|
const utils_1 = require("./utils");
|
|
14
|
+
const countLines_1 = require("./vendor/metro/countLines");
|
|
14
15
|
const utils_2 = require("./vendor/metro/utils");
|
|
15
|
-
let countLines;
|
|
16
|
-
try {
|
|
17
|
-
countLines = require('metro/private/lib/countLines');
|
|
18
|
-
}
|
|
19
|
-
catch (e) {
|
|
20
|
-
countLines = require('metro/src/lib/countLines');
|
|
21
|
-
}
|
|
22
16
|
const DEBUG_ID_PLACE_HOLDER = '__debug_id_place_holder__';
|
|
23
17
|
const DEBUG_ID_MODULE_PATH = '__debugid__';
|
|
24
18
|
const PRELUDE_MODULE_PATH = '__prelude__';
|
|
@@ -153,7 +147,7 @@ function createDebugIdModule(debugId) {
|
|
|
153
147
|
type: 'js/script/virtual',
|
|
154
148
|
data: {
|
|
155
149
|
code: debugIdCode,
|
|
156
|
-
lineCount:
|
|
150
|
+
lineCount: (0, countLines_1.default)(debugIdCode),
|
|
157
151
|
map: [],
|
|
158
152
|
},
|
|
159
153
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentryMetroSerializer.js","sourceRoot":"","sources":["../../../src/js/tools/sentryMetroSerializer.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iCAAiC;AAMjC,mCAA0G;AAC1G,gDAAoE;AAEpE,IAAI,UAAiC,CAAC;AACtC,IAAI;IACF,UAAU,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;CACtD;AAAC,OAAO,CAAC,EAAE;IACV,UAAU,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;CAClD;AAID,MAAM,qBAAqB,GAAG,2BAA2B,CAAC;AAC1D,MAAM,oBAAoB,GAAG,aAAa,CAAC;AAC3C,MAAM,mBAAmB,GAAG,aAAa,CAAC;AAC1C,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;AACnD,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAExC;;GAEG;AACH,SAAgB,uCAAuC,CAAC,EACtD,UAAU,EACV,OAAO,GAKR;IACC,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,UAAU,CAAC;KACnB;IAED,MAAM,mBAAmB,GAAG,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC;IACvG,IAAI,mBAAmB,EAAE;QACvB,sCAAsC;QACtC,OAAO,CAAC,IAAI,CAAC,mEAAmE,CAAC,CAAC;QAClF,OAAO,UAAU,CAAC;KACnB;IAED,MAAM,aAAa,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACnD,OAAO,CAAC,GAAG,gBAAgB,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC;AAC1D,CAAC;AArBD,0FAqBC;AAED;;;;;GAKG;AACI,MAAM,2BAA2B,GAAG,CAAC,gBAAkC,EAAmB,EAAE;IACjG,MAAM,UAAU,G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QACrB,CAAC;QACD,YAAY,EAAE,IAAI,GAAG,EAAE;QACvB,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC;QACzC,mBAAmB,EAAE,IAAA,iBAAS,GAAE;QAChC,IAAI,EAAE,oBAAoB;QAC1B,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,mBAAmB;gBACzB,IAAI,EAAE;oBACJ,IAAI,EAAE,WAAW;oBACjB,SAAS,EAAE,UAAU,CAAC,WAAW,CAAC;oBAClC,GAAG,EAAE,EAAE;iBACR;aACF;SACF;KACF,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,MAAc;IACtC,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACtC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACxB,KAAK,MAAM,CAAC,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE;QACrC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;KACnB;IACD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEzB,MAAM,OAAO,GAAG,IAAA,oBAAY,EAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACjD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,aAAa,CAAC,IAAY,EAAE,OAAe;IAClD,sEAAsE;IACtE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,qBAAqB,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import * as crypto from 'crypto';\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport type { MixedOutput, Module, ReadOnlyGraph } from 'metro';\nimport type * as countLinesType from 'metro/private/lib/countLines';\n\nimport type { Bundle, MetroSerializer, MetroSerializerOutput, SerializedBundle, VirtualJSOutput } from './utils';\nimport { createDebugIdSnippet, createSet, determineDebugIdFromBundleSource, stringToUUID } from './utils';\nimport { createDefaultMetroSerializer } from './vendor/metro/utils';\n\nlet countLines: typeof countLinesType;\ntry {\n countLines = require('metro/private/lib/countLines');\n} catch (e) {\n countLines = require('metro/src/lib/countLines');\n}\n\ntype SourceMap = Record<string, unknown>;\n\nconst DEBUG_ID_PLACE_HOLDER = '__debug_id_place_holder__';\nconst DEBUG_ID_MODULE_PATH = '__debugid__';\nconst PRELUDE_MODULE_PATH = '__prelude__';\nconst SOURCE_MAP_COMMENT = '//# sourceMappingURL=';\nconst DEBUG_ID_COMMENT = '//# debugId=';\n\n/**\n * Adds Sentry Debug ID polyfill module to the bundle.\n */\nexport function unstable_beforeAssetSerializationPlugin({\n premodules,\n debugId,\n}: {\n graph: ReadOnlyGraph<MixedOutput>;\n premodules: Module[];\n debugId?: string;\n}): Module[] {\n if (!debugId) {\n return premodules;\n }\n\n const debugIdModuleExists = premodules.findIndex(module => module.path === DEBUG_ID_MODULE_PATH) != -1;\n if (debugIdModuleExists) {\n // eslint-disable-next-line no-console\n console.warn('\\n\\nDebug ID module found. Skipping Sentry Debug ID module...\\n\\n');\n return premodules;\n }\n\n const debugIdModule = createDebugIdModule(debugId);\n return [...addDebugIdModule(premodules, debugIdModule)];\n}\n\n/**\n * Creates a Metro serializer that adds Debug ID module to the plain bundle.\n * The Debug ID module is a virtual module that provides a debug ID in runtime.\n *\n * RAM Bundles do not support custom serializers.\n */\nexport const createSentryMetroSerializer = (customSerializer?: MetroSerializer): MetroSerializer => {\n const serializer = customSerializer || createDefaultMetroSerializer();\n return async function (entryPoint, preModules, graph, options) {\n if (graph.transformOptions.hot) {\n return serializer(entryPoint, preModules, graph, options);\n }\n\n const debugIdModuleExists = preModules.findIndex(module => module.path === DEBUG_ID_MODULE_PATH) != -1;\n if (debugIdModuleExists) {\n // eslint-disable-next-line no-console\n console.warn('Debug ID module found. Skipping Sentry Debug ID module...');\n return serializer(entryPoint, preModules, graph, options);\n }\n\n const debugIdModule = createDebugIdModule(DEBUG_ID_PLACE_HOLDER);\n options.sentryBundleCallback = createSentryBundleCallback(debugIdModule);\n const modifiedPreModules = addDebugIdModule(preModules, debugIdModule);\n\n // Run wrapped serializer\n const serializerResult = serializer(entryPoint, modifiedPreModules, graph, options);\n const { code: bundleCode, map: bundleMapString } = await extractSerializerResult(serializerResult);\n\n // Add debug id comment to the bundle\n const debugId = determineDebugIdFromBundleSource(bundleCode);\n if (!debugId) {\n throw new Error(\n 'Debug ID was not found in the bundle. Call `options.sentryBundleCallback` if you are using a custom serializer.',\n );\n }\n // Only print debug id for command line builds => not hot reload from dev server\n // eslint-disable-next-line no-console\n console.log('info ' + `Bundle Debug ID: ${debugId}`);\n\n const debugIdComment = `${DEBUG_ID_COMMENT}${debugId}`;\n const indexOfSourceMapComment = bundleCode.lastIndexOf(SOURCE_MAP_COMMENT);\n const bundleCodeWithDebugId =\n indexOfSourceMapComment === -1\n ? // If source map comment is missing lets just add the debug id comment\n `${bundleCode}\\n${debugIdComment}`\n : // If source map comment is present lets add the debug id comment before it\n `${bundleCode.substring(0, indexOfSourceMapComment) + debugIdComment}\\n${bundleCode.substring(\n indexOfSourceMapComment,\n )}`;\n\n const bundleMap: SourceMap = JSON.parse(bundleMapString);\n // For now we write both fields until we know what will become the standard - if ever.\n bundleMap['debug_id'] = debugId;\n bundleMap['debugId'] = debugId;\n\n return {\n code: bundleCodeWithDebugId,\n map: JSON.stringify(bundleMap),\n };\n };\n};\n\n/**\n * This function is expected to be called after serializer creates the final bundle object\n * and before the source maps are generated.\n *\n * It injects a debug ID into the bundle and returns the modified bundle.\n *\n * Access it via `options.sentryBundleCallback` in your custom serializer.\n */\nfunction createSentryBundleCallback(debugIdModule: Module<VirtualJSOutput> & { setSource: (code: string) => void }) {\n return (bundle: Bundle) => {\n const debugId = calculateDebugId(bundle);\n debugIdModule.setSource(injectDebugId(debugIdModule.getSource().toString(), debugId));\n bundle.pre = injectDebugId(bundle.pre, debugId);\n return bundle;\n };\n}\n\nfunction addDebugIdModule(\n preModules: readonly Module<MixedOutput>[],\n debugIdModule: Module<VirtualJSOutput>,\n): readonly Module<MixedOutput>[] {\n const modifiedPreModules = [...preModules];\n if (\n modifiedPreModules.length > 0 &&\n modifiedPreModules[0] !== undefined &&\n modifiedPreModules[0].path === PRELUDE_MODULE_PATH\n ) {\n // prelude module must be first as it measures the bundle startup time\n modifiedPreModules.unshift(preModules[0] as Module<VirtualJSOutput>);\n modifiedPreModules[1] = debugIdModule;\n } else {\n modifiedPreModules.unshift(debugIdModule);\n }\n return modifiedPreModules;\n}\n\nasync function extractSerializerResult(serializerResult: MetroSerializerOutput): Promise<SerializedBundle> {\n if (typeof serializerResult === 'string') {\n return { code: serializerResult, map: '{}' };\n }\n\n if ('map' in serializerResult) {\n return { code: serializerResult.code, map: serializerResult.map };\n }\n\n const awaitedResult = await serializerResult;\n if (typeof awaitedResult === 'string') {\n return { code: awaitedResult, map: '{}' };\n }\n\n return { code: awaitedResult.code, map: awaitedResult.map };\n}\n\nfunction createDebugIdModule(debugId: string): Module<VirtualJSOutput> & { setSource: (code: string) => void } {\n let debugIdCode = createDebugIdSnippet(debugId);\n\n return {\n setSource: (code: string) => {\n debugIdCode = code;\n },\n dependencies: new Map(),\n getSource: () => Buffer.from(debugIdCode),\n inverseDependencies: createSet(),\n path: DEBUG_ID_MODULE_PATH,\n output: [\n {\n type: 'js/script/virtual',\n data: {\n code: debugIdCode,\n lineCount: countLines(debugIdCode),\n map: [],\n },\n },\n ],\n };\n}\n\nfunction calculateDebugId(bundle: Bundle): string {\n const hash = crypto.createHash('md5');\n hash.update(bundle.pre);\n for (const [, code] of bundle.modules) {\n hash.update(code);\n }\n hash.update(bundle.post);\n\n const debugId = stringToUUID(hash.digest('hex'));\n return debugId;\n}\n\nfunction injectDebugId(code: string, debugId: string): string {\n // eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor\n return code.replace(new RegExp(DEBUG_ID_PLACE_HOLDER, 'g'), debugId);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AI,EAAE,mBAAmB;gBACzB,IAAI,EAAE;oBACJ,IAAI,EAAE,WAAW;oBACjB,SAAS,EAAE,IAAA,oBAAU,EAAC,WAAW,CAAC;oBAClC,GAAG,EAAE,EAAE;iBACR;aACF;SACF;KACF,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,MAAc;IACtC,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACtC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACxB,KAAK,MAAM,CAAC,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE;QACrC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;KACnB;IACD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEzB,MAAM,OAAO,GAAG,IAAA,oBAAY,EAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACjD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,aAAa,CAAC,IAAY,EAAE,OAAe;IAClD,sEAAsE;IACtE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,qBAAqB,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import * as crypto from 'crypto';\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport type { MixedOutput, Module, ReadOnlyGraph } from 'metro';\n\nimport type { Bundle, MetroSerializer, MetroSerializerOutput, SerializedBundle, VirtualJSOutput } from './utils';\nimport { createDebugIdSnippet, createSet, determineDebugIdFromBundleSource, stringToUUID } from './utils';\nimport countLines from './vendor/metro/countLines';\nimport { createDefaultMetroSerializer } from './vendor/metro/utils';\n\ntype SourceMap = Record<string, unknown>;\n\nconst DEBUG_ID_PLACE_HOLDER = '__debug_id_place_holder__';\nconst DEBUG_ID_MODULE_PATH = '__debugid__';\nconst PRELUDE_MODULE_PATH = '__prelude__';\nconst SOURCE_MAP_COMMENT = '//# sourceMappingURL=';\nconst DEBUG_ID_COMMENT = '//# debugId=';\n\n/**\n * Adds Sentry Debug ID polyfill module to the bundle.\n */\nexport function unstable_beforeAssetSerializationPlugin({\n premodules,\n debugId,\n}: {\n graph: ReadOnlyGraph<MixedOutput>;\n premodules: Module[];\n debugId?: string;\n}): Module[] {\n if (!debugId) {\n return premodules;\n }\n\n const debugIdModuleExists = premodules.findIndex(module => module.path === DEBUG_ID_MODULE_PATH) != -1;\n if (debugIdModuleExists) {\n // eslint-disable-next-line no-console\n console.warn('\\n\\nDebug ID module found. Skipping Sentry Debug ID module...\\n\\n');\n return premodules;\n }\n\n const debugIdModule = createDebugIdModule(debugId);\n return [...addDebugIdModule(premodules, debugIdModule)];\n}\n\n/**\n * Creates a Metro serializer that adds Debug ID module to the plain bundle.\n * The Debug ID module is a virtual module that provides a debug ID in runtime.\n *\n * RAM Bundles do not support custom serializers.\n */\nexport const createSentryMetroSerializer = (customSerializer?: MetroSerializer): MetroSerializer => {\n const serializer = customSerializer || createDefaultMetroSerializer();\n return async function (entryPoint, preModules, graph, options) {\n if (graph.transformOptions.hot) {\n return serializer(entryPoint, preModules, graph, options);\n }\n\n const debugIdModuleExists = preModules.findIndex(module => module.path === DEBUG_ID_MODULE_PATH) != -1;\n if (debugIdModuleExists) {\n // eslint-disable-next-line no-console\n console.warn('Debug ID module found. Skipping Sentry Debug ID module...');\n return serializer(entryPoint, preModules, graph, options);\n }\n\n const debugIdModule = createDebugIdModule(DEBUG_ID_PLACE_HOLDER);\n options.sentryBundleCallback = createSentryBundleCallback(debugIdModule);\n const modifiedPreModules = addDebugIdModule(preModules, debugIdModule);\n\n // Run wrapped serializer\n const serializerResult = serializer(entryPoint, modifiedPreModules, graph, options);\n const { code: bundleCode, map: bundleMapString } = await extractSerializerResult(serializerResult);\n\n // Add debug id comment to the bundle\n const debugId = determineDebugIdFromBundleSource(bundleCode);\n if (!debugId) {\n throw new Error(\n 'Debug ID was not found in the bundle. Call `options.sentryBundleCallback` if you are using a custom serializer.',\n );\n }\n // Only print debug id for command line builds => not hot reload from dev server\n // eslint-disable-next-line no-console\n console.log('info ' + `Bundle Debug ID: ${debugId}`);\n\n const debugIdComment = `${DEBUG_ID_COMMENT}${debugId}`;\n const indexOfSourceMapComment = bundleCode.lastIndexOf(SOURCE_MAP_COMMENT);\n const bundleCodeWithDebugId =\n indexOfSourceMapComment === -1\n ? // If source map comment is missing lets just add the debug id comment\n `${bundleCode}\\n${debugIdComment}`\n : // If source map comment is present lets add the debug id comment before it\n `${bundleCode.substring(0, indexOfSourceMapComment) + debugIdComment}\\n${bundleCode.substring(\n indexOfSourceMapComment,\n )}`;\n\n const bundleMap: SourceMap = JSON.parse(bundleMapString);\n // For now we write both fields until we know what will become the standard - if ever.\n bundleMap['debug_id'] = debugId;\n bundleMap['debugId'] = debugId;\n\n return {\n code: bundleCodeWithDebugId,\n map: JSON.stringify(bundleMap),\n };\n };\n};\n\n/**\n * This function is expected to be called after serializer creates the final bundle object\n * and before the source maps are generated.\n *\n * It injects a debug ID into the bundle and returns the modified bundle.\n *\n * Access it via `options.sentryBundleCallback` in your custom serializer.\n */\nfunction createSentryBundleCallback(debugIdModule: Module<VirtualJSOutput> & { setSource: (code: string) => void }) {\n return (bundle: Bundle) => {\n const debugId = calculateDebugId(bundle);\n debugIdModule.setSource(injectDebugId(debugIdModule.getSource().toString(), debugId));\n bundle.pre = injectDebugId(bundle.pre, debugId);\n return bundle;\n };\n}\n\nfunction addDebugIdModule(\n preModules: readonly Module<MixedOutput>[],\n debugIdModule: Module<VirtualJSOutput>,\n): readonly Module<MixedOutput>[] {\n const modifiedPreModules = [...preModules];\n if (\n modifiedPreModules.length > 0 &&\n modifiedPreModules[0] !== undefined &&\n modifiedPreModules[0].path === PRELUDE_MODULE_PATH\n ) {\n // prelude module must be first as it measures the bundle startup time\n modifiedPreModules.unshift(preModules[0] as Module<VirtualJSOutput>);\n modifiedPreModules[1] = debugIdModule;\n } else {\n modifiedPreModules.unshift(debugIdModule);\n }\n return modifiedPreModules;\n}\n\nasync function extractSerializerResult(serializerResult: MetroSerializerOutput): Promise<SerializedBundle> {\n if (typeof serializerResult === 'string') {\n return { code: serializerResult, map: '{}' };\n }\n\n if ('map' in serializerResult) {\n return { code: serializerResult.code, map: serializerResult.map };\n }\n\n const awaitedResult = await serializerResult;\n if (typeof awaitedResult === 'string') {\n return { code: awaitedResult, map: '{}' };\n }\n\n return { code: awaitedResult.code, map: awaitedResult.map };\n}\n\nfunction createDebugIdModule(debugId: string): Module<VirtualJSOutput> & { setSource: (code: string) => void } {\n let debugIdCode = createDebugIdSnippet(debugId);\n\n return {\n setSource: (code: string) => {\n debugIdCode = code;\n },\n dependencies: new Map(),\n getSource: () => Buffer.from(debugIdCode),\n inverseDependencies: createSet(),\n path: DEBUG_ID_MODULE_PATH,\n output: [\n {\n type: 'js/script/virtual',\n data: {\n code: debugIdCode,\n lineCount: countLines(debugIdCode),\n map: [],\n },\n },\n ],\n };\n}\n\nfunction calculateDebugId(bundle: Bundle): string {\n const hash = crypto.createHash('md5');\n hash.update(bundle.pre);\n for (const [, code] of bundle.modules) {\n hash.update(code);\n }\n hash.update(bundle.post);\n\n const debugId = stringToUUID(hash.digest('hex'));\n return debugId;\n}\n\nfunction injectDebugId(code: string, debugId: string): string {\n // eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor\n return code.replace(new RegExp(DEBUG_ID_PLACE_HOLDER, 'g'), debugId);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"countLines.d.ts","sourceRoot":"","sources":["../../../../../src/js/tools/vendor/metro/countLines.ts"],"names":[],"mappings":"iCAgCwB,MAAM,KAAG,MAAM;AAAvC,wBAAoF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Vendored from @facebook/metro
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// https://github.com/facebook/metro/blob/93d68cca249202fd3eb52672217e725d90e44eb4/packages/metro/src/lib/countLines.js
|
|
4
|
+
// MIT License
|
|
5
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
// in the Software without restriction, including without limitation the rights
|
|
9
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
// furnished to do so, subject to the following conditions:
|
|
12
|
+
// The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
// copies or substantial portions of the Software.
|
|
14
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
// SOFTWARE.
|
|
21
|
+
// This is exported as private from `metro` and as such breaking changes can appear anytime.
|
|
22
|
+
// In the past these were related to the way the function is exported. Never to the function itself.
|
|
23
|
+
// Thus it should be more stable to vendor it.
|
|
24
|
+
const newline = /\r\n?|\n|\u2028|\u2029/g;
|
|
25
|
+
exports.default = (string) => (string.match(newline) || []).length + 1;
|
|
26
|
+
//# sourceMappingURL=countLines.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"countLines.js","sourceRoot":"","sources":["../../../../../src/js/tools/vendor/metro/countLines.ts"],"names":[],"mappings":"AAAA,gCAAgC;;AAEhC,uHAAuH;AAEvH,cAAc;AAEd,qDAAqD;AAErD,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,2DAA2D;AAE3D,iFAAiF;AACjF,kDAAkD;AAElD,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,gFAAgF;AAChF,gFAAgF;AAChF,YAAY;AAEZ,4FAA4F;AAC5F,oGAAoG;AACpG,8CAA8C;AAE9C,MAAM,OAAO,GAAG,yBAAyB,CAAC;AAE1C,kBAAe,CAAC,MAAc,EAAU,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC","sourcesContent":["// Vendored from @facebook/metro\n\n// https://github.com/facebook/metro/blob/93d68cca249202fd3eb52672217e725d90e44eb4/packages/metro/src/lib/countLines.js\n\n// MIT License\n\n// Copyright (c) Meta Platforms, Inc. and affiliates.\n\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\n// This is exported as private from `metro` and as such breaking changes can appear anytime.\n// In the past these were related to the way the function is exported. Never to the function itself.\n// Thus it should be more stable to vendor it.\n\nconst newline = /\\r\\n?|\\n|\\u2028|\\u2029/g;\n\nexport default (string: string): number => (string.match(newline) || []).length + 1;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/js/tools/vendor/metro/utils.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAe,MAAM,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/js/tools/vendor/metro/utils.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAe,MAAM,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAuChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAYnD;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,UACpB,aAAa;2BAIK,MAAM,KAAK,MAAM;MAEzC,SAAS,MAAM,EAMjB,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,4BAA4B,QAAO,eAqC/C,CAAC"}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
// Vendored / modified from @facebook/metro
|
|
2
|
+
var _a, _b;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.createDefaultMetroSerializer = exports.getSortedModules = void 0;
|
|
4
|
-
let
|
|
5
|
+
let baseJSBundleModule;
|
|
5
6
|
try {
|
|
6
|
-
|
|
7
|
+
baseJSBundleModule = require('metro/private/DeltaBundler/Serializers/baseJSBundle');
|
|
7
8
|
}
|
|
8
|
-
catch (
|
|
9
|
-
|
|
9
|
+
catch (_c) {
|
|
10
|
+
baseJSBundleModule = require('metro/src/DeltaBundler/Serializers/baseJSBundle');
|
|
10
11
|
}
|
|
12
|
+
const baseJSBundle = typeof baseJSBundleModule === 'function'
|
|
13
|
+
? baseJSBundleModule
|
|
14
|
+
: // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
15
|
+
(_a = baseJSBundleModule === null || baseJSBundleModule === void 0 ? void 0 : baseJSBundleModule.baseJSBundle) !== null && _a !== void 0 ? _a : baseJSBundleModule === null || baseJSBundleModule === void 0 ? void 0 : baseJSBundleModule.default;
|
|
11
16
|
let sourceMapString;
|
|
12
17
|
try {
|
|
13
18
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
@@ -22,13 +27,17 @@ catch (e) {
|
|
|
22
27
|
sourceMapString = sourceMapString.sourceMapString;
|
|
23
28
|
}
|
|
24
29
|
}
|
|
25
|
-
let
|
|
30
|
+
let bundleToStringModule;
|
|
26
31
|
try {
|
|
27
|
-
|
|
32
|
+
bundleToStringModule = require('metro/private/lib/bundleToString');
|
|
28
33
|
}
|
|
29
|
-
catch (
|
|
30
|
-
|
|
34
|
+
catch (_d) {
|
|
35
|
+
bundleToStringModule = require('metro/src/lib/bundleToString');
|
|
31
36
|
}
|
|
37
|
+
const bundleToString = typeof bundleToStringModule === 'function'
|
|
38
|
+
? bundleToStringModule
|
|
39
|
+
: // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
40
|
+
(_b = bundleToStringModule === null || bundleToStringModule === void 0 ? void 0 : bundleToStringModule.bundleToString) !== null && _b !== void 0 ? _b : bundleToStringModule === null || bundleToStringModule === void 0 ? void 0 : bundleToStringModule.default;
|
|
32
41
|
/**
|
|
33
42
|
* This function ensures that modules in source maps are sorted in the same
|
|
34
43
|
* order as in a plain JS bundle.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../src/js/tools/vendor/metro/utils.ts"],"names":[],"mappings":"AAAA,2CAA2C
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","s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eAAe,CAAC;SACzF;aAAM;YACL,MAAM,IAAI,KAAK,CAAC;;;CAGrB,CAAC,CAAC;SACE;QAED,oEAAoE;QACpE,MAAM,GAAG,GAAG,uBAAuB,CAAC,CAAC,GAAG,UAAU,EAAE,GAAG,IAAA,wBAAgB,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC,EAAE;YACxF,mBAAmB,EAAE,OAAO,CAAC,mBAAmB;YAChD,qBAAqB,EAAE,OAAO,CAAC,qBAAqB;SACrD,CAAC,CAAC;QACH,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IACvB,CAAC,CAAC;AACJ,CAAC,CAAC;AArCW,QAAA,4BAA4B,gCAqCvC","sourcesContent":["// Vendored / modified from @facebook/metro\n\n// https://github.com/facebook/metro/commit/9b85f83c9cc837d8cd897aa7723be7da5b296067\n\n// MIT License\n\n// Copyright (c) Meta Platforms, Inc. and affiliates.\n\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport type { MixedOutput, Module, ReadOnlyGraph } from 'metro';\nimport type * as baseJSBundleType from 'metro/private/DeltaBundler/Serializers/baseJSBundle';\nimport type * as sourceMapStringType from 'metro/private/DeltaBundler/Serializers/sourceMapString';\nimport type * as bundleToStringType from 'metro/private/lib/bundleToString';\n\nlet baseJSBundleModule: any;\ntry {\n baseJSBundleModule = require('metro/private/DeltaBundler/Serializers/baseJSBundle');\n} catch {\n baseJSBundleModule = require('metro/src/DeltaBundler/Serializers/baseJSBundle');\n}\n\nconst baseJSBundle: typeof baseJSBundleType =\n typeof baseJSBundleModule === 'function'\n ? baseJSBundleModule\n : // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n baseJSBundleModule?.baseJSBundle ?? baseJSBundleModule?.default;\n\nlet sourceMapString: typeof sourceMapStringType;\ntry {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const sourceMapStringModule = require('metro/private/DeltaBundler/Serializers/sourceMapString');\n sourceMapString = (sourceMapStringModule as { sourceMapString: typeof sourceMapStringType }).sourceMapString;\n} catch (e) {\n sourceMapString = require('metro/src/DeltaBundler/Serializers/sourceMapString');\n if ('sourceMapString' in sourceMapString) {\n // Changed to named export in https://github.com/facebook/metro/commit/34148e61200a508923315fbe387b26d1da27bf4b\n // Metro 0.81.0 and 0.80.10 patch\n sourceMapString = (sourceMapString as { sourceMapString: typeof sourceMapStringType }).sourceMapString;\n }\n}\n\nlet bundleToStringModule: any;\ntry {\n bundleToStringModule = require('metro/private/lib/bundleToString');\n} catch {\n bundleToStringModule = require('metro/src/lib/bundleToString');\n}\n\nimport type { MetroSerializer } from '../../utils';\nconst bundleToString: typeof bundleToStringType =\n typeof bundleToStringModule === 'function'\n ? bundleToStringModule\n : // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n bundleToStringModule?.bundleToString ?? bundleToStringModule?.default;\n\ntype NewSourceMapStringExport = {\n // Since Metro v0.80.10 https://github.com/facebook/metro/compare/v0.80.9...v0.80.10#diff-1b836d1729e527a725305eef0cec22e44605af2700fa413f4c2489ea1a03aebcL28\n sourceMapString: typeof sourceMapString;\n};\n\n/**\n * This function ensures that modules in source maps are sorted in the same\n * order as in a plain JS bundle.\n *\n * https://github.com/facebook/metro/blob/9b85f83c9cc837d8cd897aa7723be7da5b296067/packages/metro/src/Server.js#L984\n */\nexport const getSortedModules = (\n graph: ReadOnlyGraph,\n {\n createModuleId,\n }: {\n createModuleId: (file: string) => number;\n },\n): readonly Module[] => {\n const modules = [...graph.dependencies.values()];\n // Sort by IDs\n return modules.sort(\n (a: Module<MixedOutput>, b: Module<MixedOutput>) => createModuleId(a.path) - createModuleId(b.path),\n );\n};\n\n/**\n * Creates the default Metro plain bundle serializer.\n * Because Metro exports only the intermediate serializer functions, we need to\n * assemble the final serializer ourselves. We have to work with the modules the same as Metro does\n * to avoid unexpected changes in the final bundle.\n *\n * This is used when the user does not provide a custom serializer.\n *\n * https://github.com/facebook/metro/blob/9b85f83c9cc837d8cd897aa7723be7da5b296067/packages/metro/src/Server.js#L244-L277\n */\nexport const createDefaultMetroSerializer = (): MetroSerializer => {\n return (entryPoint, preModules, graph, options) => {\n // baseJSBundle assigns IDs to modules in a consistent order\n let bundle = baseJSBundle(entryPoint, preModules, graph, options);\n if (options.sentryBundleCallback && !graph.transformOptions.hot) {\n bundle = options.sentryBundleCallback(bundle);\n }\n const { code } = bundleToString(bundle);\n if (graph.transformOptions.hot) {\n // Hot means running in dev server, sourcemaps are generated on demand\n return code;\n }\n\n let sourceMapStringFunction: typeof sourceMapString | undefined;\n if (typeof sourceMapString === 'function') {\n sourceMapStringFunction = sourceMapString;\n } else if (\n typeof sourceMapString === 'object' &&\n sourceMapString != null &&\n 'sourceMapString' in sourceMapString &&\n typeof sourceMapString['sourceMapString'] === 'function'\n ) {\n sourceMapStringFunction = (sourceMapString as NewSourceMapStringExport).sourceMapString;\n } else {\n throw new Error(`\n[@sentry/react-native/metro] Cannot find sourceMapString function in 'metro/src/DeltaBundler/Serializers/sourceMapString'.\nPlease check the version of Metro you are using and report the issue at http://www.github.com/getsentry/sentry-react-native/issues\n`);\n }\n\n // Always generate source maps, can't use Sentry without source maps\n const map = sourceMapStringFunction([...preModules, ...getSortedModules(graph, options)], {\n processModuleFilter: options.processModuleFilter,\n shouldAddToIgnoreList: options.shouldAddToIgnoreList,\n });\n return { code, map };\n };\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timetodisplay.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/timetodisplay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAC,gBAAgB,EAAG,MAAM,cAAc,CAAC;AAE3D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"timetodisplay.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/timetodisplay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAC,gBAAgB,EAAG,MAAM,cAAc,CAAC;AAE3D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B;;GAEG;AACH,eAAO,MAAM,yBAAyB,qBAA4B,CAAC;AAOnE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,kBAAkB,GAAG,KAAK,CAAC,YAAY,CAQlF;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,kBAAkB,GAAG,KAAK,CAAC,YAAY,CAI/E;AAoBD;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,GAAG,MAAM,CAAC,GAAG;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B,GACA,IAAI,GAAG,SAAS,CAgClB;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,GAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,GAAG,MAAM,CAAC,GAAG;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAG7B,GACA,IAAI,GAAG,SAAS,CAqDlB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,qBAAqB,EAAE,MAAM,EAC7B,EACE,UAA4B,EAC5B,IAAsC,GACvC,GAAE;IACD,UAAU,CAAC,EAAE,IAAI,CAAC;IAClB;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,CAAC;CACR,GAAG,IAAI,CAgCd;AA6CD;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,cAAc,GACf,EAAE;IACD;;OAEG;IACH,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI,CAAA;CAC/C,GAAG,KAAK,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAE1C;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,EACzC,cAAc,GACf,EAAE;IACD,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI,CAAA;CAC/C,GAAG,KAAK,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAE1C"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { fill, getActiveSpan, getSpanDescendants, logger, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_STATUS_ERROR, SPAN_STATUS_OK, spanToJSON, startInactiveSpan } from '@sentry/core';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useState } from 'react';
|
|
4
|
-
import { isTurboModuleEnabled } from '../utils/environment';
|
|
5
4
|
import { SPAN_ORIGIN_AUTO_UI_TIME_TO_DISPLAY, SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY } from './origin';
|
|
6
|
-
import { getRNSentryOnDrawReporter
|
|
5
|
+
import { getRNSentryOnDrawReporter } from './timetodisplaynative';
|
|
7
6
|
import { setSpanDurationAsMeasurement, setSpanDurationAsMeasurementOnSpan } from './utils';
|
|
8
|
-
let nativeComponentMissingLogged = false;
|
|
9
7
|
/**
|
|
10
8
|
* Flags of active spans with manual initial display.
|
|
11
9
|
*/
|
|
@@ -43,14 +41,6 @@ export function TimeToFullDisplay(props) {
|
|
|
43
41
|
}
|
|
44
42
|
function TimeToDisplay(props) {
|
|
45
43
|
const RNSentryOnDrawReporter = getRNSentryOnDrawReporter();
|
|
46
|
-
const isNewArchitecture = isTurboModuleEnabled();
|
|
47
|
-
if (__DEV__ && (isNewArchitecture || (!nativeComponentExists && !nativeComponentMissingLogged))) {
|
|
48
|
-
nativeComponentMissingLogged = true;
|
|
49
|
-
// Using setTimeout with a delay of 0 milliseconds to defer execution and avoid printing the React stack trace.
|
|
50
|
-
setTimeout(() => {
|
|
51
|
-
logger.warn('TimeToInitialDisplay and TimeToFullDisplay are not supported on the web, Expo Go and New Architecture. Run native build or report an issue at https://github.com/getsentry/sentry-react-native');
|
|
52
|
-
}, 0);
|
|
53
|
-
}
|
|
54
44
|
return (React.createElement(React.Fragment, null,
|
|
55
45
|
React.createElement(RNSentryOnDrawReporter, { initialDisplay: props.initialDisplay, fullDisplay: props.fullDisplay, parentSpanId: props.parentSpanId }),
|
|
56
46
|
props.children));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timetodisplay.js","sourceRoot":"","sources":["../../../src/js/tracing/timetodisplay.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,EAAE,gCAAgC,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACnL,OAAO,KAAK,KAAK,MAAM,OAAO,CA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C,CAAC,CAAC;IAE/G,4BAA4B,CAAC,sBAAsB,EAAE,IAAI,CAAC,CAAC;AAC7D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,EACtC,cAAc,GAMf;IACC,OAAO,mBAAmB,CAAC,EAAE,cAAc,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC,CAAC;AAC/E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,0BAA0B,CAAC,EACzC,cAAc,GAGf;IACC,OAAO,mBAAmB,CAAC,EAAE,cAAc,EAAE,SAAS,EAAE,oBAAoB,EAAE,CAAC,CAAC;AAClF,CAAC;AAED,SAAS,mBAAmB,CAAC,EAC3B,cAAc,EACd,SAAS,GAOV;IACC,MAAM,oBAAoB,GAAG,CAAC,KAAyB,EAAsB,EAAE;QAC7E,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;QAE9C,cAAc,CAAC,GAAG,EAAE;YAChB,UAAU,CAAC,IAAI,CAAC,CAAC;YACjB,OAAO,GAAG,EAAE;gBACV,UAAU,CAAC,KAAK,CAAC,CAAC;YACpB,CAAC,CAAC;QACN,CAAC,CAAC,CAAC;QAEH,OAAO,oBAAC,SAAS,oBAAK,KAAK,IAAE,MAAM,EAAE,OAAO,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC;IACnE,CAAC,CAAC;IAEF,oBAAoB,CAAC,WAAW,GAAG,sBAAsB,CAAC;IAC1D,OAAO,oBAAoB,CAAC;AAC9B,CAAC","sourcesContent":["import type { Span,StartSpanOptions } from '@sentry/core';\nimport { fill, getActiveSpan, getSpanDescendants, logger, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_STATUS_ERROR, SPAN_STATUS_OK, spanToJSON, startInactiveSpan } from '@sentry/core';\nimport * as React from 'react';\nimport { useState } from 'react';\n\nimport { isTurboModuleEnabled } from '../utils/environment';\nimport { SPAN_ORIGIN_AUTO_UI_TIME_TO_DISPLAY, SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY } from './origin';\nimport { getRNSentryOnDrawReporter, nativeComponentExists } from './timetodisplaynative';\nimport { setSpanDurationAsMeasurement, setSpanDurationAsMeasurementOnSpan } from './utils';\n\nlet nativeComponentMissingLogged = false;\n\n/**\n * Flags of active spans with manual initial display.\n */\nexport const manualInitialDisplaySpans = new WeakMap<Span, true>();\n\n/**\n * Flag full display called before initial display for an active span.\n */\nconst fullDisplayBeforeInitialDisplay = new WeakMap<Span, true>();\n\nexport type TimeToDisplayProps = {\n children?: React.ReactNode;\n record?: boolean;\n};\n\n/**\n * Component to measure time to initial display.\n *\n * The initial display is recorded when the component prop `record` is true.\n *\n * <TimeToInitialDisplay record />\n */\nexport function TimeToInitialDisplay(props: TimeToDisplayProps): React.ReactElement {\n const activeSpan = getActiveSpan();\n if (activeSpan) {\n manualInitialDisplaySpans.set(activeSpan, true);\n }\n\n const parentSpanId = activeSpan && spanToJSON(activeSpan).span_id;\n return <TimeToDisplay initialDisplay={props.record} parentSpanId={parentSpanId}>{props.children}</TimeToDisplay>;\n}\n\n/**\n * Component to measure time to full display.\n *\n * The initial display is recorded when the component prop `record` is true.\n *\n * <TimeToInitialDisplay record />\n */\nexport function TimeToFullDisplay(props: TimeToDisplayProps): React.ReactElement {\n const activeSpan = getActiveSpan();\n const parentSpanId = activeSpan && spanToJSON(activeSpan).span_id;\n return <TimeToDisplay fullDisplay={props.record} parentSpanId={parentSpanId}>{props.children}</TimeToDisplay>;\n}\n\nfunction TimeToDisplay(props: {\n children?: React.ReactNode;\n initialDisplay?: boolean;\n fullDisplay?: boolean;\n parentSpanId?: string;\n}): React.ReactElement {\n const RNSentryOnDrawReporter = getRNSentryOnDrawReporter();\n const isNewArchitecture = isTurboModuleEnabled();\n\n if (__DEV__ && (isNewArchitecture || (!nativeComponentExists && !nativeComponentMissingLogged))){\n nativeComponentMissingLogged = true;\n // Using setTimeout with a delay of 0 milliseconds to defer execution and avoid printing the React stack trace.\n setTimeout(() => {\n logger.warn(\n 'TimeToInitialDisplay and TimeToFullDisplay are not supported on the web, Expo Go and New Architecture. Run native build or report an issue at https://github.com/getsentry/sentry-react-native');\n }, 0);\n }\n\n return (\n <>\n <RNSentryOnDrawReporter\n initialDisplay={props.initialDisplay}\n fullDisplay={props.fullDisplay}\n parentSpanId={props.parentSpanId} />\n {props.children}\n </>\n );\n}\n\n/**\n * Starts a new span for the initial display.\n *\n * Returns current span if already exists in the currently active span.\n *\n * @deprecated Use `<TimeToInitialDisplay record={boolean}/>` component instead.\n */\nexport function startTimeToInitialDisplaySpan(\n options?: Omit<StartSpanOptions, 'op' | 'name'> & {\n name?: string;\n isAutoInstrumented?: boolean\n },\n): Span | undefined {\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n logger.warn(`[TimeToDisplay] No active span found to attach ui.load.initial_display to.`);\n return undefined;\n }\n\n const existingSpan = getSpanDescendants(activeSpan).find((span) => spanToJSON(span).op === 'ui.load.initial_display');\n if (existingSpan) {\n logger.debug(`[TimeToDisplay] Found existing ui.load.initial_display span.`);\n return existingSpan\n }\n\n const initialDisplaySpan = startInactiveSpan({\n op: 'ui.load.initial_display',\n name: 'Time To Initial Display',\n startTime: spanToJSON(activeSpan).start_timestamp,\n ...options,\n });\n\n if (!initialDisplaySpan) {\n return undefined;\n }\n\n if (options?.isAutoInstrumented) {\n initialDisplaySpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_ORIGIN_AUTO_UI_TIME_TO_DISPLAY);\n } else {\n manualInitialDisplaySpans.set(activeSpan, true);\n initialDisplaySpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY);\n }\n\n return initialDisplaySpan;\n}\n\n/**\n * Starts a new span for the full display.\n *\n * Returns current span if already exists in the currently active span.\n *\n * @deprecated Use `<TimeToFullDisplay record={boolean}/>` component instead.\n */\nexport function startTimeToFullDisplaySpan(\n options: Omit<StartSpanOptions, 'op' | 'name'> & {\n name?: string,\n timeoutMs?: number,\n isAutoInstrumented?: boolean\n } = {\n timeoutMs: 30_000,\n },\n): Span | undefined {\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n logger.warn(`[TimeToDisplay] No active span found to attach ui.load.full_display to.`);\n return undefined;\n }\n\n const descendantSpans = getSpanDescendants(activeSpan);\n\n const initialDisplaySpan = descendantSpans.find((span) => spanToJSON(span).op === 'ui.load.initial_display');\n if (!initialDisplaySpan) {\n logger.warn(`[TimeToDisplay] No initial display span found to attach ui.load.full_display to.`);\n return undefined;\n }\n\n const existingSpan = descendantSpans.find((span) => spanToJSON(span).op === 'ui.load.full_display');\n if (existingSpan) {\n logger.debug(`[TimeToDisplay] Found existing ui.load.full_display span.`);\n return existingSpan;\n }\n\n const fullDisplaySpan = startInactiveSpan({\n op: 'ui.load.full_display',\n name: 'Time To Full Display',\n startTime: spanToJSON(initialDisplaySpan).start_timestamp,\n ...options,\n });\n if (!fullDisplaySpan) {\n return undefined;\n }\n\n const timeout = setTimeout(() => {\n if (spanToJSON(fullDisplaySpan).timestamp) {\n return;\n }\n fullDisplaySpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'deadline_exceeded' });\n fullDisplaySpan.end(spanToJSON(initialDisplaySpan).timestamp);\n setSpanDurationAsMeasurement('time_to_full_display', fullDisplaySpan);\n logger.warn(`[TimeToDisplay] Full display span deadline_exceeded.`);\n }, options.timeoutMs);\n\n fill(fullDisplaySpan, 'end', (originalEnd: Span['end']) => (endTimestamp?: Parameters<Span['end']>[0]) => {\n clearTimeout(timeout);\n originalEnd.call(fullDisplaySpan, endTimestamp);\n });\n\n if (options?.isAutoInstrumented) {\n fullDisplaySpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_ORIGIN_AUTO_UI_TIME_TO_DISPLAY);\n } else {\n fullDisplaySpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY);\n }\n\n return fullDisplaySpan;\n}\n\n/**\n *\n */\nexport function updateInitialDisplaySpan(\n frameTimestampSeconds: number,\n {\n activeSpan = getActiveSpan(),\n span = startTimeToInitialDisplaySpan(),\n }: {\n activeSpan?: Span;\n /**\n * Time to initial display span to update.\n */\n span?: Span;\n } = {}): void {\n if (!span) {\n logger.warn(`[TimeToDisplay] No span found or created, possibly performance is disabled.`);\n return;\n }\n\n if (!activeSpan) {\n logger.warn(`[TimeToDisplay] No active span found to attach ui.load.initial_display to.`);\n return;\n }\n\n if (spanToJSON(span).parent_span_id !== spanToJSON(activeSpan).span_id) {\n logger.warn(`[TimeToDisplay] Initial display span is not a child of current active span.`);\n return;\n }\n\n if (spanToJSON(span).timestamp) {\n logger.warn(`[TimeToDisplay] ${spanToJSON(span).description} span already ended.`);\n return;\n }\n\n span.end(frameTimestampSeconds);\n span.setStatus({ code: SPAN_STATUS_OK });\n logger.debug(`[TimeToDisplay] ${spanToJSON(span).description} span updated with end timestamp.`);\n\n if (fullDisplayBeforeInitialDisplay.has(activeSpan)) {\n fullDisplayBeforeInitialDisplay.delete(activeSpan);\n logger.debug(`[TimeToDisplay] Updating full display with initial display (${span.spanContext().spanId}) end.`);\n updateFullDisplaySpan(frameTimestampSeconds, span);\n }\n\n setSpanDurationAsMeasurementOnSpan('time_to_initial_display', span, activeSpan);\n}\n\nfunction updateFullDisplaySpan(frameTimestampSeconds: number, passedInitialDisplaySpan?: Span): void {\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n logger.warn(`[TimeToDisplay] No active span found to update ui.load.full_display in.`);\n return;\n }\n\n const existingInitialDisplaySpan = passedInitialDisplaySpan\n || getSpanDescendants(activeSpan).find((span) => spanToJSON(span).op === 'ui.load.initial_display');\n const initialDisplayEndTimestamp = existingInitialDisplaySpan && spanToJSON(existingInitialDisplaySpan).timestamp;\n if (!initialDisplayEndTimestamp) {\n fullDisplayBeforeInitialDisplay.set(activeSpan, true);\n logger.warn(`[TimeToDisplay] Full display called before initial display for active span (${activeSpan.spanContext().spanId}).`);\n return;\n }\n\n const span = startTimeToFullDisplaySpan({\n isAutoInstrumented: true,\n });\n if (!span) {\n logger.warn(`[TimeToDisplay] No TimeToFullDisplay span found or created, possibly performance is disabled.`);\n return;\n }\n\n const spanJSON = spanToJSON(span);\n if (spanJSON.timestamp) {\n logger.warn(`[TimeToDisplay] ${spanJSON.description} (${spanJSON.span_id}) span already ended.`);\n return;\n }\n\n if (initialDisplayEndTimestamp > frameTimestampSeconds) {\n logger.warn(`[TimeToDisplay] Using initial display end. Full display end frame timestamp is before initial display end.`);\n span.end(initialDisplayEndTimestamp);\n } else {\n span.end(frameTimestampSeconds);\n }\n\n span.setStatus({ code: SPAN_STATUS_OK });\n logger.debug(`[TimeToDisplay] ${spanJSON.description} (${spanJSON.span_id}) span updated with end timestamp.`);\n\n setSpanDurationAsMeasurement('time_to_full_display', span);\n}\n\n/**\n * Creates a new TimeToFullDisplay component which triggers the full display recording every time the component is focused.\n */\nexport function createTimeToFullDisplay({\n useFocusEffect,\n}: {\n /**\n * `@react-navigation/native` useFocusEffect hook.\n */\n useFocusEffect: (callback: () => void) => void\n}): React.ComponentType<TimeToDisplayProps> {\n return createTimeToDisplay({ useFocusEffect, Component: TimeToFullDisplay });\n}\n\n/**\n * Creates a new TimeToInitialDisplay component which triggers the initial display recording every time the component is focused.\n */\nexport function createTimeToInitialDisplay({\n useFocusEffect,\n}: {\n useFocusEffect: (callback: () => void) => void\n}): React.ComponentType<TimeToDisplayProps> {\n return createTimeToDisplay({ useFocusEffect, Component: TimeToInitialDisplay });\n}\n\nfunction createTimeToDisplay({\n useFocusEffect,\n Component,\n}: {\n /**\n * `@react-navigation/native` useFocusEffect hook.\n */\n useFocusEffect: (callback: () => void) => void;\n Component: typeof TimeToFullDisplay | typeof TimeToInitialDisplay;\n}): React.ComponentType<TimeToDisplayProps> {\n const TimeToDisplayWrapper = (props: TimeToDisplayProps): React.ReactElement => {\n const [focused, setFocused] = useState(false);\n\n useFocusEffect(() => {\n setFocused(true);\n return () => {\n setFocused(false);\n };\n });\n\n return <Component {...props} record={focused && props.record} />;\n };\n\n TimeToDisplayWrapper.displayName = `TimeToDisplayWrapper`;\n return TimeToDisplayWrapper;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"timetodisplay.js","sourceRoot":"","sources":["../../../src/js/tracing/timetodisplay.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,EAAE,gCAAgC,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACnL,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAE,mCAAmC,EAAE,qCAAqC,EAAE,MAAM,UAAU,CAAC;AACtG,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,4BAA4B,EAAE,kCAAkC,EAAE,MAAM,SAAS,CAAC;AAE3F;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,OAAO,EAAc,CAAC;AAEnE;;GAEG;AACH,MAAM,+BAA+B,GAAG,IAAI,OAAO,EAAc,CAAC;AAOlE;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAyB;IAC5D,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IACnC,IAAI,UAAU,EAAE;QACd,yBAAyB,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;KACjD;IAED,MAAM,YAAY,GAAG,UAAU,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;IAClE,OAAO,oBAAC,aAAa,IAAC,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE,YAAY,IAAG,KAAK,CAAC,QAAQ,CAAiB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AC,WAAW,KAAK,QAAQ,CAAC,OAAO,oCAAoC,CAAC,CAAC;IAE/G,4BAA4B,CAAC,sBAAsB,EAAE,IAAI,CAAC,CAAC;AAC7D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,EACtC,cAAc,GAMf;IACC,OAAO,mBAAmB,CAAC,EAAE,cAAc,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC,CAAC;AAC/E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,0BAA0B,CAAC,EACzC,cAAc,GAGf;IACC,OAAO,mBAAmB,CAAC,EAAE,cAAc,EAAE,SAAS,EAAE,oBAAoB,EAAE,CAAC,CAAC;AAClF,CAAC;AAED,SAAS,mBAAmB,CAAC,EAC3B,cAAc,EACd,SAAS,GAOV;IACC,MAAM,oBAAoB,GAAG,CAAC,KAAyB,EAAsB,EAAE;QAC7E,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;QAE9C,cAAc,CAAC,GAAG,EAAE;YAChB,UAAU,CAAC,IAAI,CAAC,CAAC;YACjB,OAAO,GAAG,EAAE;gBACV,UAAU,CAAC,KAAK,CAAC,CAAC;YACpB,CAAC,CAAC;QACN,CAAC,CAAC,CAAC;QAEH,OAAO,oBAAC,SAAS,oBAAK,KAAK,IAAE,MAAM,EAAE,OAAO,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC;IACnE,CAAC,CAAC;IAEF,oBAAoB,CAAC,WAAW,GAAG,sBAAsB,CAAC;IAC1D,OAAO,oBAAoB,CAAC;AAC9B,CAAC","sourcesContent":["import type { Span,StartSpanOptions } from '@sentry/core';\nimport { fill, getActiveSpan, getSpanDescendants, logger, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_STATUS_ERROR, SPAN_STATUS_OK, spanToJSON, startInactiveSpan } from '@sentry/core';\nimport * as React from 'react';\nimport { useState } from 'react';\n\nimport { SPAN_ORIGIN_AUTO_UI_TIME_TO_DISPLAY, SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY } from './origin';\nimport { getRNSentryOnDrawReporter } from './timetodisplaynative';\nimport { setSpanDurationAsMeasurement, setSpanDurationAsMeasurementOnSpan } from './utils';\n\n/**\n * Flags of active spans with manual initial display.\n */\nexport const manualInitialDisplaySpans = new WeakMap<Span, true>();\n\n/**\n * Flag full display called before initial display for an active span.\n */\nconst fullDisplayBeforeInitialDisplay = new WeakMap<Span, true>();\n\nexport type TimeToDisplayProps = {\n children?: React.ReactNode;\n record?: boolean;\n};\n\n/**\n * Component to measure time to initial display.\n *\n * The initial display is recorded when the component prop `record` is true.\n *\n * <TimeToInitialDisplay record />\n */\nexport function TimeToInitialDisplay(props: TimeToDisplayProps): React.ReactElement {\n const activeSpan = getActiveSpan();\n if (activeSpan) {\n manualInitialDisplaySpans.set(activeSpan, true);\n }\n\n const parentSpanId = activeSpan && spanToJSON(activeSpan).span_id;\n return <TimeToDisplay initialDisplay={props.record} parentSpanId={parentSpanId}>{props.children}</TimeToDisplay>;\n}\n\n/**\n * Component to measure time to full display.\n *\n * The initial display is recorded when the component prop `record` is true.\n *\n * <TimeToInitialDisplay record />\n */\nexport function TimeToFullDisplay(props: TimeToDisplayProps): React.ReactElement {\n const activeSpan = getActiveSpan();\n const parentSpanId = activeSpan && spanToJSON(activeSpan).span_id;\n return <TimeToDisplay fullDisplay={props.record} parentSpanId={parentSpanId}>{props.children}</TimeToDisplay>;\n}\n\nfunction TimeToDisplay(props: {\n children?: React.ReactNode;\n initialDisplay?: boolean;\n fullDisplay?: boolean;\n parentSpanId?: string;\n}): React.ReactElement {\n const RNSentryOnDrawReporter = getRNSentryOnDrawReporter();\n return (\n <>\n <RNSentryOnDrawReporter\n initialDisplay={props.initialDisplay}\n fullDisplay={props.fullDisplay}\n parentSpanId={props.parentSpanId} />\n {props.children}\n </>\n );\n}\n\n/**\n * Starts a new span for the initial display.\n *\n * Returns current span if already exists in the currently active span.\n *\n * @deprecated Use `<TimeToInitialDisplay record={boolean}/>` component instead.\n */\nexport function startTimeToInitialDisplaySpan(\n options?: Omit<StartSpanOptions, 'op' | 'name'> & {\n name?: string;\n isAutoInstrumented?: boolean\n },\n): Span | undefined {\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n logger.warn(`[TimeToDisplay] No active span found to attach ui.load.initial_display to.`);\n return undefined;\n }\n\n const existingSpan = getSpanDescendants(activeSpan).find((span) => spanToJSON(span).op === 'ui.load.initial_display');\n if (existingSpan) {\n logger.debug(`[TimeToDisplay] Found existing ui.load.initial_display span.`);\n return existingSpan\n }\n\n const initialDisplaySpan = startInactiveSpan({\n op: 'ui.load.initial_display',\n name: 'Time To Initial Display',\n startTime: spanToJSON(activeSpan).start_timestamp,\n ...options,\n });\n\n if (!initialDisplaySpan) {\n return undefined;\n }\n\n if (options?.isAutoInstrumented) {\n initialDisplaySpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_ORIGIN_AUTO_UI_TIME_TO_DISPLAY);\n } else {\n manualInitialDisplaySpans.set(activeSpan, true);\n initialDisplaySpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY);\n }\n\n return initialDisplaySpan;\n}\n\n/**\n * Starts a new span for the full display.\n *\n * Returns current span if already exists in the currently active span.\n *\n * @deprecated Use `<TimeToFullDisplay record={boolean}/>` component instead.\n */\nexport function startTimeToFullDisplaySpan(\n options: Omit<StartSpanOptions, 'op' | 'name'> & {\n name?: string,\n timeoutMs?: number,\n isAutoInstrumented?: boolean\n } = {\n timeoutMs: 30_000,\n },\n): Span | undefined {\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n logger.warn(`[TimeToDisplay] No active span found to attach ui.load.full_display to.`);\n return undefined;\n }\n\n const descendantSpans = getSpanDescendants(activeSpan);\n\n const initialDisplaySpan = descendantSpans.find((span) => spanToJSON(span).op === 'ui.load.initial_display');\n if (!initialDisplaySpan) {\n logger.warn(`[TimeToDisplay] No initial display span found to attach ui.load.full_display to.`);\n return undefined;\n }\n\n const existingSpan = descendantSpans.find((span) => spanToJSON(span).op === 'ui.load.full_display');\n if (existingSpan) {\n logger.debug(`[TimeToDisplay] Found existing ui.load.full_display span.`);\n return existingSpan;\n }\n\n const fullDisplaySpan = startInactiveSpan({\n op: 'ui.load.full_display',\n name: 'Time To Full Display',\n startTime: spanToJSON(initialDisplaySpan).start_timestamp,\n ...options,\n });\n if (!fullDisplaySpan) {\n return undefined;\n }\n\n const timeout = setTimeout(() => {\n if (spanToJSON(fullDisplaySpan).timestamp) {\n return;\n }\n fullDisplaySpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'deadline_exceeded' });\n fullDisplaySpan.end(spanToJSON(initialDisplaySpan).timestamp);\n setSpanDurationAsMeasurement('time_to_full_display', fullDisplaySpan);\n logger.warn(`[TimeToDisplay] Full display span deadline_exceeded.`);\n }, options.timeoutMs);\n\n fill(fullDisplaySpan, 'end', (originalEnd: Span['end']) => (endTimestamp?: Parameters<Span['end']>[0]) => {\n clearTimeout(timeout);\n originalEnd.call(fullDisplaySpan, endTimestamp);\n });\n\n if (options?.isAutoInstrumented) {\n fullDisplaySpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_ORIGIN_AUTO_UI_TIME_TO_DISPLAY);\n } else {\n fullDisplaySpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY);\n }\n\n return fullDisplaySpan;\n}\n\n/**\n *\n */\nexport function updateInitialDisplaySpan(\n frameTimestampSeconds: number,\n {\n activeSpan = getActiveSpan(),\n span = startTimeToInitialDisplaySpan(),\n }: {\n activeSpan?: Span;\n /**\n * Time to initial display span to update.\n */\n span?: Span;\n } = {}): void {\n if (!span) {\n logger.warn(`[TimeToDisplay] No span found or created, possibly performance is disabled.`);\n return;\n }\n\n if (!activeSpan) {\n logger.warn(`[TimeToDisplay] No active span found to attach ui.load.initial_display to.`);\n return;\n }\n\n if (spanToJSON(span).parent_span_id !== spanToJSON(activeSpan).span_id) {\n logger.warn(`[TimeToDisplay] Initial display span is not a child of current active span.`);\n return;\n }\n\n if (spanToJSON(span).timestamp) {\n logger.warn(`[TimeToDisplay] ${spanToJSON(span).description} span already ended.`);\n return;\n }\n\n span.end(frameTimestampSeconds);\n span.setStatus({ code: SPAN_STATUS_OK });\n logger.debug(`[TimeToDisplay] ${spanToJSON(span).description} span updated with end timestamp.`);\n\n if (fullDisplayBeforeInitialDisplay.has(activeSpan)) {\n fullDisplayBeforeInitialDisplay.delete(activeSpan);\n logger.debug(`[TimeToDisplay] Updating full display with initial display (${span.spanContext().spanId}) end.`);\n updateFullDisplaySpan(frameTimestampSeconds, span);\n }\n\n setSpanDurationAsMeasurementOnSpan('time_to_initial_display', span, activeSpan);\n}\n\nfunction updateFullDisplaySpan(frameTimestampSeconds: number, passedInitialDisplaySpan?: Span): void {\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n logger.warn(`[TimeToDisplay] No active span found to update ui.load.full_display in.`);\n return;\n }\n\n const existingInitialDisplaySpan = passedInitialDisplaySpan\n || getSpanDescendants(activeSpan).find((span) => spanToJSON(span).op === 'ui.load.initial_display');\n const initialDisplayEndTimestamp = existingInitialDisplaySpan && spanToJSON(existingInitialDisplaySpan).timestamp;\n if (!initialDisplayEndTimestamp) {\n fullDisplayBeforeInitialDisplay.set(activeSpan, true);\n logger.warn(`[TimeToDisplay] Full display called before initial display for active span (${activeSpan.spanContext().spanId}).`);\n return;\n }\n\n const span = startTimeToFullDisplaySpan({\n isAutoInstrumented: true,\n });\n if (!span) {\n logger.warn(`[TimeToDisplay] No TimeToFullDisplay span found or created, possibly performance is disabled.`);\n return;\n }\n\n const spanJSON = spanToJSON(span);\n if (spanJSON.timestamp) {\n logger.warn(`[TimeToDisplay] ${spanJSON.description} (${spanJSON.span_id}) span already ended.`);\n return;\n }\n\n if (initialDisplayEndTimestamp > frameTimestampSeconds) {\n logger.warn(`[TimeToDisplay] Using initial display end. Full display end frame timestamp is before initial display end.`);\n span.end(initialDisplayEndTimestamp);\n } else {\n span.end(frameTimestampSeconds);\n }\n\n span.setStatus({ code: SPAN_STATUS_OK });\n logger.debug(`[TimeToDisplay] ${spanJSON.description} (${spanJSON.span_id}) span updated with end timestamp.`);\n\n setSpanDurationAsMeasurement('time_to_full_display', span);\n}\n\n/**\n * Creates a new TimeToFullDisplay component which triggers the full display recording every time the component is focused.\n */\nexport function createTimeToFullDisplay({\n useFocusEffect,\n}: {\n /**\n * `@react-navigation/native` useFocusEffect hook.\n */\n useFocusEffect: (callback: () => void) => void\n}): React.ComponentType<TimeToDisplayProps> {\n return createTimeToDisplay({ useFocusEffect, Component: TimeToFullDisplay });\n}\n\n/**\n * Creates a new TimeToInitialDisplay component which triggers the initial display recording every time the component is focused.\n */\nexport function createTimeToInitialDisplay({\n useFocusEffect,\n}: {\n useFocusEffect: (callback: () => void) => void\n}): React.ComponentType<TimeToDisplayProps> {\n return createTimeToDisplay({ useFocusEffect, Component: TimeToInitialDisplay });\n}\n\nfunction createTimeToDisplay({\n useFocusEffect,\n Component,\n}: {\n /**\n * `@react-navigation/native` useFocusEffect hook.\n */\n useFocusEffect: (callback: () => void) => void;\n Component: typeof TimeToFullDisplay | typeof TimeToInitialDisplay;\n}): React.ComponentType<TimeToDisplayProps> {\n const TimeToDisplayWrapper = (props: TimeToDisplayProps): React.ReactElement => {\n const [focused, setFocused] = useState(false);\n\n useFocusEffect(() => {\n setFocused(true);\n return () => {\n setFocused(false);\n };\n });\n\n return <Component {...props} record={focused && props.record} />;\n };\n\n TimeToDisplayWrapper.displayName = `TimeToDisplayWrapper`;\n return TimeToDisplayWrapper;\n}\n"]}
|
package/dist/js/version.d.ts
CHANGED
package/dist/js/version.js
CHANGED
package/dist/js/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/js/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAC3D,MAAM,CAAC,MAAM,QAAQ,GAAG,gCAAgC,CAAC;AACzD,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC","sourcesContent":["export const SDK_PACKAGE_NAME = 'npm:@sentry/react-native';\nexport const SDK_NAME = 'sentry.javascript.react-native';\nexport const SDK_VERSION = '6.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/js/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAC3D,MAAM,CAAC,MAAM,QAAQ,GAAG,gCAAgC,CAAC;AACzD,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC","sourcesContent":["export const SDK_PACKAGE_NAME = 'npm:@sentry/react-native';\nexport const SDK_NAME = 'sentry.javascript.react-native';\nexport const SDK_VERSION = '6.22.0';\n"]}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#import "RNSentry.h"
|
|
2
|
+
#import "RNSentryBreadcrumb.h"
|
|
3
|
+
#import "RNSentryId.h"
|
|
4
|
+
#import <Sentry/PrivateSentrySDKOnly.h>
|
|
5
|
+
#import <Sentry/SentryAppStartMeasurement.h>
|
|
6
|
+
#import <Sentry/SentryBreadcrumb.h>
|
|
7
|
+
#import <Sentry/SentryDebugImageProvider+HybridSDKs.h>
|
|
8
|
+
#import <Sentry/SentryDebugMeta.h>
|
|
9
|
+
#import <Sentry/SentryDependencyContainer.h>
|
|
10
|
+
#import <Sentry/SentryEvent.h>
|
|
11
|
+
#import <Sentry/SentryException.h>
|
|
12
|
+
#import <Sentry/SentryFormatter.h>
|
|
13
|
+
#import <Sentry/SentryOptions.h>
|
|
14
|
+
#import <Sentry/SentryUser.h>
|
|
15
|
+
@import Sentry;
|
|
16
|
+
|
|
17
|
+
// This method was moved to a new category so we can use `@import Sentry` to use Sentry's Swift
|
|
18
|
+
// classes
|
|
19
|
+
@implementation
|
|
20
|
+
RNSentry (fetchNativeStack)
|
|
21
|
+
|
|
22
|
+
- (NSDictionary *)fetchNativeStackFramesBy:(NSArray<NSNumber *> *)instructionsAddr
|
|
23
|
+
symbolicate:(SymbolicateCallbackType)symbolicate
|
|
24
|
+
{
|
|
25
|
+
BOOL shouldSymbolicateLocally = [SentrySDKInternal.options debug];
|
|
26
|
+
|
|
27
|
+
NSString *appPackageName = [[NSBundle mainBundle] executablePath];
|
|
28
|
+
|
|
29
|
+
NSMutableSet<NSString *> *_Nonnull imagesAddrToRetrieveDebugMetaImages =
|
|
30
|
+
[[NSMutableSet alloc] init];
|
|
31
|
+
NSMutableArray<NSDictionary<NSString *, id> *> *_Nonnull serializedFrames =
|
|
32
|
+
[[NSMutableArray alloc] init];
|
|
33
|
+
|
|
34
|
+
for (NSNumber *addr in instructionsAddr) {
|
|
35
|
+
SentryBinaryImageInfo *_Nullable image = [[[SentryDependencyContainer sharedInstance]
|
|
36
|
+
binaryImageCache] imageByAddress:[addr unsignedLongLongValue]];
|
|
37
|
+
if (image != nil) {
|
|
38
|
+
NSString *imageAddr = sentry_formatHexAddressUInt64([image address]);
|
|
39
|
+
[imagesAddrToRetrieveDebugMetaImages addObject:imageAddr];
|
|
40
|
+
|
|
41
|
+
NSDictionary<NSString *, id> *_Nonnull nativeFrame = @{
|
|
42
|
+
@"platform" : @"cocoa",
|
|
43
|
+
@"instruction_addr" : sentry_formatHexAddress(addr),
|
|
44
|
+
@"package" : [image name],
|
|
45
|
+
@"image_addr" : imageAddr,
|
|
46
|
+
@"in_app" : [NSNumber numberWithBool:[appPackageName isEqualToString:[image name]]],
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
if (shouldSymbolicateLocally) {
|
|
50
|
+
Dl_info symbolsBuffer;
|
|
51
|
+
bool symbols_succeed = false;
|
|
52
|
+
symbols_succeed
|
|
53
|
+
= symbolicate((void *)[addr unsignedLongLongValue], &symbolsBuffer) != 0;
|
|
54
|
+
if (symbols_succeed) {
|
|
55
|
+
NSMutableDictionary<NSString *, id> *_Nonnull symbolicated
|
|
56
|
+
= nativeFrame.mutableCopy;
|
|
57
|
+
symbolicated[@"symbol_addr"]
|
|
58
|
+
= sentry_formatHexAddressUInt64((uintptr_t)symbolsBuffer.dli_saddr);
|
|
59
|
+
symbolicated[@"function"] = [NSString stringWithCString:symbolsBuffer.dli_sname
|
|
60
|
+
encoding:NSUTF8StringEncoding];
|
|
61
|
+
|
|
62
|
+
nativeFrame = symbolicated;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
[serializedFrames addObject:nativeFrame];
|
|
67
|
+
} else {
|
|
68
|
+
[serializedFrames addObject:@{
|
|
69
|
+
@"platform" : @"cocoa",
|
|
70
|
+
@"instruction_addr" : sentry_formatHexAddress(addr),
|
|
71
|
+
}];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (shouldSymbolicateLocally) {
|
|
76
|
+
return @{
|
|
77
|
+
@"frames" : serializedFrames,
|
|
78
|
+
};
|
|
79
|
+
} else {
|
|
80
|
+
NSMutableArray<NSDictionary<NSString *, id> *> *_Nonnull serializedDebugMetaImages =
|
|
81
|
+
[[NSMutableArray alloc] init];
|
|
82
|
+
|
|
83
|
+
NSArray<SentryDebugMeta *> *debugMetaImages =
|
|
84
|
+
[[[SentryDependencyContainer sharedInstance] debugImageProvider]
|
|
85
|
+
getDebugImagesForImageAddressesFromCache:imagesAddrToRetrieveDebugMetaImages];
|
|
86
|
+
|
|
87
|
+
for (SentryDebugMeta *debugImage in debugMetaImages) {
|
|
88
|
+
[serializedDebugMetaImages addObject:[debugImage serialize]];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return @{
|
|
92
|
+
@"frames" : serializedFrames,
|
|
93
|
+
@"debugMetaImages" : serializedDebugMetaImages,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@end
|
package/ios/RNSentry.h
CHANGED
|
@@ -15,12 +15,7 @@ typedef int (*SymbolicateCallbackType)(const void *, Dl_info *);
|
|
|
15
15
|
@class SentryOptions;
|
|
16
16
|
@class SentryEvent;
|
|
17
17
|
|
|
18
|
-
#if CROSS_PLATFORM_TEST
|
|
19
18
|
@interface SentrySDKInternal : NSObject
|
|
20
|
-
#else
|
|
21
|
-
@interface
|
|
22
|
-
SentrySDK (Private)
|
|
23
|
-
#endif
|
|
24
19
|
@property (nonatomic, nullable, readonly, class) SentryOptions *options;
|
|
25
20
|
@end
|
|
26
21
|
|
|
@@ -31,6 +26,11 @@ SentrySDK (Private)
|
|
|
31
26
|
|
|
32
27
|
- (void)setEventOriginTag:(SentryEvent *)event;
|
|
33
28
|
|
|
29
|
+
@end
|
|
30
|
+
|
|
31
|
+
@interface
|
|
32
|
+
RNSentry (fetchNativeStack)
|
|
33
|
+
|
|
34
34
|
- (NSDictionary *_Nonnull)fetchNativeStackFramesBy:(NSArray<NSNumber *> *)instructionsAddr
|
|
35
35
|
symbolicate:(SymbolicateCallbackType)symbolicate;
|
|
36
36
|
|
package/ios/RNSentry.mm
CHANGED
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
#import "RNSentryId.h"
|
|
21
21
|
#import <Sentry/PrivateSentrySDKOnly.h>
|
|
22
22
|
#import <Sentry/SentryAppStartMeasurement.h>
|
|
23
|
-
#import <Sentry/SentryBinaryImageCache.h>
|
|
24
23
|
#import <Sentry/SentryBreadcrumb.h>
|
|
25
24
|
#import <Sentry/SentryDebugImageProvider+HybridSDKs.h>
|
|
26
25
|
#import <Sentry/SentryDebugMeta.h>
|
|
@@ -29,15 +28,9 @@
|
|
|
29
28
|
#import <Sentry/SentryException.h>
|
|
30
29
|
#import <Sentry/SentryFormatter.h>
|
|
31
30
|
#import <Sentry/SentryOptions.h>
|
|
32
|
-
#import <Sentry/
|
|
33
|
-
#if __has_include(<Sentry/SentryOptions+HybridSDKs.h>)
|
|
34
|
-
# define USE_SENTRY_OPTIONS 1
|
|
35
|
-
# import <Sentry/SentryOptions+HybridSDKs.h>
|
|
36
|
-
#else
|
|
37
|
-
# define USE_SENTRY_OPTIONS 0
|
|
38
|
-
# import <Sentry/SentryOptionsInternal.h>
|
|
39
|
-
#endif
|
|
31
|
+
#import <Sentry/SentryOptionsInternal.h>
|
|
40
32
|
#import <Sentry/SentryScreenFrames.h>
|
|
33
|
+
#import <Sentry/SentryUser.h>
|
|
41
34
|
|
|
42
35
|
// This guard prevents importing Hermes in JSC apps
|
|
43
36
|
#if SENTRY_PROFILING_ENABLED
|
|
@@ -169,13 +162,8 @@ RCT_EXPORT_METHOD(initNativeSdk
|
|
|
169
162
|
[RNSentryReplay updateOptions:mutableOptions];
|
|
170
163
|
#endif
|
|
171
164
|
|
|
172
|
-
#if USE_SENTRY_OPTIONS
|
|
173
|
-
SentryOptions *sentryOptions = [[SentryOptions alloc] initWithDict:mutableOptions
|
|
174
|
-
didFailWithError:errorPointer];
|
|
175
|
-
#else
|
|
176
165
|
SentryOptions *sentryOptions = [SentryOptionsInternal initWithDict:mutableOptions
|
|
177
166
|
didFailWithError:errorPointer];
|
|
178
|
-
#endif
|
|
179
167
|
if (*errorPointer != nil) {
|
|
180
168
|
return nil;
|
|
181
169
|
}
|
|
@@ -358,89 +346,62 @@ RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSString *, fetchNativePackageName)
|
|
|
358
346
|
return packageName;
|
|
359
347
|
}
|
|
360
348
|
|
|
361
|
-
|
|
362
|
-
|
|
349
|
+
RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSDictionary *, fetchNativeStackFramesBy
|
|
350
|
+
: (NSArray *)instructionsAddr)
|
|
363
351
|
{
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
#else
|
|
367
|
-
BOOL shouldSymbolicateLocally = [SentrySDK.options debug];
|
|
368
|
-
#endif
|
|
369
|
-
NSString *appPackageName = [[NSBundle mainBundle] executablePath];
|
|
370
|
-
|
|
371
|
-
NSMutableSet<NSString *> *_Nonnull imagesAddrToRetrieveDebugMetaImages =
|
|
372
|
-
[[NSMutableSet alloc] init];
|
|
373
|
-
NSMutableArray<NSDictionary<NSString *, id> *> *_Nonnull serializedFrames =
|
|
374
|
-
[[NSMutableArray alloc] init];
|
|
375
|
-
|
|
376
|
-
for (NSNumber *addr in instructionsAddr) {
|
|
377
|
-
SentryBinaryImageInfo *_Nullable image = [[[SentryDependencyContainer sharedInstance]
|
|
378
|
-
binaryImageCache] imageByAddress:[addr unsignedLongLongValue]];
|
|
379
|
-
if (image != nil) {
|
|
380
|
-
NSString *imageAddr = sentry_formatHexAddressUInt64([image address]);
|
|
381
|
-
[imagesAddrToRetrieveDebugMetaImages addObject:imageAddr];
|
|
382
|
-
|
|
383
|
-
NSDictionary<NSString *, id> *_Nonnull nativeFrame = @{
|
|
384
|
-
@"platform" : @"cocoa",
|
|
385
|
-
@"instruction_addr" : sentry_formatHexAddress(addr),
|
|
386
|
-
@"package" : [image name],
|
|
387
|
-
@"image_addr" : imageAddr,
|
|
388
|
-
@"in_app" : [NSNumber numberWithBool:[appPackageName isEqualToString:[image name]]],
|
|
389
|
-
};
|
|
390
|
-
|
|
391
|
-
if (shouldSymbolicateLocally) {
|
|
392
|
-
Dl_info symbolsBuffer;
|
|
393
|
-
bool symbols_succeed = false;
|
|
394
|
-
symbols_succeed
|
|
395
|
-
= symbolicate((void *)[addr unsignedLongLongValue], &symbolsBuffer) != 0;
|
|
396
|
-
if (symbols_succeed) {
|
|
397
|
-
NSMutableDictionary<NSString *, id> *_Nonnull symbolicated
|
|
398
|
-
= nativeFrame.mutableCopy;
|
|
399
|
-
symbolicated[@"symbol_addr"]
|
|
400
|
-
= sentry_formatHexAddressUInt64((uintptr_t)symbolsBuffer.dli_saddr);
|
|
401
|
-
symbolicated[@"function"] = [NSString stringWithCString:symbolsBuffer.dli_sname
|
|
402
|
-
encoding:NSUTF8StringEncoding];
|
|
403
|
-
|
|
404
|
-
nativeFrame = symbolicated;
|
|
405
|
-
}
|
|
406
|
-
}
|
|
352
|
+
return [self fetchNativeStackFramesBy:instructionsAddr symbolicate:dladdr];
|
|
353
|
+
}
|
|
407
354
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
}];
|
|
414
|
-
}
|
|
415
|
-
}
|
|
355
|
+
RCT_EXPORT_METHOD(fetchNativeLogAttributes
|
|
356
|
+
: (RCTPromiseResolveBlock)resolve rejecter
|
|
357
|
+
: (RCTPromiseRejectBlock)reject)
|
|
358
|
+
{
|
|
359
|
+
__block NSMutableDictionary<NSString *, id> *result = [NSMutableDictionary new];
|
|
416
360
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
} else {
|
|
422
|
-
NSMutableArray<NSDictionary<NSString *, id> *> *_Nonnull serializedDebugMetaImages =
|
|
423
|
-
[[NSMutableArray alloc] init];
|
|
361
|
+
[SentrySDKWrapper configureScope:^(SentryScope *_Nonnull scope) {
|
|
362
|
+
// Serialize to get contexts dictionary
|
|
363
|
+
NSDictionary *serializedScope = [scope serialize];
|
|
364
|
+
NSDictionary *allContexts = serializedScope[@"context"]; // It's singular here, annoyingly
|
|
424
365
|
|
|
425
|
-
|
|
426
|
-
[[[SentryDependencyContainer sharedInstance] debugImageProvider]
|
|
427
|
-
getDebugImagesForImageAddressesFromCache:imagesAddrToRetrieveDebugMetaImages];
|
|
366
|
+
NSMutableDictionary *contexts = [NSMutableDictionary new];
|
|
428
367
|
|
|
429
|
-
|
|
430
|
-
|
|
368
|
+
NSDictionary *device = allContexts[@"device"];
|
|
369
|
+
if ([device isKindOfClass:[NSDictionary class]]) {
|
|
370
|
+
contexts[@"device"] = device;
|
|
431
371
|
}
|
|
432
372
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
@"
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
}
|
|
373
|
+
NSDictionary *os = allContexts[@"os"];
|
|
374
|
+
if ([os isKindOfClass:[NSDictionary class]]) {
|
|
375
|
+
contexts[@"os"] = os;
|
|
376
|
+
}
|
|
439
377
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
378
|
+
NSString *releaseName = SentrySDKInternal.options.releaseName;
|
|
379
|
+
if (releaseName) {
|
|
380
|
+
contexts[@"release"] = releaseName;
|
|
381
|
+
}
|
|
382
|
+
// Merge extra context
|
|
383
|
+
NSDictionary *extraContext = [PrivateSentrySDKOnly getExtraContext];
|
|
384
|
+
|
|
385
|
+
if (extraContext) {
|
|
386
|
+
NSDictionary *extraDevice = extraContext[@"device"];
|
|
387
|
+
if ([extraDevice isKindOfClass:[NSDictionary class]]) {
|
|
388
|
+
NSMutableDictionary *mergedDevice =
|
|
389
|
+
[contexts[@"device"] mutableCopy] ?: [NSMutableDictionary new];
|
|
390
|
+
[mergedDevice addEntriesFromDictionary:extraDevice];
|
|
391
|
+
contexts[@"device"] = mergedDevice;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
NSDictionary *extraOS = extraContext[@"os"];
|
|
395
|
+
if ([extraOS isKindOfClass:[NSDictionary class]]) {
|
|
396
|
+
NSMutableDictionary *mergedOS =
|
|
397
|
+
[contexts[@"os"] mutableCopy] ?: [NSMutableDictionary new];
|
|
398
|
+
[mergedOS addEntriesFromDictionary:extraOS];
|
|
399
|
+
contexts[@"os"] = mergedOS;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
result[@"contexts"] = contexts;
|
|
403
|
+
}];
|
|
404
|
+
resolve(result);
|
|
444
405
|
}
|
|
445
406
|
|
|
446
407
|
RCT_EXPORT_METHOD(fetchNativeDeviceContexts
|
package/ios/RNSentryVersion.m
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
NSString *const NATIVE_SDK_NAME = @"sentry.cocoa.react-native";
|
|
4
4
|
NSString *const REACT_NATIVE_SDK_NAME = @"sentry.javascript.react-native";
|
|
5
5
|
NSString *const REACT_NATIVE_SDK_PACKAGE_NAME = @"npm:@sentry/react-native";
|
|
6
|
-
NSString *const REACT_NATIVE_SDK_PACKAGE_VERSION = @"6.
|
|
6
|
+
NSString *const REACT_NATIVE_SDK_PACKAGE_VERSION = @"6.22.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": "6.
|
|
5
|
+
"version": "6.22.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",
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
"react-native": ">=0.65.0"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@sentry/babel-plugin-component-annotate": "4.
|
|
70
|
+
"@sentry/babel-plugin-component-annotate": "4.2.0",
|
|
71
71
|
"@sentry/browser": "8.55.0",
|
|
72
|
-
"@sentry/cli": "2.
|
|
72
|
+
"@sentry/cli": "2.53.0",
|
|
73
73
|
"@sentry/core": "8.55.0",
|
|
74
74
|
"@sentry/react": "8.55.0",
|
|
75
75
|
"@sentry/types": "8.55.0",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"@sentry-internal/eslint-config-sdk": "8.55.0",
|
|
84
84
|
"@sentry-internal/eslint-plugin-sdk": "8.55.0",
|
|
85
85
|
"@sentry-internal/typescript": "8.55.0",
|
|
86
|
-
"@sentry/wizard": "6.
|
|
86
|
+
"@sentry/wizard": "6.3.0",
|
|
87
87
|
"@testing-library/react-native": "^12.7.2",
|
|
88
88
|
"@types/jest": "^29.5.13",
|
|
89
89
|
"@types/node": "^20.9.3",
|
|
@@ -110,7 +110,6 @@
|
|
|
110
110
|
"prettier": "^2.0.5",
|
|
111
111
|
"react": "18.3.1",
|
|
112
112
|
"react-native": "0.77.1",
|
|
113
|
-
"react-test-renderer": "^18.3.1",
|
|
114
113
|
"rimraf": "^4.1.1",
|
|
115
114
|
"ts-jest": "^29.1.1",
|
|
116
115
|
"typescript": "4.9.5",
|
|
@@ -28,20 +28,20 @@ const config_plugins_1 = require("expo/config-plugins");
|
|
|
28
28
|
const path = __importStar(require("path"));
|
|
29
29
|
const utils_1 = require("./utils");
|
|
30
30
|
const withSentryAndroid = (config, sentryProperties) => {
|
|
31
|
-
const cfg = (0, config_plugins_1.withAppBuildGradle)(config,
|
|
32
|
-
if (
|
|
33
|
-
|
|
31
|
+
const cfg = (0, config_plugins_1.withAppBuildGradle)(config, appBuildGradle => {
|
|
32
|
+
if (appBuildGradle.modResults.language === 'groovy') {
|
|
33
|
+
appBuildGradle.modResults.contents = modifyAppBuildGradle(appBuildGradle.modResults.contents);
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
36
|
throw new Error('Cannot configure Sentry in the app gradle because the build.gradle is not groovy');
|
|
37
37
|
}
|
|
38
|
-
return
|
|
38
|
+
return appBuildGradle;
|
|
39
39
|
});
|
|
40
40
|
return (0, config_plugins_1.withDangerousMod)(cfg, [
|
|
41
41
|
'android',
|
|
42
|
-
|
|
43
|
-
(0, utils_1.writeSentryPropertiesTo)(path.resolve(
|
|
44
|
-
return
|
|
42
|
+
dangerousMod => {
|
|
43
|
+
(0, utils_1.writeSentryPropertiesTo)(path.resolve(dangerousMod.modRequest.projectRoot, 'android'), sentryProperties);
|
|
44
|
+
return dangerousMod;
|
|
45
45
|
},
|
|
46
46
|
]);
|
|
47
47
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ExpoConfig } from '@expo/config-types';
|
|
1
2
|
export interface SentryAndroidGradlePluginOptions {
|
|
2
3
|
enableAndroidGradlePlugin?: boolean;
|
|
3
4
|
includeProguardMapping?: boolean;
|
|
@@ -13,4 +14,4 @@ export declare const sentryAndroidGradlePluginVersion = "5.9.0";
|
|
|
13
14
|
* Adds the Sentry Android Gradle Plugin to the project.
|
|
14
15
|
* https://docs.sentry.io/platforms/react-native/manual-setup/manual-setup/#enable-sentry-agp
|
|
15
16
|
*/
|
|
16
|
-
export declare function withSentryAndroidGradlePlugin(config:
|
|
17
|
+
export declare function withSentryAndroidGradlePlugin(config: ExpoConfig, { includeProguardMapping, dexguardEnabled, autoUploadProguardMapping, uploadNativeSymbols, autoUploadNativeSymbols, includeNativeSources, includeSourceContext, }?: SentryAndroidGradlePluginOptions): ExpoConfig;
|
|
@@ -11,32 +11,26 @@ exports.sentryAndroidGradlePluginVersion = '5.9.0';
|
|
|
11
11
|
function withSentryAndroidGradlePlugin(config, { includeProguardMapping = true, dexguardEnabled = false, autoUploadProguardMapping = true, uploadNativeSymbols = true, autoUploadNativeSymbols = true, includeNativeSources = true, includeSourceContext = false, } = {}) {
|
|
12
12
|
// Modify android/build.gradle
|
|
13
13
|
const withSentryProjectBuildGradle = (config) => {
|
|
14
|
-
return (0, config_plugins_1.withProjectBuildGradle)(config,
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
14
|
+
return (0, config_plugins_1.withProjectBuildGradle)(config, projectBuildGradle => {
|
|
16
15
|
if (!projectBuildGradle.modResults || !projectBuildGradle.modResults.contents) {
|
|
17
16
|
(0, utils_1.warnOnce)('android/build.gradle content is missing or undefined.');
|
|
18
|
-
return
|
|
17
|
+
return projectBuildGradle;
|
|
19
18
|
}
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
21
19
|
if (projectBuildGradle.modResults.language !== 'groovy') {
|
|
22
20
|
(0, utils_1.warnOnce)('Cannot configure Sentry in android/build.gradle because it is not in Groovy.');
|
|
23
|
-
return
|
|
21
|
+
return projectBuildGradle;
|
|
24
22
|
}
|
|
25
23
|
const dependency = `classpath("io.sentry:sentry-android-gradle-plugin:${exports.sentryAndroidGradlePluginVersion}")`;
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
27
24
|
if (projectBuildGradle.modResults.contents.includes(dependency)) {
|
|
28
25
|
(0, utils_1.warnOnce)('sentry-android-gradle-plugin dependency in already in android/build.gradle.');
|
|
29
|
-
return
|
|
26
|
+
return projectBuildGradle;
|
|
30
27
|
}
|
|
31
28
|
try {
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
33
29
|
const updatedContents = projectBuildGradle.modResults.contents.replace(/dependencies\s*{/, `dependencies {\n ${dependency}`);
|
|
34
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
35
30
|
if (updatedContents === projectBuildGradle.modResults.contents) {
|
|
36
31
|
(0, utils_1.warnOnce)('Failed to inject the dependency. Could not find `dependencies` in build.gradle.');
|
|
37
32
|
}
|
|
38
33
|
else {
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
40
34
|
projectBuildGradle.modResults.contents = updatedContents;
|
|
41
35
|
}
|
|
42
36
|
}
|
|
@@ -48,11 +42,10 @@ function withSentryAndroidGradlePlugin(config, { includeProguardMapping = true,
|
|
|
48
42
|
};
|
|
49
43
|
// Modify android/app/build.gradle
|
|
50
44
|
const withSentryAppBuildGradle = (config) => {
|
|
51
|
-
return (0, config_plugins_1.withAppBuildGradle)(config,
|
|
52
|
-
|
|
53
|
-
if (config.modResults.language !== 'groovy') {
|
|
45
|
+
return (0, config_plugins_1.withAppBuildGradle)(config, appBuildGradle => {
|
|
46
|
+
if (appBuildGradle.modResults.language !== 'groovy') {
|
|
54
47
|
(0, utils_1.warnOnce)('Cannot configure Sentry in android/app/build.gradle because it is not in Groovy.');
|
|
55
|
-
return
|
|
48
|
+
return appBuildGradle;
|
|
56
49
|
}
|
|
57
50
|
const sentryPlugin = `apply plugin: "io.sentry.android.gradle"`;
|
|
58
51
|
const sentryConfig = `
|
|
@@ -71,19 +64,15 @@ function withSentryAndroidGradlePlugin(config, { includeProguardMapping = true,
|
|
|
71
64
|
enabled = false
|
|
72
65
|
}
|
|
73
66
|
}`;
|
|
74
|
-
|
|
75
|
-
let contents = config.modResults.contents;
|
|
76
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
67
|
+
let contents = appBuildGradle.modResults.contents;
|
|
77
68
|
if (!contents.includes(sentryPlugin)) {
|
|
78
69
|
contents = `${sentryPlugin}\n${contents}`;
|
|
79
70
|
}
|
|
80
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
81
71
|
if (!contents.includes('sentry {')) {
|
|
82
72
|
contents = `${contents}\n${sentryConfig}`;
|
|
83
73
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return config;
|
|
74
|
+
appBuildGradle.modResults.contents = contents;
|
|
75
|
+
return appBuildGradle;
|
|
87
76
|
});
|
|
88
77
|
};
|
|
89
78
|
return withSentryAppBuildGradle(withSentryProjectBuildGradle(config));
|
|
@@ -131,7 +131,7 @@ try {
|
|
|
131
131
|
|
|
132
132
|
const sentryBuildPluginPath = path.join(projectRoot, '.env.sentry-build-plugin');
|
|
133
133
|
if (fs.existsSync(sentryBuildPluginPath)) {
|
|
134
|
-
loadDotenv();
|
|
134
|
+
loadDotenv(sentryBuildPluginPath);
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
let sentryOrg = getEnvVar(SENTRY_ORG);
|