@sentry/bundler-plugin-core 0.2.1 → 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.
@@ -350,16 +350,6 @@ function _regeneratorRuntime() {
350
350
  }, exports;
351
351
  }
352
352
 
353
- function _typeof(obj) {
354
- "@babel/helpers - typeof";
355
-
356
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
357
- return typeof obj;
358
- } : function (obj) {
359
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
360
- }, _typeof(obj);
361
- }
362
-
363
353
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
364
354
  try {
365
355
  var info = gen[key](arg);
@@ -942,10 +932,25 @@ function makeSentryClient(dsn, allowedToSendTelemetryPromise) {
942
932
  dsn: dsn,
943
933
  tracesSampleRate: 1,
944
934
  sampleRate: 1,
945
- release: "0.2.1",
935
+ release: "0.2.2",
946
936
  integrations: [],
947
937
  tracePropagationTargets: ["sentry.io/api"],
948
938
  stackParser: defaultStackParser,
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
951
+
952
+ return event;
953
+ },
949
954
  // We create a transport that stalls sending events until we know that we're allowed to (i.e. when Sentry CLI told
950
955
  // us that the upload URL is the Sentry SaaS URL)
951
956
  transport: function transport(nodeTransportOptions) {
@@ -1019,26 +1024,6 @@ function addSpanToTransaction(ctx, op, description) {
1019
1024
  });
1020
1025
  return span;
1021
1026
  }
1022
- function captureMinimalError(error, hub) {
1023
- var sentryError;
1024
-
1025
- if (error && _typeof(error) === "object") {
1026
- var e = error;
1027
- sentryError = {
1028
- name: e.name,
1029
- message: e.message,
1030
- stack: e.stack
1031
- };
1032
- } else {
1033
- sentryError = {
1034
- name: "Error",
1035
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
1036
- message: "".concat(error)
1037
- };
1038
- }
1039
-
1040
- hub.captureException(sentryError);
1041
- }
1042
1027
  function addPluginOptionInformationToHub(options, hub, bundler) {
1043
1028
  var org = options.org,
1044
1029
  project = options.project,
@@ -1189,19 +1174,38 @@ function _createNewRelease() {
1189
1174
  switch (_context.prev = _context.next) {
1190
1175
  case 0:
1191
1176
  span = addSpanToTransaction(ctx, "function.plugin.create_release");
1192
- _context.next = 3;
1177
+ _context.prev = 1;
1178
+ _context.next = 4;
1193
1179
  return ctx.cli.releases["new"](releaseName);
1194
1180
 
1195
- case 3:
1196
- 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;
1197
1193
  span === null || span === void 0 ? void 0 : span.finish();
1194
+ return _context.finish(10);
1198
1195
 
1199
- 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:
1200
1204
  case "end":
1201
1205
  return _context.stop();
1202
1206
  }
1203
1207
  }
1204
- }, _callee);
1208
+ }, _callee, null, [[1, 6, 10, 13]]);
1205
1209
  }));
1206
1210
  return _createNewRelease.apply(this, arguments);
1207
1211
  }
@@ -1227,19 +1231,38 @@ function _cleanArtifacts() {
1227
1231
 
1228
1232
  case 3:
1229
1233
  span = addSpanToTransaction(ctx, "function.plugin.clean_artifacts");
1230
- _context2.next = 6;
1234
+ _context2.prev = 4;
1235
+ _context2.next = 7;
1231
1236
  return ctx.cli.releases.execute(["releases", "files", releaseName, "delete", "--all"], true);
1232
1237
 
1233
- case 6:
1234
- 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;
1235
1250
  span === null || span === void 0 ? void 0 : span.finish();
1251
+ return _context2.finish(13);
1236
1252
 
1237
- 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:
1238
1261
  case "end":
1239
1262
  return _context2.stop();
1240
1263
  }
1241
1264
  }
1242
- }, _callee2);
1265
+ }, _callee2, null, [[4, 9, 13, 16]]);
1243
1266
  }));
1244
1267
  return _cleanArtifacts.apply(this, arguments);
1245
1268
  }
@@ -1259,21 +1282,40 @@ function _uploadSourceMaps() {
1259
1282
  ctx.logger.info("Uploading Sourcemaps."); // Since our internal include entries contain all top-level sourcemaps options,
1260
1283
  // we only need to pass the include option here.
1261
1284
 
1262
- _context3.next = 4;
1285
+ _context3.prev = 2;
1286
+ _context3.next = 5;
1263
1287
  return ctx.cli.releases.uploadSourceMaps(releaseName, {
1264
1288
  include: options.include
1265
1289
  });
1266
1290
 
1267
- case 4:
1268
- 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;
1269
1303
  span === null || span === void 0 ? void 0 : span.finish();
1304
+ return _context3.finish(11);
1270
1305
 
1271
- 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:
1272
1314
  case "end":
1273
1315
  return _context3.stop();
1274
1316
  }
1275
1317
  }
1276
- }, _callee3);
1318
+ }, _callee3, null, [[2, 7, 11, 14]]);
1277
1319
  }));
1278
1320
  return _uploadSourceMaps.apply(this, arguments);
1279
1321
  }
@@ -1301,7 +1343,8 @@ function _setCommits() {
1301
1343
  case 3:
1302
1344
  span = addSpanToTransaction(ctx, "function.plugin.set_commits");
1303
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;
1304
- _context4.next = 7;
1346
+ _context4.prev = 5;
1347
+ _context4.next = 8;
1305
1348
  return ctx.cli.releases.setCommits(releaseName, {
1306
1349
  commit: commit,
1307
1350
  previousCommit: previousCommit,
@@ -1311,16 +1354,30 @@ function _setCommits() {
1311
1354
  ignoreEmpty: ignoreEmpty
1312
1355
  });
1313
1356
 
1314
- case 7:
1315
- 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;
1316
1369
  span === null || span === void 0 ? void 0 : span.finish();
1370
+ return _context4.finish(14);
1317
1371
 
1318
- case 9:
1372
+ case 17:
1373
+ ctx.logger.info("Successfully set commits.");
1374
+
1375
+ case 18:
1319
1376
  case "end":
1320
1377
  return _context4.stop();
1321
1378
  }
1322
1379
  }
1323
- }, _callee4);
1380
+ }, _callee4, null, [[5, 10, 14, 17]]);
1324
1381
  }));
1325
1382
  return _setCommits.apply(this, arguments);
1326
1383
  }
@@ -1337,28 +1394,51 @@ function _finalizeRelease() {
1337
1394
  switch (_context5.prev = _context5.next) {
1338
1395
  case 0:
1339
1396
  if (options.finalize) {
1340
- _context5.next = 3;
1397
+ _context5.next = 4;
1341
1398
  break;
1342
1399
  }
1343
1400
 
1401
+ ctx.hub.addBreadcrumb({
1402
+ level: "info",
1403
+ message: "Skipping release finalization."
1404
+ });
1344
1405
  logger.debug("Skipping release finalization.");
1345
1406
  return _context5.abrupt("return");
1346
1407
 
1347
- case 3:
1408
+ case 4:
1348
1409
  span = addSpanToTransaction(ctx, "function.plugin.finalize_release");
1349
- _context5.next = 6;
1410
+ _context5.prev = 5;
1411
+ _context5.next = 8;
1350
1412
  return ctx.cli.releases.finalize(releaseName);
1351
1413
 
1352
- case 6:
1353
- 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;
1354
1426
  span === null || span === void 0 ? void 0 : span.finish();
1427
+ return _context5.finish(14);
1355
1428
 
1356
- 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:
1357
1437
  case "end":
1358
1438
  return _context5.stop();
1359
1439
  }
1360
1440
  }
1361
- }, _callee5);
1441
+ }, _callee5, null, [[5, 10, 14, 17]]);
1362
1442
  }));
1363
1443
  return _finalizeRelease.apply(this, arguments);
1364
1444
  }
@@ -1376,17 +1456,22 @@ function _addDeploy() {
1376
1456
  switch (_context6.prev = _context6.next) {
1377
1457
  case 0:
1378
1458
  if (options.deploy) {
1379
- _context6.next = 3;
1459
+ _context6.next = 4;
1380
1460
  break;
1381
1461
  }
1382
1462
 
1463
+ ctx.hub.addBreadcrumb({
1464
+ level: "info",
1465
+ message: "Skipping adding deploy info to release."
1466
+ });
1383
1467
  logger.debug("Skipping adding deploy info to release.");
1384
1468
  return _context6.abrupt("return");
1385
1469
 
1386
- case 3:
1470
+ case 4:
1387
1471
  span = addSpanToTransaction(ctx, "function.plugin.deploy");
1388
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;
1389
- _context6.next = 7;
1473
+ _context6.prev = 6;
1474
+ _context6.next = 9;
1390
1475
  return ctx.cli.releases.newDeploy(releaseName, {
1391
1476
  env: env,
1392
1477
  started: started,
@@ -1396,29 +1481,39 @@ function _addDeploy() {
1396
1481
  url: url
1397
1482
  });
1398
1483
 
1399
- case 7:
1400
- 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;
1401
1496
  span === null || span === void 0 ? void 0 : span.finish();
1497
+ return _context6.finish(15);
1402
1498
 
1403
- 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:
1404
1507
  case "end":
1405
1508
  return _context6.stop();
1406
1509
  }
1407
1510
  }
1408
- }, _callee6);
1511
+ }, _callee6, null, [[6, 11, 15, 18]]);
1409
1512
  }));
1410
1513
  return _addDeploy.apply(this, arguments);
1411
1514
  }
1412
1515
 
1413
1516
  function createLogger(options) {
1414
- function addBreadcrumb(level, message) {
1415
- options.hub.addBreadcrumb({
1416
- category: "logger",
1417
- level: level,
1418
- message: message
1419
- });
1420
- }
1421
-
1422
1517
  return {
1423
1518
  info: function info(message) {
1424
1519
  if (!options.silent) {
@@ -1431,8 +1526,6 @@ function createLogger(options) {
1431
1526
  // eslint-disable-next-line no-console
1432
1527
  (_console = console).log.apply(_console, ["".concat(options.prefix, " Info: ").concat(message)].concat(params));
1433
1528
  }
1434
-
1435
- addBreadcrumb("info", message);
1436
1529
  },
1437
1530
  warn: function warn(message) {
1438
1531
  if (!options.silent) {
@@ -1445,8 +1538,6 @@ function createLogger(options) {
1445
1538
  // eslint-disable-next-line no-console
1446
1539
  (_console2 = console).log.apply(_console2, ["".concat(options.prefix, " Warning: ").concat(message)].concat(params));
1447
1540
  }
1448
-
1449
- addBreadcrumb("warning", message);
1450
1541
  },
1451
1542
  error: function error(message) {
1452
1543
  if (!options.silent) {
@@ -1459,8 +1550,6 @@ function createLogger(options) {
1459
1550
  // eslint-disable-next-line no-console
1460
1551
  (_console3 = console).log.apply(_console3, ["".concat(options.prefix, " Error: ").concat(message)].concat(params));
1461
1552
  }
1462
-
1463
- addBreadcrumb("error", message);
1464
1553
  },
1465
1554
  debug: function debug(message) {
1466
1555
  if (!options.silent && options.debug) {
@@ -1471,8 +1560,7 @@ function createLogger(options) {
1471
1560
  }
1472
1561
 
1473
1562
  // eslint-disable-next-line no-console
1474
- (_console4 = console).log.apply(_console4, ["".concat(options.prefix, " Debug: ").concat(message)].concat(params)); // We're not creating breadcrumbs for debug logs because it is super spammy
1475
-
1563
+ (_console4 = console).log.apply(_console4, ["".concat(options.prefix, " Debug: ").concat(message)].concat(params));
1476
1564
  }
1477
1565
  }
1478
1566
  };
@@ -1602,7 +1690,6 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
1602
1690
 
1603
1691
  makeMain(sentryHub);
1604
1692
  var logger = createLogger({
1605
- hub: sentryHub,
1606
1693
  prefix: "[sentry-".concat(unpluginMetaContext.framework, "-plugin]"),
1607
1694
  silent: internalOptions.silent,
1608
1695
  debug: internalOptions.debug
@@ -1647,6 +1734,15 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
1647
1734
  if (isAllowedToSendToSendTelemetry) {
1648
1735
  logger.info("Sending error and performance telemetry data to Sentry.");
1649
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
+ });
1650
1746
  }
1651
1747
 
1652
1748
  _context.next = 7;
@@ -1657,7 +1753,7 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
1657
1753
 
1658
1754
  // At this point, we either have determined a release or we have to bail
1659
1755
  if (!releaseName) {
1660
- 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);
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);
1661
1757
  }
1662
1758
 
1663
1759
  transaction = sentryHub.startTransaction({
@@ -1900,21 +1996,21 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
1900
1996
 
1901
1997
  case 21:
1902
1998
  (_transaction = transaction) === null || _transaction === void 0 ? void 0 : _transaction.setStatus("ok");
1903
- _context3.next = 28;
1999
+ _context3.next = 29;
1904
2000
  break;
1905
2001
 
1906
2002
  case 24:
1907
2003
  _context3.prev = 24;
1908
2004
  _context3.t0 = _context3["catch"](8);
1909
2005
  (_transaction2 = transaction) === null || _transaction2 === void 0 ? void 0 : _transaction2.setStatus("cancelled");
1910
- handleError(_context3.t0, logger, internalOptions.errorHandler, sentryHub);
1911
-
1912
- case 28:
1913
- _context3.prev = 28;
1914
2006
  sentryHub.addBreadcrumb({
1915
- category: "writeBundle:finish",
1916
- level: "info"
2007
+ level: "error",
2008
+ message: "Error during writeBundle"
1917
2009
  });
2010
+ handleError(_context3.t0, logger, internalOptions.errorHandler);
2011
+
2012
+ case 29:
2013
+ _context3.prev = 29;
1918
2014
  releasePipelineSpan === null || releasePipelineSpan === void 0 ? void 0 : releasePipelineSpan.finish();
1919
2015
  (_transaction3 = transaction) === null || _transaction3 === void 0 ? void 0 : _transaction3.finish();
1920
2016
  _context3.next = 34;
@@ -1923,30 +2019,32 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
1923
2019
  });
1924
2020
 
1925
2021
  case 34:
1926
- return _context3.finish(28);
2022
+ return _context3.finish(29);
1927
2023
 
1928
2024
  case 35:
2025
+ sentryHub.addBreadcrumb({
2026
+ category: "writeBundle:finish",
2027
+ level: "info"
2028
+ });
2029
+
2030
+ case 36:
1929
2031
  case "end":
1930
2032
  return _context3.stop();
1931
2033
  }
1932
2034
  }
1933
- }, _callee3, null, [[8, 24, 28, 35]]);
2035
+ }, _callee3, null, [[8, 24, 29, 35]]);
1934
2036
  }))();
1935
2037
  }
1936
2038
  };
1937
2039
  });
1938
2040
 
1939
- function handleError(unknownError, logger, errorHandler, sentryHub) {
2041
+ function handleError(unknownError, logger, errorHandler) {
1940
2042
  if (unknownError instanceof Error) {
1941
2043
  logger.error(unknownError.message);
1942
2044
  } else {
1943
2045
  logger.error(String(unknownError));
1944
2046
  }
1945
2047
 
1946
- if (sentryHub) {
1947
- captureMinimalError(unknownError, sentryHub);
1948
- }
1949
-
1950
2048
  if (errorHandler) {
1951
2049
  if (unknownError instanceof Error) {
1952
2050
  errorHandler(unknownError);
@@ -1990,4 +2088,4 @@ var sentryWebpackPlugin = unplugin.webpack; // eslint-disable-next-line @typescr
1990
2088
  var sentryEsbuildPlugin = unplugin.esbuild;
1991
2089
 
1992
2090
  export { sentryEsbuildPlugin, sentryRollupPlugin, sentryVitePlugin, sentryWebpackPlugin };
1993
- //# sourceMappingURL=index.js.map
2091
+ //# sourceMappingURL=index.mjs.map