@sentry/bundler-plugin-core 0.2.0 → 0.2.2

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.
@@ -1,8 +1,9 @@
1
1
  import { createUnplugin } from 'unplugin';
2
2
  import MagicString from 'magic-string';
3
- import { NodeClient, Integrations, defaultStackParser, makeNodeTransport, Hub, makeMain } from '@sentry/node';
4
- import '@sentry/tracing';
5
3
  import SentryCli from '@sentry/cli';
4
+ import { NodeClient, defaultStackParser, makeNodeTransport, Hub, makeMain } from '@sentry/node';
5
+ import '@sentry/tracing';
6
+ import path from 'path';
6
7
 
7
8
  function _regeneratorRuntime() {
8
9
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
@@ -349,16 +350,6 @@ function _regeneratorRuntime() {
349
350
  }, exports;
350
351
  }
351
352
 
352
- function _typeof(obj) {
353
- "@babel/helpers - typeof";
354
-
355
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
356
- return typeof obj;
357
- } : function (obj) {
358
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
359
- }, _typeof(obj);
360
- }
361
-
362
353
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
363
354
  try {
364
355
  var info = gen[key](arg);
@@ -822,12 +813,7 @@ function normalizeUserOptions(userOptions) {
822
813
  dist: userOptions.dist,
823
814
  errorHandler: userOptions.errorHandler,
824
815
  configFile: userOptions.configFile
825
- }; // We only want to enable telemetry for SaaS users
826
- // This is not the final check (we need to call Sentry CLI at a later point)
827
- // but we can already at this point make a first decision.
828
- // @see `turnOffTelemetryForSelfHostedSentry` (telemetry.ts) for the second check.
829
-
830
- options.telemetry = options.telemetry && options.url === SENTRY_SAAS_URL;
816
+ };
831
817
  return options;
832
818
  }
833
819
  /**
@@ -940,30 +926,83 @@ function validateOptions(options, logger) {
940
926
  return true;
941
927
  }
942
928
 
943
- function makeSentryClient(dsn, telemetryEnabled) {
929
+ var SENTRY_SAAS_HOSTNAME = "sentry.io";
930
+ function makeSentryClient(dsn, allowedToSendTelemetryPromise) {
944
931
  var client = new NodeClient({
945
932
  dsn: dsn,
946
- enabled: telemetryEnabled,
947
- tracesSampleRate: telemetryEnabled ? 1.0 : 0.0,
948
- sampleRate: telemetryEnabled ? 1.0 : 0.0,
949
- release: "0.2.0",
950
- integrations: [new Integrations.Http({
951
- tracing: true
952
- })],
933
+ tracesSampleRate: 1,
934
+ sampleRate: 1,
935
+ release: "0.2.2",
936
+ integrations: [],
953
937
  tracePropagationTargets: ["sentry.io/api"],
954
938
  stackParser: defaultStackParser,
955
- transport: makeNodeTransport
956
- });
957
- var hub = new Hub(client); //TODO: This call is problematic because as soon as we set our hub as the current hub
958
- // we might interfere with other plugins that use Sentry. However, for now, we'll
959
- // leave it in because without it, we can't get distributed traces (which are pretty nice)
960
- // Let's keep it until someone complains about interference.
961
- // The ideal solution would be a code change in the JS SDK but it's not a straight-forward fix.
939
+ beforeSend: function beforeSend(event) {
940
+ var _event$exception, _event$exception$valu;
941
+
942
+ (_event$exception = event.exception) === null || _event$exception === void 0 ? void 0 : (_event$exception$valu = _event$exception.values) === null || _event$exception$valu === void 0 ? void 0 : _event$exception$valu.forEach(function (exception) {
943
+ delete exception.stacktrace;
944
+ });
945
+ delete event.server_name; // Server name might contain PII
946
+
947
+ return event;
948
+ },
949
+ beforeSendTransaction: function beforeSendTransaction(event) {
950
+ delete event.server_name; // Server name might contain PII
962
951
 
963
- makeMain(hub);
952
+ return event;
953
+ },
954
+ // We create a transport that stalls sending events until we know that we're allowed to (i.e. when Sentry CLI told
955
+ // us that the upload URL is the Sentry SaaS URL)
956
+ transport: function transport(nodeTransportOptions) {
957
+ var nodeTransport = makeNodeTransport(nodeTransportOptions);
958
+ return {
959
+ flush: function flush(timeout) {
960
+ return nodeTransport.flush(timeout);
961
+ },
962
+ send: function () {
963
+ var _send = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
964
+ var isAllowedToSend;
965
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
966
+ while (1) {
967
+ switch (_context.prev = _context.next) {
968
+ case 0:
969
+ _context.next = 2;
970
+ return allowedToSendTelemetryPromise;
971
+
972
+ case 2:
973
+ isAllowedToSend = _context.sent;
974
+
975
+ if (!isAllowedToSend) {
976
+ _context.next = 7;
977
+ break;
978
+ }
979
+
980
+ return _context.abrupt("return", nodeTransport.send(request));
981
+
982
+ case 7:
983
+ return _context.abrupt("return", undefined);
984
+
985
+ case 8:
986
+ case "end":
987
+ return _context.stop();
988
+ }
989
+ }
990
+ }, _callee);
991
+ }));
992
+
993
+ function send(_x) {
994
+ return _send.apply(this, arguments);
995
+ }
996
+
997
+ return send;
998
+ }()
999
+ };
1000
+ }
1001
+ });
1002
+ var hub = new Hub(client);
964
1003
  return {
965
- client: client,
966
- hub: hub
1004
+ sentryClient: client,
1005
+ sentryHub: hub
967
1006
  };
968
1007
  }
969
1008
  /**
@@ -985,28 +1024,10 @@ function addSpanToTransaction(ctx, op, description) {
985
1024
  });
986
1025
  return span;
987
1026
  }
988
- function captureMinimalError(error, hub) {
989
- var sentryError;
990
-
991
- if (error && _typeof(error) === "object") {
992
- var e = error;
993
- sentryError = {
994
- name: e.name,
995
- message: e.message,
996
- stack: e.stack
997
- };
998
- } else {
999
- sentryError = {
1000
- name: "Error",
1001
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
1002
- message: "".concat(error)
1003
- };
1004
- }
1005
-
1006
- hub.captureException(sentryError);
1007
- }
1008
- function addPluginOptionTags(options, hub) {
1009
- var cleanArtifacts = options.cleanArtifacts,
1027
+ function addPluginOptionInformationToHub(options, hub, bundler) {
1028
+ var org = options.org,
1029
+ project = options.project,
1030
+ cleanArtifacts = options.cleanArtifacts,
1010
1031
  finalize = options.finalize,
1011
1032
  setCommits = options.setCommits,
1012
1033
  injectReleasesMap = options.injectReleasesMap,
@@ -1046,90 +1067,155 @@ function addPluginOptionTags(options, hub) {
1046
1067
  }
1047
1068
 
1048
1069
  hub.setTag("node", process.version);
1070
+ hub.setTags({
1071
+ organization: org,
1072
+ project: project,
1073
+ bundler: bundler
1074
+ });
1075
+ hub.setUser({
1076
+ id: org
1077
+ });
1049
1078
  }
1050
- /**
1051
- * Makes a call to SentryCLI to get the Sentry server URL the CLI uses.
1052
- *
1053
- * We need to check and decide to use telemetry based on the CLI's respone to this call
1054
- * because only at this time we checked a possibly existing .sentryclirc file. This file
1055
- * could point to another URL than the default URL.
1056
- */
1057
-
1058
- function turnOffTelemetryForSelfHostedSentry(_x, _x2) {
1059
- return _turnOffTelemetryForSelfHostedSentry.apply(this, arguments);
1079
+ function shouldSendTelemetry(_x2) {
1080
+ return _shouldSendTelemetry.apply(this, arguments);
1060
1081
  }
1061
1082
 
1062
- function _turnOffTelemetryForSelfHostedSentry() {
1063
- _turnOffTelemetryForSelfHostedSentry = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(cli, hub) {
1083
+ function _shouldSendTelemetry() {
1084
+ _shouldSendTelemetry = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
1064
1085
  var _cliInfo$split$, _cliInfo$split$$repla;
1065
1086
 
1066
- var cliInfo, url, client;
1067
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1087
+ var silent, org, project, authToken, url, vcsRemote, customHeader, dist, telemetry, dryRun, cli, cliInfo, cliInfoUrl;
1088
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1068
1089
  while (1) {
1069
- switch (_context.prev = _context.next) {
1090
+ switch (_context2.prev = _context2.next) {
1070
1091
  case 0:
1071
- _context.next = 2;
1072
- return cli.execute(["info"], false);
1092
+ silent = options.silent, org = options.org, project = options.project, authToken = options.authToken, url = options.url, vcsRemote = options.vcsRemote, customHeader = options.customHeader, dist = options.dist, telemetry = options.telemetry, dryRun = options.dryRun; // `options.telemetry` defaults to true
1073
1093
 
1074
- case 2:
1075
- cliInfo = _context.sent;
1076
- url = cliInfo === null || cliInfo === void 0 ? void 0 : (_cliInfo$split$ = cliInfo.split(/(\r\n|\n|\r)/)[0]) === null || _cliInfo$split$ === void 0 ? void 0 : (_cliInfo$split$$repla = _cliInfo$split$.replace(/^Sentry Server: /, "")) === null || _cliInfo$split$$repla === void 0 ? void 0 : _cliInfo$split$$repla.trim();
1094
+ if (!(telemetry === false)) {
1095
+ _context2.next = 3;
1096
+ break;
1097
+ }
1077
1098
 
1078
- if (url !== SENTRY_SAAS_URL) {
1079
- client = hub.getClient();
1099
+ return _context2.abrupt("return", false);
1080
1100
 
1081
- if (client) {
1082
- client.getOptions().enabled = false;
1083
- client.getOptions().tracesSampleRate = 0;
1084
- client.getOptions().sampleRate = 0;
1085
- }
1101
+ case 3:
1102
+ if (!dryRun) {
1103
+ _context2.next = 5;
1104
+ break;
1086
1105
  }
1087
1106
 
1107
+ return _context2.abrupt("return", false);
1108
+
1088
1109
  case 5:
1110
+ if (!(url === SENTRY_SAAS_URL)) {
1111
+ _context2.next = 7;
1112
+ break;
1113
+ }
1114
+
1115
+ return _context2.abrupt("return", true);
1116
+
1117
+ case 7:
1118
+ cli = new SentryCli(options.configFile, {
1119
+ url: url,
1120
+ authToken: authToken,
1121
+ org: org,
1122
+ project: project,
1123
+ vcsRemote: vcsRemote,
1124
+ dist: dist,
1125
+ silent: silent,
1126
+ customHeader: customHeader
1127
+ });
1128
+ _context2.prev = 8;
1129
+ _context2.next = 11;
1130
+ return cli.execute(["info"], false);
1131
+
1132
+ case 11:
1133
+ cliInfo = _context2.sent;
1134
+ _context2.next = 17;
1135
+ break;
1136
+
1137
+ case 14:
1138
+ _context2.prev = 14;
1139
+ _context2.t0 = _context2["catch"](8);
1140
+ throw new Error('Sentry CLI "info" command failed, make sure you have an auth token configured, and your `url` option is correct.');
1141
+
1142
+ case 17:
1143
+ cliInfoUrl = (_cliInfo$split$ = cliInfo.split(/(\r\n|\n|\r)/)[0]) === null || _cliInfo$split$ === void 0 ? void 0 : (_cliInfo$split$$repla = _cliInfo$split$.replace(/^Sentry Server: /, "")) === null || _cliInfo$split$$repla === void 0 ? void 0 : _cliInfo$split$$repla.trim();
1144
+
1145
+ if (!(cliInfoUrl === undefined)) {
1146
+ _context2.next = 20;
1147
+ break;
1148
+ }
1149
+
1150
+ return _context2.abrupt("return", false);
1151
+
1152
+ case 20:
1153
+ return _context2.abrupt("return", new URL(cliInfoUrl).hostname === SENTRY_SAAS_HOSTNAME);
1154
+
1155
+ case 21:
1089
1156
  case "end":
1090
- return _context.stop();
1157
+ return _context2.stop();
1091
1158
  }
1092
1159
  }
1093
- }, _callee);
1160
+ }, _callee2, null, [[8, 14]]);
1094
1161
  }));
1095
- return _turnOffTelemetryForSelfHostedSentry.apply(this, arguments);
1162
+ return _shouldSendTelemetry.apply(this, arguments);
1096
1163
  }
1097
1164
 
1098
- function createNewRelease(_x, _x2) {
1165
+ function createNewRelease(_x, _x2, _x3) {
1099
1166
  return _createNewRelease.apply(this, arguments);
1100
1167
  }
1101
1168
 
1102
1169
  function _createNewRelease() {
1103
- _createNewRelease = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options, ctx) {
1170
+ _createNewRelease = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options, ctx, releaseName) {
1104
1171
  var span;
1105
1172
  return _regeneratorRuntime().wrap(function _callee$(_context) {
1106
1173
  while (1) {
1107
1174
  switch (_context.prev = _context.next) {
1108
1175
  case 0:
1109
1176
  span = addSpanToTransaction(ctx, "function.plugin.create_release");
1110
- _context.next = 3;
1111
- return ctx.cli.releases["new"](options.release);
1177
+ _context.prev = 1;
1178
+ _context.next = 4;
1179
+ return ctx.cli.releases["new"](releaseName);
1112
1180
 
1113
- case 3:
1114
- ctx.logger.info("Successfully created release.");
1181
+ case 4:
1182
+ _context.next = 10;
1183
+ break;
1184
+
1185
+ case 6:
1186
+ _context.prev = 6;
1187
+ _context.t0 = _context["catch"](1);
1188
+ ctx.hub.captureException(new Error("CLI Error: Creating new release failed"));
1189
+ throw _context.t0;
1190
+
1191
+ case 10:
1192
+ _context.prev = 10;
1115
1193
  span === null || span === void 0 ? void 0 : span.finish();
1194
+ return _context.finish(10);
1116
1195
 
1117
- case 5:
1196
+ case 13:
1197
+ ctx.hub.addBreadcrumb({
1198
+ level: "info",
1199
+ message: "Successfully created release."
1200
+ });
1201
+ ctx.logger.info("Successfully created release.");
1202
+
1203
+ case 15:
1118
1204
  case "end":
1119
1205
  return _context.stop();
1120
1206
  }
1121
1207
  }
1122
- }, _callee);
1208
+ }, _callee, null, [[1, 6, 10, 13]]);
1123
1209
  }));
1124
1210
  return _createNewRelease.apply(this, arguments);
1125
1211
  }
1126
1212
 
1127
- function cleanArtifacts(_x3, _x4) {
1213
+ function cleanArtifacts(_x4, _x5, _x6) {
1128
1214
  return _cleanArtifacts.apply(this, arguments);
1129
1215
  }
1130
1216
 
1131
1217
  function _cleanArtifacts() {
1132
- _cleanArtifacts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options, ctx) {
1218
+ _cleanArtifacts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options, ctx, releaseName) {
1133
1219
  var span;
1134
1220
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1135
1221
  while (1) {
@@ -1145,29 +1231,48 @@ function _cleanArtifacts() {
1145
1231
 
1146
1232
  case 3:
1147
1233
  span = addSpanToTransaction(ctx, "function.plugin.clean_artifacts");
1148
- _context2.next = 6;
1149
- return ctx.cli.releases.execute(["releases", "files", options.release, "delete", "--all"], true);
1234
+ _context2.prev = 4;
1235
+ _context2.next = 7;
1236
+ return ctx.cli.releases.execute(["releases", "files", releaseName, "delete", "--all"], true);
1150
1237
 
1151
- case 6:
1152
- ctx.logger.info("Successfully cleaned previous artifacts.");
1238
+ case 7:
1239
+ _context2.next = 13;
1240
+ break;
1241
+
1242
+ case 9:
1243
+ _context2.prev = 9;
1244
+ _context2.t0 = _context2["catch"](4);
1245
+ ctx.hub.captureException(new Error("CLI Error: Deleting release files failed"));
1246
+ throw _context2.t0;
1247
+
1248
+ case 13:
1249
+ _context2.prev = 13;
1153
1250
  span === null || span === void 0 ? void 0 : span.finish();
1251
+ return _context2.finish(13);
1154
1252
 
1155
- case 8:
1253
+ case 16:
1254
+ ctx.hub.addBreadcrumb({
1255
+ level: "info",
1256
+ message: "Successfully cleaned previous artifacts."
1257
+ });
1258
+ ctx.logger.info("Successfully cleaned previous artifacts.");
1259
+
1260
+ case 18:
1156
1261
  case "end":
1157
1262
  return _context2.stop();
1158
1263
  }
1159
1264
  }
1160
- }, _callee2);
1265
+ }, _callee2, null, [[4, 9, 13, 16]]);
1161
1266
  }));
1162
1267
  return _cleanArtifacts.apply(this, arguments);
1163
1268
  }
1164
1269
 
1165
- function uploadSourceMaps(_x5, _x6) {
1270
+ function uploadSourceMaps(_x7, _x8, _x9) {
1166
1271
  return _uploadSourceMaps.apply(this, arguments);
1167
1272
  }
1168
1273
 
1169
1274
  function _uploadSourceMaps() {
1170
- _uploadSourceMaps = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(options, ctx) {
1275
+ _uploadSourceMaps = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(options, ctx, releaseName) {
1171
1276
  var span;
1172
1277
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1173
1278
  while (1) {
@@ -1177,31 +1282,50 @@ function _uploadSourceMaps() {
1177
1282
  ctx.logger.info("Uploading Sourcemaps."); // Since our internal include entries contain all top-level sourcemaps options,
1178
1283
  // we only need to pass the include option here.
1179
1284
 
1180
- _context3.next = 4;
1181
- return ctx.cli.releases.uploadSourceMaps(options.release, {
1285
+ _context3.prev = 2;
1286
+ _context3.next = 5;
1287
+ return ctx.cli.releases.uploadSourceMaps(releaseName, {
1182
1288
  include: options.include
1183
1289
  });
1184
1290
 
1185
- case 4:
1186
- ctx.logger.info("Successfully uploaded Sourcemaps.");
1291
+ case 5:
1292
+ _context3.next = 11;
1293
+ break;
1294
+
1295
+ case 7:
1296
+ _context3.prev = 7;
1297
+ _context3.t0 = _context3["catch"](2);
1298
+ ctx.hub.captureException(new Error("CLI Error: Uploading source maps failed"));
1299
+ throw _context3.t0;
1300
+
1301
+ case 11:
1302
+ _context3.prev = 11;
1187
1303
  span === null || span === void 0 ? void 0 : span.finish();
1304
+ return _context3.finish(11);
1188
1305
 
1189
- case 6:
1306
+ case 14:
1307
+ ctx.hub.addBreadcrumb({
1308
+ level: "info",
1309
+ message: "Successfully uploaded source maps."
1310
+ });
1311
+ ctx.logger.info("Successfully uploaded source maps.");
1312
+
1313
+ case 16:
1190
1314
  case "end":
1191
1315
  return _context3.stop();
1192
1316
  }
1193
1317
  }
1194
- }, _callee3);
1318
+ }, _callee3, null, [[2, 7, 11, 14]]);
1195
1319
  }));
1196
1320
  return _uploadSourceMaps.apply(this, arguments);
1197
1321
  }
1198
1322
 
1199
- function setCommits(_x7, _x8) {
1323
+ function setCommits(_x10, _x11, _x12) {
1200
1324
  return _setCommits.apply(this, arguments);
1201
1325
  }
1202
1326
 
1203
1327
  function _setCommits() {
1204
- _setCommits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(options, ctx) {
1328
+ _setCommits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(options, ctx, releaseName) {
1205
1329
  var span, _options$setCommits, auto, repo, commit, previousCommit, ignoreMissing, ignoreEmpty;
1206
1330
 
1207
1331
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
@@ -1219,8 +1343,9 @@ function _setCommits() {
1219
1343
  case 3:
1220
1344
  span = addSpanToTransaction(ctx, "function.plugin.set_commits");
1221
1345
  _options$setCommits = options.setCommits, auto = _options$setCommits.auto, repo = _options$setCommits.repo, commit = _options$setCommits.commit, previousCommit = _options$setCommits.previousCommit, ignoreMissing = _options$setCommits.ignoreMissing, ignoreEmpty = _options$setCommits.ignoreEmpty;
1222
- _context4.next = 7;
1223
- return ctx.cli.releases.setCommits(options.release, {
1346
+ _context4.prev = 5;
1347
+ _context4.next = 8;
1348
+ return ctx.cli.releases.setCommits(releaseName, {
1224
1349
  commit: commit,
1225
1350
  previousCommit: previousCommit,
1226
1351
  repo: repo,
@@ -1229,64 +1354,101 @@ function _setCommits() {
1229
1354
  ignoreEmpty: ignoreEmpty
1230
1355
  });
1231
1356
 
1232
- case 7:
1233
- ctx.logger.info("Successfully set commits.");
1357
+ case 8:
1358
+ _context4.next = 14;
1359
+ break;
1360
+
1361
+ case 10:
1362
+ _context4.prev = 10;
1363
+ _context4.t0 = _context4["catch"](5);
1364
+ ctx.hub.captureException(new Error("CLI Error: Setting commits failed"));
1365
+ throw _context4.t0;
1366
+
1367
+ case 14:
1368
+ _context4.prev = 14;
1234
1369
  span === null || span === void 0 ? void 0 : span.finish();
1370
+ return _context4.finish(14);
1235
1371
 
1236
- case 9:
1372
+ case 17:
1373
+ ctx.logger.info("Successfully set commits.");
1374
+
1375
+ case 18:
1237
1376
  case "end":
1238
1377
  return _context4.stop();
1239
1378
  }
1240
1379
  }
1241
- }, _callee4);
1380
+ }, _callee4, null, [[5, 10, 14, 17]]);
1242
1381
  }));
1243
1382
  return _setCommits.apply(this, arguments);
1244
1383
  }
1245
1384
 
1246
- function finalizeRelease(_x9, _x10) {
1385
+ function finalizeRelease(_x13, _x14, _x15) {
1247
1386
  return _finalizeRelease.apply(this, arguments);
1248
1387
  }
1249
1388
 
1250
1389
  function _finalizeRelease() {
1251
- _finalizeRelease = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(options, ctx) {
1390
+ _finalizeRelease = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(options, ctx, releaseName) {
1252
1391
  var span;
1253
1392
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
1254
1393
  while (1) {
1255
1394
  switch (_context5.prev = _context5.next) {
1256
1395
  case 0:
1257
1396
  if (options.finalize) {
1258
- _context5.next = 3;
1397
+ _context5.next = 4;
1259
1398
  break;
1260
1399
  }
1261
1400
 
1401
+ ctx.hub.addBreadcrumb({
1402
+ level: "info",
1403
+ message: "Skipping release finalization."
1404
+ });
1262
1405
  logger.debug("Skipping release finalization.");
1263
1406
  return _context5.abrupt("return");
1264
1407
 
1265
- case 3:
1408
+ case 4:
1266
1409
  span = addSpanToTransaction(ctx, "function.plugin.finalize_release");
1267
- _context5.next = 6;
1268
- return ctx.cli.releases.finalize(options.release);
1410
+ _context5.prev = 5;
1411
+ _context5.next = 8;
1412
+ return ctx.cli.releases.finalize(releaseName);
1269
1413
 
1270
- case 6:
1271
- ctx.logger.info("Successfully finalized release.");
1414
+ case 8:
1415
+ _context5.next = 14;
1416
+ break;
1417
+
1418
+ case 10:
1419
+ _context5.prev = 10;
1420
+ _context5.t0 = _context5["catch"](5);
1421
+ ctx.hub.captureException(new Error("CLI Error: Finalizing release failed"));
1422
+ throw _context5.t0;
1423
+
1424
+ case 14:
1425
+ _context5.prev = 14;
1272
1426
  span === null || span === void 0 ? void 0 : span.finish();
1427
+ return _context5.finish(14);
1273
1428
 
1274
- case 8:
1429
+ case 17:
1430
+ ctx.hub.addBreadcrumb({
1431
+ level: "info",
1432
+ message: "Successfully finalized release."
1433
+ });
1434
+ ctx.logger.info("Successfully finalized release.");
1435
+
1436
+ case 19:
1275
1437
  case "end":
1276
1438
  return _context5.stop();
1277
1439
  }
1278
1440
  }
1279
- }, _callee5);
1441
+ }, _callee5, null, [[5, 10, 14, 17]]);
1280
1442
  }));
1281
1443
  return _finalizeRelease.apply(this, arguments);
1282
1444
  }
1283
1445
 
1284
- function addDeploy(_x11, _x12) {
1446
+ function addDeploy(_x16, _x17, _x18) {
1285
1447
  return _addDeploy.apply(this, arguments);
1286
1448
  }
1287
1449
 
1288
1450
  function _addDeploy() {
1289
- _addDeploy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(options, ctx) {
1451
+ _addDeploy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(options, ctx, releaseName) {
1290
1452
  var span, _options$deploy, env, started, finished, time, name, url;
1291
1453
 
1292
1454
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
@@ -1294,18 +1456,23 @@ function _addDeploy() {
1294
1456
  switch (_context6.prev = _context6.next) {
1295
1457
  case 0:
1296
1458
  if (options.deploy) {
1297
- _context6.next = 3;
1459
+ _context6.next = 4;
1298
1460
  break;
1299
1461
  }
1300
1462
 
1463
+ ctx.hub.addBreadcrumb({
1464
+ level: "info",
1465
+ message: "Skipping adding deploy info to release."
1466
+ });
1301
1467
  logger.debug("Skipping adding deploy info to release.");
1302
1468
  return _context6.abrupt("return");
1303
1469
 
1304
- case 3:
1470
+ case 4:
1305
1471
  span = addSpanToTransaction(ctx, "function.plugin.deploy");
1306
1472
  _options$deploy = options.deploy, env = _options$deploy.env, started = _options$deploy.started, finished = _options$deploy.finished, time = _options$deploy.time, name = _options$deploy.name, url = _options$deploy.url;
1307
- _context6.next = 7;
1308
- return ctx.cli.releases.newDeploy(options.release, {
1473
+ _context6.prev = 6;
1474
+ _context6.next = 9;
1475
+ return ctx.cli.releases.newDeploy(releaseName, {
1309
1476
  env: env,
1310
1477
  started: started,
1311
1478
  finished: finished,
@@ -1314,29 +1481,39 @@ function _addDeploy() {
1314
1481
  url: url
1315
1482
  });
1316
1483
 
1317
- case 7:
1318
- ctx.logger.info("Successfully added deploy.");
1484
+ case 9:
1485
+ _context6.next = 15;
1486
+ break;
1487
+
1488
+ case 11:
1489
+ _context6.prev = 11;
1490
+ _context6.t0 = _context6["catch"](6);
1491
+ ctx.hub.captureException(new Error("CLI Error: Adding deploy info failed"));
1492
+ throw _context6.t0;
1493
+
1494
+ case 15:
1495
+ _context6.prev = 15;
1319
1496
  span === null || span === void 0 ? void 0 : span.finish();
1497
+ return _context6.finish(15);
1320
1498
 
1321
- case 9:
1499
+ case 18:
1500
+ ctx.hub.addBreadcrumb({
1501
+ level: "info",
1502
+ message: "Successfully added deploy."
1503
+ });
1504
+ ctx.logger.info("Successfully added deploy.");
1505
+
1506
+ case 20:
1322
1507
  case "end":
1323
1508
  return _context6.stop();
1324
1509
  }
1325
1510
  }
1326
- }, _callee6);
1511
+ }, _callee6, null, [[6, 11, 15, 18]]);
1327
1512
  }));
1328
1513
  return _addDeploy.apply(this, arguments);
1329
1514
  }
1330
1515
 
1331
1516
  function createLogger(options) {
1332
- function addBreadcrumb(level, message) {
1333
- options.hub.addBreadcrumb({
1334
- category: "logger",
1335
- level: level,
1336
- message: message
1337
- });
1338
- }
1339
-
1340
1517
  return {
1341
1518
  info: function info(message) {
1342
1519
  if (!options.silent) {
@@ -1349,8 +1526,6 @@ function createLogger(options) {
1349
1526
  // eslint-disable-next-line no-console
1350
1527
  (_console = console).log.apply(_console, ["".concat(options.prefix, " Info: ").concat(message)].concat(params));
1351
1528
  }
1352
-
1353
- addBreadcrumb("info", message);
1354
1529
  },
1355
1530
  warn: function warn(message) {
1356
1531
  if (!options.silent) {
@@ -1363,8 +1538,6 @@ function createLogger(options) {
1363
1538
  // eslint-disable-next-line no-console
1364
1539
  (_console2 = console).log.apply(_console2, ["".concat(options.prefix, " Warning: ").concat(message)].concat(params));
1365
1540
  }
1366
-
1367
- addBreadcrumb("warning", message);
1368
1541
  },
1369
1542
  error: function error(message) {
1370
1543
  if (!options.silent) {
@@ -1377,8 +1550,6 @@ function createLogger(options) {
1377
1550
  // eslint-disable-next-line no-console
1378
1551
  (_console3 = console).log.apply(_console3, ["".concat(options.prefix, " Error: ").concat(message)].concat(params));
1379
1552
  }
1380
-
1381
- addBreadcrumb("error", message);
1382
1553
  },
1383
1554
  debug: function debug(message) {
1384
1555
  if (!options.silent && options.debug) {
@@ -1391,8 +1562,6 @@ function createLogger(options) {
1391
1562
  // eslint-disable-next-line no-console
1392
1563
  (_console4 = console).log.apply(_console4, ["".concat(options.prefix, " Debug: ").concat(message)].concat(params));
1393
1564
  }
1394
-
1395
- addBreadcrumb("debug", message);
1396
1565
  }
1397
1566
  };
1398
1567
  }
@@ -1472,9 +1641,9 @@ function getDryRunCLI(cli, logger) {
1472
1641
  };
1473
1642
  }
1474
1643
 
1475
- // We prefix the polyfill id with \0 to tell other plugins not to try to load or transform it.
1476
1644
  // This hack is taken straight from https://rollupjs.org/guide/en/#resolveid.
1477
1645
  // This probably doesn't work for all bundlers but for rollup it does.
1646
+
1478
1647
  var RELEASE_INJECTOR_ID = "\0sentry-release-injector";
1479
1648
  var ALLOWED_TRANSFORMATION_FILE_ENDINGS = [".js", ".ts", ".jsx", ".tsx", ".cjs", ".mjs"];
1480
1649
  /**
@@ -1507,13 +1676,20 @@ var ALLOWED_TRANSFORMATION_FILE_ENDINGS = [".js", ".ts", ".jsx", ".tsx", ".cjs",
1507
1676
 
1508
1677
  var unplugin = createUnplugin(function (options, unpluginMetaContext) {
1509
1678
  var internalOptions = normalizeUserOptions(options);
1679
+ var allowedToSendTelemetryPromise = shouldSendTelemetry(internalOptions);
1510
1680
 
1511
- var _makeSentryClient = makeSentryClient("https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737", internalOptions.telemetry),
1512
- sentryHub = _makeSentryClient.hub;
1681
+ var _makeSentryClient = makeSentryClient("https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737", allowedToSendTelemetryPromise),
1682
+ sentryHub = _makeSentryClient.sentryHub,
1683
+ sentryClient = _makeSentryClient.sentryClient;
1513
1684
 
1514
- addPluginOptionTags(internalOptions, sentryHub);
1685
+ addPluginOptionInformationToHub(internalOptions, sentryHub, unpluginMetaContext.framework); //TODO: This call is problematic because as soon as we set our hub as the current hub
1686
+ // we might interfere with other plugins that use Sentry. However, for now, we'll
1687
+ // leave it in because without it, we can't get distributed traces (which are pretty nice)
1688
+ // Let's keep it until someone complains about interference.
1689
+ // The ideal solution would be a code change in the JS SDK but it's not a straight-forward fix.
1690
+
1691
+ makeMain(sentryHub);
1515
1692
  var logger = createLogger({
1516
- hub: sentryHub,
1517
1693
  prefix: "[sentry-".concat(unpluginMetaContext.framework, "-plugin]"),
1518
1694
  silent: internalOptions.silent,
1519
1695
  debug: internalOptions.debug
@@ -1524,19 +1700,12 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
1524
1700
  }
1525
1701
 
1526
1702
  var cli = getSentryCli(internalOptions, logger);
1527
-
1528
- if (internalOptions.telemetry) {
1529
- logger.info("Sending error and performance telemetry data to Sentry.");
1530
- logger.info("To disable telemetry, set `options.telemetry` to `false`.");
1531
- }
1532
-
1533
- sentryHub.setTags({
1534
- organization: internalOptions.org,
1535
- project: internalOptions.project,
1536
- bundler: unpluginMetaContext.framework
1537
- });
1538
- sentryHub.setUser({
1539
- id: internalOptions.org
1703
+ var releaseNamePromise = new Promise(function (resolve) {
1704
+ if (options.release) {
1705
+ resolve(options.release);
1706
+ } else {
1707
+ resolve(cli.releases.proposeVersion());
1708
+ }
1540
1709
  });
1541
1710
  var transaction;
1542
1711
  var releaseInjectionSpan;
@@ -1550,29 +1719,41 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
1550
1719
  */
1551
1720
  buildStart: function buildStart() {
1552
1721
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1722
+ var isAllowedToSendToSendTelemetry, releaseName;
1553
1723
  return _regeneratorRuntime().wrap(function _callee$(_context) {
1554
1724
  while (1) {
1555
1725
  switch (_context.prev = _context.next) {
1556
1726
  case 0:
1557
- _context.next = 2;
1558
- return turnOffTelemetryForSelfHostedSentry(cli, sentryHub);
1559
-
1560
- case 2:
1561
- if (internalOptions.release) {
1562
- _context.next = 6;
1563
- break;
1727
+ logger.debug("Called 'buildStart'");
1728
+ _context.next = 3;
1729
+ return allowedToSendTelemetryPromise;
1730
+
1731
+ case 3:
1732
+ isAllowedToSendToSendTelemetry = _context.sent;
1733
+
1734
+ if (isAllowedToSendToSendTelemetry) {
1735
+ logger.info("Sending error and performance telemetry data to Sentry.");
1736
+ logger.info("To disable telemetry, set `options.telemetry` to `false`.");
1737
+ sentryHub.addBreadcrumb({
1738
+ level: "info",
1739
+ message: "Telemetry enabled."
1740
+ });
1741
+ } else {
1742
+ sentryHub.addBreadcrumb({
1743
+ level: "info",
1744
+ message: "Telemetry disabled. This should never show up in a Sentry event."
1745
+ });
1564
1746
  }
1565
1747
 
1566
- _context.next = 5;
1567
- return cli.releases.proposeVersion();
1748
+ _context.next = 7;
1749
+ return releaseNamePromise;
1568
1750
 
1569
- case 5:
1570
- internalOptions.release = _context.sent;
1751
+ case 7:
1752
+ releaseName = _context.sent;
1571
1753
 
1572
- case 6:
1573
1754
  // At this point, we either have determined a release or we have to bail
1574
- if (!internalOptions.release) {
1575
- handleError(new Error("Unable to determine a release name. Make sure to set the `release` option or use an environment that supports auto-detection https://docs.sentry.io/cli/releases/#creating-releases`"), logger, internalOptions.errorHandler, sentryHub);
1755
+ if (!releaseName) {
1756
+ handleError(new Error("Unable to determine a release name. Make sure to set the `release` option or use an environment that supports auto-detection https://docs.sentry.io/cli/releases/#creating-releases`"), logger, internalOptions.errorHandler);
1576
1757
  }
1577
1758
 
1578
1759
  transaction = sentryHub.startTransaction({
@@ -1586,7 +1767,7 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
1586
1767
  cli: cli
1587
1768
  }, "function.plugin.inject_release", "Release injection");
1588
1769
 
1589
- case 9:
1770
+ case 11:
1590
1771
  case "end":
1591
1772
  return _context.stop();
1592
1773
  }
@@ -1608,10 +1789,10 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
1608
1789
  */
1609
1790
  resolveId: function resolveId(id, importer, _ref) {
1610
1791
  var isEntry = _ref.isEntry;
1611
- sentryHub.addBreadcrumb({
1612
- category: "resolveId",
1613
- message: "isEntry: ".concat(String(isEntry)),
1614
- level: "info"
1792
+ logger.debug('Called "resolveId":', {
1793
+ id: id,
1794
+ importer: importer,
1795
+ isEntry: isEntry
1615
1796
  });
1616
1797
 
1617
1798
  if (id === RELEASE_INJECTOR_ID) {
@@ -1621,9 +1802,9 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
1621
1802
  }
1622
1803
  },
1623
1804
  loadInclude: function loadInclude(id) {
1624
- logger.info("Called \"loadInclude\": ".concat(JSON.stringify({
1805
+ logger.debug('Called "loadInclude":', {
1625
1806
  id: id
1626
- })));
1807
+ });
1627
1808
  return id === RELEASE_INJECTOR_ID;
1628
1809
  },
1629
1810
 
@@ -1635,21 +1816,47 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
1635
1816
  * @returns The global injector code when we load the "sentry-release-injector" module. Otherwise returns `undefined`.
1636
1817
  */
1637
1818
  load: function load(id) {
1638
- sentryHub.addBreadcrumb({
1639
- category: "load",
1640
- level: "info"
1641
- });
1819
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
1820
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1821
+ while (1) {
1822
+ switch (_context2.prev = _context2.next) {
1823
+ case 0:
1824
+ logger.debug('Called "load":', {
1825
+ id: id
1826
+ });
1642
1827
 
1643
- if (id === RELEASE_INJECTOR_ID) {
1644
- return generateGlobalInjectorCode({
1645
- release: internalOptions.release,
1646
- injectReleasesMap: internalOptions.injectReleasesMap,
1647
- org: internalOptions.org,
1648
- project: internalOptions.project
1649
- });
1650
- } else {
1651
- return undefined;
1652
- }
1828
+ if (!(id === RELEASE_INJECTOR_ID)) {
1829
+ _context2.next = 13;
1830
+ break;
1831
+ }
1832
+
1833
+ _context2.t0 = generateGlobalInjectorCode;
1834
+ _context2.next = 5;
1835
+ return releaseNamePromise;
1836
+
1837
+ case 5:
1838
+ _context2.t1 = _context2.sent;
1839
+ _context2.t2 = internalOptions.injectReleasesMap;
1840
+ _context2.t3 = internalOptions.org;
1841
+ _context2.t4 = internalOptions.project;
1842
+ _context2.t5 = {
1843
+ release: _context2.t1,
1844
+ injectReleasesMap: _context2.t2,
1845
+ org: _context2.t3,
1846
+ project: _context2.t4
1847
+ };
1848
+ return _context2.abrupt("return", (0, _context2.t0)(_context2.t5));
1849
+
1850
+ case 13:
1851
+ return _context2.abrupt("return", undefined);
1852
+
1853
+ case 14:
1854
+ case "end":
1855
+ return _context2.stop();
1856
+ }
1857
+ }
1858
+ }, _callee2);
1859
+ }))();
1653
1860
  },
1654
1861
 
1655
1862
  /**
@@ -1661,32 +1868,35 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
1661
1868
  * want to transform the release injector file.
1662
1869
  */
1663
1870
  transformInclude: function transformInclude(id) {
1664
- sentryHub.addBreadcrumb({
1665
- category: "transformInclude",
1666
- level: "info"
1667
- }); // We don't want to transform our injected code.
1871
+ logger.debug('Called "transformInclude":', {
1872
+ id: id
1873
+ }); // We normalize the id because vite always passes `id` as a unix style path which causes problems when a user passes
1874
+ // a windows style path to `releaseInjectionTargets`
1668
1875
 
1669
- if (id === RELEASE_INJECTOR_ID) {
1876
+ var normalizedId = path.normalize(id); // We don't want to transform our injected code.
1877
+
1878
+ if (normalizedId === RELEASE_INJECTOR_ID) {
1670
1879
  return false;
1671
1880
  }
1672
1881
 
1673
1882
  if (internalOptions.releaseInjectionTargets) {
1674
1883
  // If there's an `releaseInjectionTargets` option transform (ie. inject the release varible) when the file path matches the option.
1675
1884
  if (typeof internalOptions.releaseInjectionTargets === "function") {
1676
- return internalOptions.releaseInjectionTargets(id);
1885
+ return internalOptions.releaseInjectionTargets(normalizedId);
1677
1886
  }
1678
1887
 
1679
1888
  return internalOptions.releaseInjectionTargets.some(function (entry) {
1680
1889
  if (entry instanceof RegExp) {
1681
- return entry.test(id);
1890
+ return entry.test(normalizedId);
1682
1891
  } else {
1683
- return id === entry;
1892
+ var normalizedEntry = path.normalize(entry);
1893
+ return normalizedId === normalizedEntry;
1684
1894
  }
1685
1895
  });
1686
1896
  } else {
1687
- var pathIsOrdinary = !id.includes("?") && !id.includes("#");
1897
+ var pathIsOrdinary = !normalizedId.includes("?") && !normalizedId.includes("#");
1688
1898
  var pathHasAllowedFileEnding = ALLOWED_TRANSFORMATION_FILE_ENDINGS.some(function (allowedFileEnding) {
1689
- return id.endsWith(allowedFileEnding);
1899
+ return normalizedId.endsWith(allowedFileEnding);
1690
1900
  });
1691
1901
  return pathIsOrdinary && pathHasAllowedFileEnding;
1692
1902
  }
@@ -1700,10 +1910,9 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
1700
1910
  * @param id Always the absolute (fully resolved) path to the module.
1701
1911
  * @returns transformed code + source map
1702
1912
  */
1703
- transform: function transform(code) {
1704
- sentryHub.addBreadcrumb({
1705
- category: "transform",
1706
- level: "info"
1913
+ transform: function transform(code, id) {
1914
+ logger.debug('Called "transform":', {
1915
+ id: id
1707
1916
  }); // The MagicString library allows us to generate sourcemaps for the changes we make to the user code.
1708
1917
 
1709
1918
  var ms = new MagicString(code); // Appending instead of prepending has less probability of mucking with user's source maps.
@@ -1729,69 +1938,121 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
1729
1938
  * Sentry.io, uploading sourcemaps, associating commits and deploys and finalizing the release)
1730
1939
  */
1731
1940
  writeBundle: function writeBundle() {
1732
- var _releaseInjectionSpan;
1733
-
1734
- (_releaseInjectionSpan = releaseInjectionSpan) === null || _releaseInjectionSpan === void 0 ? void 0 : _releaseInjectionSpan.finish();
1735
- var releasePipelineSpan = transaction && addSpanToTransaction({
1736
- hub: sentryHub,
1737
- parentSpan: transaction,
1738
- logger: logger,
1739
- cli: cli
1740
- }, "function.plugin.release", "Release pipeline");
1741
- sentryHub.addBreadcrumb({
1742
- category: "writeBundle:start",
1743
- level: "info"
1744
- });
1745
- var ctx = {
1746
- hub: sentryHub,
1747
- parentSpan: releasePipelineSpan,
1748
- logger: logger,
1749
- cli: cli
1750
- };
1751
- createNewRelease(internalOptions, ctx).then(function () {
1752
- return cleanArtifacts(internalOptions, ctx);
1753
- }).then(function () {
1754
- return uploadSourceMaps(internalOptions, ctx);
1755
- }).then(function () {
1756
- return setCommits(internalOptions, ctx);
1757
- }).then(function () {
1758
- return finalizeRelease(internalOptions, ctx);
1759
- }).then(function () {
1760
- return addDeploy(internalOptions, ctx);
1761
- }).then(function () {
1762
- var _transaction;
1763
-
1764
- return (_transaction = transaction) === null || _transaction === void 0 ? void 0 : _transaction.setStatus("ok");
1765
- })["catch"](function (e) {
1766
- var _transaction2;
1767
-
1768
- (_transaction2 = transaction) === null || _transaction2 === void 0 ? void 0 : _transaction2.setStatus("cancelled");
1769
- handleError(e, logger, internalOptions.errorHandler, sentryHub);
1770
- })["finally"](function () {
1771
- var _transaction3;
1772
-
1773
- sentryHub.addBreadcrumb({
1774
- category: "writeBundle:finish",
1775
- level: "info"
1776
- });
1777
- releasePipelineSpan === null || releasePipelineSpan === void 0 ? void 0 : releasePipelineSpan.finish();
1778
- (_transaction3 = transaction) === null || _transaction3 === void 0 ? void 0 : _transaction3.finish();
1779
- });
1941
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
1942
+ var _releaseInjectionSpan;
1943
+
1944
+ var releasePipelineSpan, ctx, releaseName, _transaction, _transaction2, _transaction3;
1945
+
1946
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1947
+ while (1) {
1948
+ switch (_context3.prev = _context3.next) {
1949
+ case 0:
1950
+ logger.debug('Called "writeBundle"');
1951
+ (_releaseInjectionSpan = releaseInjectionSpan) === null || _releaseInjectionSpan === void 0 ? void 0 : _releaseInjectionSpan.finish();
1952
+ releasePipelineSpan = transaction && addSpanToTransaction({
1953
+ hub: sentryHub,
1954
+ parentSpan: transaction,
1955
+ logger: logger,
1956
+ cli: cli
1957
+ }, "function.plugin.release", "Release pipeline");
1958
+ sentryHub.addBreadcrumb({
1959
+ category: "writeBundle:start",
1960
+ level: "info"
1961
+ });
1962
+ ctx = {
1963
+ hub: sentryHub,
1964
+ parentSpan: releasePipelineSpan,
1965
+ logger: logger,
1966
+ cli: cli
1967
+ };
1968
+ _context3.next = 7;
1969
+ return releaseNamePromise;
1970
+
1971
+ case 7:
1972
+ releaseName = _context3.sent;
1973
+ _context3.prev = 8;
1974
+ _context3.next = 11;
1975
+ return createNewRelease(internalOptions, ctx, releaseName);
1976
+
1977
+ case 11:
1978
+ _context3.next = 13;
1979
+ return cleanArtifacts(internalOptions, ctx, releaseName);
1980
+
1981
+ case 13:
1982
+ _context3.next = 15;
1983
+ return uploadSourceMaps(internalOptions, ctx, releaseName);
1984
+
1985
+ case 15:
1986
+ _context3.next = 17;
1987
+ return setCommits(internalOptions, ctx, releaseName);
1988
+
1989
+ case 17:
1990
+ _context3.next = 19;
1991
+ return finalizeRelease(internalOptions, ctx, releaseName);
1992
+
1993
+ case 19:
1994
+ _context3.next = 21;
1995
+ return addDeploy(internalOptions, ctx, releaseName);
1996
+
1997
+ case 21:
1998
+ (_transaction = transaction) === null || _transaction === void 0 ? void 0 : _transaction.setStatus("ok");
1999
+ _context3.next = 29;
2000
+ break;
2001
+
2002
+ case 24:
2003
+ _context3.prev = 24;
2004
+ _context3.t0 = _context3["catch"](8);
2005
+ (_transaction2 = transaction) === null || _transaction2 === void 0 ? void 0 : _transaction2.setStatus("cancelled");
2006
+ sentryHub.addBreadcrumb({
2007
+ level: "error",
2008
+ message: "Error during writeBundle"
2009
+ });
2010
+ handleError(_context3.t0, logger, internalOptions.errorHandler);
2011
+
2012
+ case 29:
2013
+ _context3.prev = 29;
2014
+ releasePipelineSpan === null || releasePipelineSpan === void 0 ? void 0 : releasePipelineSpan.finish();
2015
+ (_transaction3 = transaction) === null || _transaction3 === void 0 ? void 0 : _transaction3.finish();
2016
+ _context3.next = 34;
2017
+ return sentryClient.flush().then(null, function () {
2018
+ logger.warn("Sending of telemetry failed");
2019
+ });
2020
+
2021
+ case 34:
2022
+ return _context3.finish(29);
2023
+
2024
+ case 35:
2025
+ sentryHub.addBreadcrumb({
2026
+ category: "writeBundle:finish",
2027
+ level: "info"
2028
+ });
2029
+
2030
+ case 36:
2031
+ case "end":
2032
+ return _context3.stop();
2033
+ }
2034
+ }
2035
+ }, _callee3, null, [[8, 24, 29, 35]]);
2036
+ }))();
1780
2037
  }
1781
2038
  };
1782
2039
  });
1783
2040
 
1784
- function handleError(error, logger, errorHandler, sentryHub) {
1785
- logger.error(error.message);
1786
-
1787
- if (sentryHub) {
1788
- captureMinimalError(error, sentryHub);
2041
+ function handleError(unknownError, logger, errorHandler) {
2042
+ if (unknownError instanceof Error) {
2043
+ logger.error(unknownError.message);
2044
+ } else {
2045
+ logger.error(String(unknownError));
1789
2046
  }
1790
2047
 
1791
2048
  if (errorHandler) {
1792
- errorHandler(error);
2049
+ if (unknownError instanceof Error) {
2050
+ errorHandler(unknownError);
2051
+ } else {
2052
+ errorHandler(new Error("An unknown error occured"));
2053
+ }
1793
2054
  } else {
1794
- throw error;
2055
+ throw unknownError;
1795
2056
  }
1796
2057
  }
1797
2058
  /**
@@ -1827,4 +2088,4 @@ var sentryWebpackPlugin = unplugin.webpack; // eslint-disable-next-line @typescr
1827
2088
  var sentryEsbuildPlugin = unplugin.esbuild;
1828
2089
 
1829
2090
  export { sentryEsbuildPlugin, sentryRollupPlugin, sentryVitePlugin, sentryWebpackPlugin };
1830
- //# sourceMappingURL=index.js.map
2091
+ //# sourceMappingURL=index.mjs.map