@sentry/wizard 3.1.0-beta.0 → 3.2.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 +17 -2
- package/bin.ts +5 -1
- package/dist/bin.js +6 -1
- package/dist/bin.js.map +1 -1
- package/dist/lib/Constants.d.ts +2 -1
- package/dist/lib/Constants.js +5 -0
- package/dist/lib/Constants.js.map +1 -1
- package/dist/lib/Helper/File.js +25 -2
- package/dist/lib/Helper/File.js.map +1 -1
- package/dist/lib/Helper/Git.d.ts +7 -0
- package/dist/lib/Helper/Git.js +94 -0
- package/dist/lib/Helper/Git.js.map +1 -0
- package/dist/lib/Helper/Logging.d.ts +1 -0
- package/dist/lib/Helper/Logging.js +9 -2
- package/dist/lib/Helper/Logging.js.map +1 -1
- package/dist/lib/Helper/MergeConfig.js +24 -1
- package/dist/lib/Helper/MergeConfig.js.map +1 -1
- package/dist/lib/Helper/Package.d.ts +9 -0
- package/dist/lib/Helper/Package.js +39 -2
- package/dist/lib/Helper/Package.js.map +1 -1
- package/dist/lib/Helper/PackageManager.d.ts +1 -1
- package/dist/lib/Helper/PackageManager.js +32 -11
- package/dist/lib/Helper/PackageManager.js.map +1 -1
- package/dist/lib/Helper/SentryCli.d.ts +11 -0
- package/dist/lib/Helper/SentryCli.js +141 -2
- package/dist/lib/Helper/SentryCli.js.map +1 -1
- package/dist/lib/Helper/Wizard.js +24 -1
- package/dist/lib/Helper/Wizard.js.map +1 -1
- package/dist/lib/Helper/__tests__/MergeConfig.js +25 -2
- package/dist/lib/Helper/__tests__/MergeConfig.js.map +1 -1
- package/dist/lib/Setup.js +25 -2
- package/dist/lib/Setup.js.map +1 -1
- package/dist/lib/Steps/ChooseIntegration.js +28 -1
- package/dist/lib/Steps/ChooseIntegration.js.map +1 -1
- package/dist/lib/Steps/Initial.js +25 -2
- package/dist/lib/Steps/Initial.js.map +1 -1
- package/dist/lib/Steps/Integrations/BaseIntegration.js +24 -1
- package/dist/lib/Steps/Integrations/BaseIntegration.js.map +1 -1
- package/dist/lib/Steps/Integrations/Cordova.js +25 -2
- package/dist/lib/Steps/Integrations/Cordova.js.map +1 -1
- package/dist/lib/Steps/Integrations/Electron.js +26 -3
- package/dist/lib/Steps/Integrations/Electron.js.map +1 -1
- package/dist/lib/Steps/Integrations/MobileProject.js +24 -1
- package/dist/lib/Steps/Integrations/MobileProject.js.map +1 -1
- package/dist/lib/Steps/Integrations/NextJs.d.ts +5 -11
- package/dist/lib/Steps/Integrations/NextJs.js +14 -343
- package/dist/lib/Steps/Integrations/NextJs.js.map +1 -1
- package/dist/lib/Steps/Integrations/ReactNative.d.ts +1 -0
- package/dist/lib/Steps/Integrations/ReactNative.js +67 -6
- package/dist/lib/Steps/Integrations/ReactNative.js.map +1 -1
- package/dist/lib/Steps/Integrations/SvelteKit.d.ts +13 -0
- package/dist/lib/Steps/Integrations/SvelteKit.js +95 -0
- package/dist/lib/Steps/Integrations/SvelteKit.js.map +1 -0
- package/dist/lib/Steps/Integrations/__tests__/ReactNative.js +28 -5
- package/dist/lib/Steps/Integrations/__tests__/ReactNative.js.map +1 -1
- package/dist/lib/Steps/PromptForParameters.js +24 -1
- package/dist/lib/Steps/PromptForParameters.js.map +1 -1
- package/dist/lib/Steps/SentryProjectSelector.js +25 -1
- package/dist/lib/Steps/SentryProjectSelector.js.map +1 -1
- package/dist/lib/__tests__/Setup.js +24 -1
- package/dist/lib/__tests__/Setup.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +326 -0
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -0
- package/dist/src/sveltekit/sdk-example.d.ts +10 -0
- package/dist/src/sveltekit/sdk-example.js +106 -0
- package/dist/src/sveltekit/sdk-example.js.map +1 -0
- package/dist/src/sveltekit/sdk-setup.d.ts +13 -0
- package/dist/src/sveltekit/sdk-setup.js +451 -0
- package/dist/src/sveltekit/sdk-setup.js.map +1 -0
- package/dist/src/sveltekit/sentry-cli-setup.d.ts +2 -0
- package/dist/src/sveltekit/sentry-cli-setup.js +71 -0
- package/dist/src/sveltekit/sentry-cli-setup.js.map +1 -0
- package/dist/src/sveltekit/sveltekit-wizard.d.ts +5 -0
- package/dist/src/sveltekit/sveltekit-wizard.js +147 -0
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -0
- package/dist/src/templates/nextjs-templates.d.ts +13 -0
- package/dist/src/templates/nextjs-templates.js +54 -0
- package/dist/src/templates/nextjs-templates.js.map +1 -0
- package/dist/src/templates/sveltekit-templates.d.ts +12 -0
- package/dist/src/templates/sveltekit-templates.js +26 -0
- package/dist/src/templates/sveltekit-templates.js.map +1 -0
- package/dist/src/{clack-utils.d.ts → utils/clack-utils.d.ts} +7 -0
- package/dist/src/{clack-utils.js → utils/clack-utils.js} +127 -42
- package/dist/src/utils/clack-utils.js.map +1 -0
- package/lib/Constants.ts +5 -0
- package/lib/Helper/Git.ts +39 -0
- package/lib/Helper/Logging.ts +4 -0
- package/lib/Helper/Package.ts +17 -0
- package/lib/Helper/PackageManager.ts +4 -9
- package/lib/Helper/SentryCli.ts +74 -0
- package/lib/Steps/ChooseIntegration.ts +4 -0
- package/lib/Steps/Integrations/NextJs.ts +7 -397
- package/lib/Steps/Integrations/ReactNative.ts +49 -3
- package/lib/Steps/Integrations/SvelteKit.ts +29 -0
- package/lib/Steps/SentryProjectSelector.ts +1 -0
- package/package.json +1 -1
- package/src/{nextjs-wizard.ts → nextjs/nextjs-wizard.ts} +45 -273
- package/src/sveltekit/sdk-example.ts +56 -0
- package/src/sveltekit/sdk-setup.ts +430 -0
- package/src/sveltekit/sentry-cli-setup.ts +27 -0
- package/src/sveltekit/sveltekit-wizard.ts +116 -0
- package/src/templates/nextjs-templates.ts +252 -0
- package/src/templates/sveltekit-templates.ts +172 -0
- package/src/{clack-utils.ts → utils/clack-utils.ts} +73 -11
- package/dist/src/clack-utils.js.map +0 -1
- package/dist/src/nextjs-wizard.js +0 -346
- package/dist/src/nextjs-wizard.js.map +0 -1
- /package/dist/src/{nextjs-wizard.d.ts → nextjs/nextjs-wizard.d.ts} +0 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.runSvelteKitWizard = void 0;
|
|
43
|
+
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
44
|
+
var prompts_1 = __importDefault(require("@clack/prompts"));
|
|
45
|
+
var chalk_1 = __importDefault(require("chalk"));
|
|
46
|
+
var clack_utils_1 = require("../utils/clack-utils");
|
|
47
|
+
var sdk_example_1 = require("./sdk-example");
|
|
48
|
+
var sdk_setup_1 = require("./sdk-setup");
|
|
49
|
+
var sentry_cli_setup_1 = require("./sentry-cli-setup");
|
|
50
|
+
function runSvelteKitWizard(options) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
52
|
+
var packageJson, _a, sentryUrl, selfHosted, _b, projects, apiKeys, selectedProject, dsn, svelteConfig, e_1, e_2;
|
|
53
|
+
return __generator(this, function (_c) {
|
|
54
|
+
switch (_c.label) {
|
|
55
|
+
case 0:
|
|
56
|
+
(0, clack_utils_1.printWelcome)({
|
|
57
|
+
wizardName: 'Sentry SvelteKit Wizard',
|
|
58
|
+
promoCode: options.promoCode,
|
|
59
|
+
});
|
|
60
|
+
return [4 /*yield*/, (0, clack_utils_1.confirmContinueEvenThoughNoGitRepo)()];
|
|
61
|
+
case 1:
|
|
62
|
+
_c.sent();
|
|
63
|
+
return [4 /*yield*/, (0, clack_utils_1.getPackageDotJson)()];
|
|
64
|
+
case 2:
|
|
65
|
+
packageJson = _c.sent();
|
|
66
|
+
return [4 /*yield*/, (0, clack_utils_1.ensurePackageIsInstalled)(packageJson, '@sveltejs/kit', 'Sveltekit')];
|
|
67
|
+
case 3:
|
|
68
|
+
_c.sent();
|
|
69
|
+
return [4 /*yield*/, (0, clack_utils_1.askForSelfHosted)()];
|
|
70
|
+
case 4:
|
|
71
|
+
_a = _c.sent(), sentryUrl = _a.url, selfHosted = _a.selfHosted;
|
|
72
|
+
return [4 /*yield*/, (0, clack_utils_1.askForWizardLogin)({
|
|
73
|
+
promoCode: options.promoCode,
|
|
74
|
+
url: sentryUrl,
|
|
75
|
+
})];
|
|
76
|
+
case 5:
|
|
77
|
+
_b = _c.sent(), projects = _b.projects, apiKeys = _b.apiKeys;
|
|
78
|
+
return [4 /*yield*/, prompts_1.default.select({
|
|
79
|
+
message: 'Select your Sentry project.',
|
|
80
|
+
options: projects.map(function (project) {
|
|
81
|
+
return {
|
|
82
|
+
value: project,
|
|
83
|
+
label: "".concat(project.organization.slug, "/").concat(project.slug),
|
|
84
|
+
};
|
|
85
|
+
}),
|
|
86
|
+
})];
|
|
87
|
+
case 6:
|
|
88
|
+
selectedProject = _c.sent();
|
|
89
|
+
(0, clack_utils_1.abortIfCancelled)(selectedProject);
|
|
90
|
+
return [4 /*yield*/, (0, clack_utils_1.installPackage)({
|
|
91
|
+
packageName: '@sentry/sveltekit',
|
|
92
|
+
alreadyInstalled: (0, clack_utils_1.hasPackageInstalled)('@sentry/sveltekit', packageJson),
|
|
93
|
+
})];
|
|
94
|
+
case 7:
|
|
95
|
+
_c.sent();
|
|
96
|
+
return [4 /*yield*/, (0, sentry_cli_setup_1.setupCLIConfig)(apiKeys.token, selectedProject, sentryUrl)];
|
|
97
|
+
case 8:
|
|
98
|
+
_c.sent();
|
|
99
|
+
dsn = selectedProject.keys[0].dsn.public;
|
|
100
|
+
return [4 /*yield*/, (0, sdk_setup_1.loadSvelteConfig)()];
|
|
101
|
+
case 9:
|
|
102
|
+
svelteConfig = _c.sent();
|
|
103
|
+
_c.label = 10;
|
|
104
|
+
case 10:
|
|
105
|
+
_c.trys.push([10, 12, , 13]);
|
|
106
|
+
return [4 /*yield*/, (0, sdk_setup_1.createOrMergeSvelteKitFiles)(dsn, svelteConfig)];
|
|
107
|
+
case 11:
|
|
108
|
+
_c.sent();
|
|
109
|
+
return [3 /*break*/, 13];
|
|
110
|
+
case 12:
|
|
111
|
+
e_1 = _c.sent();
|
|
112
|
+
prompts_1.default.log.error('Error while setting up the SvelteKit SDK:');
|
|
113
|
+
prompts_1.default.log.info(chalk_1.default.dim(typeof e_1 === 'object' && e_1 != null && 'toString' in e_1
|
|
114
|
+
? e_1.toString()
|
|
115
|
+
: typeof e_1 === 'string'
|
|
116
|
+
? e_1
|
|
117
|
+
: 'Unknown error'));
|
|
118
|
+
return [2 /*return*/];
|
|
119
|
+
case 13:
|
|
120
|
+
_c.trys.push([13, 15, , 16]);
|
|
121
|
+
return [4 /*yield*/, (0, sdk_example_1.createExamplePage)(svelteConfig, {
|
|
122
|
+
selfHosted: selfHosted,
|
|
123
|
+
url: sentryUrl,
|
|
124
|
+
orgSlug: selectedProject.organization.slug,
|
|
125
|
+
projectId: selectedProject.id,
|
|
126
|
+
})];
|
|
127
|
+
case 14:
|
|
128
|
+
_c.sent();
|
|
129
|
+
return [3 /*break*/, 16];
|
|
130
|
+
case 15:
|
|
131
|
+
e_2 = _c.sent();
|
|
132
|
+
prompts_1.default.log.error('Error while creating an example page to test Sentry:');
|
|
133
|
+
prompts_1.default.log.info(chalk_1.default.dim(typeof e_2 === 'object' && e_2 != null && 'toString' in e_2
|
|
134
|
+
? e_2.toString()
|
|
135
|
+
: typeof e_2 === 'string'
|
|
136
|
+
? e_2
|
|
137
|
+
: 'Unknown error'));
|
|
138
|
+
return [2 /*return*/];
|
|
139
|
+
case 16:
|
|
140
|
+
prompts_1.default.outro("\n".concat(chalk_1.default.green('Successfully installed the Sentry SvelteKit SDK!'), "\n\n").concat(chalk_1.default.cyan('You can validate your setup by starting your dev environment (`npm run dev`) and visiting "/sentry-example".'), "\n\nCheck out the SDK documentation for further configuration:\nhttps://docs.sentry.io/platforms/javascript/guides/sveltekit/\n "));
|
|
141
|
+
return [2 /*return*/];
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
exports.runSvelteKitWizard = runSvelteKitWizard;
|
|
147
|
+
//# sourceMappingURL=sveltekit-wizard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sveltekit-wizard.js","sourceRoot":"","sources":["../../../src/sveltekit/sveltekit-wizard.ts"],"names":[],"mappings":"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","sourcesContent":["// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\n\nimport {\n abortIfCancelled,\n askForSelfHosted,\n askForWizardLogin,\n confirmContinueEvenThoughNoGitRepo,\n ensurePackageIsInstalled,\n getPackageDotJson,\n hasPackageInstalled,\n installPackage,\n printWelcome,\n SentryProjectData,\n} from '../utils/clack-utils';\nimport { createExamplePage } from './sdk-example';\nimport { createOrMergeSvelteKitFiles, loadSvelteConfig } from './sdk-setup';\n\nimport { setupCLIConfig } from './sentry-cli-setup';\n\ninterface SvelteKitWizardOptions {\n promoCode?: string;\n}\n\nexport async function runSvelteKitWizard(\n options: SvelteKitWizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry SvelteKit Wizard',\n promoCode: options.promoCode,\n });\n\n await confirmContinueEvenThoughNoGitRepo();\n\n const packageJson = await getPackageDotJson();\n await ensurePackageIsInstalled(packageJson, '@sveltejs/kit', 'Sveltekit');\n\n const { url: sentryUrl, selfHosted } = await askForSelfHosted();\n\n const { projects, apiKeys } = await askForWizardLogin({\n promoCode: options.promoCode,\n url: sentryUrl,\n });\n\n const selectedProject: SentryProjectData | symbol = await clack.select({\n message: 'Select your Sentry project.',\n options: projects.map((project) => {\n return {\n value: project,\n label: `${project.organization.slug}/${project.slug}`,\n };\n }),\n });\n\n abortIfCancelled(selectedProject);\n\n await installPackage({\n packageName: '@sentry/sveltekit',\n alreadyInstalled: hasPackageInstalled('@sentry/sveltekit', packageJson),\n });\n\n await setupCLIConfig(apiKeys.token, selectedProject, sentryUrl);\n\n const dsn = selectedProject.keys[0].dsn.public;\n\n const svelteConfig = await loadSvelteConfig();\n\n try {\n await createOrMergeSvelteKitFiles(dsn, svelteConfig);\n } catch (e: unknown) {\n clack.log.error('Error while setting up the SvelteKit SDK:');\n clack.log.info(\n chalk.dim(\n typeof e === 'object' && e != null && 'toString' in e\n ? e.toString()\n : typeof e === 'string'\n ? e\n : 'Unknown error',\n ),\n );\n return;\n }\n\n try {\n await createExamplePage(svelteConfig, {\n selfHosted,\n url: sentryUrl,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n });\n } catch (e: unknown) {\n clack.log.error('Error while creating an example page to test Sentry:');\n clack.log.info(\n chalk.dim(\n typeof e === 'object' && e != null && 'toString' in e\n ? e.toString()\n : typeof e === 'string'\n ? e\n : 'Unknown error',\n ),\n );\n return;\n }\n\n clack.outro(`\n${chalk.green('Successfully installed the Sentry SvelteKit SDK!')}\n\n${chalk.cyan(\n 'You can validate your setup by starting your dev environment (`npm run dev`) and visiting \"/sentry-example\".',\n)}\n\nCheck out the SDK documentation for further configuration:\nhttps://docs.sentry.io/platforms/javascript/guides/sveltekit/\n `);\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function getNextjsWebpackPluginOptionsTemplate(orgSlug: string, projectSlug: string): string;
|
|
2
|
+
export declare function getNextjsSentryBuildOptionsTemplate(): string;
|
|
3
|
+
export declare function getNextjsConfigCjsTemplate(sentryWebpackPluginOptionsTemplate: string, sentryBuildOptionsTemplate: string): string;
|
|
4
|
+
export declare function getNextjsConfigCjsAppendix(sentryWebpackPluginOptionsTemplate: string, sentryBuildOptionsTemplate: string): string;
|
|
5
|
+
export declare function getNextjsConfigEsmCopyPasteSnippet(sentryWebpackPluginOptionsTemplate: string, sentryBuildOptionsTemplate: string): string;
|
|
6
|
+
export declare function getSentryConfigContents(dsn: string, config: 'server' | 'client' | 'edge'): string;
|
|
7
|
+
export declare function getSentryExamplePageContents(options: {
|
|
8
|
+
selfHosted: boolean;
|
|
9
|
+
url: string;
|
|
10
|
+
orgSlug: string;
|
|
11
|
+
projectId: string;
|
|
12
|
+
}): string;
|
|
13
|
+
export declare function getSentryExampleApiRoute(): string;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSentryExampleApiRoute = exports.getSentryExamplePageContents = exports.getSentryConfigContents = exports.getNextjsConfigEsmCopyPasteSnippet = exports.getNextjsConfigCjsAppendix = exports.getNextjsConfigCjsTemplate = exports.getNextjsSentryBuildOptionsTemplate = exports.getNextjsWebpackPluginOptionsTemplate = void 0;
|
|
4
|
+
function getNextjsWebpackPluginOptionsTemplate(orgSlug, projectSlug) {
|
|
5
|
+
return "{\n // For all available options, see:\n // https://github.com/getsentry/sentry-webpack-plugin#options\n\n // Suppresses source map uploading logs during build\n silent: true,\n\n org: \"".concat(orgSlug, "\",\n project: \"").concat(projectSlug, "\",\n }");
|
|
6
|
+
}
|
|
7
|
+
exports.getNextjsWebpackPluginOptionsTemplate = getNextjsWebpackPluginOptionsTemplate;
|
|
8
|
+
function getNextjsSentryBuildOptionsTemplate() {
|
|
9
|
+
return "{\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 // Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)\n 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 }";
|
|
10
|
+
}
|
|
11
|
+
exports.getNextjsSentryBuildOptionsTemplate = getNextjsSentryBuildOptionsTemplate;
|
|
12
|
+
function getNextjsConfigCjsTemplate(sentryWebpackPluginOptionsTemplate, sentryBuildOptionsTemplate) {
|
|
13
|
+
return "const { withSentryConfig } = require(\"@sentry/nextjs\");\n\n/** @type {import('next').NextConfig} */\nconst nextConfig = {};\n\nmodule.exports = withSentryConfig(\n nextConfig,\n ".concat(sentryWebpackPluginOptionsTemplate, ",\n ").concat(sentryBuildOptionsTemplate, "\n);\n");
|
|
14
|
+
}
|
|
15
|
+
exports.getNextjsConfigCjsTemplate = getNextjsConfigCjsTemplate;
|
|
16
|
+
function getNextjsConfigCjsAppendix(sentryWebpackPluginOptionsTemplate, sentryBuildOptionsTemplate) {
|
|
17
|
+
return "\n\n// Injected content via Sentry wizard below\n\nconst { withSentryConfig } = require(\"@sentry/nextjs\");\n\nmodule.exports = withSentryConfig(\n module.exports,\n ".concat(sentryWebpackPluginOptionsTemplate, ",\n ").concat(sentryBuildOptionsTemplate, "\n);\n");
|
|
18
|
+
}
|
|
19
|
+
exports.getNextjsConfigCjsAppendix = getNextjsConfigCjsAppendix;
|
|
20
|
+
function getNextjsConfigEsmCopyPasteSnippet(sentryWebpackPluginOptionsTemplate, sentryBuildOptionsTemplate) {
|
|
21
|
+
return "\n\n// next.config.mjs\nimport { withSentryConfig } from \"@sentry/nextjs\";\n\nexport default withSentryConfig(\n yourNextConfig,\n ".concat(sentryWebpackPluginOptionsTemplate, ",\n ").concat(sentryBuildOptionsTemplate, "\n);\n");
|
|
22
|
+
}
|
|
23
|
+
exports.getNextjsConfigEsmCopyPasteSnippet = getNextjsConfigEsmCopyPasteSnippet;
|
|
24
|
+
function getSentryConfigContents(dsn, config) {
|
|
25
|
+
var primer;
|
|
26
|
+
if (config === 'server') {
|
|
27
|
+
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/";
|
|
28
|
+
}
|
|
29
|
+
else if (config === 'client') {
|
|
30
|
+
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/";
|
|
31
|
+
}
|
|
32
|
+
else if (config === 'edge') {
|
|
33
|
+
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/";
|
|
34
|
+
}
|
|
35
|
+
var additionalOptions = '';
|
|
36
|
+
if (config === 'client') {
|
|
37
|
+
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 new Sentry.Replay({\n // Additional Replay configuration goes in here, for example:\n maskAllText: true,\n blockAllMedia: true,\n }),\n ],";
|
|
38
|
+
}
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
40
|
+
return "".concat(primer, "\n\nimport * as Sentry from \"@sentry/nextjs\";\n\nSentry.init({\n dsn: \"").concat(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,").concat(additionalOptions, "\n});\n");
|
|
41
|
+
}
|
|
42
|
+
exports.getSentryConfigContents = getSentryConfigContents;
|
|
43
|
+
function getSentryExamplePageContents(options) {
|
|
44
|
+
var issuesPageLink = options.selfHosted
|
|
45
|
+
? "".concat(options.url, "organizations/").concat(options.orgSlug, "/issues/?project=").concat(options.projectId)
|
|
46
|
+
: "https://".concat(options.orgSlug, ".sentry.io/issues/?project=").concat(options.projectId);
|
|
47
|
+
return "import Head from \"next/head\";\nimport * as Sentry from \"@sentry/nextjs\";\n\nexport default function Home() {\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 const transaction = Sentry.startTransaction({\n name: \"Example Frontend Transaction\",\n });\n\n Sentry.configureScope((scope) => {\n scope.setSpan(transaction);\n });\n\n try {\n const res = await fetch(\"/api/sentry-example-api\");\n if (!res.ok) {\n throw new Error(\"Sentry Example Frontend Error\");\n }\n } finally {\n transaction.finish();\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");
|
|
48
|
+
}
|
|
49
|
+
exports.getSentryExamplePageContents = getSentryExamplePageContents;
|
|
50
|
+
function getSentryExampleApiRoute() {
|
|
51
|
+
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";
|
|
52
|
+
}
|
|
53
|
+
exports.getSentryExampleApiRoute = getSentryExampleApiRoute;
|
|
54
|
+
//# sourceMappingURL=nextjs-templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nextjs-templates.js","sourceRoot":"","sources":["../../../src/templates/nextjs-templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,qCAAqC,CACnD,OAAe,EACf,WAAmB;IAEnB,OAAO,oNAOG,OAAO,iCACH,WAAW,aACvB,CAAC;AACL,CAAC;AAdD,sFAcC;AAED,SAAgB,mCAAmC;IACjD,OAAO,usBAkBL,CAAC;AACL,CAAC;AApBD,kFAoBC;AAED,SAAgB,0BAA0B,CACxC,kCAA0C,EAC1C,0BAAkC;IAElC,OAAO,gMAOL,kCAAkC,kBAClC,0BAA0B,WAE7B,CAAC;AACF,CAAC;AAfD,gEAeC;AAED,SAAgB,0BAA0B,CACxC,kCAA0C,EAC1C,0BAAkC;IAElC,OAAO,mLAQL,kCAAkC,kBAClC,0BAA0B,WAE7B,CAAC;AACF,CAAC;AAhBD,gEAgBC;AAED,SAAgB,kCAAkC,CAChD,kCAA0C,EAC1C,0BAAkC;IAElC,OAAO,iJAOL,kCAAkC,kBAClC,0BAA0B,WAE7B,CAAC;AACF,CAAC;AAfD,gFAeC;AAED,SAAgB,uBAAuB,CACrC,GAAW,EACX,MAAoC;IAEpC,IAAI,MAAM,CAAC;IACX,IAAI,MAAM,KAAK,QAAQ,EAAE;QACvB,MAAM,GAAG,oNAEiD,CAAC;KAC5D;SAAM,IAAI,MAAM,KAAK,QAAQ,EAAE;QAC9B,MAAM,GAAG,6NAEiD,CAAC;KAC5D;SAAM,IAAI,MAAM,KAAK,MAAM,EAAE;QAC5B,MAAM,GAAG,gXAGiD,CAAC;KAC5D;IAED,IAAI,iBAAiB,GAAG,EAAE,CAAC;IAC3B,IAAI,MAAM,KAAK,QAAQ,EAAE;QACvB,iBAAiB,GAAG,gfAenB,CAAC;KACH;IAED,4EAA4E;IAC5E,OAAO,UAAG,MAAM,wFAKR,GAAG,4PAMI,iBAAiB,YAEjC,CAAC;AACF,CAAC;AAvDD,0DAuDC;AAED,SAAgB,4BAA4B,CAAC,OAK5C;IACC,IAAM,cAAc,GAAG,OAAO,CAAC,UAAU;QACvC,CAAC,CAAC,UAAG,OAAO,CAAC,GAAG,2BAAiB,OAAO,CAAC,OAAO,8BAAoB,OAAO,CAAC,SAAS,CAAE;QACvF,CAAC,CAAC,kBAAW,OAAO,CAAC,OAAO,wCAA8B,OAAO,CAAC,SAAS,CAAE,CAAC;IAEhF,OAAO,uxGAwEY,cAAc,8VAYlC,CAAC;AACF,CAAC;AA/FD,oEA+FC;AAED,SAAgB,wBAAwB;IACtC,OAAO,qNAKR,CAAC;AACF,CAAC;AAPD,4DAOC","sourcesContent":["export function getNextjsWebpackPluginOptionsTemplate(\n orgSlug: string,\n projectSlug: string,\n): string {\n return `{\n // For all available options, see:\n // https://github.com/getsentry/sentry-webpack-plugin#options\n\n // Suppresses source map uploading logs during build\n silent: true,\n\n org: \"${orgSlug}\",\n project: \"${projectSlug}\",\n }`;\n}\n\nexport function getNextjsSentryBuildOptionsTemplate(): string {\n return `{\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 // Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)\n 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}\n\nexport function getNextjsConfigCjsTemplate(\n sentryWebpackPluginOptionsTemplate: string,\n sentryBuildOptionsTemplate: 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 ${sentryWebpackPluginOptionsTemplate},\n ${sentryBuildOptionsTemplate}\n);\n`;\n}\n\nexport function getNextjsConfigCjsAppendix(\n sentryWebpackPluginOptionsTemplate: string,\n sentryBuildOptionsTemplate: 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 ${sentryWebpackPluginOptionsTemplate},\n ${sentryBuildOptionsTemplate}\n);\n`;\n}\n\nexport function getNextjsConfigEsmCopyPasteSnippet(\n sentryWebpackPluginOptionsTemplate: string,\n sentryBuildOptionsTemplate: string,\n): string {\n return `\n\n// next.config.mjs\nimport { withSentryConfig } from \"@sentry/nextjs\";\n\nexport default withSentryConfig(\n yourNextConfig,\n ${sentryWebpackPluginOptionsTemplate},\n ${sentryBuildOptionsTemplate}\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 new Sentry.Replay({\n // Additional Replay configuration goes in here, for example:\n maskAllText: true,\n blockAllMedia: true,\n }),\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}\n});\n`;\n}\n\nexport function getSentryExamplePageContents(options: {\n selfHosted: boolean;\n url: string;\n orgSlug: string;\n projectId: string;\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 `import Head from \"next/head\";\nimport * as Sentry from \"@sentry/nextjs\";\n\nexport default function Home() {\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 const transaction = Sentry.startTransaction({\n name: \"Example Frontend Transaction\",\n });\n\n Sentry.configureScope((scope) => {\n scope.setSpan(transaction);\n });\n\n try {\n const res = await fetch(\"/api/sentry-example-api\");\n if (!res.ok) {\n throw new Error(\"Sentry Example Frontend Error\");\n }\n } finally {\n transaction.finish();\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"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function getClientHooksTemplate(dsn: string): string;
|
|
2
|
+
export declare function getServerHooksTemplate(dsn: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* +page.svelte with Sentry example
|
|
5
|
+
*/
|
|
6
|
+
export declare function getSentryExampleSveltePage(options: {
|
|
7
|
+
selfHosted: boolean;
|
|
8
|
+
url: string;
|
|
9
|
+
orgSlug: string;
|
|
10
|
+
projectId: string;
|
|
11
|
+
}): string;
|
|
12
|
+
export declare function getSentryExampleApiRoute(): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSentryExampleApiRoute = exports.getSentryExampleSveltePage = exports.getServerHooksTemplate = exports.getClientHooksTemplate = void 0;
|
|
4
|
+
function getClientHooksTemplate(dsn) {
|
|
5
|
+
return "import { handleErrorWithSentry, Replay } from \"@sentry/sveltekit\";\nimport * as Sentry from '@sentry/sveltekit';\n\nSentry.init({\n dsn: '".concat(dsn, "',\n tracesSampleRate: 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 // If the entire session is not sampled, use the below sample rate to sample\n // sessions when an error occurs.\n replaysOnErrorSampleRate: 1.0,\n \n // If you don't want to use Session Replay, just remove the line below:\n integrations: [new Replay()],\n});\n\n// If you have a custom error handler, pass it to `handleErrorWithSentry`\nexport const handleError = handleErrorWithSentry();\n");
|
|
6
|
+
}
|
|
7
|
+
exports.getClientHooksTemplate = getClientHooksTemplate;
|
|
8
|
+
function getServerHooksTemplate(dsn) {
|
|
9
|
+
return "import { sequence } from \"@sveltejs/kit/hooks\";\nimport { handleErrorWithSentry, sentryHandle } from \"@sentry/sveltekit\";\nimport * as Sentry from '@sentry/sveltekit';\n\nSentry.init({\n dsn: '".concat(dsn, "',\n tracesSampleRate: 1.0,\n});\n\n// If you have custom handlers, make sure to place them after `sentryHandle()` in the `sequence` function.\nexport const handle = sequence(sentryHandle());\n\n// If you have a custom error handler, pass it to `handleErrorWithSentry`\nexport const handleError = handleErrorWithSentry();\n");
|
|
10
|
+
}
|
|
11
|
+
exports.getServerHooksTemplate = getServerHooksTemplate;
|
|
12
|
+
/**
|
|
13
|
+
* +page.svelte with Sentry example
|
|
14
|
+
*/
|
|
15
|
+
function getSentryExampleSveltePage(options) {
|
|
16
|
+
var issuesPageLink = options.selfHosted
|
|
17
|
+
? "".concat(options.url, "organizations/").concat(options.orgSlug, "/issues/?project=").concat(options.projectId)
|
|
18
|
+
: "https://".concat(options.orgSlug, ".sentry.io/issues/?project=").concat(options.projectId);
|
|
19
|
+
return "<!-- \nThis is just a very simple page with a button to throw an example error.\nFeel free to delete this file and the entire sentry route. \n-->\n\n<script>\n import * as Sentry from '@sentry/sveltekit';\n\n async function getSentryData() {\n const transaction = Sentry.startTransaction({\n name: 'Example Frontend Transaction'\n });\n\n Sentry.configureScope((scope) => {\n scope.setSpan(transaction);\n });\n\n try {\n const res = await fetch('/test-sentry');\n if (!res.ok) {\n throw new Error('Sentry Example Frontend Error');\n }\n } finally {\n transaction.finish();\n }\n }\n</script>\n\n<div>\n <head>\n <title>Sentry Onboarding</title>\n <meta name=\"description\" content=\"Test Sentry for your SvelteKit app!\" />\n </head>\n\n <main>\n <h1>\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 200 44\">\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 />\n </svg>\n </h1>\n <p>\n Get Started with this <strong>simple Example:</strong>\n </p>\n\n <p>1. Send us a sample error:</p>\n <button\n type=\"button\"\n on:click={getSentryData}>\n Throw error!\n </button>\n\n <p>\n 2. Look for the error on the\n <a href=\"".concat(issuesPageLink, "\">Issues Page</a>.\n </p>\n <p style=\"margin-top: 24px;\">\n For more information, take a look at the\n <a href=\"https://docs.sentry.io/platforms/javascript/guides/sveltekit/\">\n Sentry SvelteKit Documentation\n </a>\n </p>\n </main>\n</div>\n\n<style>\n main {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n }\n\n h1 {\n font-size: 4rem;\n margin: 14px 0;\n }\n\n svg {\n height: 1em;\n }\n\n button {\n padding: 12px;\n cursor: pointer;\n background-color: rgb(54, 45, 89);\n border-radius: 4px;\n border: none;\n color: white;\n font-size: 1em;\n margin: 1em;\n transition: all 0.25s ease-in-out;\n }\n button:hover {\n background-color: #8c5393;\n box-shadow: 4px;\n box-shadow: 0px 0px 15px 2px rgba(140, 83, 147, 0.5);\n }\n button:active {\n background-color: #c73852;\n }\n</style>\n");
|
|
20
|
+
}
|
|
21
|
+
exports.getSentryExampleSveltePage = getSentryExampleSveltePage;
|
|
22
|
+
function getSentryExampleApiRoute() {
|
|
23
|
+
return "// This is just a very simple API route that throws an example error.\n// Feel free to delete this file and the entire sentry route.\n\nexport const GET = async () => {\n throw new Error(\"Sentry Example API Route Error\");\n};\n";
|
|
24
|
+
}
|
|
25
|
+
exports.getSentryExampleApiRoute = getSentryExampleApiRoute;
|
|
26
|
+
//# sourceMappingURL=sveltekit-templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sveltekit-templates.js","sourceRoot":"","sources":["../../../src/templates/sveltekit-templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,sBAAsB,CAAC,GAAW;IAChD,OAAO,uJAIC,GAAG,mmBAiBZ,CAAC;AACF,CAAC;AAvBD,wDAuBC;AAED,SAAgB,sBAAsB,CAAC,GAAW;IAChD,OAAO,gNAKC,GAAG,yUASZ,CAAC;AACF,CAAC;AAhBD,wDAgBC;AAED;;GAEG;AACH,SAAgB,0BAA0B,CAAC,OAK1C;IACC,IAAM,cAAc,GAAG,OAAO,CAAC,UAAU;QACvC,CAAC,CAAC,UAAG,OAAO,CAAC,GAAG,2BAAiB,OAAO,CAAC,OAAO,8BAAoB,OAAO,CAAC,SAAS,CAAE;QACvF,CAAC,CAAC,kBAAW,OAAO,CAAC,OAAO,wCAA8B,OAAO,CAAC,SAAS,CAAE,CAAC;IAEhF,OAAO,4jFAwDQ,cAAc,w7BAgD9B,CAAC;AACF,CAAC;AAnHD,gEAmHC;AAED,SAAgB,wBAAwB;IACtC,OAAO,wOAMR,CAAC;AACF,CAAC;AARD,4DAQC","sourcesContent":["export function getClientHooksTemplate(dsn: string) {\n return `import { handleErrorWithSentry, Replay } from \"@sentry/sveltekit\";\nimport * as Sentry from '@sentry/sveltekit';\n\nSentry.init({\n dsn: '${dsn}',\n tracesSampleRate: 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 // If the entire session is not sampled, use the below sample rate to sample\n // sessions when an error occurs.\n replaysOnErrorSampleRate: 1.0,\n \n // If you don't want to use Session Replay, just remove the line below:\n integrations: [new Replay()],\n});\n\n// If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\nexport const handleError = handleErrorWithSentry();\n`;\n}\n\nexport function getServerHooksTemplate(dsn: string) {\n return `import { sequence } from \"@sveltejs/kit/hooks\";\nimport { handleErrorWithSentry, sentryHandle } from \"@sentry/sveltekit\";\nimport * as Sentry from '@sentry/sveltekit';\n\nSentry.init({\n dsn: '${dsn}',\n tracesSampleRate: 1.0,\n});\n\n// If you have custom handlers, make sure to place them after \\`sentryHandle()\\` in the \\`sequence\\` function.\nexport const handle = sequence(sentryHandle());\n\n// If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\nexport const handleError = handleErrorWithSentry();\n`;\n}\n\n/**\n * +page.svelte with Sentry example\n */\nexport function getSentryExampleSveltePage(options: {\n selfHosted: boolean;\n url: string;\n orgSlug: string;\n projectId: string;\n}) {\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 `<!-- \nThis is just a very simple page with a button to throw an example error.\nFeel free to delete this file and the entire sentry route. \n-->\n\n<script>\n import * as Sentry from '@sentry/sveltekit';\n\n async function getSentryData() {\n const transaction = Sentry.startTransaction({\n name: 'Example Frontend Transaction'\n });\n\n Sentry.configureScope((scope) => {\n scope.setSpan(transaction);\n });\n\n try {\n const res = await fetch('/test-sentry');\n if (!res.ok) {\n throw new Error('Sentry Example Frontend Error');\n }\n } finally {\n transaction.finish();\n }\n }\n</script>\n\n<div>\n <head>\n <title>Sentry Onboarding</title>\n <meta name=\"description\" content=\"Test Sentry for your SvelteKit app!\" />\n </head>\n\n <main>\n <h1>\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 200 44\">\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 />\n </svg>\n </h1>\n <p>\n Get Started with this <strong>simple Example:</strong>\n </p>\n\n <p>1. Send us a sample error:</p>\n <button\n type=\"button\"\n on:click={getSentryData}>\n Throw error!\n </button>\n\n <p>\n 2. Look for the error on the\n <a href=\"${issuesPageLink}\">Issues Page</a>.\n </p>\n <p style=\"margin-top: 24px;\">\n For more information, take a look at the\n <a href=\"https://docs.sentry.io/platforms/javascript/guides/sveltekit/\">\n Sentry SvelteKit Documentation\n </a>\n </p>\n </main>\n</div>\n\n<style>\n main {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n }\n\n h1 {\n font-size: 4rem;\n margin: 14px 0;\n }\n\n svg {\n height: 1em;\n }\n\n button {\n padding: 12px;\n cursor: pointer;\n background-color: rgb(54, 45, 89);\n border-radius: 4px;\n border: none;\n color: white;\n font-size: 1em;\n margin: 1em;\n transition: all 0.25s ease-in-out;\n }\n button:hover {\n background-color: #8c5393;\n box-shadow: 4px;\n box-shadow: 0px 0px 15px 2px rgba(140, 83, 147, 0.5);\n }\n button:active {\n background-color: #c73852;\n }\n</style>\n`;\n}\n\nexport function getSentryExampleApiRoute() {\n return `// This is just a very simple API route that throws an example error.\n// Feel free to delete this file and the entire sentry route.\n\nexport const GET = async () => {\n throw new Error(\"Sentry Example API Route Error\");\n};\n`;\n}\n"]}
|
|
@@ -4,6 +4,10 @@ interface WizardProjectData {
|
|
|
4
4
|
};
|
|
5
5
|
projects: SentryProjectData[];
|
|
6
6
|
}
|
|
7
|
+
export type PackageDotJson = {
|
|
8
|
+
dependencies?: Record<string, string>;
|
|
9
|
+
devDependencies?: Record<string, string>;
|
|
10
|
+
};
|
|
7
11
|
export interface SentryProjectData {
|
|
8
12
|
id: string;
|
|
9
13
|
slug: string;
|
|
@@ -37,4 +41,7 @@ export declare function askForSelfHosted(): Promise<{
|
|
|
37
41
|
selfHosted: boolean;
|
|
38
42
|
}>;
|
|
39
43
|
export declare function addSentryCliRc(authToken: string): Promise<void>;
|
|
44
|
+
export declare function ensurePackageIsInstalled(packageJson: PackageDotJson, packageId: string, packageName: string): Promise<void>;
|
|
45
|
+
export declare function getPackageDotJson(): Promise<PackageDotJson>;
|
|
46
|
+
export declare function hasPackageInstalled(packageName: string, packageJson: PackageDotJson): boolean;
|
|
40
47
|
export {};
|