@sentry/wizard 4.6.0 → 4.7.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 +8 -0
- package/dist/bin.js +9 -0
- package/dist/bin.js.map +1 -1
- package/dist/e2e-tests/tests/flutter.test.js +16 -16
- package/dist/e2e-tests/tests/flutter.test.js.map +1 -1
- package/dist/e2e-tests/tests/help-message.test.d.ts +1 -0
- package/dist/e2e-tests/tests/help-message.test.js +56 -0
- package/dist/e2e-tests/tests/help-message.test.js.map +1 -0
- package/dist/e2e-tests/tests/nextjs-14.test.js +15 -15
- package/dist/e2e-tests/tests/nextjs-14.test.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs-15.test.js +15 -15
- package/dist/e2e-tests/tests/nextjs-15.test.js.map +1 -1
- package/dist/e2e-tests/tests/nuxt-3.test.js +13 -12
- package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -1
- package/dist/e2e-tests/tests/nuxt-4.test.js +13 -12
- package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -1
- package/dist/e2e-tests/tests/remix.test.js +20 -20
- package/dist/e2e-tests/tests/remix.test.js.map +1 -1
- package/dist/e2e-tests/tests/sveltekit.test.js +20 -20
- package/dist/e2e-tests/tests/sveltekit.test.js.map +1 -1
- package/dist/e2e-tests/utils/index.js +15 -11
- package/dist/e2e-tests/utils/index.js.map +1 -1
- package/dist/lib/Constants.d.ts +5 -1
- package/dist/lib/Constants.js.map +1 -1
- package/dist/lib/Helper/Logging.d.ts +1 -1
- package/dist/lib/Helper/Logging.js.map +1 -1
- package/dist/lib/Helper/__tests__/File.js +9 -9
- package/dist/lib/Helper/__tests__/File.js.map +1 -1
- package/dist/lib/Helper/__tests__/MergeConfig.js +17 -17
- package/dist/lib/Helper/__tests__/MergeConfig.js.map +1 -1
- package/dist/lib/Helper/__tests__/SentryCli.js +23 -22
- package/dist/lib/Helper/__tests__/SentryCli.js.map +1 -1
- package/dist/lib/Setup.d.ts +2 -1
- package/dist/lib/Setup.js +12 -2
- package/dist/lib/Setup.js.map +1 -1
- package/dist/lib/Steps/BaseStep.d.ts +1 -1
- package/dist/lib/Steps/BaseStep.js.map +1 -1
- package/dist/lib/Steps/Integrations/Cordova.js.map +1 -1
- package/dist/lib/Steps/Welcome.js +5 -0
- package/dist/lib/Steps/Welcome.js.map +1 -1
- package/dist/lib/__tests__/Env.js +4 -3
- package/dist/lib/__tests__/Env.js.map +1 -1
- package/dist/src/apple/apple-wizard.js +24 -64
- package/dist/src/apple/apple-wizard.js.map +1 -1
- package/dist/src/apple/configure-package-manager.d.ts +5 -0
- package/dist/src/apple/configure-package-manager.js +68 -0
- package/dist/src/apple/configure-package-manager.js.map +1 -0
- package/dist/src/apple/configure-sentry-cli.d.ts +4 -0
- package/dist/src/apple/configure-sentry-cli.js +47 -0
- package/dist/src/apple/configure-sentry-cli.js.map +1 -0
- package/dist/src/apple/configure-xcode-project.d.ts +8 -0
- package/dist/src/apple/configure-xcode-project.js +11 -0
- package/dist/src/apple/configure-xcode-project.js.map +1 -0
- package/dist/src/apple/inject-code-snippet.d.ts +6 -0
- package/dist/src/apple/inject-code-snippet.js +54 -0
- package/dist/src/apple/inject-code-snippet.js.map +1 -0
- package/dist/src/apple/templates.js +11 -7
- package/dist/src/apple/templates.js.map +1 -1
- package/dist/src/apple/xcode-manager.js +3 -6
- package/dist/src/apple/xcode-manager.js.map +1 -1
- package/dist/src/nextjs/templates.js +3 -1
- package/dist/src/nextjs/templates.js.map +1 -1
- package/dist/src/react-native/javascript.d.ts +6 -4
- package/dist/src/react-native/javascript.js +25 -9
- package/dist/src/react-native/javascript.js.map +1 -1
- package/dist/src/react-native/react-native-wizard.d.ts +4 -0
- package/dist/src/react-native/react-native-wizard.js +30 -5
- package/dist/src/react-native/react-native-wizard.js.map +1 -1
- package/dist/src/react-native/xcode.d.ts +7 -3
- package/dist/src/react-native/xcode.js +64 -20
- package/dist/src/react-native/xcode.js.map +1 -1
- package/dist/src/run.js +2 -2
- package/dist/src/run.js.map +1 -1
- package/dist/src/utils/clack/index.js +3 -1
- package/dist/src/utils/clack/index.js.map +1 -1
- package/dist/src/utils/package-manager.d.ts +2 -0
- package/dist/src/utils/package-manager.js +55 -5
- package/dist/src/utils/package-manager.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/test/android/code-tools.test.js +13 -12
- package/dist/test/android/code-tools.test.js.map +1 -1
- package/dist/test/apple/cocoapod.test.js +77 -72
- package/dist/test/apple/cocoapod.test.js.map +1 -1
- package/dist/test/apple/code-tools.test.js +173 -166
- package/dist/test/apple/code-tools.test.js.map +1 -1
- package/dist/test/apple/fastfile.test.js +86 -83
- package/dist/test/apple/fastfile.test.js.map +1 -1
- package/dist/test/apple/templates.test.js +32 -27
- package/dist/test/apple/templates.test.js.map +1 -1
- package/dist/test/apple/xcode-manager.test.js +182 -183
- package/dist/test/apple/xcode-manager.test.js.map +1 -1
- package/dist/test/flutter/code-tools.test.js +29 -28
- package/dist/test/flutter/code-tools.test.js.map +1 -1
- package/dist/test/flutter/templates.test.js +15 -14
- package/dist/test/flutter/templates.test.js.map +1 -1
- package/dist/test/nextjs/templates.test.js +43 -36
- package/dist/test/nextjs/templates.test.js.map +1 -1
- package/dist/test/nuxt/templates.test.js +25 -24
- package/dist/test/nuxt/templates.test.js.map +1 -1
- package/dist/test/react-native/expo-metro.test.js +11 -10
- package/dist/test/react-native/expo-metro.test.js.map +1 -1
- package/dist/test/react-native/expo.test.js +11 -10
- package/dist/test/react-native/expo.test.js.map +1 -1
- package/dist/test/react-native/gradle.test.js +27 -26
- package/dist/test/react-native/gradle.test.js.map +1 -1
- package/dist/test/react-native/javascript.test.js +108 -58
- package/dist/test/react-native/javascript.test.js.map +1 -1
- package/dist/test/react-native/metro.test.js +65 -64
- package/dist/test/react-native/metro.test.js.map +1 -1
- package/dist/test/react-native/xcode.test.js +138 -37
- package/dist/test/react-native/xcode.test.js.map +1 -1
- package/dist/test/remix/client-entry.test.js +8 -7
- package/dist/test/remix/client-entry.test.js.map +1 -1
- package/dist/test/remix/server-instrumentation.test.js +6 -5
- package/dist/test/remix/server-instrumentation.test.js.map +1 -1
- package/dist/test/sourcemaps/tools/sentry-cli.test.js +20 -20
- package/dist/test/sourcemaps/tools/sentry-cli.test.js.map +1 -1
- package/dist/test/sourcemaps/tools/tsc.test.js +13 -14
- package/dist/test/sourcemaps/tools/tsc.test.js.map +1 -1
- package/dist/test/sourcemaps/tools/vite.test.js +13 -14
- package/dist/test/sourcemaps/tools/vite.test.js.map +1 -1
- package/dist/test/sourcemaps/tools/webpack.test.js +19 -20
- package/dist/test/sourcemaps/tools/webpack.test.js.map +1 -1
- package/dist/test/sveltekit/templates.test.js +13 -12
- package/dist/test/sveltekit/templates.test.js.map +1 -1
- package/dist/test/utils/ast-utils.test.js +45 -44
- package/dist/test/utils/ast-utils.test.js.map +1 -1
- package/dist/test/utils/clack/index.test.js +140 -144
- package/dist/test/utils/clack/index.test.js.map +1 -1
- package/dist/test/utils/package-manager.test.js +8 -7
- package/dist/test/utils/package-manager.test.js.map +1 -1
- package/package.json +10 -38
- package/dist/e2e-tests/jest.config.d.ts +0 -17
- package/dist/e2e-tests/jest.config.js +0 -23
- package/dist/e2e-tests/jest.config.js.map +0 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.injectCodeSnippet = void 0;
|
|
30
|
+
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
31
|
+
const prompts_1 = __importDefault(require("@clack/prompts"));
|
|
32
|
+
const Sentry = __importStar(require("@sentry/node"));
|
|
33
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
34
|
+
const telemetry_1 = require("../telemetry");
|
|
35
|
+
const debug_1 = require("../utils/debug");
|
|
36
|
+
const codeTools = __importStar(require("./code-tools"));
|
|
37
|
+
function injectCodeSnippet({ project, target, dsn, }) {
|
|
38
|
+
(0, debug_1.debug)(`Injecting code snippet into project at path: ${chalk_1.default.cyan(project.projectPath)}`);
|
|
39
|
+
const codeAdded = (0, telemetry_1.traceStep)('Add code snippet', () => {
|
|
40
|
+
const files = project.filesForTarget(target);
|
|
41
|
+
if (files === undefined || files.length == 0) {
|
|
42
|
+
Sentry.setTag('snippet-candidate-files-not-found', true);
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
return codeTools.addCodeSnippetToProject(project.projectPath, files, dsn);
|
|
46
|
+
});
|
|
47
|
+
Sentry.setTag('Snippet-Added', codeAdded);
|
|
48
|
+
(0, debug_1.debug)(`Snippet added: ${chalk_1.default.cyan(codeAdded.toString())}`);
|
|
49
|
+
if (!codeAdded) {
|
|
50
|
+
prompts_1.default.log.warn('Added the Sentry dependency to your project but could not add the Sentry code snippet. Please add the code snippet manually by following the docs: https://docs.sentry.io/platforms/apple/guides/ios/#configure');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.injectCodeSnippet = injectCodeSnippet;
|
|
54
|
+
//# sourceMappingURL=inject-code-snippet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inject-code-snippet.js","sourceRoot":"","sources":["../../../src/apple/inject-code-snippet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,qDAAuC;AACvC,kDAA0B;AAC1B,4CAAyC;AACzC,0CAAuC;AACvC,wDAA0C;AAG1C,SAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,MAAM,EACN,GAAG,GAKJ;IACC,IAAA,aAAK,EACH,gDAAgD,eAAK,CAAC,IAAI,CACxD,OAAO,CAAC,WAAW,CACpB,EAAE,CACJ,CAAC;IACF,MAAM,SAAS,GAAG,IAAA,qBAAS,EAAC,kBAAkB,EAAE,GAAG,EAAE;QACnD,MAAM,KAAK,GAAG,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAC7C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,EAAE;YAC5C,MAAM,CAAC,MAAM,CAAC,mCAAmC,EAAE,IAAI,CAAC,CAAC;YACzD,OAAO,KAAK,CAAC;SACd;QAED,OAAO,SAAS,CAAC,uBAAuB,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;IAC1C,IAAA,aAAK,EAAC,kBAAkB,eAAK,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;IAE5D,IAAI,CAAC,SAAS,EAAE;QACd,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,iNAAiN,CAClN,CAAC;KACH;AACH,CAAC;AA/BD,8CA+BC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport * as Sentry from '@sentry/node';\nimport chalk from 'chalk';\nimport { traceStep } from '../telemetry';\nimport { debug } from '../utils/debug';\nimport * as codeTools from './code-tools';\nimport { XcodeProject } from './xcode-manager';\n\nexport function injectCodeSnippet({\n project,\n target,\n dsn,\n}: {\n project: XcodeProject;\n target: string;\n dsn: string;\n}) {\n debug(\n `Injecting code snippet into project at path: ${chalk.cyan(\n project.projectPath,\n )}`,\n );\n const codeAdded = traceStep('Add code snippet', () => {\n const files = project.filesForTarget(target);\n if (files === undefined || files.length == 0) {\n Sentry.setTag('snippet-candidate-files-not-found', true);\n return false;\n }\n\n return codeTools.addCodeSnippetToProject(project.projectPath, files, dsn);\n });\n Sentry.setTag('Snippet-Added', codeAdded);\n debug(`Snippet added: ${chalk.cyan(codeAdded.toString())}`);\n\n if (!codeAdded) {\n clack.log.warn(\n 'Added the Sentry dependency to your project but could not add the Sentry code snippet. Please add the code snippet manually by following the docs: https://docs.sentry.io/platforms/apple/guides/ios/#configure',\n );\n }\n}\n"]}
|
|
@@ -6,7 +6,7 @@ function getRunScriptTemplate(orgSlug, projectSlug, uploadSource, includeHomebre
|
|
|
6
6
|
const includeHomebrew = includeHomebrewPath
|
|
7
7
|
? '\\nif [[ "$(uname -m)" == arm64 ]]; then\\nexport PATH="/opt/homebrew/bin:$PATH"\\nfi'
|
|
8
8
|
: '';
|
|
9
|
-
return `# This script is
|
|
9
|
+
return `# This script is responsible for uploading debug symbols and source context for Sentry.${includeHomebrew}\\nif which sentry-cli >/dev/null; then\\nexport SENTRY_ORG=${orgSlug}\\nexport SENTRY_PROJECT=${projectSlug}\\nERROR=$(sentry-cli debug-files upload ${uploadSource ? '--include-sources ' : ''}"$DWARF_DSYM_FOLDER_PATH" 2>&1 >/dev/null)\\nif [ ! $? -eq 0 ]; then\\necho "warning: sentry-cli - $ERROR"\\nfi\\nelse\\necho "warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases"\\nfi\\n`;
|
|
10
10
|
}
|
|
11
11
|
exports.getRunScriptTemplate = getRunScriptTemplate;
|
|
12
12
|
exports.scriptInputPath = '"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}"';
|
|
@@ -18,9 +18,11 @@ function getSwiftSnippet(dsn) {
|
|
|
18
18
|
// We recommend adjusting this value in production.
|
|
19
19
|
options.tracesSampleRate = 1.0
|
|
20
20
|
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
// Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.
|
|
22
|
+
options.configureProfiling = {
|
|
23
|
+
$0.sessionSampleRate = 1.0 // We recommend adjusting this value in production.
|
|
24
|
+
$0.lifecycle = .trace
|
|
25
|
+
}
|
|
24
26
|
|
|
25
27
|
// Uncomment the following lines to add more data to your events
|
|
26
28
|
// options.attachScreenshot = true // This adds a screenshot to the error events
|
|
@@ -38,9 +40,11 @@ function getObjcSnippet(dsn) {
|
|
|
38
40
|
// We recommend adjusting this value in production.
|
|
39
41
|
options.tracesSampleRate = @1.0;
|
|
40
42
|
|
|
41
|
-
//
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
// Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.
|
|
44
|
+
options.configureProfiling = ^(SentryProfileOptions *profiling) {
|
|
45
|
+
profiling.sessionSampleRate = 1.0; // We recommend adjusting this value in production.
|
|
46
|
+
profiling.lifecycle = SentryProfilingLifecycleTrace;
|
|
47
|
+
};
|
|
44
48
|
|
|
45
49
|
//Uncomment the following lines to add more data to your events
|
|
46
50
|
//options.attachScreenshot = YES; //This will add a screenshot to the error events
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/apple/templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,oBAAoB,CAClC,OAAe,EACf,WAAmB,EACnB,YAAqB,EACrB,mBAA4B;IAE5B,6CAA6C;IAC7C,MAAM,eAAe,GAAG,mBAAmB;QACzC,CAAC,CAAC,uFAAuF;QACzF,CAAC,CAAC,EAAE,CAAC;IACP,OAAO,
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/apple/templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,oBAAoB,CAClC,OAAe,EACf,WAAmB,EACnB,YAAqB,EACrB,mBAA4B;IAE5B,6CAA6C;IAC7C,MAAM,eAAe,GAAG,mBAAmB;QACzC,CAAC,CAAC,uFAAuF;QACzF,CAAC,CAAC,EAAE,CAAC;IACP,OAAO,0FAA0F,eAAe,+DAA+D,OAAO,4BAA4B,WAAW,4CAC3N,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EACxC,2OAA2O,CAAC;AAC9O,CAAC;AAbD,oDAaC;AAEY,QAAA,eAAe,GAC1B,6FAA6F,CAAC;AAEhG,SAAgB,eAAe,CAAC,GAAW;IACzC,OAAO;6BACoB,GAAG;;;;;;;;;;;;;;;;;iEAiBiC,CAAC;AAClE,CAAC;AApBD,0CAoBC;AAED,SAAgB,cAAc,CAAC,GAAW;IACxC,OAAO;0BACiB,GAAG;;;;;;;;;;;;;;;;;2DAiB8B,CAAC;AAC5D,CAAC;AApBD,wCAoBC;AAED,SAAgB,kBAAkB,CAAC,GAAW,EAAE,OAAe;IAC7D,OAAO;mBACU,GAAG;uBACC,OAAO;;MAExB,CAAC;AACP,CAAC;AAND,gDAMC","sourcesContent":["export function getRunScriptTemplate(\n orgSlug: string,\n projectSlug: string,\n uploadSource: boolean,\n includeHomebrewPath: boolean,\n): string {\n // eslint-disable-next-line no-useless-escape\n const includeHomebrew = includeHomebrewPath\n ? '\\\\nif [[ \"$(uname -m)\" == arm64 ]]; then\\\\nexport PATH=\"/opt/homebrew/bin:$PATH\"\\\\nfi'\n : '';\n return `# This script is responsible for uploading debug symbols and source context for Sentry.${includeHomebrew}\\\\nif which sentry-cli >/dev/null; then\\\\nexport SENTRY_ORG=${orgSlug}\\\\nexport SENTRY_PROJECT=${projectSlug}\\\\nERROR=$(sentry-cli debug-files upload ${\n uploadSource ? '--include-sources ' : ''\n }\"$DWARF_DSYM_FOLDER_PATH\" 2>&1 >/dev/null)\\\\nif [ ! $? -eq 0 ]; then\\\\necho \"warning: sentry-cli - $ERROR\"\\\\nfi\\\\nelse\\\\necho \"warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases\"\\\\nfi\\\\n`;\n}\n\nexport const scriptInputPath =\n '\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}\"';\n\nexport function getSwiftSnippet(dsn: string): string {\n return ` SentrySDK.start { options in\n options.dsn = \"${dsn}\"\n options.debug = true // Enabled debug when first installing is always helpful\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = 1.0\n\n // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.\n options.configureProfiling = {\n $0.sessionSampleRate = 1.0 // We recommend adjusting this value in production.\n $0.lifecycle = .trace\n }\n\n // Uncomment the following lines to add more data to your events\n // options.attachScreenshot = true // This adds a screenshot to the error events\n // options.attachViewHierarchy = true // This adds the view hierarchy to the error events\n }\n // Remove the next line after confirming that your Sentry integration is working.\n SentrySDK.capture(message: \"This app uses Sentry! :)\")\\n`;\n}\n\nexport function getObjcSnippet(dsn: string): string {\n return ` [SentrySDK startWithConfigureOptions:^(SentryOptions * options) {\n options.dsn = @\"${dsn}\";\n options.debug = YES; // Enabled debug when first installing is always helpful\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = @1.0;\n\n // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.\n options.configureProfiling = ^(SentryProfileOptions *profiling) {\n profiling.sessionSampleRate = 1.0; // We recommend adjusting this value in production.\n profiling.lifecycle = SentryProfilingLifecycleTrace;\n };\n\n //Uncomment the following lines to add more data to your events\n //options.attachScreenshot = YES; //This will add a screenshot to the error events\n //options.attachViewHierarchy = YES; //This will add the view hierarchy to the error events\n }];\n //Remove the next line after confirming that your Sentry integration is working.\n [SentrySDK captureMessage:@\"This app uses Sentry!\"];\\n`;\n}\n\nexport function getFastlaneSnippet(org: string, project: string): string {\n return ` sentry_cli(\n org_slug: '${org}',\n project_slug: '${project}',\n include_sources: true\n )`;\n}\n"]}
|
|
@@ -22,9 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
26
|
exports.XcodeProject = void 0;
|
|
30
27
|
/* eslint-disable max-lines */
|
|
@@ -32,7 +29,7 @@ exports.XcodeProject = void 0;
|
|
|
32
29
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
33
30
|
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
34
31
|
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
35
|
-
const
|
|
32
|
+
const clack = __importStar(require("@clack/prompts"));
|
|
36
33
|
const fs = __importStar(require("node:fs"));
|
|
37
34
|
const path = __importStar(require("node:path"));
|
|
38
35
|
const templates = __importStar(require("./templates"));
|
|
@@ -169,7 +166,7 @@ function addSentrySPM(proj, targetName) {
|
|
|
169
166
|
};
|
|
170
167
|
xcObjects.XCSwiftPackageProductDependency[`${sentrySPMUUID}_comment`] =
|
|
171
168
|
'Sentry';
|
|
172
|
-
|
|
169
|
+
clack.log.step('Added Sentry SPM dependency to your project');
|
|
173
170
|
}
|
|
174
171
|
function addUploadSymbolsScript(xcodeProject, sentryProject, targetName, uploadSource) {
|
|
175
172
|
const xcObjects = xcodeProject.hash.project.objects;
|
|
@@ -207,7 +204,7 @@ function addUploadSymbolsScript(xcodeProject, sentryProject, targetName, uploadS
|
|
|
207
204
|
shellPath: '/bin/sh',
|
|
208
205
|
shellScript: templates.getRunScriptTemplate(sentryProject.organization.slug, sentryProject.slug, uploadSource, isHomebrewInstalled),
|
|
209
206
|
});
|
|
210
|
-
|
|
207
|
+
clack.log.step(`Added Sentry upload script to "${targetName}" build phase`);
|
|
211
208
|
}
|
|
212
209
|
class XcodeProject {
|
|
213
210
|
projectPath;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xcode-manager.js","sourceRoot":"","sources":["../../../src/apple/xcode-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,+DAA+D;AAC/D,4DAA4D;AAC5D,sDAAsD;AACtD,+EAA+E;AAC/E,6DAAmC;AACnC,4CAA8B;AAC9B,gDAAkC;AAElC,uDAAyC;AAEzC,iCASe;AAOf,SAAS,mCAAmC,CAC1C,IAAa,EACb,UAAkB;IAElB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IAC5C,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE;QAC9B,SAAS,CAAC,eAAe,GAAG,EAAE,CAAC;KAChC;IACD,MAAM,SAAS,GAAW,MAAM,CAAC,IAAI,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,IAAI;oBACjB,CAAC,CAAC,GAAG,IAAI,GAAG,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG;oBACpD,CAAC,CAAC,IAAI,CACT,CAAC;gBACF,MAAM,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;aAC/B;SACF;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAnJD,oCAmJC","sourcesContent":["/* eslint-disable max-lines */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport type { SentryProjectData } from '../utils/types';\nimport * as templates from './templates';\n\nimport {\n project as createXcodeProject,\n type PBXBuildFile,\n type PBXGroup,\n type PBXNativeTarget,\n type PBXObjects,\n type PBXSourcesBuildPhase,\n type Project,\n type XCConfigurationList,\n} from 'xcode';\n\ninterface ProjectFile {\n key: string;\n path: string;\n}\n\nfunction setDebugInformationFormatAndSandbox(\n proj: Project,\n targetName: string,\n): void {\n const xcObjects = proj.hash.project.objects;\n if (!xcObjects.PBXNativeTarget) {\n xcObjects.PBXNativeTarget = {};\n }\n const targetKey: string = Object.keys(xcObjects.PBXNativeTarget).filter(\n (key) => {\n const value = xcObjects.PBXNativeTarget?.[key];\n return (\n !key.endsWith('_comment') &&\n typeof value !== 'string' &&\n value?.name === targetName\n );\n },\n )[0];\n const target = xcObjects.PBXNativeTarget[targetKey] as\n | PBXNativeTarget\n | undefined;\n\n if (!xcObjects.XCBuildConfiguration) {\n xcObjects.XCBuildConfiguration = {};\n }\n if (!xcObjects.XCConfigurationList) {\n xcObjects.XCConfigurationList = {};\n }\n const buildConfigurationListId = target?.buildConfigurationList ?? '';\n const configurationList = xcObjects.XCConfigurationList?.[\n buildConfigurationListId\n ] as XCConfigurationList | undefined;\n const buildListConfigurationIds =\n configurationList?.buildConfigurations ?? [];\n for (const buildListConfigId of buildListConfigurationIds) {\n const config =\n xcObjects.XCBuildConfiguration[buildListConfigId.value] ?? {};\n if (typeof config === 'string') {\n // Ignore comments\n continue;\n }\n\n const buildSettings = config.buildSettings ?? {};\n buildSettings.DEBUG_INFORMATION_FORMAT = '\"dwarf-with-dsym\"';\n buildSettings.ENABLE_USER_SCRIPT_SANDBOXING = '\"NO\"';\n\n config.buildSettings = buildSettings;\n xcObjects.XCBuildConfiguration[buildListConfigId.value] = config;\n }\n}\n\nfunction addSentrySPM(proj: Project, targetName: string): void {\n const xcObjects = proj.hash.project.objects;\n\n const sentryFrameworkUUID = proj.generateUuid();\n const sentrySPMUUID = proj.generateUuid();\n\n // Check whether xcObjects already have sentry framework\n if (xcObjects.PBXFrameworksBuildPhase) {\n for (const key in xcObjects.PBXFrameworksBuildPhase || {}) {\n const frameworkBuildPhase = xcObjects.PBXFrameworksBuildPhase[key];\n if (key.endsWith('_comment') || typeof frameworkBuildPhase === 'string') {\n // Ignore comments\n continue;\n }\n for (const framework of frameworkBuildPhase.files ?? []) {\n // We identify the Sentry framework by the comment \"Sentry in Frameworks\",\n // which is set by this manager in previous runs.\n if (framework.comment === 'Sentry in Frameworks') {\n return;\n }\n }\n }\n }\n\n if (!xcObjects.PBXBuildFile) {\n xcObjects.PBXBuildFile = {};\n }\n xcObjects.PBXBuildFile[sentryFrameworkUUID] = {\n isa: 'PBXBuildFile',\n productRef: sentrySPMUUID,\n productRef_comment: 'Sentry',\n };\n xcObjects.PBXBuildFile[`${sentryFrameworkUUID}_comment`] =\n 'Sentry in Frameworks';\n\n if (!xcObjects.PBXFrameworksBuildPhase) {\n xcObjects.PBXFrameworksBuildPhase = {};\n }\n for (const key in xcObjects.PBXFrameworksBuildPhase) {\n const value = xcObjects.PBXFrameworksBuildPhase[key];\n if (key.endsWith('_comment') || typeof value === 'string') {\n // Ignore comments\n continue;\n }\n\n const frameworks = value.files ?? [];\n frameworks.push({\n value: sentryFrameworkUUID,\n comment: 'Sentry in Frameworks',\n });\n value.files = frameworks;\n\n xcObjects.PBXFrameworksBuildPhase[key] = value;\n }\n\n if (!xcObjects.PBXNativeTarget) {\n xcObjects.PBXNativeTarget = {};\n }\n const targetKey = Object.keys(xcObjects.PBXNativeTarget || {}).filter(\n (key) => {\n const value = xcObjects.PBXNativeTarget?.[key];\n return (\n !key.endsWith('_comment') &&\n typeof value !== 'string' &&\n value?.name === targetName\n );\n },\n )[0];\n const target = xcObjects.PBXNativeTarget[targetKey] as PBXNativeTarget;\n\n if (!target.packageProductDependencies) {\n target.packageProductDependencies = [];\n }\n target.packageProductDependencies.push({\n value: sentrySPMUUID,\n comment: 'Sentry',\n });\n\n const sentrySwiftPackageUUID = proj.generateUuid();\n const xcProject = proj.getFirstProject().firstProject;\n if (!xcProject.packageReferences) {\n xcProject.packageReferences = [];\n }\n xcProject.packageReferences.push({\n value: sentrySwiftPackageUUID,\n comment: 'XCRemoteSwiftPackageReference \"sentry-cocoa\"',\n });\n\n if (!xcObjects.XCRemoteSwiftPackageReference) {\n xcObjects.XCRemoteSwiftPackageReference = {};\n }\n\n xcObjects.XCRemoteSwiftPackageReference[sentrySwiftPackageUUID] = {\n isa: 'XCRemoteSwiftPackageReference',\n repositoryURL: '\"https://github.com/getsentry/sentry-cocoa/\"',\n requirement: {\n kind: 'upToNextMajorVersion',\n minimumVersion: '8.0.0',\n },\n };\n xcObjects.XCRemoteSwiftPackageReference[`${sentrySwiftPackageUUID}_comment`] =\n 'XCRemoteSwiftPackageReference \"sentry-cocoa\"';\n\n if (!xcObjects.XCSwiftPackageProductDependency) {\n xcObjects.XCSwiftPackageProductDependency = {};\n }\n xcObjects.XCSwiftPackageProductDependency[sentrySPMUUID] = {\n isa: 'XCSwiftPackageProductDependency',\n package: sentrySwiftPackageUUID,\n package_comment: 'XCRemoteSwiftPackageReference \"sentry-cocoa\"',\n productName: 'Sentry',\n };\n xcObjects.XCSwiftPackageProductDependency[`${sentrySPMUUID}_comment`] =\n 'Sentry';\n\n clack.log.step('Added Sentry SPM dependency to your project');\n}\n\nfunction addUploadSymbolsScript(\n xcodeProject: Project,\n sentryProject: SentryProjectData,\n targetName: string,\n uploadSource: boolean,\n): void {\n const xcObjects = xcodeProject.hash.project.objects;\n if (!xcObjects.PBXNativeTarget) {\n xcObjects.PBXNativeTarget = {};\n }\n const targetKey = Object.keys(xcObjects.PBXNativeTarget).filter((key) => {\n const value = xcObjects.PBXNativeTarget?.[key];\n return (\n !key.endsWith('_comment') &&\n typeof value !== 'string' &&\n value?.name === targetName\n );\n })[0];\n\n if (!xcObjects.PBXShellScriptBuildPhase) {\n xcObjects.PBXShellScriptBuildPhase = {};\n }\n for (const key in xcObjects.PBXShellScriptBuildPhase) {\n const value = xcObjects.PBXShellScriptBuildPhase[key] ?? {};\n if (typeof value === 'string') {\n // Ignore comments\n continue;\n }\n\n // Sentry script already exists, update it\n if (value.shellScript?.includes('sentry-cli')) {\n delete xcObjects.PBXShellScriptBuildPhase?.[key];\n delete xcObjects.PBXShellScriptBuildPhase?.[`${key}_comment`];\n break;\n }\n xcObjects.PBXShellScriptBuildPhase[key] = value;\n }\n\n const isHomebrewInstalled = fs.existsSync('/opt/homebrew/bin/sentry-cli');\n xcodeProject.addBuildPhase(\n [],\n 'PBXShellScriptBuildPhase',\n 'Upload Debug Symbols to Sentry',\n targetKey,\n {\n inputFileListPaths: [],\n outputFileListPaths: [],\n inputPaths: [templates.scriptInputPath],\n shellPath: '/bin/sh',\n shellScript: templates.getRunScriptTemplate(\n sentryProject.organization.slug,\n sentryProject.slug,\n uploadSource,\n isHomebrewInstalled,\n ),\n },\n );\n clack.log.step(`Added Sentry upload script to \"${targetName}\" build phase`);\n}\n\nexport class XcodeProject {\n projectPath: string;\n project: Project;\n objects: PBXObjects;\n files: ProjectFile[] | undefined;\n\n /**\n * Creates a new XcodeProject instance, a wrapper around the Xcode project file `<PROJECT>.xcodeproj/project.pbxproj`.\n *\n * @param projectPath - The path to the Xcode project file\n */\n public constructor(projectPath: string) {\n this.projectPath = projectPath;\n this.project = createXcodeProject(projectPath);\n this.project.parseSync();\n this.objects = this.project.hash.project.objects;\n }\n\n public getAllTargets(): string[] {\n const targets = this.objects.PBXNativeTarget ?? {};\n return Object.keys(targets)\n .filter((key) => {\n const value = targets[key];\n return (\n !key.endsWith('_comment') &&\n typeof value !== 'string' &&\n value.productType.startsWith('\"com.apple.product-type.application')\n );\n })\n .map((key) => {\n return (targets[key] as PBXNativeTarget).name;\n });\n }\n\n public updateXcodeProject(\n sentryProject: SentryProjectData,\n target: string,\n addSPMReference: boolean,\n uploadSource = true,\n ): void {\n addUploadSymbolsScript(this.project, sentryProject, target, uploadSource);\n if (uploadSource) {\n setDebugInformationFormatAndSandbox(this.project, target);\n }\n if (addSPMReference) {\n addSentrySPM(this.project, target);\n }\n const newContent = this.project.writeSync();\n fs.writeFileSync(this.projectPath, newContent);\n }\n\n public filesForTarget(target: string): string[] | undefined {\n const files = this.projectFiles();\n const fileDictionary: Record<string, string> = {};\n files.forEach((file) => {\n fileDictionary[file.key] = file.path;\n });\n\n const targets = this.objects.PBXNativeTarget || {};\n const nativeTarget = Object.keys(targets).filter((key) => {\n const value = targets[key];\n return (\n !key.endsWith('_comment') &&\n typeof value !== 'string' &&\n value.name === target\n );\n })[0];\n\n if (nativeTarget === undefined) {\n return undefined;\n }\n\n const buildPhaseKey = (\n targets[nativeTarget] as PBXNativeTarget\n ).buildPhases?.filter((phase) => {\n return this.objects.PBXSourcesBuildPhase?.[phase.value] !== undefined;\n })[0];\n\n if (buildPhaseKey === undefined) {\n return undefined;\n }\n\n const buildPhase = this.objects.PBXSourcesBuildPhase?.[\n buildPhaseKey.value\n ] as PBXSourcesBuildPhase;\n const buildPhaseFiles = buildPhase?.files ?? [];\n\n const baseDir = path.dirname(path.dirname(this.projectPath));\n\n return buildPhaseFiles\n .map((file) => {\n const fileRef = (\n this.objects.PBXBuildFile?.[file.value] as PBXBuildFile\n )?.fileRef;\n if (!fileRef) {\n return '';\n }\n const buildFile = fileDictionary[fileRef];\n if (!buildFile) {\n return '';\n }\n return path.join(baseDir, buildFile);\n })\n .filter((f: string) => f.length > 0);\n }\n\n projectFiles(): ProjectFile[] {\n if (this.files === undefined) {\n const proj = this.project.getFirstProject();\n const mainGroupKey = proj.firstProject.mainGroup;\n const mainGroup = this.objects.PBXGroup?.[mainGroupKey];\n if (!mainGroup || typeof mainGroup === 'string') {\n return [];\n }\n this.files = this.buildGroup(mainGroup);\n }\n return this.files;\n }\n\n buildGroup(group: PBXGroup, path = ''): ProjectFile[] {\n const result: ProjectFile[] = [];\n for (const child of group.children ?? []) {\n const fileReference = this.objects.PBXFileReference?.[child.value];\n const groupReference = this.objects.PBXGroup?.[child.value];\n if (fileReference) {\n if (typeof fileReference === 'string') {\n continue;\n }\n result.push({\n key: child.value,\n path: `${path}${fileReference.path.replace(/\"/g, '')}`,\n });\n } else if (groupReference) {\n if (typeof groupReference === 'string') {\n continue;\n }\n const groupChildren = this.buildGroup(\n groupReference,\n groupReference.path\n ? `${path}${groupReference.path.replace(/\"/g, '')}/`\n : path,\n );\n result.push(...groupChildren);\n }\n }\n return result;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"xcode-manager.js","sourceRoot":"","sources":["../../../src/apple/xcode-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,+DAA+D;AAC/D,4DAA4D;AAC5D,sDAAsD;AACtD,+EAA+E;AAC/E,sDAAwC;AACxC,4CAA8B;AAC9B,gDAAkC;AAElC,uDAAyC;AAEzC,iCASe;AAOf,SAAS,mCAAmC,CAC1C,IAAa,EACb,UAAkB;IAElB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IAC5C,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE;QAC9B,SAAS,CAAC,eAAe,GAAG,EAAE,CAAC;KA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I,CAAC,UAAU,CACnC,cAAc,EACd,cAAc,CAAC,IAAI;oBACjB,CAAC,CAAC,GAAG,IAAI,GAAG,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG;oBACpD,CAAC,CAAC,IAAI,CACT,CAAC;gBACF,MAAM,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;aAC/B;SACF;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAnJD,oCAmJC","sourcesContent":["/* eslint-disable max-lines */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport type { SentryProjectData } from '../utils/types';\nimport * as templates from './templates';\n\nimport {\n project as createXcodeProject,\n type PBXBuildFile,\n type PBXGroup,\n type PBXNativeTarget,\n type PBXObjects,\n type PBXSourcesBuildPhase,\n type Project,\n type XCConfigurationList,\n} from 'xcode';\n\ninterface ProjectFile {\n key: string;\n path: string;\n}\n\nfunction setDebugInformationFormatAndSandbox(\n proj: Project,\n targetName: string,\n): void {\n const xcObjects = proj.hash.project.objects;\n if (!xcObjects.PBXNativeTarget) {\n xcObjects.PBXNativeTarget = {};\n }\n const targetKey: string = Object.keys(xcObjects.PBXNativeTarget).filter(\n (key) => {\n const value = xcObjects.PBXNativeTarget?.[key];\n return (\n !key.endsWith('_comment') &&\n typeof value !== 'string' &&\n value?.name === targetName\n );\n },\n )[0];\n const target = xcObjects.PBXNativeTarget[targetKey] as\n | PBXNativeTarget\n | undefined;\n\n if (!xcObjects.XCBuildConfiguration) {\n xcObjects.XCBuildConfiguration = {};\n }\n if (!xcObjects.XCConfigurationList) {\n xcObjects.XCConfigurationList = {};\n }\n const buildConfigurationListId = target?.buildConfigurationList ?? '';\n const configurationList = xcObjects.XCConfigurationList?.[\n buildConfigurationListId\n ] as XCConfigurationList | undefined;\n const buildListConfigurationIds =\n configurationList?.buildConfigurations ?? [];\n for (const buildListConfigId of buildListConfigurationIds) {\n const config =\n xcObjects.XCBuildConfiguration[buildListConfigId.value] ?? {};\n if (typeof config === 'string') {\n // Ignore comments\n continue;\n }\n\n const buildSettings = config.buildSettings ?? {};\n buildSettings.DEBUG_INFORMATION_FORMAT = '\"dwarf-with-dsym\"';\n buildSettings.ENABLE_USER_SCRIPT_SANDBOXING = '\"NO\"';\n\n config.buildSettings = buildSettings;\n xcObjects.XCBuildConfiguration[buildListConfigId.value] = config;\n }\n}\n\nfunction addSentrySPM(proj: Project, targetName: string): void {\n const xcObjects = proj.hash.project.objects;\n\n const sentryFrameworkUUID = proj.generateUuid();\n const sentrySPMUUID = proj.generateUuid();\n\n // Check whether xcObjects already have sentry framework\n if (xcObjects.PBXFrameworksBuildPhase) {\n for (const key in xcObjects.PBXFrameworksBuildPhase || {}) {\n const frameworkBuildPhase = xcObjects.PBXFrameworksBuildPhase[key];\n if (key.endsWith('_comment') || typeof frameworkBuildPhase === 'string') {\n // Ignore comments\n continue;\n }\n for (const framework of frameworkBuildPhase.files ?? []) {\n // We identify the Sentry framework by the comment \"Sentry in Frameworks\",\n // which is set by this manager in previous runs.\n if (framework.comment === 'Sentry in Frameworks') {\n return;\n }\n }\n }\n }\n\n if (!xcObjects.PBXBuildFile) {\n xcObjects.PBXBuildFile = {};\n }\n xcObjects.PBXBuildFile[sentryFrameworkUUID] = {\n isa: 'PBXBuildFile',\n productRef: sentrySPMUUID,\n productRef_comment: 'Sentry',\n };\n xcObjects.PBXBuildFile[`${sentryFrameworkUUID}_comment`] =\n 'Sentry in Frameworks';\n\n if (!xcObjects.PBXFrameworksBuildPhase) {\n xcObjects.PBXFrameworksBuildPhase = {};\n }\n for (const key in xcObjects.PBXFrameworksBuildPhase) {\n const value = xcObjects.PBXFrameworksBuildPhase[key];\n if (key.endsWith('_comment') || typeof value === 'string') {\n // Ignore comments\n continue;\n }\n\n const frameworks = value.files ?? [];\n frameworks.push({\n value: sentryFrameworkUUID,\n comment: 'Sentry in Frameworks',\n });\n value.files = frameworks;\n\n xcObjects.PBXFrameworksBuildPhase[key] = value;\n }\n\n if (!xcObjects.PBXNativeTarget) {\n xcObjects.PBXNativeTarget = {};\n }\n const targetKey = Object.keys(xcObjects.PBXNativeTarget || {}).filter(\n (key) => {\n const value = xcObjects.PBXNativeTarget?.[key];\n return (\n !key.endsWith('_comment') &&\n typeof value !== 'string' &&\n value?.name === targetName\n );\n },\n )[0];\n const target = xcObjects.PBXNativeTarget[targetKey] as PBXNativeTarget;\n\n if (!target.packageProductDependencies) {\n target.packageProductDependencies = [];\n }\n target.packageProductDependencies.push({\n value: sentrySPMUUID,\n comment: 'Sentry',\n });\n\n const sentrySwiftPackageUUID = proj.generateUuid();\n const xcProject = proj.getFirstProject().firstProject;\n if (!xcProject.packageReferences) {\n xcProject.packageReferences = [];\n }\n xcProject.packageReferences.push({\n value: sentrySwiftPackageUUID,\n comment: 'XCRemoteSwiftPackageReference \"sentry-cocoa\"',\n });\n\n if (!xcObjects.XCRemoteSwiftPackageReference) {\n xcObjects.XCRemoteSwiftPackageReference = {};\n }\n\n xcObjects.XCRemoteSwiftPackageReference[sentrySwiftPackageUUID] = {\n isa: 'XCRemoteSwiftPackageReference',\n repositoryURL: '\"https://github.com/getsentry/sentry-cocoa/\"',\n requirement: {\n kind: 'upToNextMajorVersion',\n minimumVersion: '8.0.0',\n },\n };\n xcObjects.XCRemoteSwiftPackageReference[`${sentrySwiftPackageUUID}_comment`] =\n 'XCRemoteSwiftPackageReference \"sentry-cocoa\"';\n\n if (!xcObjects.XCSwiftPackageProductDependency) {\n xcObjects.XCSwiftPackageProductDependency = {};\n }\n xcObjects.XCSwiftPackageProductDependency[sentrySPMUUID] = {\n isa: 'XCSwiftPackageProductDependency',\n package: sentrySwiftPackageUUID,\n package_comment: 'XCRemoteSwiftPackageReference \"sentry-cocoa\"',\n productName: 'Sentry',\n };\n xcObjects.XCSwiftPackageProductDependency[`${sentrySPMUUID}_comment`] =\n 'Sentry';\n\n clack.log.step('Added Sentry SPM dependency to your project');\n}\n\nfunction addUploadSymbolsScript(\n xcodeProject: Project,\n sentryProject: SentryProjectData,\n targetName: string,\n uploadSource: boolean,\n): void {\n const xcObjects = xcodeProject.hash.project.objects;\n if (!xcObjects.PBXNativeTarget) {\n xcObjects.PBXNativeTarget = {};\n }\n const targetKey = Object.keys(xcObjects.PBXNativeTarget).filter((key) => {\n const value = xcObjects.PBXNativeTarget?.[key];\n return (\n !key.endsWith('_comment') &&\n typeof value !== 'string' &&\n value?.name === targetName\n );\n })[0];\n\n if (!xcObjects.PBXShellScriptBuildPhase) {\n xcObjects.PBXShellScriptBuildPhase = {};\n }\n for (const key in xcObjects.PBXShellScriptBuildPhase) {\n const value = xcObjects.PBXShellScriptBuildPhase[key] ?? {};\n if (typeof value === 'string') {\n // Ignore comments\n continue;\n }\n\n // Sentry script already exists, update it\n if (value.shellScript?.includes('sentry-cli')) {\n delete xcObjects.PBXShellScriptBuildPhase?.[key];\n delete xcObjects.PBXShellScriptBuildPhase?.[`${key}_comment`];\n break;\n }\n xcObjects.PBXShellScriptBuildPhase[key] = value;\n }\n\n const isHomebrewInstalled = fs.existsSync('/opt/homebrew/bin/sentry-cli');\n xcodeProject.addBuildPhase(\n [],\n 'PBXShellScriptBuildPhase',\n 'Upload Debug Symbols to Sentry',\n targetKey,\n {\n inputFileListPaths: [],\n outputFileListPaths: [],\n inputPaths: [templates.scriptInputPath],\n shellPath: '/bin/sh',\n shellScript: templates.getRunScriptTemplate(\n sentryProject.organization.slug,\n sentryProject.slug,\n uploadSource,\n isHomebrewInstalled,\n ),\n },\n );\n clack.log.step(`Added Sentry upload script to \"${targetName}\" build phase`);\n}\n\nexport class XcodeProject {\n projectPath: string;\n project: Project;\n objects: PBXObjects;\n files: ProjectFile[] | undefined;\n\n /**\n * Creates a new XcodeProject instance, a wrapper around the Xcode project file `<PROJECT>.xcodeproj/project.pbxproj`.\n *\n * @param projectPath - The path to the Xcode project file\n */\n public constructor(projectPath: string) {\n this.projectPath = projectPath;\n this.project = createXcodeProject(projectPath);\n this.project.parseSync();\n this.objects = this.project.hash.project.objects;\n }\n\n public getAllTargets(): string[] {\n const targets = this.objects.PBXNativeTarget ?? {};\n return Object.keys(targets)\n .filter((key) => {\n const value = targets[key];\n return (\n !key.endsWith('_comment') &&\n typeof value !== 'string' &&\n value.productType.startsWith('\"com.apple.product-type.application')\n );\n })\n .map((key) => {\n return (targets[key] as PBXNativeTarget).name;\n });\n }\n\n public updateXcodeProject(\n sentryProject: SentryProjectData,\n target: string,\n addSPMReference: boolean,\n uploadSource = true,\n ): void {\n addUploadSymbolsScript(this.project, sentryProject, target, uploadSource);\n if (uploadSource) {\n setDebugInformationFormatAndSandbox(this.project, target);\n }\n if (addSPMReference) {\n addSentrySPM(this.project, target);\n }\n const newContent = this.project.writeSync();\n fs.writeFileSync(this.projectPath, newContent);\n }\n\n public filesForTarget(target: string): string[] | undefined {\n const files = this.projectFiles();\n const fileDictionary: Record<string, string> = {};\n files.forEach((file) => {\n fileDictionary[file.key] = file.path;\n });\n\n const targets = this.objects.PBXNativeTarget || {};\n const nativeTarget = Object.keys(targets).filter((key) => {\n const value = targets[key];\n return (\n !key.endsWith('_comment') &&\n typeof value !== 'string' &&\n value.name === target\n );\n })[0];\n\n if (nativeTarget === undefined) {\n return undefined;\n }\n\n const buildPhaseKey = (\n targets[nativeTarget] as PBXNativeTarget\n ).buildPhases?.filter((phase) => {\n return this.objects.PBXSourcesBuildPhase?.[phase.value] !== undefined;\n })[0];\n\n if (buildPhaseKey === undefined) {\n return undefined;\n }\n\n const buildPhase = this.objects.PBXSourcesBuildPhase?.[\n buildPhaseKey.value\n ] as PBXSourcesBuildPhase;\n const buildPhaseFiles = buildPhase?.files ?? [];\n\n const baseDir = path.dirname(path.dirname(this.projectPath));\n\n return buildPhaseFiles\n .map((file) => {\n const fileRef = (\n this.objects.PBXBuildFile?.[file.value] as PBXBuildFile\n )?.fileRef;\n if (!fileRef) {\n return '';\n }\n const buildFile = fileDictionary[fileRef];\n if (!buildFile) {\n return '';\n }\n return path.join(baseDir, buildFile);\n })\n .filter((f: string) => f.length > 0);\n }\n\n projectFiles(): ProjectFile[] {\n if (this.files === undefined) {\n const proj = this.project.getFirstProject();\n const mainGroupKey = proj.firstProject.mainGroup;\n const mainGroup = this.objects.PBXGroup?.[mainGroupKey];\n if (!mainGroup || typeof mainGroup === 'string') {\n return [];\n }\n this.files = this.buildGroup(mainGroup);\n }\n return this.files;\n }\n\n buildGroup(group: PBXGroup, path = ''): ProjectFile[] {\n const result: ProjectFile[] = [];\n for (const child of group.children ?? []) {\n const fileReference = this.objects.PBXFileReference?.[child.value];\n const groupReference = this.objects.PBXGroup?.[child.value];\n if (fileReference) {\n if (typeof fileReference === 'string') {\n continue;\n }\n result.push({\n key: child.value,\n path: `${path}${fileReference.path.replace(/\"/g, '')}`,\n });\n } else if (groupReference) {\n if (typeof groupReference === 'string') {\n continue;\n }\n const groupChildren = this.buildGroup(\n groupReference,\n groupReference.path\n ? `${path}${groupReference.path.replace(/\"/g, '')}/`\n : path,\n );\n result.push(...groupChildren);\n }\n }\n return result;\n }\n}\n"]}
|
|
@@ -172,7 +172,9 @@ Sentry.init({
|
|
|
172
172
|
|
|
173
173
|
// Setting this option to true will print useful information to the console while you're setting up Sentry.
|
|
174
174
|
debug: false,
|
|
175
|
-
})
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;`;
|
|
176
178
|
}
|
|
177
179
|
exports.getInstrumentationClientFileContents = getInstrumentationClientFileContents;
|
|
178
180
|
function getSentryExamplePageContents(options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/nextjs/templates.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC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,2CAA2C,CAAC;EACxD,eAAK,CAAC,KAAK,CAAC,iCAAiC,CAAC;EAC9C,eAAK,CAAC,KAAK,CAAC,oCAAoC,CAAC;;sCAEb,eAAK,CAAC,KAAK,CAAC,WAAW,CAAC;IAC1D,eAAK,CAAC,KAAK,CAAC;;eAED,CAAC;;;;;;;;;;CAUf,CAAC;AACF,CAAC;AA7CD,wEA6CC;AAEM,MAAM,aAAa,GAAG,CAC3B,IAAa,EACb,EAAE,CAAC;;;;;;;;;;GAWH,IAAI;IACF,CAAC,CAAC;;EAEJ;IACE,CAAC,CAAC,EACN;;;;;;;CAOC,CAAC;AAzBW,QAAA,aAAa,iBAyBxB","sourcesContent":["import chalk from 'chalk';\nimport { makeCodeSnippet } from '../utils/clack';\n\ntype WithSentryConfigOptions = {\n orgSlug: string;\n projectSlug: string;\n selfHosted: boolean;\n sentryUrl: string;\n tunnelRoute: boolean;\n};\n\nexport function getWithSentryConfigOptionsTemplate({\n orgSlug,\n projectSlug,\n selfHosted,\n tunnelRoute,\n sentryUrl,\n}: WithSentryConfigOptions): string {\n return `{\n // For all available options, see:\n // https://www.npmjs.com/package/@sentry/webpack-plugin#options\n\n org: \"${orgSlug}\",\n project: \"${projectSlug}\",${\n selfHosted ? `\\n sentryUrl: \"${sentryUrl}\",` : ''\n }\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 // 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 getNextjsConfigMjsTemplate(\n withSentryConfigOptionsTemplate: string,\n): string {\n return `import { withSentryConfig } from \"@sentry/nextjs\";\n\n/** @type {import('next').NextConfig} */\nconst nextConfig = {};\n\nexport default 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\nfunction getClientIntegrationsSnippet(features: { replay: boolean }) {\n if (features.replay) {\n return `\n\n // Add optional integrations for additional features\n integrations: [\n Sentry.replayIntegration(),\n ],`;\n }\n\n return '';\n}\n\nexport function getSentryServersideConfigContents(\n dsn: string,\n config: 'server' | 'edge',\n selectedFeaturesMap: {\n replay: boolean;\n performance: boolean;\n },\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 === '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 performanceOptions = '';\n if (selectedFeaturesMap.performance) {\n performanceOptions += `\n\n // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.\n tracesSampleRate: 1,`;\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}\",${performanceOptions}\n\n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n});\n`;\n}\n\nexport function getInstrumentationClientFileContents(\n dsn: string,\n selectedFeaturesMap: {\n replay: boolean;\n performance: boolean;\n },\n): string {\n const integrationsOptions = getClientIntegrationsSnippet({\n replay: selectedFeaturesMap.replay,\n });\n\n let replayOptions = '';\n\n if (selectedFeaturesMap.replay) {\n replayOptions += `\n\n // Define how likely Replay events are sampled.\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 // Define how likely Replay events are sampled when an error occurs.\n replaysOnErrorSampleRate: 1.0,`;\n }\n\n let performanceOptions = '';\n if (selectedFeaturesMap.performance) {\n performanceOptions += `\n\n // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.\n tracesSampleRate: 1,`;\n }\n\n return `// This file configures the initialization of Sentry on the client.\n// The added config here will be used whenever a users loads a page in their browser.\n// https://docs.sentry.io/platforms/javascript/guides/nextjs/\n\nimport * as Sentry from \"@sentry/nextjs\";\n\nSentry.init({\n dsn: \"${dsn}\",${integrationsOptions}${performanceOptions}${replayOptions}\n\n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n});`;\n}\n\nexport function getSentryExamplePageContents(options: {\n selfHosted: boolean;\n sentryUrl: string;\n orgSlug: string;\n projectId: string;\n useClient: boolean;\n}): string {\n const issuesPageLink = options.selfHosted\n ? `${options.sentryUrl}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\";\nimport { useState } from \"react\";\n\nexport default function Page() {\n const [hasSentError, setHasSentError] = useState(false);\n\n return (\n <div>\n <Head>\n <title>sentry-example-page</title>\n <meta name=\"description\" content=\"Test Sentry for your Next.js app!\" />\n </Head>\n\n <main>\n <div className=\"flex-spacer\" />\n <svg height=\"40\" width=\"40\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M21.85 2.995a3.698 3.698 0 0 1 1.353 1.354l16.303 28.278a3.703 3.703 0 0 1-1.354 5.053 3.694 3.694 0 0 1-1.848.496h-3.828a31.149 31.149 0 0 0 0-3.09h3.815a.61.61 0 0 0 .537-.917L20.523 5.893a.61.61 0 0 0-1.057 0l-3.739 6.494a28.948 28.948 0 0 1 9.63 10.453 28.988 28.988 0 0 1 3.499 13.78v1.542h-9.852v-1.544a19.106 19.106 0 0 0-2.182-8.85 19.08 19.08 0 0 0-6.032-6.829l-1.85 3.208a15.377 15.377 0 0 1 6.382 12.484v1.542H3.696A3.694 3.694 0 0 1 0 34.473c0-.648.17-1.286.494-1.849l2.33-4.074a8.562 8.562 0 0 1 2.689 1.536L3.158 34.17a.611.611 0 0 0 .538.917h8.448a12.481 12.481 0 0 0-6.037-9.09l-1.344-.772 4.908-8.545 1.344.77a22.16 22.16 0 0 1 7.705 7.444 22.193 22.193 0 0 1 3.316 10.193h3.699a25.892 25.892 0 0 0-3.811-12.033 25.856 25.856 0 0 0-9.046-8.796l-1.344-.772 5.269-9.136a3.698 3.698 0 0 1 3.2-1.849c.648 0 1.285.17 1.847.495Z\" fill=\"currentcolor\"/>\n </svg>\n <h1>\n sentry-example-page\n </h1>\n\n <p className=\"description\">\n Click the button below, and view the sample error on the Sentry <a target=\"_blank\" href=\"${issuesPageLink}\">Issues Page</a>.\n For more details about setting up Sentry, <a target=\"_blank\" href=\"https://docs.sentry.io/platforms/javascript/guides/nextjs/\">read our docs</a>.\n </p>\n\n <button\n type=\"button\"\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 setHasSentError(true);\n throw new Error(\"Sentry Example Frontend Error\");\n }\n });\n }}\n >\n <span>\n Throw Sample Error\n </span>\n </button>\n\n {hasSentError ? (\n <p className=\"success\">\n Sample error was sent to Sentry.\n </p>\n ) : (\n <div className=\"success_placeholder\" />\n )}\n\n <div className=\"flex-spacer\" />\n <p className=\"description\">\n Adblockers will prevent errors from being sent to Sentry.\n </p>\n </main>\n\n <style>{\\`\n main {\n display: flex;\n min-height: 100vh;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n gap: 16px;\n padding: 16px;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", sans-serif;\n }\n\n h1 {\n padding: 0px 4px;\n border-radius: 4px;\n background-color: rgba(24, 20, 35, 0.03);\n font-family: monospace;\n font-size: 20px;\n line-height: 1.2;\n }\n\n p {\n margin: 0;\n font-size: 20px;\n }\n\n a {\n color: #6341F0;\n text-decoration: underline;\n cursor: pointer;\n\n @media (prefers-color-scheme: dark) {\n color: #B3A1FF;\n }\n }\n\n button {\n border-radius: 8px;\n color: white;\n cursor: pointer;\n background-color: #553DB8;\n border: none;\n padding: 0;\n margin-top: 4px;\n\n & > span {\n display: inline-block;\n padding: 12px 16px;\n border-radius: inherit;\n font-size: 20px;\n font-weight: bold;\n line-height: 1;\n background-color: #7553FF;\n border: 1px solid #553DB8;\n transform: translateY(-4px);\n }\n\n &:hover > span {\n transform: translateY(-8px);\n }\n\n &:active > span {\n transform: translateY(0);\n }\n }\n\n .description {\n text-align: center;\n color: #6E6C75;\n max-width: 500px;\n line-height: 1.5;\n font-size: 20px;\n\n @media (prefers-color-scheme: dark) {\n color: #A49FB5;\n }\n }\n\n .flex-spacer {\n flex: 1;\n }\n\n .success {\n padding: 12px 16px;\n border-radius: 8px;\n font-size: 20px;\n line-height: 1;\n background-color: #00F261;\n border: 1px solid #00BF4D;\n color: #181423;\n }\n\n .success_placeholder {\n height: 46px;\n }\n \\`}</style>\n </div>\n );\n}\n`;\n}\n\nexport function getSentryExamplePagesDirApiRoute() {\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${chalk.green(`import Error from \"next/error\";`)}\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 return Error.getInitialProps(contextData);\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 }\nimport Error from \"next/error\";\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 return Error.getInitialProps(contextData);\n};\n`;\n}\n\nexport function getInstrumentationHookContent(\n instrumentationHookLocation: 'src' | 'root',\n) {\n return `import * as Sentry from '@sentry/nextjs';\n\nexport 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\nexport const onRequestError = Sentry.captureRequestError;\n`;\n}\n\nexport function getInstrumentationHookCopyPasteSnippet(\n instrumentationHookLocation: 'src' | 'root',\n) {\n return makeCodeSnippet(true, (unchanged, plus) => {\n return unchanged(`${plus(\"import * as Sentry from '@sentry/nextjs';\")}\n\nexport ${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${plus('export const onRequestError = Sentry.captureRequestError;')}\n`);\n });\n}\n\nexport function getInstrumentationClientHookCopyPasteSnippet(\n dsn: string,\n selectedFeaturesMap: {\n replay: boolean;\n performance: boolean;\n },\n) {\n return makeCodeSnippet(true, (unchanged, plus) => {\n return plus(getInstrumentationClientFileContents(dsn, selectedFeaturesMap));\n });\n}\n\nexport function getSentryDefaultGlobalErrorPage(isTs: boolean) {\n return isTs\n ? `\"use client\";\n\nimport * as Sentry from \"@sentry/nextjs\";\nimport NextError from \"next/error\";\nimport { useEffect } from \"react\";\n\nexport default function GlobalError({ error }: { error: Error & { digest?: string } }) {\n useEffect(() => {\n Sentry.captureException(error);\n }, [error]);\n\n return (\n <html>\n <body>\n {/* \\`NextError\\` is the default Next.js error page component. Its type\n definition requires a \\`statusCode\\` prop. However, since the App Router\n does not expose status codes for errors, we simply pass 0 to render a\n generic error message. */}\n <NextError statusCode={0} />\n </body>\n </html>\n );\n}`\n : `\"use client\";\n\nimport * as Sentry from \"@sentry/nextjs\";\nimport NextError 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 {/* \\`NextError\\` is the default Next.js error page component. Its type\n definition requires a \\`statusCode\\` prop. However, since the App Router\n does not expose status codes for errors, we simply pass 0 to render a\n generic error message. */}\n <NextError statusCode={0} />\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 }\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\nexport const getRootLayout = (\n isTs: boolean,\n) => `// This file was generated by the Sentry wizard because we couldn't find a root layout file.\n// You can delete this file at any time.\n\nexport const metadata = {\n title: 'Sentry NextJS Example',\n description: 'Generated by Sentry',\n}\n\nexport default function RootLayout({\n children,\n}${\n isTs\n ? `: {\n children: React.ReactNode\n}`\n : ''\n}) {\n return (\n <html lang=\"en\">\n <body>{children}</body>\n </html>\n )\n}\n`;\n"]}
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/nextjs/templates.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,0CAAiD;AAUjD,SAAgB,kCAAkC,CAAC,EACjD,OAAO,EACP,WAAW,EACX,UAAU,EACV,WAAW,EACX,SAAS,GACe;IACxB,OAAO;;;;YAIG,OAAO;gBACH,WAAW,KACvB,UAAU,CAAC,CAAC,CAAC,qBAAqB,SAAS,IAAI,CAAC,CAAC,CAAC,EACpD;;;;;;;;;;;SAYI,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,oBAC1B;;;;MAIE,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK;;;;;;;;;;IAU1B,CAAC;AACL,CAAC;AA1CD,gFA0CC;AAED,SAAgB,0BAA0B,CACxC,+BAAuC;IAEvC,OAAO;;;;;;;IAOL,+BAA+B;;CAElC,CAAC;AACF,CAAC;AAbD,gEAaC;AAED,SAAgB,0BAA0B,CACxC,+BAAuC;IAEvC,OAAO;;;;;;;IAOL,+BAA+B;;CAElC,CAAC;AACF,CAAC;AAbD,gEAaC;AAED,SAAgB,0BAA0B,CACxC,+BAAuC;IAEvC,OAAO;;;;;;;;IAQL,+BAA+B;;CAElC,CAAC;AACF,CAAC;AAdD,gEAcC;AAED,SAAgB,kCAAkC,CAChD,+BAAuC;IAEv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;;;;;;;;;;;;;;EAsBJ;QACE,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;CAuBL,CAAC;AACF,CAAC;AAjDD,0EAiDC;AAED,SAAgB,8BAA8B,CAAC,IAAa;IAC1D,IAAI,IAAI,EAAE;QACR,OAAO;;EAET,eAAK,CAAC,KAAK,CAAC,2CAA2C,CAAC;EACxD,eAAK,CAAC,KAAK,CAAC,iCAAiC,CAAC;EAC9C,eAAK,CAAC,KAAK,CAAC,oCAAoC,CAAC;;sCAEb,eAAK,CAAC,KAAK,CAC3C,6BAA6B,CAC9B;IACD,eAAK,CAAC,KAAK,CAAC;;eAED,CAAC;;;;;;;;;;CAUf,CAAC;KACC;IACD,OAAO;;EAEP,eAAK,CAAC,KAAK,CAAC,2CAA2C,CAAC;EACxD,eAAK,CAAC,KAAK,CAAC,iCAAiC,CAAC;EAC9C,eAAK,CAAC,KAAK,CAAC,oCAAoC,CAAC;;sCAEb,eAAK,CAAC,KAAK,CAAC,WAAW,CAAC;IAC1D,eAAK,CAAC,KAAK,CAAC;;eAED,CAAC;;;;;;;;;;CAUf,CAAC;AACF,CAAC;AA7CD,wEA6CC;AAEM,MAAM,aAAa,GAAG,CAC3B,IAAa,EACb,EAAE,CAAC;;;;;;;;;;GAWH,IAAI;IACF,CAAC,CAAC;;EAEJ;IACE,CAAC,CAAC,EACN;;;;;;;CAOC,CAAC;AAzBW,QAAA,aAAa,iBAyBxB","sourcesContent":["import chalk from 'chalk';\nimport { makeCodeSnippet } from '../utils/clack';\n\ntype WithSentryConfigOptions = {\n orgSlug: string;\n projectSlug: string;\n selfHosted: boolean;\n sentryUrl: string;\n tunnelRoute: boolean;\n};\n\nexport function getWithSentryConfigOptionsTemplate({\n orgSlug,\n projectSlug,\n selfHosted,\n tunnelRoute,\n sentryUrl,\n}: WithSentryConfigOptions): string {\n return `{\n // For all available options, see:\n // https://www.npmjs.com/package/@sentry/webpack-plugin#options\n\n org: \"${orgSlug}\",\n project: \"${projectSlug}\",${\n selfHosted ? `\\n sentryUrl: \"${sentryUrl}\",` : ''\n }\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 // 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 getNextjsConfigMjsTemplate(\n withSentryConfigOptionsTemplate: string,\n): string {\n return `import { withSentryConfig } from \"@sentry/nextjs\";\n\n/** @type {import('next').NextConfig} */\nconst nextConfig = {};\n\nexport default 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\nfunction getClientIntegrationsSnippet(features: { replay: boolean }) {\n if (features.replay) {\n return `\n\n // Add optional integrations for additional features\n integrations: [\n Sentry.replayIntegration(),\n ],`;\n }\n\n return '';\n}\n\nexport function getSentryServersideConfigContents(\n dsn: string,\n config: 'server' | 'edge',\n selectedFeaturesMap: {\n replay: boolean;\n performance: boolean;\n },\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 === '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 performanceOptions = '';\n if (selectedFeaturesMap.performance) {\n performanceOptions += `\n\n // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.\n tracesSampleRate: 1,`;\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}\",${performanceOptions}\n\n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n});\n`;\n}\n\nexport function getInstrumentationClientFileContents(\n dsn: string,\n selectedFeaturesMap: {\n replay: boolean;\n performance: boolean;\n },\n): string {\n const integrationsOptions = getClientIntegrationsSnippet({\n replay: selectedFeaturesMap.replay,\n });\n\n let replayOptions = '';\n\n if (selectedFeaturesMap.replay) {\n replayOptions += `\n\n // Define how likely Replay events are sampled.\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 // Define how likely Replay events are sampled when an error occurs.\n replaysOnErrorSampleRate: 1.0,`;\n }\n\n let performanceOptions = '';\n if (selectedFeaturesMap.performance) {\n performanceOptions += `\n\n // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.\n tracesSampleRate: 1,`;\n }\n\n return `// This file configures the initialization of Sentry on the client.\n// The added config here will be used whenever a users loads a page in their browser.\n// https://docs.sentry.io/platforms/javascript/guides/nextjs/\n\nimport * as Sentry from \"@sentry/nextjs\";\n\nSentry.init({\n dsn: \"${dsn}\",${integrationsOptions}${performanceOptions}${replayOptions}\n\n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n});\n\nexport const onRouterTransitionStart = Sentry.captureRouterTransitionStart;`;\n}\n\nexport function getSentryExamplePageContents(options: {\n selfHosted: boolean;\n sentryUrl: string;\n orgSlug: string;\n projectId: string;\n useClient: boolean;\n}): string {\n const issuesPageLink = options.selfHosted\n ? `${options.sentryUrl}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\";\nimport { useState } from \"react\";\n\nexport default function Page() {\n const [hasSentError, setHasSentError] = useState(false);\n\n return (\n <div>\n <Head>\n <title>sentry-example-page</title>\n <meta name=\"description\" content=\"Test Sentry for your Next.js app!\" />\n </Head>\n\n <main>\n <div className=\"flex-spacer\" />\n <svg height=\"40\" width=\"40\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M21.85 2.995a3.698 3.698 0 0 1 1.353 1.354l16.303 28.278a3.703 3.703 0 0 1-1.354 5.053 3.694 3.694 0 0 1-1.848.496h-3.828a31.149 31.149 0 0 0 0-3.09h3.815a.61.61 0 0 0 .537-.917L20.523 5.893a.61.61 0 0 0-1.057 0l-3.739 6.494a28.948 28.948 0 0 1 9.63 10.453 28.988 28.988 0 0 1 3.499 13.78v1.542h-9.852v-1.544a19.106 19.106 0 0 0-2.182-8.85 19.08 19.08 0 0 0-6.032-6.829l-1.85 3.208a15.377 15.377 0 0 1 6.382 12.484v1.542H3.696A3.694 3.694 0 0 1 0 34.473c0-.648.17-1.286.494-1.849l2.33-4.074a8.562 8.562 0 0 1 2.689 1.536L3.158 34.17a.611.611 0 0 0 .538.917h8.448a12.481 12.481 0 0 0-6.037-9.09l-1.344-.772 4.908-8.545 1.344.77a22.16 22.16 0 0 1 7.705 7.444 22.193 22.193 0 0 1 3.316 10.193h3.699a25.892 25.892 0 0 0-3.811-12.033 25.856 25.856 0 0 0-9.046-8.796l-1.344-.772 5.269-9.136a3.698 3.698 0 0 1 3.2-1.849c.648 0 1.285.17 1.847.495Z\" fill=\"currentcolor\"/>\n </svg>\n <h1>\n sentry-example-page\n </h1>\n\n <p className=\"description\">\n Click the button below, and view the sample error on the Sentry <a target=\"_blank\" href=\"${issuesPageLink}\">Issues Page</a>.\n For more details about setting up Sentry, <a target=\"_blank\" href=\"https://docs.sentry.io/platforms/javascript/guides/nextjs/\">read our docs</a>.\n </p>\n\n <button\n type=\"button\"\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 setHasSentError(true);\n throw new Error(\"Sentry Example Frontend Error\");\n }\n });\n }}\n >\n <span>\n Throw Sample Error\n </span>\n </button>\n\n {hasSentError ? (\n <p className=\"success\">\n Sample error was sent to Sentry.\n </p>\n ) : (\n <div className=\"success_placeholder\" />\n )}\n\n <div className=\"flex-spacer\" />\n <p className=\"description\">\n Adblockers will prevent errors from being sent to Sentry.\n </p>\n </main>\n\n <style>{\\`\n main {\n display: flex;\n min-height: 100vh;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n gap: 16px;\n padding: 16px;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", sans-serif;\n }\n\n h1 {\n padding: 0px 4px;\n border-radius: 4px;\n background-color: rgba(24, 20, 35, 0.03);\n font-family: monospace;\n font-size: 20px;\n line-height: 1.2;\n }\n\n p {\n margin: 0;\n font-size: 20px;\n }\n\n a {\n color: #6341F0;\n text-decoration: underline;\n cursor: pointer;\n\n @media (prefers-color-scheme: dark) {\n color: #B3A1FF;\n }\n }\n\n button {\n border-radius: 8px;\n color: white;\n cursor: pointer;\n background-color: #553DB8;\n border: none;\n padding: 0;\n margin-top: 4px;\n\n & > span {\n display: inline-block;\n padding: 12px 16px;\n border-radius: inherit;\n font-size: 20px;\n font-weight: bold;\n line-height: 1;\n background-color: #7553FF;\n border: 1px solid #553DB8;\n transform: translateY(-4px);\n }\n\n &:hover > span {\n transform: translateY(-8px);\n }\n\n &:active > span {\n transform: translateY(0);\n }\n }\n\n .description {\n text-align: center;\n color: #6E6C75;\n max-width: 500px;\n line-height: 1.5;\n font-size: 20px;\n\n @media (prefers-color-scheme: dark) {\n color: #A49FB5;\n }\n }\n\n .flex-spacer {\n flex: 1;\n }\n\n .success {\n padding: 12px 16px;\n border-radius: 8px;\n font-size: 20px;\n line-height: 1;\n background-color: #00F261;\n border: 1px solid #00BF4D;\n color: #181423;\n }\n\n .success_placeholder {\n height: 46px;\n }\n \\`}</style>\n </div>\n );\n}\n`;\n}\n\nexport function getSentryExamplePagesDirApiRoute() {\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${chalk.green(`import Error from \"next/error\";`)}\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 return Error.getInitialProps(contextData);\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 }\nimport Error from \"next/error\";\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 return Error.getInitialProps(contextData);\n};\n`;\n}\n\nexport function getInstrumentationHookContent(\n instrumentationHookLocation: 'src' | 'root',\n) {\n return `import * as Sentry from '@sentry/nextjs';\n\nexport 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\nexport const onRequestError = Sentry.captureRequestError;\n`;\n}\n\nexport function getInstrumentationHookCopyPasteSnippet(\n instrumentationHookLocation: 'src' | 'root',\n) {\n return makeCodeSnippet(true, (unchanged, plus) => {\n return unchanged(`${plus(\"import * as Sentry from '@sentry/nextjs';\")}\n\nexport ${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${plus('export const onRequestError = Sentry.captureRequestError;')}\n`);\n });\n}\n\nexport function getInstrumentationClientHookCopyPasteSnippet(\n dsn: string,\n selectedFeaturesMap: {\n replay: boolean;\n performance: boolean;\n },\n) {\n return makeCodeSnippet(true, (unchanged, plus) => {\n return plus(getInstrumentationClientFileContents(dsn, selectedFeaturesMap));\n });\n}\n\nexport function getSentryDefaultGlobalErrorPage(isTs: boolean) {\n return isTs\n ? `\"use client\";\n\nimport * as Sentry from \"@sentry/nextjs\";\nimport NextError from \"next/error\";\nimport { useEffect } from \"react\";\n\nexport default function GlobalError({ error }: { error: Error & { digest?: string } }) {\n useEffect(() => {\n Sentry.captureException(error);\n }, [error]);\n\n return (\n <html>\n <body>\n {/* \\`NextError\\` is the default Next.js error page component. Its type\n definition requires a \\`statusCode\\` prop. However, since the App Router\n does not expose status codes for errors, we simply pass 0 to render a\n generic error message. */}\n <NextError statusCode={0} />\n </body>\n </html>\n );\n}`\n : `\"use client\";\n\nimport * as Sentry from \"@sentry/nextjs\";\nimport NextError 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 {/* \\`NextError\\` is the default Next.js error page component. Its type\n definition requires a \\`statusCode\\` prop. However, since the App Router\n does not expose status codes for errors, we simply pass 0 to render a\n generic error message. */}\n <NextError statusCode={0} />\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 }\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\nexport const getRootLayout = (\n isTs: boolean,\n) => `// This file was generated by the Sentry wizard because we couldn't find a root layout file.\n// You can delete this file at any time.\n\nexport const metadata = {\n title: 'Sentry NextJS Example',\n description: 'Generated by Sentry',\n}\n\nexport default function RootLayout({\n children,\n}${\n isTs\n ? `: {\n children: React.ReactNode\n}`\n : ''\n}) {\n return (\n <html lang=\"en\">\n <body>{children}</body>\n </html>\n )\n}\n`;\n"]}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { ProxifiedModule } from 'magicast';
|
|
2
2
|
import * as t from '@babel/types';
|
|
3
|
-
export declare function addSentryInit({ dsn }: {
|
|
3
|
+
export declare function addSentryInit({ dsn, enableSessionReplay, }: {
|
|
4
4
|
dsn: string;
|
|
5
|
+
enableSessionReplay?: boolean;
|
|
5
6
|
}): Promise<void>;
|
|
6
|
-
export declare function addSentryInitWithSdkImport(js: string, { dsn }: {
|
|
7
|
+
export declare function addSentryInitWithSdkImport(js: string, { dsn, enableSessionReplay, }: {
|
|
7
8
|
dsn: string;
|
|
9
|
+
enableSessionReplay?: boolean;
|
|
8
10
|
}): string;
|
|
9
11
|
export declare function doesJsCodeIncludeSdkSentryImport(js: string, { sdkPackageName }: {
|
|
10
12
|
sdkPackageName: string;
|
|
11
13
|
}): boolean;
|
|
12
|
-
export declare function getSentryInitColoredCodeSnippet(dsn: string): string;
|
|
13
|
-
export declare function getSentryInitPlainTextSnippet(dsn: string): string;
|
|
14
|
+
export declare function getSentryInitColoredCodeSnippet(dsn: string, enableSessionReplay?: boolean): string;
|
|
15
|
+
export declare function getSentryInitPlainTextSnippet(dsn: string, enableSessionReplay?: boolean): string;
|
|
14
16
|
/**
|
|
15
17
|
* This step should be executed after `addSentryInit`
|
|
16
18
|
*/
|
|
@@ -42,12 +42,14 @@ const react_native_wizard_1 = require("./react-native-wizard");
|
|
|
42
42
|
// @ts-expect-error - magicast is ESM and TS complains about that. It works though
|
|
43
43
|
const magicast_1 = require("magicast");
|
|
44
44
|
const t = __importStar(require("@babel/types"));
|
|
45
|
-
|
|
45
|
+
const sessionReplaySampleRate = 0.1;
|
|
46
|
+
const sessionReplayOnErrorSampleRate = 1.0;
|
|
47
|
+
async function addSentryInit({ dsn, enableSessionReplay = false, }) {
|
|
46
48
|
const jsPath = getMainAppFilePath();
|
|
47
49
|
Sentry.setTag('app-js-file-status', jsPath ? 'found' : 'not-found');
|
|
48
50
|
if (!jsPath) {
|
|
49
51
|
prompts_1.default.log.warn(`Could not find main App file. Place the following code snippet close to the Apps Root component.`);
|
|
50
|
-
await (0, clack_1.showCopyPasteInstructions)('App.js or _layout.tsx', getSentryInitColoredCodeSnippet(dsn), 'This ensures the Sentry SDK is ready to capture errors.');
|
|
52
|
+
await (0, clack_1.showCopyPasteInstructions)('App.js or _layout.tsx', getSentryInitColoredCodeSnippet(dsn, enableSessionReplay), 'This ensures the Sentry SDK is ready to capture errors.');
|
|
51
53
|
return;
|
|
52
54
|
}
|
|
53
55
|
const jsRelativePath = path.relative(process.cwd(), jsPath);
|
|
@@ -60,8 +62,15 @@ async function addSentryInit({ dsn }) {
|
|
|
60
62
|
prompts_1.default.log.warn(`${chalk_1.default.cyan(jsRelativePath)} already includes Sentry. We wont't add it again.`);
|
|
61
63
|
return;
|
|
62
64
|
}
|
|
65
|
+
if (enableSessionReplay) {
|
|
66
|
+
prompts_1.default.log.info(`Session Replay will be enabled with default settings (replaysSessionSampleRate: ${sessionReplaySampleRate}, replaysOnErrorSampleRate: ${sessionReplayOnErrorSampleRate}).`);
|
|
67
|
+
prompts_1.default.log.message('By default, all text content, images, and webviews will be masked for privacy. You can customize this in your code later.');
|
|
68
|
+
}
|
|
63
69
|
(0, telemetry_1.traceStep)('add-sentry-init', () => {
|
|
64
|
-
const newContent = addSentryInitWithSdkImport(js, {
|
|
70
|
+
const newContent = addSentryInitWithSdkImport(js, {
|
|
71
|
+
dsn,
|
|
72
|
+
enableSessionReplay,
|
|
73
|
+
});
|
|
65
74
|
prompts_1.default.log.success(`Added ${chalk_1.default.cyan('Sentry.init')} to ${chalk_1.default.cyan(jsRelativePath)}.`);
|
|
66
75
|
fs.writeFileSync(jsPath, newContent, 'utf-8');
|
|
67
76
|
});
|
|
@@ -69,27 +78,34 @@ async function addSentryInit({ dsn }) {
|
|
|
69
78
|
prompts_1.default.log.success(chalk_1.default.green(`${chalk_1.default.cyan(jsRelativePath)} changes saved.`));
|
|
70
79
|
}
|
|
71
80
|
exports.addSentryInit = addSentryInit;
|
|
72
|
-
function addSentryInitWithSdkImport(js, { dsn }) {
|
|
81
|
+
function addSentryInitWithSdkImport(js, { dsn, enableSessionReplay = false, }) {
|
|
73
82
|
return js.replace(/^([^]*)(import\s+[^;]*?;$)/m, (match) => `${match}
|
|
74
|
-
${getSentryInitPlainTextSnippet(dsn)}`);
|
|
83
|
+
${getSentryInitPlainTextSnippet(dsn, enableSessionReplay)}`);
|
|
75
84
|
}
|
|
76
85
|
exports.addSentryInitWithSdkImport = addSentryInitWithSdkImport;
|
|
77
86
|
function doesJsCodeIncludeSdkSentryImport(js, { sdkPackageName }) {
|
|
78
87
|
return !!js.match(sdkPackageName);
|
|
79
88
|
}
|
|
80
89
|
exports.doesJsCodeIncludeSdkSentryImport = doesJsCodeIncludeSdkSentryImport;
|
|
81
|
-
function getSentryInitColoredCodeSnippet(dsn) {
|
|
90
|
+
function getSentryInitColoredCodeSnippet(dsn, enableSessionReplay = false) {
|
|
82
91
|
return (0, clack_1.makeCodeSnippet)(true, (_unchanged, plus, _minus) => {
|
|
83
|
-
return plus(getSentryInitPlainTextSnippet(dsn));
|
|
92
|
+
return plus(getSentryInitPlainTextSnippet(dsn, enableSessionReplay));
|
|
84
93
|
});
|
|
85
94
|
}
|
|
86
95
|
exports.getSentryInitColoredCodeSnippet = getSentryInitColoredCodeSnippet;
|
|
87
|
-
function getSentryInitPlainTextSnippet(dsn) {
|
|
96
|
+
function getSentryInitPlainTextSnippet(dsn, enableSessionReplay = false) {
|
|
88
97
|
return `import * as Sentry from '@sentry/react-native';
|
|
89
98
|
|
|
90
99
|
Sentry.init({
|
|
91
100
|
dsn: '${dsn}',
|
|
92
|
-
|
|
101
|
+
${enableSessionReplay
|
|
102
|
+
? `
|
|
103
|
+
// Configure Session Replay
|
|
104
|
+
replaysSessionSampleRate: ${sessionReplaySampleRate},
|
|
105
|
+
replaysOnErrorSampleRate: ${sessionReplayOnErrorSampleRate},
|
|
106
|
+
integrations: [Sentry.mobileReplayIntegration()],
|
|
107
|
+
`
|
|
108
|
+
: ''}
|
|
93
109
|
// uncomment the line below to enable Spotlight (https://spotlightjs.com)
|
|
94
110
|
// spotlight: __DEV__,
|
|
95
111
|
});`;
|