@sentry/wizard 6.9.0 → 6.11.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 +56 -1
- package/dist/ci-ensure-runtime-loaded.sh +82 -0
- package/dist/e2e-tests/tests/angular-17.test.js +72 -82
- package/dist/e2e-tests/tests/angular-17.test.js.map +1 -1
- package/dist/e2e-tests/tests/angular-19.test.js +71 -80
- package/dist/e2e-tests/tests/angular-19.test.js.map +1 -1
- package/dist/e2e-tests/tests/cloudflare-worker.test.d.ts +1 -0
- package/dist/e2e-tests/tests/cloudflare-worker.test.js +64 -0
- package/dist/e2e-tests/tests/cloudflare-worker.test.js.map +1 -0
- package/dist/e2e-tests/tests/cloudflare-wrangler-sourcemaps.test.js +2 -5
- package/dist/e2e-tests/tests/cloudflare-wrangler-sourcemaps.test.js.map +1 -1
- package/dist/e2e-tests/tests/expo.test.js +36 -61
- package/dist/e2e-tests/tests/expo.test.js.map +1 -1
- package/dist/e2e-tests/tests/flutter.test.js +63 -70
- package/dist/e2e-tests/tests/flutter.test.js.map +1 -1
- package/dist/e2e-tests/tests/help-message.test.js +2 -2
- package/dist/e2e-tests/tests/help-message.test.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs-14.test.js +54 -82
- package/dist/e2e-tests/tests/nextjs-14.test.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs-15.test.js +95 -105
- package/dist/e2e-tests/tests/nextjs-15.test.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs-16.test.d.ts +1 -0
- package/dist/e2e-tests/tests/nextjs-16.test.js +123 -0
- package/dist/e2e-tests/tests/nextjs-16.test.js.map +1 -0
- package/dist/e2e-tests/tests/nuxt-3.test.js +45 -58
- package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -1
- package/dist/e2e-tests/tests/nuxt-4.test.js +59 -73
- package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -1
- package/dist/e2e-tests/tests/pnpm-workspace.test.js +4 -7
- package/dist/e2e-tests/tests/pnpm-workspace.test.js.map +1 -1
- package/dist/e2e-tests/tests/react-native.test.js +44 -80
- package/dist/e2e-tests/tests/react-native.test.js.map +1 -1
- package/dist/e2e-tests/tests/react-router.test.js +163 -145
- package/dist/e2e-tests/tests/react-router.test.js.map +1 -1
- package/dist/e2e-tests/tests/remix.test.js +162 -132
- package/dist/e2e-tests/tests/remix.test.js.map +1 -1
- package/dist/e2e-tests/tests/sveltekit-hooks.test.js +48 -36
- package/dist/e2e-tests/tests/sveltekit-hooks.test.js.map +1 -1
- package/dist/e2e-tests/tests/sveltekit-tracing.test.js +3 -6
- package/dist/e2e-tests/tests/sveltekit-tracing.test.js.map +1 -1
- package/dist/e2e-tests/utils/index.d.ts +21 -43
- package/dist/e2e-tests/utils/index.js +108 -183
- package/dist/e2e-tests/utils/index.js.map +1 -1
- package/dist/get-e2e-test-matrix.mjs +11 -0
- package/dist/lib/Constants.d.ts +1 -0
- package/dist/lib/Constants.js +5 -0
- package/dist/lib/Constants.js.map +1 -1
- package/dist/src/android/android-wizard.js +2 -4
- package/dist/src/android/android-wizard.js.map +1 -1
- package/dist/src/angular/angular-wizard.js +4 -6
- package/dist/src/angular/angular-wizard.js.map +1 -1
- package/dist/src/angular/sdk-setup.js +1 -1
- package/dist/src/angular/sdk-setup.js.map +1 -1
- package/dist/src/apple/apple-wizard.js +2 -4
- package/dist/src/apple/apple-wizard.js.map +1 -1
- package/dist/src/cloudflare/cloudflare-wizard.d.ts +3 -0
- package/dist/src/cloudflare/cloudflare-wizard.js +99 -0
- package/dist/src/cloudflare/cloudflare-wizard.js.map +1 -0
- package/dist/src/cloudflare/sdk-setup.d.ts +7 -0
- package/dist/src/cloudflare/sdk-setup.js +47 -0
- package/dist/src/cloudflare/sdk-setup.js.map +1 -0
- package/dist/src/cloudflare/templates.d.ts +4 -0
- package/dist/src/cloudflare/templates.js +44 -0
- package/dist/src/cloudflare/templates.js.map +1 -0
- package/dist/src/cloudflare/wrangler/create-wrangler-config.d.ts +4 -0
- package/dist/src/cloudflare/wrangler/create-wrangler-config.js +27 -0
- package/dist/src/cloudflare/wrangler/create-wrangler-config.js.map +1 -0
- package/dist/src/cloudflare/wrangler/ensure-wrangler-config.d.ts +4 -0
- package/dist/src/cloudflare/wrangler/ensure-wrangler-config.js +25 -0
- package/dist/src/cloudflare/wrangler/ensure-wrangler-config.js.map +1 -0
- package/dist/src/cloudflare/wrangler/find-wrangler-config.d.ts +4 -0
- package/dist/src/cloudflare/wrangler/find-wrangler-config.js +23 -0
- package/dist/src/cloudflare/wrangler/find-wrangler-config.js.map +1 -0
- package/dist/src/cloudflare/wrangler/get-entry-point-from-wrangler-config.d.ts +6 -0
- package/dist/src/cloudflare/wrangler/get-entry-point-from-wrangler-config.js +52 -0
- package/dist/src/cloudflare/wrangler/get-entry-point-from-wrangler-config.js.map +1 -0
- package/dist/src/cloudflare/wrangler/update-wrangler-config.d.ts +17 -0
- package/dist/src/cloudflare/wrangler/update-wrangler-config.js +173 -0
- package/dist/src/cloudflare/wrangler/update-wrangler-config.js.map +1 -0
- package/dist/src/cloudflare/wrap-worker.d.ts +32 -0
- package/dist/src/cloudflare/wrap-worker.js +109 -0
- package/dist/src/cloudflare/wrap-worker.js.map +1 -0
- package/dist/src/flutter/flutter-wizard.js +3 -6
- package/dist/src/flutter/flutter-wizard.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +46 -10
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nextjs/templates.d.ts +6 -3
- package/dist/src/nextjs/templates.js +144 -93
- package/dist/src/nextjs/templates.js.map +1 -1
- package/dist/src/nuxt/nuxt-wizard.js +3 -5
- package/dist/src/nuxt/nuxt-wizard.js.map +1 -1
- package/dist/src/react-native/react-native-wizard.js +2 -4
- package/dist/src/react-native/react-native-wizard.js.map +1 -1
- package/dist/src/react-router/codemods/client.entry.js +4 -1
- package/dist/src/react-router/codemods/client.entry.js.map +1 -1
- package/dist/src/react-router/react-router-wizard.js +3 -5
- package/dist/src/react-router/react-router-wizard.js.map +1 -1
- package/dist/src/react-router/sdk-example.js +5 -2
- package/dist/src/react-router/sdk-example.js.map +1 -1
- package/dist/src/react-router/sdk-setup.d.ts +1 -1
- package/dist/src/react-router/sdk-setup.js +3 -4
- package/dist/src/react-router/sdk-setup.js.map +1 -1
- package/dist/src/remix/remix-wizard.js +2 -4
- package/dist/src/remix/remix-wizard.js.map +1 -1
- package/dist/src/run.d.ts +1 -1
- package/dist/src/run.js +5 -0
- package/dist/src/run.js.map +1 -1
- package/dist/src/sourcemaps/tools/sentry-cli.js +1 -1
- package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
- package/dist/src/sourcemaps/tools/wrangler.js +1 -1
- package/dist/src/sourcemaps/tools/wrangler.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js +4 -6
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/telemetry.d.ts +1 -1
- package/dist/src/telemetry.js +52 -31
- package/dist/src/telemetry.js.map +1 -1
- package/dist/src/utils/abort-if-sportlight-not-supported.d.ts +5 -0
- package/dist/src/utils/abort-if-sportlight-not-supported.js +40 -0
- package/dist/src/utils/abort-if-sportlight-not-supported.js.map +1 -0
- package/dist/src/utils/ast-utils.d.ts +1 -1
- package/dist/src/utils/ast-utils.js.map +1 -1
- package/dist/src/utils/clack/index.d.ts +19 -2
- package/dist/src/utils/clack/index.js +174 -12
- package/dist/src/utils/clack/index.js.map +1 -1
- package/dist/src/utils/clack/mcp-config.js +117 -59
- package/dist/src/utils/clack/mcp-config.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/angular/angular-wizard.test.js +2 -4
- package/dist/test/angular/angular-wizard.test.js.map +1 -1
- package/dist/test/apple/cocoapod.test.js +7 -3
- package/dist/test/apple/cocoapod.test.js.map +1 -1
- package/dist/test/apple/code-tools.test.js +8 -2
- package/dist/test/apple/code-tools.test.js.map +1 -1
- package/dist/test/cloudflare/create-wrangler-config.test.d.ts +1 -0
- package/dist/test/cloudflare/create-wrangler-config.test.js +48 -0
- package/dist/test/cloudflare/create-wrangler-config.test.js.map +1 -0
- package/dist/test/cloudflare/ensure-wrangler-config.test.d.ts +1 -0
- package/dist/test/cloudflare/ensure-wrangler-config.test.js +61 -0
- package/dist/test/cloudflare/ensure-wrangler-config.test.js.map +1 -0
- package/dist/test/cloudflare/find-wrangler-config.test.d.ts +1 -0
- package/dist/test/cloudflare/find-wrangler-config.test.js +77 -0
- package/dist/test/cloudflare/find-wrangler-config.test.js.map +1 -0
- package/dist/test/cloudflare/get-entry-point-from-wrangler-config.test.d.ts +1 -0
- package/dist/test/cloudflare/get-entry-point-from-wrangler-config.test.js +81 -0
- package/dist/test/cloudflare/get-entry-point-from-wrangler-config.test.js.map +1 -0
- package/dist/test/cloudflare/sdk-setup.test.d.ts +1 -0
- package/dist/test/cloudflare/sdk-setup.test.js +152 -0
- package/dist/test/cloudflare/sdk-setup.test.js.map +1 -0
- package/dist/test/cloudflare/templates.test.d.ts +1 -0
- package/dist/test/cloudflare/templates.test.js +68 -0
- package/dist/test/cloudflare/templates.test.js.map +1 -0
- package/dist/test/cloudflare/update-wrangler-config.test.d.ts +1 -0
- package/dist/test/cloudflare/update-wrangler-config.test.js +216 -0
- package/dist/test/cloudflare/update-wrangler-config.test.js.map +1 -0
- package/dist/test/cloudflare/wrap-worker.test.d.ts +1 -0
- package/dist/test/cloudflare/wrap-worker.test.js +143 -0
- package/dist/test/cloudflare/wrap-worker.test.js.map +1 -0
- package/dist/test/nextjs/templates.test.js +156 -87
- package/dist/test/nextjs/templates.test.js.map +1 -1
- package/dist/test/nextjs/wizard-double-wrap-prevention.test.js +12 -7
- package/dist/test/nextjs/wizard-double-wrap-prevention.test.js.map +1 -1
- package/dist/test/react-router/sdk-setup.test.js +2 -2
- package/dist/test/react-router/sdk-setup.test.js.map +1 -1
- package/dist/test/utils/clack/index.test.js +37 -29
- package/dist/test/utils/clack/index.test.js.map +1 -1
- package/dist/test/utils/clack/mcp-config.test.js +176 -51
- package/dist/test/utils/clack/mcp-config.test.js.map +1 -1
- package/package.json +6 -5
|
@@ -0,0 +1,143 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const vitest_1 = require("vitest");
|
|
27
|
+
const fs = __importStar(require("node:fs"));
|
|
28
|
+
const path = __importStar(require("node:path"));
|
|
29
|
+
const os = __importStar(require("node:os"));
|
|
30
|
+
const wrap_worker_1 = require("../../src/cloudflare/wrap-worker");
|
|
31
|
+
(0, vitest_1.describe)('wrapWorkerWithSentry', () => {
|
|
32
|
+
const fixturesDir = path.join(__dirname, 'fixtures', 'worker');
|
|
33
|
+
let tmpDir;
|
|
34
|
+
function copyFixture(fixtureName) {
|
|
35
|
+
const content = fs.readFileSync(path.join(fixturesDir, fixtureName), 'utf-8');
|
|
36
|
+
const targetPath = path.join(tmpDir, 'worker.ts');
|
|
37
|
+
fs.writeFileSync(targetPath, content);
|
|
38
|
+
return targetPath;
|
|
39
|
+
}
|
|
40
|
+
function readResult() {
|
|
41
|
+
return fs.readFileSync(path.join(tmpDir, 'worker.ts'), 'utf-8');
|
|
42
|
+
}
|
|
43
|
+
(0, vitest_1.beforeEach)(() => {
|
|
44
|
+
vitest_1.vi.clearAllMocks();
|
|
45
|
+
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'wrap-worker-'));
|
|
46
|
+
});
|
|
47
|
+
(0, vitest_1.afterEach)(() => {
|
|
48
|
+
if (fs.existsSync(tmpDir)) {
|
|
49
|
+
fs.rmSync(tmpDir, { recursive: true });
|
|
50
|
+
}
|
|
51
|
+
vitest_1.vi.restoreAllMocks();
|
|
52
|
+
});
|
|
53
|
+
(0, vitest_1.describe)('basic wrapping', () => {
|
|
54
|
+
(0, vitest_1.it)('wraps a simple worker export with Sentry', async () => {
|
|
55
|
+
const filePath = copyFixture('simple-with-satisfies.ts');
|
|
56
|
+
await (0, wrap_worker_1.wrapWorkerWithSentry)(filePath, 'my-test-dsn', {
|
|
57
|
+
performance: false,
|
|
58
|
+
});
|
|
59
|
+
const result = readResult();
|
|
60
|
+
(0, vitest_1.expect)(result).toMatchSnapshot();
|
|
61
|
+
});
|
|
62
|
+
(0, vitest_1.it)('preserves complex handler logic', async () => {
|
|
63
|
+
const filePath = copyFixture('complex-handler.ts');
|
|
64
|
+
await (0, wrap_worker_1.wrapWorkerWithSentry)(filePath, 'my-dsn', { performance: false });
|
|
65
|
+
const result = readResult();
|
|
66
|
+
(0, vitest_1.expect)(result).toMatchSnapshot();
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
(0, vitest_1.describe)('performance monitoring', () => {
|
|
70
|
+
(0, vitest_1.it)('includes tracesSampleRate when performance is enabled', async () => {
|
|
71
|
+
const filePath = copyFixture('simple.ts');
|
|
72
|
+
await (0, wrap_worker_1.wrapWorkerWithSentry)(filePath, 'my-dsn', { performance: true });
|
|
73
|
+
const result = readResult();
|
|
74
|
+
(0, vitest_1.expect)(result).toMatchSnapshot();
|
|
75
|
+
});
|
|
76
|
+
(0, vitest_1.it)('omits tracesSampleRate when performance is disabled', async () => {
|
|
77
|
+
const filePath = copyFixture('simple.ts');
|
|
78
|
+
await (0, wrap_worker_1.wrapWorkerWithSentry)(filePath, 'my-dsn', { performance: false });
|
|
79
|
+
const result = readResult();
|
|
80
|
+
(0, vitest_1.expect)(result).toMatchSnapshot();
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
(0, vitest_1.describe)('import handling', () => {
|
|
84
|
+
(0, vitest_1.it)('adds Sentry import at the beginning of the file', async () => {
|
|
85
|
+
const filePath = copyFixture('with-comment.ts');
|
|
86
|
+
await (0, wrap_worker_1.wrapWorkerWithSentry)(filePath, 'my-dsn', { performance: false });
|
|
87
|
+
const result = readResult();
|
|
88
|
+
(0, vitest_1.expect)(result).toMatchSnapshot();
|
|
89
|
+
});
|
|
90
|
+
(0, vitest_1.it)('preserves existing imports', async () => {
|
|
91
|
+
const filePath = copyFixture('with-import.ts');
|
|
92
|
+
await (0, wrap_worker_1.wrapWorkerWithSentry)(filePath, 'my-dsn', { performance: false });
|
|
93
|
+
const result = readResult();
|
|
94
|
+
(0, vitest_1.expect)(result).toMatchSnapshot();
|
|
95
|
+
});
|
|
96
|
+
(0, vitest_1.it)('preserves an external default export', async () => {
|
|
97
|
+
const filePath = copyFixture('external-default-export.ts');
|
|
98
|
+
await (0, wrap_worker_1.wrapWorkerWithSentry)(filePath, 'my-dsn', { performance: false });
|
|
99
|
+
const result = readResult();
|
|
100
|
+
(0, vitest_1.expect)(result).toMatchSnapshot();
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
(0, vitest_1.describe)('idempotency', () => {
|
|
104
|
+
(0, vitest_1.it)('does not wrap again if Sentry is already present', async () => {
|
|
105
|
+
const filePath = copyFixture('already-wrapped.ts');
|
|
106
|
+
const originalContent = fs.readFileSync(path.join(fixturesDir, 'already-wrapped.ts'), 'utf-8');
|
|
107
|
+
await (0, wrap_worker_1.wrapWorkerWithSentry)(filePath, 'new-dsn', { performance: true });
|
|
108
|
+
const result = readResult();
|
|
109
|
+
(0, vitest_1.expect)(result).toBe(originalContent);
|
|
110
|
+
});
|
|
111
|
+
(0, vitest_1.it)('does not modify if @sentry/cloudflare is imported', async () => {
|
|
112
|
+
const filePath = copyFixture('with-sentry-import.ts');
|
|
113
|
+
const originalContent = fs.readFileSync(path.join(fixturesDir, 'with-sentry-import.ts'), 'utf-8');
|
|
114
|
+
await (0, wrap_worker_1.wrapWorkerWithSentry)(filePath, 'my-dsn', { performance: false });
|
|
115
|
+
const result = readResult();
|
|
116
|
+
(0, vitest_1.expect)(result).toBe(originalContent);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
(0, vitest_1.describe)('DSN handling', () => {
|
|
120
|
+
(0, vitest_1.it)('uses the provided DSN', async () => {
|
|
121
|
+
const filePath = copyFixture('simple.ts');
|
|
122
|
+
const testDsn = 'https://d7a9abbecd95ed7d0f5b6c965f5fb6ba@o447951.ingest.us.sentry.io/4510147615391744';
|
|
123
|
+
await (0, wrap_worker_1.wrapWorkerWithSentry)(filePath, testDsn, { performance: false });
|
|
124
|
+
const result = readResult();
|
|
125
|
+
(0, vitest_1.expect)(result).toMatchSnapshot();
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
(0, vitest_1.describe)('edge cases', () => {
|
|
129
|
+
(0, vitest_1.it)('handles worker without satisfies clause', async () => {
|
|
130
|
+
const filePath = copyFixture('simple.ts');
|
|
131
|
+
await (0, wrap_worker_1.wrapWorkerWithSentry)(filePath, 'my-dsn', { performance: false });
|
|
132
|
+
const result = readResult();
|
|
133
|
+
(0, vitest_1.expect)(result).toMatchSnapshot();
|
|
134
|
+
});
|
|
135
|
+
(0, vitest_1.it)('handles files with no default export gracefully', async () => {
|
|
136
|
+
const filePath = copyFixture('no-default-export.ts');
|
|
137
|
+
await (0, vitest_1.expect)((0, wrap_worker_1.wrapWorkerWithSentry)(filePath, 'my-dsn', { performance: false })).resolves.not.toThrow();
|
|
138
|
+
const result = readResult();
|
|
139
|
+
(0, vitest_1.expect)(result).toMatchSnapshot();
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
//# sourceMappingURL=wrap-worker.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrap-worker.test.js","sourceRoot":"","sources":["../../../test/cloudflare/wrap-worker.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAyE;AACzE,4CAA8B;AAC9B,gDAAkC;AAClC,4CAA8B;AAC9B,kEAAwE;AAExE,IAAA,iBAAQ,EAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IAC/D,IAAI,MAAc,CAAC;IAEnB,SAAS,WAAW,CAAC,WAAmB;QACtC,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAC7B,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,EACnC,OAAO,CACR,CAAC;QACF,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QAClD,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACtC,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,SAAS,UAAU;QACjB,OAAO,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,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AM,GAAG,UAAU,EAAE,CAAC;YAE5B,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,eAAe,EAAE,CAAC;QACnC,CAAC,CAAC,CAAC;QAEH,IAAA,WAAE,EAAC,iDAAiD,EAAE,KAAK,IAAI,EAAE;YAC/D,MAAM,QAAQ,GAAG,WAAW,CAAC,sBAAsB,CAAC,CAAC;YAErD,MAAM,IAAA,eAAM,EACV,IAAA,kCAAoB,EAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CACjE,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;YAEzB,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;YAE5B,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,eAAe,EAAE,CAAC;QACnC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport * as os from 'node:os';\nimport { wrapWorkerWithSentry } from '../../src/cloudflare/wrap-worker';\n\ndescribe('wrapWorkerWithSentry', () => {\n const fixturesDir = path.join(__dirname, 'fixtures', 'worker');\n let tmpDir: string;\n\n function copyFixture(fixtureName: string): string {\n const content = fs.readFileSync(\n path.join(fixturesDir, fixtureName),\n 'utf-8',\n );\n const targetPath = path.join(tmpDir, 'worker.ts');\n fs.writeFileSync(targetPath, content);\n return targetPath;\n }\n\n function readResult(): string {\n return fs.readFileSync(path.join(tmpDir, 'worker.ts'), 'utf-8');\n }\n\n beforeEach(() => {\n vi.clearAllMocks();\n\n tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'wrap-worker-'));\n });\n\n afterEach(() => {\n if (fs.existsSync(tmpDir)) {\n fs.rmSync(tmpDir, { recursive: true });\n }\n\n vi.restoreAllMocks();\n });\n\n describe('basic wrapping', () => {\n it('wraps a simple worker export with Sentry', async () => {\n const filePath = copyFixture('simple-with-satisfies.ts');\n\n await wrapWorkerWithSentry(filePath, 'my-test-dsn', {\n performance: false,\n });\n\n const result = readResult();\n\n expect(result).toMatchSnapshot();\n });\n\n it('preserves complex handler logic', async () => {\n const filePath = copyFixture('complex-handler.ts');\n\n await wrapWorkerWithSentry(filePath, 'my-dsn', { performance: false });\n\n const result = readResult();\n\n expect(result).toMatchSnapshot();\n });\n });\n\n describe('performance monitoring', () => {\n it('includes tracesSampleRate when performance is enabled', async () => {\n const filePath = copyFixture('simple.ts');\n\n await wrapWorkerWithSentry(filePath, 'my-dsn', { performance: true });\n\n const result = readResult();\n\n expect(result).toMatchSnapshot();\n });\n\n it('omits tracesSampleRate when performance is disabled', async () => {\n const filePath = copyFixture('simple.ts');\n\n await wrapWorkerWithSentry(filePath, 'my-dsn', { performance: false });\n\n const result = readResult();\n\n expect(result).toMatchSnapshot();\n });\n });\n\n describe('import handling', () => {\n it('adds Sentry import at the beginning of the file', async () => {\n const filePath = copyFixture('with-comment.ts');\n\n await wrapWorkerWithSentry(filePath, 'my-dsn', { performance: false });\n\n const result = readResult();\n\n expect(result).toMatchSnapshot();\n });\n\n it('preserves existing imports', async () => {\n const filePath = copyFixture('with-import.ts');\n\n await wrapWorkerWithSentry(filePath, 'my-dsn', { performance: false });\n\n const result = readResult();\n\n expect(result).toMatchSnapshot();\n });\n\n it('preserves an external default export', async () => {\n const filePath = copyFixture('external-default-export.ts');\n\n await wrapWorkerWithSentry(filePath, 'my-dsn', { performance: false });\n\n const result = readResult();\n\n expect(result).toMatchSnapshot();\n });\n });\n\n describe('idempotency', () => {\n it('does not wrap again if Sentry is already present', async () => {\n const filePath = copyFixture('already-wrapped.ts');\n const originalContent = fs.readFileSync(\n path.join(fixturesDir, 'already-wrapped.ts'),\n 'utf-8',\n );\n\n await wrapWorkerWithSentry(filePath, 'new-dsn', { performance: true });\n\n const result = readResult();\n\n expect(result).toBe(originalContent);\n });\n\n it('does not modify if @sentry/cloudflare is imported', async () => {\n const filePath = copyFixture('with-sentry-import.ts');\n const originalContent = fs.readFileSync(\n path.join(fixturesDir, 'with-sentry-import.ts'),\n 'utf-8',\n );\n\n await wrapWorkerWithSentry(filePath, 'my-dsn', { performance: false });\n\n const result = readResult();\n\n expect(result).toBe(originalContent);\n });\n });\n\n describe('DSN handling', () => {\n it('uses the provided DSN', async () => {\n const filePath = copyFixture('simple.ts');\n\n const testDsn =\n 'https://d7a9abbecd95ed7d0f5b6c965f5fb6ba@o447951.ingest.us.sentry.io/4510147615391744';\n\n await wrapWorkerWithSentry(filePath, testDsn, { performance: false });\n\n const result = readResult();\n\n expect(result).toMatchSnapshot();\n });\n });\n\n describe('edge cases', () => {\n it('handles worker without satisfies clause', async () => {\n const filePath = copyFixture('simple.ts');\n\n await wrapWorkerWithSentry(filePath, 'my-dsn', { performance: false });\n\n const result = readResult();\n\n expect(result).toMatchSnapshot();\n });\n\n it('handles files with no default export gracefully', async () => {\n const filePath = copyFixture('no-default-export.ts');\n\n await expect(\n wrapWorkerWithSentry(filePath, 'my-dsn', { performance: false }),\n ).resolves.not.toThrow();\n\n const result = readResult();\n\n expect(result).toMatchSnapshot();\n });\n });\n});\n"]}
|
|
@@ -21,9 +21,7 @@ const templates_1 = require("../../src/nextjs/templates");
|
|
|
21
21
|
dsn: "my-dsn",
|
|
22
22
|
|
|
23
23
|
// Add optional integrations for additional features
|
|
24
|
-
integrations: [
|
|
25
|
-
Sentry.replayIntegration(),
|
|
26
|
-
],
|
|
24
|
+
integrations: [Sentry.replayIntegration()],
|
|
27
25
|
|
|
28
26
|
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
|
|
29
27
|
tracesSampleRate: 1,
|
|
@@ -43,7 +41,8 @@ const templates_1 = require("../../src/nextjs/templates");
|
|
|
43
41
|
sendDefaultPii: true,
|
|
44
42
|
});
|
|
45
43
|
|
|
46
|
-
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;
|
|
44
|
+
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;
|
|
45
|
+
"
|
|
47
46
|
`);
|
|
48
47
|
});
|
|
49
48
|
(0, vitest_1.it)('generates client-side Sentry config with performance monitoring disabled', () => {
|
|
@@ -63,9 +62,7 @@ const templates_1 = require("../../src/nextjs/templates");
|
|
|
63
62
|
dsn: "my-dsn",
|
|
64
63
|
|
|
65
64
|
// Add optional integrations for additional features
|
|
66
|
-
integrations: [
|
|
67
|
-
Sentry.replayIntegration(),
|
|
68
|
-
],
|
|
65
|
+
integrations: [Sentry.replayIntegration()],
|
|
69
66
|
// Enable logs to be sent to Sentry
|
|
70
67
|
enableLogs: true,
|
|
71
68
|
|
|
@@ -82,7 +79,8 @@ const templates_1 = require("../../src/nextjs/templates");
|
|
|
82
79
|
sendDefaultPii: true,
|
|
83
80
|
});
|
|
84
81
|
|
|
85
|
-
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;
|
|
82
|
+
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;
|
|
83
|
+
"
|
|
86
84
|
`);
|
|
87
85
|
});
|
|
88
86
|
(0, vitest_1.it)('generates client-side Sentry config with session replay disabled', () => {
|
|
@@ -111,7 +109,8 @@ const templates_1 = require("../../src/nextjs/templates");
|
|
|
111
109
|
sendDefaultPii: true,
|
|
112
110
|
});
|
|
113
111
|
|
|
114
|
-
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;
|
|
112
|
+
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;
|
|
113
|
+
"
|
|
115
114
|
`);
|
|
116
115
|
});
|
|
117
116
|
(0, vitest_1.it)('generates client-side Sentry config with logs disabled', () => {
|
|
@@ -131,9 +130,7 @@ const templates_1 = require("../../src/nextjs/templates");
|
|
|
131
130
|
dsn: "my-dsn",
|
|
132
131
|
|
|
133
132
|
// Add optional integrations for additional features
|
|
134
|
-
integrations: [
|
|
135
|
-
Sentry.replayIntegration(),
|
|
136
|
-
],
|
|
133
|
+
integrations: [Sentry.replayIntegration()],
|
|
137
134
|
|
|
138
135
|
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
|
|
139
136
|
tracesSampleRate: 1,
|
|
@@ -151,7 +148,8 @@ const templates_1 = require("../../src/nextjs/templates");
|
|
|
151
148
|
sendDefaultPii: true,
|
|
152
149
|
});
|
|
153
150
|
|
|
154
|
-
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;
|
|
151
|
+
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;
|
|
152
|
+
"
|
|
155
153
|
`);
|
|
156
154
|
});
|
|
157
155
|
(0, vitest_1.it)('uses empty DSN in spotlight mode', () => {
|
|
@@ -386,36 +384,41 @@ const templates_1 = require("../../src/nextjs/templates");
|
|
|
386
384
|
});
|
|
387
385
|
(0, vitest_1.expect)(template).toMatchInlineSnapshot(`
|
|
388
386
|
"{
|
|
389
|
-
|
|
390
|
-
|
|
387
|
+
// For all available options, see:
|
|
388
|
+
// https://www.npmjs.com/package/@sentry/webpack-plugin#options
|
|
391
389
|
|
|
392
|
-
|
|
393
|
-
|
|
390
|
+
org: "my-org",
|
|
391
|
+
project: "my-project",
|
|
394
392
|
|
|
395
|
-
|
|
396
|
-
|
|
393
|
+
// Only print logs for uploading source maps in CI
|
|
394
|
+
silent: !process.env.CI,
|
|
397
395
|
|
|
398
|
-
|
|
399
|
-
|
|
396
|
+
// For all available options, see:
|
|
397
|
+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
|
|
400
398
|
|
|
401
|
-
|
|
402
|
-
|
|
399
|
+
// Upload a larger set of source maps for prettier stack traces (increases build time)
|
|
400
|
+
widenClientFileUpload: true,
|
|
403
401
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
// Automatically tree-shake Sentry logger statements to reduce bundle size
|
|
411
|
-
disableLogger: true,
|
|
402
|
+
// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
|
|
403
|
+
// This can increase your server load as well as your hosting bill.
|
|
404
|
+
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
|
|
405
|
+
// side errors will fail.
|
|
406
|
+
tunnelRoute: "/monitoring",
|
|
412
407
|
|
|
408
|
+
webpack: {
|
|
413
409
|
// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
|
|
414
410
|
// See the following for more information:
|
|
415
411
|
// https://docs.sentry.io/product/crons/
|
|
416
412
|
// https://vercel.com/docs/cron-jobs
|
|
417
413
|
automaticVercelMonitors: true,
|
|
418
|
-
|
|
414
|
+
|
|
415
|
+
// Tree-shaking options for reducing bundle size
|
|
416
|
+
treeshake: {
|
|
417
|
+
// Automatically tree-shake Sentry logger statements to reduce bundle size
|
|
418
|
+
removeDebugLogging: true,
|
|
419
|
+
},
|
|
420
|
+
},
|
|
421
|
+
}"
|
|
419
422
|
`);
|
|
420
423
|
});
|
|
421
424
|
(0, vitest_1.it)('generates options for self-hosted', () => {
|
|
@@ -428,37 +431,42 @@ const templates_1 = require("../../src/nextjs/templates");
|
|
|
428
431
|
});
|
|
429
432
|
(0, vitest_1.expect)(template).toMatchInlineSnapshot(`
|
|
430
433
|
"{
|
|
431
|
-
|
|
432
|
-
|
|
434
|
+
// For all available options, see:
|
|
435
|
+
// https://www.npmjs.com/package/@sentry/webpack-plugin#options
|
|
433
436
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
+
org: "my-org",
|
|
438
|
+
project: "my-project",
|
|
439
|
+
sentryUrl: "https://my-sentry.com",
|
|
437
440
|
|
|
438
|
-
|
|
439
|
-
|
|
441
|
+
// Only print logs for uploading source maps in CI
|
|
442
|
+
silent: !process.env.CI,
|
|
440
443
|
|
|
441
|
-
|
|
442
|
-
|
|
444
|
+
// For all available options, see:
|
|
445
|
+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
|
|
443
446
|
|
|
444
|
-
|
|
445
|
-
|
|
447
|
+
// Upload a larger set of source maps for prettier stack traces (increases build time)
|
|
448
|
+
widenClientFileUpload: true,
|
|
446
449
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
// Automatically tree-shake Sentry logger statements to reduce bundle size
|
|
454
|
-
disableLogger: true,
|
|
450
|
+
// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
|
|
451
|
+
// This can increase your server load as well as your hosting bill.
|
|
452
|
+
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
|
|
453
|
+
// side errors will fail.
|
|
454
|
+
tunnelRoute: "/monitoring",
|
|
455
455
|
|
|
456
|
+
webpack: {
|
|
456
457
|
// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
|
|
457
458
|
// See the following for more information:
|
|
458
459
|
// https://docs.sentry.io/product/crons/
|
|
459
460
|
// https://vercel.com/docs/cron-jobs
|
|
460
461
|
automaticVercelMonitors: true,
|
|
461
|
-
|
|
462
|
+
|
|
463
|
+
// Tree-shaking options for reducing bundle size
|
|
464
|
+
treeshake: {
|
|
465
|
+
// Automatically tree-shake Sentry logger statements to reduce bundle size
|
|
466
|
+
removeDebugLogging: true,
|
|
467
|
+
},
|
|
468
|
+
},
|
|
469
|
+
}"
|
|
462
470
|
`);
|
|
463
471
|
});
|
|
464
472
|
(0, vitest_1.it)('comments out tunnelRoute if `tunnelRoute` option is disabled', () => {
|
|
@@ -471,36 +479,41 @@ const templates_1 = require("../../src/nextjs/templates");
|
|
|
471
479
|
});
|
|
472
480
|
(0, vitest_1.expect)(template).toMatchInlineSnapshot(`
|
|
473
481
|
"{
|
|
474
|
-
|
|
475
|
-
|
|
482
|
+
// For all available options, see:
|
|
483
|
+
// https://www.npmjs.com/package/@sentry/webpack-plugin#options
|
|
476
484
|
|
|
477
|
-
|
|
478
|
-
|
|
485
|
+
org: "my-org",
|
|
486
|
+
project: "my-project",
|
|
479
487
|
|
|
480
|
-
|
|
481
|
-
|
|
488
|
+
// Only print logs for uploading source maps in CI
|
|
489
|
+
silent: !process.env.CI,
|
|
482
490
|
|
|
483
|
-
|
|
484
|
-
|
|
491
|
+
// For all available options, see:
|
|
492
|
+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
|
|
485
493
|
|
|
486
|
-
|
|
487
|
-
|
|
494
|
+
// Upload a larger set of source maps for prettier stack traces (increases build time)
|
|
495
|
+
widenClientFileUpload: true,
|
|
488
496
|
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
// Automatically tree-shake Sentry logger statements to reduce bundle size
|
|
496
|
-
disableLogger: true,
|
|
497
|
+
// Uncomment to route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
|
|
498
|
+
// This can increase your server load as well as your hosting bill.
|
|
499
|
+
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
|
|
500
|
+
// side errors will fail.
|
|
501
|
+
// tunnelRoute: "/monitoring",
|
|
497
502
|
|
|
503
|
+
webpack: {
|
|
498
504
|
// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
|
|
499
505
|
// See the following for more information:
|
|
500
506
|
// https://docs.sentry.io/product/crons/
|
|
501
507
|
// https://vercel.com/docs/cron-jobs
|
|
502
508
|
automaticVercelMonitors: true,
|
|
503
|
-
|
|
509
|
+
|
|
510
|
+
// Tree-shaking options for reducing bundle size
|
|
511
|
+
treeshake: {
|
|
512
|
+
// Automatically tree-shake Sentry logger statements to reduce bundle size
|
|
513
|
+
removeDebugLogging: true,
|
|
514
|
+
},
|
|
515
|
+
},
|
|
516
|
+
}"
|
|
504
517
|
`);
|
|
505
518
|
});
|
|
506
519
|
});
|
|
@@ -575,21 +588,21 @@ const templates_1 = require("../../src/nextjs/templates");
|
|
|
575
588
|
(0, vitest_1.it)('generates metadata snippet without TypeScript types', () => {
|
|
576
589
|
const template = (0, templates_1.getGenerateMetadataSnippet)(false);
|
|
577
590
|
(0, vitest_1.expect)(template).toMatchInlineSnapshot(`
|
|
578
|
-
"
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
"
|
|
592
|
-
|
|
591
|
+
"
|
|
592
|
+
import * as Sentry from '@sentry/nextjs';
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
// Add or edit your "generateMetadata" to include the Sentry trace data:
|
|
596
|
+
export function generateMetadata() {
|
|
597
|
+
return {
|
|
598
|
+
// ... your existing metadata
|
|
599
|
+
other: {
|
|
600
|
+
...Sentry.getTraceData()
|
|
601
|
+
}
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
"
|
|
605
|
+
`);
|
|
593
606
|
});
|
|
594
607
|
});
|
|
595
608
|
(0, vitest_1.describe)('getRootLayoutWithGenerateMetadata', () => {
|
|
@@ -628,7 +641,7 @@ const templates_1 = require("../../src/nextjs/templates");
|
|
|
628
641
|
"// This file was generated by the Sentry wizard because we couldn't find a root layout file.
|
|
629
642
|
import * as Sentry from '@sentry/nextjs';
|
|
630
643
|
|
|
631
|
-
|
|
644
|
+
|
|
632
645
|
export function generateMetadata() {
|
|
633
646
|
return {
|
|
634
647
|
other: {
|
|
@@ -689,6 +702,31 @@ const templates_1 = require("../../src/nextjs/templates");
|
|
|
689
702
|
(0, vitest_1.expect)(template).not.toContain('"use client";');
|
|
690
703
|
(0, vitest_1.expect)(template).toContain('https://my-org.sentry.io/issues/?project=123');
|
|
691
704
|
});
|
|
705
|
+
(0, vitest_1.it)('generates example page with logger calls when logsEnabled is true', () => {
|
|
706
|
+
const template = (0, templates_1.getSentryExamplePageContents)({
|
|
707
|
+
selfHosted: false,
|
|
708
|
+
sentryUrl: 'https://sentry.io',
|
|
709
|
+
orgSlug: 'my-org',
|
|
710
|
+
projectId: '123',
|
|
711
|
+
useClient: true,
|
|
712
|
+
isTypeScript: true,
|
|
713
|
+
logsEnabled: true,
|
|
714
|
+
});
|
|
715
|
+
(0, vitest_1.expect)(template).toContain('Sentry.logger.info("Sentry example page loaded")');
|
|
716
|
+
(0, vitest_1.expect)(template).toContain('Sentry.logger.info("User clicked the button, throwing a sample error")');
|
|
717
|
+
});
|
|
718
|
+
(0, vitest_1.it)('generates example page without logger calls when logsEnabled is false', () => {
|
|
719
|
+
const template = (0, templates_1.getSentryExamplePageContents)({
|
|
720
|
+
selfHosted: false,
|
|
721
|
+
sentryUrl: 'https://sentry.io',
|
|
722
|
+
orgSlug: 'my-org',
|
|
723
|
+
projectId: '123',
|
|
724
|
+
useClient: true,
|
|
725
|
+
isTypeScript: true,
|
|
726
|
+
logsEnabled: false,
|
|
727
|
+
});
|
|
728
|
+
(0, vitest_1.expect)(template).not.toContain('Sentry.logger.info');
|
|
729
|
+
});
|
|
692
730
|
});
|
|
693
731
|
(0, vitest_1.describe)('getSentryExamplePagesDirApiRoute', () => {
|
|
694
732
|
(0, vitest_1.it)('generates Pages Router API route with TypeScript types', () => {
|
|
@@ -707,6 +745,22 @@ const templates_1 = require("../../src/nextjs/templates");
|
|
|
707
745
|
(0, vitest_1.expect)(template).toContain('class SentryExampleAPIError extends Error');
|
|
708
746
|
(0, vitest_1.expect)(template).toContain('export default function handler(_req, res)');
|
|
709
747
|
});
|
|
748
|
+
(0, vitest_1.it)('generates Pages Router API route with logger calls when logsEnabled is true', () => {
|
|
749
|
+
const template = (0, templates_1.getSentryExamplePagesDirApiRoute)({
|
|
750
|
+
isTypeScript: true,
|
|
751
|
+
logsEnabled: true,
|
|
752
|
+
});
|
|
753
|
+
(0, vitest_1.expect)(template).toContain('import * as Sentry from "@sentry/nextjs";');
|
|
754
|
+
(0, vitest_1.expect)(template).toContain('Sentry.logger.info("Sentry example API called")');
|
|
755
|
+
});
|
|
756
|
+
(0, vitest_1.it)('generates Pages Router API route without logger calls when logsEnabled is false', () => {
|
|
757
|
+
const template = (0, templates_1.getSentryExamplePagesDirApiRoute)({
|
|
758
|
+
isTypeScript: true,
|
|
759
|
+
logsEnabled: false,
|
|
760
|
+
});
|
|
761
|
+
(0, vitest_1.expect)(template).not.toContain('import * as Sentry from "@sentry/nextjs"');
|
|
762
|
+
(0, vitest_1.expect)(template).not.toContain('Sentry.logger.info');
|
|
763
|
+
});
|
|
710
764
|
});
|
|
711
765
|
(0, vitest_1.describe)('getSentryExampleAppDirApiRoute', () => {
|
|
712
766
|
(0, vitest_1.it)('generates App Router API route with TypeScript types', () => {
|
|
@@ -727,6 +781,21 @@ const templates_1 = require("../../src/nextjs/templates");
|
|
|
727
781
|
(0, vitest_1.expect)(template).toContain('export function GET()');
|
|
728
782
|
(0, vitest_1.expect)(template).toContain('export const dynamic = "force-dynamic";');
|
|
729
783
|
});
|
|
784
|
+
(0, vitest_1.it)('generates App Router API route with logger calls when logsEnabled is true', () => {
|
|
785
|
+
const template = (0, templates_1.getSentryExampleAppDirApiRoute)({
|
|
786
|
+
isTypeScript: true,
|
|
787
|
+
logsEnabled: true,
|
|
788
|
+
});
|
|
789
|
+
(0, vitest_1.expect)(template).toContain('import * as Sentry from "@sentry/nextjs";');
|
|
790
|
+
(0, vitest_1.expect)(template).toContain('Sentry.logger.info("Sentry example API called")');
|
|
791
|
+
});
|
|
792
|
+
(0, vitest_1.it)('generates App Router API route without logger calls when logsEnabled is false', () => {
|
|
793
|
+
const template = (0, templates_1.getSentryExampleAppDirApiRoute)({
|
|
794
|
+
isTypeScript: true,
|
|
795
|
+
logsEnabled: false,
|
|
796
|
+
});
|
|
797
|
+
(0, vitest_1.expect)(template).not.toContain('Sentry.logger.info');
|
|
798
|
+
});
|
|
730
799
|
});
|
|
731
800
|
});
|
|
732
801
|
//# sourceMappingURL=templates.test.js.map
|