@sentry/wizard 3.22.2 → 3.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/package.json +1 -1
- package/dist/src/nextjs/templates.js +2 -2
- package/dist/src/nextjs/templates.js.map +1 -1
- package/dist/src/react-native/javascript.js +1 -1
- package/dist/src/react-native/javascript.js.map +1 -1
- package/dist/src/react-native/metro.d.ts +6 -1
- package/dist/src/react-native/metro.js +166 -17
- package/dist/src/react-native/metro.js.map +1 -1
- package/dist/src/react-native/react-native-wizard.d.ts +1 -0
- package/dist/src/react-native/react-native-wizard.js +19 -20
- package/dist/src/react-native/react-native-wizard.js.map +1 -1
- package/dist/src/utils/ast-utils.d.ts +1 -1
- package/dist/src/utils/ast-utils.js +2 -2
- package/dist/src/utils/ast-utils.js.map +1 -1
- package/dist/src/utils/clack-utils.js +1 -1
- package/dist/src/utils/clack-utils.js.map +1 -1
- package/dist/test/react-native/javascript.test.js +1 -1
- package/dist/test/react-native/javascript.test.js.map +1 -1
- package/dist/test/react-native/metro.test.js +115 -0
- package/dist/test/react-native/metro.test.js.map +1 -1
- package/package.json +1 -1
- package/src/nextjs/templates.ts +2 -5
- package/src/react-native/javascript.ts +3 -0
- package/src/react-native/metro.ts +208 -18
- package/src/react-native/react-native-wizard.ts +24 -7
- package/src/utils/ast-utils.ts +2 -2
- package/src/utils/clack-utils.ts +1 -1
- package/test/react-native/javascript.test.ts +3 -0
- package/test/react-native/metro.test.ts +113 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.23.0
|
|
4
|
+
|
|
5
|
+
- feat(reactnative): Added comment to add spotlight in Sentry.init for React Native config (#548)
|
|
6
|
+
- feat(reactnative): Added `withSentryConfig` Metro patch (#575)
|
|
7
|
+
|
|
8
|
+
## 3.22.3
|
|
9
|
+
|
|
10
|
+
- feat(nextjs): Make example page resilient to
|
|
11
|
+
`typescript-eslint/no-floating-promises` (#568)
|
|
12
|
+
- fix: Remove quotes around auth token in .env files (#570)
|
|
13
|
+
- fix(nextjs): Remove `transpileClientSDK` from template (#571)
|
|
14
|
+
|
|
3
15
|
## 3.22.2
|
|
4
16
|
|
|
5
17
|
- feat(nextjs): Adjust Next.js wizard for usage with v8 SDK (#567)
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/wizard",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.23.0",
|
|
4
4
|
"homepage": "https://github.com/getsentry/sentry-wizard",
|
|
5
5
|
"repository": "https://github.com/getsentry/sentry-wizard",
|
|
6
6
|
"description": "Sentry wizard helping you to configure your project",
|
|
@@ -8,7 +8,7 @@ var chalk_1 = __importDefault(require("chalk"));
|
|
|
8
8
|
var clack_utils_1 = require("../utils/clack-utils");
|
|
9
9
|
function getWithSentryConfigOptionsTemplate(_a) {
|
|
10
10
|
var orgSlug = _a.orgSlug, projectSlug = _a.projectSlug, selfHosted = _a.selfHosted, tunnelRoute = _a.tunnelRoute, url = _a.url;
|
|
11
|
-
return "{\n // For all available options, see:\n // https://github.com/getsentry/sentry-webpack-plugin#options\n\n org: \"".concat(orgSlug, "\",\n project: \"").concat(projectSlug, "\",").concat(selfHosted ? "\n url: \"".concat(url, "\"") : '', "\n\n // Only print logs for uploading source maps in CI\n silent: !process.env.CI,\n\n // For all available options, see:\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/\n\n // Upload a larger set of source maps for prettier stack traces (increases build time)\n widenClientFileUpload: true,\n\n //
|
|
11
|
+
return "{\n // For all available options, see:\n // https://github.com/getsentry/sentry-webpack-plugin#options\n\n org: \"".concat(orgSlug, "\",\n project: \"").concat(projectSlug, "\",").concat(selfHosted ? "\n url: \"".concat(url, "\"") : '', "\n\n // Only print logs for uploading source maps in CI\n silent: !process.env.CI,\n\n // For all available options, see:\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/\n\n // Upload a larger set of source maps for prettier stack traces (increases build time)\n widenClientFileUpload: true,\n\n // ").concat(tunnelRoute ? 'Route' : 'Uncomment to route', " browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.\n // This can increase your server load as well as your hosting bill.\n // Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-\n // side errors will fail.\n ").concat(tunnelRoute ? '' : '// ', "tunnelRoute: \"/monitoring\",\n\n // Hides source maps from generated client bundles\n hideSourceMaps: true,\n\n // Automatically tree-shake Sentry logger statements to reduce bundle size\n disableLogger: true,\n\n // Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)\n // See the following for more information:\n // https://docs.sentry.io/product/crons/\n // https://vercel.com/docs/cron-jobs\n automaticVercelMonitors: true,\n }");
|
|
12
12
|
}
|
|
13
13
|
exports.getWithSentryConfigOptionsTemplate = getWithSentryConfigOptionsTemplate;
|
|
14
14
|
function getNextjsConfigCjsTemplate(withSentryConfigOptionsTemplate) {
|
|
@@ -50,7 +50,7 @@ function getSentryExamplePageContents(options) {
|
|
|
50
50
|
var issuesPageLink = options.selfHosted
|
|
51
51
|
? "".concat(options.url, "organizations/").concat(options.orgSlug, "/issues/?project=").concat(options.projectId)
|
|
52
52
|
: "https://".concat(options.orgSlug, ".sentry.io/issues/?project=").concat(options.projectId);
|
|
53
|
-
return "".concat(options.useClient ? '"use client";\n\n' : '', "import Head from \"next/head\";\nimport * as Sentry from \"@sentry/nextjs\";\n\nexport default function Page() {\n return (\n <div>\n <Head>\n <title>Sentry Onboarding</title>\n <meta name=\"description\" content=\"Test Sentry for your Next.js app!\" />\n </Head>\n\n <main\n style={{\n minHeight: \"100vh\",\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: \"center\",\n alignItems: \"center\",\n }}\n >\n <h1 style={{ fontSize: \"4rem\", margin: \"14px 0\" }}>\n <svg\n style={{\n height: \"1em\",\n }}\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 200 44\"\n >\n <path\n fill=\"currentColor\"\n d=\"M124.32,28.28,109.56,9.22h-3.68V34.77h3.73V15.19l15.18,19.58h3.26V9.22h-3.73ZM87.15,23.54h13.23V20.22H87.14V12.53h14.93V9.21H83.34V34.77h18.92V31.45H87.14ZM71.59,20.3h0C66.44,19.06,65,18.08,65,15.7c0-2.14,1.89-3.59,4.71-3.59a12.06,12.06,0,0,1,7.07,2.55l2-2.83a14.1,14.1,0,0,0-9-3c-5.06,0-8.59,3-8.59,7.27,0,4.6,3,6.19,8.46,7.52C74.51,24.74,76,25.78,76,28.11s-2,3.77-5.09,3.77a12.34,12.34,0,0,1-8.3-3.26l-2.25,2.69a15.94,15.94,0,0,0,10.42,3.85c5.48,0,9-2.95,9-7.51C79.75,23.79,77.47,21.72,71.59,20.3ZM195.7,9.22l-7.69,12-7.64-12h-4.46L186,24.67V34.78h3.84V24.55L200,9.22Zm-64.63,3.46h8.37v22.1h3.84V12.68h8.37V9.22H131.08ZM169.41,24.8c3.86-1.07,6-3.77,6-7.63,0-4.91-3.59-8-9.38-8H154.67V34.76h3.8V25.58h6.45l6.48,9.2h4.44l-7-9.82Zm-10.95-2.5V12.6h7.17c3.74,0,5.88,1.77,5.88,4.84s-2.29,4.86-5.84,4.86Z M29,2.26a4.67,4.67,0,0,0-8,0L14.42,13.53A32.21,32.21,0,0,1,32.17,40.19H27.55A27.68,27.68,0,0,0,12.09,17.47L6,28a15.92,15.92,0,0,1,9.23,12.17H4.62A.76.76,0,0,1,4,39.06l2.94-5a10.74,10.74,0,0,0-3.36-1.9l-2.91,5a4.54,4.54,0,0,0,1.69,6.24A4.66,4.66,0,0,0,4.62,44H19.15a19.4,19.4,0,0,0-8-17.31l2.31-4A23.87,23.87,0,0,1,23.76,44H36.07a35.88,35.88,0,0,0-16.41-31.8l4.67-8a.77.77,0,0,1,1.05-.27c.53.29,20.29,34.77,20.66,35.17a.76.76,0,0,1-.68,1.13H40.6q.09,1.91,0,3.81h4.78A4.59,4.59,0,0,0,50,39.43a4.49,4.49,0,0,0-.62-2.28Z\"\n ></path>\n </svg>\n </h1>\n\n <p>Get started by sending us a sample error:</p>\n <button\n type=\"button\"\n style={{\n padding: \"12px\",\n cursor: \"pointer\",\n backgroundColor: \"#AD6CAA\",\n borderRadius: \"4px\",\n border: \"none\",\n color: \"white\",\n fontSize: \"14px\",\n margin: \"18px\",\n }}\n onClick={() => {\n Sentry.startSpan({\n name: 'Example Frontend Span',\n op: 'test'\n }, async () => {\n const res = await fetch(\"/api/sentry-example-api\");\n if (!res.ok) {\n throw new Error(\"Sentry Example Frontend Error\");\n }\n });\n }}\n >\n Throw error!\n </button>\n\n <p>\n Next, look for the error on the{\" \"}\n <a href=\"").concat(issuesPageLink, "\">Issues Page</a>.\n </p>\n <p style={{ marginTop: \"24px\" }}>\n For more information, see{\" \"}\n <a href=\"https://docs.sentry.io/platforms/javascript/guides/nextjs/\">\n https://docs.sentry.io/platforms/javascript/guides/nextjs/\n </a>\n </p>\n </main>\n </div>\n );\n}\n");
|
|
53
|
+
return "".concat(options.useClient ? '"use client";\n\n' : '', "import Head from \"next/head\";\nimport * as Sentry from \"@sentry/nextjs\";\n\nexport default function Page() {\n return (\n <div>\n <Head>\n <title>Sentry Onboarding</title>\n <meta name=\"description\" content=\"Test Sentry for your Next.js app!\" />\n </Head>\n\n <main\n style={{\n minHeight: \"100vh\",\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: \"center\",\n alignItems: \"center\",\n }}\n >\n <h1 style={{ fontSize: \"4rem\", margin: \"14px 0\" }}>\n <svg\n style={{\n height: \"1em\",\n }}\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 200 44\"\n >\n <path\n fill=\"currentColor\"\n d=\"M124.32,28.28,109.56,9.22h-3.68V34.77h3.73V15.19l15.18,19.58h3.26V9.22h-3.73ZM87.15,23.54h13.23V20.22H87.14V12.53h14.93V9.21H83.34V34.77h18.92V31.45H87.14ZM71.59,20.3h0C66.44,19.06,65,18.08,65,15.7c0-2.14,1.89-3.59,4.71-3.59a12.06,12.06,0,0,1,7.07,2.55l2-2.83a14.1,14.1,0,0,0-9-3c-5.06,0-8.59,3-8.59,7.27,0,4.6,3,6.19,8.46,7.52C74.51,24.74,76,25.78,76,28.11s-2,3.77-5.09,3.77a12.34,12.34,0,0,1-8.3-3.26l-2.25,2.69a15.94,15.94,0,0,0,10.42,3.85c5.48,0,9-2.95,9-7.51C79.75,23.79,77.47,21.72,71.59,20.3ZM195.7,9.22l-7.69,12-7.64-12h-4.46L186,24.67V34.78h3.84V24.55L200,9.22Zm-64.63,3.46h8.37v22.1h3.84V12.68h8.37V9.22H131.08ZM169.41,24.8c3.86-1.07,6-3.77,6-7.63,0-4.91-3.59-8-9.38-8H154.67V34.76h3.8V25.58h6.45l6.48,9.2h4.44l-7-9.82Zm-10.95-2.5V12.6h7.17c3.74,0,5.88,1.77,5.88,4.84s-2.29,4.86-5.84,4.86Z M29,2.26a4.67,4.67,0,0,0-8,0L14.42,13.53A32.21,32.21,0,0,1,32.17,40.19H27.55A27.68,27.68,0,0,0,12.09,17.47L6,28a15.92,15.92,0,0,1,9.23,12.17H4.62A.76.76,0,0,1,4,39.06l2.94-5a10.74,10.74,0,0,0-3.36-1.9l-2.91,5a4.54,4.54,0,0,0,1.69,6.24A4.66,4.66,0,0,0,4.62,44H19.15a19.4,19.4,0,0,0-8-17.31l2.31-4A23.87,23.87,0,0,1,23.76,44H36.07a35.88,35.88,0,0,0-16.41-31.8l4.67-8a.77.77,0,0,1,1.05-.27c.53.29,20.29,34.77,20.66,35.17a.76.76,0,0,1-.68,1.13H40.6q.09,1.91,0,3.81h4.78A4.59,4.59,0,0,0,50,39.43a4.49,4.49,0,0,0-.62-2.28Z\"\n ></path>\n </svg>\n </h1>\n\n <p>Get started by sending us a sample error:</p>\n <button\n type=\"button\"\n style={{\n padding: \"12px\",\n cursor: \"pointer\",\n backgroundColor: \"#AD6CAA\",\n borderRadius: \"4px\",\n border: \"none\",\n color: \"white\",\n fontSize: \"14px\",\n margin: \"18px\",\n }}\n onClick={async () => {\n await Sentry.startSpan({\n name: 'Example Frontend Span',\n op: 'test'\n }, async () => {\n const res = await fetch(\"/api/sentry-example-api\");\n if (!res.ok) {\n throw new Error(\"Sentry Example Frontend Error\");\n }\n });\n }}\n >\n Throw error!\n </button>\n\n <p>\n Next, look for the error on the{\" \"}\n <a href=\"").concat(issuesPageLink, "\">Issues Page</a>.\n </p>\n <p style={{ marginTop: \"24px\" }}>\n For more information, see{\" \"}\n <a href=\"https://docs.sentry.io/platforms/javascript/guides/nextjs/\">\n https://docs.sentry.io/platforms/javascript/guides/nextjs/\n </a>\n </p>\n </main>\n </div>\n );\n}\n");
|
|
54
54
|
}
|
|
55
55
|
exports.getSentryExamplePageContents = getSentryExamplePageContents;
|
|
56
56
|
function getSentryExampleApiRoute() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/nextjs/templates.ts"],"names":[],"mappings":";;;;;;AAAA,gDAA0B;AAC1B,oDAAuD;AAUvD,SAAgB,kCAAkC,CAAC,EAMzB;QALxB,OAAO,aAAA,EACP,WAAW,iBAAA,EACX,UAAU,gBAAA,EACV,WAAW,iBAAA,EACX,GAAG,SAAA;IAEH,OAAO,qIAIG,OAAO,iCACH,WAAW,gBAAK,UAAU,CAAC,CAAC,CAAC,uBAAe,GAAG,OAAG,CAAC,CAAC,CAAC,EAAE,qdAejE,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,oBAAoB,qUAK5C,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,6gBAa1B,CAAC;AACL,CAAC;AA9CD,gFA8CC;AAED,SAAgB,0BAA0B,CACxC,+BAAuC;IAEvC,OAAO,gMAOL,+BAA+B,WAElC,CAAC;AACF,CAAC;AAbD,gEAaC;AAED,SAAgB,0BAA0B,CACxC,+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C,CAAC,IAAI,8GAMnD,2BAA2B,KAAK,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,gCAErD,CAAC,QACH,CAAC,CAAC;IACF,CAAC,CAAC,CAAC;AACL,CAAC;AAlBD,wFAkBC;AAED,SAAgB,+BAA+B;IAC7C,OAAO,yWAmBR,CAAC;AACF,CAAC;AArBD,0EAqBC;AAED,SAAgB,8BAA8B,CAAC,IAAa;IAC1D,IAAI,IAAI,EAAE;QACR,OAAO,6BAET,eAAK,CAAC,KAAK,CAAC,2CAA2C,CAAC,eACxD,eAAK,CAAC,KAAK,CAAC,iCAAiC,CAAC,eAC9C,eAAK,CAAC,KAAK,CAAC,oCAAoC,CAAC,qDAEb,eAAK,CAAC,KAAK,CAC3C,6BAA6B,CAC9B,oBACD,eAAK,CAAC,KAAK,CAAC,wEAED,CAAC,kIAUf,CAAC;KACC;SAAM;QACL,OAAO,6BAET,eAAK,CAAC,KAAK,CAAC,2CAA2C,CAAC,eACxD,eAAK,CAAC,KAAK,CAAC,iCAAiC,CAAC,eAC9C,eAAK,CAAC,KAAK,CAAC,oCAAoC,CAAC,qDAEb,eAAK,CAAC,KAAK,CAAC,WAAW,CAAC,oBAC1D,eAAK,CAAC,KAAK,CAAC,wEAED,CAAC,kIAUf,CAAC;KACC;AACH,CAAC;AA9CD,wEA8CC","sourcesContent":["import chalk from 'chalk';\nimport { makeCodeSnippet } from '../utils/clack-utils';\n\ntype WithSentryConfigOptions = {\n orgSlug: string;\n projectSlug: string;\n selfHosted: boolean;\n url: string;\n tunnelRoute: boolean;\n};\n\nexport function getWithSentryConfigOptionsTemplate({\n orgSlug,\n projectSlug,\n selfHosted,\n tunnelRoute,\n url,\n}: WithSentryConfigOptions): string {\n return `{\n // For all available options, see:\n // https://github.com/getsentry/sentry-webpack-plugin#options\n\n org: \"${orgSlug}\",\n project: \"${projectSlug}\",${selfHosted ? `\\n url: \"${url}\"` : ''}\n\n // Only print logs for uploading source maps in CI\n silent: !process.env.CI,\n\n // For all available options, see:\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/\n\n // Upload a larger set of source maps for prettier stack traces (increases build time)\n widenClientFileUpload: true,\n\n // Transpiles SDK to be compatible with IE11 (increases bundle size)\n transpileClientSDK: true,\n\n // ${\n tunnelRoute ? 'Route' : 'Uncomment to route'\n } browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.\n // This can increase your server load as well as your hosting bill.\n // Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-\n // side errors will fail.\n ${tunnelRoute ? '' : '// '}tunnelRoute: \"/monitoring\",\n\n // Hides source maps from generated client bundles\n hideSourceMaps: true,\n\n // Automatically tree-shake Sentry logger statements to reduce bundle size\n disableLogger: true,\n\n // Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)\n // See the following for more information:\n // https://docs.sentry.io/product/crons/\n // https://vercel.com/docs/cron-jobs\n automaticVercelMonitors: true,\n }`;\n}\n\nexport function getNextjsConfigCjsTemplate(\n withSentryConfigOptionsTemplate: string,\n): string {\n return `const { withSentryConfig } = require(\"@sentry/nextjs\");\n\n/** @type {import('next').NextConfig} */\nconst nextConfig = {};\n\nmodule.exports = withSentryConfig(\n nextConfig,\n ${withSentryConfigOptionsTemplate}\n);\n`;\n}\n\nexport function getNextjsConfigCjsAppendix(\n withSentryConfigOptionsTemplate: string,\n): string {\n return `\n\n// Injected content via Sentry wizard below\n\nconst { withSentryConfig } = require(\"@sentry/nextjs\");\n\nmodule.exports = withSentryConfig(\n module.exports,\n ${withSentryConfigOptionsTemplate}\n);\n`;\n}\n\nexport function getNextjsConfigEsmCopyPasteSnippet(\n withSentryConfigOptionsTemplate: string,\n): string {\n return `\n\n// next.config.mjs\nimport { withSentryConfig } from \"@sentry/nextjs\";\n\nexport default withSentryConfig(\n yourNextConfig,\n ${withSentryConfigOptionsTemplate}\n);\n`;\n}\n\nexport function getSentryConfigContents(\n dsn: string,\n config: 'server' | 'client' | 'edge',\n): string {\n let primer;\n if (config === 'server') {\n primer = `// This file configures the initialization of Sentry on the server.\n// The config you add here will be used whenever the server handles a request.\n// https://docs.sentry.io/platforms/javascript/guides/nextjs/`;\n } else if (config === 'client') {\n primer = `// This file configures the initialization of Sentry on the client.\n// The config you add here will be used whenever a users loads a page in their browser.\n// https://docs.sentry.io/platforms/javascript/guides/nextjs/`;\n } else if (config === 'edge') {\n primer = `// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on).\n// The config you add here will be used whenever one of the edge features is loaded.\n// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.\n// https://docs.sentry.io/platforms/javascript/guides/nextjs/`;\n }\n\n let additionalOptions = '';\n if (config === 'client') {\n additionalOptions = `\n\n replaysOnErrorSampleRate: 1.0,\n\n // This sets the sample rate to be 10%. You may want this to be 100% while\n // in development and sample at a lower rate in production\n replaysSessionSampleRate: 0.1,\n\n // You can remove this option if you're not planning to use the Sentry Session Replay feature:\n integrations: [\n Sentry.replayIntegration({\n // Additional Replay configuration goes in here, for example:\n maskAllText: true,\n blockAllMedia: true,\n }),\n ],`;\n }\n\n let spotlightOption = '';\n if (config === 'server') {\n spotlightOption = `\n\n // Uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: process.env.NODE_ENV === 'development',\n `;\n }\n\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n return `${primer}\n\nimport * as Sentry from \"@sentry/nextjs\";\n\nSentry.init({\n dsn: \"${dsn}\",\n\n // Adjust this value in production, or use tracesSampler for greater control\n tracesSampleRate: 1,\n\n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,${additionalOptions}${spotlightOption}\n});\n`;\n}\n\nexport function getSentryExamplePageContents(options: {\n selfHosted: boolean;\n url: string;\n orgSlug: string;\n projectId: string;\n useClient: boolean;\n}): string {\n const issuesPageLink = options.selfHosted\n ? `${options.url}organizations/${options.orgSlug}/issues/?project=${options.projectId}`\n : `https://${options.orgSlug}.sentry.io/issues/?project=${options.projectId}`;\n\n return `${\n options.useClient ? '\"use client\";\\n\\n' : ''\n }import Head from \"next/head\";\nimport * as Sentry from \"@sentry/nextjs\";\n\nexport default function Page() {\n return (\n <div>\n <Head>\n <title>Sentry Onboarding</title>\n <meta name=\"description\" content=\"Test Sentry for your Next.js app!\" />\n </Head>\n\n <main\n style={{\n minHeight: \"100vh\",\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: \"center\",\n alignItems: \"center\",\n }}\n >\n <h1 style={{ fontSize: \"4rem\", margin: \"14px 0\" }}>\n <svg\n style={{\n height: \"1em\",\n }}\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 200 44\"\n >\n <path\n fill=\"currentColor\"\n d=\"M124.32,28.28,109.56,9.22h-3.68V34.77h3.73V15.19l15.18,19.58h3.26V9.22h-3.73ZM87.15,23.54h13.23V20.22H87.14V12.53h14.93V9.21H83.34V34.77h18.92V31.45H87.14ZM71.59,20.3h0C66.44,19.06,65,18.08,65,15.7c0-2.14,1.89-3.59,4.71-3.59a12.06,12.06,0,0,1,7.07,2.55l2-2.83a14.1,14.1,0,0,0-9-3c-5.06,0-8.59,3-8.59,7.27,0,4.6,3,6.19,8.46,7.52C74.51,24.74,76,25.78,76,28.11s-2,3.77-5.09,3.77a12.34,12.34,0,0,1-8.3-3.26l-2.25,2.69a15.94,15.94,0,0,0,10.42,3.85c5.48,0,9-2.95,9-7.51C79.75,23.79,77.47,21.72,71.59,20.3ZM195.7,9.22l-7.69,12-7.64-12h-4.46L186,24.67V34.78h3.84V24.55L200,9.22Zm-64.63,3.46h8.37v22.1h3.84V12.68h8.37V9.22H131.08ZM169.41,24.8c3.86-1.07,6-3.77,6-7.63,0-4.91-3.59-8-9.38-8H154.67V34.76h3.8V25.58h6.45l6.48,9.2h4.44l-7-9.82Zm-10.95-2.5V12.6h7.17c3.74,0,5.88,1.77,5.88,4.84s-2.29,4.86-5.84,4.86Z M29,2.26a4.67,4.67,0,0,0-8,0L14.42,13.53A32.21,32.21,0,0,1,32.17,40.19H27.55A27.68,27.68,0,0,0,12.09,17.47L6,28a15.92,15.92,0,0,1,9.23,12.17H4.62A.76.76,0,0,1,4,39.06l2.94-5a10.74,10.74,0,0,0-3.36-1.9l-2.91,5a4.54,4.54,0,0,0,1.69,6.24A4.66,4.66,0,0,0,4.62,44H19.15a19.4,19.4,0,0,0-8-17.31l2.31-4A23.87,23.87,0,0,1,23.76,44H36.07a35.88,35.88,0,0,0-16.41-31.8l4.67-8a.77.77,0,0,1,1.05-.27c.53.29,20.29,34.77,20.66,35.17a.76.76,0,0,1-.68,1.13H40.6q.09,1.91,0,3.81h4.78A4.59,4.59,0,0,0,50,39.43a4.49,4.49,0,0,0-.62-2.28Z\"\n ></path>\n </svg>\n </h1>\n\n <p>Get started by sending us a sample error:</p>\n <button\n type=\"button\"\n style={{\n padding: \"12px\",\n cursor: \"pointer\",\n backgroundColor: \"#AD6CAA\",\n borderRadius: \"4px\",\n border: \"none\",\n color: \"white\",\n fontSize: \"14px\",\n margin: \"18px\",\n }}\n onClick={() => {\n Sentry.startSpan({\n name: 'Example Frontend Span',\n op: 'test'\n }, async () => {\n const res = await fetch(\"/api/sentry-example-api\");\n if (!res.ok) {\n throw new Error(\"Sentry Example Frontend Error\");\n }\n });\n }}\n >\n Throw error!\n </button>\n\n <p>\n Next, look for the error on the{\" \"}\n <a href=\"${issuesPageLink}\">Issues Page</a>.\n </p>\n <p style={{ marginTop: \"24px\" }}>\n For more information, see{\" \"}\n <a href=\"https://docs.sentry.io/platforms/javascript/guides/nextjs/\">\n https://docs.sentry.io/platforms/javascript/guides/nextjs/\n </a>\n </p>\n </main>\n </div>\n );\n}\n`;\n}\n\nexport function getSentryExampleApiRoute() {\n return `// A faulty API route to test Sentry's error monitoring\nexport default function handler(_req, res) {\n throw new Error(\"Sentry Example API Route Error\");\n res.status(200).json({ name: \"John Doe\" });\n}\n`;\n}\n\nexport function getSentryExampleAppDirApiRoute() {\n return `import { NextResponse } from \"next/server\";\n\nexport const dynamic = \"force-dynamic\";\n\n// A faulty API route to test Sentry's error monitoring\nexport function GET() {\n throw new Error(\"Sentry Example API Route Error\");\n return NextResponse.json({ data: \"Testing Sentry Error...\" });\n}\n`;\n}\n\nexport function getSentryDefaultUnderscoreErrorPage() {\n return `import * as Sentry from \"@sentry/nextjs\";\nimport Error from \"next/error\";\n\nconst CustomErrorComponent = (props) => {\n return <Error statusCode={props.statusCode} />;\n};\n\nCustomErrorComponent.getInitialProps = async (contextData) => {\n // In case this is running in a serverless function, await this in order to give Sentry\n // time to send the error before the lambda exits\n await Sentry.captureUnderscoreErrorException(contextData);\n\n // This will contain the status code of the response\n return Error.getInitialProps(contextData);\n};\n\nexport default CustomErrorComponent;\n`;\n}\n\nexport function getSimpleUnderscoreErrorCopyPasteSnippet() {\n return `\n${chalk.green(`import * as Sentry from '@sentry/nextjs';`)}\n\n${chalk.dim(\n '// Replace \"YourCustomErrorComponent\" with your custom error component!',\n)}\nYourCustomErrorComponent.getInitialProps = async (${chalk.green(\n `contextData`,\n )}) => {\n ${chalk.green('await Sentry.captureUnderscoreErrorException(contextData);')}\n\n ${chalk.dim('// ...other getInitialProps code')}\n};\n`;\n}\n\nexport function getFullUnderscoreErrorCopyPasteSnippet(isTs: boolean) {\n return `\nimport * as Sentry from '@sentry/nextjs';${\n isTs ? '\\nimport type { NextPageContext } from \"next\";' : ''\n }\n\n${chalk.dim(\n '// Replace \"YourCustomErrorComponent\" with your custom error component!',\n)}\nYourCustomErrorComponent.getInitialProps = async (contextData${\n isTs ? ': NextPageContext' : ''\n }) => {\n await Sentry.captureUnderscoreErrorException(contextData);\n};\n`;\n}\n\nexport function getInstrumentationHookContent(\n instrumentationHookLocation: 'src' | 'root',\n) {\n return `export async function register() {\n if (process.env.NEXT_RUNTIME === 'nodejs') {\n await import('${\n instrumentationHookLocation === 'root' ? '.' : '..'\n }/sentry.server.config');\n }\n\n if (process.env.NEXT_RUNTIME === 'edge') {\n await import('${\n instrumentationHookLocation === 'root' ? '.' : '..'\n }/sentry.edge.config');\n }\n}\n`;\n}\n\nexport function getInstrumentationHookCopyPasteSnippet(\n instrumentationHookLocation: 'src' | 'root',\n) {\n return makeCodeSnippet(true, (unchanged, plus) => {\n return unchanged(`export ${plus('async')} function register() {\n ${plus(`if (process.env.NEXT_RUNTIME === 'nodejs') {\n await import('${\n instrumentationHookLocation === 'root' ? '.' : '..'\n }/sentry.server.config');\n }\n\n if (process.env.NEXT_RUNTIME === 'edge') {\n await import('${\n instrumentationHookLocation === 'root' ? '.' : '..'\n }/sentry.edge.config');\n }`)}\n}`);\n });\n}\n\nexport function getSentryDefaultGlobalErrorPage() {\n return `\"use client\";\n\nimport * as Sentry from \"@sentry/nextjs\";\nimport Error from \"next/error\";\nimport { useEffect } from \"react\";\n\nexport default function GlobalError({ error }) {\n useEffect(() => {\n Sentry.captureException(error);\n }, [error]);\n\n return (\n <html>\n <body>\n <Error />\n </body>\n </html>\n );\n}\n`;\n}\n\nexport function getGlobalErrorCopyPasteSnippet(isTs: boolean) {\n if (isTs) {\n return `\"use client\";\n\n${chalk.green('import * as Sentry from \"@sentry/nextjs\";')}\n${chalk.green('import Error from \"next/error\";')}\n${chalk.green('import { useEffect } from \"react\";')}\n\nexport default function GlobalError(${chalk.green(\n '{ error }: { error: Error }',\n )}) {\n ${chalk.green(`useEffect(() => {\n Sentry.captureException(error);\n }, [error]);`)}\n\n return (\n <html>\n <body>\n {/* Your Error component here... */}\n </body>\n </html>\n );\n}\n`;\n } else {\n return `\"use client\";\n\n${chalk.green('import * as Sentry from \"@sentry/nextjs\";')}\n${chalk.green('import Error from \"next/error\";')}\n${chalk.green('import { useEffect } from \"react\";')}\n\nexport default function GlobalError(${chalk.green('{ error }')}) {\n ${chalk.green(`useEffect(() => {\n Sentry.captureException(error);\n }, [error]);`)}\n\n return (\n <html>\n <body>\n {/* Your Error component here... */}\n </body>\n </html>\n );\n}\n`;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"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eAAK,CAAC,KAAK,CAAC,iCAAiC,CAAC,eAC9C,eAAK,CAAC,KAAK,CAAC,oCAAoC,CAAC,qDAEb,eAAK,CAAC,KAAK,CAAC,WAAW,CAAC,oBAC1D,eAAK,CAAC,KAAK,CAAC,wEAED,CAAC,kIAUf,CAAC;KACC;AACH,CAAC;AA9CD,wEA8CC","sourcesContent":["import chalk from 'chalk';\nimport { makeCodeSnippet } from '../utils/clack-utils';\n\ntype WithSentryConfigOptions = {\n orgSlug: string;\n projectSlug: string;\n selfHosted: boolean;\n url: string;\n tunnelRoute: boolean;\n};\n\nexport function getWithSentryConfigOptionsTemplate({\n orgSlug,\n projectSlug,\n selfHosted,\n tunnelRoute,\n url,\n}: WithSentryConfigOptions): string {\n return `{\n // For all available options, see:\n // https://github.com/getsentry/sentry-webpack-plugin#options\n\n org: \"${orgSlug}\",\n project: \"${projectSlug}\",${selfHosted ? `\\n url: \"${url}\"` : ''}\n\n // Only print logs for uploading source maps in CI\n silent: !process.env.CI,\n\n // For all available options, see:\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/\n\n // Upload a larger set of source maps for prettier stack traces (increases build time)\n widenClientFileUpload: true,\n\n // ${\n tunnelRoute ? 'Route' : 'Uncomment to route'\n } browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.\n // This can increase your server load as well as your hosting bill.\n // Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-\n // side errors will fail.\n ${tunnelRoute ? '' : '// '}tunnelRoute: \"/monitoring\",\n\n // Hides source maps from generated client bundles\n hideSourceMaps: true,\n\n // Automatically tree-shake Sentry logger statements to reduce bundle size\n disableLogger: true,\n\n // Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)\n // See the following for more information:\n // https://docs.sentry.io/product/crons/\n // https://vercel.com/docs/cron-jobs\n automaticVercelMonitors: true,\n }`;\n}\n\nexport function getNextjsConfigCjsTemplate(\n withSentryConfigOptionsTemplate: string,\n): string {\n return `const { withSentryConfig } = require(\"@sentry/nextjs\");\n\n/** @type {import('next').NextConfig} */\nconst nextConfig = {};\n\nmodule.exports = withSentryConfig(\n nextConfig,\n ${withSentryConfigOptionsTemplate}\n);\n`;\n}\n\nexport function getNextjsConfigCjsAppendix(\n withSentryConfigOptionsTemplate: string,\n): string {\n return `\n\n// Injected content via Sentry wizard below\n\nconst { withSentryConfig } = require(\"@sentry/nextjs\");\n\nmodule.exports = withSentryConfig(\n module.exports,\n ${withSentryConfigOptionsTemplate}\n);\n`;\n}\n\nexport function getNextjsConfigEsmCopyPasteSnippet(\n withSentryConfigOptionsTemplate: string,\n): string {\n return `\n\n// next.config.mjs\nimport { withSentryConfig } from \"@sentry/nextjs\";\n\nexport default withSentryConfig(\n yourNextConfig,\n ${withSentryConfigOptionsTemplate}\n);\n`;\n}\n\nexport function getSentryConfigContents(\n dsn: string,\n config: 'server' | 'client' | 'edge',\n): string {\n let primer;\n if (config === 'server') {\n primer = `// This file configures the initialization of Sentry on the server.\n// The config you add here will be used whenever the server handles a request.\n// https://docs.sentry.io/platforms/javascript/guides/nextjs/`;\n } else if (config === 'client') {\n primer = `// This file configures the initialization of Sentry on the client.\n// The config you add here will be used whenever a users loads a page in their browser.\n// https://docs.sentry.io/platforms/javascript/guides/nextjs/`;\n } else if (config === 'edge') {\n primer = `// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on).\n// The config you add here will be used whenever one of the edge features is loaded.\n// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.\n// https://docs.sentry.io/platforms/javascript/guides/nextjs/`;\n }\n\n let additionalOptions = '';\n if (config === 'client') {\n additionalOptions = `\n\n replaysOnErrorSampleRate: 1.0,\n\n // This sets the sample rate to be 10%. You may want this to be 100% while\n // in development and sample at a lower rate in production\n replaysSessionSampleRate: 0.1,\n\n // You can remove this option if you're not planning to use the Sentry Session Replay feature:\n integrations: [\n Sentry.replayIntegration({\n // Additional Replay configuration goes in here, for example:\n maskAllText: true,\n blockAllMedia: true,\n }),\n ],`;\n }\n\n let spotlightOption = '';\n if (config === 'server') {\n spotlightOption = `\n\n // Uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: process.env.NODE_ENV === 'development',\n `;\n }\n\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n return `${primer}\n\nimport * as Sentry from \"@sentry/nextjs\";\n\nSentry.init({\n dsn: \"${dsn}\",\n\n // Adjust this value in production, or use tracesSampler for greater control\n tracesSampleRate: 1,\n\n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,${additionalOptions}${spotlightOption}\n});\n`;\n}\n\nexport function getSentryExamplePageContents(options: {\n selfHosted: boolean;\n url: string;\n orgSlug: string;\n projectId: string;\n useClient: boolean;\n}): string {\n const issuesPageLink = options.selfHosted\n ? `${options.url}organizations/${options.orgSlug}/issues/?project=${options.projectId}`\n : `https://${options.orgSlug}.sentry.io/issues/?project=${options.projectId}`;\n\n return `${\n options.useClient ? '\"use client\";\\n\\n' : ''\n }import Head from \"next/head\";\nimport * as Sentry from \"@sentry/nextjs\";\n\nexport default function Page() {\n return (\n <div>\n <Head>\n <title>Sentry Onboarding</title>\n <meta name=\"description\" content=\"Test Sentry for your Next.js app!\" />\n </Head>\n\n <main\n style={{\n minHeight: \"100vh\",\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: \"center\",\n alignItems: \"center\",\n }}\n >\n <h1 style={{ fontSize: \"4rem\", margin: \"14px 0\" }}>\n <svg\n style={{\n height: \"1em\",\n }}\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 200 44\"\n >\n <path\n fill=\"currentColor\"\n d=\"M124.32,28.28,109.56,9.22h-3.68V34.77h3.73V15.19l15.18,19.58h3.26V9.22h-3.73ZM87.15,23.54h13.23V20.22H87.14V12.53h14.93V9.21H83.34V34.77h18.92V31.45H87.14ZM71.59,20.3h0C66.44,19.06,65,18.08,65,15.7c0-2.14,1.89-3.59,4.71-3.59a12.06,12.06,0,0,1,7.07,2.55l2-2.83a14.1,14.1,0,0,0-9-3c-5.06,0-8.59,3-8.59,7.27,0,4.6,3,6.19,8.46,7.52C74.51,24.74,76,25.78,76,28.11s-2,3.77-5.09,3.77a12.34,12.34,0,0,1-8.3-3.26l-2.25,2.69a15.94,15.94,0,0,0,10.42,3.85c5.48,0,9-2.95,9-7.51C79.75,23.79,77.47,21.72,71.59,20.3ZM195.7,9.22l-7.69,12-7.64-12h-4.46L186,24.67V34.78h3.84V24.55L200,9.22Zm-64.63,3.46h8.37v22.1h3.84V12.68h8.37V9.22H131.08ZM169.41,24.8c3.86-1.07,6-3.77,6-7.63,0-4.91-3.59-8-9.38-8H154.67V34.76h3.8V25.58h6.45l6.48,9.2h4.44l-7-9.82Zm-10.95-2.5V12.6h7.17c3.74,0,5.88,1.77,5.88,4.84s-2.29,4.86-5.84,4.86Z M29,2.26a4.67,4.67,0,0,0-8,0L14.42,13.53A32.21,32.21,0,0,1,32.17,40.19H27.55A27.68,27.68,0,0,0,12.09,17.47L6,28a15.92,15.92,0,0,1,9.23,12.17H4.62A.76.76,0,0,1,4,39.06l2.94-5a10.74,10.74,0,0,0-3.36-1.9l-2.91,5a4.54,4.54,0,0,0,1.69,6.24A4.66,4.66,0,0,0,4.62,44H19.15a19.4,19.4,0,0,0-8-17.31l2.31-4A23.87,23.87,0,0,1,23.76,44H36.07a35.88,35.88,0,0,0-16.41-31.8l4.67-8a.77.77,0,0,1,1.05-.27c.53.29,20.29,34.77,20.66,35.17a.76.76,0,0,1-.68,1.13H40.6q.09,1.91,0,3.81h4.78A4.59,4.59,0,0,0,50,39.43a4.49,4.49,0,0,0-.62-2.28Z\"\n ></path>\n </svg>\n </h1>\n\n <p>Get started by sending us a sample error:</p>\n <button\n type=\"button\"\n style={{\n padding: \"12px\",\n cursor: \"pointer\",\n backgroundColor: \"#AD6CAA\",\n borderRadius: \"4px\",\n border: \"none\",\n color: \"white\",\n fontSize: \"14px\",\n margin: \"18px\",\n }}\n onClick={async () => {\n await Sentry.startSpan({\n name: 'Example Frontend Span',\n op: 'test'\n }, async () => {\n const res = await fetch(\"/api/sentry-example-api\");\n if (!res.ok) {\n throw new Error(\"Sentry Example Frontend Error\");\n }\n });\n }}\n >\n Throw error!\n </button>\n\n <p>\n Next, look for the error on the{\" \"}\n <a href=\"${issuesPageLink}\">Issues Page</a>.\n </p>\n <p style={{ marginTop: \"24px\" }}>\n For more information, see{\" \"}\n <a href=\"https://docs.sentry.io/platforms/javascript/guides/nextjs/\">\n https://docs.sentry.io/platforms/javascript/guides/nextjs/\n </a>\n </p>\n </main>\n </div>\n );\n}\n`;\n}\n\nexport function getSentryExampleApiRoute() {\n return `// A faulty API route to test Sentry's error monitoring\nexport default function handler(_req, res) {\n throw new Error(\"Sentry Example API Route Error\");\n res.status(200).json({ name: \"John Doe\" });\n}\n`;\n}\n\nexport function getSentryExampleAppDirApiRoute() {\n return `import { NextResponse } from \"next/server\";\n\nexport const dynamic = \"force-dynamic\";\n\n// A faulty API route to test Sentry's error monitoring\nexport function GET() {\n throw new Error(\"Sentry Example API Route Error\");\n return NextResponse.json({ data: \"Testing Sentry Error...\" });\n}\n`;\n}\n\nexport function getSentryDefaultUnderscoreErrorPage() {\n return `import * as Sentry from \"@sentry/nextjs\";\nimport Error from \"next/error\";\n\nconst CustomErrorComponent = (props) => {\n return <Error statusCode={props.statusCode} />;\n};\n\nCustomErrorComponent.getInitialProps = async (contextData) => {\n // In case this is running in a serverless function, await this in order to give Sentry\n // time to send the error before the lambda exits\n await Sentry.captureUnderscoreErrorException(contextData);\n\n // This will contain the status code of the response\n return Error.getInitialProps(contextData);\n};\n\nexport default CustomErrorComponent;\n`;\n}\n\nexport function getSimpleUnderscoreErrorCopyPasteSnippet() {\n return `\n${chalk.green(`import * as Sentry from '@sentry/nextjs';`)}\n\n${chalk.dim(\n '// Replace \"YourCustomErrorComponent\" with your custom error component!',\n)}\nYourCustomErrorComponent.getInitialProps = async (${chalk.green(\n `contextData`,\n )}) => {\n ${chalk.green('await Sentry.captureUnderscoreErrorException(contextData);')}\n\n ${chalk.dim('// ...other getInitialProps code')}\n};\n`;\n}\n\nexport function getFullUnderscoreErrorCopyPasteSnippet(isTs: boolean) {\n return `\nimport * as Sentry from '@sentry/nextjs';${\n isTs ? '\\nimport type { NextPageContext } from \"next\";' : ''\n }\n\n${chalk.dim(\n '// Replace \"YourCustomErrorComponent\" with your custom error component!',\n)}\nYourCustomErrorComponent.getInitialProps = async (contextData${\n isTs ? ': NextPageContext' : ''\n }) => {\n await Sentry.captureUnderscoreErrorException(contextData);\n};\n`;\n}\n\nexport function getInstrumentationHookContent(\n instrumentationHookLocation: 'src' | 'root',\n) {\n return `export async function register() {\n if (process.env.NEXT_RUNTIME === 'nodejs') {\n await import('${\n instrumentationHookLocation === 'root' ? '.' : '..'\n }/sentry.server.config');\n }\n\n if (process.env.NEXT_RUNTIME === 'edge') {\n await import('${\n instrumentationHookLocation === 'root' ? '.' : '..'\n }/sentry.edge.config');\n }\n}\n`;\n}\n\nexport function getInstrumentationHookCopyPasteSnippet(\n instrumentationHookLocation: 'src' | 'root',\n) {\n return makeCodeSnippet(true, (unchanged, plus) => {\n return unchanged(`export ${plus('async')} function register() {\n ${plus(`if (process.env.NEXT_RUNTIME === 'nodejs') {\n await import('${\n instrumentationHookLocation === 'root' ? '.' : '..'\n }/sentry.server.config');\n }\n\n if (process.env.NEXT_RUNTIME === 'edge') {\n await import('${\n instrumentationHookLocation === 'root' ? '.' : '..'\n }/sentry.edge.config');\n }`)}\n}`);\n });\n}\n\nexport function getSentryDefaultGlobalErrorPage() {\n return `\"use client\";\n\nimport * as Sentry from \"@sentry/nextjs\";\nimport Error from \"next/error\";\nimport { useEffect } from \"react\";\n\nexport default function GlobalError({ error }) {\n useEffect(() => {\n Sentry.captureException(error);\n }, [error]);\n\n return (\n <html>\n <body>\n <Error />\n </body>\n </html>\n );\n}\n`;\n}\n\nexport function getGlobalErrorCopyPasteSnippet(isTs: boolean) {\n if (isTs) {\n return `\"use client\";\n\n${chalk.green('import * as Sentry from \"@sentry/nextjs\";')}\n${chalk.green('import Error from \"next/error\";')}\n${chalk.green('import { useEffect } from \"react\";')}\n\nexport default function GlobalError(${chalk.green(\n '{ error }: { error: Error }',\n )}) {\n ${chalk.green(`useEffect(() => {\n Sentry.captureException(error);\n }, [error]);`)}\n\n return (\n <html>\n <body>\n {/* Your Error component here... */}\n </body>\n </html>\n );\n}\n`;\n } else {\n return `\"use client\";\n\n${chalk.green('import * as Sentry from \"@sentry/nextjs\";')}\n${chalk.green('import Error from \"next/error\";')}\n${chalk.green('import { useEffect } from \"react\";')}\n\nexport default function GlobalError(${chalk.green('{ error }')}) {\n ${chalk.green(`useEffect(() => {\n Sentry.captureException(error);\n }, [error]);`)}\n\n return (\n <html>\n <body>\n {/* Your Error component here... */}\n </body>\n </html>\n );\n}\n`;\n }\n}\n"]}
|
|
@@ -19,7 +19,7 @@ function getSentryInitColoredCodeSnippet(dsn) {
|
|
|
19
19
|
}
|
|
20
20
|
exports.getSentryInitColoredCodeSnippet = getSentryInitColoredCodeSnippet;
|
|
21
21
|
function getSentryInitPlainTextSnippet(dsn) {
|
|
22
|
-
return "import * as Sentry from '@sentry/react-native';\n\nSentry.init({\n dsn: '".concat(dsn, "',\n});");
|
|
22
|
+
return "import * as Sentry from '@sentry/react-native';\n\nSentry.init({\n dsn: '".concat(dsn, "',\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // enableSpotlight: __DEV__,\n});");
|
|
23
23
|
}
|
|
24
24
|
exports.getSentryInitPlainTextSnippet = getSentryInitPlainTextSnippet;
|
|
25
25
|
//# sourceMappingURL=javascript.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"javascript.js","sourceRoot":"","sources":["../../../src/react-native/javascript.ts"],"names":[],"mappings":";;;AAAA,oDAAuD;AAEvD,SAAgB,0BAA0B,CACxC,EAAU,EACV,EAAwB;QAAtB,GAAG,SAAA;IAEL,OAAO,EAAE,CAAC,OAAO,CACf,6BAA6B,EAC7B,UAAC,KAAa,IAAK,OAAA,UAAG,KAAK,eAC7B,6BAA6B,CAAC,GAAG,CAAC,CAAE,EADf,CACe,CACnC,CAAC;AACJ,CAAC;AATD,gEASC;AAED,SAAgB,gCAAgC,CAC9C,EAAU,EACV,EAA8C;QAA5C,cAAc,oBAAA;IAEhB,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;AACpC,CAAC;AALD,4EAKC;AAED,SAAgB,+BAA+B,CAAC,GAAW;IACzD,OAAO,IAAA,6BAAe,EAAC,IAAI,EAAE,UAAC,UAAU,EAAE,IAAI,EAAE,MAAM;QACpD,OAAO,IAAI,CAAC,6BAA6B,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC;AAJD,0EAIC;AAED,SAAgB,6BAA6B,CAAC,GAAW;IACvD,OAAO,oFAGC,GAAG,
|
|
1
|
+
{"version":3,"file":"javascript.js","sourceRoot":"","sources":["../../../src/react-native/javascript.ts"],"names":[],"mappings":";;;AAAA,oDAAuD;AAEvD,SAAgB,0BAA0B,CACxC,EAAU,EACV,EAAwB;QAAtB,GAAG,SAAA;IAEL,OAAO,EAAE,CAAC,OAAO,CACf,6BAA6B,EAC7B,UAAC,KAAa,IAAK,OAAA,UAAG,KAAK,eAC7B,6BAA6B,CAAC,GAAG,CAAC,CAAE,EADf,CACe,CACnC,CAAC;AACJ,CAAC;AATD,gEASC;AAED,SAAgB,gCAAgC,CAC9C,EAAU,EACV,EAA8C;QAA5C,cAAc,oBAAA;IAEhB,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;AACpC,CAAC;AALD,4EAKC;AAED,SAAgB,+BAA+B,CAAC,GAAW;IACzD,OAAO,IAAA,6BAAe,EAAC,IAAI,EAAE,UAAC,UAAU,EAAE,IAAI,EAAE,MAAM;QACpD,OAAO,IAAI,CAAC,6BAA6B,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC;AAJD,0EAIC;AAED,SAAgB,6BAA6B,CAAC,GAAW;IACvD,OAAO,oFAGC,GAAG,2HAIT,CAAC;AACL,CAAC;AATD,sEASC","sourcesContent":["import { makeCodeSnippet } from '../utils/clack-utils';\n\nexport function addSentryInitWithSdkImport(\n js: string,\n { dsn }: { dsn: string },\n): string {\n return js.replace(\n /^([^]*)(import\\s+[^;]*?;$)/m,\n (match: string) => `${match}\n${getSentryInitPlainTextSnippet(dsn)}`,\n );\n}\n\nexport function doesJsCodeIncludeSdkSentryImport(\n js: string,\n { sdkPackageName }: { sdkPackageName: string },\n): boolean {\n return !!js.match(sdkPackageName);\n}\n\nexport function getSentryInitColoredCodeSnippet(dsn: string) {\n return makeCodeSnippet(true, (_unchanged, plus, _minus) => {\n return plus(getSentryInitPlainTextSnippet(dsn));\n });\n}\n\nexport function getSentryInitPlainTextSnippet(dsn: string) {\n return `import * as Sentry from '@sentry/react-native';\n\nSentry.init({\n dsn: '${dsn}',\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // enableSpotlight: __DEV__,\n});`;\n}\n"]}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
+
import { ProxifiedModule } from 'magicast';
|
|
1
2
|
import * as recast from 'recast';
|
|
2
3
|
import x = recast.types;
|
|
3
4
|
import t = x.namedTypes;
|
|
4
|
-
export declare function
|
|
5
|
+
export declare function patchMetroWithSentryConfig(): Promise<void>;
|
|
6
|
+
export declare function patchMetroWithSentryConfigInMemory(mod: ProxifiedModule, showInstructions: () => Promise<void>): Promise<boolean>;
|
|
7
|
+
export declare function patchMetroConfigWithSentrySerializer(): Promise<void>;
|
|
5
8
|
export declare function unPatchMetroConfig(): Promise<void>;
|
|
6
9
|
export declare function removeSentrySerializerFromMetroConfig(program: t.Program): boolean;
|
|
7
10
|
export declare function removeSentryRequire(program: t.Program): boolean;
|
|
8
11
|
export declare function addSentrySerializerToMetroConfig(configObj: t.ObjectExpression): boolean;
|
|
9
12
|
export declare function addSentrySerializerRequireToMetroConfig(program: t.Program): boolean;
|
|
13
|
+
export declare function addSentryMetroRequireToMetroConfig(program: t.Program): boolean;
|
|
10
14
|
/**
|
|
11
15
|
* Returns value from `module.exports = value` or `const config = value`
|
|
12
16
|
*/
|
|
13
17
|
export declare function getMetroConfigObject(program: t.Program): t.ObjectExpression | undefined;
|
|
18
|
+
export declare function getModuleExportsAssignmentRight(program: t.Program): t.Identifier | t.CallExpression | t.ObjectExpression | undefined;
|
|
@@ -62,7 +62,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
62
62
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
63
63
|
};
|
|
64
64
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
|
-
exports.getMetroConfigObject = exports.addSentrySerializerRequireToMetroConfig = exports.addSentrySerializerToMetroConfig = exports.removeSentryRequire = exports.removeSentrySerializerFromMetroConfig = exports.unPatchMetroConfig = exports.
|
|
65
|
+
exports.getModuleExportsAssignmentRight = exports.getMetroConfigObject = exports.addSentryMetroRequireToMetroConfig = exports.addSentrySerializerRequireToMetroConfig = exports.addSentrySerializerToMetroConfig = exports.removeSentryRequire = exports.removeSentrySerializerFromMetroConfig = exports.unPatchMetroConfig = exports.patchMetroConfigWithSentrySerializer = exports.patchMetroWithSentryConfigInMemory = exports.patchMetroWithSentryConfig = void 0;
|
|
66
66
|
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
67
67
|
var clack = __importStar(require("@clack/prompts"));
|
|
68
68
|
// @ts-ignore - magicast is ESM and TS complains about that. It works though
|
|
@@ -75,7 +75,88 @@ var recast = __importStar(require("recast"));
|
|
|
75
75
|
var chalk_1 = __importDefault(require("chalk"));
|
|
76
76
|
var b = recast.types.builders;
|
|
77
77
|
var metroConfigPath = 'metro.config.js';
|
|
78
|
-
function
|
|
78
|
+
function patchMetroWithSentryConfig() {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
80
|
+
var mod, showInstructions, success, saved;
|
|
81
|
+
return __generator(this, function (_a) {
|
|
82
|
+
switch (_a.label) {
|
|
83
|
+
case 0: return [4 /*yield*/, parseMetroConfig()];
|
|
84
|
+
case 1:
|
|
85
|
+
mod = _a.sent();
|
|
86
|
+
showInstructions = function () {
|
|
87
|
+
return (0, clack_utils_1.showCopyPasteInstructions)(metroConfigPath, getMetroWithSentryConfigSnippet(true));
|
|
88
|
+
};
|
|
89
|
+
return [4 /*yield*/, patchMetroWithSentryConfigInMemory(mod, showInstructions)];
|
|
90
|
+
case 2:
|
|
91
|
+
success = _a.sent();
|
|
92
|
+
if (!success) {
|
|
93
|
+
return [2 /*return*/];
|
|
94
|
+
}
|
|
95
|
+
return [4 /*yield*/, writeMetroConfig(mod)];
|
|
96
|
+
case 3:
|
|
97
|
+
saved = _a.sent();
|
|
98
|
+
if (!saved) return [3 /*break*/, 4];
|
|
99
|
+
clack.log.success(chalk_1.default.green("".concat(chalk_1.default.cyan(metroConfigPath), " changes saved.")));
|
|
100
|
+
return [3 /*break*/, 6];
|
|
101
|
+
case 4:
|
|
102
|
+
clack.log.warn("Could not save changes to ".concat(chalk_1.default.cyan(metroConfigPath), ", please follow the manual steps."));
|
|
103
|
+
return [4 /*yield*/, showInstructions()];
|
|
104
|
+
case 5: return [2 /*return*/, _a.sent()];
|
|
105
|
+
case 6: return [2 /*return*/];
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
exports.patchMetroWithSentryConfig = patchMetroWithSentryConfig;
|
|
111
|
+
function patchMetroWithSentryConfigInMemory(mod, showInstructions) {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
113
|
+
var shouldContinue, configExpression, wrappedConfig, replacedModuleExportsRight, addedSentryMetroImport;
|
|
114
|
+
return __generator(this, function (_a) {
|
|
115
|
+
switch (_a.label) {
|
|
116
|
+
case 0:
|
|
117
|
+
if (!(0, ast_utils_1.hasSentryContent)(mod.$ast)) return [3 /*break*/, 3];
|
|
118
|
+
return [4 /*yield*/, confirmPathMetroConfig()];
|
|
119
|
+
case 1:
|
|
120
|
+
shouldContinue = _a.sent();
|
|
121
|
+
if (!!shouldContinue) return [3 /*break*/, 3];
|
|
122
|
+
return [4 /*yield*/, showInstructions()];
|
|
123
|
+
case 2:
|
|
124
|
+
_a.sent();
|
|
125
|
+
return [2 /*return*/, false];
|
|
126
|
+
case 3:
|
|
127
|
+
configExpression = getModuleExportsAssignmentRight(mod.$ast);
|
|
128
|
+
if (!!configExpression) return [3 /*break*/, 5];
|
|
129
|
+
clack.log.warn('Could not find Metro config, please follow the manual steps.');
|
|
130
|
+
return [4 /*yield*/, showInstructions()];
|
|
131
|
+
case 4:
|
|
132
|
+
_a.sent();
|
|
133
|
+
return [2 /*return*/, false];
|
|
134
|
+
case 5:
|
|
135
|
+
wrappedConfig = wrapWithSentryConfig(configExpression);
|
|
136
|
+
replacedModuleExportsRight = replaceModuleExportsRight(mod.$ast, wrappedConfig);
|
|
137
|
+
if (!!replacedModuleExportsRight) return [3 /*break*/, 7];
|
|
138
|
+
clack.log.warn('Could not automatically wrap the config export, please follow the manual steps.');
|
|
139
|
+
return [4 /*yield*/, showInstructions()];
|
|
140
|
+
case 6:
|
|
141
|
+
_a.sent();
|
|
142
|
+
return [2 /*return*/, false];
|
|
143
|
+
case 7:
|
|
144
|
+
addedSentryMetroImport = addSentryMetroRequireToMetroConfig(mod.$ast);
|
|
145
|
+
if (!!addedSentryMetroImport) return [3 /*break*/, 9];
|
|
146
|
+
clack.log.warn('Could not add `@sentry/react-native/metro` import to Metro config, please follow the manual steps.');
|
|
147
|
+
return [4 /*yield*/, showInstructions()];
|
|
148
|
+
case 8:
|
|
149
|
+
_a.sent();
|
|
150
|
+
return [2 /*return*/, false];
|
|
151
|
+
case 9:
|
|
152
|
+
clack.log.success("Added Sentry Metro plugin to ".concat(chalk_1.default.cyan(metroConfigPath), "."));
|
|
153
|
+
return [2 /*return*/, true];
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
exports.patchMetroWithSentryConfigInMemory = patchMetroWithSentryConfigInMemory;
|
|
159
|
+
function patchMetroConfigWithSentrySerializer() {
|
|
79
160
|
return __awaiter(this, void 0, void 0, function () {
|
|
80
161
|
var mod, showInstructions, shouldContinue, configObj, addedSentrySerializer, addedSentrySerializerImport, saved;
|
|
81
162
|
return __generator(this, function (_a) {
|
|
@@ -84,7 +165,7 @@ function patchMetroConfig() {
|
|
|
84
165
|
case 1:
|
|
85
166
|
mod = _a.sent();
|
|
86
167
|
showInstructions = function () {
|
|
87
|
-
return (0, clack_utils_1.showCopyPasteInstructions)(metroConfigPath,
|
|
168
|
+
return (0, clack_utils_1.showCopyPasteInstructions)(metroConfigPath, getMetroSentrySerializerSnippet(true));
|
|
88
169
|
};
|
|
89
170
|
if (!(0, ast_utils_1.hasSentryContent)(mod.$ast)) return [3 /*break*/, 4];
|
|
90
171
|
return [4 /*yield*/, confirmPathMetroConfig()];
|
|
@@ -127,7 +208,7 @@ function patchMetroConfig() {
|
|
|
127
208
|
});
|
|
128
209
|
});
|
|
129
210
|
}
|
|
130
|
-
exports.
|
|
211
|
+
exports.patchMetroConfigWithSentrySerializer = patchMetroConfigWithSentrySerializer;
|
|
131
212
|
function unPatchMetroConfig() {
|
|
132
213
|
return __awaiter(this, void 0, void 0, function () {
|
|
133
214
|
var mod, removedAtLeastOneRequire, removedSerializerConfig, saved;
|
|
@@ -295,12 +376,41 @@ function addSentrySerializerRequireToMetroConfig(program) {
|
|
|
295
376
|
program.body.splice(lastRequireIndex + 1, 0, sentrySerializerRequire);
|
|
296
377
|
}
|
|
297
378
|
else {
|
|
298
|
-
// insert at the
|
|
299
|
-
program.body.
|
|
379
|
+
// insert at the beginning
|
|
380
|
+
program.body.unshift(sentrySerializerRequire);
|
|
300
381
|
}
|
|
301
382
|
return true;
|
|
302
383
|
}
|
|
303
384
|
exports.addSentrySerializerRequireToMetroConfig = addSentrySerializerRequireToMetroConfig;
|
|
385
|
+
function addSentryMetroRequireToMetroConfig(program) {
|
|
386
|
+
var lastRequireIndex = (0, ast_utils_1.getLastRequireIndex)(program);
|
|
387
|
+
var sentryMetroRequire = createSentryMetroRequire();
|
|
388
|
+
var sentryImportIndex = lastRequireIndex + 1;
|
|
389
|
+
if (sentryImportIndex < program.body.length) {
|
|
390
|
+
// insert after last require
|
|
391
|
+
program.body.splice(lastRequireIndex + 1, 0, sentryMetroRequire);
|
|
392
|
+
}
|
|
393
|
+
else {
|
|
394
|
+
// insert at the beginning
|
|
395
|
+
program.body.unshift(sentryMetroRequire);
|
|
396
|
+
}
|
|
397
|
+
return true;
|
|
398
|
+
}
|
|
399
|
+
exports.addSentryMetroRequireToMetroConfig = addSentryMetroRequireToMetroConfig;
|
|
400
|
+
function wrapWithSentryConfig(configObj) {
|
|
401
|
+
return b.callExpression(b.identifier('withSentryConfig'), [configObj]);
|
|
402
|
+
}
|
|
403
|
+
function replaceModuleExportsRight(program, wrappedConfig) {
|
|
404
|
+
var moduleExports = getModuleExports(program);
|
|
405
|
+
if (!moduleExports) {
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
if (moduleExports.expression.type === 'AssignmentExpression') {
|
|
409
|
+
moduleExports.expression.right = wrappedConfig;
|
|
410
|
+
return true;
|
|
411
|
+
}
|
|
412
|
+
return false;
|
|
413
|
+
}
|
|
304
414
|
/**
|
|
305
415
|
* Creates const {createSentryMetroSerializer} = require('@sentry/react-native/dist/js/tools/sentryMetroSerializer');
|
|
306
416
|
*/
|
|
@@ -317,6 +427,22 @@ function createSentrySerializerRequire() {
|
|
|
317
427
|
])),
|
|
318
428
|
]);
|
|
319
429
|
}
|
|
430
|
+
/**
|
|
431
|
+
* Creates const {withSentryConfig} = require('@sentry/react-native/metro');
|
|
432
|
+
*/
|
|
433
|
+
function createSentryMetroRequire() {
|
|
434
|
+
return b.variableDeclaration('const', [
|
|
435
|
+
b.variableDeclarator(b.objectPattern([
|
|
436
|
+
b.objectProperty.from({
|
|
437
|
+
key: b.identifier('withSentryConfig'),
|
|
438
|
+
value: b.identifier('withSentryConfig'),
|
|
439
|
+
shorthand: true,
|
|
440
|
+
}),
|
|
441
|
+
]), b.callExpression(b.identifier('require'), [
|
|
442
|
+
b.literal('@sentry/react-native/metro'),
|
|
443
|
+
])),
|
|
444
|
+
]);
|
|
445
|
+
}
|
|
320
446
|
function confirmPathMetroConfig() {
|
|
321
447
|
return __awaiter(this, void 0, void 0, function () {
|
|
322
448
|
var shouldContinue;
|
|
@@ -367,8 +493,35 @@ function getMetroConfigObject(program) {
|
|
|
367
493
|
Sentry.setTag('metro-config', 'config-variable');
|
|
368
494
|
return configVariable.declarations[0].init;
|
|
369
495
|
}
|
|
496
|
+
return getModuleExportsObject(program);
|
|
497
|
+
}
|
|
498
|
+
exports.getMetroConfigObject = getMetroConfigObject;
|
|
499
|
+
function getModuleExportsObject(program) {
|
|
500
|
+
// check module.exports
|
|
501
|
+
var moduleExports = getModuleExportsAssignmentRight(program);
|
|
502
|
+
if ((moduleExports === null || moduleExports === void 0 ? void 0 : moduleExports.type) === 'ObjectExpression') {
|
|
503
|
+
return moduleExports;
|
|
504
|
+
}
|
|
505
|
+
Sentry.setTag('metro-config', 'not-found');
|
|
506
|
+
return undefined;
|
|
507
|
+
}
|
|
508
|
+
function getModuleExportsAssignmentRight(program) {
|
|
370
509
|
// check module.exports
|
|
371
|
-
var moduleExports = program
|
|
510
|
+
var moduleExports = getModuleExports(program);
|
|
511
|
+
if ((moduleExports === null || moduleExports === void 0 ? void 0 : moduleExports.expression.type) === 'AssignmentExpression' &&
|
|
512
|
+
(moduleExports.expression.right.type === 'ObjectExpression' ||
|
|
513
|
+
moduleExports.expression.right.type === 'CallExpression' ||
|
|
514
|
+
moduleExports.expression.right.type === 'Identifier')) {
|
|
515
|
+
Sentry.setTag('metro-config', 'module-exports');
|
|
516
|
+
return moduleExports === null || moduleExports === void 0 ? void 0 : moduleExports.expression.right;
|
|
517
|
+
}
|
|
518
|
+
Sentry.setTag('metro-config', 'not-found');
|
|
519
|
+
return undefined;
|
|
520
|
+
}
|
|
521
|
+
exports.getModuleExportsAssignmentRight = getModuleExportsAssignmentRight;
|
|
522
|
+
function getModuleExports(program) {
|
|
523
|
+
// find module.exports
|
|
524
|
+
return program.body.find(function (s) {
|
|
372
525
|
if (s.type === 'ExpressionStatement' &&
|
|
373
526
|
s.expression.type === 'AssignmentExpression' &&
|
|
374
527
|
s.expression.left.type === 'MemberExpression' &&
|
|
@@ -380,19 +533,15 @@ function getMetroConfigObject(program) {
|
|
|
380
533
|
}
|
|
381
534
|
return false;
|
|
382
535
|
});
|
|
383
|
-
if ((moduleExports === null || moduleExports === void 0 ? void 0 : moduleExports.expression).right.type ===
|
|
384
|
-
'ObjectExpression') {
|
|
385
|
-
Sentry.setTag('metro-config', 'module-exports');
|
|
386
|
-
return (moduleExports === null || moduleExports === void 0 ? void 0 : moduleExports.expression)
|
|
387
|
-
.right;
|
|
388
|
-
}
|
|
389
|
-
Sentry.setTag('metro-config', 'not-found');
|
|
390
|
-
return undefined;
|
|
391
536
|
}
|
|
392
|
-
|
|
393
|
-
function getMetroConfigSnippet(colors) {
|
|
537
|
+
function getMetroSentrySerializerSnippet(colors) {
|
|
394
538
|
return (0, clack_utils_1.makeCodeSnippet)(colors, function (unchanged, plus, _) {
|
|
395
539
|
return unchanged("const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');\";\n".concat(plus("const {createSentryMetroSerializer} = require('@sentry/react-native/dist/js/tools/sentryMetroSerializer');"), "\n\nconst config = {\n ").concat(plus("serializer: {\n customSerializer: createSentryMetroSerializer(),\n },"), "\n};\n\nmodule.exports = mergeConfig(getDefaultConfig(__dirname), config);\n"));
|
|
396
540
|
});
|
|
397
541
|
}
|
|
542
|
+
function getMetroWithSentryConfigSnippet(colors) {
|
|
543
|
+
return (0, clack_utils_1.makeCodeSnippet)(colors, function (unchanged, plus, _) {
|
|
544
|
+
return unchanged("const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');\";\n".concat(plus("const {withSentryConfig} = require('@sentry/react-native/metro');"), "\n\nconst config = {};\n\nmodule.exports = ").concat(plus('withSentryConfig('), "mergeConfig(getDefaultConfig(__dirname), config)").concat(plus(')'), ";\n"));
|
|
545
|
+
});
|
|
546
|
+
}
|
|
398
547
|
//# sourceMappingURL=metro.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metro.js","sourceRoot":"","sources":["../../../src/react-native/metro.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAyE;AACzE,oDAAwC;AACxC,4EAA4E;AAC5E,qCAAmE;AACnE,qCAAyB;AACzB,mDAAuC;AAEvC,gDAI4B;AAC5B,oDAI8B;AAE9B,6CAAiC;AAGjC,gDAA0B;AAE1B,IAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;AAEhC,IAAM,eAAe,GAAG,iBAAiB,CAAC;AAE1C,SAAsB,gBAAgB;;;;;wBACxB,qBAAM,gBAAgB,EAAE,EAAA;;oBAA9B,GAAG,GAAG,SAAwB;oBAE9B,gBAAgB,GAAG;wBACvB,OAAA,IAAA,uCAAyB,EAAC,eAAe,EAAE,qBAAqB,CAAC,IAAI,CAAC,CAAC;oBAAvE,CAAuE,CAAC;yBAEtE,IAAA,4BAAgB,EAAC,GAAG,CAAC,IAAiB,CAAC,EAAvC,wBAAuC;oBAClB,qBAAM,sBAAsB,EAAE,EAAA;;oBAA/C,cAAc,GAAG,SAA8B;yBACjD,CAAC,cAAc,EAAf,wBAAe;oBACV,qBAAM,gBAAgB,EAAE,EAAA;wBAA/B,sBAAO,SAAwB,EAAC;;oBAI9B,SAAS,GAAG,oBAAoB,CAAC,GAAG,CAAC,IAAiB,CAAC,CAAC;oBAC9D,IAAI,CAAC,SAAS,EAAE;wBACd,KAAK,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,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ;YAC1C,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY;YAChD,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,EAC7C;YACA,OAAO,IAAI,CAAC;SACb;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAsC,CAAC;IAExC,IACE,CAAC,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,UAAqC,CAAA,CAAC,KAAK,CAAC,IAAI;QAChE,kBAAkB,EAClB;QACA,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;QAChD,OAAO,CAAC,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,UAAqC,CAAA;aACzD,KAA2B,CAAC;KAChC;IAED,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;IAC3C,OAAO,SAAS,CAAC;AACnB,CAAC;AApDD,oDAoDC;AAED,SAAS,qBAAqB,CAAC,MAAe;IAC5C,OAAO,IAAA,6BAAe,EAAC,MAAM,EAAE,UAAC,SAAS,EAAE,IAAI,EAAE,CAAC;QAChD,OAAA,SAAS,CAAC,6FACZ,IAAI,CACJ,4GAA4G,CAC7G,qCAGG,IAAI,CAAC,2EAEJ,CAAC,iFAIL,CAAC;IAZE,CAYF,CACC,CAAC;AACJ,CAAC","sourcesContent":["// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\n// @ts-ignore - magicast is ESM and TS complains about that. It works though\nimport { ProxifiedModule, parseModule, writeFile } from 'magicast';\nimport * as fs from 'fs';\nimport * as Sentry from '@sentry/node';\n\nimport {\n getLastRequireIndex,\n hasSentryContent,\n removeRequire,\n} from '../utils/ast-utils';\nimport {\n abortIfCancelled,\n makeCodeSnippet,\n showCopyPasteInstructions,\n} from '../utils/clack-utils';\n\nimport * as recast from 'recast';\nimport x = recast.types;\nimport t = x.namedTypes;\nimport chalk from 'chalk';\n\nconst b = recast.types.builders;\n\nconst metroConfigPath = 'metro.config.js';\n\nexport async function patchMetroConfig() {\n const mod = await parseMetroConfig();\n\n const showInstructions = () =>\n showCopyPasteInstructions(metroConfigPath, getMetroConfigSnippet(true));\n\n if (hasSentryContent(mod.$ast as t.Program)) {\n const shouldContinue = await confirmPathMetroConfig();\n if (!shouldContinue) {\n return await showInstructions();\n }\n }\n\n const configObj = getMetroConfigObject(mod.$ast as t.Program);\n if (!configObj) {\n clack.log.warn(\n 'Could not find Metro config object, please follow the manual steps.',\n );\n return showInstructions();\n }\n\n const addedSentrySerializer = addSentrySerializerToMetroConfig(configObj);\n if (!addedSentrySerializer) {\n clack.log.warn(\n 'Could not add Sentry serializer to Metro config, please follow the manual steps.',\n );\n return await showInstructions();\n }\n\n const addedSentrySerializerImport = addSentrySerializerRequireToMetroConfig(\n mod.$ast as t.Program,\n );\n if (!addedSentrySerializerImport) {\n clack.log.warn(\n 'Could not add Sentry serializer import to Metro config, please follow the manual steps.',\n );\n return await showInstructions();\n }\n\n clack.log.success(\n `Added Sentry Metro plugin to ${chalk.cyan(metroConfigPath)}.`,\n );\n\n const saved = await writeMetroConfig(mod);\n if (saved) {\n clack.log.success(\n chalk.green(`${chalk.cyan(metroConfigPath)} changes saved.`),\n );\n } else {\n clack.log.warn(\n `Could not save changes to ${chalk.cyan(\n metroConfigPath,\n )}, please follow the manual steps.`,\n );\n return await showInstructions();\n }\n}\n\nexport async function unPatchMetroConfig() {\n const mod = await parseMetroConfig();\n\n const removedAtLeastOneRequire = removeSentryRequire(mod.$ast as t.Program);\n const removedSerializerConfig = removeSentrySerializerFromMetroConfig(\n mod.$ast as t.Program,\n );\n\n if (removedAtLeastOneRequire || removedSerializerConfig) {\n const saved = await writeMetroConfig(mod);\n if (saved) {\n clack.log.success(\n `Removed Sentry Metro plugin from ${chalk.cyan(metroConfigPath)}.`,\n );\n }\n } else {\n clack.log.warn(\n `No Sentry Metro plugin found in ${chalk.cyan(metroConfigPath)}.`,\n );\n }\n}\n\nexport function removeSentrySerializerFromMetroConfig(\n program: t.Program,\n): boolean {\n const configObject = getMetroConfigObject(program);\n if (!configObject) {\n return false;\n }\n\n const serializerProp = getSerializerProp(configObject);\n if ('invalid' === serializerProp || 'undefined' === serializerProp) {\n return false;\n }\n\n const customSerializerProp = getCustomSerializerProp(serializerProp);\n if (\n 'invalid' === customSerializerProp ||\n 'undefined' === customSerializerProp\n ) {\n return false;\n }\n\n if (\n serializerProp.value.type === 'ObjectExpression' &&\n customSerializerProp.value.type === 'CallExpression' &&\n customSerializerProp.value.callee.type === 'Identifier' &&\n customSerializerProp.value.callee.name === 'createSentryMetroSerializer'\n ) {\n if (customSerializerProp.value.arguments.length === 0) {\n // FROM serializer: { customSerializer: createSentryMetroSerializer() }\n // TO serializer: {}\n let removed = false;\n serializerProp.value.properties = serializerProp.value.properties.filter(\n (p) => {\n if (\n p.type === 'ObjectProperty' &&\n p.key.type === 'Identifier' &&\n p.key.name === 'customSerializer'\n ) {\n removed = true;\n return false;\n }\n return true;\n },\n );\n\n if (removed) {\n return true;\n }\n } else {\n if (customSerializerProp.value.arguments[0].type !== 'SpreadElement') {\n // FROM serializer: { customSerializer: createSentryMetroSerializer(wrapperSerializer) }\n // TO serializer: { customSerializer: wrapperSerializer }\n customSerializerProp.value = customSerializerProp.value.arguments[0];\n return true;\n }\n }\n }\n\n return false;\n}\n\nexport function removeSentryRequire(program: t.Program): boolean {\n return removeRequire(program, '@sentry');\n}\n\nasync function parseMetroConfig(): Promise<ProxifiedModule> {\n const metroConfigContent = (\n await fs.promises.readFile(metroConfigPath)\n ).toString();\n\n return parseModule(metroConfigContent);\n}\n\nasync function writeMetroConfig(mod: ProxifiedModule): Promise<boolean> {\n try {\n await writeFile(mod.$ast, metroConfigPath);\n } catch (e) {\n clack.log.error(\n `Failed to write to ${chalk.cyan(metroConfigPath)}: ${JSON.stringify(e)}`,\n );\n return false;\n }\n return true;\n}\n\nexport function addSentrySerializerToMetroConfig(\n configObj: t.ObjectExpression,\n): boolean {\n const serializerProp = getSerializerProp(configObj);\n if ('invalid' === serializerProp) {\n return false;\n }\n\n // case 1: serializer property doesn't exist yet, so we can just add it\n if ('undefined' === serializerProp) {\n configObj.properties.push(\n b.objectProperty(\n b.identifier('serializer'),\n b.objectExpression([\n b.objectProperty(\n b.identifier('customSerializer'),\n b.callExpression(b.identifier('createSentryMetroSerializer'), []),\n ),\n ]),\n ),\n );\n return true;\n }\n\n const customSerializerProp = getCustomSerializerProp(serializerProp);\n // case 2: serializer.customSerializer property doesn't exist yet, so we just add it\n if (\n 'undefined' === customSerializerProp &&\n serializerProp.value.type === 'ObjectExpression'\n ) {\n serializerProp.value.properties.push(\n b.objectProperty(\n b.identifier('customSerializer'),\n b.callExpression(b.identifier('createSentryMetroSerializer'), []),\n ),\n );\n return true;\n }\n\n return false;\n}\n\nfunction getCustomSerializerProp(\n prop: t.ObjectProperty,\n): t.ObjectProperty | 'undefined' | 'invalid' {\n const customSerializerProp =\n prop.value.type === 'ObjectExpression' &&\n prop.value.properties.find(\n (p: t.ObjectProperty) =>\n p.key.type === 'Identifier' && p.key.name === 'customSerializer',\n );\n\n if (!customSerializerProp) {\n return 'undefined';\n }\n\n if (customSerializerProp.type === 'ObjectProperty') {\n return customSerializerProp;\n }\n\n return 'invalid';\n}\n\nfunction getSerializerProp(\n obj: t.ObjectExpression,\n): t.ObjectProperty | 'undefined' | 'invalid' {\n const serializerProp = obj.properties.find(\n (p: t.ObjectProperty) =>\n p.key.type === 'Identifier' && p.key.name === 'serializer',\n );\n\n if (!serializerProp) {\n return 'undefined';\n }\n\n if (serializerProp.type === 'ObjectProperty') {\n return serializerProp;\n }\n\n return 'invalid';\n}\n\nexport function addSentrySerializerRequireToMetroConfig(\n program: t.Program,\n): boolean {\n const lastRequireIndex = getLastRequireIndex(program);\n const sentrySerializerRequire = createSentrySerializerRequire();\n const sentryImportIndex = lastRequireIndex + 1;\n if (sentryImportIndex < program.body.length) {\n // insert after last require\n program.body.splice(lastRequireIndex + 1, 0, sentrySerializerRequire);\n } else {\n // insert at the end\n program.body.push(sentrySerializerRequire);\n }\n return true;\n}\n\n/**\n * Creates const {createSentryMetroSerializer} = require('@sentry/react-native/dist/js/tools/sentryMetroSerializer');\n */\nfunction createSentrySerializerRequire() {\n return b.variableDeclaration('const', [\n b.variableDeclarator(\n b.objectPattern([\n b.objectProperty.from({\n key: b.identifier('createSentryMetroSerializer'),\n value: b.identifier('createSentryMetroSerializer'),\n shorthand: true,\n }),\n ]),\n b.callExpression(b.identifier('require'), [\n b.literal('@sentry/react-native/dist/js/tools/sentryMetroSerializer'),\n ]),\n ),\n ]);\n}\n\nasync function confirmPathMetroConfig() {\n const shouldContinue = await abortIfCancelled(\n clack.select({\n message: `Metro Config already contains Sentry-related code. Should the wizard modify it anyway?`,\n options: [\n {\n label: 'Yes, add the Sentry Metro plugin',\n value: true,\n },\n {\n label: 'No, show me instructions to manually add the plugin',\n value: false,\n },\n ],\n initialValue: true,\n }),\n );\n\n if (!shouldContinue) {\n Sentry.setTag('ast-mod-fail-reason', 'has-sentry-content');\n }\n\n return shouldContinue;\n}\n\n/**\n * Returns value from `module.exports = value` or `const config = value`\n */\nexport function getMetroConfigObject(\n program: t.Program,\n): t.ObjectExpression | undefined {\n // check config variable\n const configVariable = program.body.find((s) => {\n if (\n s.type === 'VariableDeclaration' &&\n s.declarations.length === 1 &&\n s.declarations[0].type === 'VariableDeclarator' &&\n s.declarations[0].id.type === 'Identifier' &&\n s.declarations[0].id.name === 'config'\n ) {\n return true;\n }\n return false;\n }) as t.VariableDeclaration | undefined;\n\n if (\n configVariable?.declarations[0].type === 'VariableDeclarator' &&\n configVariable?.declarations[0].init?.type === 'ObjectExpression'\n ) {\n Sentry.setTag('metro-config', 'config-variable');\n return configVariable.declarations[0].init;\n }\n\n // check module.exports\n const moduleExports = program.body.find((s) => {\n if (\n s.type === 'ExpressionStatement' &&\n s.expression.type === 'AssignmentExpression' &&\n s.expression.left.type === 'MemberExpression' &&\n s.expression.left.object.type === 'Identifier' &&\n s.expression.left.object.name === 'module' &&\n s.expression.left.property.type === 'Identifier' &&\n s.expression.left.property.name === 'exports'\n ) {\n return true;\n }\n return false;\n }) as t.ExpressionStatement | undefined;\n\n if (\n (moduleExports?.expression as t.AssignmentExpression).right.type ===\n 'ObjectExpression'\n ) {\n Sentry.setTag('metro-config', 'module-exports');\n return (moduleExports?.expression as t.AssignmentExpression)\n .right as t.ObjectExpression;\n }\n\n Sentry.setTag('metro-config', 'not-found');\n return undefined;\n}\n\nfunction getMetroConfigSnippet(colors: boolean) {\n return makeCodeSnippet(colors, (unchanged, plus, _) =>\n unchanged(`const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');\";\n${plus(\n \"const {createSentryMetroSerializer} = require('@sentry/react-native/dist/js/tools/sentryMetroSerializer');\",\n)}\n\nconst config = {\n ${plus(`serializer: {\n customSerializer: createSentryMetroSerializer(),\n },`)}\n};\n\nmodule.exports = mergeConfig(getDefaultConfig(__dirname), config);\n`),\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"metro.js","sourceRoot":"","sources":["../../../src/react-native/metro.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAyE;AACzE,oDAAwC;AACxC,4EAA4E;AAC5E,qCAAmE;AACnE,qCAAyB;AACzB,mDAAuC;AAEvC,gDAI4B;AAC5B,oDAI8B;AAE9B,6CAAiC;AAGjC,gDAA0B;AAE1B,IAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;AAEhC,IAAM,eAAe,GAAG,iBAAiB,CAAC;AAE1C,SAAsB,0BAA0B;;;;;wBAClC,qBAAM,gBAAgB,EAAE,EAAA;;oBAA9B,GAAG,GAAG,SAAwB;oBAE9B,gBAAgB,GAAG;wBACvB,OAAA,IAAA,uCAAyB,EACvB,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IAAI,KAAK,kBAAkB;YAC7C,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,YAAY;YAC9C,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ;YAC1C,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY;YAChD,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,EAC7C;YACA,OAAO,IAAI,CAAC;SACb;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAsC,CAAC;AAC1C,CAAC;AAED,SAAS,+BAA+B,CAAC,MAAe;IACtD,OAAO,IAAA,6BAAe,EAAC,MAAM,EAAE,UAAC,SAAS,EAAE,IAAI,EAAE,CAAC;QAChD,OAAA,SAAS,CAAC,6FACZ,IAAI,CACJ,4GAA4G,CAC7G,qCAGG,IAAI,CAAC,2EAEJ,CAAC,iFAIL,CAAC;IAZE,CAYF,CACC,CAAC;AACJ,CAAC;AAED,SAAS,+BAA+B,CAAC,MAAe;IACtD,OAAO,IAAA,6BAAe,EAAC,MAAM,EAAE,UAAC,SAAS,EAAE,IAAI,EAAE,CAAC;QAChD,OAAA,SAAS,CAAC,6FACZ,IAAI,CAAC,mEAAmE,CAAC,wDAIxD,IAAI,CACjB,mBAAmB,CACpB,6DAAmD,IAAI,CAAC,GAAG,CAAC,QAChE,CAAC;IARE,CAQF,CACC,CAAC;AACJ,CAAC","sourcesContent":["// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\n// @ts-ignore - magicast is ESM and TS complains about that. It works though\nimport { ProxifiedModule, parseModule, writeFile } from 'magicast';\nimport * as fs from 'fs';\nimport * as Sentry from '@sentry/node';\n\nimport {\n getLastRequireIndex,\n hasSentryContent,\n removeRequire,\n} from '../utils/ast-utils';\nimport {\n abortIfCancelled,\n makeCodeSnippet,\n showCopyPasteInstructions,\n} from '../utils/clack-utils';\n\nimport * as recast from 'recast';\nimport x = recast.types;\nimport t = x.namedTypes;\nimport chalk from 'chalk';\n\nconst b = recast.types.builders;\n\nconst metroConfigPath = 'metro.config.js';\n\nexport async function patchMetroWithSentryConfig() {\n const mod = await parseMetroConfig();\n\n const showInstructions = () =>\n showCopyPasteInstructions(\n metroConfigPath,\n getMetroWithSentryConfigSnippet(true),\n );\n\n const success = await patchMetroWithSentryConfigInMemory(\n mod,\n showInstructions,\n );\n if (!success) {\n return;\n }\n\n const saved = await writeMetroConfig(mod);\n if (saved) {\n clack.log.success(\n chalk.green(`${chalk.cyan(metroConfigPath)} changes saved.`),\n );\n } else {\n clack.log.warn(\n `Could not save changes to ${chalk.cyan(\n metroConfigPath,\n )}, please follow the manual steps.`,\n );\n return await showInstructions();\n }\n}\n\nexport async function patchMetroWithSentryConfigInMemory(\n mod: ProxifiedModule,\n showInstructions: () => Promise<void>,\n): Promise<boolean> {\n if (hasSentryContent(mod.$ast as t.Program)) {\n const shouldContinue = await confirmPathMetroConfig();\n if (!shouldContinue) {\n await showInstructions();\n return false;\n }\n }\n\n const configExpression = getModuleExportsAssignmentRight(\n mod.$ast as t.Program,\n );\n if (!configExpression) {\n clack.log.warn(\n 'Could not find Metro config, please follow the manual steps.',\n );\n await showInstructions();\n return false;\n }\n\n const wrappedConfig = wrapWithSentryConfig(configExpression);\n\n const replacedModuleExportsRight = replaceModuleExportsRight(\n mod.$ast as t.Program,\n wrappedConfig,\n );\n if (!replacedModuleExportsRight) {\n clack.log.warn(\n 'Could not automatically wrap the config export, please follow the manual steps.',\n );\n await showInstructions();\n return false;\n }\n\n const addedSentryMetroImport = addSentryMetroRequireToMetroConfig(\n mod.$ast as t.Program,\n );\n if (!addedSentryMetroImport) {\n clack.log.warn(\n 'Could not add `@sentry/react-native/metro` import to Metro config, please follow the manual steps.',\n );\n await showInstructions();\n return false;\n }\n\n clack.log.success(\n `Added Sentry Metro plugin to ${chalk.cyan(metroConfigPath)}.`,\n );\n return true;\n}\n\nexport async function patchMetroConfigWithSentrySerializer() {\n const mod = await parseMetroConfig();\n\n const showInstructions = () =>\n showCopyPasteInstructions(\n metroConfigPath,\n getMetroSentrySerializerSnippet(true),\n );\n\n if (hasSentryContent(mod.$ast as t.Program)) {\n const shouldContinue = await confirmPathMetroConfig();\n if (!shouldContinue) {\n return await showInstructions();\n }\n }\n\n const configObj = getMetroConfigObject(mod.$ast as t.Program);\n if (!configObj) {\n clack.log.warn(\n 'Could not find Metro config object, please follow the manual steps.',\n );\n return showInstructions();\n }\n\n const addedSentrySerializer = addSentrySerializerToMetroConfig(configObj);\n if (!addedSentrySerializer) {\n clack.log.warn(\n 'Could not add Sentry serializer to Metro config, please follow the manual steps.',\n );\n return await showInstructions();\n }\n\n const addedSentrySerializerImport = addSentrySerializerRequireToMetroConfig(\n mod.$ast as t.Program,\n );\n if (!addedSentrySerializerImport) {\n clack.log.warn(\n 'Could not add Sentry serializer import to Metro config, please follow the manual steps.',\n );\n return await showInstructions();\n }\n\n clack.log.success(\n `Added Sentry Metro plugin to ${chalk.cyan(metroConfigPath)}.`,\n );\n\n const saved = await writeMetroConfig(mod);\n if (saved) {\n clack.log.success(\n chalk.green(`${chalk.cyan(metroConfigPath)} changes saved.`),\n );\n } else {\n clack.log.warn(\n `Could not save changes to ${chalk.cyan(\n metroConfigPath,\n )}, please follow the manual steps.`,\n );\n return await showInstructions();\n }\n}\n\nexport async function unPatchMetroConfig() {\n const mod = await parseMetroConfig();\n\n const removedAtLeastOneRequire = removeSentryRequire(mod.$ast as t.Program);\n const removedSerializerConfig = removeSentrySerializerFromMetroConfig(\n mod.$ast as t.Program,\n );\n\n if (removedAtLeastOneRequire || removedSerializerConfig) {\n const saved = await writeMetroConfig(mod);\n if (saved) {\n clack.log.success(\n `Removed Sentry Metro plugin from ${chalk.cyan(metroConfigPath)}.`,\n );\n }\n } else {\n clack.log.warn(\n `No Sentry Metro plugin found in ${chalk.cyan(metroConfigPath)}.`,\n );\n }\n}\n\nexport function removeSentrySerializerFromMetroConfig(\n program: t.Program,\n): boolean {\n const configObject = getMetroConfigObject(program);\n if (!configObject) {\n return false;\n }\n\n const serializerProp = getSerializerProp(configObject);\n if ('invalid' === serializerProp || 'undefined' === serializerProp) {\n return false;\n }\n\n const customSerializerProp = getCustomSerializerProp(serializerProp);\n if (\n 'invalid' === customSerializerProp ||\n 'undefined' === customSerializerProp\n ) {\n return false;\n }\n\n if (\n serializerProp.value.type === 'ObjectExpression' &&\n customSerializerProp.value.type === 'CallExpression' &&\n customSerializerProp.value.callee.type === 'Identifier' &&\n customSerializerProp.value.callee.name === 'createSentryMetroSerializer'\n ) {\n if (customSerializerProp.value.arguments.length === 0) {\n // FROM serializer: { customSerializer: createSentryMetroSerializer() }\n // TO serializer: {}\n let removed = false;\n serializerProp.value.properties = serializerProp.value.properties.filter(\n (p) => {\n if (\n p.type === 'ObjectProperty' &&\n p.key.type === 'Identifier' &&\n p.key.name === 'customSerializer'\n ) {\n removed = true;\n return false;\n }\n return true;\n },\n );\n\n if (removed) {\n return true;\n }\n } else {\n if (customSerializerProp.value.arguments[0].type !== 'SpreadElement') {\n // FROM serializer: { customSerializer: createSentryMetroSerializer(wrapperSerializer) }\n // TO serializer: { customSerializer: wrapperSerializer }\n customSerializerProp.value = customSerializerProp.value.arguments[0];\n return true;\n }\n }\n }\n\n return false;\n}\n\nexport function removeSentryRequire(program: t.Program): boolean {\n return removeRequire(program, '@sentry');\n}\n\nasync function parseMetroConfig(): Promise<ProxifiedModule> {\n const metroConfigContent = (\n await fs.promises.readFile(metroConfigPath)\n ).toString();\n\n return parseModule(metroConfigContent);\n}\n\nasync function writeMetroConfig(mod: ProxifiedModule): Promise<boolean> {\n try {\n await writeFile(mod.$ast, metroConfigPath);\n } catch (e) {\n clack.log.error(\n `Failed to write to ${chalk.cyan(metroConfigPath)}: ${JSON.stringify(e)}`,\n );\n return false;\n }\n return true;\n}\n\nexport function addSentrySerializerToMetroConfig(\n configObj: t.ObjectExpression,\n): boolean {\n const serializerProp = getSerializerProp(configObj);\n if ('invalid' === serializerProp) {\n return false;\n }\n\n // case 1: serializer property doesn't exist yet, so we can just add it\n if ('undefined' === serializerProp) {\n configObj.properties.push(\n b.objectProperty(\n b.identifier('serializer'),\n b.objectExpression([\n b.objectProperty(\n b.identifier('customSerializer'),\n b.callExpression(b.identifier('createSentryMetroSerializer'), []),\n ),\n ]),\n ),\n );\n return true;\n }\n\n const customSerializerProp = getCustomSerializerProp(serializerProp);\n // case 2: serializer.customSerializer property doesn't exist yet, so we just add it\n if (\n 'undefined' === customSerializerProp &&\n serializerProp.value.type === 'ObjectExpression'\n ) {\n serializerProp.value.properties.push(\n b.objectProperty(\n b.identifier('customSerializer'),\n b.callExpression(b.identifier('createSentryMetroSerializer'), []),\n ),\n );\n return true;\n }\n\n return false;\n}\n\nfunction getCustomSerializerProp(\n prop: t.ObjectProperty,\n): t.ObjectProperty | 'undefined' | 'invalid' {\n const customSerializerProp =\n prop.value.type === 'ObjectExpression' &&\n prop.value.properties.find(\n (p: t.ObjectProperty) =>\n p.key.type === 'Identifier' && p.key.name === 'customSerializer',\n );\n\n if (!customSerializerProp) {\n return 'undefined';\n }\n\n if (customSerializerProp.type === 'ObjectProperty') {\n return customSerializerProp;\n }\n\n return 'invalid';\n}\n\nfunction getSerializerProp(\n obj: t.ObjectExpression,\n): t.ObjectProperty | 'undefined' | 'invalid' {\n const serializerProp = obj.properties.find(\n (p: t.ObjectProperty) =>\n p.key.type === 'Identifier' && p.key.name === 'serializer',\n );\n\n if (!serializerProp) {\n return 'undefined';\n }\n\n if (serializerProp.type === 'ObjectProperty') {\n return serializerProp;\n }\n\n return 'invalid';\n}\n\nexport function addSentrySerializerRequireToMetroConfig(\n program: t.Program,\n): boolean {\n const lastRequireIndex = getLastRequireIndex(program);\n const sentrySerializerRequire = createSentrySerializerRequire();\n const sentryImportIndex = lastRequireIndex + 1;\n if (sentryImportIndex < program.body.length) {\n // insert after last require\n program.body.splice(lastRequireIndex + 1, 0, sentrySerializerRequire);\n } else {\n // insert at the beginning\n program.body.unshift(sentrySerializerRequire);\n }\n return true;\n}\n\nexport function addSentryMetroRequireToMetroConfig(\n program: t.Program,\n): boolean {\n const lastRequireIndex = getLastRequireIndex(program);\n const sentryMetroRequire = createSentryMetroRequire();\n const sentryImportIndex = lastRequireIndex + 1;\n if (sentryImportIndex < program.body.length) {\n // insert after last require\n program.body.splice(lastRequireIndex + 1, 0, sentryMetroRequire);\n } else {\n // insert at the beginning\n program.body.unshift(sentryMetroRequire);\n }\n return true;\n}\n\nfunction wrapWithSentryConfig(\n configObj: t.Identifier | t.CallExpression | t.ObjectExpression,\n): t.CallExpression {\n return b.callExpression(b.identifier('withSentryConfig'), [configObj]);\n}\n\nfunction replaceModuleExportsRight(\n program: t.Program,\n wrappedConfig: t.CallExpression,\n): boolean {\n const moduleExports = getModuleExports(program);\n if (!moduleExports) {\n return false;\n }\n\n if (moduleExports.expression.type === 'AssignmentExpression') {\n moduleExports.expression.right = wrappedConfig;\n return true;\n }\n\n return false;\n}\n\n/**\n * Creates const {createSentryMetroSerializer} = require('@sentry/react-native/dist/js/tools/sentryMetroSerializer');\n */\nfunction createSentrySerializerRequire() {\n return b.variableDeclaration('const', [\n b.variableDeclarator(\n b.objectPattern([\n b.objectProperty.from({\n key: b.identifier('createSentryMetroSerializer'),\n value: b.identifier('createSentryMetroSerializer'),\n shorthand: true,\n }),\n ]),\n b.callExpression(b.identifier('require'), [\n b.literal('@sentry/react-native/dist/js/tools/sentryMetroSerializer'),\n ]),\n ),\n ]);\n}\n\n/**\n * Creates const {withSentryConfig} = require('@sentry/react-native/metro');\n */\nfunction createSentryMetroRequire() {\n return b.variableDeclaration('const', [\n b.variableDeclarator(\n b.objectPattern([\n b.objectProperty.from({\n key: b.identifier('withSentryConfig'),\n value: b.identifier('withSentryConfig'),\n shorthand: true,\n }),\n ]),\n b.callExpression(b.identifier('require'), [\n b.literal('@sentry/react-native/metro'),\n ]),\n ),\n ]);\n}\n\nasync function confirmPathMetroConfig() {\n const shouldContinue = await abortIfCancelled(\n clack.select({\n message: `Metro Config already contains Sentry-related code. Should the wizard modify it anyway?`,\n options: [\n {\n label: 'Yes, add the Sentry Metro plugin',\n value: true,\n },\n {\n label: 'No, show me instructions to manually add the plugin',\n value: false,\n },\n ],\n initialValue: true,\n }),\n );\n\n if (!shouldContinue) {\n Sentry.setTag('ast-mod-fail-reason', 'has-sentry-content');\n }\n\n return shouldContinue;\n}\n\n/**\n * Returns value from `module.exports = value` or `const config = value`\n */\nexport function getMetroConfigObject(\n program: t.Program,\n): t.ObjectExpression | undefined {\n // check config variable\n const configVariable = program.body.find((s) => {\n if (\n s.type === 'VariableDeclaration' &&\n s.declarations.length === 1 &&\n s.declarations[0].type === 'VariableDeclarator' &&\n s.declarations[0].id.type === 'Identifier' &&\n s.declarations[0].id.name === 'config'\n ) {\n return true;\n }\n return false;\n }) as t.VariableDeclaration | undefined;\n\n if (\n configVariable?.declarations[0].type === 'VariableDeclarator' &&\n configVariable?.declarations[0].init?.type === 'ObjectExpression'\n ) {\n Sentry.setTag('metro-config', 'config-variable');\n return configVariable.declarations[0].init;\n }\n\n return getModuleExportsObject(program);\n}\n\nfunction getModuleExportsObject(\n program: t.Program,\n): t.ObjectExpression | undefined {\n // check module.exports\n const moduleExports = getModuleExportsAssignmentRight(program);\n\n if (moduleExports?.type === 'ObjectExpression') {\n return moduleExports;\n }\n\n Sentry.setTag('metro-config', 'not-found');\n return undefined;\n}\n\nexport function getModuleExportsAssignmentRight(\n program: t.Program,\n): t.Identifier | t.CallExpression | t.ObjectExpression | undefined {\n // check module.exports\n const moduleExports = getModuleExports(program);\n\n if (\n moduleExports?.expression.type === 'AssignmentExpression' &&\n (moduleExports.expression.right.type === 'ObjectExpression' ||\n moduleExports.expression.right.type === 'CallExpression' ||\n moduleExports.expression.right.type === 'Identifier')\n ) {\n Sentry.setTag('metro-config', 'module-exports');\n return moduleExports?.expression.right;\n }\n\n Sentry.setTag('metro-config', 'not-found');\n return undefined;\n}\n\nfunction getModuleExports(\n program: t.Program,\n): t.ExpressionStatement | undefined {\n // find module.exports\n return program.body.find((s) => {\n if (\n s.type === 'ExpressionStatement' &&\n s.expression.type === 'AssignmentExpression' &&\n s.expression.left.type === 'MemberExpression' &&\n s.expression.left.object.type === 'Identifier' &&\n s.expression.left.object.name === 'module' &&\n s.expression.left.property.type === 'Identifier' &&\n s.expression.left.property.name === 'exports'\n ) {\n return true;\n }\n return false;\n }) as t.ExpressionStatement | undefined;\n}\n\nfunction getMetroSentrySerializerSnippet(colors: boolean) {\n return makeCodeSnippet(colors, (unchanged, plus, _) =>\n unchanged(`const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');\";\n${plus(\n \"const {createSentryMetroSerializer} = require('@sentry/react-native/dist/js/tools/sentryMetroSerializer');\",\n)}\n\nconst config = {\n ${plus(`serializer: {\n customSerializer: createSentryMetroSerializer(),\n },`)}\n};\n\nmodule.exports = mergeConfig(getDefaultConfig(__dirname), config);\n`),\n );\n}\n\nfunction getMetroWithSentryConfigSnippet(colors: boolean) {\n return makeCodeSnippet(colors, (unchanged, plus, _) =>\n unchanged(`const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');\";\n${plus(\"const {withSentryConfig} = require('@sentry/react-native/metro');\")}\n\nconst config = {};\n\nmodule.exports = ${plus(\n 'withSentryConfig(',\n )}mergeConfig(getDefaultConfig(__dirname), config)${plus(')')};\n`),\n );\n}\n"]}
|
|
@@ -6,6 +6,7 @@ export declare const RN_HUMAN_NAME = "React Native";
|
|
|
6
6
|
export declare const SUPPORTED_RN_RANGE = ">=0.69.0";
|
|
7
7
|
export declare const SDK_XCODE_SCRIPTS_SUPPORTED_SDK_RANGE = ">=5.11.0";
|
|
8
8
|
export declare const SDK_SENTRY_METRO_PLUGIN_SUPPORTED_SDK_RANGE = ">=5.11.0";
|
|
9
|
+
export declare const SDK_SENTRY_METRO_WITH_SENTRY_CONFIG_SUPPORTED_SDK_RANGE = ">=5.17.0";
|
|
9
10
|
export type RNCliSetupConfigContent = Pick<Required<CliSetupConfigContent>, 'authToken' | 'org' | 'project' | 'url'>;
|
|
10
11
|
export declare function runReactNativeWizard(params: ReactNativeWizardOptions): Promise<void>;
|
|
11
12
|
export declare function runReactNativeWizardWithTelemetry(options: ReactNativeWizardOptions): Promise<void>;
|