diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a6b6242..28701ba 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,8 +27,13 @@ jobs: ${{ runner.os }}-yarn- - name: Install dependencies run: yarn install --frozen-lockfile --check-files --ignore-scripts + - name: Install scripts dependencies + working-directory: ./scripts + run: yarn install --frozen-lockfile --check-files --ignore-scripts - name: Clean build run: rm -rf build plugin/build + - name: Bake version + run: yarn bake-version - name: Build package run: yarn build - name: Build up-to-date diff --git a/CHANGELOG.md b/CHANGELOG.md index 51d2833..bf8599b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ ### ๐Ÿงน Chores +- Add `sentry-expo` metadata to the Sentry clients. This will help with debugging issues related to the SDKs. + ## [6.1.1](https://github.com/expo/sentry-expo/releases/tag/v6.1.1) - 2023-03-16 ### ๐Ÿ› Bug fixes diff --git a/build/sentry.d.ts.map b/build/sentry.d.ts.map index fd0e08d..f6f9434 100644 --- a/build/sentry.d.ts.map +++ b/build/sentry.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"sentry.d.ts","sourceRoot":"","sources":["../src/sentry.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,uBAAuB,EAA+B,MAAM,SAAS,CAAC;AAK/E,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAC;AAwC/C,eAAO,MAAM,IAAI,aAAa,uBAAuB,SAiEpD,CAAC"} \ No newline at end of file +{"version":3,"file":"sentry.d.ts","sourceRoot":"","sources":["../src/sentry.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,uBAAuB,EAA+B,MAAM,SAAS,CAAC;AAW/E,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAC;AA0D/C,eAAO,MAAM,IAAI,aAAa,uBAAuB,SAiEpD,CAAC"} \ No newline at end of file diff --git a/build/sentry.js b/build/sentry.js index d3666cf..66fd1ba 100644 --- a/build/sentry.js +++ b/build/sentry.js @@ -32,8 +32,23 @@ const integrations_1 = require("@sentry/integrations"); const bare_1 = require("./integrations/bare"); const managed_1 = require("./integrations/managed"); const utils_1 = require("./utils"); +const version_1 = require("./version"); const react_native_2 = require("@sentry/react-native"); exports.Native = __importStar(require("@sentry/react-native")); +const defaultSdkInfo = { + name: 'sentry.javascript.react-native.expo', + packages: [ + { + name: version_1.SENTRY_EXPO_PACKAGE, + version: version_1.SENTRY_EXPO_VERSION, + }, + { + name: version_1.SENTRY_REACT_NATIVE_PACKAGE, + version: version_1.SENTRY_REACT_NATIVE_VERSION, + } + ], + version: version_1.SENTRY_EXPO_VERSION, +}; const MANIFEST = Updates.manifest; const IS_BARE_WORKFLOW = expo_constants_1.default.executionEnvironment === expo_constants_1.ExecutionEnvironment.Bare; const DEFAULT_OPTIONS = { @@ -41,6 +56,9 @@ const DEFAULT_OPTIONS = { release: getDefaultRelease(), dist: getDist(), ...(IS_BARE_WORKFLOW ? {} : { enableNative: false, enableNativeCrashHandling: false }), + _metadata: { + sdk: defaultSdkInfo, + }, }; /** * For embedded updates, the dist version needs to match what is set by the Sentry build script. diff --git a/build/sentry.js.map b/build/sentry.js.map index bf1639e..538ba69 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;AAE/E,uDAAwE;AAGxE,+DAA+C;AAE/C,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,O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aAAa;gBAChB,YAAY,EAAE,KAAK;gBACnB,yBAAyB,EAAE,KAAK;aACjC,CAAC,CAAC;SACJ;aAAM;YACL,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 } from '@sentry/types';\n\nimport { ExpoBareIntegration } from './integrations/bare';\nimport { ExpoManagedIntegration } from './integrations/managed';\nimport { SentryExpoNativeOptions, overrideDefaultIntegrations } from './utils';\n\nimport { init as initNative, Integrations } from '@sentry/react-native';\nimport { AppManifest } from 'expo-constants/build/Constants.types';\n\nexport * as Native from '@sentry/react-native';\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};\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,sDAAwC;AACxC,iEAAiE;AACjE,8DAAgD;AAChD,uDAAqD;AAGrD,8CAA0D;AAC1D,oDAAgE;AAChE,mCAA+E;AAC/E,uCAKmB;AAEnB,uDAAwE;AAGxE,+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,qCAA2B;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,CAAC;IACtF,SAAS,EAAE;QACT,GAAG,EAAE,cAAc;KACpB;CACF,CAAC;AAEF;;;GAGG;AACH,SAAS,OAAO;IACd,IAAI,OAAO,CAAC,gBAAgB,EAAE;QAC5B,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,kBAAkB,EAAE,CAAC;KACrF;SAAM;QACL,OAAO,OAAO,CAAC,QAAQ,CAAC;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AAC,YAAY,KAAK,UAAU,EAAE;QAC3D,mEAAmE;QACnE,IAAI,+BAA+B,GAAG,aAAa,CAAC,YAAY,CAAC;QACjE,MAAM,4BAA4B,GAAG,CAAC,YAA2B,EAAE,EAAE;YACnE,OAAO,+BAA+B,CACpC,IAAA,mCAA2B,EAAC,YAAY,EAAE,uBAAuB,CAAC,CACnE,CAAC;QACJ,CAAC,CAAC;QACF,aAAa,CAAC,YAAY,GAAG,4BAA4B,CAAC;KAC3D;SAAM;QACL,aAAa,CAAC,YAAY,GAAG,CAAC,GAAG,uBAAuB,CAAC,CAAC;KAC3D;IAED,IAAI,OAAO,IAAI,CAAC,aAAa,CAAC,uBAAuB,EAAE;QACrD,aAAa,CAAC,OAAO,GAAG,KAAK,CAAC;QAC9B,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,yBAAyB,CAAC,EAAE;YAC5D,OAAO,CAAC,GAAG,CACT,gHAAgH,CACjH,CAAC;SACH;KACF;IAED,IAAI;QACF,OAAO,IAAA,mBAAU,EAAC,EAAE,GAAG,aAAa,EAAE,CAAC,CAAC;KACzC;IAAC,OAAO,CAAC,EAAE;QACV,IAAI,gBAAgB,EAAE;YACpB,kFAAkF;YAClF,OAAO,CAAC,IAAI,CACV,iRAAiR,CAClR,CAAC;YACF,OAAO,IAAA,mBAAU,EAAC;gBAChB,GAAG,aAAa;gBAChB,YAAY,EAAE,KAAK;gBACnB,yBAAyB,EAAE,KAAK;aACjC,CAAC,CAAC;SACJ;aAAM;YACL,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 SENTRY_REACT_NATIVE_VERSION,\n} from './version';\n\nimport { init as initNative, Integrations } 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/build/sentry.web.d.ts.map b/build/sentry.web.d.ts.map index c7c7a73..c9bb912 100644 --- a/build/sentry.web.d.ts.map +++ b/build/sentry.web.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"sentry.web.d.ts","sourceRoot":"","sources":["../src/sentry.web.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/C,eAAO,MAAM,IAAI,aAAa,oBAAoB,SAKjD,CAAC"} \ No newline at end of file +{"version":3,"file":"sentry.web.d.ts","sourceRoot":"","sources":["../src/sentry.web.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAwB/C,eAAO,MAAM,IAAI,aAAa,oBAAoB,SAMjD,CAAC"} \ No newline at end of file diff --git a/build/sentry.web.js b/build/sentry.web.js index a2c792b..ff4d628 100644 --- a/build/sentry.web.js +++ b/build/sentry.web.js @@ -2,9 +2,25 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.init = void 0; const react_1 = require("@sentry/react"); +const version_1 = require("./version"); +const defaultSdkInfo = { + name: 'sentry.javascript.react.expo', + packages: [ + { + name: version_1.SENTRY_EXPO_PACKAGE, + version: version_1.SENTRY_EXPO_VERSION, + }, + { + name: version_1.SENTRY_REACT_PACKAGE, + version: version_1.SENTRY_REACT_VERSION, + } + ], + version: version_1.SENTRY_EXPO_VERSION, +}; const init = (options = {}) => { return (0, react_1.init)({ ...options, + _metadata: options._metadata || { sdk: defaultSdkInfo }, enabled: __DEV__ ? options.enableInExpoDevelopment || false : true, }); }; diff --git a/build/sentry.web.js.map b/build/sentry.web.js.map index f3067eb..e06a4b0 100644 --- a/build/sentry.web.js.map +++ b/build/sentry.web.js.map @@ -1 +1 @@ -{"version":3,"file":"sentry.web.js","sourceRoot":"","sources":["../src/sentry.web.ts"],"names":[],"mappings":";;;AAAA,yCAAoD;AAG7C,MAAM,IAAI,GAAG,CAAC,UAAgC,EAAE,EAAE,EAAE;IACzD,OAAO,IAAA,YAAW,EAAC;QACjB,GAAI,OAAgC;QACpC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,uBAAuB,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI;KACnE,CAAC,CAAC;AACL,CAAC,CAAC;AALW,QAAA,IAAI,QAKf","sourcesContent":["import { init as initBrowser } from '@sentry/react';\nimport { SentryExpoWebOptions } from './utils';\n\nexport const init = (options: SentryExpoWebOptions = {}) => {\n return initBrowser({\n ...(options as SentryExpoWebOptions),\n enabled: __DEV__ ? options.enableInExpoDevelopment || false : true,\n });\n};\n"]} \ No newline at end of file +{"version":3,"file":"sentry.web.js","sourceRoot":"","sources":["../src/sentry.web.ts"],"names":[],"mappings":";;;AAAA,yCAAoD;AAGpD,uCAKmB;AAEnB,MAAM,cAAc,GAAY;IAC9B,IAAI,EAAE,8BAA8B;IACpC,QAAQ,EAAE;QACR;YACE,IAAI,EAAE,6BAAmB;YACzB,OAAO,EAAE,6BAAmB;SAC7B;QACD;YACE,IAAI,EAAE,8BAAoB;YAC1B,OAAO,EAAE,8BAAoB;SAC9B;KACF;IACD,OAAO,EAAE,6BAAmB;CAC7B,CAAC;AAEK,MAAM,IAAI,GAAG,CAAC,UAAgC,EAAE,EAAE,EAAE;IACzD,OAAO,IAAA,YAAW,EAAC;QACjB,GAAI,OAAgC;QACpC,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,EAAE,GAAG,EAAE,cAAc,EAAE;QACvD,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,uBAAuB,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI;KACnE,CAAC,CAAC;AACL,CAAC,CAAC;AANW,QAAA,IAAI,QAMf","sourcesContent":["import { init as initBrowser } from '@sentry/react';\nimport { SentryExpoWebOptions } from './utils';\nimport { SdkInfo } from '@sentry/react-native';\nimport {\n SENTRY_EXPO_PACKAGE,\n SENTRY_EXPO_VERSION,\n SENTRY_REACT_PACKAGE, \n SENTRY_REACT_VERSION,\n} from './version';\n\nconst defaultSdkInfo: SdkInfo = {\n name: 'sentry.javascript.react.expo',\n packages: [\n {\n name: SENTRY_EXPO_PACKAGE,\n version: SENTRY_EXPO_VERSION,\n },\n {\n name: SENTRY_REACT_PACKAGE,\n version: SENTRY_REACT_VERSION,\n }\n ],\n version: SENTRY_EXPO_VERSION,\n};\n\nexport const init = (options: SentryExpoWebOptions = {}) => {\n return initBrowser({\n ...(options as SentryExpoWebOptions),\n _metadata: options._metadata || { sdk: defaultSdkInfo },\n enabled: __DEV__ ? options.enableInExpoDevelopment || false : true,\n });\n};\n"]} \ No newline at end of file diff --git a/build/version.d.ts b/build/version.d.ts new file mode 100644 index 0000000..3a85511 --- /dev/null +++ b/build/version.d.ts @@ -0,0 +1,8 @@ +import { SDK_VERSION as SENTRY_REACT_NATIVE_VERSION } from '@sentry/react-native'; +import { SDK_VERSION as SENTRY_REACT_VERSION } from '@sentry/react'; +export declare const SENTRY_EXPO_PACKAGE = "npm:sentry-expo"; +export declare const SENTRY_EXPO_VERSION = "6.1.1"; +export declare const SENTRY_REACT_NATIVE_PACKAGE = "npm:@sentry/react-native"; +export declare const SENTRY_REACT_PACKAGE = "npm:@sentry/react"; +export { SENTRY_REACT_NATIVE_VERSION, SENTRY_REACT_VERSION }; +//# sourceMappingURL=version.d.ts.map \ No newline at end of file diff --git a/build/version.d.ts.map b/build/version.d.ts.map new file mode 100644 index 0000000..61f7f08 --- /dev/null +++ b/build/version.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAE,WAAW,IAAI,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAEpE,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AACrD,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAE3C,eAAO,MAAM,2BAA2B,6BAA6B,CAAC;AACtE,eAAO,MAAM,oBAAoB,sBAAsB,CAAC;AACxD,OAAO,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,CAAC"} \ No newline at end of file diff --git a/build/version.js b/build/version.js new file mode 100644 index 0000000..6e9a94a --- /dev/null +++ b/build/version.js @@ -0,0 +1,12 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SENTRY_REACT_VERSION = exports.SENTRY_REACT_NATIVE_VERSION = exports.SENTRY_REACT_PACKAGE = exports.SENTRY_REACT_NATIVE_PACKAGE = exports.SENTRY_EXPO_VERSION = exports.SENTRY_EXPO_PACKAGE = void 0; +const react_native_1 = require("@sentry/react-native"); +Object.defineProperty(exports, "SENTRY_REACT_NATIVE_VERSION", { enumerable: true, get: function () { return react_native_1.SDK_VERSION; } }); +const react_1 = require("@sentry/react"); +Object.defineProperty(exports, "SENTRY_REACT_VERSION", { enumerable: true, get: function () { return react_1.SDK_VERSION; } }); +exports.SENTRY_EXPO_PACKAGE = 'npm:sentry-expo'; +exports.SENTRY_EXPO_VERSION = '6.1.1'; +exports.SENTRY_REACT_NATIVE_PACKAGE = 'npm:@sentry/react-native'; +exports.SENTRY_REACT_PACKAGE = 'npm:@sentry/react'; +//# sourceMappingURL=version.js.map \ No newline at end of file diff --git a/build/version.js.map b/build/version.js.map new file mode 100644 index 0000000..b807009 --- /dev/null +++ b/build/version.js.map @@ -0,0 +1 @@ +{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,uDAAkF;AAQzE,4GARe,0BAA2B,OAQf;AAPpC,yCAAoE;AAO9B,qGAPd,mBAAoB,OAOc;AAL7C,QAAA,mBAAmB,GAAG,iBAAiB,CAAC;AACxC,QAAA,mBAAmB,GAAG,OAAO,CAAC;AAE9B,QAAA,2BAA2B,GAAG,0BAA0B,CAAC;AACzD,QAAA,oBAAoB,GAAG,mBAAmB,CAAC","sourcesContent":["import { SDK_VERSION as SENTRY_REACT_NATIVE_VERSION } from '@sentry/react-native';\nimport { SDK_VERSION as SENTRY_REACT_VERSION } from '@sentry/react';\n\nexport const SENTRY_EXPO_PACKAGE = 'npm:sentry-expo';\nexport const SENTRY_EXPO_VERSION = '6.1.1';\n\nexport const SENTRY_REACT_NATIVE_PACKAGE = 'npm:@sentry/react-native';\nexport const SENTRY_REACT_PACKAGE = 'npm:@sentry/react';\nexport { SENTRY_REACT_NATIVE_VERSION, SENTRY_REACT_VERSION };\n"]} \ No newline at end of file diff --git a/package.json b/package.json index a931def..89031f9 100644 --- a/package.json +++ b/package.json @@ -11,12 +11,13 @@ "app.plugin.js" ], "scripts": { - "build": "expo-module build", + "build": "yarn bake-version && expo-module build", "clean": "expo-module clean", "test": "expo-module test", "prepare": "expo-module prepare", "prepublishOnly": "expo-module prepublishOnly", - "expo-module": "expo-module" + "expo-module": "expo-module", + "bake-version": "cd scripts; yarn bake-version; cd .." }, "license": "MIT", "keywords": [ diff --git a/scripts/package.json b/scripts/package.json index ea614e9..3d97cab 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -7,7 +7,8 @@ "changelog-entry": "ts-node-esm src/changelogEntry.ts", "release-changelog": "ts-node-esm src/releaseChangelog.ts", "update-local-plugin": "./src/updateLocalPlugin.sh", - "typecheck": "tsc" + "typecheck": "tsc", + "bake-version": "ts-node-esm src/bake-version.ts" }, "author": "Expo ", "license": "MIT", diff --git a/scripts/src/bake-version.ts b/scripts/src/bake-version.ts new file mode 100644 index 0000000..9fab74b --- /dev/null +++ b/scripts/src/bake-version.ts @@ -0,0 +1,37 @@ +import * as fs from 'fs'; +import * as path from 'path'; +import { fileURLToPath } from 'url'; +import { dirname } from 'path'; + +const __dirname = dirname(fileURLToPath(import.meta.url)); + +const PKG_JSON_PATH = path.join(__dirname, '../../package.json'); +const VERSION_TS_PATH = path.join(__dirname, '../../src/version.ts'); + +const PKG_JSON = fs.readFileSync(PKG_JSON_PATH).toString('utf8'); +const { name, version } = JSON.parse(PKG_JSON); + +if (typeof name !== 'string') { + throw new Error('package.json name is not a string'); +} +if (name.length === 0) { + throw new Error('package.json name is empty'); +} +if (typeof version !== 'string') { + throw new Error('package.json version is not a string'); +} +if (version.length === 0) { + throw new Error('package.json version is empty'); +} + +const versionTs = fs.readFileSync(VERSION_TS_PATH, 'utf8'); + +const newVersionTs = versionTs.replace( + /export const SENTRY_EXPO_VERSION = '[^']+';/, + `export const SENTRY_EXPO_VERSION = '${version}';` +).replace( + /export const SENTRY_EXPO_PACKAGE = '[^']+';/, + `export const SENTRY_EXPO_PACKAGE = 'npm:${name}';` +); + +fs.writeFileSync(VERSION_TS_PATH, newVersionTs); diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json index bd6b0f9..2899f9b 100644 --- a/scripts/tsconfig.json +++ b/scripts/tsconfig.json @@ -8,6 +8,7 @@ "target": "ES2020", "outDir": "build", "rootDir": "src", + "types": ["node"], "typeRoots": [ "../ts-declarations", "./node_modules/@types" diff --git a/src/sentry.ts b/src/sentry.ts index f288e54..e1f1d14 100644 --- a/src/sentry.ts +++ b/src/sentry.ts @@ -3,17 +3,38 @@ import * as Updates from 'expo-updates'; import Constants, { ExecutionEnvironment } from 'expo-constants'; import * as Application from 'expo-application'; import { RewriteFrames } from '@sentry/integrations'; -import { Integration } from '@sentry/types'; +import { Integration, SdkInfo } from '@sentry/types'; import { ExpoBareIntegration } from './integrations/bare'; import { ExpoManagedIntegration } from './integrations/managed'; import { SentryExpoNativeOptions, overrideDefaultIntegrations } from './utils'; +import { + SENTRY_EXPO_PACKAGE, + SENTRY_EXPO_VERSION, + SENTRY_REACT_NATIVE_PACKAGE, + SENTRY_REACT_NATIVE_VERSION, +} from './version'; import { init as initNative, Integrations } from '@sentry/react-native'; import { AppManifest } from 'expo-constants/build/Constants.types'; export * as Native from '@sentry/react-native'; +const defaultSdkInfo: SdkInfo = { + name: 'sentry.javascript.react-native.expo', + packages: [ + { + name: SENTRY_EXPO_PACKAGE, + version: SENTRY_EXPO_VERSION, + }, + { + name: SENTRY_REACT_NATIVE_PACKAGE, + version: SENTRY_REACT_NATIVE_VERSION, + } + ], + version: SENTRY_EXPO_VERSION, +}; + const MANIFEST = Updates.manifest as AppManifest; const IS_BARE_WORKFLOW = Constants.executionEnvironment === ExecutionEnvironment.Bare; @@ -22,6 +43,9 @@ const DEFAULT_OPTIONS = { release: getDefaultRelease(), dist: getDist(), ...(IS_BARE_WORKFLOW ? {} : { enableNative: false, enableNativeCrashHandling: false }), + _metadata: { + sdk: defaultSdkInfo, + }, }; /** diff --git a/src/sentry.web.ts b/src/sentry.web.ts index 00f8ed0..33a4334 100644 --- a/src/sentry.web.ts +++ b/src/sentry.web.ts @@ -1,9 +1,32 @@ import { init as initBrowser } from '@sentry/react'; import { SentryExpoWebOptions } from './utils'; +import { SdkInfo } from '@sentry/react-native'; +import { + SENTRY_EXPO_PACKAGE, + SENTRY_EXPO_VERSION, + SENTRY_REACT_PACKAGE, + SENTRY_REACT_VERSION, +} from './version'; + +const defaultSdkInfo: SdkInfo = { + name: 'sentry.javascript.react.expo', + packages: [ + { + name: SENTRY_EXPO_PACKAGE, + version: SENTRY_EXPO_VERSION, + }, + { + name: SENTRY_REACT_PACKAGE, + version: SENTRY_REACT_VERSION, + } + ], + version: SENTRY_EXPO_VERSION, +}; export const init = (options: SentryExpoWebOptions = {}) => { return initBrowser({ ...(options as SentryExpoWebOptions), + _metadata: options._metadata || { sdk: defaultSdkInfo }, enabled: __DEV__ ? options.enableInExpoDevelopment || false : true, }); }; diff --git a/src/version.ts b/src/version.ts new file mode 100644 index 0000000..8559f20 --- /dev/null +++ b/src/version.ts @@ -0,0 +1,9 @@ +import { SDK_VERSION as SENTRY_REACT_NATIVE_VERSION } from '@sentry/react-native'; +import { SDK_VERSION as SENTRY_REACT_VERSION } from '@sentry/react'; + +export const SENTRY_EXPO_PACKAGE = 'npm:sentry-expo'; +export const SENTRY_EXPO_VERSION = '6.1.1'; + +export const SENTRY_REACT_NATIVE_PACKAGE = 'npm:@sentry/react-native'; +export const SENTRY_REACT_PACKAGE = 'npm:@sentry/react'; +export { SENTRY_REACT_NATIVE_VERSION, SENTRY_REACT_VERSION };