@sentry/wizard 6.1.2 → 6.3.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 +25 -0
- package/dist/e2e-tests/tests/angular-17.test.js +5 -0
- package/dist/e2e-tests/tests/angular-17.test.js.map +1 -1
- package/dist/e2e-tests/tests/angular-19.test.js +5 -0
- package/dist/e2e-tests/tests/angular-19.test.js.map +1 -1
- 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/flutter.test.js +32 -4
- package/dist/e2e-tests/tests/flutter.test.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs-14.test.js +4 -3
- package/dist/e2e-tests/tests/nextjs-14.test.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs-15.test.js +17 -4
- package/dist/e2e-tests/tests/nextjs-15.test.js.map +1 -1
- package/dist/e2e-tests/tests/nuxt-3.test.js +9 -2
- package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -1
- package/dist/e2e-tests/tests/nuxt-4.test.js +9 -2
- package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -1
- package/dist/e2e-tests/tests/react-native.test.js +8 -1
- package/dist/e2e-tests/tests/react-native.test.js.map +1 -1
- package/dist/e2e-tests/tests/remix.test.js +19 -4
- package/dist/e2e-tests/tests/remix.test.js.map +1 -1
- package/dist/e2e-tests/tests/sveltekit.test.js +16 -2
- package/dist/e2e-tests/tests/sveltekit.test.js.map +1 -1
- package/dist/lib/Steps/Integrations/Electron.js +4 -0
- package/dist/lib/Steps/Integrations/Electron.js.map +1 -1
- package/dist/src/android/android-wizard.js +3 -0
- package/dist/src/android/android-wizard.js.map +1 -1
- package/dist/src/angular/angular-wizard.js +3 -0
- package/dist/src/angular/angular-wizard.js.map +1 -1
- package/dist/src/apple/apple-wizard.js +13 -0
- package/dist/src/apple/apple-wizard.js.map +1 -1
- package/dist/src/apple/code-tools.d.ts +1 -1
- package/dist/src/apple/code-tools.js +3 -3
- package/dist/src/apple/code-tools.js.map +1 -1
- package/dist/src/apple/inject-code-snippet.d.ts +2 -1
- package/dist/src/apple/inject-code-snippet.js +2 -2
- package/dist/src/apple/inject-code-snippet.js.map +1 -1
- package/dist/src/apple/templates.d.ts +2 -2
- package/dist/src/apple/templates.js +22 -6
- package/dist/src/apple/templates.js.map +1 -1
- package/dist/src/flutter/code-tools.d.ts +1 -0
- package/dist/src/flutter/code-tools.js +6 -0
- package/dist/src/flutter/code-tools.js.map +1 -1
- package/dist/src/flutter/flutter-wizard.js +3 -0
- package/dist/src/flutter/flutter-wizard.js.map +1 -1
- package/dist/src/flutter/templates.d.ts +1 -0
- package/dist/src/flutter/templates.js +5 -0
- package/dist/src/flutter/templates.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +14 -7
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nextjs/utils.d.ts +8 -0
- package/dist/src/nextjs/utils.js +36 -1
- package/dist/src/nextjs/utils.js.map +1 -1
- package/dist/src/nuxt/nuxt-wizard.js +3 -0
- package/dist/src/nuxt/nuxt-wizard.js.map +1 -1
- package/dist/src/react-native/expo-metro.d.ts +2 -2
- package/dist/src/react-native/expo-metro.js +32 -27
- package/dist/src/react-native/expo-metro.js.map +1 -1
- package/dist/src/react-native/metro.d.ts +4 -4
- package/dist/src/react-native/metro.js +39 -17
- package/dist/src/react-native/metro.js.map +1 -1
- package/dist/src/react-native/react-native-wizard.js +3 -0
- package/dist/src/react-native/react-native-wizard.js.map +1 -1
- package/dist/src/remix/codemods/root.d.ts +1 -0
- package/dist/src/remix/codemods/root.js +30 -2
- package/dist/src/remix/codemods/root.js.map +1 -1
- package/dist/src/remix/remix-wizard.d.ts +4 -0
- package/dist/src/remix/remix-wizard.js +7 -0
- package/dist/src/remix/remix-wizard.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js +3 -0
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/utils/clack/mcp-config.d.ts +7 -0
- package/dist/src/utils/clack/mcp-config.js +427 -0
- package/dist/src/utils/clack/mcp-config.js.map +1 -0
- 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 +3 -0
- package/dist/test/angular/angular-wizard.test.js.map +1 -1
- package/dist/test/apple/code-tools.test.js +62 -14
- package/dist/test/apple/code-tools.test.js.map +1 -1
- package/dist/test/apple/templates.test.js +71 -2
- package/dist/test/apple/templates.test.js.map +1 -1
- package/dist/test/flutter/code-tools.test.js +1 -0
- package/dist/test/flutter/code-tools.test.js.map +1 -1
- package/dist/test/flutter/templates.test.js +31 -1
- package/dist/test/flutter/templates.test.js.map +1 -1
- package/dist/test/nextjs/wizard-double-wrap-prevention.test.d.ts +1 -0
- package/dist/test/nextjs/wizard-double-wrap-prevention.test.js +269 -0
- package/dist/test/nextjs/wizard-double-wrap-prevention.test.js.map +1 -0
- package/dist/test/nuxt/templates.test.js +3 -0
- package/dist/test/nuxt/templates.test.js.map +1 -1
- package/dist/test/react-native/expo-metro.test.js +3 -3
- package/dist/test/react-native/expo-metro.test.js.map +1 -1
- package/dist/test/react-native/metro.test.js +76 -15
- package/dist/test/react-native/metro.test.js.map +1 -1
- package/dist/test/remix/root.test.js +229 -0
- package/dist/test/remix/root.test.js.map +1 -1
- package/dist/test/sveltekit/templates.test.js +3 -0
- package/dist/test/sveltekit/templates.test.js.map +1 -1
- package/dist/test/utils/clack/mcp-config.test.d.ts +1 -0
- package/dist/test/utils/clack/mcp-config.test.js +520 -0
- package/dist/test/utils/clack/mcp-config.test.js.map +1 -0
- package/package.json +1 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-wizard.js","sourceRoot":"","sources":["../../../src/angular/angular-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC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AS;YACd,OAAO,EAAE,eAAe,CAAC,YAAY,CAAC,IAAI;YAC1C,SAAS,EAAE,eAAe,CAAC,EAAE;SAC9B,CAAC,CACL,CAAC;KACH;IAED,MAAM,IAAA,qBAAS,EAAC,cAAc,EAAE,KAAK,IAAI,EAAE;QACzC,MAAM,IAAA,8BAAsB,EAAC,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,iBAAK,CAAC,KAAK,CAAC,iBAAiB,CAAC,4BAA4B,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED,SAAgB,iBAAiB,CAAC,uBAAgC;IAChE,IAAI,GAAG,GAAG,eAAK,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;IAE1E,IAAI,uBAAuB,EAAE;QAC3B,GAAG,IAAI,qEAAqE,eAAK,CAAC,IAAI,CACpF,UAAU,CACX,mDAAmD,CAAC;KACtD;IAED,GAAG,IAAI;4DACmD,CAAC;IAE3D,OAAO,GAAG,CAAC;AACb,CAAC;AAbD,8CAaC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\n\nimport chalk from 'chalk';\nimport type { WizardOptions } from '../utils/types';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport {\n abortIfCancelled,\n askShouldCreateExampleComponent,\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n featureSelectionPrompt,\n getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n printWelcome,\n runPrettierIfInstalled,\n abort,\n} from '../utils/clack';\nimport { getPackageVersion, hasPackageInstalled } from '../utils/package-json';\nimport { gte, minVersion, SemVer } from 'semver';\n\nimport * as Sentry from '@sentry/node';\nimport { initializeSentryOnApplicationEntry } from './sdk-setup';\nimport { updateAppConfig } from './sdk-setup';\nimport { runSourcemapsWizard } from '../sourcemaps/sourcemaps-wizard';\nimport { addSourcemapEntryToAngularJSON } from './codemods/sourcemaps';\nimport { createExampleComponent } from './example-component';\n\nconst MIN_SUPPORTED_ANGULAR_VERSION = '14.0.0';\nconst MIN_SUPPORTED_WIZARD_ANGULAR_VERSION = '17.0.0';\n\nexport async function runAngularWizard(options: WizardOptions): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'angular',\n wizardOptions: options,\n },\n () => runAngularWizardWithTelemetry(options),\n );\n}\n\nasync function runAngularWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry Angular Wizard',\n promoCode: options.promoCode,\n telemetryEnabled: options.telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\n\n const packageJson = await getPackageDotJson();\n\n await ensurePackageIsInstalled(packageJson, '@angular/core', 'Angular');\n\n let installedAngularVersion = getPackageVersion('@angular/core', packageJson);\n\n if (!installedAngularVersion) {\n clack.log.warn('Could not determine installed Angular version.');\n\n installedAngularVersion = await abortIfCancelled(\n clack.text({\n message: `Please enter your installed Angular major version (e.g. ${chalk.cyan(\n '18',\n )} for Angular 18)`,\n validate(value) {\n if (!value) {\n return 'Angular version is required';\n }\n\n try {\n if (!minVersion(value)) {\n return `Invalid Angular version provided: ${value}`;\n }\n } catch (error) {\n return `Invalid Angular version provided: ${value}`;\n }\n },\n }),\n );\n }\n\n Sentry.setTag('angular-version', installedAngularVersion);\n\n const installedMinVersion = minVersion(installedAngularVersion) as SemVer;\n\n const sdkSupportsAngularVersion = gte(\n installedMinVersion,\n MIN_SUPPORTED_ANGULAR_VERSION,\n );\n\n const wizardSupportsAngularVersion = gte(\n installedMinVersion,\n MIN_SUPPORTED_WIZARD_ANGULAR_VERSION,\n );\n\n if (!sdkSupportsAngularVersion) {\n Sentry.setTag('angular-version-compatible', false);\n\n clack.log.warn(\n `Angular version ${chalk.cyan(\n MIN_SUPPORTED_ANGULAR_VERSION,\n )} or higher is required for the Sentry SDK.`,\n );\n clack.log.warn(\n `Please refer to Sentry's version compatibility table for more information:\n\n${chalk.underline(\n 'https://docs.sentry.io/platforms/javascript/guides/angular/#angular-version-compatibility',\n)}\n`,\n );\n\n return abort('Exiting the wizard.', 0);\n }\n\n if (!wizardSupportsAngularVersion) {\n Sentry.setTag('angular-wizard-version-compatible', false);\n\n clack.log.warn(\n `The Sentry Angular Wizard requires Angular version ${chalk.cyan(\n MIN_SUPPORTED_WIZARD_ANGULAR_VERSION,\n )} or higher.`,\n );\n clack.log.warn(\n `Your Angular version (${installedAngularVersion}) is compatible with the Sentry SDK but you need to set it up manually by following our documentation:\n\n${chalk.underline('https://docs.sentry.io/platforms/javascript/guides/angular')}\n\nApologies for the inconvenience!`,\n );\n\n return abort('Exiting the wizard.', 0);\n }\n\n const { selectedProject, authToken, sentryUrl, selfHosted } =\n await getOrAskForProjectData(options, 'javascript-angular');\n\n const dsn = selectedProject.keys[0].dsn.public;\n\n const sdkAlreadyInstalled = hasPackageInstalled(\n '@sentry/angular',\n packageJson,\n );\n\n Sentry.setTag('sdk-already-installed', sdkAlreadyInstalled);\n\n await installPackage({\n packageName: '@sentry/angular@^10',\n packageNameDisplayLabel: '@sentry/angular',\n alreadyInstalled: sdkAlreadyInstalled,\n });\n\n const selectedFeatures = await featureSelectionPrompt([\n {\n id: 'performance',\n prompt: `Do you want to enable ${chalk.bold(\n 'Tracing',\n )} to track the performance of your application?`,\n enabledHint: 'recommended',\n },\n {\n id: 'replay',\n prompt: `Do you want to enable ${chalk.bold(\n 'Sentry Session Replay',\n )} to get a video-like reproduction of errors during a user session?`,\n enabledHint: 'recommended, but increases bundle size',\n },\n {\n id: 'logs',\n prompt: `Do you want to enable ${chalk.bold(\n 'Logs',\n )} to send your application logs to Sentry?`,\n enabledHint: 'recommended',\n },\n ] as const);\n\n await traceStep(\n 'Initialize Sentry on Angular application entry point',\n async () => {\n await initializeSentryOnApplicationEntry(dsn, selectedFeatures);\n },\n );\n\n await traceStep('Update Angular project configuration', async () => {\n await updateAppConfig(installedMinVersion, selectedFeatures.performance);\n });\n\n await traceStep('Setup for sourcemap uploads', async () => {\n await addSourcemapEntryToAngularJSON();\n\n if (!options.preSelectedProject) {\n options.preSelectedProject = {\n authToken,\n selfHosted,\n project: {\n organization: {\n id: selectedProject.organization.id,\n name: selectedProject.organization.name,\n slug: selectedProject.organization.slug,\n },\n id: selectedProject.id,\n slug: selectedProject.slug,\n keys: [\n {\n dsn: {\n public: dsn,\n },\n },\n ],\n },\n };\n\n options.url = sentryUrl;\n }\n\n await runSourcemapsWizard(options, 'angular');\n });\n\n const shouldCreateExampleComponent = await askShouldCreateExampleComponent();\n\n Sentry.setTag('create-example-component', shouldCreateExampleComponent);\n\n if (shouldCreateExampleComponent) {\n await traceStep(\n 'create-example-component',\n async () =>\n await createExampleComponent({\n url: sentryUrl,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n }),\n );\n }\n\n await traceStep('Run Prettier', async () => {\n await runPrettierIfInstalled({ cwd: undefined });\n });\n\n clack.outro(buildOutroMessage(shouldCreateExampleComponent));\n}\n\nexport function buildOutroMessage(createdExampleComponent: boolean): string {\n let msg = chalk.green('\\nSuccessfully installed the Sentry Angular SDK!');\n\n if (createdExampleComponent) {\n msg += `\\n\\nYou can validate your setup by starting your dev environment (${chalk.cyan(\n 'ng serve',\n )}) and throwing an error in the example component.`;\n }\n\n msg += `\\n\\nCheck out the SDK documentation for further configuration:\nhttps://docs.sentry.io/platforms/javascript/guides/angular/`;\n\n return msg;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"angular-wizard.js","sourceRoot":"","sources":["../../../src/angular/angular-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AAEnC,kDAA0B;AAE1B,4CAAwD;AACxD,0DAAwE;AACxE,0CAYwB;AACxB,wDAA+E;AAC/E,mCAAiD;AAEjD,qDAAuC;AACvC,2CAAiE;AACjE,2CAA8C;AAC9C,uEAAsE;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AAc,EAAE,KAAK,IAAI,EAAE;QACzC,MAAM,IAAA,8BAAsB,EAAC,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,iFAAiF;IACjF,MAAM,IAAA,wCAA2B,EAC/B,eAAe,CAAC,YAAY,CAAC,IAAI,EACjC,eAAe,CAAC,IAAI,CACrB,CAAC;IAEF,iBAAK,CAAC,KAAK,CAAC,iBAAiB,CAAC,4BAA4B,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED,SAAgB,iBAAiB,CAAC,uBAAgC;IAChE,IAAI,GAAG,GAAG,eAAK,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;IAE1E,IAAI,uBAAuB,EAAE;QAC3B,GAAG,IAAI,qEAAqE,eAAK,CAAC,IAAI,CACpF,UAAU,CACX,mDAAmD,CAAC;KACtD;IAED,GAAG,IAAI;4DACmD,CAAC;IAE3D,OAAO,GAAG,CAAC;AACb,CAAC;AAbD,8CAaC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\n\nimport chalk from 'chalk';\nimport type { WizardOptions } from '../utils/types';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport { offerProjectScopedMcpConfig } from '../utils/clack/mcp-config';\nimport {\n abortIfCancelled,\n askShouldCreateExampleComponent,\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n featureSelectionPrompt,\n getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n printWelcome,\n runPrettierIfInstalled,\n abort,\n} from '../utils/clack';\nimport { getPackageVersion, hasPackageInstalled } from '../utils/package-json';\nimport { gte, minVersion, SemVer } from 'semver';\n\nimport * as Sentry from '@sentry/node';\nimport { initializeSentryOnApplicationEntry } from './sdk-setup';\nimport { updateAppConfig } from './sdk-setup';\nimport { runSourcemapsWizard } from '../sourcemaps/sourcemaps-wizard';\nimport { addSourcemapEntryToAngularJSON } from './codemods/sourcemaps';\nimport { createExampleComponent } from './example-component';\n\nconst MIN_SUPPORTED_ANGULAR_VERSION = '14.0.0';\nconst MIN_SUPPORTED_WIZARD_ANGULAR_VERSION = '17.0.0';\n\nexport async function runAngularWizard(options: WizardOptions): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'angular',\n wizardOptions: options,\n },\n () => runAngularWizardWithTelemetry(options),\n );\n}\n\nasync function runAngularWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry Angular Wizard',\n promoCode: options.promoCode,\n telemetryEnabled: options.telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\n\n const packageJson = await getPackageDotJson();\n\n await ensurePackageIsInstalled(packageJson, '@angular/core', 'Angular');\n\n let installedAngularVersion = getPackageVersion('@angular/core', packageJson);\n\n if (!installedAngularVersion) {\n clack.log.warn('Could not determine installed Angular version.');\n\n installedAngularVersion = await abortIfCancelled(\n clack.text({\n message: `Please enter your installed Angular major version (e.g. ${chalk.cyan(\n '18',\n )} for Angular 18)`,\n validate(value) {\n if (!value) {\n return 'Angular version is required';\n }\n\n try {\n if (!minVersion(value)) {\n return `Invalid Angular version provided: ${value}`;\n }\n } catch (error) {\n return `Invalid Angular version provided: ${value}`;\n }\n },\n }),\n );\n }\n\n Sentry.setTag('angular-version', installedAngularVersion);\n\n const installedMinVersion = minVersion(installedAngularVersion) as SemVer;\n\n const sdkSupportsAngularVersion = gte(\n installedMinVersion,\n MIN_SUPPORTED_ANGULAR_VERSION,\n );\n\n const wizardSupportsAngularVersion = gte(\n installedMinVersion,\n MIN_SUPPORTED_WIZARD_ANGULAR_VERSION,\n );\n\n if (!sdkSupportsAngularVersion) {\n Sentry.setTag('angular-version-compatible', false);\n\n clack.log.warn(\n `Angular version ${chalk.cyan(\n MIN_SUPPORTED_ANGULAR_VERSION,\n )} or higher is required for the Sentry SDK.`,\n );\n clack.log.warn(\n `Please refer to Sentry's version compatibility table for more information:\n\n${chalk.underline(\n 'https://docs.sentry.io/platforms/javascript/guides/angular/#angular-version-compatibility',\n)}\n`,\n );\n\n return abort('Exiting the wizard.', 0);\n }\n\n if (!wizardSupportsAngularVersion) {\n Sentry.setTag('angular-wizard-version-compatible', false);\n\n clack.log.warn(\n `The Sentry Angular Wizard requires Angular version ${chalk.cyan(\n MIN_SUPPORTED_WIZARD_ANGULAR_VERSION,\n )} or higher.`,\n );\n clack.log.warn(\n `Your Angular version (${installedAngularVersion}) is compatible with the Sentry SDK but you need to set it up manually by following our documentation:\n\n${chalk.underline('https://docs.sentry.io/platforms/javascript/guides/angular')}\n\nApologies for the inconvenience!`,\n );\n\n return abort('Exiting the wizard.', 0);\n }\n\n const { selectedProject, authToken, sentryUrl, selfHosted } =\n await getOrAskForProjectData(options, 'javascript-angular');\n\n const dsn = selectedProject.keys[0].dsn.public;\n\n const sdkAlreadyInstalled = hasPackageInstalled(\n '@sentry/angular',\n packageJson,\n );\n\n Sentry.setTag('sdk-already-installed', sdkAlreadyInstalled);\n\n await installPackage({\n packageName: '@sentry/angular@^10',\n packageNameDisplayLabel: '@sentry/angular',\n alreadyInstalled: sdkAlreadyInstalled,\n });\n\n const selectedFeatures = await featureSelectionPrompt([\n {\n id: 'performance',\n prompt: `Do you want to enable ${chalk.bold(\n 'Tracing',\n )} to track the performance of your application?`,\n enabledHint: 'recommended',\n },\n {\n id: 'replay',\n prompt: `Do you want to enable ${chalk.bold(\n 'Sentry Session Replay',\n )} to get a video-like reproduction of errors during a user session?`,\n enabledHint: 'recommended, but increases bundle size',\n },\n {\n id: 'logs',\n prompt: `Do you want to enable ${chalk.bold(\n 'Logs',\n )} to send your application logs to Sentry?`,\n enabledHint: 'recommended',\n },\n ] as const);\n\n await traceStep(\n 'Initialize Sentry on Angular application entry point',\n async () => {\n await initializeSentryOnApplicationEntry(dsn, selectedFeatures);\n },\n );\n\n await traceStep('Update Angular project configuration', async () => {\n await updateAppConfig(installedMinVersion, selectedFeatures.performance);\n });\n\n await traceStep('Setup for sourcemap uploads', async () => {\n await addSourcemapEntryToAngularJSON();\n\n if (!options.preSelectedProject) {\n options.preSelectedProject = {\n authToken,\n selfHosted,\n project: {\n organization: {\n id: selectedProject.organization.id,\n name: selectedProject.organization.name,\n slug: selectedProject.organization.slug,\n },\n id: selectedProject.id,\n slug: selectedProject.slug,\n keys: [\n {\n dsn: {\n public: dsn,\n },\n },\n ],\n },\n };\n\n options.url = sentryUrl;\n }\n\n await runSourcemapsWizard(options, 'angular');\n });\n\n const shouldCreateExampleComponent = await askShouldCreateExampleComponent();\n\n Sentry.setTag('create-example-component', shouldCreateExampleComponent);\n\n if (shouldCreateExampleComponent) {\n await traceStep(\n 'create-example-component',\n async () =>\n await createExampleComponent({\n url: sentryUrl,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n }),\n );\n }\n\n await traceStep('Run Prettier', async () => {\n await runPrettierIfInstalled({ cwd: undefined });\n });\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 clack.outro(buildOutroMessage(shouldCreateExampleComponent));\n}\n\nexport function buildOutroMessage(createdExampleComponent: boolean): string {\n let msg = chalk.green('\\nSuccessfully installed the Sentry Angular SDK!');\n\n if (createdExampleComponent) {\n msg += `\\n\\nYou can validate your setup by starting your dev environment (${chalk.cyan(\n 'ng serve',\n )}) and throwing an error in the example component.`;\n }\n\n msg += `\\n\\nCheck out the SDK documentation for further configuration:\nhttps://docs.sentry.io/platforms/javascript/guides/angular/`;\n\n return msg;\n}\n"]}
|
|
@@ -6,8 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.runAppleWizard = void 0;
|
|
7
7
|
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
8
8
|
const prompts_1 = __importDefault(require("@clack/prompts"));
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
10
|
const telemetry_1 = require("../telemetry");
|
|
10
11
|
const clack_1 = require("../utils/clack");
|
|
12
|
+
const mcp_config_1 = require("../utils/clack/mcp-config");
|
|
11
13
|
const check_installed_cli_1 = require("./check-installed-cli");
|
|
12
14
|
const configure_fastlane_1 = require("./configure-fastlane");
|
|
13
15
|
const configure_package_manager_1 = require("./configure-package-manager");
|
|
@@ -62,11 +64,20 @@ async function runAppleWizardWithTelementry(options) {
|
|
|
62
64
|
target,
|
|
63
65
|
shouldUseSPM,
|
|
64
66
|
});
|
|
67
|
+
// Step - Feature Selection
|
|
68
|
+
const selectedFeatures = await (0, clack_1.featureSelectionPrompt)([
|
|
69
|
+
{
|
|
70
|
+
id: 'logs',
|
|
71
|
+
prompt: `Do you want to enable ${chalk_1.default.bold('Logs')} to send your application logs to Sentry?`,
|
|
72
|
+
enabledHint: 'optional',
|
|
73
|
+
},
|
|
74
|
+
]);
|
|
65
75
|
// Step - Add Code Snippet
|
|
66
76
|
(0, inject_code_snippet_1.injectCodeSnippet)({
|
|
67
77
|
project: xcProject,
|
|
68
78
|
target,
|
|
69
79
|
dsn: selectedProject.keys[0].dsn.public,
|
|
80
|
+
enableLogs: selectedFeatures.logs ?? false,
|
|
70
81
|
});
|
|
71
82
|
// Step - Fastlane Configuration
|
|
72
83
|
await (0, configure_fastlane_1.configureFastlane)({
|
|
@@ -74,6 +85,8 @@ async function runAppleWizardWithTelementry(options) {
|
|
|
74
85
|
orgSlug: selectedProject.organization.slug,
|
|
75
86
|
projectSlug: selectedProject.slug,
|
|
76
87
|
});
|
|
88
|
+
// Offer optional project-scoped MCP config for Sentry with org and project scope
|
|
89
|
+
await (0, mcp_config_1.offerProjectScopedMcpConfig)(selectedProject.organization.slug, selectedProject.slug);
|
|
77
90
|
prompts_1.default.log.success('Sentry was successfully added to your project! Run your project to send your first event to Sentry. Go to Sentry.io to see whether everything is working fine.');
|
|
78
91
|
}
|
|
79
92
|
//# sourceMappingURL=apple-wizard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apple-wizard.js","sourceRoot":"","sources":["../../../src/apple/apple-wizard.ts"],"names":[],"mappings":";;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;
|
|
1
|
+
{"version":3,"file":"apple-wizard.js","sourceRoot":"","sources":["../../../src/apple/apple-wizard.ts"],"names":[],"mappings":";;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAE1B,4CAA6C;AAC7C,0CAKwB;AACxB,0DAAwE;AACxE,+DAA0D;AAC1D,6DAAyD;AACzD,2EAAsE;AACtE,iEAA4D;AAC5D,uEAAkE;AAClE,+DAA0D;AAC1D,iEAA4D;AAGrD,KAAK,UAAU,cAAc,CAClC,OAA2B;IAE3B,OAAO,IAAA,yBAAa,EAClB;QACE,OAAO,EAAE,OAAO,CAAC,gBAAgB;QACjC,WAAW,EAAE,KAAK;QAClB,aAAa,EAAE,OAAO;KACvB,EACD,GAAG,EAAE,CAAC,4BAA4B,CAAC,OAAO,CAAC,CAC5C,CAAC;AACJ,CAAC;AAXD,wCAWC;AAED,KAAK,UAAU,4BAA4B,CACzC,OAA2B;IAE3B,+BAA+B;IAC/B,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAEvD,yBAAyB;IACzB,IAAA,oBAAY,EAAC;QACX,UAAU,EAAE,qBAAqB;QACjC,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAC,CAAC;IAEH,0BAA0B;IAC1B,MAAM,IAAA,yCAAiC,EAAC;QACtC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,GAAG,EAAE,UAAU;KAChB,CAAC,CAAC;IAEH,0BAA0B;IAC1B,MAAM,IAAA,uCAAiB,GAAE,CAAC;IAE1B,8BAA8B;IAC9B,qEAAqE;IACrE,gEAAgE;IAChE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,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O,CACf,gKAAgK,CACjK,CAAC;AACJ,CAAC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\n\nimport { withTelemetry } from '../telemetry';\nimport {\n confirmContinueIfNoOrDirtyGitRepo,\n featureSelectionPrompt,\n getOrAskForProjectData,\n printWelcome,\n} from '../utils/clack';\nimport { offerProjectScopedMcpConfig } from '../utils/clack/mcp-config';\nimport { checkInstalledCLI } from './check-installed-cli';\nimport { configureFastlane } from './configure-fastlane';\nimport { configurePackageManager } from './configure-package-manager';\nimport { configureSentryCLI } from './configure-sentry-cli';\nimport { configureXcodeProject } from './configure-xcode-project';\nimport { injectCodeSnippet } from './inject-code-snippet';\nimport { lookupXcodeProject } from './lookup-xcode-project';\nimport { AppleWizardOptions } from './options';\n\nexport async function runAppleWizard(\n options: AppleWizardOptions,\n): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'ios',\n wizardOptions: options,\n },\n () => runAppleWizardWithTelementry(options),\n );\n}\n\nasync function runAppleWizardWithTelementry(\n options: AppleWizardOptions,\n): Promise<void> {\n // Define options with defaults\n const projectDir = options.projectDir ?? process.cwd();\n\n // Step - Welcome Message\n printWelcome({\n wizardName: 'Sentry Apple Wizard',\n promoCode: options.promoCode,\n });\n\n // Step - Git Status Check\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: projectDir,\n });\n\n // Step - Sentry CLI Check\n await checkInstalledCLI();\n\n // Step - Xcode Project Lookup\n // This step should be run before the Sentry Project and API Key step\n // because it can abort the wizard if no Xcode project is found.\n const { xcProject, target } = await lookupXcodeProject({\n projectDir,\n });\n\n // Step - Sentry Project and API Key\n const { selectedProject, authToken } = await getOrAskForProjectData(\n options,\n 'apple-ios',\n );\n\n // Step - Sentry CLI Configuration Setup\n configureSentryCLI({\n projectDir,\n authToken: authToken,\n });\n\n // Step - Set up Package Manager\n const { shouldUseSPM } = await configurePackageManager({\n projectDir,\n });\n\n // Step - Configure Xcode Project\n configureXcodeProject({\n xcProject,\n project: selectedProject,\n target,\n shouldUseSPM,\n });\n\n // Step - Feature Selection\n const selectedFeatures = await featureSelectionPrompt([\n {\n id: 'logs',\n prompt: `Do you want to enable ${chalk.bold(\n 'Logs',\n )} to send your application logs to Sentry?`,\n enabledHint: 'optional',\n },\n ]);\n\n // Step - Add Code Snippet\n injectCodeSnippet({\n project: xcProject,\n target,\n dsn: selectedProject.keys[0].dsn.public,\n enableLogs: selectedFeatures.logs ?? false,\n });\n\n // Step - Fastlane Configuration\n await configureFastlane({\n projectDir,\n orgSlug: selectedProject.organization.slug,\n projectSlug: selectedProject.slug,\n });\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 clack.log.success(\n 'Sentry was successfully added to your project! Run your project to send your first event to Sentry. Go to Sentry.io to see whether everything is working fine.',\n );\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare function isAppDelegateFile(filePath: string): boolean;
|
|
2
2
|
declare function findAppDidFinishLaunchingWithOptionsInDirectory(dir: string): string | null;
|
|
3
3
|
declare function findAppDidFinishLaunchingWithOptions(files: string[]): string | null;
|
|
4
|
-
export declare function addCodeSnippetToProject(files: string[], dsn: string): boolean;
|
|
4
|
+
export declare function addCodeSnippetToProject(files: string[], dsn: string, enableLogs: boolean): boolean;
|
|
5
5
|
/**
|
|
6
6
|
* Exported for testing purposes, but should not be used in other modules.
|
|
7
7
|
*/
|
|
@@ -80,7 +80,7 @@ function findAppDidFinishLaunchingWithOptions(files) {
|
|
|
80
80
|
}
|
|
81
81
|
return null;
|
|
82
82
|
}
|
|
83
|
-
function addCodeSnippetToProject(files, dsn) {
|
|
83
|
+
function addCodeSnippetToProject(files, dsn, enableLogs) {
|
|
84
84
|
const appDelegate = findAppDidFinishLaunchingWithOptions(files);
|
|
85
85
|
if (!appDelegate) {
|
|
86
86
|
return false;
|
|
@@ -91,8 +91,8 @@ function addCodeSnippetToProject(files, dsn) {
|
|
|
91
91
|
const importStatement = isSwift ? 'import Sentry\n' : '@import Sentry;\n';
|
|
92
92
|
const checkForSentryInit = isSwift ? 'SentrySDK.start' : '[SentrySDK start';
|
|
93
93
|
let codeSnippet = isSwift
|
|
94
|
-
? templates.getSwiftSnippet(dsn)
|
|
95
|
-
: templates.getObjcSnippet(dsn);
|
|
94
|
+
? templates.getSwiftSnippet(dsn, enableLogs)
|
|
95
|
+
: templates.getObjcSnippet(dsn, enableLogs);
|
|
96
96
|
Sentry.setTag('code-language', isSwift ? 'swift' : 'objc');
|
|
97
97
|
Sentry.setTag('ui-engine', swiftUIRegex.test(fileContent) ? 'swiftui' : 'uikit');
|
|
98
98
|
if (fileContent.includes(checkForSentryInit)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-tools.js","sourceRoot":"","sources":["../../../src/apple/code-tools.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,uCAAyB;AACzB,2CAA6B;AAC7B,uDAAyC;AACzC,+EAA+E;AAC/E,sDAAwC;AACxC,0CAAuC;AAEvC,MAAM,mBAAmB,GACvB,mNAAmN,CAAC;AACtN,MAAM,kBAAkB,GACtB,qKAAqK,CAAC;AACxK,MAAM,YAAY,GAAG,8CAA8C,CAAC;AAEpE,SAAS,iBAAiB,CAAC,QAAgB;IACzC,IAAA,aAAK,EAAC,cAAc,GAAG,QAAQ,GAAG,yBAAyB,CAAC,CAAC;IAC7D,MAAM,cAAc,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAC9D,CAAC,CAAC,mBAAmB;QACrB,CAAC,CAAC,kBAAkB,CAAC;IAEvB,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACtD,OAAO,cAAc,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ACL,cAAc,GAAG,eAAe,GAAG,cAAc,CAAC;SACnD;KACF;IAED,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;IAEtD,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,8CAA8C,GAAG,WAAW,CAAC,CAAC;IAC7E,OAAO,IAAI,CAAC;AACd,CAAC;AAtED,0DAsEC;AAUD,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,EAAE;IACnC,wBAAgB,GAAG;QACjB,iBAAiB;QACjB,+CAA+C;QAC/C,oCAAoC;KACrC,CAAC;CACH","sourcesContent":["import * as Sentry from '@sentry/node';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as templates from './templates';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport { debug } from '../utils/debug';\n\nconst swiftAppLaunchRegex =\n /(func\\s+application\\s*\\(\\s*_\\s+application:\\s*[^,]+,\\s*didFinishLaunchingWithOptions[^,]+:\\s*[^)]+\\s*\\)\\s+->\\s+Bool\\s+{)|func\\s+applicationDidFinishLaunching\\s*\\(\\s*_\\s+aNotification:\\s+Notification\\s*\\)\\s*{/im;\nconst objcAppLaunchRegex =\n /-\\s*\\(\\s*BOOL\\s*\\)\\s*application:\\s*\\(\\s*UIApplication\\s*\\*\\s*\\)\\s*application\\s+didFinishLaunchingWithOptions:\\s*\\(\\s*NSDictionary\\s*\\*\\s*\\)\\s*launchOptions\\s*{/im;\nconst swiftUIRegex = /@main\\s+struct[^:]+:\\s*(SwiftUI\\.)?App\\s*{/im;\n\nfunction isAppDelegateFile(filePath: string): boolean {\n debug('Checking if ' + filePath + ' is an AppDelegate file');\n const appLaunchRegex = filePath.toLowerCase().endsWith('.swift')\n ? swiftAppLaunchRegex\n : objcAppLaunchRegex;\n\n const fileContent = fs.readFileSync(filePath, 'utf8');\n return appLaunchRegex.test(fileContent) || swiftUIRegex.test(fileContent);\n}\n\nfunction findAppDidFinishLaunchingWithOptionsInDirectory(\n dir: string,\n): string | null {\n debug('Searching for AppDelegate in directory: ' + dir);\n const files = fs.readdirSync(dir);\n const filePaths = files.map((f) => path.join(dir, f));\n return findAppDidFinishLaunchingWithOptions(filePaths);\n}\n\nfunction findAppDidFinishLaunchingWithOptions(files: string[]): string | null {\n debug(`Searching for AppDelegate in ${files.length} files`);\n\n // Iterate over subdirectories after iterating over files,\n // because the AppDelegate is usually in the top level\n const dirs: string[] = [];\n for (const filePath of files) {\n debug('Checking file: ' + filePath);\n if (\n filePath.endsWith('.swift') ||\n filePath.endsWith('.m') ||\n filePath.endsWith('.mm')\n ) {\n if (fs.existsSync(filePath) && isAppDelegateFile(filePath)) {\n debug('Found AppDelegate in ' + filePath);\n return filePath;\n }\n } else if (\n !path.basename(filePath).startsWith('.') &&\n !filePath.endsWith('.xcodeproj') &&\n !filePath.endsWith('.xcassets') &&\n fs.existsSync(filePath) &&\n fs.lstatSync(filePath).isDirectory()\n ) {\n dirs.push(filePath);\n }\n }\n\n for (const dr of dirs) {\n const result = findAppDidFinishLaunchingWithOptionsInDirectory(dr);\n if (result) {\n debug('Found AppDelegate in ' + dr);\n return result;\n }\n }\n return null;\n}\n\nexport function addCodeSnippetToProject(\n files: string[],\n dsn: string,\n enableLogs: boolean,\n): boolean {\n const appDelegate = findAppDidFinishLaunchingWithOptions(files);\n if (!appDelegate) {\n return false;\n }\n\n const fileContent = fs.readFileSync(appDelegate, 'utf8');\n const isSwift = appDelegate.toLowerCase().endsWith('.swift');\n const appLaunchRegex = isSwift ? swiftAppLaunchRegex : objcAppLaunchRegex;\n const importStatement = isSwift ? 'import Sentry\\n' : '@import Sentry;\\n';\n const checkForSentryInit = isSwift ? 'SentrySDK.start' : '[SentrySDK start';\n let codeSnippet = isSwift\n ? templates.getSwiftSnippet(dsn, enableLogs)\n : templates.getObjcSnippet(dsn, enableLogs);\n\n Sentry.setTag('code-language', isSwift ? 'swift' : 'objc');\n Sentry.setTag(\n 'ui-engine',\n swiftUIRegex.test(fileContent) ? 'swiftui' : 'uikit',\n );\n\n if (fileContent.includes(checkForSentryInit)) {\n //already initialized\n clack.log.info(\n 'Sentry is already initialized in your AppDelegate. Skipping adding the code snippet.',\n );\n return true;\n }\n\n let match = appLaunchRegex.exec(fileContent);\n if (!match) {\n const swiftUIMatch = swiftUIRegex.exec(fileContent);\n if (!swiftUIMatch) {\n // This branch is not reached, because we already checked for SwiftUI in isAppDelegateFile\n return false;\n }\n //Is SwiftUI with no init\n match = swiftUIMatch;\n codeSnippet = ` init() {\\n${codeSnippet} }`;\n }\n\n const insertIndex = match.index + match[0].length;\n let newFileContent =\n fileContent.slice(0, insertIndex) +\n '\\n' +\n codeSnippet +\n fileContent.slice(insertIndex);\n\n if (newFileContent.indexOf(importStatement) < 0) {\n const firstImport = /^[ \\t]*import +\\w+.*$/m.exec(newFileContent);\n if (firstImport) {\n const importIndex = firstImport.index + firstImport[0].length;\n newFileContent =\n newFileContent.slice(0, importIndex) +\n '\\n' +\n importStatement +\n newFileContent.slice(importIndex);\n } else {\n newFileContent = importStatement + newFileContent;\n }\n }\n\n fs.writeFileSync(appDelegate, newFileContent, 'utf8');\n\n clack.log.step('Added Sentry initialization code snippet to ' + appDelegate);\n return true;\n}\n\n/**\n * Exported for testing purposes, but should not be used in other modules.\n */\nexport let exportForTesting: {\n isAppDelegateFile: typeof isAppDelegateFile;\n findAppDidFinishLaunchingWithOptionsInDirectory: typeof findAppDidFinishLaunchingWithOptionsInDirectory;\n findAppDidFinishLaunchingWithOptions: typeof findAppDidFinishLaunchingWithOptions;\n};\nif (process.env.NODE_ENV === 'test') {\n exportForTesting = {\n isAppDelegateFile,\n findAppDidFinishLaunchingWithOptionsInDirectory,\n findAppDidFinishLaunchingWithOptions,\n };\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { XcodeProject } from './xcode-manager';
|
|
2
|
-
export declare function injectCodeSnippet({ project, target, dsn, }: {
|
|
2
|
+
export declare function injectCodeSnippet({ project, target, dsn, enableLogs, }: {
|
|
3
3
|
project: XcodeProject;
|
|
4
4
|
target: string;
|
|
5
5
|
dsn: string;
|
|
6
|
+
enableLogs: boolean;
|
|
6
7
|
}): void;
|
|
@@ -34,7 +34,7 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
34
34
|
const telemetry_1 = require("../telemetry");
|
|
35
35
|
const debug_1 = require("../utils/debug");
|
|
36
36
|
const codeTools = __importStar(require("./code-tools"));
|
|
37
|
-
function injectCodeSnippet({ project, target, dsn, }) {
|
|
37
|
+
function injectCodeSnippet({ project, target, dsn, enableLogs, }) {
|
|
38
38
|
(0, debug_1.debug)(`Injecting code snippet into project at path: ${chalk_1.default.cyan(project.baseDir)}`);
|
|
39
39
|
const codeAdded = (0, telemetry_1.traceStep)('Add code snippet', () => {
|
|
40
40
|
const files = project.getSourceFilesForTarget(target);
|
|
@@ -44,7 +44,7 @@ function injectCodeSnippet({ project, target, dsn, }) {
|
|
|
44
44
|
return false;
|
|
45
45
|
}
|
|
46
46
|
(0, debug_1.debug)(`Adding code snippet to ${files.length} candidate files`);
|
|
47
|
-
return codeTools.addCodeSnippetToProject(files, dsn);
|
|
47
|
+
return codeTools.addCodeSnippetToProject(files, dsn, enableLogs);
|
|
48
48
|
});
|
|
49
49
|
Sentry.setTag('Snippet-Added', codeAdded);
|
|
50
50
|
(0, debug_1.debug)(`Snippet added: ${chalk_1.default.cyan(codeAdded.toString())}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject-code-snippet.js","sourceRoot":"","sources":["../../../src/apple/inject-code-snippet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,qDAAuC;AACvC,kDAA0B;AAC1B,4CAAyC;AACzC,0CAAuC;AACvC,wDAA0C;AAG1C,SAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,MAAM,EACN,GAAG,
|
|
1
|
+
{"version":3,"file":"inject-code-snippet.js","sourceRoot":"","sources":["../../../src/apple/inject-code-snippet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,qDAAuC;AACvC,kDAA0B;AAC1B,4CAAyC;AACzC,0CAAuC;AACvC,wDAA0C;AAG1C,SAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,MAAM,EACN,GAAG,EACH,UAAU,GAMX;IACC,IAAA,aAAK,EACH,gDAAgD,eAAK,CAAC,IAAI,CACxD,OAAO,CAAC,OAAO,CAChB,EAAE,CACJ,CAAC;IACF,MAAM,SAAS,GAAG,IAAA,qBAAS,EAAC,kBAAkB,EAAE,GAAG,EAAE;QACnD,MAAM,KAAK,GAAG,OAAO,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;QACtD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,EAAE;YAC5C,IAAA,aAAK,EAAC,6BAA6B,GAAG,MAAM,CAAC,CAAC;YAC9C,MAAM,CAAC,MAAM,CAAC,mCAAmC,EAAE,IAAI,CAAC,CAAC;YACzD,OAAO,KAAK,CAAC;SACd;QAED,IAAA,aAAK,EAAC,0BAA0B,KAAK,CAAC,MAAM,kBAAkB,CAAC,CAAC;QAChE,OAAO,SAAS,CAAC,uBAAuB,CAAC,KAAK,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;IAC1C,IAAA,aAAK,EAAC,kBAAkB,eAAK,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;IAE5D,IAAI,CAAC,SAAS,EAAE;QACd,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,iNAAiN,CAClN,CAAC;KACH;AACH,CAAC;AAnCD,8CAmCC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport * as Sentry from '@sentry/node';\nimport chalk from 'chalk';\nimport { traceStep } from '../telemetry';\nimport { debug } from '../utils/debug';\nimport * as codeTools from './code-tools';\nimport { XcodeProject } from './xcode-manager';\n\nexport function injectCodeSnippet({\n project,\n target,\n dsn,\n enableLogs,\n}: {\n project: XcodeProject;\n target: string;\n dsn: string;\n enableLogs: boolean;\n}) {\n debug(\n `Injecting code snippet into project at path: ${chalk.cyan(\n project.baseDir,\n )}`,\n );\n const codeAdded = traceStep('Add code snippet', () => {\n const files = project.getSourceFilesForTarget(target);\n if (files === undefined || files.length == 0) {\n debug('No files found for target: ' + target);\n Sentry.setTag('snippet-candidate-files-not-found', true);\n return false;\n }\n\n debug(`Adding code snippet to ${files.length} candidate files`);\n return codeTools.addCodeSnippetToProject(files, dsn, enableLogs);\n });\n Sentry.setTag('Snippet-Added', codeAdded);\n debug(`Snippet added: ${chalk.cyan(codeAdded.toString())}`);\n\n if (!codeAdded) {\n clack.log.warn(\n 'Added the Sentry dependency to your project but could not add the Sentry code snippet. Please add the code snippet manually by following the docs: https://docs.sentry.io/platforms/apple/guides/ios/#configure',\n );\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function getRunScriptTemplate(orgSlug: string, projectSlug: string, uploadSource: boolean, includeHomebrewPath: boolean): string;
|
|
2
2
|
export declare const scriptInputPath = "\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}\"";
|
|
3
|
-
export declare function getSwiftSnippet(dsn: string): string;
|
|
4
|
-
export declare function getObjcSnippet(dsn: string): string;
|
|
3
|
+
export declare function getSwiftSnippet(dsn: string, enableLogs: boolean): string;
|
|
4
|
+
export declare function getObjcSnippet(dsn: string, enableLogs: boolean): string;
|
|
5
5
|
export declare function getFastlaneSnippet(org: string, project: string): string;
|
|
@@ -25,8 +25,8 @@ fi
|
|
|
25
25
|
}
|
|
26
26
|
exports.getRunScriptTemplate = getRunScriptTemplate;
|
|
27
27
|
exports.scriptInputPath = '"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}"';
|
|
28
|
-
function getSwiftSnippet(dsn) {
|
|
29
|
-
|
|
28
|
+
function getSwiftSnippet(dsn, enableLogs) {
|
|
29
|
+
let snippet = ` SentrySDK.start { options in
|
|
30
30
|
options.dsn = "${dsn}"
|
|
31
31
|
options.debug = true // Enabled debug when first installing is always helpful
|
|
32
32
|
|
|
@@ -46,14 +46,22 @@ function getSwiftSnippet(dsn) {
|
|
|
46
46
|
|
|
47
47
|
// Uncomment the following lines to add more data to your events
|
|
48
48
|
// options.attachScreenshot = true // This adds a screenshot to the error events
|
|
49
|
-
// options.attachViewHierarchy = true // This adds the view hierarchy to the error events
|
|
49
|
+
// options.attachViewHierarchy = true // This adds the view hierarchy to the error events`;
|
|
50
|
+
if (enableLogs) {
|
|
51
|
+
snippet += `
|
|
52
|
+
|
|
53
|
+
// Enable experimental logging features
|
|
54
|
+
options.experimental.enableLogs = true`;
|
|
55
|
+
}
|
|
56
|
+
snippet += `
|
|
50
57
|
}
|
|
51
58
|
// Remove the next line after confirming that your Sentry integration is working.
|
|
52
59
|
SentrySDK.capture(message: "This app uses Sentry! :)")\n`;
|
|
60
|
+
return snippet;
|
|
53
61
|
}
|
|
54
62
|
exports.getSwiftSnippet = getSwiftSnippet;
|
|
55
|
-
function getObjcSnippet(dsn) {
|
|
56
|
-
|
|
63
|
+
function getObjcSnippet(dsn, enableLogs) {
|
|
64
|
+
let snippet = ` [SentrySDK startWithConfigureOptions:^(SentryOptions * options) {
|
|
57
65
|
options.dsn = @"${dsn}";
|
|
58
66
|
options.debug = YES; // Enabled debug when first installing is always helpful
|
|
59
67
|
|
|
@@ -73,10 +81,18 @@ function getObjcSnippet(dsn) {
|
|
|
73
81
|
|
|
74
82
|
//Uncomment the following lines to add more data to your events
|
|
75
83
|
//options.attachScreenshot = YES; //This will add a screenshot to the error events
|
|
76
|
-
//options.attachViewHierarchy = YES; //This will add the view hierarchy to the error events
|
|
84
|
+
//options.attachViewHierarchy = YES; //This will add the view hierarchy to the error events`;
|
|
85
|
+
if (enableLogs) {
|
|
86
|
+
snippet += `
|
|
87
|
+
|
|
88
|
+
// Enable experimental logging features
|
|
89
|
+
options.experimental.enableLogs = YES;`;
|
|
90
|
+
}
|
|
91
|
+
snippet += `
|
|
77
92
|
}];
|
|
78
93
|
//Remove the next line after confirming that your Sentry integration is working.
|
|
79
94
|
[SentrySDK captureMessage:@"This app uses Sentry!"];\n`;
|
|
95
|
+
return snippet;
|
|
80
96
|
}
|
|
81
97
|
exports.getObjcSnippet = getObjcSnippet;
|
|
82
98
|
function getFastlaneSnippet(org, project) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/apple/templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,oBAAoB,CAClC,OAAe,EACf,WAAmB,EACnB,YAAqB,EACrB,mBAA4B;IAE5B,6CAA6C;IAC7C,MAAM,eAAe,GAAG,mBAAmB;QACzC,CAAC,CAAC;;;;CAIL;QACG,CAAC,CAAC,EAAE,CAAC;IACP,OAAO,0FAA0F,eAAe;;sBAE5F,OAAO;0BACH,WAAW;0CAEjC,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EACxC;;;;;;;CAOD,CAAC;AACF,CAAC;AA5BD,oDA4BC;AAEY,QAAA,eAAe,GAC1B,6FAA6F,CAAC;AAEhG,SAAgB,eAAe,CAAC,GAAW;
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/apple/templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,oBAAoB,CAClC,OAAe,EACf,WAAmB,EACnB,YAAqB,EACrB,mBAA4B;IAE5B,6CAA6C;IAC7C,MAAM,eAAe,GAAG,mBAAmB;QACzC,CAAC,CAAC;;;;CAIL;QACG,CAAC,CAAC,EAAE,CAAC;IACP,OAAO,0FAA0F,eAAe;;sBAE5F,OAAO;0BACH,WAAW;0CAEjC,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EACxC;;;;;;;CAOD,CAAC;AACF,CAAC;AA5BD,oDA4BC;AAEY,QAAA,eAAe,GAC1B,6FAA6F,CAAC;AAEhG,SAAgB,eAAe,CAAC,GAAW,EAAE,UAAmB;IAC9D,IAAI,OAAO,GAAG;6BACa,GAAG;;;;;;;;;;;;;;;;;;;sGAmBsE,CAAC;IAErG,IAAI,UAAU,EAAE;QACd,OAAO,IAAI;;;mDAGoC,CAAC;KACjD;IAED,OAAO,IAAI;;;iEAGoD,CAAC;IAEhE,OAAO,OAAO,CAAC;AACjB,CAAC;AApCD,0CAoCC;AAED,SAAgB,cAAc,CAAC,GAAW,EAAE,UAAmB;IAC7D,IAAI,OAAO,GAAG;0BACU,GAAG;;;;;;;;;;;;;;;;;;;oGAmBuE,CAAC;IAEnG,IAAI,UAAU,EAAE;QACd,OAAO,IAAI;;;+CAGgC,CAAC;KAC7C;IAED,OAAO,IAAI;;;2DAG8C,CAAC;IAE1D,OAAO,OAAO,CAAC;AACjB,CAAC;AApCD,wCAoCC;AAED,SAAgB,kBAAkB,CAAC,GAAW,EAAE,OAAe;IAC7D,OAAO;mBACU,GAAG;uBACC,OAAO;;MAExB,CAAC;AACP,CAAC;AAND,gDAMC","sourcesContent":["export function getRunScriptTemplate(\n orgSlug: string,\n projectSlug: string,\n uploadSource: boolean,\n includeHomebrewPath: boolean,\n): string {\n // eslint-disable-next-line no-useless-escape\n const includeHomebrew = includeHomebrewPath\n ? `\nif [[ \"$(uname -m)\" == arm64 ]]; then\n export PATH=\"/opt/homebrew/bin:$PATH\"\nfi\n`\n : '';\n return `# This script is responsible for uploading debug symbols and source context for Sentry.${includeHomebrew}\nif which sentry-cli >/dev/null; then\n export SENTRY_ORG=${orgSlug}\n export SENTRY_PROJECT=${projectSlug}\n ERROR=$(sentry-cli debug-files upload ${\n uploadSource ? '--include-sources ' : ''\n }\"$DWARF_DSYM_FOLDER_PATH\" 2>&1 >/dev/null)\n if [ ! $? -eq 0 ]; then\n echo \"warning: sentry-cli - $ERROR\"\n fi\nelse\n echo \"warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases\"\nfi\n`;\n}\n\nexport const scriptInputPath =\n '\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}\"';\n\nexport function getSwiftSnippet(dsn: string, enableLogs: boolean): string {\n let snippet = ` SentrySDK.start { options in\n options.dsn = \"${dsn}\"\n options.debug = true // Enabled debug when first installing is always helpful\n\n // Adds IP for users.\n // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/\n options.sendDefaultPii = true\n\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = 1.0\n\n // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.\n options.configureProfiling = {\n $0.sessionSampleRate = 1.0 // We recommend adjusting this value in production.\n $0.lifecycle = .trace\n }\n\n // Uncomment the following lines to add more data to your events\n // options.attachScreenshot = true // This adds a screenshot to the error events\n // options.attachViewHierarchy = true // This adds the view hierarchy to the error events`;\n\n if (enableLogs) {\n snippet += `\n \n // Enable experimental logging features\n options.experimental.enableLogs = true`;\n }\n\n snippet += `\n }\n // Remove the next line after confirming that your Sentry integration is working.\n SentrySDK.capture(message: \"This app uses Sentry! :)\")\\n`;\n\n return snippet;\n}\n\nexport function getObjcSnippet(dsn: string, enableLogs: boolean): string {\n let snippet = ` [SentrySDK startWithConfigureOptions:^(SentryOptions * options) {\n options.dsn = @\"${dsn}\";\n options.debug = YES; // Enabled debug when first installing is always helpful\n\n // Adds IP for users.\n // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/\n options.sendDefaultPii = YES;\n\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = @1.0;\n\n // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.\n options.configureProfiling = ^(SentryProfileOptions *profiling) {\n profiling.sessionSampleRate = 1.0; // We recommend adjusting this value in production.\n profiling.lifecycle = SentryProfilingLifecycleTrace;\n };\n\n //Uncomment the following lines to add more data to your events\n //options.attachScreenshot = YES; //This will add a screenshot to the error events\n //options.attachViewHierarchy = YES; //This will add the view hierarchy to the error events`;\n\n if (enableLogs) {\n snippet += `\n \n // Enable experimental logging features\n options.experimental.enableLogs = YES;`;\n }\n\n snippet += `\n }];\n //Remove the next line after confirming that your Sentry integration is working.\n [SentrySDK captureMessage:@\"This app uses Sentry!\"];\\n`;\n\n return snippet;\n}\n\nexport function getFastlaneSnippet(org: string, project: string): string {\n return ` sentry_cli(\n org_slug: '${org}',\n project_slug: '${project}',\n include_sources: true\n )`;\n}\n"]}
|
|
@@ -12,6 +12,7 @@ export declare function patchMainContent(dsn: string, mainContent: string, selec
|
|
|
12
12
|
tracing: boolean;
|
|
13
13
|
profiling: boolean;
|
|
14
14
|
replay: boolean;
|
|
15
|
+
logs: boolean;
|
|
15
16
|
}): string;
|
|
16
17
|
export declare function getLastImportLineLocation(sourceCode: string): number;
|
|
17
18
|
export declare function getDependenciesLocation(sourceCode: string): number;
|
|
@@ -161,11 +161,17 @@ async function patchMain(mainFile, dsn, canEnableProfiling) {
|
|
|
161
161
|
prompt: `Do you want to enable ${chalk_1.default.bold('Session Replay')} to record user interactions and debug issues?`,
|
|
162
162
|
enabledHint: 'recommended',
|
|
163
163
|
});
|
|
164
|
+
features.push({
|
|
165
|
+
id: 'logs',
|
|
166
|
+
prompt: `Do you want to enable ${chalk_1.default.bold('Logs')} to send your application logs to Sentry?`,
|
|
167
|
+
enabledHint: 'optional',
|
|
168
|
+
});
|
|
164
169
|
const selectedFeatures = await (0, clack_1.featureSelectionPrompt)(features);
|
|
165
170
|
const normalizedSelectedFeatures = {
|
|
166
171
|
tracing: selectedFeatures.tracing ?? false,
|
|
167
172
|
profiling: selectedFeatures.profiling ?? false,
|
|
168
173
|
replay: selectedFeatures.replay ?? false,
|
|
174
|
+
logs: selectedFeatures.logs ?? false,
|
|
169
175
|
};
|
|
170
176
|
mainContent = patchMainContent(dsn, mainContent, normalizedSelectedFeatures);
|
|
171
177
|
if (normalizedSelectedFeatures.replay) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-tools.js","sourceRoot":"","sources":["../../../src/flutter/code-tools.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,qDAAuC;AACvC,+EAA+E;AAC/E,sDAAwC;AACxC,kDAA0B;AAC1B,2CAOqB;AACrB,0CAAwD;AAExD;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,GAAW,EAAE,IAAY;IAChD,MAAM,KAAK,GAAa,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAE5C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,QAAQ,GAAW,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC9C,MAAM,KAAK,GAAa,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAE9C,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE;YACvB,MAAM,MAAM,GAAkB,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YACvD,IAAI,MAAM,EAAE;gBACV,OAAO,MAAM,CAAC;aACf;SACF;aAAM,IAAI,IAAI,KAAK,IAAI,EAAE;YACxB,OAAO,QAAQ,CAAC;SACjB;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAlBD,4BAkBC;AAED,SAAgB,YAAY,CAC1B,WAA0B,EAC1B,wBAAgC,EAChC,uBAA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qBAAqB,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;AAC5D,CAAC;AAHD,gEAGC;AAED,SAAS;AAET,SAAS,qBAAqB,CAAC,UAAkB,EAAE,MAAc;IAC/D,IAAI,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACpC,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,OAAO,KAAK,EAAE;QACZ,WAAW,GAAG,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;QAChD,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;KACjC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport * as Sentry from '@sentry/node';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport {\n sentryImport,\n pubspecOptions,\n sentryProperties,\n initSnippet,\n sessionReplaySampleRate,\n sessionReplayOnErrorSampleRate,\n} from './templates';\nimport { featureSelectionPrompt } from '../utils/clack';\n\n/**\n * Recursively finds a file per name in subfolders.\n * @param dir - The directory to start searching.\n * @param name - The name of the file including path extension.\n * @returns The path to the main.dart file or null if not found.\n */\nexport function findFile(dir: string, name: string): string | null {\n const files: string[] = fs.readdirSync(dir);\n\n for (const file of files) {\n const fullPath: string = path.join(dir, file);\n const stats: fs.Stats = fs.statSync(fullPath);\n\n if (stats.isDirectory()) {\n const result: string | null = findFile(fullPath, name);\n if (result) {\n return result;\n }\n } else if (file === name) {\n return fullPath;\n }\n }\n\n return null;\n}\n\nexport function patchPubspec(\n pubspecFile: string | null,\n sentryDartFlutterVersion: string,\n sentryDartPluginVersion: string,\n project: string,\n org: string,\n): boolean {\n try {\n if (!pubspecFile) {\n throw new Error('pubspec.yaml is not provided or invalid.');\n }\n\n let pubspecContent = fs.readFileSync(pubspecFile, 'utf8');\n\n if (!pubspecContent.includes('sentry_flutter:')) {\n const dependenciesIndex = getDependenciesLocation(pubspecContent);\n\n pubspecContent =\n pubspecContent.slice(0, dependenciesIndex) +\n ` sentry_flutter: ${sentryDartFlutterVersion}\\n` +\n pubspecContent.slice(dependenciesIndex);\n\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('sentry_flutter')} added to pubspec.yaml`,\n ),\n );\n } else {\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('sentry_flutter')} is already included in pubspec.yaml`,\n ),\n );\n }\n\n if (!pubspecContent.includes('sentry_dart_plugin:')) {\n const devDependenciesIndex = getDevDependenciesLocation(pubspecContent);\n pubspecContent =\n pubspecContent.slice(0, devDependenciesIndex) +\n ` sentry_dart_plugin: ${sentryDartPluginVersion}\\n` +\n pubspecContent.slice(devDependenciesIndex);\n\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('sentry_dart_plugin')} added to pubspec.yaml`,\n ),\n );\n } else {\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold(\n 'sentry_dart_plugin',\n )} is already included in pubspec.yaml`,\n ),\n );\n }\n\n if (!pubspecContent.includes('sentry:')) {\n pubspecContent += '\\n';\n pubspecContent += pubspecOptions(project, org);\n\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('sentry plugin configuration')} added to pubspec.yaml`,\n ),\n );\n } else {\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold(\n 'sentry plugin configuration',\n )} is already included in pubspec.yaml`,\n ),\n );\n }\n\n fs.writeFileSync(pubspecFile, pubspecContent, 'utf8');\n\n return true;\n } catch (error) {\n clack.log.warn(`Failed to read/write ${chalk.cyan('pubspec.yaml')} file.`);\n Sentry.captureException(error);\n return false;\n }\n}\n\nexport function addProperties(pubspecFile: string | null, authToken: string) {\n try {\n if (!pubspecFile) {\n throw new Error('pubspec.yaml is not provided or invalid.');\n }\n\n const pubspecDir = path.dirname(pubspecFile);\n const sentryPropertiesFileName = 'sentry.properties';\n const sentryPropertiesFile = path.join(\n pubspecDir,\n sentryPropertiesFileName,\n );\n const sentryPropertiesContent = sentryProperties(authToken);\n\n fs.writeFileSync(sentryPropertiesFile, sentryPropertiesContent, 'utf8');\n\n const gitignoreFile = path.join(pubspecDir, '.gitignore');\n if (fs.existsSync(gitignoreFile)) {\n fs.appendFileSync(gitignoreFile, `\\n${sentryPropertiesFileName}\\n`);\n } else {\n fs.writeFileSync(gitignoreFile, `${sentryPropertiesFileName}\\n`, 'utf8');\n }\n return true;\n } catch (error) {\n clack.log.warn(`Failed to read/write ${chalk.cyan('pubspec.yaml')} file.`);\n Sentry.captureException(error);\n return false;\n }\n}\n\nexport async function patchMain(\n mainFile: string | null,\n dsn: string,\n canEnableProfiling: boolean,\n): Promise<boolean> {\n try {\n if (!mainFile) {\n throw new Error('pubspec.yaml is not provided or invalid.');\n }\n\n let mainContent = fs.readFileSync(mainFile, 'utf8');\n if (\n /import\\s+['\"]package[:]sentry_flutter\\/sentry_flutter\\.dart['\"];?/i.test(\n mainContent,\n )\n ) {\n // sentry is already configured\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('main.dart')} already has Sentry configured.`,\n ),\n );\n return true;\n }\n\n const features = [\n {\n id: 'tracing',\n prompt: `Do you want to enable ${chalk.bold(\n 'Tracing',\n )} to track the performance of your application?`,\n enabledHint: 'recommended',\n },\n ];\n if (canEnableProfiling) {\n features.push({\n id: 'profiling',\n prompt: `Do you want to enable ${chalk.bold(\n 'Profiling',\n )} to analyze CPU usage and optimize performance-critical code on iOS & macOS?`,\n enabledHint: 'recommended, tracing must be enabled',\n });\n }\n features.push({\n id: 'replay',\n prompt: `Do you want to enable ${chalk.bold(\n 'Session Replay',\n )} to record user interactions and debug issues?`,\n enabledHint: 'recommended',\n });\n\n const selectedFeatures = await featureSelectionPrompt(features);\n const normalizedSelectedFeatures = {\n tracing: selectedFeatures.tracing ?? false,\n profiling: selectedFeatures.profiling ?? false,\n replay: selectedFeatures.replay ?? false,\n };\n mainContent = patchMainContent(\n dsn,\n mainContent,\n normalizedSelectedFeatures,\n );\n\n if (normalizedSelectedFeatures.replay) {\n clack.log.info(\n `Session Replay will be enabled with default settings (replaysSessionSampleRate: ${sessionReplaySampleRate}, replaysOnErrorSampleRate: ${sessionReplayOnErrorSampleRate}).`,\n );\n clack.log.message(\n 'By default, all text content, images, and webviews will be masked for privacy. You can customize this in your code later.',\n );\n }\n\n fs.writeFileSync(mainFile, mainContent, 'utf8');\n\n clack.log.success(\n chalk.greenBright(\n `Patched ${chalk.bold(\n 'main.dart',\n )} with the Sentry setup and test error snippet.`,\n ),\n );\n\n return true;\n } catch (error) {\n clack.log.warn(`Failed to read/write ${chalk.cyan('main.dart')} file.`);\n Sentry.captureException(error);\n return false;\n }\n}\n\nexport function patchMainContent(\n dsn: string,\n mainContent: string,\n selectedFeatures: {\n tracing: boolean;\n profiling: boolean;\n replay: boolean;\n },\n): string {\n const importIndex = getLastImportLineLocation(mainContent);\n mainContent =\n mainContent.slice(0, importIndex) +\n sentryImport +\n mainContent.slice(importIndex);\n\n // Find and replace `runApp(...)`\n mainContent = mainContent.replace(\n /runApp\\(([\\s\\S]*?)\\);/g, // Match the `runApp(...)` invocation\n (_, runAppArgs) => initSnippet(dsn, selectedFeatures, runAppArgs as string),\n );\n\n // Make the `main` function async if it's not already\n mainContent = mainContent.replace(\n /void\\s+main\\(\\)\\s*\\{/g,\n 'Future<void> main() async {',\n );\n\n return mainContent;\n}\n\nexport function getLastImportLineLocation(sourceCode: string): number {\n const importRegex = /import\\s+['\"].*['\"].*;/gim;\n return getLastReqExpLocation(sourceCode, importRegex);\n}\n\nexport function getDependenciesLocation(sourceCode: string): number {\n const dependencyRegex = /^dependencies:\\s*$/gim;\n return getLastReqExpLocation(sourceCode, dependencyRegex);\n}\n\nexport function getDevDependenciesLocation(sourceCode: string): number {\n const dependencyRegex = /^dev_dependencies:\\s*$/gim;\n return getLastReqExpLocation(sourceCode, dependencyRegex);\n}\n\n// Helper\n\nfunction getLastReqExpLocation(sourceCode: string, regExp: RegExp): number {\n let match = regExp.exec(sourceCode);\n let importIndex = 0;\n while (match) {\n importIndex = match.index + match[0].length + 1;\n match = regExp.exec(sourceCode);\n }\n return importIndex;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"code-tools.js","sourceRoot":"","sources":["../../../src/flutter/code-tools.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,qDAAuC;AACvC,+EAA+E;AAC/E,sDAAwC;AACxC,kDAA0B;AAC1B,2CAOqB;AACrB,0CAAwD;AAExD;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,GAAW,EAAE,IAAY;IAChD,MAAM,KAAK,GAAa,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAE5C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,QAAQ,GAAW,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC9C,MAAM,KAAK,GAAa,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAE9C,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE;YACvB,MAAM,MAAM,GAAkB,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YACvD,IAAI,MAAM,EAAE;gBACV,OAAO,MAAM,CAAC;aACf;SACF;aAAM,IAAI,IAAI,KAAK,IAAI,EAAE;YACxB,OAAO,QAAQ,CAAC;SACjB;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAlBD,4BAkBC;AAED,SAAgB,YAAY,CAC1B,WAA0B,EAC1B,wBAAgC,EAChC,uBAA+B,EAC/B,OAAe,EACf,GAAW;IAEX,IAAI;QACF,IAAI,CAAC,WAAW,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;SAC7D;QAED,IAAI,cAAc,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,MAAM,CAAC,CAA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AC;IACpD,OAAO,qBAAqB,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;AAC5D,CAAC;AAHD,gEAGC;AAED,SAAS;AAET,SAAS,qBAAqB,CAAC,UAAkB,EAAE,MAAc;IAC/D,IAAI,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACpC,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,OAAO,KAAK,EAAE;QACZ,WAAW,GAAG,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;QAChD,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;KACjC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport * as Sentry from '@sentry/node';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport {\n sentryImport,\n pubspecOptions,\n sentryProperties,\n initSnippet,\n sessionReplaySampleRate,\n sessionReplayOnErrorSampleRate,\n} from './templates';\nimport { featureSelectionPrompt } from '../utils/clack';\n\n/**\n * Recursively finds a file per name in subfolders.\n * @param dir - The directory to start searching.\n * @param name - The name of the file including path extension.\n * @returns The path to the main.dart file or null if not found.\n */\nexport function findFile(dir: string, name: string): string | null {\n const files: string[] = fs.readdirSync(dir);\n\n for (const file of files) {\n const fullPath: string = path.join(dir, file);\n const stats: fs.Stats = fs.statSync(fullPath);\n\n if (stats.isDirectory()) {\n const result: string | null = findFile(fullPath, name);\n if (result) {\n return result;\n }\n } else if (file === name) {\n return fullPath;\n }\n }\n\n return null;\n}\n\nexport function patchPubspec(\n pubspecFile: string | null,\n sentryDartFlutterVersion: string,\n sentryDartPluginVersion: string,\n project: string,\n org: string,\n): boolean {\n try {\n if (!pubspecFile) {\n throw new Error('pubspec.yaml is not provided or invalid.');\n }\n\n let pubspecContent = fs.readFileSync(pubspecFile, 'utf8');\n\n if (!pubspecContent.includes('sentry_flutter:')) {\n const dependenciesIndex = getDependenciesLocation(pubspecContent);\n\n pubspecContent =\n pubspecContent.slice(0, dependenciesIndex) +\n ` sentry_flutter: ${sentryDartFlutterVersion}\\n` +\n pubspecContent.slice(dependenciesIndex);\n\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('sentry_flutter')} added to pubspec.yaml`,\n ),\n );\n } else {\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('sentry_flutter')} is already included in pubspec.yaml`,\n ),\n );\n }\n\n if (!pubspecContent.includes('sentry_dart_plugin:')) {\n const devDependenciesIndex = getDevDependenciesLocation(pubspecContent);\n pubspecContent =\n pubspecContent.slice(0, devDependenciesIndex) +\n ` sentry_dart_plugin: ${sentryDartPluginVersion}\\n` +\n pubspecContent.slice(devDependenciesIndex);\n\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('sentry_dart_plugin')} added to pubspec.yaml`,\n ),\n );\n } else {\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold(\n 'sentry_dart_plugin',\n )} is already included in pubspec.yaml`,\n ),\n );\n }\n\n if (!pubspecContent.includes('sentry:')) {\n pubspecContent += '\\n';\n pubspecContent += pubspecOptions(project, org);\n\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('sentry plugin configuration')} added to pubspec.yaml`,\n ),\n );\n } else {\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold(\n 'sentry plugin configuration',\n )} is already included in pubspec.yaml`,\n ),\n );\n }\n\n fs.writeFileSync(pubspecFile, pubspecContent, 'utf8');\n\n return true;\n } catch (error) {\n clack.log.warn(`Failed to read/write ${chalk.cyan('pubspec.yaml')} file.`);\n Sentry.captureException(error);\n return false;\n }\n}\n\nexport function addProperties(pubspecFile: string | null, authToken: string) {\n try {\n if (!pubspecFile) {\n throw new Error('pubspec.yaml is not provided or invalid.');\n }\n\n const pubspecDir = path.dirname(pubspecFile);\n const sentryPropertiesFileName = 'sentry.properties';\n const sentryPropertiesFile = path.join(\n pubspecDir,\n sentryPropertiesFileName,\n );\n const sentryPropertiesContent = sentryProperties(authToken);\n\n fs.writeFileSync(sentryPropertiesFile, sentryPropertiesContent, 'utf8');\n\n const gitignoreFile = path.join(pubspecDir, '.gitignore');\n if (fs.existsSync(gitignoreFile)) {\n fs.appendFileSync(gitignoreFile, `\\n${sentryPropertiesFileName}\\n`);\n } else {\n fs.writeFileSync(gitignoreFile, `${sentryPropertiesFileName}\\n`, 'utf8');\n }\n return true;\n } catch (error) {\n clack.log.warn(`Failed to read/write ${chalk.cyan('pubspec.yaml')} file.`);\n Sentry.captureException(error);\n return false;\n }\n}\n\nexport async function patchMain(\n mainFile: string | null,\n dsn: string,\n canEnableProfiling: boolean,\n): Promise<boolean> {\n try {\n if (!mainFile) {\n throw new Error('pubspec.yaml is not provided or invalid.');\n }\n\n let mainContent = fs.readFileSync(mainFile, 'utf8');\n if (\n /import\\s+['\"]package[:]sentry_flutter\\/sentry_flutter\\.dart['\"];?/i.test(\n mainContent,\n )\n ) {\n // sentry is already configured\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('main.dart')} already has Sentry configured.`,\n ),\n );\n return true;\n }\n\n const features = [\n {\n id: 'tracing',\n prompt: `Do you want to enable ${chalk.bold(\n 'Tracing',\n )} to track the performance of your application?`,\n enabledHint: 'recommended',\n },\n ];\n if (canEnableProfiling) {\n features.push({\n id: 'profiling',\n prompt: `Do you want to enable ${chalk.bold(\n 'Profiling',\n )} to analyze CPU usage and optimize performance-critical code on iOS & macOS?`,\n enabledHint: 'recommended, tracing must be enabled',\n });\n }\n features.push({\n id: 'replay',\n prompt: `Do you want to enable ${chalk.bold(\n 'Session Replay',\n )} to record user interactions and debug issues?`,\n enabledHint: 'recommended',\n });\n features.push({\n id: 'logs',\n prompt: `Do you want to enable ${chalk.bold(\n 'Logs',\n )} to send your application logs to Sentry?`,\n enabledHint: 'optional',\n });\n\n const selectedFeatures = await featureSelectionPrompt(features);\n const normalizedSelectedFeatures = {\n tracing: selectedFeatures.tracing ?? false,\n profiling: selectedFeatures.profiling ?? false,\n replay: selectedFeatures.replay ?? false,\n logs: selectedFeatures.logs ?? false,\n };\n mainContent = patchMainContent(\n dsn,\n mainContent,\n normalizedSelectedFeatures,\n );\n\n if (normalizedSelectedFeatures.replay) {\n clack.log.info(\n `Session Replay will be enabled with default settings (replaysSessionSampleRate: ${sessionReplaySampleRate}, replaysOnErrorSampleRate: ${sessionReplayOnErrorSampleRate}).`,\n );\n clack.log.message(\n 'By default, all text content, images, and webviews will be masked for privacy. You can customize this in your code later.',\n );\n }\n\n fs.writeFileSync(mainFile, mainContent, 'utf8');\n\n clack.log.success(\n chalk.greenBright(\n `Patched ${chalk.bold(\n 'main.dart',\n )} with the Sentry setup and test error snippet.`,\n ),\n );\n\n return true;\n } catch (error) {\n clack.log.warn(`Failed to read/write ${chalk.cyan('main.dart')} file.`);\n Sentry.captureException(error);\n return false;\n }\n}\n\nexport function patchMainContent(\n dsn: string,\n mainContent: string,\n selectedFeatures: {\n tracing: boolean;\n profiling: boolean;\n replay: boolean;\n logs: boolean;\n },\n): string {\n const importIndex = getLastImportLineLocation(mainContent);\n mainContent =\n mainContent.slice(0, importIndex) +\n sentryImport +\n mainContent.slice(importIndex);\n\n // Find and replace `runApp(...)`\n mainContent = mainContent.replace(\n /runApp\\(([\\s\\S]*?)\\);/g, // Match the `runApp(...)` invocation\n (_, runAppArgs) => initSnippet(dsn, selectedFeatures, runAppArgs as string),\n );\n\n // Make the `main` function async if it's not already\n mainContent = mainContent.replace(\n /void\\s+main\\(\\)\\s*\\{/g,\n 'Future<void> main() async {',\n );\n\n return mainContent;\n}\n\nexport function getLastImportLineLocation(sourceCode: string): number {\n const importRegex = /import\\s+['\"].*['\"].*;/gim;\n return getLastReqExpLocation(sourceCode, importRegex);\n}\n\nexport function getDependenciesLocation(sourceCode: string): number {\n const dependencyRegex = /^dependencies:\\s*$/gim;\n return getLastReqExpLocation(sourceCode, dependencyRegex);\n}\n\nexport function getDevDependenciesLocation(sourceCode: string): number {\n const dependencyRegex = /^dev_dependencies:\\s*$/gim;\n return getLastReqExpLocation(sourceCode, dependencyRegex);\n}\n\n// Helper\n\nfunction getLastReqExpLocation(sourceCode: string, regExp: RegExp): number {\n let match = regExp.exec(sourceCode);\n let importIndex = 0;\n while (match) {\n importIndex = match.index + match[0].length + 1;\n match = regExp.exec(sourceCode);\n }\n return importIndex;\n}\n"]}
|
|
@@ -39,6 +39,7 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
39
39
|
const clack_1 = require("../utils/clack");
|
|
40
40
|
const telemetry_1 = require("../telemetry");
|
|
41
41
|
const code_tools_1 = require("./code-tools");
|
|
42
|
+
const mcp_config_1 = require("../utils/clack/mcp-config");
|
|
42
43
|
async function runFlutterWizard(options) {
|
|
43
44
|
return (0, telemetry_1.withTelemetry)({
|
|
44
45
|
enabled: options.telemetryEnabled,
|
|
@@ -106,6 +107,8 @@ Set the ${chalk_1.default.cyan('SENTRY_AUTH_TOKEN')} environment variable in you
|
|
|
106
107
|
}
|
|
107
108
|
Sentry.setTag('main-patched', mainPatched);
|
|
108
109
|
// ======== OUTRO ========
|
|
110
|
+
// Offer optional project-scoped MCP config for Sentry with org and project scope
|
|
111
|
+
await (0, mcp_config_1.offerProjectScopedMcpConfig)(selectedProject.organization.slug, selectedProject.slug);
|
|
109
112
|
const issuesPageLink = selfHosted
|
|
110
113
|
? `${sentryUrl}organizations/${selectedProject.organization.slug}/issues/?project=${selectedProject.id}`
|
|
111
114
|
: `https://${selectedProject.organization.slug}.sentry.io/issues/?project=${selectedProject.id}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flutter-wizard.js","sourceRoot":"","sources":["../../../src/flutter/flutter-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,uCAAyB;AACzB,2CAA6B;AAC7B,gEAA4D;AAE5D,wDAA0C;AAC1C,2CAAwE;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AAE,WAAW,CAAC,CAAC;IAE3C,0BAA0B;IAE1B,MAAM,cAAc,GAAG,UAAU;QAC/B,CAAC,CAAC,GAAG,SAAS,iBAAiB,eAAe,CAAC,YAAY,CAAC,IAAI,oBAAoB,eAAe,CAAC,EAAE,EAAE;QACxG,CAAC,CAAC,WAAW,eAAe,CAAC,YAAY,CAAC,IAAI,8BAA8B,eAAe,CAAC,EAAE,EAAE,CAAC;IAEnG,KAAK,CAAC,KAAK,CAAC;MACR,eAAK,CAAC,WAAW,CAAC,gDAAgD,CAAC;;MAEnE,eAAK,CAAC,IAAI,CAAC,aAAa,CAAC;aAClB,eAAK,CAAC,IAAI,CACjB,aAAa,CACd;oCAC+B,eAAK,CAAC,IAAI,CACxC,mEAAmE,CACpE,wBAAwB,eAAK,CAAC,IAAI,CACnC,oCAAoC,CACrC;sDACmD,cAAc;;MAE9D,eAAK,CAAC,IAAI,CAAC,aAAa,CAAC;;;;GAI5B,CAAC,CAAC;AACL,CAAC","sourcesContent":["import * as Sentry from '@sentry/node';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { fetchSdkVersion } from '../utils/release-registry';\nimport { WizardOptions } from '../utils/types';\nimport * as codetools from './code-tools';\nimport { initSnippetColored, pubspecSnippetColored } from './templates';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\n\nimport {\n confirmContinueIfNoOrDirtyGitRepo,\n getOrAskForProjectData,\n printWelcome,\n showCopyPasteInstructions,\n} from '../utils/clack';\n\nimport { traceStep, withTelemetry } from '../telemetry';\nimport { findFile } from './code-tools';\n\nexport async function runFlutterWizard(options: WizardOptions): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'flutter',\n wizardOptions: options,\n },\n () => runFlutterWizardWithTelemetry(options),\n );\n}\n\nasync function runFlutterWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry Flutter Wizard',\n promoCode: options.promoCode,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\n\n const { selectedProject, selfHosted, sentryUrl, authToken } =\n await getOrAskForProjectData(options, 'flutter');\n\n const projectDir = process.cwd();\n const pubspecFile = path.join(projectDir, 'pubspec.yaml');\n if (!fs.existsSync(pubspecFile)) {\n clack.log.error(\n `Could not find ${chalk.cyan(\n 'pubspec.yaml',\n )}. Make sure you run the wizard in the projects root folder.`,\n );\n return;\n }\n\n // ======== STEP 1. Add sentry_flutter and sentry_dart_plugin to pubspec.yaml ============\n\n clack.log.step(\n `Adding ${chalk.bold('Sentry')} to your apps ${chalk.cyan(\n 'pubspec.yaml',\n )} file.`,\n );\n\n const flutterVersion = await fetchSdkVersion('sentry.dart.flutter');\n const flutterVersionOrAny = flutterVersion ? `^${flutterVersion}` : 'any';\n\n const pluginVersion = await fetchSdkVersion('sentry.dart.plugin');\n const pluginVersionOrAny = pluginVersion ? `^${pluginVersion}` : 'any';\n\n const pubspecPatched = traceStep('Patch pubspec.yaml', () =>\n codetools.patchPubspec(\n pubspecFile,\n flutterVersionOrAny,\n pluginVersionOrAny,\n selectedProject.slug,\n selectedProject.organization.slug,\n ),\n );\n if (!pubspecPatched) {\n clack.log.warn(\n `Could not patch ${chalk.cyan(\n 'pubspec.yaml',\n )}. Add the dependencies to it.`,\n );\n await showCopyPasteInstructions({\n filename: 'pubspec.yaml',\n codeSnippet: pubspecSnippetColored(\n flutterVersionOrAny,\n pluginVersionOrAny,\n selectedProject.slug,\n selectedProject.organization.slug,\n ),\n hint: 'This ensures the Sentry SDK and plugin can be imported.',\n });\n }\n Sentry.setTag('pubspec-patched', pubspecPatched);\n\n // ======== STEP 2. Add sentry.properties with auth token ============\n\n const propertiesAdded = traceStep('Add sentry.properties', () =>\n codetools.addProperties(pubspecFile, authToken),\n );\n if (!propertiesAdded) {\n clack.log.warn(\n `We could not add ${chalk.cyan(\n 'sentry.properties',\n )} file in your project directory in order to provide an auth token for Sentry CLI. You'll have to add it manually, or you can set the SENTRY_AUTH_TOKEN environment variable instead. See https://docs.sentry.io/cli/configuration/#auth-token for more information.`,\n );\n } else {\n clack.log.info(\n `Created a ${chalk.cyan(\n 'sentry.properties',\n )} file in your project directory to provide an auth token for Sentry CLI.\nIt was also added to your ${chalk.cyan('.gitignore')} file.\nSet the ${chalk.cyan(\n 'SENTRY_AUTH_TOKEN',\n )} environment variable in your CI environment. See https://docs.sentry.io/cli/configuration/#auth-token for more information.`,\n );\n }\n Sentry.setTag('sentry-properties-added', pubspecPatched);\n\n // ======== STEP 3. Patch main.dart with setup and a test error snippet ============\n\n clack.log.step(\n `Next, the wizard will patch your ${chalk.cyan(\n 'main.dart',\n )} file with the SDK init and a test error snippet.`,\n );\n\n const mainFile = findFile(`${projectDir}/lib`, 'main.dart');\n const dsn = selectedProject.keys[0].dsn.public;\n const canEnableProfiling =\n fs.existsSync(`${projectDir}/ios`) || fs.existsSync(`${projectDir}/macos`);\n\n const mainPatched = await traceStep('Patch main.dart', () =>\n codetools.patchMain(mainFile, dsn, canEnableProfiling),\n );\n if (!mainPatched) {\n clack.log.warn(\n `Could not patch ${chalk.cyan(\n 'main.dart',\n )} file. Place the following code snippet within the apps main function.`,\n );\n await showCopyPasteInstructions({\n filename: 'main.dart',\n codeSnippet: initSnippetColored(dsn),\n hint: 'This ensures the Sentry SDK is ready to capture errors.',\n });\n }\n Sentry.setTag('main-patched', mainPatched);\n\n // ======== OUTRO ========\n\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 Flutter SDK!')}\n \n ${chalk.cyan('Next steps:')}\n 1. Run ${chalk.bold(\n 'flutter run',\n )} to test the setup - we've added a test error that will trigger on app start\n 2. For production builds, run ${chalk.bold(\n 'flutter build apk --obfuscate --split-debug-info=build/debug-info',\n )} (or ios/macos) then ${chalk.bold(\n 'flutter pub run sentry_dart_plugin',\n )} to upload debug symbols\n 3. View your test error and transaction data at ${issuesPageLink}\n \n ${chalk.cyan('Learn more:')}\n - Debug Symbols: https://docs.sentry.io/platforms/dart/guides/flutter/debug-symbols/\n - Performance Monitoring: https://docs.sentry.io/platforms/dart/guides/flutter/performance/\n - Integrations: https://docs.sentry.io/platforms/dart/guides/flutter/integrations/\n `);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"flutter-wizard.js","sourceRoot":"","sources":["../../../src/flutter/flutter-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,uCAAyB;AACzB,2CAA6B;AAC7B,gEAA4D;AAE5D,wDAA0C;AAC1C,2CAAwE;AACxE,+EAA+E;AAC/E,sDAAwC;AACxC,kDAA0B;AAE1B,0CAKwB;AAExB,4CAAwD;AACxD,6CAAwC;AACxC,0DAAwE;AAEjE,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,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,GACzD,MAAM,IAAA,8BAAsB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;GAI5B,CAAC,CAAC;AACL,CAAC","sourcesContent":["import * as Sentry from '@sentry/node';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { fetchSdkVersion } from '../utils/release-registry';\nimport { WizardOptions } from '../utils/types';\nimport * as codetools from './code-tools';\nimport { initSnippetColored, pubspecSnippetColored } from './templates';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\n\nimport {\n confirmContinueIfNoOrDirtyGitRepo,\n getOrAskForProjectData,\n printWelcome,\n showCopyPasteInstructions,\n} from '../utils/clack';\n\nimport { traceStep, withTelemetry } from '../telemetry';\nimport { findFile } from './code-tools';\nimport { offerProjectScopedMcpConfig } from '../utils/clack/mcp-config';\n\nexport async function runFlutterWizard(options: WizardOptions): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'flutter',\n wizardOptions: options,\n },\n () => runFlutterWizardWithTelemetry(options),\n );\n}\n\nasync function runFlutterWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry Flutter Wizard',\n promoCode: options.promoCode,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\n\n const { selectedProject, selfHosted, sentryUrl, authToken } =\n await getOrAskForProjectData(options, 'flutter');\n\n const projectDir = process.cwd();\n const pubspecFile = path.join(projectDir, 'pubspec.yaml');\n if (!fs.existsSync(pubspecFile)) {\n clack.log.error(\n `Could not find ${chalk.cyan(\n 'pubspec.yaml',\n )}. Make sure you run the wizard in the projects root folder.`,\n );\n return;\n }\n\n // ======== STEP 1. Add sentry_flutter and sentry_dart_plugin to pubspec.yaml ============\n\n clack.log.step(\n `Adding ${chalk.bold('Sentry')} to your apps ${chalk.cyan(\n 'pubspec.yaml',\n )} file.`,\n );\n\n const flutterVersion = await fetchSdkVersion('sentry.dart.flutter');\n const flutterVersionOrAny = flutterVersion ? `^${flutterVersion}` : 'any';\n\n const pluginVersion = await fetchSdkVersion('sentry.dart.plugin');\n const pluginVersionOrAny = pluginVersion ? `^${pluginVersion}` : 'any';\n\n const pubspecPatched = traceStep('Patch pubspec.yaml', () =>\n codetools.patchPubspec(\n pubspecFile,\n flutterVersionOrAny,\n pluginVersionOrAny,\n selectedProject.slug,\n selectedProject.organization.slug,\n ),\n );\n if (!pubspecPatched) {\n clack.log.warn(\n `Could not patch ${chalk.cyan(\n 'pubspec.yaml',\n )}. Add the dependencies to it.`,\n );\n await showCopyPasteInstructions({\n filename: 'pubspec.yaml',\n codeSnippet: pubspecSnippetColored(\n flutterVersionOrAny,\n pluginVersionOrAny,\n selectedProject.slug,\n selectedProject.organization.slug,\n ),\n hint: 'This ensures the Sentry SDK and plugin can be imported.',\n });\n }\n Sentry.setTag('pubspec-patched', pubspecPatched);\n\n // ======== STEP 2. Add sentry.properties with auth token ============\n\n const propertiesAdded = traceStep('Add sentry.properties', () =>\n codetools.addProperties(pubspecFile, authToken),\n );\n if (!propertiesAdded) {\n clack.log.warn(\n `We could not add ${chalk.cyan(\n 'sentry.properties',\n )} file in your project directory in order to provide an auth token for Sentry CLI. You'll have to add it manually, or you can set the SENTRY_AUTH_TOKEN environment variable instead. See https://docs.sentry.io/cli/configuration/#auth-token for more information.`,\n );\n } else {\n clack.log.info(\n `Created a ${chalk.cyan(\n 'sentry.properties',\n )} file in your project directory to provide an auth token for Sentry CLI.\nIt was also added to your ${chalk.cyan('.gitignore')} file.\nSet the ${chalk.cyan(\n 'SENTRY_AUTH_TOKEN',\n )} environment variable in your CI environment. See https://docs.sentry.io/cli/configuration/#auth-token for more information.`,\n );\n }\n Sentry.setTag('sentry-properties-added', pubspecPatched);\n\n // ======== STEP 3. Patch main.dart with setup and a test error snippet ============\n\n clack.log.step(\n `Next, the wizard will patch your ${chalk.cyan(\n 'main.dart',\n )} file with the SDK init and a test error snippet.`,\n );\n\n const mainFile = findFile(`${projectDir}/lib`, 'main.dart');\n const dsn = selectedProject.keys[0].dsn.public;\n const canEnableProfiling =\n fs.existsSync(`${projectDir}/ios`) || fs.existsSync(`${projectDir}/macos`);\n\n const mainPatched = await traceStep('Patch main.dart', () =>\n codetools.patchMain(mainFile, dsn, canEnableProfiling),\n );\n if (!mainPatched) {\n clack.log.warn(\n `Could not patch ${chalk.cyan(\n 'main.dart',\n )} file. Place the following code snippet within the apps main function.`,\n );\n await showCopyPasteInstructions({\n filename: 'main.dart',\n codeSnippet: initSnippetColored(dsn),\n hint: 'This ensures the Sentry SDK is ready to capture errors.',\n });\n }\n Sentry.setTag('main-patched', mainPatched);\n\n // ======== OUTRO ========\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 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 Flutter SDK!')}\n \n ${chalk.cyan('Next steps:')}\n 1. Run ${chalk.bold(\n 'flutter run',\n )} to test the setup - we've added a test error that will trigger on app start\n 2. For production builds, run ${chalk.bold(\n 'flutter build apk --obfuscate --split-debug-info=build/debug-info',\n )} (or ios/macos) then ${chalk.bold(\n 'flutter pub run sentry_dart_plugin',\n )} to upload debug symbols\n 3. View your test error and transaction data at ${issuesPageLink}\n \n ${chalk.cyan('Learn more:')}\n - Debug Symbols: https://docs.sentry.io/platforms/dart/guides/flutter/debug-symbols/\n - Performance Monitoring: https://docs.sentry.io/platforms/dart/guides/flutter/performance/\n - Integrations: https://docs.sentry.io/platforms/dart/guides/flutter/integrations/\n `);\n}\n"]}
|
|
@@ -7,6 +7,7 @@ export declare function initSnippet(dsn: string, selectedFeaturesMap: {
|
|
|
7
7
|
tracing: boolean;
|
|
8
8
|
profiling: boolean;
|
|
9
9
|
replay: boolean;
|
|
10
|
+
logs: boolean;
|
|
10
11
|
}, runApp: string): string;
|
|
11
12
|
export declare function pubspecSnippetColored(sentryVersion: string, pluginVersion: string, project: string, org: string): string;
|
|
12
13
|
export declare function initSnippetColored(dsn: string): string;
|
|
@@ -25,6 +25,10 @@ function initSnippet(dsn, selectedFeaturesMap, runApp) {
|
|
|
25
25
|
// Adds request headers and IP for users, for more info visit:
|
|
26
26
|
// https://docs.sentry.io/platforms/dart/guides/flutter/data-management/data-collected/
|
|
27
27
|
options.sendDefaultPii = true;`;
|
|
28
|
+
if (selectedFeaturesMap.logs) {
|
|
29
|
+
snippet += `
|
|
30
|
+
options.enableLogs = true;`;
|
|
31
|
+
}
|
|
28
32
|
if (selectedFeaturesMap.tracing) {
|
|
29
33
|
snippet += `
|
|
30
34
|
// Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing.
|
|
@@ -79,6 +83,7 @@ Future<void>main() async {
|
|
|
79
83
|
// Adds request headers and IP for users, for more info visit:
|
|
80
84
|
// https://docs.sentry.io/platforms/dart/guides/flutter/data-management/data-collected/
|
|
81
85
|
options.sendDefaultPii = true;
|
|
86
|
+
|
|
82
87
|
// Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing.
|
|
83
88
|
// We recommend adjusting this value in production.
|
|
84
89
|
options.tracesSampleRate = 1.0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/flutter/templates.ts"],"names":[],"mappings":";;;AAAA,0CAAiD;AAEpC,QAAA,YAAY,GAAG,wDAAwD,CAAC;AACxE,QAAA,uBAAuB,GAAG,GAAG,CAAC;AAC9B,QAAA,8BAA8B,GAAG,GAAG,CAAC;AAElD,SAAgB,cAAc,CAAC,OAAe,EAAE,GAAW;IACzD,OAAO;;;aAGI,OAAO;SACX,GAAG;CACX,CAAC;AACF,CAAC;AAPD,wCAOC;AAED,SAAgB,gBAAgB,CAAC,SAAiB;IAChD,OAAO,cAAc,SAAS,EAAE,CAAC;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A2DC;AAED,SAAgB,qBAAqB,CACnC,aAAqB,EACrB,aAAqB,EACrB,OAAe,EACf,GAAW;IAEX,MAAM,OAAO,GAAG;oBACE,aAAa;;;wBAGT,aAAa;;EAEnC,cAAc,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC;IAE/B,OAAO,IAAA,uBAAe,EAAC,IAAI,EAAE,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACL,CAAC;AAjBD,sDAiBC;AAED,SAAgB,kBAAkB,CAAC,GAAW;IAC5C,MAAM,OAAO,GAAG;;;;;uBAKK,GAAG;;;;;;;;;;;EAWxB,CAAC;IACD,OAAO,IAAA,uBAAe,EAAC,IAAI,EAAE,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACL,CAAC;AArBD,gDAqBC","sourcesContent":["import { makeCodeSnippet } from '../utils/clack';\n\nexport const sentryImport = `import 'package:sentry_flutter/sentry_flutter.dart';\\n`;\nexport const sessionReplaySampleRate = 0.1;\nexport const sessionReplayOnErrorSampleRate = 1.0;\n\nexport function pubspecOptions(project: string, org: string): string {\n return `sentry:\n upload_debug_symbols: true\n upload_source_maps: true\n project: ${project}\n org: ${org}\n`;\n}\n\nexport function sentryProperties(authToken: string): string {\n return `auth_token=${authToken}`;\n}\n\nexport function initSnippet(\n dsn: string,\n selectedFeaturesMap: {\n tracing: boolean;\n profiling: boolean;\n replay: boolean;\n logs: boolean;\n },\n runApp: string,\n): string {\n let snippet = `await SentryFlutter.init(\n (options) {\n options.dsn = '${dsn}';\n // Adds request headers and IP for users, for more info visit:\n // https://docs.sentry.io/platforms/dart/guides/flutter/data-management/data-collected/\n options.sendDefaultPii = true;`;\n\n if (selectedFeaturesMap.logs) {\n snippet += `\n options.enableLogs = true;`;\n }\n\n if (selectedFeaturesMap.tracing) {\n snippet += `\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = 1.0;`;\n }\n\n if (selectedFeaturesMap.profiling && selectedFeaturesMap.tracing) {\n snippet += `\n // The sampling rate for profiling is relative to tracesSampleRate\n // Setting to 1.0 will profile 100% of sampled transactions:\n options.profilesSampleRate = 1.0;`;\n }\n\n if (selectedFeaturesMap.replay) {\n snippet += `\n // Configure Session Replay\n options.replay.sessionSampleRate = ${\n sessionReplaySampleRate % 1 === 0\n ? `${sessionReplaySampleRate}.0`\n : sessionReplaySampleRate\n };\n options.replay.onErrorSampleRate = ${\n sessionReplayOnErrorSampleRate % 1 === 0\n ? `${sessionReplayOnErrorSampleRate}.0`\n : sessionReplayOnErrorSampleRate\n };`;\n }\n\n snippet += `\n },\n appRunner: () => runApp(SentryWidget(child: ${runApp})),\n );\n // TODO: Remove this line after sending the first sample event to sentry.\n await Sentry.captureException(StateError('This is a sample exception.'));`;\n\n return snippet;\n}\n\nexport function pubspecSnippetColored(\n sentryVersion: string,\n pluginVersion: string,\n project: string,\n org: string,\n): string {\n const snippet = `dependencies:\n sentry_flutter: ${sentryVersion}\n\ndev_dependencies:\n sentry_dart_plugin: ${pluginVersion}\n \n${pubspecOptions(project, org)}`;\n\n return makeCodeSnippet(true, (_unchanged, plus, _minus) => {\n return plus(snippet);\n });\n}\n\nexport function initSnippetColored(dsn: string): string {\n const snippet = `import 'package:sentry_flutter/sentry_flutter.dart';\n\nFuture<void>main() async {\n await SentryFlutter.init(\n (options) {\n options.dsn = '${dsn}';\n // Adds request headers and IP for users, for more info visit:\n // https://docs.sentry.io/platforms/dart/guides/flutter/data-management/data-collected/\n options.sendDefaultPii = true;\n \n // Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = 1.0;\n },\n appRunner: () => runApp(SentryWidget(child: YourApp())),\n )\n}`;\n return makeCodeSnippet(true, (_unchanged, plus, _minus) => {\n return plus(snippet);\n });\n}\n"]}
|