@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.
package/dist/cjs/index.js CHANGED
@@ -360,16 +360,6 @@ function _regeneratorRuntime() {
360
360
  }, exports;
361
361
  }
362
362
 
363
- function _typeof(obj) {
364
- "@babel/helpers - typeof";
365
-
366
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
367
- return typeof obj;
368
- } : function (obj) {
369
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
370
- }, _typeof(obj);
371
- }
372
-
373
363
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
374
364
  try {
375
365
  var info = gen[key](arg);
@@ -952,10 +942,25 @@ function makeSentryClient(dsn, allowedToSendTelemetryPromise) {
952
942
  dsn: dsn,
953
943
  tracesSampleRate: 1,
954
944
  sampleRate: 1,
955
- release: "0.2.1",
945
+ release: "0.2.2",
956
946
  integrations: [],
957
947
  tracePropagationTargets: ["sentry.io/api"],
958
948
  stackParser: node.defaultStackParser,
949
+ beforeSend: function beforeSend(event) {
950
+ var _event$exception, _event$exception$valu;
951
+
952
+ (_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) {
953
+ delete exception.stacktrace;
954
+ });
955
+ delete event.server_name; // Server name might contain PII
956
+
957
+ return event;
958
+ },
959
+ beforeSendTransaction: function beforeSendTransaction(event) {
960
+ delete event.server_name; // Server name might contain PII
961
+
962
+ return event;
963
+ },
959
964
  // We create a transport that stalls sending events until we know that we're allowed to (i.e. when Sentry CLI told
960
965
  // us that the upload URL is the Sentry SaaS URL)
961
966
  transport: function transport(nodeTransportOptions) {
@@ -1029,26 +1034,6 @@ function addSpanToTransaction(ctx, op, description) {
1029
1034
  });
1030
1035
  return span;
1031
1036
  }
1032
- function captureMinimalError(error, hub) {
1033
- var sentryError;
1034
-
1035
- if (error && _typeof(error) === "object") {
1036
- var e = error;
1037
- sentryError = {
1038
- name: e.name,
1039
- message: e.message,
1040
- stack: e.stack
1041
- };
1042
- } else {
1043
- sentryError = {
1044
- name: "Error",
1045
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
1046
- message: "".concat(error)
1047
- };
1048
- }
1049
-
1050
- hub.captureException(sentryError);
1051
- }
1052
1037
  function addPluginOptionInformationToHub(options, hub, bundler) {
1053
1038
  var org = options.org,
1054
1039
  project = options.project,
@@ -1199,19 +1184,38 @@ function _createNewRelease() {
1199
1184
  switch (_context.prev = _context.next) {
1200
1185
  case 0:
1201
1186
  span = addSpanToTransaction(ctx, "function.plugin.create_release");
1202
- _context.next = 3;
1187
+ _context.prev = 1;
1188
+ _context.next = 4;
1203
1189
  return ctx.cli.releases["new"](releaseName);
1204
1190
 
1205
- case 3:
1206
- ctx.logger.info("Successfully created release.");
1191
+ case 4:
1192
+ _context.next = 10;
1193
+ break;
1194
+
1195
+ case 6:
1196
+ _context.prev = 6;
1197
+ _context.t0 = _context["catch"](1);
1198
+ ctx.hub.captureException(new Error("CLI Error: Creating new release failed"));
1199
+ throw _context.t0;
1200
+
1201
+ case 10:
1202
+ _context.prev = 10;
1207
1203
  span === null || span === void 0 ? void 0 : span.finish();
1204
+ return _context.finish(10);
1208
1205
 
1209
- case 5:
1206
+ case 13:
1207
+ ctx.hub.addBreadcrumb({
1208
+ level: "info",
1209
+ message: "Successfully created release."
1210
+ });
1211
+ ctx.logger.info("Successfully created release.");
1212
+
1213
+ case 15:
1210
1214
  case "end":
1211
1215
  return _context.stop();
1212
1216
  }
1213
1217
  }
1214
- }, _callee);
1218
+ }, _callee, null, [[1, 6, 10, 13]]);
1215
1219
  }));
1216
1220
  return _createNewRelease.apply(this, arguments);
1217
1221
  }
@@ -1237,19 +1241,38 @@ function _cleanArtifacts() {
1237
1241
 
1238
1242
  case 3:
1239
1243
  span = addSpanToTransaction(ctx, "function.plugin.clean_artifacts");
1240
- _context2.next = 6;
1244
+ _context2.prev = 4;
1245
+ _context2.next = 7;
1241
1246
  return ctx.cli.releases.execute(["releases", "files", releaseName, "delete", "--all"], true);
1242
1247
 
1243
- case 6:
1244
- ctx.logger.info("Successfully cleaned previous artifacts.");
1248
+ case 7:
1249
+ _context2.next = 13;
1250
+ break;
1251
+
1252
+ case 9:
1253
+ _context2.prev = 9;
1254
+ _context2.t0 = _context2["catch"](4);
1255
+ ctx.hub.captureException(new Error("CLI Error: Deleting release files failed"));
1256
+ throw _context2.t0;
1257
+
1258
+ case 13:
1259
+ _context2.prev = 13;
1245
1260
  span === null || span === void 0 ? void 0 : span.finish();
1261
+ return _context2.finish(13);
1246
1262
 
1247
- case 8:
1263
+ case 16:
1264
+ ctx.hub.addBreadcrumb({
1265
+ level: "info",
1266
+ message: "Successfully cleaned previous artifacts."
1267
+ });
1268
+ ctx.logger.info("Successfully cleaned previous artifacts.");
1269
+
1270
+ case 18:
1248
1271
  case "end":
1249
1272
  return _context2.stop();
1250
1273
  }
1251
1274
  }
1252
- }, _callee2);
1275
+ }, _callee2, null, [[4, 9, 13, 16]]);
1253
1276
  }));
1254
1277
  return _cleanArtifacts.apply(this, arguments);
1255
1278
  }
@@ -1269,21 +1292,40 @@ function _uploadSourceMaps() {
1269
1292
  ctx.logger.info("Uploading Sourcemaps."); // Since our internal include entries contain all top-level sourcemaps options,
1270
1293
  // we only need to pass the include option here.
1271
1294
 
1272
- _context3.next = 4;
1295
+ _context3.prev = 2;
1296
+ _context3.next = 5;
1273
1297
  return ctx.cli.releases.uploadSourceMaps(releaseName, {
1274
1298
  include: options.include
1275
1299
  });
1276
1300
 
1277
- case 4:
1278
- ctx.logger.info("Successfully uploaded Sourcemaps.");
1301
+ case 5:
1302
+ _context3.next = 11;
1303
+ break;
1304
+
1305
+ case 7:
1306
+ _context3.prev = 7;
1307
+ _context3.t0 = _context3["catch"](2);
1308
+ ctx.hub.captureException(new Error("CLI Error: Uploading source maps failed"));
1309
+ throw _context3.t0;
1310
+
1311
+ case 11:
1312
+ _context3.prev = 11;
1279
1313
  span === null || span === void 0 ? void 0 : span.finish();
1314
+ return _context3.finish(11);
1280
1315
 
1281
- case 6:
1316
+ case 14:
1317
+ ctx.hub.addBreadcrumb({
1318
+ level: "info",
1319
+ message: "Successfully uploaded source maps."
1320
+ });
1321
+ ctx.logger.info("Successfully uploaded source maps.");
1322
+
1323
+ case 16:
1282
1324
  case "end":
1283
1325
  return _context3.stop();
1284
1326
  }
1285
1327
  }
1286
- }, _callee3);
1328
+ }, _callee3, null, [[2, 7, 11, 14]]);
1287
1329
  }));
1288
1330
  return _uploadSourceMaps.apply(this, arguments);
1289
1331
  }
@@ -1311,7 +1353,8 @@ function _setCommits() {
1311
1353
  case 3:
1312
1354
  span = addSpanToTransaction(ctx, "function.plugin.set_commits");
1313
1355
  _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;
1314
- _context4.next = 7;
1356
+ _context4.prev = 5;
1357
+ _context4.next = 8;
1315
1358
  return ctx.cli.releases.setCommits(releaseName, {
1316
1359
  commit: commit,
1317
1360
  previousCommit: previousCommit,
@@ -1321,16 +1364,30 @@ function _setCommits() {
1321
1364
  ignoreEmpty: ignoreEmpty
1322
1365
  });
1323
1366
 
1324
- case 7:
1325
- ctx.logger.info("Successfully set commits.");
1367
+ case 8:
1368
+ _context4.next = 14;
1369
+ break;
1370
+
1371
+ case 10:
1372
+ _context4.prev = 10;
1373
+ _context4.t0 = _context4["catch"](5);
1374
+ ctx.hub.captureException(new Error("CLI Error: Setting commits failed"));
1375
+ throw _context4.t0;
1376
+
1377
+ case 14:
1378
+ _context4.prev = 14;
1326
1379
  span === null || span === void 0 ? void 0 : span.finish();
1380
+ return _context4.finish(14);
1327
1381
 
1328
- case 9:
1382
+ case 17:
1383
+ ctx.logger.info("Successfully set commits.");
1384
+
1385
+ case 18:
1329
1386
  case "end":
1330
1387
  return _context4.stop();
1331
1388
  }
1332
1389
  }
1333
- }, _callee4);
1390
+ }, _callee4, null, [[5, 10, 14, 17]]);
1334
1391
  }));
1335
1392
  return _setCommits.apply(this, arguments);
1336
1393
  }
@@ -1347,28 +1404,51 @@ function _finalizeRelease() {
1347
1404
  switch (_context5.prev = _context5.next) {
1348
1405
  case 0:
1349
1406
  if (options.finalize) {
1350
- _context5.next = 3;
1407
+ _context5.next = 4;
1351
1408
  break;
1352
1409
  }
1353
1410
 
1411
+ ctx.hub.addBreadcrumb({
1412
+ level: "info",
1413
+ message: "Skipping release finalization."
1414
+ });
1354
1415
  logger.debug("Skipping release finalization.");
1355
1416
  return _context5.abrupt("return");
1356
1417
 
1357
- case 3:
1418
+ case 4:
1358
1419
  span = addSpanToTransaction(ctx, "function.plugin.finalize_release");
1359
- _context5.next = 6;
1420
+ _context5.prev = 5;
1421
+ _context5.next = 8;
1360
1422
  return ctx.cli.releases.finalize(releaseName);
1361
1423
 
1362
- case 6:
1363
- ctx.logger.info("Successfully finalized release.");
1424
+ case 8:
1425
+ _context5.next = 14;
1426
+ break;
1427
+
1428
+ case 10:
1429
+ _context5.prev = 10;
1430
+ _context5.t0 = _context5["catch"](5);
1431
+ ctx.hub.captureException(new Error("CLI Error: Finalizing release failed"));
1432
+ throw _context5.t0;
1433
+
1434
+ case 14:
1435
+ _context5.prev = 14;
1364
1436
  span === null || span === void 0 ? void 0 : span.finish();
1437
+ return _context5.finish(14);
1365
1438
 
1366
- case 8:
1439
+ case 17:
1440
+ ctx.hub.addBreadcrumb({
1441
+ level: "info",
1442
+ message: "Successfully finalized release."
1443
+ });
1444
+ ctx.logger.info("Successfully finalized release.");
1445
+
1446
+ case 19:
1367
1447
  case "end":
1368
1448
  return _context5.stop();
1369
1449
  }
1370
1450
  }
1371
- }, _callee5);
1451
+ }, _callee5, null, [[5, 10, 14, 17]]);
1372
1452
  }));
1373
1453
  return _finalizeRelease.apply(this, arguments);
1374
1454
  }
@@ -1386,17 +1466,22 @@ function _addDeploy() {
1386
1466
  switch (_context6.prev = _context6.next) {
1387
1467
  case 0:
1388
1468
  if (options.deploy) {
1389
- _context6.next = 3;
1469
+ _context6.next = 4;
1390
1470
  break;
1391
1471
  }
1392
1472
 
1473
+ ctx.hub.addBreadcrumb({
1474
+ level: "info",
1475
+ message: "Skipping adding deploy info to release."
1476
+ });
1393
1477
  logger.debug("Skipping adding deploy info to release.");
1394
1478
  return _context6.abrupt("return");
1395
1479
 
1396
- case 3:
1480
+ case 4:
1397
1481
  span = addSpanToTransaction(ctx, "function.plugin.deploy");
1398
1482
  _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;
1399
- _context6.next = 7;
1483
+ _context6.prev = 6;
1484
+ _context6.next = 9;
1400
1485
  return ctx.cli.releases.newDeploy(releaseName, {
1401
1486
  env: env,
1402
1487
  started: started,
@@ -1406,29 +1491,39 @@ function _addDeploy() {
1406
1491
  url: url
1407
1492
  });
1408
1493
 
1409
- case 7:
1410
- ctx.logger.info("Successfully added deploy.");
1494
+ case 9:
1495
+ _context6.next = 15;
1496
+ break;
1497
+
1498
+ case 11:
1499
+ _context6.prev = 11;
1500
+ _context6.t0 = _context6["catch"](6);
1501
+ ctx.hub.captureException(new Error("CLI Error: Adding deploy info failed"));
1502
+ throw _context6.t0;
1503
+
1504
+ case 15:
1505
+ _context6.prev = 15;
1411
1506
  span === null || span === void 0 ? void 0 : span.finish();
1507
+ return _context6.finish(15);
1412
1508
 
1413
- case 9:
1509
+ case 18:
1510
+ ctx.hub.addBreadcrumb({
1511
+ level: "info",
1512
+ message: "Successfully added deploy."
1513
+ });
1514
+ ctx.logger.info("Successfully added deploy.");
1515
+
1516
+ case 20:
1414
1517
  case "end":
1415
1518
  return _context6.stop();
1416
1519
  }
1417
1520
  }
1418
- }, _callee6);
1521
+ }, _callee6, null, [[6, 11, 15, 18]]);
1419
1522
  }));
1420
1523
  return _addDeploy.apply(this, arguments);
1421
1524
  }
1422
1525
 
1423
1526
  function createLogger(options) {
1424
- function addBreadcrumb(level, message) {
1425
- options.hub.addBreadcrumb({
1426
- category: "logger",
1427
- level: level,
1428
- message: message
1429
- });
1430
- }
1431
-
1432
1527
  return {
1433
1528
  info: function info(message) {
1434
1529
  if (!options.silent) {
@@ -1441,8 +1536,6 @@ function createLogger(options) {
1441
1536
  // eslint-disable-next-line no-console
1442
1537
  (_console = console).log.apply(_console, ["".concat(options.prefix, " Info: ").concat(message)].concat(params));
1443
1538
  }
1444
-
1445
- addBreadcrumb("info", message);
1446
1539
  },
1447
1540
  warn: function warn(message) {
1448
1541
  if (!options.silent) {
@@ -1455,8 +1548,6 @@ function createLogger(options) {
1455
1548
  // eslint-disable-next-line no-console
1456
1549
  (_console2 = console).log.apply(_console2, ["".concat(options.prefix, " Warning: ").concat(message)].concat(params));
1457
1550
  }
1458
-
1459
- addBreadcrumb("warning", message);
1460
1551
  },
1461
1552
  error: function error(message) {
1462
1553
  if (!options.silent) {
@@ -1469,8 +1560,6 @@ function createLogger(options) {
1469
1560
  // eslint-disable-next-line no-console
1470
1561
  (_console3 = console).log.apply(_console3, ["".concat(options.prefix, " Error: ").concat(message)].concat(params));
1471
1562
  }
1472
-
1473
- addBreadcrumb("error", message);
1474
1563
  },
1475
1564
  debug: function debug(message) {
1476
1565
  if (!options.silent && options.debug) {
@@ -1481,8 +1570,7 @@ function createLogger(options) {
1481
1570
  }
1482
1571
 
1483
1572
  // eslint-disable-next-line no-console
1484
- (_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
1485
-
1573
+ (_console4 = console).log.apply(_console4, ["".concat(options.prefix, " Debug: ").concat(message)].concat(params));
1486
1574
  }
1487
1575
  }
1488
1576
  };
@@ -1612,7 +1700,6 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
1612
1700
 
1613
1701
  node.makeMain(sentryHub);
1614
1702
  var logger = createLogger({
1615
- hub: sentryHub,
1616
1703
  prefix: "[sentry-".concat(unpluginMetaContext.framework, "-plugin]"),
1617
1704
  silent: internalOptions.silent,
1618
1705
  debug: internalOptions.debug
@@ -1657,6 +1744,15 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
1657
1744
  if (isAllowedToSendToSendTelemetry) {
1658
1745
  logger.info("Sending error and performance telemetry data to Sentry.");
1659
1746
  logger.info("To disable telemetry, set `options.telemetry` to `false`.");
1747
+ sentryHub.addBreadcrumb({
1748
+ level: "info",
1749
+ message: "Telemetry enabled."
1750
+ });
1751
+ } else {
1752
+ sentryHub.addBreadcrumb({
1753
+ level: "info",
1754
+ message: "Telemetry disabled. This should never show up in a Sentry event."
1755
+ });
1660
1756
  }
1661
1757
 
1662
1758
  _context.next = 7;
@@ -1667,7 +1763,7 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
1667
1763
 
1668
1764
  // At this point, we either have determined a release or we have to bail
1669
1765
  if (!releaseName) {
1670
- 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);
1766
+ 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);
1671
1767
  }
1672
1768
 
1673
1769
  transaction = sentryHub.startTransaction({
@@ -1910,21 +2006,21 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
1910
2006
 
1911
2007
  case 21:
1912
2008
  (_transaction = transaction) === null || _transaction === void 0 ? void 0 : _transaction.setStatus("ok");
1913
- _context3.next = 28;
2009
+ _context3.next = 29;
1914
2010
  break;
1915
2011
 
1916
2012
  case 24:
1917
2013
  _context3.prev = 24;
1918
2014
  _context3.t0 = _context3["catch"](8);
1919
2015
  (_transaction2 = transaction) === null || _transaction2 === void 0 ? void 0 : _transaction2.setStatus("cancelled");
1920
- handleError(_context3.t0, logger, internalOptions.errorHandler, sentryHub);
1921
-
1922
- case 28:
1923
- _context3.prev = 28;
1924
2016
  sentryHub.addBreadcrumb({
1925
- category: "writeBundle:finish",
1926
- level: "info"
2017
+ level: "error",
2018
+ message: "Error during writeBundle"
1927
2019
  });
2020
+ handleError(_context3.t0, logger, internalOptions.errorHandler);
2021
+
2022
+ case 29:
2023
+ _context3.prev = 29;
1928
2024
  releasePipelineSpan === null || releasePipelineSpan === void 0 ? void 0 : releasePipelineSpan.finish();
1929
2025
  (_transaction3 = transaction) === null || _transaction3 === void 0 ? void 0 : _transaction3.finish();
1930
2026
  _context3.next = 34;
@@ -1933,30 +2029,32 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
1933
2029
  });
1934
2030
 
1935
2031
  case 34:
1936
- return _context3.finish(28);
2032
+ return _context3.finish(29);
1937
2033
 
1938
2034
  case 35:
2035
+ sentryHub.addBreadcrumb({
2036
+ category: "writeBundle:finish",
2037
+ level: "info"
2038
+ });
2039
+
2040
+ case 36:
1939
2041
  case "end":
1940
2042
  return _context3.stop();
1941
2043
  }
1942
2044
  }
1943
- }, _callee3, null, [[8, 24, 28, 35]]);
2045
+ }, _callee3, null, [[8, 24, 29, 35]]);
1944
2046
  }))();
1945
2047
  }
1946
2048
  };
1947
2049
  });
1948
2050
 
1949
- function handleError(unknownError, logger, errorHandler, sentryHub) {
2051
+ function handleError(unknownError, logger, errorHandler) {
1950
2052
  if (unknownError instanceof Error) {
1951
2053
  logger.error(unknownError.message);
1952
2054
  } else {
1953
2055
  logger.error(String(unknownError));
1954
2056
  }
1955
2057
 
1956
- if (sentryHub) {
1957
- captureMinimalError(unknownError, sentryHub);
1958
- }
1959
-
1960
2058
  if (errorHandler) {
1961
2059
  if (unknownError instanceof Error) {
1962
2060
  errorHandler(unknownError);