@sentry/wizard 3.38.0 → 3.40.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 +10 -1
- package/README.md +3 -3
- package/dist/e2e-tests/tests/flutter.test.d.ts +1 -0
- package/dist/e2e-tests/tests/flutter.test.js +190 -0
- package/dist/e2e-tests/tests/flutter.test.js.map +1 -0
- package/dist/e2e-tests/tests/nextjs.test.js +1 -1
- package/dist/e2e-tests/tests/nextjs.test.js.map +1 -1
- package/dist/e2e-tests/tests/nuxt-3.test.js +1 -1
- package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -1
- package/dist/e2e-tests/tests/nuxt-4.test.js +1 -1
- package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -1
- package/dist/e2e-tests/tests/remix.test.js +1 -2
- package/dist/e2e-tests/tests/remix.test.js.map +1 -1
- package/dist/e2e-tests/tests/sveltekit.test.js +17 -5
- package/dist/e2e-tests/tests/sveltekit.test.js.map +1 -1
- package/dist/e2e-tests/utils/index.d.ts +22 -1
- package/dist/e2e-tests/utils/index.js +58 -3
- package/dist/e2e-tests/utils/index.js.map +1 -1
- package/dist/lib/Constants.d.ts +1 -0
- package/dist/lib/Constants.js +5 -0
- package/dist/lib/Constants.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/src/apple/apple-wizard.js +1 -1
- package/dist/src/apple/apple-wizard.js.map +1 -1
- package/dist/src/apple/xcode-manager.d.ts +4 -4
- package/dist/src/apple/xcode-manager.js.map +1 -1
- package/dist/src/flutter/code-tools.d.ts +17 -0
- package/dist/src/flutter/code-tools.js +263 -0
- package/dist/src/flutter/code-tools.js.map +1 -0
- package/dist/src/flutter/flutter-wizard.d.ts +2 -0
- package/dist/src/flutter/flutter-wizard.js +171 -0
- package/dist/src/flutter/flutter-wizard.js.map +1 -0
- package/dist/src/flutter/templates.d.ts +9 -0
- package/dist/src/flutter/templates.js +40 -0
- package/dist/src/flutter/templates.js.map +1 -0
- package/dist/src/nextjs/nextjs-wizard.js +3 -1
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/run.d.ts +1 -1
- package/dist/src/run.js +39 -32
- package/dist/src/run.js.map +1 -1
- package/dist/src/sourcemaps/sourcemaps-wizard.js +2 -3
- package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
- package/dist/src/telemetry.d.ts +2 -1
- package/dist/src/telemetry.js +1 -1
- package/dist/src/telemetry.js.map +1 -1
- package/dist/src/utils/clack-utils.d.ts +1 -1
- package/dist/src/utils/clack-utils.js +3 -3
- package/dist/src/utils/clack-utils.js.map +1 -1
- package/dist/src/utils/package-manager.d.ts +0 -1
- package/dist/src/utils/package-manager.js +9 -10
- package/dist/src/utils/package-manager.js.map +1 -1
- package/dist/test/flutter/code-tools.test.d.ts +1 -0
- package/dist/test/flutter/code-tools.test.js +84 -0
- package/dist/test/flutter/code-tools.test.js.map +1 -0
- package/dist/test/flutter/templates.test.d.ts +1 -0
- package/dist/test/flutter/templates.test.js +41 -0
- package/dist/test/flutter/templates.test.js.map +1 -0
- package/e2e-tests/README.md +5 -1
- package/e2e-tests/test-applications/flutter-test-app/.metadata +45 -0
- package/e2e-tests/test-applications/flutter-test-app/README.md +16 -0
- package/e2e-tests/test-applications/flutter-test-app/analysis_options.yaml +28 -0
- package/e2e-tests/test-applications/flutter-test-app/android/app/build.gradle +44 -0
- package/e2e-tests/test-applications/flutter-test-app/android/app/src/debug/AndroidManifest.xml +7 -0
- package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/AndroidManifest.xml +45 -0
- package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/kotlin/com/example/flutter_magic/MainActivity.kt +5 -0
- package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/res/drawable/launch_background.xml +12 -0
- package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/res/drawable-v21/launch_background.xml +12 -0
- package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/res/values/styles.xml +18 -0
- package/e2e-tests/test-applications/flutter-test-app/android/app/src/main/res/values-night/styles.xml +18 -0
- package/e2e-tests/test-applications/flutter-test-app/android/app/src/profile/AndroidManifest.xml +7 -0
- package/e2e-tests/test-applications/flutter-test-app/android/build.gradle +18 -0
- package/e2e-tests/test-applications/flutter-test-app/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/e2e-tests/test-applications/flutter-test-app/android/gradle.properties +3 -0
- package/e2e-tests/test-applications/flutter-test-app/android/settings.gradle +25 -0
- package/e2e-tests/test-applications/flutter-test-app/lib/main.dart +125 -0
- package/e2e-tests/test-applications/flutter-test-app/linux/CMakeLists.txt +145 -0
- package/e2e-tests/test-applications/flutter-test-app/linux/flutter/CMakeLists.txt +88 -0
- package/e2e-tests/test-applications/flutter-test-app/linux/flutter/generated_plugin_registrant.cc +11 -0
- package/e2e-tests/test-applications/flutter-test-app/linux/flutter/generated_plugin_registrant.h +15 -0
- package/e2e-tests/test-applications/flutter-test-app/linux/flutter/generated_plugins.cmake +23 -0
- package/e2e-tests/test-applications/flutter-test-app/linux/main.cc +6 -0
- package/e2e-tests/test-applications/flutter-test-app/linux/my_application.cc +124 -0
- package/e2e-tests/test-applications/flutter-test-app/linux/my_application.h +18 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Flutter/Flutter-Debug.xcconfig +2 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Flutter/Flutter-Release.xcconfig +2 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Flutter/GeneratedPluginRegistrant.swift +10 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Podfile +43 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/AppDelegate.swift +9 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +68 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Base.lproj/MainMenu.xib +343 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Configs/AppInfo.xcconfig +14 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Configs/Debug.xcconfig +2 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Configs/Release.xcconfig +2 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Configs/Warnings.xcconfig +13 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/DebugProfile.entitlements +12 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Info.plist +32 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/MainFlutterWindow.swift +15 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner/Release.entitlements +8 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner.xcodeproj/project.pbxproj +705 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +98 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner.xcworkspace/contents.xcworkspacedata +7 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/e2e-tests/test-applications/flutter-test-app/macos/RunnerTests/RunnerTests.swift +12 -0
- package/e2e-tests/test-applications/flutter-test-app/pubspec.lock +213 -0
- package/e2e-tests/test-applications/flutter-test-app/pubspec.yaml +89 -0
- package/e2e-tests/test-applications/flutter-test-app/test/widget_test.dart +30 -0
- package/e2e-tests/test-applications/flutter-test-app/web/favicon.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/web/icons/Icon-192.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/web/icons/Icon-512.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/web/icons/Icon-maskable-192.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/web/icons/Icon-maskable-512.png +0 -0
- package/e2e-tests/test-applications/flutter-test-app/web/index.html +38 -0
- package/e2e-tests/test-applications/flutter-test-app/web/manifest.json +35 -0
- package/e2e-tests/test-applications/flutter-test-app/windows/CMakeLists.txt +108 -0
- package/e2e-tests/test-applications/flutter-test-app/windows/flutter/CMakeLists.txt +109 -0
- package/e2e-tests/test-applications/flutter-test-app/windows/flutter/generated_plugin_registrant.cc +11 -0
- package/e2e-tests/test-applications/flutter-test-app/windows/flutter/generated_plugin_registrant.h +15 -0
- package/e2e-tests/test-applications/flutter-test-app/windows/flutter/generated_plugins.cmake +23 -0
- package/e2e-tests/test-applications/flutter-test-app/windows/runner/CMakeLists.txt +40 -0
- package/e2e-tests/test-applications/flutter-test-app/windows/runner/Runner.rc +121 -0
- package/e2e-tests/test-applications/flutter-test-app/windows/runner/flutter_window.cpp +71 -0
- package/e2e-tests/test-applications/flutter-test-app/windows/runner/flutter_window.h +33 -0
- package/e2e-tests/test-applications/flutter-test-app/windows/runner/main.cpp +43 -0
- package/e2e-tests/test-applications/flutter-test-app/windows/runner/resource.h +16 -0
- package/e2e-tests/test-applications/flutter-test-app/windows/runner/resources/app_icon.ico +0 -0
- package/e2e-tests/test-applications/flutter-test-app/windows/runner/runner.exe.manifest +14 -0
- package/e2e-tests/test-applications/flutter-test-app/windows/runner/utils.cpp +65 -0
- package/e2e-tests/test-applications/flutter-test-app/windows/runner/utils.h +19 -0
- package/e2e-tests/test-applications/flutter-test-app/windows/runner/win32_window.cpp +288 -0
- package/e2e-tests/test-applications/flutter-test-app/windows/runner/win32_window.h +102 -0
- package/e2e-tests/test-applications/nextjs-test-app/package.json +1 -1
- package/e2e-tests/tests/flutter.test.ts +127 -0
- package/e2e-tests/tests/nextjs.test.ts +1 -1
- package/e2e-tests/tests/nuxt-3.test.ts +1 -1
- package/e2e-tests/tests/nuxt-4.test.ts +1 -1
- package/e2e-tests/tests/remix.test.ts +30 -19
- package/e2e-tests/tests/sveltekit.test.ts +79 -50
- package/e2e-tests/utils/index.ts +62 -2
- package/lib/Constants.ts +5 -0
- package/package.json +1 -1
- package/src/apple/apple-wizard.ts +1 -1
- package/src/apple/xcode-manager.ts +5 -5
- package/src/flutter/code-tools.ts +284 -0
- package/src/flutter/flutter-wizard.ts +164 -0
- package/src/flutter/templates.ts +90 -0
- package/src/nextjs/nextjs-wizard.ts +4 -1
- package/src/run.ts +7 -0
- package/src/sourcemaps/sourcemaps-wizard.ts +3 -7
- package/src/telemetry.ts +6 -2
- package/src/utils/clack-utils.ts +8 -5
- package/src/utils/package-manager.ts +8 -11
- package/test/flutter/code-tools.test.ts +212 -0
- package/test/flutter/templates.test.ts +100 -0
|
@@ -0,0 +1,263 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
+
function step(op) {
|
|
39
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
41
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
42
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
+
switch (op[0]) {
|
|
44
|
+
case 0: case 1: t = op; break;
|
|
45
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
+
default:
|
|
49
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
+
if (t[2]) _.ops.pop();
|
|
54
|
+
_.trys.pop(); continue;
|
|
55
|
+
}
|
|
56
|
+
op = body.call(thisArg, _);
|
|
57
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
62
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
63
|
+
};
|
|
64
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
|
+
exports.getDevDependenciesLocation = exports.getDependenciesLocation = exports.getLastImportLineLocation = exports.patchMainContent = exports.patchMain = exports.addProperties = exports.patchPubspec = exports.findFile = void 0;
|
|
66
|
+
var fs = __importStar(require("fs"));
|
|
67
|
+
var path = __importStar(require("path"));
|
|
68
|
+
var Sentry = __importStar(require("@sentry/node"));
|
|
69
|
+
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
70
|
+
var clack = __importStar(require("@clack/prompts"));
|
|
71
|
+
var chalk_1 = __importDefault(require("chalk"));
|
|
72
|
+
var templates_1 = require("./templates");
|
|
73
|
+
var clack_utils_1 = require("../utils/clack-utils");
|
|
74
|
+
/**
|
|
75
|
+
* Recursively finds a file per name in subfolders.
|
|
76
|
+
* @param dir - The directory to start searching.
|
|
77
|
+
* @param name - The name of the file including path extension.
|
|
78
|
+
* @returns The path to the main.dart file or null if not found.
|
|
79
|
+
*/
|
|
80
|
+
function findFile(dir, name) {
|
|
81
|
+
var files = fs.readdirSync(dir);
|
|
82
|
+
for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
|
|
83
|
+
var file = files_1[_i];
|
|
84
|
+
var fullPath = path.join(dir, file);
|
|
85
|
+
var stats = fs.statSync(fullPath);
|
|
86
|
+
if (stats.isDirectory()) {
|
|
87
|
+
var result = findFile(fullPath, name);
|
|
88
|
+
if (result) {
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else if (file === name) {
|
|
93
|
+
return fullPath;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
exports.findFile = findFile;
|
|
99
|
+
function patchPubspec(pubspecFile, sentryDartFlutterVersion, sentryDartPluginVersion, project, org) {
|
|
100
|
+
try {
|
|
101
|
+
if (!pubspecFile) {
|
|
102
|
+
throw new Error('pubspec.yaml is not provided or invalid.');
|
|
103
|
+
}
|
|
104
|
+
var pubspecContent = fs.readFileSync(pubspecFile, 'utf8');
|
|
105
|
+
if (!pubspecContent.includes('sentry_flutter:')) {
|
|
106
|
+
var dependenciesIndex = getDependenciesLocation(pubspecContent);
|
|
107
|
+
pubspecContent =
|
|
108
|
+
pubspecContent.slice(0, dependenciesIndex) +
|
|
109
|
+
" sentry_flutter: ".concat(sentryDartFlutterVersion, "\n") +
|
|
110
|
+
pubspecContent.slice(dependenciesIndex);
|
|
111
|
+
clack.log.success(chalk_1.default.greenBright("".concat(chalk_1.default.bold('sentry_flutter'), " added to pubspec.yaml")));
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
clack.log.success(chalk_1.default.greenBright("".concat(chalk_1.default.bold('sentry_flutter'), " is already included in pubspec.yaml")));
|
|
115
|
+
}
|
|
116
|
+
if (!pubspecContent.includes('sentry_dart_plugin:')) {
|
|
117
|
+
var devDependenciesIndex = getDevDependenciesLocation(pubspecContent);
|
|
118
|
+
pubspecContent =
|
|
119
|
+
pubspecContent.slice(0, devDependenciesIndex) +
|
|
120
|
+
" sentry_dart_plugin: ".concat(sentryDartPluginVersion, "\n") +
|
|
121
|
+
pubspecContent.slice(devDependenciesIndex);
|
|
122
|
+
clack.log.success(chalk_1.default.greenBright("".concat(chalk_1.default.bold('sentry_dart_plugin'), " added to pubspec.yaml")));
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
clack.log.success(chalk_1.default.greenBright("".concat(chalk_1.default.bold('sentry_dart_plugin'), " is already included in pubspec.yaml")));
|
|
126
|
+
}
|
|
127
|
+
if (!pubspecContent.includes('sentry:')) {
|
|
128
|
+
pubspecContent += '\n';
|
|
129
|
+
pubspecContent += (0, templates_1.pubspecOptions)(project, org);
|
|
130
|
+
clack.log.success(chalk_1.default.greenBright("".concat(chalk_1.default.bold('sentry plugin configuration'), " added to pubspec.yaml")));
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
clack.log.success(chalk_1.default.greenBright("".concat(chalk_1.default.bold('sentry plugin configuration'), " is already included in pubspec.yaml")));
|
|
134
|
+
}
|
|
135
|
+
fs.writeFileSync(pubspecFile, pubspecContent, 'utf8');
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
clack.log.warn("Failed to read/write ".concat(chalk_1.default.cyan('pubspec.yaml'), " file."));
|
|
140
|
+
Sentry.captureException(error);
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.patchPubspec = patchPubspec;
|
|
145
|
+
function addProperties(pubspecFile, authToken) {
|
|
146
|
+
try {
|
|
147
|
+
if (!pubspecFile) {
|
|
148
|
+
throw new Error('pubspec.yaml is not provided or invalid.');
|
|
149
|
+
}
|
|
150
|
+
var pubspecDir = path.dirname(pubspecFile);
|
|
151
|
+
var sentryPropertiesFileName = 'sentry.properties';
|
|
152
|
+
var sentryPropertiesFile = path.join(pubspecDir, sentryPropertiesFileName);
|
|
153
|
+
var sentryPropertiesContent = (0, templates_1.sentryProperties)(authToken);
|
|
154
|
+
fs.writeFileSync(sentryPropertiesFile, sentryPropertiesContent, 'utf8');
|
|
155
|
+
var gitignoreFile = path.join(pubspecDir, '.gitignore');
|
|
156
|
+
if (fs.existsSync(gitignoreFile)) {
|
|
157
|
+
fs.appendFileSync(gitignoreFile, "\n".concat(sentryPropertiesFileName, "\n"));
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
fs.writeFileSync(gitignoreFile, "".concat(sentryPropertiesFileName, "\n"), 'utf8');
|
|
161
|
+
}
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
clack.log.warn("Failed to read/write ".concat(chalk_1.default.cyan('pubspec.yaml'), " file."));
|
|
166
|
+
Sentry.captureException(error);
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
exports.addProperties = addProperties;
|
|
171
|
+
function patchMain(mainFile, dsn, canEnableProfiling) {
|
|
172
|
+
var _a, _b;
|
|
173
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
174
|
+
var mainContent, features, selectedFeatures, normalizedSelectedFeatures, error_1;
|
|
175
|
+
return __generator(this, function (_c) {
|
|
176
|
+
switch (_c.label) {
|
|
177
|
+
case 0:
|
|
178
|
+
_c.trys.push([0, 2, , 3]);
|
|
179
|
+
if (!mainFile) {
|
|
180
|
+
throw new Error('pubspec.yaml is not provided or invalid.');
|
|
181
|
+
}
|
|
182
|
+
mainContent = fs.readFileSync(mainFile, 'utf8');
|
|
183
|
+
if (/import\s+['"]package[:]sentry_flutter\/sentry_flutter\.dart['"];?/i.test(mainContent)) {
|
|
184
|
+
// sentry is already configured
|
|
185
|
+
clack.log.success(chalk_1.default.greenBright("".concat(chalk_1.default.bold('main.dart'), " already has Sentry configured.")));
|
|
186
|
+
return [2 /*return*/, true];
|
|
187
|
+
}
|
|
188
|
+
features = [
|
|
189
|
+
{
|
|
190
|
+
id: 'tracing',
|
|
191
|
+
prompt: "Do you want to enable ".concat(chalk_1.default.bold('Tracing'), " to track the performance of your application?"),
|
|
192
|
+
enabledHint: 'recommended',
|
|
193
|
+
},
|
|
194
|
+
];
|
|
195
|
+
if (canEnableProfiling) {
|
|
196
|
+
features.push({
|
|
197
|
+
id: 'profiling',
|
|
198
|
+
prompt: "Do you want to enable ".concat(chalk_1.default.bold('Profiling'), " to analyze CPU usage and optimize performance-critical code on iOS & macOS?"),
|
|
199
|
+
enabledHint: 'recommended, tracing must be enabled',
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
return [4 /*yield*/, (0, clack_utils_1.featureSelectionPrompt)(features)];
|
|
203
|
+
case 1:
|
|
204
|
+
selectedFeatures = _c.sent();
|
|
205
|
+
normalizedSelectedFeatures = {
|
|
206
|
+
tracing: (_a = selectedFeatures.tracing) !== null && _a !== void 0 ? _a : false,
|
|
207
|
+
profiling: (_b = selectedFeatures.profiling) !== null && _b !== void 0 ? _b : false,
|
|
208
|
+
};
|
|
209
|
+
mainContent = patchMainContent(dsn, mainContent, normalizedSelectedFeatures);
|
|
210
|
+
fs.writeFileSync(mainFile, mainContent, 'utf8');
|
|
211
|
+
clack.log.success(chalk_1.default.greenBright("Patched ".concat(chalk_1.default.bold('main.dart'), " with the Sentry setup and test error snippet.")));
|
|
212
|
+
return [2 /*return*/, true];
|
|
213
|
+
case 2:
|
|
214
|
+
error_1 = _c.sent();
|
|
215
|
+
clack.log.warn("Failed to read/write ".concat(chalk_1.default.cyan('main.dart'), " file."));
|
|
216
|
+
Sentry.captureException(error_1);
|
|
217
|
+
return [2 /*return*/, false];
|
|
218
|
+
case 3: return [2 /*return*/];
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
exports.patchMain = patchMain;
|
|
224
|
+
function patchMainContent(dsn, mainContent, selectedFeatures) {
|
|
225
|
+
var importIndex = getLastImportLineLocation(mainContent);
|
|
226
|
+
mainContent =
|
|
227
|
+
mainContent.slice(0, importIndex) +
|
|
228
|
+
templates_1.sentryImport +
|
|
229
|
+
mainContent.slice(importIndex);
|
|
230
|
+
// Find and replace `runApp(...)`
|
|
231
|
+
mainContent = mainContent.replace(/runApp\(([\s\S]*?)\);/g, // Match the `runApp(...)` invocation
|
|
232
|
+
function (_, runAppArgs) { return (0, templates_1.initSnippet)(dsn, selectedFeatures, runAppArgs); });
|
|
233
|
+
// Make the `main` function async if it's not already
|
|
234
|
+
mainContent = mainContent.replace(/void\s+main\(\)\s*\{/g, 'Future<void> main() async {');
|
|
235
|
+
return mainContent;
|
|
236
|
+
}
|
|
237
|
+
exports.patchMainContent = patchMainContent;
|
|
238
|
+
function getLastImportLineLocation(sourceCode) {
|
|
239
|
+
var importRegex = /import\s+['"].*['"].*;/gim;
|
|
240
|
+
return getLastReqExpLocation(sourceCode, importRegex);
|
|
241
|
+
}
|
|
242
|
+
exports.getLastImportLineLocation = getLastImportLineLocation;
|
|
243
|
+
function getDependenciesLocation(sourceCode) {
|
|
244
|
+
var dependencyRegex = /^dependencies:\s*$/gim;
|
|
245
|
+
return getLastReqExpLocation(sourceCode, dependencyRegex);
|
|
246
|
+
}
|
|
247
|
+
exports.getDependenciesLocation = getDependenciesLocation;
|
|
248
|
+
function getDevDependenciesLocation(sourceCode) {
|
|
249
|
+
var dependencyRegex = /^dev_dependencies:\s*$/gim;
|
|
250
|
+
return getLastReqExpLocation(sourceCode, dependencyRegex);
|
|
251
|
+
}
|
|
252
|
+
exports.getDevDependenciesLocation = getDevDependenciesLocation;
|
|
253
|
+
// Helper
|
|
254
|
+
function getLastReqExpLocation(sourceCode, regExp) {
|
|
255
|
+
var match = regExp.exec(sourceCode);
|
|
256
|
+
var importIndex = 0;
|
|
257
|
+
while (match) {
|
|
258
|
+
importIndex = match.index + match[0].length + 1;
|
|
259
|
+
match = regExp.exec(sourceCode);
|
|
260
|
+
}
|
|
261
|
+
return importIndex;
|
|
262
|
+
}
|
|
263
|
+
//# sourceMappingURL=code-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-tools.js","sourceRoot":"","sources":["../../../src/flutter/code-tools.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AACzB,yCAA6B;AAC7B,mDAAuC;AACvC,yEAAyE;AACzE,oDAAwC;AACxC,gDAA0B;AAC1B,yCAKqB;AACrB,oDAA8D;AAE9D;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,GAAW,EAAE,IAAY;IAChD,IAAM,KAAK,GAAa,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAE5C,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BAAuB,CAAC;IAChD,OAAO,qBAAqB,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;AAC5D,CAAC;AAHD,0DAGC;AAED,SAAgB,0BAA0B,CAAC,UAAkB;IAC3D,IAAM,eAAe,GAAG,2BAA2B,CAAC;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-ignore - 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} from './templates';\nimport { featureSelectionPrompt } from '../utils/clack-utils';\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\n const selectedFeatures = await featureSelectionPrompt(features);\n const normalizedSelectedFeatures = {\n tracing: selectedFeatures.tracing ?? false,\n profiling: selectedFeatures.profiling ?? false,\n };\n mainContent = patchMainContent(\n dsn,\n mainContent,\n normalizedSelectedFeatures,\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 },\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"]}
|
|
@@ -0,0 +1,171 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
+
function step(op) {
|
|
39
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
41
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
42
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
+
switch (op[0]) {
|
|
44
|
+
case 0: case 1: t = op; break;
|
|
45
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
+
default:
|
|
49
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
+
if (t[2]) _.ops.pop();
|
|
54
|
+
_.trys.pop(); continue;
|
|
55
|
+
}
|
|
56
|
+
op = body.call(thisArg, _);
|
|
57
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
62
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
63
|
+
};
|
|
64
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
|
+
exports.runFlutterWizard = void 0;
|
|
66
|
+
var Sentry = __importStar(require("@sentry/node"));
|
|
67
|
+
var codetools = __importStar(require("./code-tools"));
|
|
68
|
+
var fs = __importStar(require("fs"));
|
|
69
|
+
var path = __importStar(require("path"));
|
|
70
|
+
var clack_utils_1 = require("../utils/clack-utils");
|
|
71
|
+
var templates_1 = require("./templates");
|
|
72
|
+
var release_registry_1 = require("../utils/release-registry");
|
|
73
|
+
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
74
|
+
var clack = __importStar(require("@clack/prompts"));
|
|
75
|
+
var chalk_1 = __importDefault(require("chalk"));
|
|
76
|
+
var clack_utils_2 = require("../utils/clack-utils");
|
|
77
|
+
var telemetry_1 = require("../telemetry");
|
|
78
|
+
var code_tools_1 = require("./code-tools");
|
|
79
|
+
function runFlutterWizard(options) {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
81
|
+
return __generator(this, function (_a) {
|
|
82
|
+
return [2 /*return*/, (0, telemetry_1.withTelemetry)({
|
|
83
|
+
enabled: options.telemetryEnabled,
|
|
84
|
+
integration: 'flutter',
|
|
85
|
+
wizardOptions: options,
|
|
86
|
+
}, function () { return runFlutterWizardWithTelemetry(options); })];
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
exports.runFlutterWizard = runFlutterWizard;
|
|
91
|
+
function runFlutterWizardWithTelemetry(options) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
93
|
+
var _a, selectedProject, selfHosted, sentryUrl, authToken, projectDir, pubspecFile, flutterVersion, flutterVersionOrAny, pluginVersion, pluginVersionOrAny, pubspecPatched, propertiesAdded, mainFile, dsn, canEnableProfiling, mainPatched, issuesPageLink;
|
|
94
|
+
return __generator(this, function (_b) {
|
|
95
|
+
switch (_b.label) {
|
|
96
|
+
case 0:
|
|
97
|
+
(0, clack_utils_2.printWelcome)({
|
|
98
|
+
wizardName: 'Sentry Flutter Wizard',
|
|
99
|
+
promoCode: options.promoCode,
|
|
100
|
+
});
|
|
101
|
+
return [4 /*yield*/, (0, clack_utils_2.confirmContinueIfNoOrDirtyGitRepo)()];
|
|
102
|
+
case 1:
|
|
103
|
+
_b.sent();
|
|
104
|
+
return [4 /*yield*/, (0, clack_utils_2.getOrAskForProjectData)(options, 'flutter')];
|
|
105
|
+
case 2:
|
|
106
|
+
_a = _b.sent(), selectedProject = _a.selectedProject, selfHosted = _a.selfHosted, sentryUrl = _a.sentryUrl, authToken = _a.authToken;
|
|
107
|
+
projectDir = process.cwd();
|
|
108
|
+
pubspecFile = path.join(projectDir, 'pubspec.yaml');
|
|
109
|
+
if (!fs.existsSync(pubspecFile)) {
|
|
110
|
+
clack.log.error("Could not find ".concat(chalk_1.default.cyan('pubspec.yaml'), ". Make sure you run the wizard in the projects root folder."));
|
|
111
|
+
return [2 /*return*/];
|
|
112
|
+
}
|
|
113
|
+
// ======== STEP 1. Add sentry_flutter and sentry_dart_plugin to pubspec.yaml ============
|
|
114
|
+
clack.log.step("Adding ".concat(chalk_1.default.bold('Sentry'), " to your apps ").concat(chalk_1.default.cyan('pubspec.yaml'), " file."));
|
|
115
|
+
return [4 /*yield*/, (0, release_registry_1.fetchSdkVersion)('sentry.dart.flutter')];
|
|
116
|
+
case 3:
|
|
117
|
+
flutterVersion = _b.sent();
|
|
118
|
+
flutterVersionOrAny = flutterVersion ? "^".concat(flutterVersion) : 'any';
|
|
119
|
+
return [4 /*yield*/, (0, release_registry_1.fetchSdkVersion)('sentry.dart.plugin')];
|
|
120
|
+
case 4:
|
|
121
|
+
pluginVersion = _b.sent();
|
|
122
|
+
pluginVersionOrAny = pluginVersion ? "^".concat(pluginVersion) : 'any';
|
|
123
|
+
pubspecPatched = (0, telemetry_1.traceStep)('Patch pubspec.yaml', function () {
|
|
124
|
+
return codetools.patchPubspec(pubspecFile, flutterVersionOrAny, pluginVersionOrAny, selectedProject.slug, selectedProject.organization.slug);
|
|
125
|
+
});
|
|
126
|
+
if (!!pubspecPatched) return [3 /*break*/, 6];
|
|
127
|
+
clack.log.warn("Could not patch ".concat(chalk_1.default.cyan('pubspec.yaml'), ". Add the dependencies to it."));
|
|
128
|
+
return [4 /*yield*/, (0, clack_utils_1.showCopyPasteInstructions)('pubspec.yaml', (0, templates_1.pubspecSnippetColored)(flutterVersionOrAny, pluginVersionOrAny, selectedProject.slug, selectedProject.organization.slug), 'This ensures the Sentry SDK and plugin can be imported.')];
|
|
129
|
+
case 5:
|
|
130
|
+
_b.sent();
|
|
131
|
+
_b.label = 6;
|
|
132
|
+
case 6:
|
|
133
|
+
Sentry.setTag('pubspec-patched', pubspecPatched);
|
|
134
|
+
propertiesAdded = (0, telemetry_1.traceStep)('Add sentry.properties', function () {
|
|
135
|
+
return codetools.addProperties(pubspecFile, authToken);
|
|
136
|
+
});
|
|
137
|
+
if (!propertiesAdded) {
|
|
138
|
+
clack.log.warn("We could not add ".concat(chalk_1.default.cyan('sentry.properties'), " 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."));
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
clack.log.info("We created ".concat(chalk_1.default.cyan('sentry.properties'), " file in your project directory in order to provide an auth token for Sentry CLI.\nIt was also added to your \".gitignore\" file.\nAt your CI enviroment, you can set the SENTRY_AUTH_TOKEN environment variable instead. See https://docs.sentry.io/cli/configuration/#auth-token for more information."));
|
|
142
|
+
}
|
|
143
|
+
Sentry.setTag('sentry-properties-added', pubspecPatched);
|
|
144
|
+
// ======== STEP 3. Patch main.dart with setup and a test error snippet ============
|
|
145
|
+
clack.log.step("Patching ".concat(chalk_1.default.cyan('main.dart'), " with setup and test error snippet."));
|
|
146
|
+
mainFile = (0, code_tools_1.findFile)("".concat(projectDir, "/lib"), 'main.dart');
|
|
147
|
+
dsn = selectedProject.keys[0].dsn.public;
|
|
148
|
+
canEnableProfiling = fs.existsSync("".concat(projectDir, "/ios")) || fs.existsSync("".concat(projectDir, "/macos"));
|
|
149
|
+
return [4 /*yield*/, (0, telemetry_1.traceStep)('Patch main.dart', function () {
|
|
150
|
+
return codetools.patchMain(mainFile, dsn, canEnableProfiling);
|
|
151
|
+
})];
|
|
152
|
+
case 7:
|
|
153
|
+
mainPatched = _b.sent();
|
|
154
|
+
if (!!mainPatched) return [3 /*break*/, 9];
|
|
155
|
+
clack.log.warn("Could not patch ".concat(chalk_1.default.cyan('main.dart'), " file. Place the following code snippet within the apps main function."));
|
|
156
|
+
return [4 /*yield*/, (0, clack_utils_1.showCopyPasteInstructions)('main.dart', (0, templates_1.initSnippetColored)(dsn), 'This ensures the Sentry SDK is ready to capture errors.')];
|
|
157
|
+
case 8:
|
|
158
|
+
_b.sent();
|
|
159
|
+
_b.label = 9;
|
|
160
|
+
case 9:
|
|
161
|
+
Sentry.setTag('main-patched', mainPatched);
|
|
162
|
+
issuesPageLink = selfHosted
|
|
163
|
+
? "".concat(sentryUrl, "organizations/").concat(selectedProject.organization.slug, "/issues/?project=").concat(selectedProject.id)
|
|
164
|
+
: "https://".concat(selectedProject.organization.slug, ".sentry.io/issues/?project=").concat(selectedProject.id);
|
|
165
|
+
clack.outro("\n ".concat(chalk_1.default.greenBright('Successfully installed the Sentry Flutter SDK!'), "\n \n ").concat(chalk_1.default.cyan("You can validate your setup by launching your application and checking Sentry issues page afterwards\n ".concat(issuesPageLink)), "\n \n Check out the SDK documentation for further configuration:\n https://docs.sentry.io/platforms/flutter/\n "));
|
|
166
|
+
return [2 /*return*/];
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=flutter-wizard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flutter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,EACX,IAAA,8BAAkB,EAAC,GAAG,CAAC,EACvB,yDAAyD,CAC1D,EAAA;;oBAJD,SAIC,CAAC;;;oBAEJ,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;oBAIrC,cAAc,GAAG,UAAU;wBAC/B,CAAC,CAAC,UAAG,SAAS,2BAAiB,eAAe,CAAC,YAAY,CAAC,IAAI,8BAAoB,eAAe,CAAC,EAAE,CAAE;wBACxG,CAAC,CAAC,kBAAW,eAAe,CAAC,YAAY,CAAC,IAAI,wCAA8B,eAAe,CAAC,EAAE,CAAE,CAAC;oBAEnG,KAAK,CAAC,KAAK,CAAC,gBACR,eAAK,CAAC,WAAW,CAAC,gDAAgD,CAAC,yBAEnE,eAAK,CAAC,IAAI,CACV,oHACA,cAAc,CAAE,CACjB,8HAIF,CAAC,CAAC;;;;;CACJ","sourcesContent":["import { WizardOptions } from '../utils/types';\nimport * as Sentry from '@sentry/node';\nimport * as codetools from './code-tools';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { showCopyPasteInstructions } from '../utils/clack-utils';\nimport { pubspecSnippetColored, initSnippetColored } from './templates';\nimport { fetchSdkVersion } from '../utils/release-registry';\n// @ts-ignore - 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} from '../utils/clack-utils';\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\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 `We created ${chalk.cyan(\n 'sentry.properties',\n )} file in your project directory in order to provide an auth token for Sentry CLI.\\nIt was also added to your \".gitignore\" file.\\nAt your CI enviroment, you can set the SENTRY_AUTH_TOKEN environment variable instead. 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 `Patching ${chalk.cyan('main.dart')} with setup and 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(\n `You can validate your setup by launching your application and checking Sentry issues page afterwards\n ${issuesPageLink}`,\n )}\n \n Check out the SDK documentation for further configuration:\n https://docs.sentry.io/platforms/flutter/\n `);\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const sentryImport = "import 'package:sentry_flutter/sentry_flutter.dart';\n";
|
|
2
|
+
export declare function pubspecOptions(project: string, org: string): string;
|
|
3
|
+
export declare function sentryProperties(authToken: string): string;
|
|
4
|
+
export declare function initSnippet(dsn: string, selectedFeaturesMap: {
|
|
5
|
+
tracing: boolean;
|
|
6
|
+
profiling: boolean;
|
|
7
|
+
}, runApp: string): string;
|
|
8
|
+
export declare function pubspecSnippetColored(sentryVersion: string, pluginVersion: string, project: string, org: string): string;
|
|
9
|
+
export declare function initSnippetColored(dsn: string): string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initSnippetColored = exports.pubspecSnippetColored = exports.initSnippet = exports.sentryProperties = exports.pubspecOptions = exports.sentryImport = void 0;
|
|
4
|
+
var clack_utils_1 = require("../utils/clack-utils");
|
|
5
|
+
exports.sentryImport = "import 'package:sentry_flutter/sentry_flutter.dart';\n";
|
|
6
|
+
function pubspecOptions(project, org) {
|
|
7
|
+
return "sentry:\n upload_debug_symbols: true\n upload_source_maps: true\n project: ".concat(project, "\n org: ").concat(org, "\n");
|
|
8
|
+
}
|
|
9
|
+
exports.pubspecOptions = pubspecOptions;
|
|
10
|
+
function sentryProperties(authToken) {
|
|
11
|
+
return "auth_token=".concat(authToken);
|
|
12
|
+
}
|
|
13
|
+
exports.sentryProperties = sentryProperties;
|
|
14
|
+
function initSnippet(dsn, selectedFeaturesMap, runApp) {
|
|
15
|
+
var snippet = "await SentryFlutter.init(\n (options) {\n options.dsn = '".concat(dsn, "';");
|
|
16
|
+
if (selectedFeaturesMap.tracing) {
|
|
17
|
+
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;";
|
|
18
|
+
}
|
|
19
|
+
if (selectedFeaturesMap.profiling && selectedFeaturesMap.tracing) {
|
|
20
|
+
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;";
|
|
21
|
+
}
|
|
22
|
+
snippet += "\n },\n appRunner: () => runApp(SentryWidget(child: ".concat(runApp, ")),\n );\n // TODO: Remove this line after sending the first sample event to sentry.\n await Sentry.captureException(Exception('This is a sample exception.'));");
|
|
23
|
+
return snippet;
|
|
24
|
+
}
|
|
25
|
+
exports.initSnippet = initSnippet;
|
|
26
|
+
function pubspecSnippetColored(sentryVersion, pluginVersion, project, org) {
|
|
27
|
+
var snippet = "dependencies:\n sentry_flutter: ".concat(sentryVersion, "\n\ndev_dependencies:\n sentry_dart_plugin: ").concat(pluginVersion, "\n \n").concat(pubspecOptions(project, org));
|
|
28
|
+
return (0, clack_utils_1.makeCodeSnippet)(true, function (_unchanged, plus, _minus) {
|
|
29
|
+
return plus(snippet);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
exports.pubspecSnippetColored = pubspecSnippetColored;
|
|
33
|
+
function initSnippetColored(dsn) {
|
|
34
|
+
var snippet = "import 'package:sentry_flutter/sentry_flutter.dart';\n\nFuture<void>main() async {\n await SentryFlutter.init(\n (options) {\n options.dsn = '".concat(dsn, "';\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}");
|
|
35
|
+
return (0, clack_utils_1.makeCodeSnippet)(true, function (_unchanged, plus, _minus) {
|
|
36
|
+
return plus(snippet);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
exports.initSnippetColored = initSnippetColored;
|
|
40
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/flutter/templates.ts"],"names":[],"mappings":";;;AAAA,oDAAuD;AAE1C,QAAA,YAAY,GAAG,wDAAwD,CAAC;AAErF,SAAgB,cAAc,CAAC,OAAe,EAAE,GAAW;IACzD,OAAO,wFAGI,OAAO,sBACX,GAAG,OACX,CAAC;AACF,CAAC;AAPD,wCAOC;AAED,SAAgB,gBAAgB,CAAC,SAAiB;IAChD,OAAO,qBAAc,SAAS,CAAE,CAAC;AACnC,CAAC;AAFD,4CAEC;AAED,SAAgB,WAAW,CACzB,GAAW,EACX,mBAGC,EACD,MAAc;IAEd,IAAI,OAAO,GAAG,2EAEO,GAAG,OAAI,CAAC;IAE7B,IAAI,mBAAmB,CAAC,OAAO,EAAE;QAC/B,OAAO,IAAI,uLAGuB,CAAC;KACpC;IAED,IAAI,mBAAmB,CAAC,SAAS,IAAI,mBAAmB,CAAC,OAAO,EAAE;QAChE,OAAO,IAAI,yLAGyB,CAAC;KACtC;IAED,OAAO,IAAI,oEAEqC,MAAM,uKAGmB,CAAC;IAE1E,OAAO,OAAO,CAAC;AACjB,CAAC;AAlCD,kCAkCC;AAED,SAAgB,qBAAqB,CACnC,aAAqB,EACrB,aAAqB,EACrB,OAAe,EACf,GAAW;IAEX,IAAM,OAAO,GAAG,2CACE,aAAa,0DAGT,aAAa,mBAEnC,cAAc,CAAC,OAAO,EAAE,GAAG,CAAC,CAAE,CAAC;IAE/B,OAAO,IAAA,6BAAe,EAAC,IAAI,EAAE,UAAC,UAAU,EAAE,IAAI,EAAE,MAAM;QACpD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACL,CAAC;AAjBD,sDAiBC;AAED,SAAgB,kBAAkB,CAAC,GAAW;IAC5C,IAAM,OAAO,GAAG,iKAKK,GAAG,0QAOxB,CAAC;IACD,OAAO,IAAA,6BAAe,EAAC,IAAI,EAAE,UAAC,UAAU,EAAE,IAAI,EAAE,MAAM;QACpD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACL,CAAC;AAjBD,gDAiBC","sourcesContent":["import { makeCodeSnippet } from '../utils/clack-utils';\n\nexport const sentryImport = `import 'package:sentry_flutter/sentry_flutter.dart';\\n`;\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 },\n runApp: string,\n): string {\n let snippet = `await SentryFlutter.init(\n (options) {\n options.dsn = '${dsn}';`;\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 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(Exception('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 // 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"]}
|
|
@@ -772,7 +772,7 @@ function askShouldSetTunnelRoute() {
|
|
|
772
772
|
var _this = this;
|
|
773
773
|
return __generator(this, function (_a) {
|
|
774
774
|
switch (_a.label) {
|
|
775
|
-
case 0: return [4 /*yield*/, (0, telemetry_1.traceStep)('ask-tunnelRoute-option', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
775
|
+
case 0: return [4 /*yield*/, (0, telemetry_1.traceStep)('ask-tunnelRoute-option', function (span) { return __awaiter(_this, void 0, void 0, function () {
|
|
776
776
|
var shouldSetTunnelRoute;
|
|
777
777
|
return __generator(this, function (_a) {
|
|
778
778
|
switch (_a.label) {
|
|
@@ -797,6 +797,8 @@ function askShouldSetTunnelRoute() {
|
|
|
797
797
|
if (!shouldSetTunnelRoute) {
|
|
798
798
|
prompts_1.default.log.info("Sounds good! We'll leave the option commented for later, just in case :)");
|
|
799
799
|
}
|
|
800
|
+
span === null || span === void 0 ? void 0 : span.setAttribute('tunnelRoute', shouldSetTunnelRoute);
|
|
801
|
+
Sentry.setTag('tunnelRoute', shouldSetTunnelRoute);
|
|
800
802
|
return [2 /*return*/, shouldSetTunnelRoute];
|
|
801
803
|
}
|
|
802
804
|
});
|