@sentry/wizard 6.3.0 → 6.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/e2e-tests/tests/expo.test.js +9 -2
- package/dist/e2e-tests/tests/expo.test.js.map +1 -1
- package/dist/e2e-tests/tests/react-native.test.js +9 -2
- package/dist/e2e-tests/tests/react-native.test.js.map +1 -1
- package/dist/e2e-tests/tests/{sveltekit.test.js → sveltekit-hooks.test.js} +10 -6
- package/dist/e2e-tests/tests/sveltekit-hooks.test.js.map +1 -0
- package/dist/e2e-tests/tests/sveltekit-tracing.test.d.ts +1 -0
- package/dist/e2e-tests/tests/sveltekit-tracing.test.js +203 -0
- package/dist/e2e-tests/tests/sveltekit-tracing.test.js.map +1 -0
- package/dist/src/android/android-wizard.js +9 -1
- package/dist/src/android/android-wizard.js.map +1 -1
- package/dist/src/android/manifest.d.ts +1 -1
- package/dist/src/android/manifest.js +2 -2
- package/dist/src/android/manifest.js.map +1 -1
- package/dist/src/android/templates.d.ts +1 -1
- package/dist/src/android/templates.js +4 -1
- package/dist/src/android/templates.js.map +1 -1
- package/dist/src/react-native/javascript.d.ts +6 -4
- package/dist/src/react-native/javascript.js +11 -7
- package/dist/src/react-native/javascript.js.map +1 -1
- package/dist/src/react-native/react-native-wizard.js +12 -3
- package/dist/src/react-native/react-native-wizard.js.map +1 -1
- package/dist/src/react-native/xcode.d.ts +2 -2
- package/dist/src/react-native/xcode.js +11 -4
- package/dist/src/react-native/xcode.js.map +1 -1
- package/dist/src/sveltekit/sdk-example.d.ts +2 -2
- package/dist/src/sveltekit/sdk-example.js.map +1 -1
- package/dist/src/sveltekit/sdk-setup/setup.d.ts +3 -0
- package/dist/src/sveltekit/{sdk-setup.js → sdk-setup/setup.js} +113 -157
- package/dist/src/sveltekit/sdk-setup/setup.js.map +1 -0
- package/dist/src/sveltekit/sdk-setup/svelte-config.d.ts +25 -0
- package/dist/src/sveltekit/sdk-setup/svelte-config.js +291 -0
- package/dist/src/sveltekit/sdk-setup/svelte-config.js.map +1 -0
- package/dist/src/sveltekit/sdk-setup/types.d.ts +7 -0
- package/dist/src/sveltekit/sdk-setup/types.js +3 -0
- package/dist/src/sveltekit/sdk-setup/types.js.map +1 -0
- package/dist/src/sveltekit/sdk-setup/utils.d.ts +6 -0
- package/dist/src/sveltekit/sdk-setup/utils.js +45 -0
- package/dist/src/sveltekit/sdk-setup/utils.js.map +1 -0
- package/dist/src/sveltekit/sdk-setup/vite.d.ts +2 -0
- package/dist/src/sveltekit/sdk-setup/vite.js +120 -0
- package/dist/src/sveltekit/sdk-setup/vite.js.map +1 -0
- package/dist/src/sveltekit/sveltekit-wizard.js +45 -5
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/sveltekit/templates.d.ts +4 -0
- package/dist/src/sveltekit/templates.js +33 -10
- package/dist/src/sveltekit/templates.js.map +1 -1
- package/dist/src/sveltekit/utils.d.ts +2 -1
- package/dist/src/sveltekit/utils.js +7 -2
- package/dist/src/sveltekit/utils.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/react-native/javascript.test.js +225 -0
- package/dist/test/react-native/javascript.test.js.map +1 -1
- package/dist/test/react-native/xcode.test.js +21 -4
- package/dist/test/react-native/xcode.test.js.map +1 -1
- package/dist/test/sveltekit/sdk-setup/svelte-config.test.d.ts +1 -0
- package/dist/test/sveltekit/sdk-setup/svelte-config.test.js +529 -0
- package/dist/test/sveltekit/sdk-setup/svelte-config.test.js.map +1 -0
- package/dist/test/sveltekit/templates.test.js +103 -10
- package/dist/test/sveltekit/templates.test.js.map +1 -1
- package/package.json +1 -1
- package/dist/e2e-tests/tests/sveltekit.test.js.map +0 -1
- package/dist/src/sveltekit/sdk-setup.d.ts +0 -21
- package/dist/src/sveltekit/sdk-setup.js.map +0 -1
- /package/dist/e2e-tests/tests/{sveltekit.test.d.ts → sveltekit-hooks.test.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 6.5.0
|
|
4
|
+
|
|
5
|
+
- feat(android): Add Logs step ([#1085](https://github.com/getsentry/sentry-wizard/pull/1085))
|
|
6
|
+
- feat(react-native): Add Logs step ([#1080](https://github.com/getsentry/sentry-wizard/pull/1080))
|
|
7
|
+
- fix(react-native): Omits quotes in with-environment.sh parameter script in RN >= 0.81.1 ([#1082](https://github.com/getsentry/sentry-wizard/pull/1082))
|
|
8
|
+
|
|
9
|
+
## 6.4.0
|
|
10
|
+
|
|
11
|
+
- feat(sveltekit): Add support for SDK setup with `instrumentation.server.ts` ([#1077](https://github.com/getsentry/sentry-wizard/pull/1077))
|
|
12
|
+
|
|
13
|
+
This release adds support for setting up the SvelteKit SDK in SvelteKit versions 2.31.0 or higher.
|
|
14
|
+
|
|
3
15
|
## 6.3.0
|
|
4
16
|
|
|
5
17
|
- feat(nextjs,remix,sveltekit,react-native,flutter,ios,angular,android,nuxt): add support to add MCP server during wizard based installlations ([#1063](https://github.com/getsentry/sentry-wizard/pull/1063))
|
|
@@ -41,10 +41,14 @@ const vitest_1 = require("vitest");
|
|
|
41
41
|
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
42
42
|
// Enable session replay
|
|
43
43
|
[utils_1.KEYS.ENTER], 'Do you want to enable the Feedback Widget to collect feedback from your users? (See https://docs.sentry.io/platforms/react-native/user-feedback/)'));
|
|
44
|
-
|
|
45
|
-
const mcpPrompted = feedbackWidgetPrompted &&
|
|
44
|
+
const logsPrompted = feedbackWidgetPrompted &&
|
|
46
45
|
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
47
46
|
// Enable feedback widget
|
|
47
|
+
[utils_1.KEYS.ENTER], 'Do you want to enable Logs? (See https://docs.sentry.io/platforms/react-native/logs/)'));
|
|
48
|
+
// Handle the MCP prompt (default is now Yes, so press DOWN to select No)
|
|
49
|
+
const mcpPrompted = logsPrompted &&
|
|
50
|
+
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
51
|
+
// Enable logs
|
|
48
52
|
[utils_1.KEYS.ENTER], 'Optionally add a project-scoped MCP server configuration for the Sentry MCP?', {
|
|
49
53
|
optional: true,
|
|
50
54
|
}));
|
|
@@ -75,6 +79,9 @@ Sentry.init({
|
|
|
75
79
|
// For more information, visit: https://docs.sentry.io/platforms/react-native/data-management/data-collected/
|
|
76
80
|
sendDefaultPii: true,
|
|
77
81
|
|
|
82
|
+
// Enable Logs
|
|
83
|
+
enableLogs: true,
|
|
84
|
+
|
|
78
85
|
// Configure Session Replay
|
|
79
86
|
replaysSessionSampleRate: 0.1,
|
|
80
87
|
replaysOnErrorSampleRate: 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expo.test.js","sourceRoot":"","sources":["../../../e2e-tests/tests/expo.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,mDAAkD;AAClD,oCASkB;AAClB,mCAAqE;AAErE,IAAA,iBAAQ,EAAC,MAAM,EAAE,GAAG,EAAE;IACpB,MAAM,WAAW,GAAG,uBAAW,CAAC,WAAW,CAAC;IAC5C,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAC7B,SAAS,EACT,iDAAiD,CAClD,CAAC;IAEF,IAAA,kBAAS,EAAC,KAAK,IAAI,EAAE;QACnB,MAAM,cAAc,GAAG,IAAA,2BAAmB,EAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QACpE,MAAM,sBAAsB,GAAG,MAAM,cAAc,CAAC,aAAa,CAC/D,qCAAqC,CACtC,CAAC;QACF,MAAM,qBAAqB,GACzB,sBAAsB;YACtB,CAAC,MAAM,cAAc,CAAC,yBAAyB;YAC7C,0CAA0C;YAC1C,CAAC,YAAI,CAAC,IAAI,EAAE,YAAI,CAAC,IAAI,EAAE,YAAI,CAAC,KAAK,C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sourcesContent":["import * as path from 'node:path';\nimport { Integration } from '../../lib/Constants';\nimport {\n KEYS,\n TEST_ARGS,\n checkFileContents,\n checkFileExists,\n checkIfExpoBundles,\n cleanupGit,\n revertLocalChanges,\n startWizardInstance,\n} from '../utils';\nimport { afterAll, beforeAll, describe, test, expect } from 'vitest';\n\ndescribe('Expo', () => {\n const integration = Integration.reactNative;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/react-native-expo-test-app',\n );\n\n beforeAll(async () => {\n const wizardInstance = startWizardInstance(integration, projectDir);\n const packageManagerPrompted = await wizardInstance.waitForOutput(\n 'Please select your package manager.',\n );\n const sessionReplayPrompted =\n packageManagerPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Selecting `yarn` as the package manager\n [KEYS.DOWN, KEYS.DOWN, KEYS.ENTER],\n 'Do you want to enable Session Replay to help debug issues? (See https://docs.sentry.io/platforms/react-native/session-replay/)',\n ));\n const feedbackWidgetPrompted =\n sessionReplayPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Enable session replay\n [KEYS.ENTER],\n 'Do you want to enable the Feedback Widget to collect feedback from your users? (See https://docs.sentry.io/platforms/react-native/user-feedback/)',\n ));\n const logsPrompted =\n feedbackWidgetPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Enable feedback widget\n [KEYS.ENTER],\n 'Do you want to enable Logs? (See https://docs.sentry.io/platforms/react-native/logs/)',\n ));\n // Handle the MCP prompt (default is now Yes, so press DOWN to select No)\n const mcpPrompted =\n logsPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Enable logs\n [KEYS.ENTER],\n 'Optionally add a project-scoped MCP server configuration for the Sentry MCP?',\n {\n optional: true,\n },\n ));\n const testEventPrompted =\n mcpPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Decline MCP config by selecting No\n [KEYS.DOWN, KEYS.ENTER],\n 'Have you successfully sent a test event?',\n ));\n testEventPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Respond that test event was sent\n [KEYS.ENTER],\n 'Everything is set up!',\n ));\n wizardInstance.kill();\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n test('package.json is updated correctly', () => {\n checkFileContents(`${projectDir}/package.json`, `@sentry/react-native`);\n });\n\n test('_layout.tsx is updated correctly', () => {\n checkFileContents(\n `${projectDir}/app/_layout.tsx`,\n `import * as Sentry from '@sentry/react-native';\n\nSentry.init({\n dsn: 'https://public@dsn.ingest.sentry.io/1337',\n\n // Adds more context data to events (IP address, cookies, user, etc.)\n // For more information, visit: https://docs.sentry.io/platforms/react-native/data-management/data-collected/\n sendDefaultPii: true,\n\n // Enable Logs\n enableLogs: true,\n\n // Configure Session Replay\n replaysSessionSampleRate: 0.1,\n replaysOnErrorSampleRate: 1,\n integrations: [Sentry.mobileReplayIntegration(), Sentry.feedbackIntegration()],\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: __DEV__,\n});`,\n );\n checkFileContents(\n `${projectDir}/app/_layout.tsx`,\n `export default Sentry.wrap(function RootLayout() {`,\n );\n });\n\n test('app.json is updated correctly', () => {\n checkFileContents(\n `${projectDir}/app.json`,\n `\"@sentry/react-native/expo\",\n {\n \"url\": \"https://sentry.io/\",\n \"project\": \"${TEST_ARGS.PROJECT_SLUG}\",\n \"organization\": \"${TEST_ARGS.ORG_SLUG}\"\n }`,\n );\n });\n\n test('metro.config.js is added', () => {\n checkFileExists(`${projectDir}/metro.config.js`);\n checkFileContents(\n `${projectDir}/metro.config.js`,\n `const { getSentryExpoConfig } = require(\"@sentry/react-native/metro\");\n\nconst config = getSentryExpoConfig(__dirname);\n\nmodule.exports = config;`,\n );\n });\n\n test('.gitignore is updated correctly', () => {\n checkFileContents(`${projectDir}/.gitignore`, `.env.local`);\n });\n\n test('android project is bundled correctly', async () => {\n const bundled = await checkIfExpoBundles(projectDir, 'android');\n expect(bundled).toBe(true);\n });\n\n test('ios project is bundled correctly', async () => {\n const bundled = await checkIfExpoBundles(projectDir, 'ios');\n expect(bundled).toBe(true);\n });\n\n test('web project is bundled correctly', async () => {\n const bundled = await checkIfExpoBundles(projectDir, 'web');\n expect(bundled).toBe(true);\n });\n});\n"]}
|
|
@@ -42,10 +42,14 @@ const vitest_1 = require("vitest");
|
|
|
42
42
|
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
43
43
|
// Enable session replay
|
|
44
44
|
[utils_1.KEYS.ENTER], 'Do you want to enable the Feedback Widget to collect feedback from your users? (See https://docs.sentry.io/platforms/react-native/user-feedback/)'));
|
|
45
|
+
const logsPrompted = feedbackWidgetPrompted &&
|
|
46
|
+
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
47
|
+
// Enable feedback widget
|
|
48
|
+
[utils_1.KEYS.ENTER], 'Do you want to enable Logs? (See https://docs.sentry.io/platforms/react-native/logs/)'));
|
|
45
49
|
podInstallPrompted =
|
|
46
|
-
|
|
50
|
+
logsPrompted &&
|
|
47
51
|
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
48
|
-
// Enable
|
|
52
|
+
// Enable logs
|
|
49
53
|
[utils_1.KEYS.ENTER], 'Do you want to run `pod install` now?', {
|
|
50
54
|
optional: true,
|
|
51
55
|
timeout: 5000,
|
|
@@ -94,6 +98,9 @@ Sentry.init({
|
|
|
94
98
|
// For more information, visit: https://docs.sentry.io/platforms/react-native/data-management/data-collected/
|
|
95
99
|
sendDefaultPii: true,
|
|
96
100
|
|
|
101
|
+
// Enable Logs
|
|
102
|
+
enableLogs: true,
|
|
103
|
+
|
|
97
104
|
// Configure Session Replay
|
|
98
105
|
replaysSessionSampleRate: 0.1,
|
|
99
106
|
replaysOnErrorSampleRate: 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-native.test.js","sourceRoot":"","sources":["../../../e2e-tests/tests/react-native.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,mDAAk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AAC;IAC7B,CAAC,CAAC,CAAC;IAEH,IAAA,aAAI,EAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;QAClD,MAAM,OAAO,GAAG,MAAM,IAAA,iCAAyB,EAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QACnE,IAAA,eAAM,EAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import * as path from 'node:path';\nimport { Integration } from '../../lib/Constants';\nimport {\n KEYS,\n TEST_ARGS,\n cleanupGit,\n checkFileContents,\n checkIfReactNativeBundles,\n revertLocalChanges,\n startWizardInstance\n} from '../utils';\nimport { afterAll, beforeAll, describe, test, expect } from 'vitest';\n\ndescribe('ReactNative', () => {\n const integration = Integration.reactNative;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/react-native-test-app',\n );\n\n let podInstallPrompted = false;\n\n beforeAll(async () => {\n const wizardInstance = startWizardInstance(integration, projectDir);\n const packageManagerPrompted = await wizardInstance.waitForOutput(\n 'Please select your package manager.',\n );\n const sessionReplayPrompted =\n packageManagerPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Selecting `yarn` as the package manager\n [KEYS.DOWN, KEYS.DOWN, KEYS.ENTER],\n 'Do you want to enable Session Replay to help debug issues? (See https://docs.sentry.io/platforms/react-native/session-replay/)',\n ));\n\n const feedbackWidgetPrompted =\n sessionReplayPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Enable session replay\n [KEYS.ENTER],\n 'Do you want to enable the Feedback Widget to collect feedback from your users? (See https://docs.sentry.io/platforms/react-native/user-feedback/)',\n ));\n\n podInstallPrompted =\n feedbackWidgetPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Enable feedback widget\n [KEYS.ENTER],\n 'Do you want to run `pod install` now?',\n {\n optional: true,\n timeout: 5000,\n },\n ));\n\n const prettierPrompted =\n podInstallPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Skip pod install\n [KEYS.DOWN, KEYS.ENTER],\n 'Looks like you have Prettier in your project. Do you want to run it on your files?',\n ));\n\n // Handle the MCP prompt (default is now Yes, so press DOWN to select No)\n const mcpPrompted =\n prettierPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Skip prettier\n [KEYS.DOWN, KEYS.ENTER],\n 'Optionally add a project-scoped MCP server configuration for the Sentry MCP?',\n {\n optional: true,\n },\n ));\n\n const testEventPrompted =\n mcpPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Decline MCP config by selecting No\n [KEYS.DOWN, KEYS.ENTER],\n 'Have you successfully sent a test event?',\n ));\n\n testEventPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Respond that test event was sent\n [KEYS.ENTER],\n 'Everything is set up!',\n ));\n wizardInstance.kill();\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n test('package.json is updated correctly', () => {\n checkFileContents(`${projectDir}/package.json`, `@sentry/react-native`);\n });\n\n test('metro.config.js is updated correctly', () => {\n checkFileContents(\n `${projectDir}/metro.config.js`,\n `const {\n withSentryConfig\n} = require(\"@sentry/react-native/metro\");`,\n );\n checkFileContents(\n `${projectDir}/metro.config.js`,\n `module.exports = withSentryConfig(mergeConfig(getDefaultConfig(__dirname), config));`,\n );\n });\n\n test('App.tsx is updated correctly', () => {\n checkFileContents(\n `${projectDir}/App.tsx`,\n `import * as Sentry from '@sentry/react-native';\n\nSentry.init({\n dsn: 'https://public@dsn.ingest.sentry.io/1337',\n\n // Adds more context data to events (IP address, cookies, user, etc.)\n // For more information, visit: https://docs.sentry.io/platforms/react-native/data-management/data-collected/\n sendDefaultPii: true,\n\n // Configure Session Replay\n replaysSessionSampleRate: 0.1,\n replaysOnErrorSampleRate: 1,\n integrations: [Sentry.mobileReplayIntegration(), Sentry.feedbackIntegration()],\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: __DEV__,\n});`,\n );\n checkFileContents(\n `${projectDir}/App.tsx`,\n `export default Sentry.wrap(App);`,\n );\n });\n\n test('ios/sentry.properties is added', () => {\n if (!podInstallPrompted) {\n return;\n }\n checkFileContents(\n `${projectDir}/ios/sentry.properties`,\n `auth.token=${TEST_ARGS.AUTH_TOKEN}\n\ndefaults.org=${TEST_ARGS.ORG_SLUG}\ndefaults.project=${TEST_ARGS.PROJECT_SLUG}\n\ndefaults.url=https://sentry.io/`,\n );\n });\n\n test('android/sentry.properties is added', () => {\n checkFileContents(\n `${projectDir}/android/sentry.properties`,\n `auth.token=${TEST_ARGS.AUTH_TOKEN}\n\ndefaults.org=${TEST_ARGS.ORG_SLUG}\ndefaults.project=${TEST_ARGS.PROJECT_SLUG}\n\ndefaults.url=https://sentry.io/`,\n );\n });\n\n test('build.gradle is updated correctly', () => {\n checkFileContents(\n `${projectDir}/android/app/build.gradle`,\n `apply from: new File([\"node\", \"--print\", \"require.resolve('@sentry/react-native/package.json')\"].execute().text.trim(), \"../sentry.gradle\")`,\n );\n });\n\n test('xcode project is updated correctly', () => {\n if (!podInstallPrompted) {\n return;\n }\n checkFileContents(\n `${projectDir}/ios/reactnative078.xcodeproj/project.pbxproj`,\n `../node_modules/@sentry/react-native/scripts/sentry-xcode.sh`,\n );\n checkFileContents(\n `${projectDir}/ios/reactnative078.xcodeproj/project.pbxproj`,\n `../node_modules/@sentry/react-native/scripts/sentry-xcode-debug-files.sh`,\n );\n });\n\n test('android project is bundled correctly', async () => {\n const bundled = await checkIfReactNativeBundles(projectDir, 'android');\n expect(bundled).toBe(true);\n });\n\n test('ios project is bundled correctly', async () => {\n const bundled = await checkIfReactNativeBundles(projectDir, 'ios');\n expect(bundled).toBe(true);\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"react-native.test.js","sourceRoot":"","sources":["../../../e2e-tests/tests/react-native.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC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IAAI,EAAE;QACtD,MAAM,OAAO,GAAG,MAAM,IAAA,iCAAyB,EAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QACvE,IAAA,eAAM,EAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,IAAA,aAAI,EAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;QAClD,MAAM,OAAO,GAAG,MAAM,IAAA,iCAAyB,EAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QACnE,IAAA,eAAM,EAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import * as path from 'node:path';\nimport { Integration } from '../../lib/Constants';\nimport {\n KEYS,\n TEST_ARGS,\n cleanupGit,\n checkFileContents,\n checkIfReactNativeBundles,\n revertLocalChanges,\n startWizardInstance\n} from '../utils';\nimport { afterAll, beforeAll, describe, test, expect } from 'vitest';\n\ndescribe('ReactNative', () => {\n const integration = Integration.reactNative;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/react-native-test-app',\n );\n\n let podInstallPrompted = false;\n\n beforeAll(async () => {\n const wizardInstance = startWizardInstance(integration, projectDir);\n const packageManagerPrompted = await wizardInstance.waitForOutput(\n 'Please select your package manager.',\n );\n const sessionReplayPrompted =\n packageManagerPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Selecting `yarn` as the package manager\n [KEYS.DOWN, KEYS.DOWN, KEYS.ENTER],\n 'Do you want to enable Session Replay to help debug issues? (See https://docs.sentry.io/platforms/react-native/session-replay/)',\n ));\n\n const feedbackWidgetPrompted =\n sessionReplayPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Enable session replay\n [KEYS.ENTER],\n 'Do you want to enable the Feedback Widget to collect feedback from your users? (See https://docs.sentry.io/platforms/react-native/user-feedback/)',\n ));\n\n const logsPrompted =\n feedbackWidgetPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Enable feedback widget\n [KEYS.ENTER],\n 'Do you want to enable Logs? (See https://docs.sentry.io/platforms/react-native/logs/)',\n ));\n\n podInstallPrompted =\n logsPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Enable logs\n [KEYS.ENTER],\n 'Do you want to run `pod install` now?',\n {\n optional: true,\n timeout: 5000,\n },\n ));\n\n const prettierPrompted =\n podInstallPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Skip pod install\n [KEYS.DOWN, KEYS.ENTER],\n 'Looks like you have Prettier in your project. Do you want to run it on your files?',\n ));\n\n // Handle the MCP prompt (default is now Yes, so press DOWN to select No)\n const mcpPrompted =\n prettierPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Skip prettier\n [KEYS.DOWN, KEYS.ENTER],\n 'Optionally add a project-scoped MCP server configuration for the Sentry MCP?',\n {\n optional: true,\n },\n ));\n\n const testEventPrompted =\n mcpPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Decline MCP config by selecting No\n [KEYS.DOWN, KEYS.ENTER],\n 'Have you successfully sent a test event?',\n ));\n\n testEventPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Respond that test event was sent\n [KEYS.ENTER],\n 'Everything is set up!',\n ));\n wizardInstance.kill();\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n test('package.json is updated correctly', () => {\n checkFileContents(`${projectDir}/package.json`, `@sentry/react-native`);\n });\n\n test('metro.config.js is updated correctly', () => {\n checkFileContents(\n `${projectDir}/metro.config.js`,\n `const {\n withSentryConfig\n} = require(\"@sentry/react-native/metro\");`,\n );\n checkFileContents(\n `${projectDir}/metro.config.js`,\n `module.exports = withSentryConfig(mergeConfig(getDefaultConfig(__dirname), config));`,\n );\n });\n\n test('App.tsx is updated correctly', () => {\n checkFileContents(\n `${projectDir}/App.tsx`,\n `import * as Sentry from '@sentry/react-native';\n\nSentry.init({\n dsn: 'https://public@dsn.ingest.sentry.io/1337',\n\n // Adds more context data to events (IP address, cookies, user, etc.)\n // For more information, visit: https://docs.sentry.io/platforms/react-native/data-management/data-collected/\n sendDefaultPii: true,\n\n // Enable Logs\n enableLogs: true,\n\n // Configure Session Replay\n replaysSessionSampleRate: 0.1,\n replaysOnErrorSampleRate: 1,\n integrations: [Sentry.mobileReplayIntegration(), Sentry.feedbackIntegration()],\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: __DEV__,\n});`,\n );\n checkFileContents(\n `${projectDir}/App.tsx`,\n `export default Sentry.wrap(App);`,\n );\n });\n\n test('ios/sentry.properties is added', () => {\n if (!podInstallPrompted) {\n return;\n }\n checkFileContents(\n `${projectDir}/ios/sentry.properties`,\n `auth.token=${TEST_ARGS.AUTH_TOKEN}\n\ndefaults.org=${TEST_ARGS.ORG_SLUG}\ndefaults.project=${TEST_ARGS.PROJECT_SLUG}\n\ndefaults.url=https://sentry.io/`,\n );\n });\n\n test('android/sentry.properties is added', () => {\n checkFileContents(\n `${projectDir}/android/sentry.properties`,\n `auth.token=${TEST_ARGS.AUTH_TOKEN}\n\ndefaults.org=${TEST_ARGS.ORG_SLUG}\ndefaults.project=${TEST_ARGS.PROJECT_SLUG}\n\ndefaults.url=https://sentry.io/`,\n );\n });\n\n test('build.gradle is updated correctly', () => {\n checkFileContents(\n `${projectDir}/android/app/build.gradle`,\n `apply from: new File([\"node\", \"--print\", \"require.resolve('@sentry/react-native/package.json')\"].execute().text.trim(), \"../sentry.gradle\")`,\n );\n });\n\n test('xcode project is updated correctly', () => {\n if (!podInstallPrompted) {\n return;\n }\n checkFileContents(\n `${projectDir}/ios/reactnative078.xcodeproj/project.pbxproj`,\n `../node_modules/@sentry/react-native/scripts/sentry-xcode.sh`,\n );\n checkFileContents(\n `${projectDir}/ios/reactnative078.xcodeproj/project.pbxproj`,\n `../node_modules/@sentry/react-native/scripts/sentry-xcode-debug-files.sh`,\n );\n });\n\n test('android project is bundled correctly', async () => {\n const bundled = await checkIfReactNativeBundles(projectDir, 'android');\n expect(bundled).toBe(true);\n });\n\n test('ios project is bundled correctly', async () => {\n const bundled = await checkIfReactNativeBundles(projectDir, 'ios');\n expect(bundled).toBe(true);\n });\n});\n"]}
|
|
@@ -52,16 +52,20 @@ export async function handleError({ error, event }) {
|
|
|
52
52
|
`;
|
|
53
53
|
async function runWizardOnSvelteKitProject(projectDir, integration, fileModificationFn) {
|
|
54
54
|
const wizardInstance = (0, utils_1.startWizardInstance)(integration, projectDir);
|
|
55
|
-
let
|
|
55
|
+
let kitVersionPrompted = false;
|
|
56
56
|
if (fileModificationFn) {
|
|
57
57
|
fileModificationFn(projectDir, integration);
|
|
58
58
|
// As we modified project, we have a warning prompt before we get the package manager prompt
|
|
59
59
|
await wizardInstance.waitForOutput('Do you want to continue anyway?');
|
|
60
|
-
|
|
60
|
+
kitVersionPrompted = await wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER], "It seems you're using a SvelteKit version");
|
|
61
61
|
}
|
|
62
62
|
else {
|
|
63
|
-
|
|
63
|
+
kitVersionPrompted = await wizardInstance.waitForOutput("It seems you're using a SvelteKit version");
|
|
64
64
|
}
|
|
65
|
+
const packageManagerPrompted = kitVersionPrompted &&
|
|
66
|
+
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
67
|
+
// Select "Yes, Continue" to perform hooks-based SDK setup
|
|
68
|
+
[utils_1.KEYS.DOWN, utils_1.KEYS.DOWN, utils_1.KEYS.ENTER], 'Please select your package manager.'));
|
|
65
69
|
const tracingOptionPrompted = packageManagerPrompted &&
|
|
66
70
|
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
67
71
|
// Selecting `yarn` as the package manager
|
|
@@ -132,7 +136,7 @@ function checkSvelteKitProject(projectDir, integration, options) {
|
|
|
132
136
|
(0, vitest_1.describe)('Sveltekit', () => {
|
|
133
137
|
(0, vitest_1.describe)('without existing hooks', () => {
|
|
134
138
|
const integration = Constants_1.Integration.sveltekit;
|
|
135
|
-
const projectDir = path.resolve(__dirname, '../test-applications/sveltekit-test-app');
|
|
139
|
+
const projectDir = path.resolve(__dirname, '../test-applications/sveltekit-hooks-test-app');
|
|
136
140
|
(0, vitest_1.beforeAll)(async () => {
|
|
137
141
|
await runWizardOnSvelteKitProject(projectDir, integration);
|
|
138
142
|
});
|
|
@@ -186,7 +190,7 @@ function checkSvelteKitProject(projectDir, integration, options) {
|
|
|
186
190
|
});
|
|
187
191
|
(0, vitest_1.describe)('with existing hooks', () => {
|
|
188
192
|
const integration = Constants_1.Integration.sveltekit;
|
|
189
|
-
const projectDir = path.resolve(__dirname, '../test-applications/sveltekit-test-app');
|
|
193
|
+
const projectDir = path.resolve(__dirname, '../test-applications/sveltekit-hooks-test-app');
|
|
190
194
|
(0, vitest_1.beforeAll)(async () => {
|
|
191
195
|
await runWizardOnSvelteKitProject(projectDir, integration, (projectDir) => {
|
|
192
196
|
(0, utils_1.createFile)(path.resolve(projectDir, 'src/hooks.server.ts'), SERVER_HOOK_TEMPLATE);
|
|
@@ -227,4 +231,4 @@ function checkSvelteKitProject(projectDir, integration, options) {
|
|
|
227
231
|
});
|
|
228
232
|
});
|
|
229
233
|
});
|
|
230
|
-
//# sourceMappingURL=sveltekit.test.js.map
|
|
234
|
+
//# sourceMappingURL=sveltekit-hooks.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sveltekit-hooks.test.js","sourceRoot":"","sources":["../../../e2e-tests/tests/sveltekit-hooks.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,mDAAkD;AAClD,oCAckB;AAClB,mCAA6D;AAE7D,MAAM,oBAAoB,GAAG;;;;;;;;;;CAU5B,CAAC;AACF,MAAM,oBAAoB,GAAG;;;;;;;;;;;CAW5B,CAAC;AAEF,KAAK,UAAU,2BAA2B,CACxC,UAAkB,EAClB,WAAwB,EACxB,kBAGY;I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AI,CAAC,OAAO,CAAC,UAAU,EAAE,qBAAqB,CAAC,EAC/C,oBAAoB,CACrB,CAAC;YACJ,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,IAAA,iBAAQ,EAAC,GAAG,EAAE;YACZ,IAAA,0BAAkB,EAAC,UAAU,CAAC,CAAC;YAC/B,IAAA,kBAAU,EAAC,UAAU,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,qBAAqB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QAE/C,sEAAsE;QACtE,iEAAiE;QACjE,IAAA,aAAI,EAAC,iDAAiD,EAAE,GAAG,EAAE;YAC3D,IAAA,yBAAiB,EAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,qBAAqB,CAAC,EAAE;gBACjE,8CAA8C;gBAC9C;YACI,iBAAS,CAAC,WAAW;;;;;;GAM9B;gBACK,0DAA0D;aAC3D,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAA,aAAI,EAAC,sCAAsC,EAAE,GAAG,EAAE;YAChD,IAAA,yBAAiB,EAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,qBAAqB,CAAC,EAAE;gBACjE,8CAA8C;gBAC9C;YACI,iBAAS,CAAC,WAAW;;;GAG9B;gBACK,4DAA4D;aAC7D,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import * as path from 'node:path';\nimport { Integration } from '../../lib/Constants';\nimport {\n KEYS,\n TEST_ARGS,\n checkEnvBuildPlugin,\n checkFileContents,\n checkFileExists,\n checkIfBuilds,\n checkIfRunsOnDevMode,\n checkIfRunsOnProdMode,\n checkPackageJson,\n cleanupGit,\n createFile,\n revertLocalChanges,\n startWizardInstance,\n} from '../utils';\nimport { afterAll, beforeAll, describe, test } from 'vitest';\n\nconst SERVER_HOOK_TEMPLATE = `import type { Handle } from '@sveltejs/kit';\n\nexport const handle: Handle = async ({ event, resolve }) => {\n\tif (event.url.pathname.startsWith('/custom')) {\n\t\treturn new Response('custom response');\n\t}\n\n\tconst response = await resolve(event);\n\treturn response;\n};\n`;\nconst CLIENT_HOOK_TEMPLATE = `\nexport async function handleError({ error, event }) {\n // you can capture the \\`error\\` and \\`event\\` from the client\n // but it only runs if the unexpected error comes from \\`+ page.ts\\`\n console.log(error)\n\n return {\n // don't show sensitive data to the user\n message: 'Yikes! 💩',\n }\n}\n`;\n\nasync function runWizardOnSvelteKitProject(\n projectDir: string,\n integration: Integration,\n fileModificationFn?: (\n projectDir: string,\n integration: Integration,\n ) => unknown,\n) {\n const wizardInstance = startWizardInstance(integration, projectDir);\n let kitVersionPrompted = false;\n\n if (fileModificationFn) {\n fileModificationFn(projectDir, integration);\n\n // As we modified project, we have a warning prompt before we get the package manager prompt\n await wizardInstance.waitForOutput('Do you want to continue anyway?');\n\n kitVersionPrompted = await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n \"It seems you're using a SvelteKit version\",\n );\n } else {\n kitVersionPrompted = await wizardInstance.waitForOutput(\n \"It seems you're using a SvelteKit version\",\n );\n }\n\n const packageManagerPrompted =\n kitVersionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Select \"Yes, Continue\" to perform hooks-based SDK setup\n [KEYS.DOWN, KEYS.DOWN, KEYS.ENTER],\n 'Please select your package manager.',\n ));\n\n const tracingOptionPrompted =\n packageManagerPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Selecting `yarn` as the package manager\n [KEYS.DOWN, KEYS.ENTER],\n // \"Do you want to enable Tracing\", sometimes doesn't work as `Tracing` can be printed in bold.\n 'to track the performance of your application?',\n {\n timeout: 240_000,\n },\n ));\n\n const replayOptionPrompted =\n tracingOptionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n // \"Do you want to enable Sentry Session Replay\", sometimes doesn't work as `Sentry Session Replay` can be printed in bold.\n 'to get a video-like reproduction of errors during a user session?',\n ));\n\n const logsOptionPrompted =\n replayOptionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n // \"Do you want to enable Logs\", sometimes doesn't work as `Logs` can be printed in bold.\n 'to send your application logs to Sentry?',\n ));\n\n const examplePagePrompted =\n logsOptionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n 'Do you want to create an example page',\n {\n optional: true,\n },\n ));\n\n // After the example page prompt, we send ENTER to accept it\n // Then handle the MCP prompt that comes after\n const mcpPrompted =\n examplePagePrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER], // This ENTER is for accepting the example page\n 'Optionally add a project-scoped MCP server configuration for the Sentry MCP?',\n {\n optional: true,\n },\n ));\n\n // Decline MCP config (default is Yes, so press DOWN then ENTER to select No)\n if (mcpPrompted) {\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.DOWN, KEYS.ENTER],\n 'Successfully installed the Sentry SvelteKit SDK!',\n );\n } else {\n // If MCP wasn't prompted, wait for success message directly\n await wizardInstance.waitForOutput(\n 'Successfully installed the Sentry SvelteKit SDK!',\n );\n }\n\n wizardInstance.kill();\n}\n\nfunction checkSvelteKitProject(\n projectDir: string,\n integration: Integration,\n options?: {\n devModeExpectedOutput: string;\n prodModeExpectedOutput: string;\n },\n) {\n test('should have the correct package.json', () => {\n checkPackageJson(projectDir, integration);\n });\n\n test('should have the correct .env.sentry-build-plugin', () => {\n checkEnvBuildPlugin(projectDir);\n });\n\n test('example page exists', () => {\n checkFileExists(\n path.resolve(projectDir, 'src/routes/sentry-example-page/+page.svelte'),\n );\n checkFileExists(\n path.resolve(projectDir, 'src/routes/sentry-example-page/+server.js'),\n );\n });\n\n test('vite.config contains sentry plugin', () => {\n checkFileContents(\n path.resolve(projectDir, 'vite.config.ts'),\n `plugins: [sentrySvelteKit({\n sourceMapsUploadOptions: {\n`,\n );\n });\n\n test('hook files created', () => {\n checkFileExists(path.resolve(projectDir, 'src/hooks.server.ts'));\n checkFileExists(path.resolve(projectDir, 'src/hooks.client.ts'));\n });\n\n test('builds successfully', async () => {\n await checkIfBuilds(projectDir);\n });\n\n test('runs on dev mode correctly', async () => {\n await checkIfRunsOnDevMode(\n projectDir,\n options?.devModeExpectedOutput || 'ready in',\n );\n });\n\n test('runs on prod mode correctly', async () => {\n await checkIfRunsOnProdMode(\n projectDir,\n options?.prodModeExpectedOutput || 'to expose',\n 'preview',\n );\n });\n}\n\ndescribe('Sveltekit', () => {\n describe('without existing hooks', () => {\n const integration = Integration.sveltekit;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/sveltekit-hooks-test-app',\n );\n\n beforeAll(async () => {\n await runWizardOnSvelteKitProject(projectDir, integration);\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n checkSvelteKitProject(projectDir, integration);\n\n test('hooks.client.ts contains sentry', () => {\n checkFileContents(path.resolve(projectDir, 'src/hooks.client.ts'), [\n `import * as Sentry from '@sentry/sveltekit';`,\n `Sentry.init({\n dsn: '${TEST_ARGS.PROJECT_DSN}',\n\n tracesSampleRate: 1.0,\n\n // Enable logs to be sent to Sentry\n enableLogs: true,\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: [replayIntegration()],\n});`,\n 'export const handleError = handleErrorWithSentry(',\n ]);\n });\n\n test('hooks.server.ts contains sentry', () => {\n checkFileContents(path.resolve(projectDir, 'src/hooks.server.ts'), [\n `import * as Sentry from '@sentry/sveltekit';`,\n `Sentry.init({\n dsn: '${TEST_ARGS.PROJECT_DSN}',\n\n tracesSampleRate: 1.0,\n\n // Enable logs to be sent to Sentry\n enableLogs: true,\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n});`,\n 'export const handleError = handleErrorWithSentry();',\n ]);\n });\n });\n\n describe('with existing hooks', () => {\n const integration = Integration.sveltekit;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/sveltekit-hooks-test-app',\n );\n\n beforeAll(async () => {\n await runWizardOnSvelteKitProject(\n projectDir,\n integration,\n (projectDir) => {\n createFile(\n path.resolve(projectDir, 'src/hooks.server.ts'),\n SERVER_HOOK_TEMPLATE,\n );\n\n createFile(\n path.resolve(projectDir, 'src/hooks.client.ts'),\n CLIENT_HOOK_TEMPLATE,\n );\n },\n );\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n checkSvelteKitProject(projectDir, integration);\n\n // These are removed from the common tests as the content is different\n // when the hooks are merged instead of created from the template\n test('hooks.client.ts contains sentry instrumentation', () => {\n checkFileContents(path.resolve(projectDir, 'src/hooks.client.ts'), [\n `import * as Sentry from '@sentry/sveltekit';`,\n `Sentry.init({\n dsn: \"${TEST_ARGS.PROJECT_DSN}\",\n tracesSampleRate: 1,\n replaysSessionSampleRate: 0.1,\n replaysOnErrorSampleRate: 1,\n integrations: [Sentry.replayIntegration()],\n enableLogs: true\n})`,\n 'export const handleError = Sentry.handleErrorWithSentry(',\n ]);\n });\n\n test('hooks.server.ts contains sentry init', () => {\n checkFileContents(path.resolve(projectDir, 'src/hooks.server.ts'), [\n `import * as Sentry from '@sentry/sveltekit';`,\n `Sentry.init({\n dsn: \"${TEST_ARGS.PROJECT_DSN}\",\n tracesSampleRate: 1,\n enableLogs: true\n})`,\n 'export const handleError = Sentry.handleErrorWithSentry();',\n ]);\n });\n });\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,203 @@
|
|
|
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 path = __importStar(require("node:path"));
|
|
27
|
+
const fs = __importStar(require("node:fs"));
|
|
28
|
+
const Constants_1 = require("../../lib/Constants");
|
|
29
|
+
const utils_1 = require("../utils");
|
|
30
|
+
const vitest_1 = require("vitest");
|
|
31
|
+
//@ts-expect-error - clifty is ESM only
|
|
32
|
+
const clifty_1 = require("clifty");
|
|
33
|
+
(0, vitest_1.describe)('Sveltekit with instrumentation and tracing', () => {
|
|
34
|
+
(0, vitest_1.describe)('without existing files', () => {
|
|
35
|
+
const projectDir = path.resolve(__dirname, '../test-applications/sveltekit-tracing-test-app');
|
|
36
|
+
const integration = Constants_1.Integration.sveltekit;
|
|
37
|
+
let wizardExitCode;
|
|
38
|
+
(0, vitest_1.beforeAll)(async () => {
|
|
39
|
+
(0, utils_1.initGit)(projectDir);
|
|
40
|
+
(0, utils_1.revertLocalChanges)(projectDir);
|
|
41
|
+
wizardExitCode = await (0, clifty_1.withEnv)({
|
|
42
|
+
cwd: projectDir,
|
|
43
|
+
})
|
|
44
|
+
.defineInteraction()
|
|
45
|
+
.expectOutput('The Sentry SvelteKit Wizard will help you set up Sentry for your application')
|
|
46
|
+
.step('package installation', ({ expectOutput, whenAsked }) => {
|
|
47
|
+
whenAsked('Please select your package manager.').respondWith(clifty_1.KEYS.DOWN, clifty_1.KEYS.ENTER);
|
|
48
|
+
expectOutput('Installing @sentry/sveltekit');
|
|
49
|
+
})
|
|
50
|
+
.step('SDK setup', ({ whenAsked }) => {
|
|
51
|
+
whenAsked('Do you want to enable Tracing', {
|
|
52
|
+
timeout: 90000, // package installation can take a while in CI
|
|
53
|
+
}).respondWith(clifty_1.KEYS.ENTER);
|
|
54
|
+
whenAsked('Do you want to enable Session Replay').respondWith(clifty_1.KEYS.ENTER);
|
|
55
|
+
whenAsked('Do you want to enable Logs').respondWith(clifty_1.KEYS.ENTER);
|
|
56
|
+
})
|
|
57
|
+
.whenAsked('Do you want to create an example page')
|
|
58
|
+
.respondWith(clifty_1.KEYS.ENTER)
|
|
59
|
+
.whenAsked('Optionally add a project-scoped MCP server configuration for the Sentry MCP?')
|
|
60
|
+
.respondWith(clifty_1.KEYS.DOWN, clifty_1.KEYS.ENTER)
|
|
61
|
+
.expectOutput('Successfully installed the Sentry SvelteKit SDK!')
|
|
62
|
+
.run((0, utils_1.getWizardCommand)(integration));
|
|
63
|
+
});
|
|
64
|
+
(0, vitest_1.afterAll)(() => {
|
|
65
|
+
(0, utils_1.revertLocalChanges)(projectDir);
|
|
66
|
+
(0, utils_1.cleanupGit)(projectDir);
|
|
67
|
+
});
|
|
68
|
+
(0, vitest_1.it)('exits with exit code 0', () => {
|
|
69
|
+
(0, vitest_1.expect)(wizardExitCode).toBe(0);
|
|
70
|
+
});
|
|
71
|
+
(0, vitest_1.it)('adds the SDK dependency to package.json', () => {
|
|
72
|
+
(0, utils_1.checkPackageJson)(projectDir, integration);
|
|
73
|
+
});
|
|
74
|
+
(0, vitest_1.it)('adds the .env.sentry-build-plugin', () => {
|
|
75
|
+
(0, utils_1.checkEnvBuildPlugin)(projectDir);
|
|
76
|
+
});
|
|
77
|
+
(0, vitest_1.it)('adds the example page', () => {
|
|
78
|
+
(0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/routes/sentry-example-page/+page.svelte'));
|
|
79
|
+
(0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/routes/sentry-example-page/+server.js'));
|
|
80
|
+
});
|
|
81
|
+
(0, vitest_1.it)('adds the sentry plugin to vite.config.ts', () => {
|
|
82
|
+
const viteConfig = fs.readFileSync(path.resolve(projectDir, 'vite.config.ts'));
|
|
83
|
+
(0, vitest_1.expect)(viteConfig.toString()).toMatchInlineSnapshot(`
|
|
84
|
+
"import { sentrySvelteKit } from "@sentry/sveltekit";
|
|
85
|
+
import { sveltekit } from '@sveltejs/kit/vite';
|
|
86
|
+
import { defineConfig } from 'vite';
|
|
87
|
+
|
|
88
|
+
export default defineConfig({
|
|
89
|
+
plugins: [sentrySvelteKit({
|
|
90
|
+
sourceMapsUploadOptions: {
|
|
91
|
+
org: "${utils_1.TEST_ARGS.ORG_SLUG}",
|
|
92
|
+
project: "${utils_1.TEST_ARGS.PROJECT_SLUG}"
|
|
93
|
+
}
|
|
94
|
+
}), sveltekit()]
|
|
95
|
+
});"
|
|
96
|
+
`);
|
|
97
|
+
});
|
|
98
|
+
(0, vitest_1.it)('creates the hook files', () => {
|
|
99
|
+
const clientHooks = fs.readFileSync(path.resolve(projectDir, 'src/hooks.client.ts'));
|
|
100
|
+
const serverHooks = fs.readFileSync(path.resolve(projectDir, 'src/hooks.server.ts'));
|
|
101
|
+
(0, vitest_1.expect)(clientHooks.toString()).toMatchInlineSnapshot(`
|
|
102
|
+
"import { handleErrorWithSentry, replayIntegration } from "@sentry/sveltekit";
|
|
103
|
+
import * as Sentry from '@sentry/sveltekit';
|
|
104
|
+
|
|
105
|
+
Sentry.init({
|
|
106
|
+
dsn: '${utils_1.TEST_ARGS.PROJECT_DSN}',
|
|
107
|
+
|
|
108
|
+
tracesSampleRate: 1.0,
|
|
109
|
+
|
|
110
|
+
// Enable logs to be sent to Sentry
|
|
111
|
+
enableLogs: true,
|
|
112
|
+
|
|
113
|
+
// This sets the sample rate to be 10%. You may want this to be 100% while
|
|
114
|
+
// in development and sample at a lower rate in production
|
|
115
|
+
replaysSessionSampleRate: 0.1,
|
|
116
|
+
|
|
117
|
+
// If the entire session is not sampled, use the below sample rate to sample
|
|
118
|
+
// sessions when an error occurs.
|
|
119
|
+
replaysOnErrorSampleRate: 1.0,
|
|
120
|
+
|
|
121
|
+
// If you don't want to use Session Replay, just remove the line below:
|
|
122
|
+
integrations: [replayIntegration()],
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// If you have a custom error handler, pass it to \`handleErrorWithSentry\`
|
|
126
|
+
export const handleError = handleErrorWithSentry();
|
|
127
|
+
"
|
|
128
|
+
`);
|
|
129
|
+
(0, vitest_1.expect)(serverHooks.toString()).toMatchInlineSnapshot(`
|
|
130
|
+
"import {sequence} from "@sveltejs/kit/hooks";
|
|
131
|
+
import * as Sentry from "@sentry/sveltekit";
|
|
132
|
+
export const handle = sequence(Sentry.sentryHandle(), async ({ event, resolve }) => {
|
|
133
|
+
const response = await resolve(event);
|
|
134
|
+
return response;
|
|
135
|
+
});
|
|
136
|
+
export const handleError = Sentry.handleErrorWithSentry();"
|
|
137
|
+
`);
|
|
138
|
+
});
|
|
139
|
+
(0, vitest_1.it)('creates the insturmentation.server file', () => {
|
|
140
|
+
const instrumentationServer = fs.readFileSync(path.resolve(projectDir, 'src/instrumentation.server.ts'));
|
|
141
|
+
(0, vitest_1.expect)(instrumentationServer.toString()).toMatchInlineSnapshot(`
|
|
142
|
+
"import * as Sentry from '@sentry/sveltekit';
|
|
143
|
+
|
|
144
|
+
Sentry.init({
|
|
145
|
+
dsn: '${utils_1.TEST_ARGS.PROJECT_DSN}',
|
|
146
|
+
|
|
147
|
+
tracesSampleRate: 1.0,
|
|
148
|
+
|
|
149
|
+
// Enable logs to be sent to Sentry
|
|
150
|
+
enableLogs: true,
|
|
151
|
+
|
|
152
|
+
// uncomment the line below to enable Spotlight (https://spotlightjs.com)
|
|
153
|
+
// spotlight: import.meta.env.DEV,
|
|
154
|
+
});"
|
|
155
|
+
`);
|
|
156
|
+
});
|
|
157
|
+
(0, vitest_1.it)('enables tracing and instrumentation in svelte.config.js', () => {
|
|
158
|
+
const svelteConfig = fs.readFileSync(path.resolve(projectDir, 'svelte.config.js'));
|
|
159
|
+
(0, vitest_1.expect)(svelteConfig.toString()).toMatchInlineSnapshot(`
|
|
160
|
+
"import adapter from '@sveltejs/adapter-node';
|
|
161
|
+
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
|
162
|
+
|
|
163
|
+
/** @type {import('@sveltejs/kit').Config} */
|
|
164
|
+
const config = {
|
|
165
|
+
// Consult https://svelte.dev/docs/kit/integrations#preprocessors
|
|
166
|
+
// for more information about preprocessors
|
|
167
|
+
preprocess: vitePreprocess(),
|
|
168
|
+
|
|
169
|
+
kit: {
|
|
170
|
+
// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
|
|
171
|
+
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
|
|
172
|
+
// See https://svelte.dev/docs/kit/adapters for more information about adapters.
|
|
173
|
+
adapter: adapter(),
|
|
174
|
+
experimental: {
|
|
175
|
+
remoteFunctions: true,
|
|
176
|
+
|
|
177
|
+
tracing: {
|
|
178
|
+
server: true,
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
instrumentation: {
|
|
182
|
+
server: true,
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
export default config;"
|
|
189
|
+
`);
|
|
190
|
+
});
|
|
191
|
+
// checkSvelteKitProject(projectDir, integration);
|
|
192
|
+
(0, vitest_1.it)('builds successfully', async () => {
|
|
193
|
+
await (0, utils_1.checkIfBuilds)(projectDir);
|
|
194
|
+
});
|
|
195
|
+
(0, vitest_1.it)('runs on dev mode correctly', async () => {
|
|
196
|
+
await (0, utils_1.checkIfRunsOnDevMode)(projectDir, 'ready in');
|
|
197
|
+
});
|
|
198
|
+
(0, vitest_1.it)('runs on prod mode correctly', async () => {
|
|
199
|
+
await (0, utils_1.checkIfRunsOnProdMode)(projectDir, 'to expose', 'preview');
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
//# sourceMappingURL=sveltekit-tracing.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sveltekit-tracing.test.js","sourceRoot":"","sources":["../../../e2e-tests/tests/sveltekit-tracing.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,4CAA8B;AAC9B,mDAAkD;AAClD,oCAYkB;AAClB,mCAAmE;AAEnE,uCAAuC;AACvC,mCAAuC;AAEvC,IAAA,iBAAQ,EAAC,4CAA4C,EAAE,GAAG,EAAE;IAC1D,IAAA,iBAAQ,EAAC,wBAAwB,EAAE,GAAG,EAAE;QACtC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAC7B,SAAS,EACT,iDAAiD,CAClD,CAAC;QAEF,MAAM,WAAW,GAAG,uBAAW,CAAC,SAAS,CAAC;QAC1C,IAAI,cAAsB,CAAC;QAE3B,IAAA,kBAAS,EAAC,KAAK,IAAI,EAAE;YACnB,IAAA,eAAO,EAAC,UAAU,CAAC,CAAC;YACpB,IAAA,0BAAkB,EAAC,UAAU,CAAC,CAAC;YAE/B,cAAc,GAAG,MAAM,IAAA,gBAAO,EAAC;gBAC7B,GAAG,EAAE,UAAU;aAChB,CAAC;iBACC,iBAAiB,EAAE;iBACnB,YAAY,CACX,8EAA8E,CAC/E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,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import * as path from 'node:path';\nimport * as fs from 'node:fs';\nimport { Integration } from '../../lib/Constants';\nimport {\n checkEnvBuildPlugin,\n checkFileExists,\n checkIfBuilds,\n checkIfRunsOnDevMode,\n checkIfRunsOnProdMode,\n checkPackageJson,\n cleanupGit,\n getWizardCommand,\n initGit,\n revertLocalChanges,\n TEST_ARGS,\n} from '../utils';\nimport { afterAll, beforeAll, describe, expect, it } from 'vitest';\n\n//@ts-expect-error - clifty is ESM only\nimport { KEYS, withEnv } from 'clifty';\n\ndescribe('Sveltekit with instrumentation and tracing', () => {\n describe('without existing files', () => {\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/sveltekit-tracing-test-app',\n );\n\n const integration = Integration.sveltekit;\n let wizardExitCode: number;\n\n beforeAll(async () => {\n initGit(projectDir);\n revertLocalChanges(projectDir);\n\n wizardExitCode = await withEnv({\n cwd: projectDir,\n })\n .defineInteraction()\n .expectOutput(\n 'The Sentry SvelteKit Wizard will help you set up Sentry for your application',\n )\n .step('package installation', ({ expectOutput, whenAsked }) => {\n whenAsked('Please select your package manager.').respondWith(\n KEYS.DOWN,\n KEYS.ENTER,\n );\n expectOutput('Installing @sentry/sveltekit');\n })\n .step('SDK setup', ({ whenAsked }) => {\n whenAsked('Do you want to enable Tracing', {\n timeout: 90_000, // package installation can take a while in CI\n }).respondWith(KEYS.ENTER);\n whenAsked('Do you want to enable Session Replay').respondWith(\n KEYS.ENTER,\n );\n whenAsked('Do you want to enable Logs').respondWith(KEYS.ENTER);\n })\n .whenAsked('Do you want to create an example page')\n .respondWith(KEYS.ENTER)\n .whenAsked(\n 'Optionally add a project-scoped MCP server configuration for the Sentry MCP?',\n )\n .respondWith(KEYS.DOWN, KEYS.ENTER)\n .expectOutput('Successfully installed the Sentry SvelteKit SDK!')\n .run(getWizardCommand(integration));\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n it('exits with exit code 0', () => {\n expect(wizardExitCode).toBe(0);\n });\n\n it('adds the SDK dependency to package.json', () => {\n checkPackageJson(projectDir, integration);\n });\n\n it('adds the .env.sentry-build-plugin', () => {\n checkEnvBuildPlugin(projectDir);\n });\n\n it('adds the example page', () => {\n checkFileExists(\n path.resolve(projectDir, 'src/routes/sentry-example-page/+page.svelte'),\n );\n checkFileExists(\n path.resolve(projectDir, 'src/routes/sentry-example-page/+server.js'),\n );\n });\n\n it('adds the sentry plugin to vite.config.ts', () => {\n const viteConfig = fs.readFileSync(\n path.resolve(projectDir, 'vite.config.ts'),\n );\n expect(viteConfig.toString()).toMatchInlineSnapshot(`\n \"import { sentrySvelteKit } from \"@sentry/sveltekit\";\n import { sveltekit } from '@sveltejs/kit/vite';\n import { defineConfig } from 'vite';\n\n export default defineConfig({\n \tplugins: [sentrySvelteKit({\n sourceMapsUploadOptions: {\n org: \"${TEST_ARGS.ORG_SLUG}\",\n project: \"${TEST_ARGS.PROJECT_SLUG}\"\n }\n }), sveltekit()]\n });\"\n `);\n });\n\n it('creates the hook files', () => {\n const clientHooks = fs.readFileSync(\n path.resolve(projectDir, 'src/hooks.client.ts'),\n );\n const serverHooks = fs.readFileSync(\n path.resolve(projectDir, 'src/hooks.server.ts'),\n );\n\n expect(clientHooks.toString()).toMatchInlineSnapshot(`\n \"import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: '${TEST_ARGS.PROJECT_DSN}',\n\n tracesSampleRate: 1.0,\n\n // Enable logs to be sent to Sentry\n enableLogs: true,\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: [replayIntegration()],\n });\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n\n expect(serverHooks.toString()).toMatchInlineSnapshot(`\n \"import {sequence} from \"@sveltejs/kit/hooks\";\n import * as Sentry from \"@sentry/sveltekit\";\n export const handle = sequence(Sentry.sentryHandle(), async ({ event, resolve }) => {\n const response = await resolve(event);\n return response;\n });\n export const handleError = Sentry.handleErrorWithSentry();\"\n `);\n });\n\n it('creates the insturmentation.server file', () => {\n const instrumentationServer = fs.readFileSync(\n path.resolve(projectDir, 'src/instrumentation.server.ts'),\n );\n\n expect(instrumentationServer.toString()).toMatchInlineSnapshot(`\n \"import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: '${TEST_ARGS.PROJECT_DSN}',\n\n tracesSampleRate: 1.0,\n\n // Enable logs to be sent to Sentry\n enableLogs: true,\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n });\"\n `);\n });\n\n it('enables tracing and instrumentation in svelte.config.js', () => {\n const svelteConfig = fs.readFileSync(\n path.resolve(projectDir, 'svelte.config.js'),\n );\n expect(svelteConfig.toString()).toMatchInlineSnapshot(`\n \"import adapter from '@sveltejs/adapter-node';\n import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';\n\n /** @type {import('@sveltejs/kit').Config} */\n const config = {\n // Consult https://svelte.dev/docs/kit/integrations#preprocessors\n // for more information about preprocessors\n preprocess: vitePreprocess(),\n\n kit: {\n // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.\n // If your environment is not supported, or you settled on a specific environment, switch out the adapter.\n // See https://svelte.dev/docs/kit/adapters for more information about adapters.\n adapter: adapter(),\n experimental: {\n remoteFunctions: true,\n\n tracing: {\n server: true,\n },\n\n instrumentation: {\n server: true,\n },\n },\n },\n };\n\n export default config;\"\n `);\n });\n\n // checkSvelteKitProject(projectDir, integration);\n it('builds successfully', async () => {\n await checkIfBuilds(projectDir);\n });\n\n it('runs on dev mode correctly', async () => {\n await checkIfRunsOnDevMode(projectDir, 'ready in');\n });\n\n it('runs on prod mode correctly', async () => {\n await checkIfRunsOnProdMode(projectDir, 'to expose', 'preview');\n });\n });\n});\n"]}
|
|
@@ -74,6 +74,14 @@ async function runAndroidWizardWithTelemetry(options) {
|
|
|
74
74
|
}
|
|
75
75
|
const appFile = await (0, telemetry_1.traceStep)('Select App File', () => gradle.selectAppFile(buildGradleFiles));
|
|
76
76
|
const { selectedProject, selfHosted, sentryUrl, authToken } = await (0, clack_1.getOrAskForProjectData)(options, 'android');
|
|
77
|
+
// Ask if user wants to enable Sentry Logs
|
|
78
|
+
const enableLogs = await (0, clack_1.abortIfCancelled)(clack.confirm({
|
|
79
|
+
message: 'Do you want to enable Logs? (See https://docs.sentry.io/platforms/android/logs/)',
|
|
80
|
+
}));
|
|
81
|
+
Sentry.setTag('enable-logs', enableLogs);
|
|
82
|
+
if (enableLogs) {
|
|
83
|
+
clack.log.info('Logs will be enabled with default settings. You can send logs using the Sentry.logger() APIs or use one of the integrations: https://docs.sentry.io/platforms/android/logs/#integrations.');
|
|
84
|
+
}
|
|
77
85
|
// ======== STEP 1. Add Sentry Gradle Plugin to build.gradle(.kts) ============
|
|
78
86
|
clack.log.step(`Adding ${chalk_1.default.bold('Sentry Gradle plugin')} to your app's ${chalk_1.default.cyan('build.gradle')} file.`);
|
|
79
87
|
const pluginAdded = await (0, telemetry_1.traceStep)('Add Gradle Plugin', () => gradle.addGradlePlugin(appFile, selectedProject.organization.slug, selectedProject.slug));
|
|
@@ -85,7 +93,7 @@ async function runAndroidWizardWithTelemetry(options) {
|
|
|
85
93
|
clack.log.step(`Configuring Sentry SDK via ${chalk_1.default.cyan('AndroidManifest.xml')}`);
|
|
86
94
|
const appDir = path.dirname(appFile);
|
|
87
95
|
const manifestFile = path.join(appDir, 'src', 'main', 'AndroidManifest.xml');
|
|
88
|
-
const manifestUpdated = (0, telemetry_1.traceStep)('Update Android Manifest', () => manifest.addManifestSnippet(manifestFile, selectedProject.keys[0].dsn.public));
|
|
96
|
+
const manifestUpdated = (0, telemetry_1.traceStep)('Update Android Manifest', () => manifest.addManifestSnippet(manifestFile, selectedProject.keys[0].dsn.public, enableLogs));
|
|
89
97
|
if (!manifestUpdated) {
|
|
90
98
|
clack.log.warn("Could not configure the Sentry SDK. You'll have to do it manually.\nPlease follow the instructions at https://docs.sentry.io/platforms/android/#configure");
|
|
91
99
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"android-wizard.js","sourceRoot":"","sources":["../../../src/android/android-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA4D;AAC5D,uCAAyB;AACzB,+EAA+E;AAC/E,sDAAwC;AACxC,qDAAuC;AACvC,kDAA0B;AAC1B,2CAA6B;AAC7B,4CAAwD;AACxD,0CAQwB;AAExB,0DAAwE;AACxE,wDAA0C;AAC1C,iDAAmC;AACnC,qDAAuC;AAEvC,MAAM,6BAA6B,GAAmB;IACpD,GAAG,gCAAwB;IAC3B,IAAI,EAAE,mBAAmB;CAC1B,CAAC;AAEK,KAAK,UAAU,gBAAgB,CAAC,OAAsB;IAC3D,OAAO,IAAA,yBAAa,EAClB;QACE,OAAO,EAAE,OAAO,CAAC,gBAAgB;QACjC,WAAW,EAAE,SAAS;QACtB,aAAa,EAAE,OAAO;KACvB,EACD,GAAG,EAAE,CAAC,6BAA6B,CAAC,OAAO,CAAC,CAC7C,CAAC;AACJ,CAAC;AATD,4CASC;AAED,KAAK,UAAU,6BAA6B,CAC1C,OAAsB;IAEtB,IAAA,oBAAY,EAAC;QACX,UAAU,EAAE,uBAAuB;QACnC,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAC,CAAC;IAEH,MAAM,IAAA,yCAAiC,EAAC;QACtC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,GAAG,EAAE,SAAS;KACf,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,OAAO,C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CAAC;;EAEnE,eAAK,CAAC,IAAI,CACV;EACA,cAAc,EAAE,CACjB;;;;GAIE,CAAC,CAAC;AACL,CAAC;AAED,qCAAqC;AACrC,SAAS,uBAAuB,CAC9B,GAAW,EACX,UAAoB,EACpB,sBAAgC,EAAE;IAElC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC1B,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE;YACtB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAC3C,uBAAuB,CAAC,QAAQ,EAAE,UAAU,EAAE,mBAAmB,CAAC,CAAC;SACpE;aAAM,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE;YAC5D,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACzE;KACF;IACD,OAAO,mBAAmB,CAAC;AAC7B,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport * as fs from 'fs';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport * as Sentry from '@sentry/node';\nimport chalk from 'chalk';\nimport * as path from 'path';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport {\n CliSetupConfig,\n abort,\n addSentryCliConfig,\n confirmContinueIfNoOrDirtyGitRepo,\n getOrAskForProjectData,\n printWelcome,\n propertiesCliSetupConfig,\n} from '../utils/clack';\nimport { WizardOptions } from '../utils/types';\nimport { offerProjectScopedMcpConfig } from '../utils/clack/mcp-config';\nimport * as codetools from './code-tools';\nimport * as gradle from './gradle';\nimport * as manifest from './manifest';\n\nconst proguardMappingCliSetupConfig: CliSetupConfig = {\n ...propertiesCliSetupConfig,\n name: 'proguard mappings',\n};\n\nexport async function runAndroidWizard(options: WizardOptions): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'android',\n wizardOptions: options,\n },\n () => runAndroidWizardWithTelemetry(options),\n );\n}\n\nasync function runAndroidWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry Android Wizard',\n promoCode: options.promoCode,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\n\n const projectDir = process.cwd();\n const buildGradleFiles = findFilesWithExtensions(projectDir, [\n '.gradle',\n 'gradle.kts',\n ]);\n\n if (!buildGradleFiles || buildGradleFiles.length === 0) {\n clack.log.error(\n 'No Gradle project found. Please run this command from the root of your project.',\n );\n Sentry.captureException('No Gradle project found');\n await abort();\n return;\n }\n\n const appFile = await traceStep('Select App File', () =>\n gradle.selectAppFile(buildGradleFiles),\n );\n\n const { selectedProject, selfHosted, sentryUrl, authToken } =\n await getOrAskForProjectData(options, 'android');\n\n // ======== STEP 1. Add Sentry Gradle Plugin to build.gradle(.kts) ============\n clack.log.step(\n `Adding ${chalk.bold('Sentry Gradle plugin')} to your app's ${chalk.cyan(\n 'build.gradle',\n )} file.`,\n );\n const pluginAdded = await traceStep('Add Gradle Plugin', () =>\n gradle.addGradlePlugin(\n appFile,\n selectedProject.organization.slug,\n selectedProject.slug,\n ),\n );\n if (!pluginAdded) {\n clack.log.warn(\n \"Could not add Sentry Gradle plugin to your app's build.gradle file. You'll have to add it manually.\\nPlease follow the instructions at https://docs.sentry.io/platforms/android/#install\",\n );\n }\n Sentry.setTag('gradle-plugin-added', pluginAdded);\n\n // ======== STEP 2. Configure Sentry SDK via AndroidManifest ============\n clack.log.step(\n `Configuring Sentry SDK via ${chalk.cyan('AndroidManifest.xml')}`,\n );\n const appDir = path.dirname(appFile);\n const manifestFile = path.join(appDir, 'src', 'main', 'AndroidManifest.xml');\n\n const manifestUpdated = traceStep('Update Android Manifest', () =>\n manifest.addManifestSnippet(\n manifestFile,\n selectedProject.keys[0].dsn.public,\n ),\n );\n if (!manifestUpdated) {\n clack.log.warn(\n \"Could not configure the Sentry SDK. You'll have to do it manually.\\nPlease follow the instructions at https://docs.sentry.io/platforms/android/#configure\",\n );\n }\n Sentry.setTag('android-manifest-updated', manifestUpdated);\n\n // ======== STEP 3. Patch Main Activity with a test error snippet ============\n clack.log.step(\n `Patching ${chalk.bold('Main Activity')} with a test error snippet.`,\n );\n const mainActivity = traceStep('Find Main Activity', () =>\n manifest.getMainActivity(manifestFile),\n );\n let packageName = mainActivity.packageName;\n if (!packageName) {\n // if no package name in AndroidManifest, look into gradle script\n packageName = gradle.getNamespace(appFile);\n }\n const activityName = mainActivity.activityName;\n Sentry.setTag('has-activity-name', !!activityName);\n Sentry.setTag('has-package-name', !!packageName);\n if (!activityName || !packageName) {\n clack.log.warn(\n \"Could not find Activity with intent action MAIN. You'll have to manually verify the setup.\\nPlease follow the instructions at https://docs.sentry.io/platforms/android/#verify\",\n );\n Sentry.captureException('Could not find Main Activity');\n } else {\n const packageNameStable = packageName;\n const activityFile = traceStep('Find Main Activity Source File', () =>\n codetools.findActivitySourceFile(appDir, packageNameStable, activityName),\n );\n\n const activityPatched = traceStep('Patch Main Activity', () =>\n codetools.patchMainActivity(activityFile),\n );\n if (!activityPatched) {\n clack.log.warn(\n \"Could not patch main activity. You'll have to manually verify the setup.\\nPlease follow the instructions at https://docs.sentry.io/platforms/android/#verify\",\n );\n }\n Sentry.setTag('main-activity-patched', activityPatched);\n }\n\n // ======== STEP 4. Add sentry-cli config file ============\n clack.log.step(\n `Configuring ${chalk.bold('proguard mappings upload')} via the ${chalk.cyan(\n 'sentry.properties',\n )} file.`,\n );\n\n await addSentryCliConfig({ authToken }, proguardMappingCliSetupConfig);\n\n // Offer optional project-scoped MCP config for Sentry with org and project scope\n await offerProjectScopedMcpConfig(\n selectedProject.organization.slug,\n selectedProject.slug,\n );\n\n // ======== OUTRO ========\n const issuesPageLink = selfHosted\n ? `${sentryUrl}organizations/${selectedProject.organization.slug}/issues/?project=${selectedProject.id}`\n : `https://${selectedProject.organization.slug}.sentry.io/issues/?project=${selectedProject.id}`;\n\n clack.outro(`\n${chalk.greenBright('Successfully installed the Sentry Android SDK!')}\n\n${chalk.cyan(\n `You can validate your setup by launching your application and checking Sentry issues page afterwards\n${issuesPageLink}`,\n)}\n\nCheck out the SDK documentation for further configuration:\nhttps://docs.sentry.io/platforms/android/\n `);\n}\n\n//find files with the given extension\nfunction findFilesWithExtensions(\n dir: string,\n extensions: string[],\n filesWithExtensions: string[] = [],\n): string[] {\n const cwd = process.cwd();\n const files = fs.readdirSync(dir, { withFileTypes: true });\n for (const file of files) {\n if (file.isDirectory()) {\n const childDir = path.join(dir, file.name);\n findFilesWithExtensions(childDir, extensions, filesWithExtensions);\n } else if (extensions.some((ext) => file.name.endsWith(ext))) {\n filesWithExtensions.push(path.relative(cwd, path.join(dir, file.name)));\n }\n }\n return filesWithExtensions;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"android-wizard.js","sourceRoot":"","sources":["../../../src/android/android-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA4D;AAC5D,uCAAyB;AACzB,+EAA+E;AAC/E,sDAAwC;AACxC,qDAAuC;AACvC,kDAA0B;AAC1B,2CAA6B;AAC7B,4CAAwD;AACxD,0CASwB;AAExB,0DAAwE;AACxE,wDAA0C;AAC1C,iDAAmC;AACnC,qDAAuC;AAEvC,MAAM,6BAA6B,GAAmB;IACpD,GAAG,gCAAwB;IAC3B,IAAI,EAAE,mBAAmB;CAC1B,CAAC;AA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AAC,WAAW,EAAE,EAAE;YACtB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAC3C,uBAAuB,CAAC,QAAQ,EAAE,UAAU,EAAE,mBAAmB,CAAC,CAAC;SACpE;aAAM,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE;YAC5D,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACzE;KACF;IACD,OAAO,mBAAmB,CAAC;AAC7B,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport * as fs from 'fs';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport * as Sentry from '@sentry/node';\nimport chalk from 'chalk';\nimport * as path from 'path';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport {\n CliSetupConfig,\n abort,\n abortIfCancelled,\n addSentryCliConfig,\n confirmContinueIfNoOrDirtyGitRepo,\n getOrAskForProjectData,\n printWelcome,\n propertiesCliSetupConfig,\n} from '../utils/clack';\nimport { WizardOptions } from '../utils/types';\nimport { offerProjectScopedMcpConfig } from '../utils/clack/mcp-config';\nimport * as codetools from './code-tools';\nimport * as gradle from './gradle';\nimport * as manifest from './manifest';\n\nconst proguardMappingCliSetupConfig: CliSetupConfig = {\n ...propertiesCliSetupConfig,\n name: 'proguard mappings',\n};\n\nexport async function runAndroidWizard(options: WizardOptions): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'android',\n wizardOptions: options,\n },\n () => runAndroidWizardWithTelemetry(options),\n );\n}\n\nasync function runAndroidWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry Android Wizard',\n promoCode: options.promoCode,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\n\n const projectDir = process.cwd();\n const buildGradleFiles = findFilesWithExtensions(projectDir, [\n '.gradle',\n 'gradle.kts',\n ]);\n\n if (!buildGradleFiles || buildGradleFiles.length === 0) {\n clack.log.error(\n 'No Gradle project found. Please run this command from the root of your project.',\n );\n Sentry.captureException('No Gradle project found');\n await abort();\n return;\n }\n\n const appFile = await traceStep('Select App File', () =>\n gradle.selectAppFile(buildGradleFiles),\n );\n\n const { selectedProject, selfHosted, sentryUrl, authToken } =\n await getOrAskForProjectData(options, 'android');\n\n // Ask if user wants to enable Sentry Logs\n const enableLogs = await abortIfCancelled(\n clack.confirm({\n message:\n 'Do you want to enable Logs? (See https://docs.sentry.io/platforms/android/logs/)',\n }),\n );\n Sentry.setTag('enable-logs', enableLogs);\n\n if (enableLogs) {\n clack.log.info(\n 'Logs will be enabled with default settings. You can send logs using the Sentry.logger() APIs or use one of the integrations: https://docs.sentry.io/platforms/android/logs/#integrations.',\n );\n }\n\n // ======== STEP 1. Add Sentry Gradle Plugin to build.gradle(.kts) ============\n clack.log.step(\n `Adding ${chalk.bold('Sentry Gradle plugin')} to your app's ${chalk.cyan(\n 'build.gradle',\n )} file.`,\n );\n const pluginAdded = await traceStep('Add Gradle Plugin', () =>\n gradle.addGradlePlugin(\n appFile,\n selectedProject.organization.slug,\n selectedProject.slug,\n ),\n );\n if (!pluginAdded) {\n clack.log.warn(\n \"Could not add Sentry Gradle plugin to your app's build.gradle file. You'll have to add it manually.\\nPlease follow the instructions at https://docs.sentry.io/platforms/android/#install\",\n );\n }\n Sentry.setTag('gradle-plugin-added', pluginAdded);\n\n // ======== STEP 2. Configure Sentry SDK via AndroidManifest ============\n clack.log.step(\n `Configuring Sentry SDK via ${chalk.cyan('AndroidManifest.xml')}`,\n );\n const appDir = path.dirname(appFile);\n const manifestFile = path.join(appDir, 'src', 'main', 'AndroidManifest.xml');\n\n const manifestUpdated = traceStep('Update Android Manifest', () =>\n manifest.addManifestSnippet(\n manifestFile,\n selectedProject.keys[0].dsn.public,\n enableLogs,\n ),\n );\n if (!manifestUpdated) {\n clack.log.warn(\n \"Could not configure the Sentry SDK. You'll have to do it manually.\\nPlease follow the instructions at https://docs.sentry.io/platforms/android/#configure\",\n );\n }\n Sentry.setTag('android-manifest-updated', manifestUpdated);\n\n // ======== STEP 3. Patch Main Activity with a test error snippet ============\n clack.log.step(\n `Patching ${chalk.bold('Main Activity')} with a test error snippet.`,\n );\n const mainActivity = traceStep('Find Main Activity', () =>\n manifest.getMainActivity(manifestFile),\n );\n let packageName = mainActivity.packageName;\n if (!packageName) {\n // if no package name in AndroidManifest, look into gradle script\n packageName = gradle.getNamespace(appFile);\n }\n const activityName = mainActivity.activityName;\n Sentry.setTag('has-activity-name', !!activityName);\n Sentry.setTag('has-package-name', !!packageName);\n if (!activityName || !packageName) {\n clack.log.warn(\n \"Could not find Activity with intent action MAIN. You'll have to manually verify the setup.\\nPlease follow the instructions at https://docs.sentry.io/platforms/android/#verify\",\n );\n Sentry.captureException('Could not find Main Activity');\n } else {\n const packageNameStable = packageName;\n const activityFile = traceStep('Find Main Activity Source File', () =>\n codetools.findActivitySourceFile(appDir, packageNameStable, activityName),\n );\n\n const activityPatched = traceStep('Patch Main Activity', () =>\n codetools.patchMainActivity(activityFile),\n );\n if (!activityPatched) {\n clack.log.warn(\n \"Could not patch main activity. You'll have to manually verify the setup.\\nPlease follow the instructions at https://docs.sentry.io/platforms/android/#verify\",\n );\n }\n Sentry.setTag('main-activity-patched', activityPatched);\n }\n\n // ======== STEP 4. Add sentry-cli config file ============\n clack.log.step(\n `Configuring ${chalk.bold('proguard mappings upload')} via the ${chalk.cyan(\n 'sentry.properties',\n )} file.`,\n );\n\n await addSentryCliConfig({ authToken }, proguardMappingCliSetupConfig);\n\n // Offer optional project-scoped MCP config for Sentry with org and project scope\n await offerProjectScopedMcpConfig(\n selectedProject.organization.slug,\n selectedProject.slug,\n );\n\n // ======== OUTRO ========\n const issuesPageLink = selfHosted\n ? `${sentryUrl}organizations/${selectedProject.organization.slug}/issues/?project=${selectedProject.id}`\n : `https://${selectedProject.organization.slug}.sentry.io/issues/?project=${selectedProject.id}`;\n\n clack.outro(`\n${chalk.greenBright('Successfully installed the Sentry Android SDK!')}\n\n${chalk.cyan(\n `You can validate your setup by launching your application and checking Sentry issues page afterwards\n${issuesPageLink}`,\n)}\n\nCheck out the SDK documentation for further configuration:\nhttps://docs.sentry.io/platforms/android/\n `);\n}\n\n//find files with the given extension\nfunction findFilesWithExtensions(\n dir: string,\n extensions: string[],\n filesWithExtensions: string[] = [],\n): string[] {\n const cwd = process.cwd();\n const files = fs.readdirSync(dir, { withFileTypes: true });\n for (const file of files) {\n if (file.isDirectory()) {\n const childDir = path.join(dir, file.name);\n findFilesWithExtensions(childDir, extensions, filesWithExtensions);\n } else if (extensions.some((ext) => file.name.endsWith(ext))) {\n filesWithExtensions.push(path.relative(cwd, path.join(dir, file.name)));\n }\n }\n return filesWithExtensions;\n}\n"]}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* @param dsn
|
|
19
19
|
* @returns true if successfully patched the manifest, false otherwise
|
|
20
20
|
*/
|
|
21
|
-
export declare function addManifestSnippet(manifestFile: string, dsn: string): boolean;
|
|
21
|
+
export declare function addManifestSnippet(manifestFile: string, dsn: string, enableLogs: boolean): boolean;
|
|
22
22
|
/**
|
|
23
23
|
* There might be multiple <activity> in the manifest, as well as multiple <activity-alias> with category LAUNCHER,
|
|
24
24
|
* but only one main activity with action MAIN. We are looking for this one by parsing xml and walking it.
|
|
@@ -56,7 +56,7 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
56
56
|
* @param dsn
|
|
57
57
|
* @returns true if successfully patched the manifest, false otherwise
|
|
58
58
|
*/
|
|
59
|
-
function addManifestSnippet(manifestFile, dsn) {
|
|
59
|
+
function addManifestSnippet(manifestFile, dsn, enableLogs) {
|
|
60
60
|
if (!fs.existsSync(manifestFile)) {
|
|
61
61
|
clack.log.warn('AndroidManifest.xml not found.');
|
|
62
62
|
Sentry.captureException('No AndroidManifest file');
|
|
@@ -76,7 +76,7 @@ function addManifestSnippet(manifestFile, dsn) {
|
|
|
76
76
|
}
|
|
77
77
|
const insertionIndex = applicationMatch.index;
|
|
78
78
|
const newContent = manifestContent.slice(0, insertionIndex) +
|
|
79
|
-
(0, templates_1.manifest)(dsn) +
|
|
79
|
+
(0, templates_1.manifest)(dsn, enableLogs) +
|
|
80
80
|
manifestContent.slice(insertionIndex);
|
|
81
81
|
fs.writeFileSync(manifestFile, newContent, 'utf8');
|
|
82
82
|
clack.log.success(chalk_1.default.greenBright(`Updated ${chalk_1.default.bold('AndroidManifest.xml')} with the Sentry SDK configuration.`));
|