@sentry/wizard 4.7.0 → 4.8.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 +11 -0
- package/README.md +19 -19
- package/dist/e2e-tests/tests/angular-17.test.d.ts +1 -0
- package/dist/e2e-tests/tests/angular-17.test.js +196 -0
- package/dist/e2e-tests/tests/angular-17.test.js.map +1 -0
- package/dist/e2e-tests/tests/angular-19.test.d.ts +1 -0
- package/dist/e2e-tests/tests/angular-19.test.js +194 -0
- package/dist/e2e-tests/tests/angular-19.test.js.map +1 -0
- package/dist/e2e-tests/tests/expo.test.d.ts +1 -0
- package/dist/e2e-tests/tests/expo.test.js +95 -0
- package/dist/e2e-tests/tests/expo.test.js.map +1 -0
- package/dist/e2e-tests/tests/help-message.test.js +2 -2
- package/dist/e2e-tests/tests/help-message.test.js.map +1 -1
- package/dist/e2e-tests/tests/react-native.test.d.ts +1 -0
- package/dist/e2e-tests/tests/react-native.test.js +97 -0
- package/dist/e2e-tests/tests/react-native.test.js.map +1 -0
- package/dist/e2e-tests/tests/remix.test.js +4 -4
- package/dist/e2e-tests/tests/remix.test.js.map +1 -1
- package/dist/e2e-tests/tests/sveltekit.test.js +2 -2
- package/dist/e2e-tests/tests/sveltekit.test.js.map +1 -1
- package/dist/e2e-tests/utils/index.d.ts +7 -0
- package/dist/e2e-tests/utils/index.js +18 -1
- package/dist/e2e-tests/utils/index.js.map +1 -1
- package/dist/lib/Constants.d.ts +1 -0
- package/dist/lib/Constants.js +3 -0
- package/dist/lib/Constants.js.map +1 -1
- package/dist/src/angular/angular-wizard.d.ts +3 -0
- package/dist/src/angular/angular-wizard.js +186 -0
- package/dist/src/angular/angular-wizard.js.map +1 -0
- package/dist/src/angular/codemods/app-config.d.ts +3 -0
- package/dist/src/angular/codemods/app-config.js +211 -0
- package/dist/src/angular/codemods/app-config.js.map +1 -0
- package/dist/src/angular/codemods/main.d.ts +20 -0
- package/dist/src/angular/codemods/main.js +62 -0
- package/dist/src/angular/codemods/main.js.map +1 -0
- package/dist/src/angular/codemods/sourcemaps.d.ts +21 -0
- package/dist/src/angular/codemods/sourcemaps.js +94 -0
- package/dist/src/angular/codemods/sourcemaps.js.map +1 -0
- package/dist/src/angular/example-component.d.ts +8 -0
- package/dist/src/angular/example-component.js +286 -0
- package/dist/src/angular/example-component.js.map +1 -0
- package/dist/src/angular/sdk-setup.d.ts +6 -0
- package/dist/src/angular/sdk-setup.js +99 -0
- package/dist/src/angular/sdk-setup.js.map +1 -0
- package/dist/src/flutter/flutter-wizard.js +10 -2
- package/dist/src/flutter/flutter-wizard.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +26 -12
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nextjs/templates.js +56 -7
- package/dist/src/nextjs/templates.js.map +1 -1
- package/dist/src/nuxt/templates.js +30 -0
- package/dist/src/nuxt/templates.js.map +1 -1
- package/dist/src/react-native/expo-metro.js +4 -1
- package/dist/src/react-native/expo-metro.js.map +1 -1
- package/dist/src/react-native/expo.js +5 -1
- package/dist/src/react-native/expo.js.map +1 -1
- package/dist/src/react-native/javascript.js +9 -2
- package/dist/src/react-native/javascript.js.map +1 -1
- package/dist/src/react-native/metro.js +8 -2
- package/dist/src/react-native/metro.js.map +1 -1
- package/dist/src/react-native/xcode.js +5 -1
- package/dist/src/react-native/xcode.js.map +1 -1
- package/dist/src/remix/sdk-example.js +30 -1
- package/dist/src/remix/sdk-example.js.map +1 -1
- package/dist/src/remix/sdk-setup.js +11 -5
- package/dist/src/remix/sdk-setup.js.map +1 -1
- package/dist/src/run.d.ts +1 -1
- package/dist/src/run.js +5 -0
- package/dist/src/run.js.map +1 -1
- package/dist/src/sourcemaps/sourcemaps-wizard.d.ts +1 -1
- package/dist/src/sourcemaps/sourcemaps-wizard.js +35 -20
- package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
- package/dist/src/sourcemaps/tools/angular.d.ts +1 -0
- package/dist/src/sourcemaps/tools/angular.js +7 -7
- package/dist/src/sourcemaps/tools/angular.js.map +1 -1
- package/dist/src/sourcemaps/tools/sentry-cli.d.ts +5 -1
- package/dist/src/sourcemaps/tools/sentry-cli.js +6 -3
- package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
- package/dist/src/sourcemaps/tools/tsc.js +5 -1
- package/dist/src/sourcemaps/tools/tsc.js.map +1 -1
- package/dist/src/sourcemaps/tools/vite.js +4 -1
- package/dist/src/sourcemaps/tools/vite.js.map +1 -1
- package/dist/src/sourcemaps/tools/webpack.js +4 -1
- package/dist/src/sourcemaps/tools/webpack.js.map +1 -1
- package/dist/src/sveltekit/sdk-example.js +1 -1
- package/dist/src/sveltekit/sdk-example.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js +2 -2
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/sveltekit/templates.js +28 -1
- package/dist/src/sveltekit/templates.js.map +1 -1
- package/dist/src/utils/clack/index.d.ts +11 -3
- package/dist/src/utils/clack/index.js +9 -3
- package/dist/src/utils/clack/index.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/test/angular/angular-wizard.test.d.ts +1 -0
- package/dist/test/angular/angular-wizard.test.js +27 -0
- package/dist/test/angular/angular-wizard.test.js.map +1 -0
- package/dist/test/angular/codemods/sourcemaps.test.d.ts +1 -0
- package/dist/test/angular/codemods/sourcemaps.test.js +237 -0
- package/dist/test/angular/codemods/sourcemaps.test.js.map +1 -0
- package/dist/test/angular/example-component.test.d.ts +1 -0
- package/dist/test/angular/example-component.test.js +105 -0
- package/dist/test/angular/example-component.test.js.map +1 -0
- package/dist/test/react-native/metro.test.js +113 -0
- package/dist/test/react-native/metro.test.js.map +1 -1
- package/dist/test/remix/client-entry.test.js +10 -10
- package/dist/test/remix/client-entry.test.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.addSourceMapsSetting = exports.addSourcemapEntryToAngularJSON = void 0;
|
|
27
|
+
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
28
|
+
const clack = __importStar(require("@clack/prompts"));
|
|
29
|
+
const path = __importStar(require("path"));
|
|
30
|
+
const fs = __importStar(require("fs"));
|
|
31
|
+
const angular_1 = require("../../sourcemaps/tools/angular");
|
|
32
|
+
const node_1 = require("@sentry/node");
|
|
33
|
+
async function addSourcemapEntryToAngularJSON() {
|
|
34
|
+
const angularJsonPath = path.join(process.cwd(), 'angular.json');
|
|
35
|
+
const angularJson = getParsedAngularJson(angularJsonPath);
|
|
36
|
+
if (!angularJson || typeof angularJson !== 'object') {
|
|
37
|
+
await (0, angular_1.configureAngularSourcemapGenerationFlow)();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const updatedAngularJson = addSourceMapsSetting(angularJson);
|
|
41
|
+
if (!updatedAngularJson) {
|
|
42
|
+
await (0, angular_1.configureAngularSourcemapGenerationFlow)();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
fs.writeFileSync(angularJsonPath, JSON.stringify(updatedAngularJson, null, 2));
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
clack.log.error(`Failed to write sourcemap configuration to angular.json`);
|
|
50
|
+
(0, node_1.captureException)('Failed to write sourcemap configuration to angular.json');
|
|
51
|
+
await (0, angular_1.configureAngularSourcemapGenerationFlow)();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.addSourcemapEntryToAngularJSON = addSourcemapEntryToAngularJSON;
|
|
55
|
+
/**
|
|
56
|
+
* Extracted from `addSourcemapEntryToAngularJSON` and exported to allow for easier testing.
|
|
57
|
+
*/
|
|
58
|
+
function addSourceMapsSetting(angularJson) {
|
|
59
|
+
const newAngularJson = { ...angularJson };
|
|
60
|
+
const projectKeys = Object.keys(newAngularJson.projects || {});
|
|
61
|
+
if (!projectKeys.length || !newAngularJson.projects) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
// Emit sourcemaps from all projects in angular.json
|
|
65
|
+
for (const projectKey of projectKeys) {
|
|
66
|
+
const projectConfig = newAngularJson.projects[projectKey];
|
|
67
|
+
if (!projectConfig.architect) {
|
|
68
|
+
projectConfig.architect = {};
|
|
69
|
+
}
|
|
70
|
+
if (!projectConfig.architect.build) {
|
|
71
|
+
projectConfig.architect.build = {};
|
|
72
|
+
}
|
|
73
|
+
if (!projectConfig.architect.build.configurations) {
|
|
74
|
+
projectConfig.architect.build.configurations = {};
|
|
75
|
+
}
|
|
76
|
+
projectConfig.architect.build.configurations.production = {
|
|
77
|
+
...projectConfig.architect.build.configurations.production,
|
|
78
|
+
sourceMap: true,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return newAngularJson;
|
|
82
|
+
}
|
|
83
|
+
exports.addSourceMapsSetting = addSourceMapsSetting;
|
|
84
|
+
function getParsedAngularJson(path) {
|
|
85
|
+
try {
|
|
86
|
+
const angularJSONFile = fs.readFileSync(path, 'utf-8');
|
|
87
|
+
return JSON.parse(angularJSONFile);
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
(0, node_1.captureException)('Could not parse `angular.json`');
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=sourcemaps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sourcemaps.js","sourceRoot":"","sources":["../../../../src/angular/codemods/sourcemaps.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,sDAAwC;AACxC,2CAA6B;AAC7B,uCAAyB;AACzB,4DAAyF;AACzF,uCAAgD;AAkBzC,KAAK,UAAU,8BAA8B;IAClD,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;IACjE,MAAM,WAAW,GAAG,oBAAoB,CAAC,eAAe,CAAC,CAAC;IAE1D,IAAI,CAAC,WAAW,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;QACnD,MAAM,IAAA,iDAAuC,GAAE,CAAC;QAChD,OAAO;KACR;IAED,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAC;IAE7D,IAAI,CAAC,kBAAkB,EAAE;QACvB,MAAM,IAAA,iDAAuC,GAAE,CAAC;QAChD,OAAO;KACR;IAED,IAAI;QACF,EAAE,CAAC,aAAa,CACd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KACH;IAED,OAAO,cAAc,CAAC;AACxB,CAAC;AAlCD,oDAkCC;AAED,SAAS,oBAAoB,CAAC,IAAY;IACxC,IAAI;QACF,MAAM,eAAe,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC,KAAK,CAAC,eAAe,CAAmC,CAAC;KACtE;IAAC,MAAM;QACN,IAAA,uBAAgB,EAAC,gCAAgC,CAAC,CAAC;QACnD,OAAO,SAAS,CAAC;KAClB;AACH,CAAC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport * as path from 'path';\nimport * as fs from 'fs';\nimport { configureAngularSourcemapGenerationFlow } from '../../sourcemaps/tools/angular';\nimport { captureException } from '@sentry/node';\n\ninterface PartialAngularJson {\n projects?: {\n [key: string]: {\n architect?: {\n build?: {\n configurations?: {\n production?: {\n sourceMap?: boolean;\n } & Record<string, unknown>;\n };\n };\n };\n };\n };\n}\n\nexport async function addSourcemapEntryToAngularJSON(): Promise<void> {\n const angularJsonPath = path.join(process.cwd(), 'angular.json');\n const angularJson = getParsedAngularJson(angularJsonPath);\n\n if (!angularJson || typeof angularJson !== 'object') {\n await configureAngularSourcemapGenerationFlow();\n return;\n }\n\n const updatedAngularJson = addSourceMapsSetting(angularJson);\n\n if (!updatedAngularJson) {\n await configureAngularSourcemapGenerationFlow();\n return;\n }\n\n try {\n fs.writeFileSync(\n angularJsonPath,\n JSON.stringify(updatedAngularJson, null, 2),\n );\n } catch (error) {\n clack.log.error(`Failed to write sourcemap configuration to angular.json`);\n captureException('Failed to write sourcemap configuration to angular.json');\n await configureAngularSourcemapGenerationFlow();\n }\n}\n\n/**\n * Extracted from `addSourcemapEntryToAngularJSON` and exported to allow for easier testing.\n */\nexport function addSourceMapsSetting(\n angularJson: PartialAngularJson,\n): PartialAngularJson | undefined {\n const newAngularJson = { ...angularJson };\n\n const projectKeys = Object.keys(newAngularJson.projects || {});\n\n if (!projectKeys.length || !newAngularJson.projects) {\n return undefined;\n }\n\n // Emit sourcemaps from all projects in angular.json\n for (const projectKey of projectKeys) {\n const projectConfig = newAngularJson.projects[projectKey];\n\n if (!projectConfig.architect) {\n projectConfig.architect = {};\n }\n\n if (!projectConfig.architect.build) {\n projectConfig.architect.build = {};\n }\n\n if (!projectConfig.architect.build.configurations) {\n projectConfig.architect.build.configurations = {};\n }\n\n projectConfig.architect.build.configurations.production = {\n ...projectConfig.architect.build.configurations.production,\n sourceMap: true,\n };\n }\n\n return newAngularJson;\n}\n\nfunction getParsedAngularJson(path: string): PartialAngularJson | undefined {\n try {\n const angularJSONFile = fs.readFileSync(path, 'utf-8');\n return JSON.parse(angularJSONFile) as PartialAngularJson | undefined;\n } catch {\n captureException('Could not parse `angular.json`');\n return undefined;\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface ExampleComponentOptions {
|
|
2
|
+
url: string;
|
|
3
|
+
orgSlug: string;
|
|
4
|
+
projectId: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function createExampleComponent(options: ExampleComponentOptions): Promise<void>;
|
|
7
|
+
export declare function getSentryExampleComponentCode(options: ExampleComponentOptions): string;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.getSentryExampleComponentCode = exports.createExampleComponent = void 0;
|
|
30
|
+
const fs = __importStar(require("fs"));
|
|
31
|
+
const clack_1 = require("../utils/clack");
|
|
32
|
+
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
33
|
+
const clack = __importStar(require("@clack/prompts"));
|
|
34
|
+
const url_1 = require("../utils/url");
|
|
35
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
36
|
+
async function createExampleComponent(options) {
|
|
37
|
+
const componentName = 'sentry-example';
|
|
38
|
+
const appRootPath = './src/app';
|
|
39
|
+
let componentDirPath = appRootPath;
|
|
40
|
+
const hasAppRoot = fs.existsSync(appRootPath);
|
|
41
|
+
if (!hasAppRoot) {
|
|
42
|
+
componentDirPath = await (0, clack_1.abortIfCancelled)(clack.text({
|
|
43
|
+
message: 'Where should we create the example component?',
|
|
44
|
+
placeholder: appRootPath,
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
if (!fs.existsSync(componentDirPath)) {
|
|
48
|
+
fs.mkdirSync(componentDirPath, { recursive: true });
|
|
49
|
+
}
|
|
50
|
+
const componentCode = getSentryExampleComponentCode(options);
|
|
51
|
+
const componentFilePath = `${componentDirPath}/${componentName}.component.ts`;
|
|
52
|
+
fs.writeFileSync(componentFilePath, componentCode);
|
|
53
|
+
clack.log.success(`Created example component at ${chalk_1.default.cyan(componentFilePath)}`);
|
|
54
|
+
const addComponentCodeSnippet = (0, clack_1.makeCodeSnippet)(true, (unchanged, plus) => unchanged(`${plus("import { SentryExample } from './sentry-example.component'")}
|
|
55
|
+
|
|
56
|
+
@Component({
|
|
57
|
+
selector: 'app-root',
|
|
58
|
+
standalone: true,
|
|
59
|
+
imports: [RouterOutlet, ${plus('SentryExample')}],
|
|
60
|
+
template: \`
|
|
61
|
+
<div class="app">
|
|
62
|
+
<h1>Your Application</h1>
|
|
63
|
+
${plus('<app-sentry-example></app-sentry-example>')}
|
|
64
|
+
</div>
|
|
65
|
+
\`,
|
|
66
|
+
})
|
|
67
|
+
`));
|
|
68
|
+
await (0, clack_1.showCopyPasteInstructions)({
|
|
69
|
+
instructions: `Add the example component one of your pages or components (for example, in ${chalk_1.default.cyan('app.component.ts')}).`,
|
|
70
|
+
codeSnippet: addComponentCodeSnippet,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
exports.createExampleComponent = createExampleComponent;
|
|
74
|
+
function getSentryExampleComponentCode(options) {
|
|
75
|
+
const issueStreamUrl = (0, url_1.getIssueStreamUrl)(options);
|
|
76
|
+
return `import { NgIf } from '@angular/common';
|
|
77
|
+
import { Component, OnInit } from '@angular/core';
|
|
78
|
+
import * as Sentry from '@sentry/angular';
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* This is just a very simple component that throws an example error.
|
|
82
|
+
* Feel free to delete this file once you verify that Sentry is working.
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
@Component({
|
|
86
|
+
selector: 'app-sentry-example',
|
|
87
|
+
standalone: true,
|
|
88
|
+
imports: [NgIf],
|
|
89
|
+
template: \`
|
|
90
|
+
<svg height="40" width="40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
91
|
+
<path
|
|
92
|
+
d="M21.85 2.995a3.698 3.698 0 0 1 1.353 1.354l16.303 28.278a3.703 3.703 0 0 1-1.354 5.053 3.694 3.694 0 0 1-1.848.496h-3.828a31.149 31.149 0 0 0 0-3.09h3.815a.61.61 0 0 0 .537-.917L20.523 5.893a.61.61 0 0 0-1.057 0l-3.739 6.494a28.948 28.948 0 0 1 9.63 10.453 28.988 28.988 0 0 1 3.499 13.78v1.542h-9.852v-1.544a19.106 19.106 0 0 0-2.182-8.85 19.08 19.08 0 0 0-6.032-6.829l-1.85 3.208a15.377 15.377 0 0 1 6.382 12.484v1.542H3.696A3.694 3.694 0 0 1 0 34.473c0-.648.17-1.286.494-1.849l2.33-4.074a8.562 8.562 0 0 1 2.689 1.536L3.158 34.17a.611.611 0 0 0 .538.917h8.448a12.481 12.481 0 0 0-6.037-9.09l-1.344-.772 4.908-8.545 1.344.77a22.16 22.16 0 0 1 7.705 7.444 22.193 22.193 0 0 1 3.316 10.193h3.699a25.892 25.892 0 0 0-3.811-12.033 25.856 25.856 0 0 0-9.046-8.796l-1.344-.772 5.269-9.136a3.698 3.698 0 0 1 3.2-1.849c.648 0 1.285.17 1.847.495Z"
|
|
93
|
+
fill="currentcolor"
|
|
94
|
+
/>
|
|
95
|
+
</svg>
|
|
96
|
+
|
|
97
|
+
<h1>app-sentry-example</h1>
|
|
98
|
+
|
|
99
|
+
<p class="description">
|
|
100
|
+
Click the button below, and view the sample error on the Sentry
|
|
101
|
+
<a
|
|
102
|
+
target="_blank"
|
|
103
|
+
href="${issueStreamUrl}"
|
|
104
|
+
>Issues Page</a
|
|
105
|
+
>. For more details about setting up Sentry,
|
|
106
|
+
<a
|
|
107
|
+
target="_blank"
|
|
108
|
+
href="https://docs.sentry.io/platforms/javascript/guides/angular/"
|
|
109
|
+
>read our docs</a
|
|
110
|
+
>.
|
|
111
|
+
</p>
|
|
112
|
+
|
|
113
|
+
<button (click)="throwError()">
|
|
114
|
+
<span>Throw Sample Error</span>
|
|
115
|
+
</button>
|
|
116
|
+
|
|
117
|
+
<div *ngIf="isConnected && sentError" class="success">
|
|
118
|
+
Sample error was sent to Sentry.
|
|
119
|
+
</div>
|
|
120
|
+
<div *ngIf="isConnected && !sentError" class="success_placeholder"></div>
|
|
121
|
+
|
|
122
|
+
<div *ngIf="!isConnected" class="connectivity-error">
|
|
123
|
+
<p>
|
|
124
|
+
The Sentry SDK is not able to reach Sentry right now - this may be due
|
|
125
|
+
to an adblocker. For more information, see
|
|
126
|
+
<a
|
|
127
|
+
target="_blank"
|
|
128
|
+
href="https://docs.sentry.io/platforms/javascript/guides/angular/troubleshooting/#the-sdk-is-not-sending-any-data"
|
|
129
|
+
>the troubleshooting guide</a
|
|
130
|
+
>.
|
|
131
|
+
</p>
|
|
132
|
+
</div>
|
|
133
|
+
|
|
134
|
+
<p class="description">
|
|
135
|
+
Adblockers will prevent errors from being sent to Sentry.
|
|
136
|
+
</p>
|
|
137
|
+
\`,
|
|
138
|
+
styles: \`
|
|
139
|
+
:host {
|
|
140
|
+
display: flex;
|
|
141
|
+
flex-direction: column;
|
|
142
|
+
justify-content: space-between;
|
|
143
|
+
align-items: center;
|
|
144
|
+
border: 2px solid #553DB8;
|
|
145
|
+
border-radius: 8px;
|
|
146
|
+
padding: 1em;
|
|
147
|
+
margin: 0.5em;
|
|
148
|
+
width: 500px;
|
|
149
|
+
height: 495px;
|
|
150
|
+
gap: 1em;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
h1 {
|
|
154
|
+
padding: 0px 4px;
|
|
155
|
+
border-radius: 4px;
|
|
156
|
+
background-color: rgba(24, 20, 35, 0.03);
|
|
157
|
+
font-family: monospace;
|
|
158
|
+
font-size: 20px;
|
|
159
|
+
line-height: 1.2;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
p {
|
|
163
|
+
margin: 0;
|
|
164
|
+
font-size: 20px;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
a {
|
|
168
|
+
color: #6341F0;
|
|
169
|
+
text-decoration: underline;
|
|
170
|
+
cursor: pointer;
|
|
171
|
+
|
|
172
|
+
@media (prefers-color-scheme: dark) {
|
|
173
|
+
color: #B3A1FF;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
button {
|
|
178
|
+
border-radius: 8px;
|
|
179
|
+
color: white;
|
|
180
|
+
cursor: pointer;
|
|
181
|
+
background-color: #553DB8;
|
|
182
|
+
border: none;
|
|
183
|
+
padding: 0;
|
|
184
|
+
margin-top: 4px;
|
|
185
|
+
|
|
186
|
+
& > span {
|
|
187
|
+
display: inline-block;
|
|
188
|
+
padding: 12px 16px;
|
|
189
|
+
border-radius: inherit;
|
|
190
|
+
font-size: 20px;
|
|
191
|
+
font-weight: bold;
|
|
192
|
+
line-height: 1;
|
|
193
|
+
background-color: #7553FF;
|
|
194
|
+
border: 1px solid #553DB8;
|
|
195
|
+
transform: translateY(-4px);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
&:hover > span {
|
|
199
|
+
transform: translateY(-8px);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
&:active > span {
|
|
203
|
+
transform: translateY(0);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.success {
|
|
208
|
+
padding: 12px 16px;
|
|
209
|
+
border-radius: 8px;
|
|
210
|
+
font-size: 20px;
|
|
211
|
+
line-height: 1;
|
|
212
|
+
background-color: #00F261;
|
|
213
|
+
border: 1px solid #00BF4D;
|
|
214
|
+
color: #181423;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.success_placeholder {
|
|
218
|
+
height: 46px;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.description {
|
|
222
|
+
text-align: center;
|
|
223
|
+
color: #6E6C75;
|
|
224
|
+
max-width: 500px;
|
|
225
|
+
line-height: 1.5;
|
|
226
|
+
font-size: 20px;
|
|
227
|
+
|
|
228
|
+
@media (prefers-color-scheme: dark) {
|
|
229
|
+
color: #A49FB5;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.connectivity-error {
|
|
234
|
+
padding: 12px 16px;
|
|
235
|
+
background-color: #E50045;
|
|
236
|
+
border-radius: 8px;
|
|
237
|
+
width: 500px;
|
|
238
|
+
color: #FFFFFF;
|
|
239
|
+
border: 1px solid #A80033;
|
|
240
|
+
text-align: center;
|
|
241
|
+
margin: 0;
|
|
242
|
+
max-width: 400px;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.connectivity-error a {
|
|
246
|
+
color: #FFFFFF;
|
|
247
|
+
text-decoration: underline;
|
|
248
|
+
}
|
|
249
|
+
\`,
|
|
250
|
+
})
|
|
251
|
+
export class SentryExample implements OnInit {
|
|
252
|
+
sentError = false;
|
|
253
|
+
isConnected = true;
|
|
254
|
+
|
|
255
|
+
async ngOnInit(): Promise<void> {
|
|
256
|
+
const res = await Sentry.diagnoseSdkConnectivity();
|
|
257
|
+
this.isConnected = res !== 'sentry-unreachable';
|
|
258
|
+
console.log({ res });
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
throwError() {
|
|
262
|
+
Sentry.startSpan(
|
|
263
|
+
{
|
|
264
|
+
name: 'Example Frontend Span',
|
|
265
|
+
op: 'test',
|
|
266
|
+
},
|
|
267
|
+
() => {
|
|
268
|
+
this.sentError = true;
|
|
269
|
+
throw new SentryExampleError(
|
|
270
|
+
'This error was thrown by the Sentry example component.'
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
class SentryExampleError extends Error {
|
|
278
|
+
constructor(message: string | undefined) {
|
|
279
|
+
super(message);
|
|
280
|
+
this.name = 'SentryExampleError';
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
`;
|
|
284
|
+
}
|
|
285
|
+
exports.getSentryExampleComponentCode = getSentryExampleComponentCode;
|
|
286
|
+
//# sourceMappingURL=example-component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example-component.js","sourceRoot":"","sources":["../../../src/angular/example-component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,0CAIwB;AAExB,+EAA+E;AAC/E,sDAAwC;AACxC,sCAAiD;AACjD,kDAA0B;AAQnB,KAAK,UAAU,sBAAsB,CAAC,OAAgC;IAC3E,MAAM,aAAa,GAAG,gBAAgB,CAAC;IACvC,MAAM,WAAW,GAAG,WAAW,CAAC;IAEhC,IAAI,gBAAgB,GAAG,WAAW,CAAC;IACnC,MAAM,UAAU,GAAG,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC9C,IAAI,CAAC,UAAU,EAAE;QACf,gBAAgB,GAAG,MAAM,IAAA,wBAAgB,EACvC,KAAK,CAAC,IAAI,CAAC;YACT,OAAO,EAAE,+CAA+C;YACxD,WAAW,EAAE,WAAW;SACzB,CAAC,CACH,CAAC;KACH;IAED,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;QACpC,EAAE,CAAC,SAAS,CAAC,gBAAgB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;KACrD;IAED,MAAM,aAAa,GAAG,6BAA6B,CAAC,OAAO,CAAC,CAAC;IAE7D,MAAM,iBAAiB,GAAG,GAAG,gBAAgB,IAAI,aAAa,eAAe,CAAC;IAE9E,EAAE,CAAC,aAAa,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;IAEnD,KAAK,CAAC,GAAG,CAAC,OAAO,CACf,gCAAgC,eAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE,CAChE,CAAC;IAEF,MAAM,uBAAuB,GAAG,IAAA,uBAAe,EAAC,IAAI,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,CACxE,SAAS,CAAC,GAAG,IAAI,CACf,4DAA4D,CAC7D;;;;;4BAKuB,IAAI,CAAC,eAAe,CAAC;;;;QAIzC,IAAI,CAAC,2CAA2C,CAAC;;;;CAIxD,CAAC,CACC,CAAC;IAEF,MAAM,IAAA,iCAAyB,EAAC;QAC9B,YAAY,EAAE,8EAA8E,eAAK,CAAC,IAAI,CACpG,kBAAkB,CACnB,IAAI;QACL,WAAW,EAAE,uBAAuB;KACrC,CAAC,CAAC;AACL,CAAC;AAtDD,wDAsDC;AAED,SAAgB,6BAA6B,CAC3C,OAAgC;IAEhC,MAAM,cAAc,GAAG,IAAA,uBAAiB,EAAC,OAAO,CAAC,CAAC;IAElD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA2BO,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoL7B,CAAC;AACF,CAAC;AArND,sEAqNC","sourcesContent":["import * as fs from 'fs';\nimport {\n abortIfCancelled,\n makeCodeSnippet,\n showCopyPasteInstructions,\n} from '../utils/clack';\n\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport { getIssueStreamUrl } from '../utils/url';\nimport chalk from 'chalk';\n\ninterface ExampleComponentOptions {\n url: string;\n orgSlug: string;\n projectId: string;\n}\n\nexport async function createExampleComponent(options: ExampleComponentOptions) {\n const componentName = 'sentry-example';\n const appRootPath = './src/app';\n\n let componentDirPath = appRootPath;\n const hasAppRoot = fs.existsSync(appRootPath);\n if (!hasAppRoot) {\n componentDirPath = await abortIfCancelled(\n clack.text({\n message: 'Where should we create the example component?',\n placeholder: appRootPath,\n }),\n );\n }\n\n if (!fs.existsSync(componentDirPath)) {\n fs.mkdirSync(componentDirPath, { recursive: true });\n }\n\n const componentCode = getSentryExampleComponentCode(options);\n\n const componentFilePath = `${componentDirPath}/${componentName}.component.ts`;\n\n fs.writeFileSync(componentFilePath, componentCode);\n\n clack.log.success(\n `Created example component at ${chalk.cyan(componentFilePath)}`,\n );\n\n const addComponentCodeSnippet = makeCodeSnippet(true, (unchanged, plus) =>\n unchanged(`${plus(\n \"import { SentryExample } from './sentry-example.component'\",\n )}\n\n@Component({\n selector: 'app-root',\n standalone: true,\n imports: [RouterOutlet, ${plus('SentryExample')}],\n template: \\`\n <div class=\"app\">\n <h1>Your Application</h1>\n ${plus('<app-sentry-example></app-sentry-example>')}\n </div>\n \\`,\n})\n`),\n );\n\n await showCopyPasteInstructions({\n instructions: `Add the example component one of your pages or components (for example, in ${chalk.cyan(\n 'app.component.ts',\n )}).`,\n codeSnippet: addComponentCodeSnippet,\n });\n}\n\nexport function getSentryExampleComponentCode(\n options: ExampleComponentOptions,\n) {\n const issueStreamUrl = getIssueStreamUrl(options);\n\n return `import { NgIf } from '@angular/common';\nimport { Component, OnInit } from '@angular/core';\nimport * as Sentry from '@sentry/angular';\n\n/**\n * This is just a very simple component that throws an example error.\n * Feel free to delete this file once you verify that Sentry is working.\n */\n\n@Component({\n selector: 'app-sentry-example',\n standalone: true,\n imports: [NgIf],\n template: \\`\n <svg height=\"40\" width=\"40\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M21.85 2.995a3.698 3.698 0 0 1 1.353 1.354l16.303 28.278a3.703 3.703 0 0 1-1.354 5.053 3.694 3.694 0 0 1-1.848.496h-3.828a31.149 31.149 0 0 0 0-3.09h3.815a.61.61 0 0 0 .537-.917L20.523 5.893a.61.61 0 0 0-1.057 0l-3.739 6.494a28.948 28.948 0 0 1 9.63 10.453 28.988 28.988 0 0 1 3.499 13.78v1.542h-9.852v-1.544a19.106 19.106 0 0 0-2.182-8.85 19.08 19.08 0 0 0-6.032-6.829l-1.85 3.208a15.377 15.377 0 0 1 6.382 12.484v1.542H3.696A3.694 3.694 0 0 1 0 34.473c0-.648.17-1.286.494-1.849l2.33-4.074a8.562 8.562 0 0 1 2.689 1.536L3.158 34.17a.611.611 0 0 0 .538.917h8.448a12.481 12.481 0 0 0-6.037-9.09l-1.344-.772 4.908-8.545 1.344.77a22.16 22.16 0 0 1 7.705 7.444 22.193 22.193 0 0 1 3.316 10.193h3.699a25.892 25.892 0 0 0-3.811-12.033 25.856 25.856 0 0 0-9.046-8.796l-1.344-.772 5.269-9.136a3.698 3.698 0 0 1 3.2-1.849c.648 0 1.285.17 1.847.495Z\"\n fill=\"currentcolor\"\n />\n </svg>\n\n <h1>app-sentry-example</h1>\n\n <p class=\"description\">\n Click the button below, and view the sample error on the Sentry\n <a\n target=\"_blank\"\n href=\"${issueStreamUrl}\"\n >Issues Page</a\n >. For more details about setting up Sentry,\n <a\n target=\"_blank\"\n href=\"https://docs.sentry.io/platforms/javascript/guides/angular/\"\n >read our docs</a\n >.\n </p>\n\n <button (click)=\"throwError()\">\n <span>Throw Sample Error</span>\n </button>\n\n <div *ngIf=\"isConnected && sentError\" class=\"success\">\n Sample error was sent to Sentry.\n </div>\n <div *ngIf=\"isConnected && !sentError\" class=\"success_placeholder\"></div>\n\n <div *ngIf=\"!isConnected\" class=\"connectivity-error\">\n <p>\n The Sentry SDK is not able to reach Sentry right now - this may be due\n to an adblocker. For more information, see\n <a\n target=\"_blank\"\n href=\"https://docs.sentry.io/platforms/javascript/guides/angular/troubleshooting/#the-sdk-is-not-sending-any-data\"\n >the troubleshooting guide</a\n >.\n </p>\n </div>\n\n <p class=\"description\">\n Adblockers will prevent errors from being sent to Sentry.\n </p>\n \\`,\n styles: \\`\n :host {\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n align-items: center;\n border: 2px solid #553DB8;\n border-radius: 8px;\n padding: 1em;\n margin: 0.5em;\n width: 500px;\n height: 495px;\n gap: 1em;\n }\n\n h1 {\n padding: 0px 4px;\n border-radius: 4px;\n background-color: rgba(24, 20, 35, 0.03);\n font-family: monospace;\n font-size: 20px;\n line-height: 1.2;\n }\n\n p {\n margin: 0;\n font-size: 20px;\n } \n\n a {\n color: #6341F0;\n text-decoration: underline;\n cursor: pointer;\n\n @media (prefers-color-scheme: dark) {\n color: #B3A1FF;\n }\n }\n\n button {\n border-radius: 8px;\n color: white;\n cursor: pointer;\n background-color: #553DB8;\n border: none;\n padding: 0;\n margin-top: 4px;\n\n & > span {\n display: inline-block;\n padding: 12px 16px;\n border-radius: inherit;\n font-size: 20px;\n font-weight: bold;\n line-height: 1;\n background-color: #7553FF;\n border: 1px solid #553DB8;\n transform: translateY(-4px);\n }\n\n &:hover > span {\n transform: translateY(-8px);\n }\n\n &:active > span {\n transform: translateY(0);\n }\n }\n\n .success {\n padding: 12px 16px;\n border-radius: 8px;\n font-size: 20px;\n line-height: 1;\n background-color: #00F261;\n border: 1px solid #00BF4D;\n color: #181423;\n }\n\n .success_placeholder {\n height: 46px;\n }\n\n .description {\n text-align: center;\n color: #6E6C75;\n max-width: 500px;\n line-height: 1.5;\n font-size: 20px;\n\n @media (prefers-color-scheme: dark) {\n color: #A49FB5;\n }\n }\n\n .connectivity-error {\n padding: 12px 16px;\n background-color: #E50045;\n border-radius: 8px;\n width: 500px;\n color: #FFFFFF;\n border: 1px solid #A80033;\n text-align: center;\n margin: 0;\n max-width: 400px;\n }\n \n .connectivity-error a {\n color: #FFFFFF;\n text-decoration: underline;\n }\n \\`,\n})\nexport class SentryExample implements OnInit {\n sentError = false;\n isConnected = true;\n\n async ngOnInit(): Promise<void> {\n const res = await Sentry.diagnoseSdkConnectivity();\n this.isConnected = res !== 'sentry-unreachable';\n console.log({ res });\n }\n\n throwError() {\n Sentry.startSpan(\n {\n name: 'Example Frontend Span',\n op: 'test',\n },\n () => {\n this.sentError = true;\n throw new SentryExampleError(\n 'This error was thrown by the Sentry example component.'\n );\n }\n );\n }\n}\n\nclass SentryExampleError extends Error {\n constructor(message: string | undefined) {\n super(message);\n this.name = 'SentryExampleError';\n }\n}\n`;\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SemVer } from 'semver';
|
|
2
|
+
export declare function initalizeSentryOnApplicationEntry(dsn: string, selectedFeatures: {
|
|
3
|
+
performance: boolean;
|
|
4
|
+
replay: boolean;
|
|
5
|
+
}): Promise<void>;
|
|
6
|
+
export declare function updateAppConfig(angularVersion: SemVer, isTracingEnabled: boolean): Promise<void>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.updateAppConfig = exports.initalizeSentryOnApplicationEntry = void 0;
|
|
31
|
+
// @ts-expect-error - magicast is ESM and TS complains about that. It works though
|
|
32
|
+
const magicast_1 = require("magicast");
|
|
33
|
+
const fs = __importStar(require("fs"));
|
|
34
|
+
const path = __importStar(require("path"));
|
|
35
|
+
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
36
|
+
const prompts_1 = __importDefault(require("@clack/prompts"));
|
|
37
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
38
|
+
const app_config_1 = require("./codemods/app-config");
|
|
39
|
+
const main_1 = require("./codemods/main");
|
|
40
|
+
const ast_utils_1 = require("../utils/ast-utils");
|
|
41
|
+
const Sentry = __importStar(require("@sentry/node"));
|
|
42
|
+
async function initalizeSentryOnApplicationEntry(dsn, selectedFeatures) {
|
|
43
|
+
const appEntryFilename = 'main.ts';
|
|
44
|
+
const appEntryPath = path.join(process.cwd(), 'src', appEntryFilename);
|
|
45
|
+
const originalAppEntry = await (0, magicast_1.loadFile)(appEntryPath);
|
|
46
|
+
if ((0, ast_utils_1.hasSentryContent)(originalAppEntry.$ast)) {
|
|
47
|
+
prompts_1.default.log.warn(`File ${chalk_1.default.cyan(appEntryFilename)} already contains Sentry.
|
|
48
|
+
Skipping adding Sentry functionality to ${chalk_1.default.cyan(appEntryFilename)}.`);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const updatedAppEntryMod = (0, main_1.updateAppEntryMod)(originalAppEntry, dsn, selectedFeatures);
|
|
52
|
+
try {
|
|
53
|
+
await (0, magicast_1.writeFile)(updatedAppEntryMod.$ast, appEntryPath);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
prompts_1.default.log.error(`Error while adding Sentry to ${chalk_1.default.cyan(appEntryFilename)}`);
|
|
57
|
+
prompts_1.default.log.warn(`Please refer to the documentation for manual setup:
|
|
58
|
+
${chalk_1.default.underline('https://docs.sentry.io/platforms/javascript/guides/angular/#configure')}`);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
prompts_1.default.log.success(`Successfully initialized Sentry on ${chalk_1.default.cyan(appEntryFilename)}`);
|
|
62
|
+
}
|
|
63
|
+
exports.initalizeSentryOnApplicationEntry = initalizeSentryOnApplicationEntry;
|
|
64
|
+
async function updateAppConfig(angularVersion, isTracingEnabled) {
|
|
65
|
+
const appConfigFilename = 'app.config.ts';
|
|
66
|
+
const appConfigPath = path.join(process.cwd(), 'src', 'app', appConfigFilename);
|
|
67
|
+
if (!fs.existsSync(appConfigPath)) {
|
|
68
|
+
Sentry.setTag('angular-app-config-found', false);
|
|
69
|
+
prompts_1.default.log.warn(`File ${chalk_1.default.cyan(appConfigFilename)} not found. Skipping adding Sentry functionality.`);
|
|
70
|
+
prompts_1.default.log.warn(`Please refer to the documentation for manual setup:
|
|
71
|
+
${chalk_1.default.underline('https://docs.sentry.io/platforms/javascript/guides/angular/#configure')}`);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
Sentry.setTag('angular-app-config-found', true);
|
|
75
|
+
const appConfig = await (0, magicast_1.loadFile)(appConfigPath);
|
|
76
|
+
if ((0, ast_utils_1.hasSentryContent)(appConfig.$ast)) {
|
|
77
|
+
prompts_1.default.log.warn(`File ${chalk_1.default.cyan(appConfigFilename)} already contains Sentry.
|
|
78
|
+
Skipping adding Sentry functionality to ${chalk_1.default.cyan(appConfigFilename)}.`);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
const updatedAppConfigMod = (0, app_config_1.updateAppConfigMod)(appConfig, angularVersion, isTracingEnabled);
|
|
83
|
+
await (0, magicast_1.writeFile)(updatedAppConfigMod.$ast, appConfigPath);
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
prompts_1.default.log.error(`Error while updating your app config ${chalk_1.default.cyan(appConfigFilename)}.`);
|
|
87
|
+
prompts_1.default.log.info(chalk_1.default.dim(typeof error === 'object' && error != null && 'toString' in error
|
|
88
|
+
? error.toString()
|
|
89
|
+
: typeof error === 'string'
|
|
90
|
+
? error
|
|
91
|
+
: ''));
|
|
92
|
+
prompts_1.default.log.warn(`Please refer to the documentation for manual setup:
|
|
93
|
+
${chalk_1.default.underline('https://docs.sentry.io/platforms/javascript/guides/angular/#configure')}`);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
prompts_1.default.log.success(`Successfully updated your app config ${chalk_1.default.cyan(appConfigFilename)}`);
|
|
97
|
+
}
|
|
98
|
+
exports.updateAppConfig = updateAppConfig;
|
|
99
|
+
//# sourceMappingURL=sdk-setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-setup.js","sourceRoot":"","sources":["../../../src/angular/sdk-setup.ts"],"names":[],"mappings":";AAAA,4DAA4D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE5D,kFAAkF;AAClF,uCAA+C;AAE/C,uCAAyB;AACzB,2CAA6B;AAE7B,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAC1B,sDAA2D;AAC3D,0CAAoD;AACpD,kDAAsD;AACtD,qDAAuC;AAKhC,KAAK,UAAU,iCAAiC,CACrD,GAAW,EACX,gBAGC;IAED,MAAM,gBAAgB,GAAG,SAAS,CAAC;IACnC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC;IAEvE,MAAM,gBAAgB,GAAG,MAAM,IAAA,mBAAQ,EAAC,YAAY,CAAC,CAAC;IAEtD,IAAI,IAAA,4BAAgB,EAAC,gBAAgB,CAAC,IAAiB,CAAC,EAAE;QACxD,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,QAAQ,eAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC;0CACA,eAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,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S complains about that. It works though\nimport { loadFile, writeFile } from 'magicast';\n\nimport * as fs from 'fs';\nimport * as path from 'path';\n\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport { updateAppConfigMod } from './codemods/app-config';\nimport { updateAppEntryMod } from './codemods/main';\nimport { hasSentryContent } from '../utils/ast-utils';\nimport * as Sentry from '@sentry/node';\n\nimport type { namedTypes as t } from 'ast-types';\nimport type { SemVer } from 'semver';\n\nexport async function initalizeSentryOnApplicationEntry(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n): Promise<void> {\n const appEntryFilename = 'main.ts';\n const appEntryPath = path.join(process.cwd(), 'src', appEntryFilename);\n\n const originalAppEntry = await loadFile(appEntryPath);\n\n if (hasSentryContent(originalAppEntry.$ast as t.Program)) {\n clack.log.warn(\n `File ${chalk.cyan(appEntryFilename)} already contains Sentry.\nSkipping adding Sentry functionality to ${chalk.cyan(appEntryFilename)}.`,\n );\n\n return;\n }\n\n const updatedAppEntryMod = updateAppEntryMod(\n originalAppEntry,\n dsn,\n selectedFeatures,\n );\n\n try {\n await writeFile(updatedAppEntryMod.$ast, appEntryPath);\n } catch (error: unknown) {\n clack.log.error(\n `Error while adding Sentry to ${chalk.cyan(appEntryFilename)}`,\n );\n\n clack.log.warn(\n `Please refer to the documentation for manual setup:\n${chalk.underline(\n 'https://docs.sentry.io/platforms/javascript/guides/angular/#configure',\n)}`,\n );\n\n return;\n }\n\n clack.log.success(\n `Successfully initialized Sentry on ${chalk.cyan(appEntryFilename)}`,\n );\n}\n\nexport async function updateAppConfig(\n angularVersion: SemVer,\n isTracingEnabled: boolean,\n): Promise<void> {\n const appConfigFilename = 'app.config.ts';\n const appConfigPath = path.join(\n process.cwd(),\n 'src',\n 'app',\n appConfigFilename,\n );\n\n if (!fs.existsSync(appConfigPath)) {\n Sentry.setTag('angular-app-config-found', false);\n\n clack.log.warn(\n `File ${chalk.cyan(\n appConfigFilename,\n )} not found. Skipping adding Sentry functionality.`,\n );\n\n clack.log.warn(`Please refer to the documentation for manual setup:\n${chalk.underline(\n 'https://docs.sentry.io/platforms/javascript/guides/angular/#configure',\n)}`);\n\n return;\n }\n\n Sentry.setTag('angular-app-config-found', true);\n\n const appConfig = await loadFile(appConfigPath);\n\n if (hasSentryContent(appConfig.$ast as t.Program)) {\n clack.log.warn(\n `File ${chalk.cyan(appConfigFilename)} already contains Sentry.\n Skipping adding Sentry functionality to ${chalk.cyan(appConfigFilename)}.`,\n );\n\n return;\n }\n\n try {\n const updatedAppConfigMod = updateAppConfigMod(\n appConfig,\n angularVersion,\n isTracingEnabled,\n );\n\n await writeFile(updatedAppConfigMod.$ast, appConfigPath);\n } catch (error: unknown) {\n clack.log.error(\n `Error while updating your app config ${chalk.cyan(appConfigFilename)}.`,\n );\n\n clack.log.info(\n chalk.dim(\n typeof error === 'object' && error != null && 'toString' in error\n ? error.toString()\n : typeof error === 'string'\n ? error\n : '',\n ),\n );\n\n clack.log.warn(`Please refer to the documentation for manual setup:\n${chalk.underline(\n 'https://docs.sentry.io/platforms/javascript/guides/angular/#configure',\n)}`);\n\n return;\n }\n\n clack.log.success(\n `Successfully updated your app config ${chalk.cyan(appConfigFilename)}`,\n );\n}\n"]}
|
|
@@ -72,7 +72,11 @@ async function runFlutterWizardWithTelemetry(options) {
|
|
|
72
72
|
const pubspecPatched = (0, telemetry_1.traceStep)('Patch pubspec.yaml', () => codetools.patchPubspec(pubspecFile, flutterVersionOrAny, pluginVersionOrAny, selectedProject.slug, selectedProject.organization.slug));
|
|
73
73
|
if (!pubspecPatched) {
|
|
74
74
|
clack.log.warn(`Could not patch ${chalk_1.default.cyan('pubspec.yaml')}. Add the dependencies to it.`);
|
|
75
|
-
await (0, clack_1.showCopyPasteInstructions)(
|
|
75
|
+
await (0, clack_1.showCopyPasteInstructions)({
|
|
76
|
+
filename: 'pubspec.yaml',
|
|
77
|
+
codeSnippet: (0, templates_1.pubspecSnippetColored)(flutterVersionOrAny, pluginVersionOrAny, selectedProject.slug, selectedProject.organization.slug),
|
|
78
|
+
hint: 'This ensures the Sentry SDK and plugin can be imported.',
|
|
79
|
+
});
|
|
76
80
|
}
|
|
77
81
|
Sentry.setTag('pubspec-patched', pubspecPatched);
|
|
78
82
|
// ======== STEP 2. Add sentry.properties with auth token ============
|
|
@@ -94,7 +98,11 @@ Set the ${chalk_1.default.cyan('SENTRY_AUTH_TOKEN')} environment variable in you
|
|
|
94
98
|
const mainPatched = await (0, telemetry_1.traceStep)('Patch main.dart', () => codetools.patchMain(mainFile, dsn, canEnableProfiling));
|
|
95
99
|
if (!mainPatched) {
|
|
96
100
|
clack.log.warn(`Could not patch ${chalk_1.default.cyan('main.dart')} file. Place the following code snippet within the apps main function.`);
|
|
97
|
-
await (0, clack_1.showCopyPasteInstructions)(
|
|
101
|
+
await (0, clack_1.showCopyPasteInstructions)({
|
|
102
|
+
filename: 'main.dart',
|
|
103
|
+
codeSnippet: (0, templates_1.initSnippetColored)(dsn),
|
|
104
|
+
hint: 'This ensures the Sentry SDK is ready to capture errors.',
|
|
105
|
+
});
|
|
98
106
|
}
|
|
99
107
|
Sentry.setTag('main-patched', mainPatched);
|
|
100
108
|
// ======== OUTRO ========
|
|
@@ -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;AACxE,+EAA+E;AAC/E,sDAAwC;AACxC,kDAA0B;AAE1B,0CAKwB;AAExB,4CAAwD;AACxD,6CAAwC;AAEjC,KAAK,UAAU,gBAAgB,CAAC,OAAsB;IAC3D,OAAO,IAAA,yBAAa,EAClB;QACE,OAAO,EAAE,OAAO,CAAC,gBAAgB;QACjC,WAAW,EAAE,SAAS;QACtB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gD,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 'pubspec.yaml',\n pubspecSnippetColored(\n flutterVersionOrAny,\n pluginVersionOrAny,\n selectedProject.slug,\n selectedProject.organization.slug,\n ),\n '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 'main.dart',\n initSnippetColored(dsn),\n '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":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YAC9B,QAAQ,EAAE,WAAW;YACrB,WAAW,EAAE,IAAA,8BAAkB,EAAC,GAAG,CAAC;YACpC,IAAI,EAAE,yDAAyD;SAChE,CAAC,CAAC;KACJ;IACD,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,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"]}
|