From 7bb403e57def60a6cb46cbc151e8a97d9f12dcc1 Mon Sep 17 00:00:00 2001 From: Brent Vatne Date: Mon, 10 Jul 2023 12:02:43 -0700 Subject: [PATCH 1/3] Remove dependency on expo-updates --- build/integrations/Updates.d.ts | 7 +++++ build/integrations/Updates.d.ts.map | 1 + build/integrations/Updates.js | 15 ++++++++++ build/integrations/Updates.js.map | 1 + build/integrations/managed.js | 4 +-- build/integrations/managed.js.map | 2 +- build/sentry.js | 2 +- build/sentry.js.map | 2 +- package.json | 4 +-- src/integrations/Updates.ts | 15 ++++++++++ src/integrations/bare.ts | 2 +- src/integrations/managed.ts | 4 +-- src/sentry.ts | 2 +- yarn.lock | 45 ----------------------------- 14 files changed, 49 insertions(+), 57 deletions(-) create mode 100644 build/integrations/Updates.d.ts create mode 100644 build/integrations/Updates.d.ts.map create mode 100644 build/integrations/Updates.js create mode 100644 build/integrations/Updates.js.map create mode 100644 src/integrations/Updates.ts diff --git a/build/integrations/Updates.d.ts b/build/integrations/Updates.d.ts new file mode 100644 index 0000000..8535b5d --- /dev/null +++ b/build/integrations/Updates.d.ts @@ -0,0 +1,7 @@ +export declare const isEmbeddedLaunch: boolean; +export declare const releaseChannel: string; +export declare const channel: string | null; +export declare const updateId: string | null; +export declare const runtimeVersion: string | null; +export declare const manifest: any; +//# sourceMappingURL=Updates.d.ts.map \ No newline at end of file diff --git a/build/integrations/Updates.d.ts.map b/build/integrations/Updates.d.ts.map new file mode 100644 index 0000000..d9780c3 --- /dev/null +++ b/build/integrations/Updates.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Updates.d.ts","sourceRoot":"","sources":["../../src/integrations/Updates.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB,EAAE,OAA+C,CAAC;AAC/E,eAAO,MAAM,cAAc,EAAE,MAAgD,CAAC;AAC9E,eAAO,MAAM,OAAO,EAAE,MAAM,GAAG,IAAkC,CAAC;AAClE,eAAO,MAAM,QAAQ,EAAE,MAAM,GAAG,IAGtB,CAAC;AACX,eAAO,MAAM,cAAc,EAAE,MAAM,GAAG,IAAyC,CAAC;AAEhF,eAAO,MAAM,QAAQ,KAEjB,CAAC"} \ No newline at end of file diff --git a/build/integrations/Updates.js b/build/integrations/Updates.js new file mode 100644 index 0000000..c65f0bd --- /dev/null +++ b/build/integrations/Updates.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.manifest = exports.runtimeVersion = exports.updateId = exports.channel = exports.releaseChannel = exports.isEmbeddedLaunch = void 0; +const expo_modules_core_1 = require("expo-modules-core"); +const ExpoUpdates = expo_modules_core_1.NativeModulesProxy.ExpoUpdates ?? {}; +exports.isEmbeddedLaunch = ExpoUpdates.isEmbeddedLaunch || false; +exports.releaseChannel = ExpoUpdates.releaseChannel ?? 'default'; +exports.channel = ExpoUpdates.channel ?? null; +exports.updateId = ExpoUpdates.updateId && typeof ExpoUpdates.updateId === 'string' + ? ExpoUpdates.updateId.toLowerCase() + : null; +exports.runtimeVersion = ExpoUpdates.runtimeVersion ?? null; +exports.manifest = (ExpoUpdates.manifestString ? JSON.parse(ExpoUpdates.manifestString) : ExpoUpdates.manifest) ?? + {}; +//# sourceMappingURL=Updates.js.map \ No newline at end of file diff --git a/build/integrations/Updates.js.map b/build/integrations/Updates.js.map new file mode 100644 index 0000000..6de41c0 --- /dev/null +++ b/build/integrations/Updates.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Updates.js","sourceRoot":"","sources":["../../src/integrations/Updates.ts"],"names":[],"mappings":";;;AAAA,yDAAuD;AACvD,MAAM,WAAW,GAAG,sCAAkB,CAAC,WAAW,IAAK,EAAU,CAAC;AAErD,QAAA,gBAAgB,GAAY,WAAW,CAAC,gBAAgB,IAAI,KAAK,CAAC;AAClE,QAAA,cAAc,GAAW,WAAW,CAAC,cAAc,IAAI,SAAS,CAAC;AACjE,QAAA,OAAO,GAAkB,WAAW,CAAC,OAAO,IAAI,IAAI,CAAC;AACrD,QAAA,QAAQ,GACnB,WAAW,CAAC,QAAQ,IAAI,OAAO,WAAW,CAAC,QAAQ,KAAK,QAAQ;IAC9D,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,WAAW,EAAE;IACpC,CAAC,CAAC,IAAI,CAAC;AACE,QAAA,cAAc,GAAkB,WAAW,CAAC,cAAc,IAAI,IAAI,CAAC;AAEnE,QAAA,QAAQ,GACnB,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC;IAC5F,EAAE,CAAC","sourcesContent":["import { NativeModulesProxy } from 'expo-modules-core';\nconst ExpoUpdates = NativeModulesProxy.ExpoUpdates ?? ({} as any);\n\nexport const isEmbeddedLaunch: boolean = ExpoUpdates.isEmbeddedLaunch || false;\nexport const releaseChannel: string = ExpoUpdates.releaseChannel ?? 'default';\nexport const channel: string | null = ExpoUpdates.channel ?? null;\nexport const updateId: string | null =\n ExpoUpdates.updateId && typeof ExpoUpdates.updateId === 'string'\n ? ExpoUpdates.updateId.toLowerCase()\n : null;\nexport const runtimeVersion: string | null = ExpoUpdates.runtimeVersion ?? null;\n\nexport const manifest =\n (ExpoUpdates.manifestString ? JSON.parse(ExpoUpdates.manifestString) : ExpoUpdates.manifest) ??\n {};"]} \ No newline at end of file diff --git a/build/integrations/managed.js b/build/integrations/managed.js index 37d2549..9e32fde 100644 --- a/build/integrations/managed.js +++ b/build/integrations/managed.js @@ -27,10 +27,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ExpoManagedIntegration = void 0; +const Updates = __importStar(require("./Updates")); const react_native_1 = require("react-native"); const expo_constants_1 = __importDefault(require("expo-constants")); const Device = __importStar(require("expo-device")); -const Updates = __importStar(require("expo-updates")); const react_native_2 = require("@sentry/react-native"); const DEFAULT_TAGS = [ { @@ -74,7 +74,7 @@ class ExpoManagedIntegration { } }); } - if (Updates?.channel) { + if (Updates.channel) { (0, react_native_2.setTag)('expoChannel', Updates.channel); } const defaultHandler = ErrorUtils.getGlobalHandler(); diff --git a/build/integrations/managed.js.map b/build/integrations/managed.js.map index 767ea5c..a0992eb 100644 --- a/build/integrations/managed.js.map +++ b/build/integrations/managed.js.map @@ -1 +1 @@ -{"version":3,"file":"managed.js","sourceRoot":"","sources":["../../src/integrations/managed.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAwC;AACxC,oEAAuC;AACvC,oDAAsC;AACtC,sDAAwC;AACxC,uDAM8B;AAG9B,MAAM,YAAY,GAAG;IACnB;QACE,OAAO,EAAE,oBAAoB;QAC7B,YAAY,EAAE,gBAAgB;KAC/B;IACD;QACE,OAAO,EAAE,YAAY;QACrB,YAAY,EAAE,SAAS;KACxB;IACD;QACE,OAAO,EAAE,kBAAkB;QAC3B,YAAY,EAAE,eAAe;KAC9B;IACD;QACE,OAAO,EAAE,gBAAgB;QACzB,YAAY,EAAE,YAAY;KAC3B;CACF,CAAC;AAEF,MAAa,sBAAsB;IACjC,MAAM,CAAC,EAAE,GAAG,wBAAwB,CAAC;IACrC,IAAI,GAAG,sBAAsB,CAAC,EAAE,CAAC;IAEjC,SAAS;QACP,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAe,CAAC;QAEzC,IAAA,wBAAS,EAAC;YACR,QAAQ;YACR,eAAe,EAAE,MAAM,CAAC,eAAe;YACvC,UAAU,EAAE,wBAAS,CAAC,UAAU;SACjC,CAAC,CAAC;QAEH,IAAA,sBAAO,EAAC;YACN,QAAQ,EAAE,wBAAS,CAAC,SAAS;YAC7B,YAAY,EAAE,wBAAS,CAAC,YAAY,IAAI,KAAK;SAC9C,CAAC,CAAC;QAEH,IAAI,wBAAS,CAAC,YAAY,KAAK,MAAM,IAAI,wBAAS,CAAC,WAAW,EAAE;YAC9D,IAAA,qBAAM,EAAC,gBAAgB,EAAE,wBAAS,CAAC,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AI,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;oBAClE,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;gBACjC,CAAC,CAAC,CAAC;aACJ;iBAAM;gBACL,mGAAmG;gBACnG,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;aAChC;QACH,CAAC,CAAC,CAAC;QAEH,IAAA,sCAAuB,EAAC,UAAU,KAAK,EAAE,KAAK;YAC5C,MAAM,IAAI,GAAG,IAAA,4BAAa,GAAE,CAAC,cAAc,CAAC,sBAAsB,CAAC,CAAC;YAEpE,IAAI,IAAI,EAAE;gBACR,KAAK,CAAC,QAAQ,GAAG;oBACf,GAAG,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC;oBACzB,MAAM,EAAE;wBACN,SAAS,EAAE,CAAC,MAAM,CAAC,QAAQ;wBAC3B,KAAK,EAAE,MAAM,CAAC,SAAS,IAAI,SAAS;qBACrC;oBACD,EAAE,EAAE;wBACF,IAAI,EAAE,MAAM,CAAC,MAAM,IAAI,SAAS;wBAChC,OAAO,EAAE,MAAM,CAAC,SAAS,IAAI,SAAS;qBACvC;iBACF,CAAC;aACH;YAED,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;;AAtFH,wDAuFC","sourcesContent":["import { Platform } from 'react-native';\nimport Constants from 'expo-constants';\nimport * as Device from 'expo-device';\nimport * as Updates from 'expo-updates';\nimport {\n setExtras,\n setTags,\n getCurrentHub,\n setTag,\n addGlobalEventProcessor,\n} from '@sentry/react-native';\nimport { SeverityLevel } from '@sentry/types';\n\nconst DEFAULT_TAGS = [\n {\n tagName: 'expoReleaseChannel',\n manifestName: 'releaseChannel',\n },\n {\n tagName: 'appVersion',\n manifestName: 'version',\n },\n {\n tagName: 'appPublishedTime',\n manifestName: 'publishedTime',\n },\n {\n tagName: 'expoSdkVersion',\n manifestName: 'sdkVersion',\n },\n];\n\nexport class ExpoManagedIntegration {\n static id = 'ExpoManagedIntegration';\n name = ExpoManagedIntegration.id;\n\n setupOnce() {\n const manifest = Updates.manifest as any;\n\n setExtras({\n manifest,\n deviceYearClass: Device.deviceYearClass,\n linkingUri: Constants.linkingUri,\n });\n\n setTags({\n deviceId: Constants.sessionId,\n appOwnership: Constants.appOwnership || 'N/A',\n });\n\n if (Constants.appOwnership === 'expo' && Constants.expoVersion) {\n setTag('expoAppVersion', Constants.expoVersion);\n }\n\n if (typeof manifest === 'object') {\n DEFAULT_TAGS.forEach((tag) => {\n if (manifest.hasOwnProperty(tag.manifestName)) {\n setTag(tag.tagName, manifest[tag.manifestName]);\n }\n });\n }\n\n if (Updates?.channel) {\n setTag('expoChannel', Updates.channel);\n }\n\n const defaultHandler = ErrorUtils.getGlobalHandler();\n\n ErrorUtils.setGlobalHandler((error, isFatal) => {\n // On Android, the Expo bundle filepath cannot be handled by TraceKit,\n // so we normalize it to use the same filepath that we use on Expo iOS.\n if (Platform.OS === 'android') {\n error.stack = error.stack.replace(\n /\\/.*\\/\\d+\\.\\d+.\\d+\\/cached\\-bundle\\-experience\\-/g,\n 'https://classic-assets.eascdn.net:443/'\n );\n }\n\n getCurrentHub().withScope((scope) => {\n if (isFatal) {\n scope.setLevel(\"fatal\" as SeverityLevel);\n }\n getCurrentHub().captureException(error, {\n originalException: error,\n });\n });\n\n const client = getCurrentHub().getClient();\n if (client && !__DEV__) {\n // @ts-ignore PR to add this to types: https://github.com/getsentry/sentry-javascript/pull/2669\n client.flush(client.getOptions().shutdownTimeout || 2000).then(() => {\n defaultHandler(error, isFatal);\n });\n } else {\n // If there is no client, something is fishy but we call the default handler anyway. Even if in dev\n defaultHandler(error, isFatal);\n }\n });\n\n addGlobalEventProcessor(function (event, _hint) {\n const that = getCurrentHub().getIntegration(ExpoManagedIntegration);\n\n if (that) {\n event.contexts = {\n ...(event.contexts || {}),\n device: {\n simulator: !Device.isDevice,\n model: Device.modelName || undefined,\n },\n os: {\n name: Device.osName || undefined,\n version: Device.osVersion || undefined,\n },\n };\n }\n\n return event;\n });\n }\n}\n"]} \ No newline at end of file +{"version":3,"file":"managed.js","sourceRoot":"","sources":["../../src/integrations/managed.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAqC;AACrC,+CAAwC;AACxC,oEAAuC;AACvC,oDAAsC;AACtC,uDAM8B;AAG9B,MAAM,YAAY,GAAG;IACnB;QACE,OAAO,EAAE,oBAAoB;QAC7B,YAAY,EAAE,gBAAgB;KAC/B;IACD;QACE,OAAO,EAAE,YAAY;QACrB,YAAY,EAAE,SAAS;KACxB;IACD;QACE,OAAO,EAAE,kBAAkB;QAC3B,YAAY,EAAE,eAAe;KAC9B;IACD;QACE,OAAO,EAAE,gBAAgB;QACzB,YAAY,EAAE,YAAY;KAC3B;CACF,CAAC;AAEF,MAAa,sBAAsB;IACjC,MAAM,CAAC,EAAE,GAAG,wBAAwB,CAAC;IACrC,IAAI,GAAG,sBAAsB,CAAC,EAAE,CAAC;IAEjC,SAAS;QACP,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAe,CAAC;QAEzC,IAAA,wBAAS,EAAC;YACR,QAAQ;YACR,eAAe,EAAE,MAAM,CAAC,eAAe;YACvC,UAAU,EAAE,wBAAS,CAAC,UAAU;SACjC,CAAC,CAAC;QAEH,IAAA,sBAAO,EAAC;YACN,QAAQ,EAAE,wBAAS,CAAC,SAAS;YAC7B,YAAY,EAAE,wBAAS,CAAC,YAAY,IAAI,KAAK;SAC9C,CAAC,CAAC;QAEH,IAAI,wBAAS,CAAC,YAAY,KAAK,MAAM,IAAI,wBAAS,CAAC,WAAW,EAAE;YAC9D,IAAA,qBAAM,EAAC,gBAAgB,EAAE,wBAAS,CAAC,WAAW,CAAC,CAAC;SACjD;QAED,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;YAChC,YAAY,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBAC3B,IAAI,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,YAAY,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CAAC,CAAC;aAChC;QACH,CAAC,CAAC,CAAC;QAEH,IAAA,sCAAuB,EAAC,UAAU,KAAK,EAAE,KAAK;YAC5C,MAAM,IAAI,GAAG,IAAA,4BAAa,GAAE,CAAC,cAAc,CAAC,sBAAsB,CAAC,CAAC;YAEpE,IAAI,IAAI,EAAE;gBACR,KAAK,CAAC,QAAQ,GAAG;oBACf,GAAG,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC;oBACzB,MAAM,EAAE;wBACN,SAAS,EAAE,CAAC,MAAM,CAAC,QAAQ;wBAC3B,KAAK,EAAE,MAAM,CAAC,SAAS,IAAI,SAAS;qBACrC;oBACD,EAAE,EAAE;wBACF,IAAI,EAAE,MAAM,CAAC,MAAM,IAAI,SAAS;wBAChC,OAAO,EAAE,MAAM,CAAC,SAAS,IAAI,SAAS;qBACvC;iBACF,CAAC;aACH;YAED,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;;AAtFH,wDAuFC","sourcesContent":["import * as Updates from './Updates';\nimport { Platform } from 'react-native';\nimport Constants from 'expo-constants';\nimport * as Device from 'expo-device';\nimport {\n setExtras,\n setTags,\n getCurrentHub,\n setTag,\n addGlobalEventProcessor,\n} from '@sentry/react-native';\nimport { SeverityLevel } from '@sentry/types';\n\nconst DEFAULT_TAGS = [\n {\n tagName: 'expoReleaseChannel',\n manifestName: 'releaseChannel',\n },\n {\n tagName: 'appVersion',\n manifestName: 'version',\n },\n {\n tagName: 'appPublishedTime',\n manifestName: 'publishedTime',\n },\n {\n tagName: 'expoSdkVersion',\n manifestName: 'sdkVersion',\n },\n];\n\nexport class ExpoManagedIntegration {\n static id = 'ExpoManagedIntegration';\n name = ExpoManagedIntegration.id;\n\n setupOnce() {\n const manifest = Updates.manifest as any;\n\n setExtras({\n manifest,\n deviceYearClass: Device.deviceYearClass,\n linkingUri: Constants.linkingUri,\n });\n\n setTags({\n deviceId: Constants.sessionId,\n appOwnership: Constants.appOwnership || 'N/A',\n });\n\n if (Constants.appOwnership === 'expo' && Constants.expoVersion) {\n setTag('expoAppVersion', Constants.expoVersion);\n }\n\n if (typeof manifest === 'object') {\n DEFAULT_TAGS.forEach((tag) => {\n if (manifest.hasOwnProperty(tag.manifestName)) {\n setTag(tag.tagName, manifest[tag.manifestName]);\n }\n });\n }\n\n if (Updates.channel) {\n setTag('expoChannel', Updates.channel);\n }\n\n const defaultHandler = ErrorUtils.getGlobalHandler();\n\n ErrorUtils.setGlobalHandler((error, isFatal) => {\n // On Android, the Expo bundle filepath cannot be handled by TraceKit,\n // so we normalize it to use the same filepath that we use on Expo iOS.\n if (Platform.OS === 'android') {\n error.stack = error.stack.replace(\n /\\/.*\\/\\d+\\.\\d+.\\d+\\/cached\\-bundle\\-experience\\-/g,\n 'https://classic-assets.eascdn.net:443/'\n );\n }\n\n getCurrentHub().withScope((scope) => {\n if (isFatal) {\n scope.setLevel(\"fatal\" as SeverityLevel);\n }\n getCurrentHub().captureException(error, {\n originalException: error,\n });\n });\n\n const client = getCurrentHub().getClient();\n if (client && !__DEV__) {\n // @ts-ignore PR to add this to types: https://github.com/getsentry/sentry-javascript/pull/2669\n client.flush(client.getOptions().shutdownTimeout || 2000).then(() => {\n defaultHandler(error, isFatal);\n });\n } else {\n // If there is no client, something is fishy but we call the default handler anyway. Even if in dev\n defaultHandler(error, isFatal);\n }\n });\n\n addGlobalEventProcessor(function (event, _hint) {\n const that = getCurrentHub().getIntegration(ExpoManagedIntegration);\n\n if (that) {\n event.contexts = {\n ...(event.contexts || {}),\n device: {\n simulator: !Device.isDevice,\n model: Device.modelName || undefined,\n },\n os: {\n name: Device.osName || undefined,\n version: Device.osVersion || undefined,\n },\n };\n }\n\n return event;\n });\n }\n}\n"]} \ No newline at end of file diff --git a/build/sentry.js b/build/sentry.js index 9e53d6b..8be109f 100644 --- a/build/sentry.js +++ b/build/sentry.js @@ -25,12 +25,12 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.init = exports.Native = void 0; const react_native_1 = require("react-native"); -const Updates = __importStar(require("expo-updates")); const expo_constants_1 = __importStar(require("expo-constants")); const Application = __importStar(require("expo-application")); const integrations_1 = require("@sentry/integrations"); const bare_1 = require("./integrations/bare"); const managed_1 = require("./integrations/managed"); +const Updates = __importStar(require("./integrations/Updates")); const utils_1 = require("./utils"); const version_1 = require("./version"); const react_native_2 = require("@sentry/react-native"); diff --git a/build/sentry.js.map b/build/sentry.js.map index 2908ad3..b1803db 100644 --- a/build/sentry.js.map +++ b/build/sentry.js.map @@ -1 +1 @@ -{"version":3,"file":"sentry.js","sourceRoot":"","sources":["../src/sentry.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAwC;AACxC,sDAAwC;AACxC,iEAAiE;AACjE,8DAAgD;AAChD,uDAAqD;AAGrD,8CAA0D;AAC1D,oDAAgE;AAChE,mCAA+E;AAC/E,uCAImB;AAEnB,uDAI8B;AAG9B,+DAA+C;AAE/C,MAAM,cAAc,GAAY;IAC9B,IAAI,EAAE,qCAAqC;IAC3C,QAAQ,EAAE;QACR;YACE,IAAI,EAAE,6BAAmB;YACzB,OAAO,EAAE,6BAAmB;SAC7B;QACD;YACE,IAAI,EAAE,qCAA2B;YACjC,OAAO,EAAE,0BAA2B;SACrC;KACF;IACD,OAAO,EAAE,6BAAmB;CAC7B,CAAC;AAEF,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAuB,CAAC;AACjD,MAAM,gBAAgB,GAAG,wBAAS,CAAC,oBAAoB,KAAK,qCAAoB,CAAC,IAAI,CAAC;AAEtF,MAAM,eAAe,GAAG;IACtB,kBAAkB,EAAE,KAAK;IACzB,OAAO,EAAE,iBAAiB,EAAE;IAC5B,IAAI,EAAE,OAAO,EAAE;IACf,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,yBAAyB,EAAE,KAAK,EAAE,CA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L,MAAM,CAAC,CAAC;SACT;KACF;AACH,CAAC,CAAC;AAjEW,QAAA,IAAI,QAiEf","sourcesContent":["import { Platform } from 'react-native';\nimport * as Updates from 'expo-updates';\nimport Constants, { ExecutionEnvironment } from 'expo-constants';\nimport * as Application from 'expo-application';\nimport { RewriteFrames } from '@sentry/integrations';\nimport { Integration, SdkInfo } from '@sentry/types';\n\nimport { ExpoBareIntegration } from './integrations/bare';\nimport { ExpoManagedIntegration } from './integrations/managed';\nimport { SentryExpoNativeOptions, overrideDefaultIntegrations } from './utils';\nimport {\n SENTRY_EXPO_PACKAGE,\n SENTRY_EXPO_VERSION,\n SENTRY_REACT_NATIVE_PACKAGE,\n} from './version';\n\nimport {\n init as initNative,\n Integrations,\n SDK_VERSION as SENTRY_REACT_NATIVE_VERSION,\n} from '@sentry/react-native';\nimport { AppManifest } from 'expo-constants/build/Constants.types';\n\nexport * as Native from '@sentry/react-native';\n\nconst defaultSdkInfo: SdkInfo = {\n name: 'sentry.javascript.react-native.expo',\n packages: [\n {\n name: SENTRY_EXPO_PACKAGE,\n version: SENTRY_EXPO_VERSION,\n },\n {\n name: SENTRY_REACT_NATIVE_PACKAGE,\n version: SENTRY_REACT_NATIVE_VERSION,\n }\n ],\n version: SENTRY_EXPO_VERSION,\n};\n\nconst MANIFEST = Updates.manifest as AppManifest;\nconst IS_BARE_WORKFLOW = Constants.executionEnvironment === ExecutionEnvironment.Bare;\n\nconst DEFAULT_OPTIONS = {\n enableNativeNagger: false, // Otherwise this will trigger an Alert(), let's rely on the logs instead\n release: getDefaultRelease(),\n dist: getDist(),\n ...(IS_BARE_WORKFLOW ? {} : { enableNative: false, enableNativeCrashHandling: false }),\n _metadata: {\n sdk: defaultSdkInfo,\n },\n};\n\n/**\n * For embedded updates, the dist version needs to match what is set by the Sentry build script.\n * For modern manifest OTA updates, the updateId is used.\n */\nfunction getDist(): string | null | undefined {\n if (Updates.isEmbeddedLaunch) {\n return MANIFEST.revisionId ? MANIFEST.version : `${Application.nativeBuildVersion}`;\n } else {\n return Updates.updateId;\n }\n}\n\n/**\n * We assign the appropriate release based on if the app is running in development,\n * on an Classic OTA Update, or on a no-publish build.\n */\nfunction getDefaultRelease(): string {\n if (__DEV__) {\n return 'DEVELOPMENT';\n } else if (MANIFEST.revisionId) {\n // Want to make sure this still exists in EAS update: equal on iOS & Android\n return MANIFEST.revisionId;\n } else {\n // This is the default set by Sentry's native Xcode & Gradle scripts\n return `${Application.applicationId}@${Application.nativeApplicationVersion}+${Application.nativeBuildVersion}`;\n }\n}\n\nexport const init = (options: SentryExpoNativeOptions = {}) => {\n const defaultExpoIntegrations = [\n new Integrations.ReactNativeErrorHandlers({\n onerror: false,\n onunhandledrejection: true,\n }),\n IS_BARE_WORKFLOW ? new ExpoBareIntegration() : new ExpoManagedIntegration(),\n new RewriteFrames({\n iteratee: (frame) => {\n if (frame.filename && frame.filename !== '[native code]') {\n frame.filename =\n Platform.OS === 'android' ? 'app:///index.android.bundle' : 'app:///main.jsbundle';\n }\n return frame;\n },\n }),\n ];\n\n let nativeOptions = { ...DEFAULT_OPTIONS, ...options } as SentryExpoNativeOptions;\n\n if (Array.isArray(nativeOptions.integrations)) {\n // Allow users to override Expo defaults...ymmv\n nativeOptions.integrations = overrideDefaultIntegrations(\n defaultExpoIntegrations,\n nativeOptions.integrations\n );\n } else if (typeof nativeOptions.integrations === 'function') {\n // Need to rewrite the function to take Expo's default integrations\n let functionWithoutExpoIntegrations = nativeOptions.integrations;\n const functionWithExpoIntegrations = (integrations: Integration[]) => {\n return functionWithoutExpoIntegrations(\n overrideDefaultIntegrations(integrations, defaultExpoIntegrations)\n );\n };\n nativeOptions.integrations = functionWithExpoIntegrations;\n } else {\n nativeOptions.integrations = [...defaultExpoIntegrations];\n }\n\n if (__DEV__ && !nativeOptions.enableInExpoDevelopment) {\n nativeOptions.enabled = false;\n if (!nativeOptions.hasOwnProperty('enableInExpoDevelopment')) {\n console.log(\n '[sentry-expo] Disabled Sentry in development. Note you can set Sentry.init({ enableInExpoDevelopment: true });'\n );\n }\n }\n\n try {\n return initNative({ ...nativeOptions });\n } catch (e) {\n if (IS_BARE_WORKFLOW) {\n // Native projects have not been linked, try to continue with no native capability\n console.warn(\n `[sentry-expo] Disabling the Sentry Native SDK (all JS errors will still be reported).\\nTo enable it, run 'yarn add @sentry/react-native' or 'npm install @sentry/react-native' in your project directory. To silence this warning, pass 'enableNative: false' to Sentry.init().`\n );\n return initNative({\n ...nativeOptions,\n enableNative: false,\n enableNativeCrashHandling: false,\n });\n } else {\n throw e;\n }\n }\n};\n"]} \ No newline at end of file +{"version":3,"file":"sentry.js","sourceRoot":"","sources":["../src/sentry.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAwC;AACxC,iEAAiE;AACjE,8DAAgD;AAChD,uDAAqD;AAGrD,8CAA0D;AAC1D,oDAAgE;AAChE,gEAAiD;AACjD,mCAA+E;AAC/E,uCAImB;AAEnB,uDAI8B;AAG9B,+DAA+C;AAE/C,MAAM,cAAc,GAAY;IAC9B,IAAI,EAAE,qCAAqC;IAC3C,QAAQ,EAAE;QACR;YACE,IAAI,EAAE,6BAAmB;YACzB,OAAO,EAAE,6BAAmB;SAC7B;QACD;YACE,IAAI,EAAE,qCAA2B;YACjC,OAAO,EAAE,0BAA2B;SACrC;KACF;IACD,OAAO,EAAE,6BAAmB;CAC7B,CAAC;AAEF,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAuB,CAAC;AACjD,MAAM,gBAAgB,GAAG,wBAAS,CAAC,oBAAoB,KAAK,qCAAoB,CAAC,IAAI,CAAC;AAEtF,MAAM,eAAe,GAAG;IACtB,kBAAkB,EAAE,KAAK;IACzB,OAAO,EAAE,iBAAiB,EAAE;IAC5B,IAAI,EAAE,OAAO,EAAE;IACf,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,yBAAyB,EAAE,KAAK,EAAE,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YACL,MAAM,CAAC,CAAC;SACT;KACF;AACH,CAAC,CAAC;AAjEW,QAAA,IAAI,QAiEf","sourcesContent":["import { Platform } from 'react-native';\nimport Constants, { ExecutionEnvironment } from 'expo-constants';\nimport * as Application from 'expo-application';\nimport { RewriteFrames } from '@sentry/integrations';\nimport { Integration, SdkInfo } from '@sentry/types';\n\nimport { ExpoBareIntegration } from './integrations/bare';\nimport { ExpoManagedIntegration } from './integrations/managed';\nimport * as Updates from './integrations/Updates'\nimport { SentryExpoNativeOptions, overrideDefaultIntegrations } from './utils';\nimport {\n SENTRY_EXPO_PACKAGE,\n SENTRY_EXPO_VERSION,\n SENTRY_REACT_NATIVE_PACKAGE,\n} from './version';\n\nimport {\n init as initNative,\n Integrations,\n SDK_VERSION as SENTRY_REACT_NATIVE_VERSION,\n} from '@sentry/react-native';\nimport { AppManifest } from 'expo-constants/build/Constants.types';\n\nexport * as Native from '@sentry/react-native';\n\nconst defaultSdkInfo: SdkInfo = {\n name: 'sentry.javascript.react-native.expo',\n packages: [\n {\n name: SENTRY_EXPO_PACKAGE,\n version: SENTRY_EXPO_VERSION,\n },\n {\n name: SENTRY_REACT_NATIVE_PACKAGE,\n version: SENTRY_REACT_NATIVE_VERSION,\n }\n ],\n version: SENTRY_EXPO_VERSION,\n};\n\nconst MANIFEST = Updates.manifest as AppManifest;\nconst IS_BARE_WORKFLOW = Constants.executionEnvironment === ExecutionEnvironment.Bare;\n\nconst DEFAULT_OPTIONS = {\n enableNativeNagger: false, // Otherwise this will trigger an Alert(), let's rely on the logs instead\n release: getDefaultRelease(),\n dist: getDist(),\n ...(IS_BARE_WORKFLOW ? {} : { enableNative: false, enableNativeCrashHandling: false }),\n _metadata: {\n sdk: defaultSdkInfo,\n },\n};\n\n/**\n * For embedded updates, the dist version needs to match what is set by the Sentry build script.\n * For modern manifest OTA updates, the updateId is used.\n */\nfunction getDist(): string | null | undefined {\n if (Updates.isEmbeddedLaunch) {\n return MANIFEST.revisionId ? MANIFEST.version : `${Application.nativeBuildVersion}`;\n } else {\n return Updates.updateId;\n }\n}\n\n/**\n * We assign the appropriate release based on if the app is running in development,\n * on an Classic OTA Update, or on a no-publish build.\n */\nfunction getDefaultRelease(): string {\n if (__DEV__) {\n return 'DEVELOPMENT';\n } else if (MANIFEST.revisionId) {\n // Want to make sure this still exists in EAS update: equal on iOS & Android\n return MANIFEST.revisionId;\n } else {\n // This is the default set by Sentry's native Xcode & Gradle scripts\n return `${Application.applicationId}@${Application.nativeApplicationVersion}+${Application.nativeBuildVersion}`;\n }\n}\n\nexport const init = (options: SentryExpoNativeOptions = {}) => {\n const defaultExpoIntegrations = [\n new Integrations.ReactNativeErrorHandlers({\n onerror: false,\n onunhandledrejection: true,\n }),\n IS_BARE_WORKFLOW ? new ExpoBareIntegration() : new ExpoManagedIntegration(),\n new RewriteFrames({\n iteratee: (frame) => {\n if (frame.filename && frame.filename !== '[native code]') {\n frame.filename =\n Platform.OS === 'android' ? 'app:///index.android.bundle' : 'app:///main.jsbundle';\n }\n return frame;\n },\n }),\n ];\n\n let nativeOptions = { ...DEFAULT_OPTIONS, ...options } as SentryExpoNativeOptions;\n\n if (Array.isArray(nativeOptions.integrations)) {\n // Allow users to override Expo defaults...ymmv\n nativeOptions.integrations = overrideDefaultIntegrations(\n defaultExpoIntegrations,\n nativeOptions.integrations\n );\n } else if (typeof nativeOptions.integrations === 'function') {\n // Need to rewrite the function to take Expo's default integrations\n let functionWithoutExpoIntegrations = nativeOptions.integrations;\n const functionWithExpoIntegrations = (integrations: Integration[]) => {\n return functionWithoutExpoIntegrations(\n overrideDefaultIntegrations(integrations, defaultExpoIntegrations)\n );\n };\n nativeOptions.integrations = functionWithExpoIntegrations;\n } else {\n nativeOptions.integrations = [...defaultExpoIntegrations];\n }\n\n if (__DEV__ && !nativeOptions.enableInExpoDevelopment) {\n nativeOptions.enabled = false;\n if (!nativeOptions.hasOwnProperty('enableInExpoDevelopment')) {\n console.log(\n '[sentry-expo] Disabled Sentry in development. Note you can set Sentry.init({ enableInExpoDevelopment: true });'\n );\n }\n }\n\n try {\n return initNative({ ...nativeOptions });\n } catch (e) {\n if (IS_BARE_WORKFLOW) {\n // Native projects have not been linked, try to continue with no native capability\n console.warn(\n `[sentry-expo] Disabling the Sentry Native SDK (all JS errors will still be reported).\\nTo enable it, run 'yarn add @sentry/react-native' or 'npm install @sentry/react-native' in your project directory. To silence this warning, pass 'enableNative: false' to Sentry.init().`\n );\n return initNative({\n ...nativeOptions,\n enableNative: false,\n enableNativeCrashHandling: false,\n });\n } else {\n throw e;\n }\n }\n};\n"]} \ No newline at end of file diff --git a/package.json b/package.json index 0cf71a6..9760752 100644 --- a/package.json +++ b/package.json @@ -50,8 +50,7 @@ "expo": ">=47.0.0", "expo-application": "*", "expo-constants": "*", - "expo-device": "*", - "expo-updates": "*" + "expo-device": "*" }, "devDependencies": { "@expo/config-types": "^47.0.0", @@ -64,7 +63,6 @@ "expo-constants": "~14.0.2", "expo-device": "~5.0.0", "expo-module-scripts": "3.0.4", - "expo-updates": "~0.15.6", "jest": "26", "react": "18.1.0", "react-native": "^0.70.5", diff --git a/src/integrations/Updates.ts b/src/integrations/Updates.ts new file mode 100644 index 0000000..44b5d0f --- /dev/null +++ b/src/integrations/Updates.ts @@ -0,0 +1,15 @@ +import { NativeModulesProxy } from 'expo-modules-core'; +const ExpoUpdates = NativeModulesProxy.ExpoUpdates ?? ({} as any); + +export const isEmbeddedLaunch: boolean = ExpoUpdates.isEmbeddedLaunch || false; +export const releaseChannel: string = ExpoUpdates.releaseChannel ?? 'default'; +export const channel: string | null = ExpoUpdates.channel ?? null; +export const updateId: string | null = + ExpoUpdates.updateId && typeof ExpoUpdates.updateId === 'string' + ? ExpoUpdates.updateId.toLowerCase() + : null; +export const runtimeVersion: string | null = ExpoUpdates.runtimeVersion ?? null; + +export const manifest = + (ExpoUpdates.manifestString ? JSON.parse(ExpoUpdates.manifestString) : ExpoUpdates.manifest) ?? + {}; \ No newline at end of file diff --git a/src/integrations/bare.ts b/src/integrations/bare.ts index b40ecbf..907c064 100644 --- a/src/integrations/bare.ts +++ b/src/integrations/bare.ts @@ -1,7 +1,7 @@ import { Platform } from 'react-native'; import Constants from 'expo-constants'; import * as Device from 'expo-device'; -import * as Updates from 'expo-updates'; +import * as Updates from './Updates'; import { setExtras, setTags, diff --git a/src/integrations/managed.ts b/src/integrations/managed.ts index 57a1c81..8a35ee2 100644 --- a/src/integrations/managed.ts +++ b/src/integrations/managed.ts @@ -1,7 +1,7 @@ +import * as Updates from './Updates'; import { Platform } from 'react-native'; import Constants from 'expo-constants'; import * as Device from 'expo-device'; -import * as Updates from 'expo-updates'; import { setExtras, setTags, @@ -60,7 +60,7 @@ export class ExpoManagedIntegration { }); } - if (Updates?.channel) { + if (Updates.channel) { setTag('expoChannel', Updates.channel); } diff --git a/src/sentry.ts b/src/sentry.ts index e4203d2..6ecafc3 100644 --- a/src/sentry.ts +++ b/src/sentry.ts @@ -1,5 +1,4 @@ import { Platform } from 'react-native'; -import * as Updates from 'expo-updates'; import Constants, { ExecutionEnvironment } from 'expo-constants'; import * as Application from 'expo-application'; import { RewriteFrames } from '@sentry/integrations'; @@ -7,6 +6,7 @@ import { Integration, SdkInfo } from '@sentry/types'; import { ExpoBareIntegration } from './integrations/bare'; import { ExpoManagedIntegration } from './integrations/managed'; +import * as Updates from './integrations/Updates' import { SentryExpoNativeOptions, overrideDefaultIntegrations } from './utils'; import { SENTRY_EXPO_PACKAGE, diff --git a/yarn.lock b/yarn.lock index 34bfccc..3c3695a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4375,11 +4375,6 @@ expo-device@~5.0.0: dependencies: ua-parser-js "^0.7.19" -expo-eas-client@~0.4.0: - version "0.4.1" - resolved "https://registry.yarnpkg.com/expo-eas-client/-/expo-eas-client-0.4.1.tgz#4ccdafb5faeac97394fb3fa4c777ec22b2017f1d" - integrity sha512-bIj2rm6lw/iZAOAW5CSAxshSXi2oY+ORpHRp4ZdqSDuwA0RIa9jGyMm1Jhostjjz5y9k2uur5vtVqq6P3Bwx/Q== - expo-error-recovery@~4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/expo-error-recovery/-/expo-error-recovery-4.0.1.tgz#3e3333e134c992c234539d3773fe78915c883755" @@ -4399,23 +4394,11 @@ expo-font@~11.0.1: dependencies: fontfaceobserver "^2.1.0" -expo-json-utils@~0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/expo-json-utils/-/expo-json-utils-0.4.0.tgz#47ae83a1cc973101d62371f94790e9ad39491751" - integrity sha512-lK6gjea72XTYafpKNNJaMrBK5dYAX8LFLXrp/M1MKJU4Zy7EHd2rKrLwop3GZts8VdwLHeVcMko79SAbhe3i5Q== - expo-keep-awake@~11.0.1: version "11.0.1" resolved "https://registry.yarnpkg.com/expo-keep-awake/-/expo-keep-awake-11.0.1.tgz#ee354465892a94040ffe09901b85b469e7d54fb3" integrity sha512-44ZjgLE4lnce2d40Pv8xsjMVc6R5GvgHOwZfkLYtGmgYG9TYrEJeEj5UfSeweXPL3pBFhXKfFU8xpGYMaHdP0A== -expo-manifests@~0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/expo-manifests/-/expo-manifests-0.4.0.tgz#6fd44b6427e113f2eb9409ca46df95cbbea068df" - integrity sha512-IdZjIYDxx4nH0Gb3X4T4/2YknmR/jSLxymAS0m7SfJ9V7Vlu/y0p3lNwUys9/JzihxX9PDIuOi/Y4/uqL6TlXg== - dependencies: - expo-json-utils "~0.4.0" - expo-module-scripts@3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/expo-module-scripts/-/expo-module-scripts-3.0.4.tgz#6444070dc2d90c2f34a7a11aa741e78c1df17915" @@ -4455,34 +4438,6 @@ expo-modules-core@1.1.1: compare-versions "^3.4.0" invariant "^2.2.4" -expo-structured-headers@~3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/expo-structured-headers/-/expo-structured-headers-3.0.1.tgz#291596c61acd2a45839ad6c6798c3d5cfc1eb4e9" - integrity sha512-x6hkzuQL5HJoyB+xQyBf9M04ZUmrjFWqEW7gzIYWN/6LA+dgyaV4fF6U9++Re+GgGjF03vHJFqR1xYaosKKZYQ== - -expo-updates-interface@~0.8.0: - version "0.8.1" - resolved "https://registry.yarnpkg.com/expo-updates-interface/-/expo-updates-interface-0.8.1.tgz#baeeeb01a77439682432be83ba78bc2e00547c4e" - integrity sha512-1TPFCTQFHMZbltFGnxig3PbN/b6nO4T0RyL8XqdmYvQY0ElOCprZXQQ8vNDqeLYHgausG1lD4OyJwFzh2SNBSA== - -expo-updates@~0.15.6: - version "0.15.6" - resolved "https://registry.yarnpkg.com/expo-updates/-/expo-updates-0.15.6.tgz#99e3faa3e38312ebddb77afb697863fa1f1f6a03" - integrity sha512-g5BuCmWdyiLqFaVkVz+m7r6U7MHJrLKvqybs04H6ArMNpTEf6FhUwSzmnCyOkSSP35KFNkC/I0dYlgW3Vcf1sw== - dependencies: - "@expo/code-signing-certificates" "0.0.5" - "@expo/config" "~7.0.2" - "@expo/config-plugins" "~5.0.3" - "@expo/metro-config" "~0.5.0" - arg "4.1.0" - expo-eas-client "~0.4.0" - expo-manifests "~0.4.0" - expo-structured-headers "~3.0.0" - expo-updates-interface "~0.8.0" - fbemitter "^3.0.0" - resolve-from "^5.0.0" - uuid "^3.4.0" - expo@^47.0.7: version "47.0.14" resolved "https://registry.yarnpkg.com/expo/-/expo-47.0.14.tgz#3386d82d56f0827d1c5661aec5eae7d2b7dea43e" From 9a55555c2a283100ba0cc884d0115b9610990e87 Mon Sep 17 00:00:00 2001 From: Brent Vatne Date: Mon, 10 Jul 2023 13:30:11 -0700 Subject: [PATCH 2/3] Update build files --- build/integrations/bare.js | 2 +- build/integrations/bare.js.map | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/integrations/bare.js b/build/integrations/bare.js index dd79f2f..b55128d 100644 --- a/build/integrations/bare.js +++ b/build/integrations/bare.js @@ -30,7 +30,7 @@ exports.ExpoBareIntegration = void 0; const react_native_1 = require("react-native"); const expo_constants_1 = __importDefault(require("expo-constants")); const Device = __importStar(require("expo-device")); -const Updates = __importStar(require("expo-updates")); +const Updates = __importStar(require("./Updates")); const react_native_2 = require("@sentry/react-native"); const DEFAULT_TAGS = [ { diff --git a/build/integrations/bare.js.map b/build/integrations/bare.js.map index 6de0c4d..e5e7994 100644 --- a/build/integrations/bare.js.map +++ b/build/integrations/bare.js.map @@ -1 +1 @@ -{"version":3,"file":"bare.js","sourceRoot":"","sources":["../../src/integrations/bare.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAwC;AACxC,oEAAuC;AACvC,oDAAsC;AACtC,sDAAwC;AACxC,uDAM8B;AAG9B,MAAM,YAAY,GAAG;IACnB;QACE,OAAO,EAAE,oBAAoB;QAC7B,YAAY,EAAE,gBAAgB;KAC/B;IACD;QACE,OAAO,EAAE,YAAY;QACrB,YAAY,EAAE,SAAS;KACxB;IACD;QACE,OAAO,EAAE,kBAAkB;QAC3B,YAAY,EAAE,eAAe;KAC9B;IACD;QACE,OAAO,EAAE,gBAAgB;QACzB,YAAY,EAAE,YAAY;KAC3B;CACF,CAAC;AAEF,MAAa,mBAAmB;IAC9B,MAAM,CAAC,EAAE,GAAG,qBAAqB,CAAC;IAClC,IAAI,GAAG,mBAAmB,CAAC,EAAE,CAAC;IAE9B,SAAS;QACP,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAe,CAAC;QAEzC,IAAA,wBAAS,EAAC;YACR,QAAQ;YACR,eAAe,EAAE,MAAM,CAAC,eAAe;YACvC,UAAU,EAAE,wBAAS,CAAC,UAAU;SACjC,CAAC,CAAC;QAEH,IAAA,sBAAO,EAAC;YACN,QAAQ,EAAE,wBAAS,CAAC,SAAS;SAC9B,CAAC,CAAC;QAEH,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;YAChC,YAAY,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBAC3B,IAAI,QAAQ,CAAC,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CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;gBACjC,CAAC,CAAC,CAAC;aACJ;iBAAM;gBACL,mGAAmG;gBACnG,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;aAChC;QACH,CAAC,CAAC,CAAC;QAEH,IAAA,sCAAuB,EAAC,UAAU,KAAK,EAAE,KAAK;YAC5C,MAAM,IAAI,GAAG,IAAA,4BAAa,GAAE,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC;YAEjE,IAAI,IAAI,EAAE;gBACR,KAAK,CAAC,QAAQ,GAAG;oBACf,GAAG,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC;oBACzB,MAAM,EAAE;wBACN,SAAS,EAAE,CAAC,MAAM,CAAC,QAAQ;wBAC3B,KAAK,EAAE,MAAM,CAAC,SAAS,IAAI,SAAS;qBACrC;oBACD,EAAE,EAAE;wBACF,IAAI,EAAE,MAAM,CAAC,MAAM,IAAI,SAAS;wBAChC,OAAO,EAAE,MAAM,CAAC,SAAS,IAAI,SAAS;qBACvC;iBACF,CAAC;aACH;YAED,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;;AAnFH,kDAoFC","sourcesContent":["import { Platform } from 'react-native';\nimport Constants from 'expo-constants';\nimport * as Device from 'expo-device';\nimport * as Updates from 'expo-updates';\nimport {\n setExtras,\n setTags,\n getCurrentHub,\n setTag,\n addGlobalEventProcessor,\n} from '@sentry/react-native';\nimport { SeverityLevel } from '@sentry/types';\n\nconst DEFAULT_TAGS = [\n {\n tagName: 'expoReleaseChannel',\n manifestName: 'releaseChannel',\n },\n {\n tagName: 'appVersion',\n manifestName: 'version',\n },\n {\n tagName: 'appPublishedTime',\n manifestName: 'publishedTime',\n },\n {\n tagName: 'expoSdkVersion',\n manifestName: 'sdkVersion',\n },\n];\n\nexport class ExpoBareIntegration {\n static id = 'ExpoBareIntegration';\n name = ExpoBareIntegration.id;\n\n setupOnce() {\n const manifest = Updates.manifest as any;\n\n setExtras({\n manifest,\n deviceYearClass: Device.deviceYearClass,\n linkingUri: Constants.linkingUri,\n });\n\n setTags({\n deviceId: Constants.sessionId,\n });\n\n if (typeof manifest === 'object') {\n DEFAULT_TAGS.forEach((tag) => {\n if (manifest.hasOwnProperty(tag.manifestName)) {\n setTag(tag.tagName, manifest[tag.manifestName]);\n }\n });\n }\n\n const defaultHandler = ErrorUtils.getGlobalHandler();\n\n ErrorUtils.setGlobalHandler((error, isFatal) => {\n // Updates bundle names are not predictable in advance, so we replace them with the names\n // Sentry expects to be in the stacktrace.\n // The name of the sourcemap file in Sentry is different depending on whether it was uploaded\n // by the upload-sourcemaps script in this package (in which case it will have a revisionId)\n // or by the default @sentry/react-native script.\n if (typeof error.stack === 'string') {\n const sentryFilename = Platform.OS === 'android' ? 'index.android.bundle' : 'main.jsbundle';\n error.stack = error.stack.replace(\n /\\/(bundle\\-\\d+|[\\dabcdef]+\\.bundle)/g,\n `/${sentryFilename}`\n );\n }\n\n getCurrentHub().withScope((scope) => {\n if (isFatal) {\n scope.setLevel(\"fatal\" as SeverityLevel);\n }\n getCurrentHub().captureException(error, {\n originalException: error,\n });\n });\n\n const client = getCurrentHub().getClient();\n // If in dev, we call the default handler anyway and hope the error will be sent\n // Just for a better dev experience\n if (client && !__DEV__) {\n // @ts-ignore PR to add this to types: https://github.com/getsentry/sentry-javascript/pull/2669\n client.flush(client.getOptions().shutdownTimeout || 2000).then(() => {\n defaultHandler(error, isFatal);\n });\n } else {\n // If there is no client, something is fishy but we call the default handler anyway. Even if in dev\n defaultHandler(error, isFatal);\n }\n });\n\n addGlobalEventProcessor(function (event, _hint) {\n const that = getCurrentHub().getIntegration(ExpoBareIntegration);\n\n if (that) {\n event.contexts = {\n ...(event.contexts || {}),\n device: {\n simulator: !Device.isDevice,\n model: Device.modelName || undefined,\n },\n os: {\n name: Device.osName || undefined,\n version: Device.osVersion || undefined,\n },\n };\n }\n\n return event;\n });\n }\n}\n"]} \ No newline at end of file +{"version":3,"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AC,mBAAmB,CAAC,CAAC;YAEjE,IAAI,IAAI,EAAE;gBACR,KAAK,CAAC,QAAQ,GAAG;oBACf,GAAG,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC;oBACzB,MAAM,EAAE;wBACN,SAAS,EAAE,CAAC,MAAM,CAAC,QAAQ;wBAC3B,KAAK,EAAE,MAAM,CAAC,SAAS,IAAI,SAAS;qBACrC;oBACD,EAAE,EAAE;wBACF,IAAI,EAAE,MAAM,CAAC,MAAM,IAAI,SAAS;wBAChC,OAAO,EAAE,MAAM,CAAC,SAAS,IAAI,SAAS;qBACvC;iBACF,CAAC;aACH;YAED,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;;AAnFH,kDAoFC","sourcesContent":["import { Platform } from 'react-native';\nimport Constants from 'expo-constants';\nimport * as Device from 'expo-device';\nimport * as Updates from './Updates';\nimport {\n setExtras,\n setTags,\n getCurrentHub,\n setTag,\n addGlobalEventProcessor,\n} from '@sentry/react-native';\nimport { SeverityLevel } from '@sentry/types';\n\nconst DEFAULT_TAGS = [\n {\n tagName: 'expoReleaseChannel',\n manifestName: 'releaseChannel',\n },\n {\n tagName: 'appVersion',\n manifestName: 'version',\n },\n {\n tagName: 'appPublishedTime',\n manifestName: 'publishedTime',\n },\n {\n tagName: 'expoSdkVersion',\n manifestName: 'sdkVersion',\n },\n];\n\nexport class ExpoBareIntegration {\n static id = 'ExpoBareIntegration';\n name = ExpoBareIntegration.id;\n\n setupOnce() {\n const manifest = Updates.manifest as any;\n\n setExtras({\n manifest,\n deviceYearClass: Device.deviceYearClass,\n linkingUri: Constants.linkingUri,\n });\n\n setTags({\n deviceId: Constants.sessionId,\n });\n\n if (typeof manifest === 'object') {\n DEFAULT_TAGS.forEach((tag) => {\n if (manifest.hasOwnProperty(tag.manifestName)) {\n setTag(tag.tagName, manifest[tag.manifestName]);\n }\n });\n }\n\n const defaultHandler = ErrorUtils.getGlobalHandler();\n\n ErrorUtils.setGlobalHandler((error, isFatal) => {\n // Updates bundle names are not predictable in advance, so we replace them with the names\n // Sentry expects to be in the stacktrace.\n // The name of the sourcemap file in Sentry is different depending on whether it was uploaded\n // by the upload-sourcemaps script in this package (in which case it will have a revisionId)\n // or by the default @sentry/react-native script.\n if (typeof error.stack === 'string') {\n const sentryFilename = Platform.OS === 'android' ? 'index.android.bundle' : 'main.jsbundle';\n error.stack = error.stack.replace(\n /\\/(bundle\\-\\d+|[\\dabcdef]+\\.bundle)/g,\n `/${sentryFilename}`\n );\n }\n\n getCurrentHub().withScope((scope) => {\n if (isFatal) {\n scope.setLevel(\"fatal\" as SeverityLevel);\n }\n getCurrentHub().captureException(error, {\n originalException: error,\n });\n });\n\n const client = getCurrentHub().getClient();\n // If in dev, we call the default handler anyway and hope the error will be sent\n // Just for a better dev experience\n if (client && !__DEV__) {\n // @ts-ignore PR to add this to types: https://github.com/getsentry/sentry-javascript/pull/2669\n client.flush(client.getOptions().shutdownTimeout || 2000).then(() => {\n defaultHandler(error, isFatal);\n });\n } else {\n // If there is no client, something is fishy but we call the default handler anyway. Even if in dev\n defaultHandler(error, isFatal);\n }\n });\n\n addGlobalEventProcessor(function (event, _hint) {\n const that = getCurrentHub().getIntegration(ExpoBareIntegration);\n\n if (that) {\n event.contexts = {\n ...(event.contexts || {}),\n device: {\n simulator: !Device.isDevice,\n model: Device.modelName || undefined,\n },\n os: {\n name: Device.osName || undefined,\n version: Device.osVersion || undefined,\n },\n };\n }\n\n return event;\n });\n }\n}\n"]} \ No newline at end of file From 345bbf7a2d5cb2f31cca0955311f685b3e6b3897 Mon Sep 17 00:00:00 2001 From: kbrandwijk Date: Wed, 12 Jul 2023 01:31:34 +0200 Subject: [PATCH 3/3] docs: changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98082a3..febc314 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ### ๐Ÿ› Bug fixes +- Remove dependency on expo-updates ([#356](https://github.com/expo/sentry-expo/pull/356) by [@brentvatne](https://github.com/brentvatne)) - Create new options object on every init to avoid read only error when initializing multiple times ([#350](https://github.com/expo/sentry-expo/pull/350) by [@krystofwoldrich](https://github.com/krystofwoldrich)) ### ๐Ÿงน Chores