@sentry/bundler-plugin-core 2.4.0 → 2.6.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/dist/cjs/index.js CHANGED
@@ -619,6 +619,13 @@ function generateGlobalInjectorCode(_ref2) {
619
619
  }
620
620
  return code;
621
621
  }
622
+
623
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
624
+ function generateModuleMetadataInjectorCode(metadata) {
625
+ // The code below is mostly ternary operators because it saves bundle size.
626
+ // The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
627
+ return "\n var _global2 =\n typeof window !== 'undefined' ?\n window :\n typeof global !== 'undefined' ?\n global :\n typeof self !== 'undefined' ?\n self :\n {};\n\n _global2._sentryModuleMetadata = _global2._sentryModuleMetadata || {};\n _global2._sentryModuleMetadata[new Error().stack] = ".concat(JSON.stringify(metadata), ";");
628
+ }
622
629
  function getBuildInformation$1() {
623
630
  var packageJson = getPackageJson();
624
631
  var _ref3 = packageJson ? getDependencies(packageJson) : {
@@ -1293,7 +1300,7 @@ function createSentryInstance(options, shouldSendTelemetry, bundler) {
1293
1300
  dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
1294
1301
  tracesSampleRate: 1,
1295
1302
  sampleRate: 1,
1296
- release: "2.4.0",
1303
+ release: "2.6.0",
1297
1304
  integrations: [],
1298
1305
  tracePropagationTargets: ["sentry.io/api"],
1299
1306
  stackParser: node.defaultStackParser,
@@ -1479,6 +1486,7 @@ function _allowedToSendTelemetry() {
1479
1486
  */
1480
1487
  function sentryUnpluginFactory(_ref) {
1481
1488
  var releaseInjectionPlugin = _ref.releaseInjectionPlugin,
1489
+ moduleMetadataInjectionPlugin = _ref.moduleMetadataInjectionPlugin,
1482
1490
  debugIdInjectionPlugin = _ref.debugIdInjectionPlugin,
1483
1491
  debugIdUploadPlugin = _ref.debugIdUploadPlugin;
1484
1492
  return unplugin.createUnplugin(function (userOptions, unpluginMetaContext) {
@@ -1522,7 +1530,7 @@ function sentryUnpluginFactory(_ref) {
1522
1530
  });
1523
1531
 
1524
1532
  // Set the User-Agent that Sentry CLI will use when interacting with Sentry
1525
- process.env["SENTRY_PIPELINE"] = "".concat(unpluginMetaContext.framework, "-plugin/", "2.4.0");
1533
+ process.env["SENTRY_PIPELINE"] = "".concat(unpluginMetaContext.framework, "-plugin/", "2.6.0");
1526
1534
  function handleRecoverableError(unknownError) {
1527
1535
  sentrySession.status = "abnormal";
1528
1536
  try {
@@ -1561,7 +1569,7 @@ function sentryUnpluginFactory(_ref) {
1561
1569
  if (!options.release.inject) {
1562
1570
  logger.debug("Release injection disabled via `release.inject` option. Will not inject release.");
1563
1571
  } else if (!options.release.name) {
1564
- logger.warn("No release name provided. Will not inject release. Please set the `release.name` option to identifiy your release.");
1572
+ logger.warn("No release name provided. Will not inject release. Please set the `release.name` option to identify your release.");
1565
1573
  } else {
1566
1574
  var _injectionCode = generateGlobalInjectorCode({
1567
1575
  release: options.release.name,
@@ -1569,11 +1577,30 @@ function sentryUnpluginFactory(_ref) {
1569
1577
  });
1570
1578
  plugins.push(releaseInjectionPlugin(_injectionCode));
1571
1579
  }
1580
+ if (moduleMetadataInjectionPlugin && options._experiments.moduleMetadata) {
1581
+ var metadata;
1582
+ if (typeof options._experiments.moduleMetadata === "function") {
1583
+ var args = {
1584
+ org: options.org,
1585
+ project: options.project,
1586
+ release: options.release.name
1587
+ };
1588
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
1589
+ metadata = options._experiments.moduleMetadata(args);
1590
+ } else {
1591
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1592
+ metadata = options._experiments.moduleMetadata;
1593
+ }
1594
+ var _injectionCode2 = generateModuleMetadataInjectorCode(metadata);
1595
+ plugins.push(moduleMetadataInjectionPlugin(_injectionCode2));
1596
+ } else if (options._experiments.moduleMetadata) {
1597
+ logger.warn("'moduleMetadata' is currently only supported by '@sentry/webpack-plugin'");
1598
+ }
1572
1599
  if (!options.release.name) {
1573
- logger.warn("No release name provided. Will not create release. Please set the `release.name` option to identifiy your release.");
1600
+ logger.warn("No release name provided. Will not create release. Please set the `release.name` option to identify your release.");
1574
1601
  } else if (!options.authToken) {
1575
1602
  logger.warn("No auth token provided. Will not create release. Please set the `authToken` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/");
1576
- } else if (!options.org) {
1603
+ } else if (!options.org && !options.authToken.startsWith("sntrys_")) {
1577
1604
  logger.warn("No organization slug provided. Will not create release. Please set the `org` option to your Sentry organization slug.");
1578
1605
  } else if (!options.project) {
1579
1606
  logger.warn("No project provided. Will not create release. Please set the `project` option to your Sentry project slug.");
@@ -1605,7 +1632,7 @@ function sentryUnpluginFactory(_ref) {
1605
1632
  plugins.push(debugIdInjectionPlugin());
1606
1633
  if (!options.authToken) {
1607
1634
  logger.warn("No auth token provided. Will not upload source maps. Please set the `authToken` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/");
1608
- } else if (!options.org) {
1635
+ } else if (!options.org && !options.authToken.startsWith("sntrys_")) {
1609
1636
  logger.warn("No org provided. Will not upload source maps. Please set the `org` option to your Sentry organization slug.");
1610
1637
  } else if (!options.project) {
1611
1638
  logger.warn("No project provided. Will not upload source maps. Please set the `project` option to your Sentry project slug.");
@@ -1758,35 +1785,40 @@ function createRollupDebugIdUploadHooks(upload) {
1758
1785
  while (1) switch (_context.prev = _context.next) {
1759
1786
  case 0:
1760
1787
  if (!outputOptions.dir) {
1761
- _context.next = 7;
1788
+ _context.next = 9;
1762
1789
  break;
1763
1790
  }
1764
1791
  outputDir = outputOptions.dir;
1765
- _buildArtifacts = Object.keys(bundle).map(function (asset) {
1766
- return path__namespace.join(outputDir, asset);
1792
+ _context.next = 4;
1793
+ return glob.glob(["/**/*.js", "/**/*.js.map"], {
1794
+ root: outputDir,
1795
+ absolute: true,
1796
+ nodir: true
1767
1797
  });
1768
- _context.next = 5;
1798
+ case 4:
1799
+ _buildArtifacts = _context.sent;
1800
+ _context.next = 7;
1769
1801
  return upload(_buildArtifacts);
1770
- case 5:
1771
- _context.next = 15;
1772
- break;
1773
1802
  case 7:
1803
+ _context.next = 17;
1804
+ break;
1805
+ case 9:
1774
1806
  if (!outputOptions.file) {
1775
- _context.next = 12;
1807
+ _context.next = 14;
1776
1808
  break;
1777
1809
  }
1778
- _context.next = 10;
1810
+ _context.next = 12;
1779
1811
  return upload([outputOptions.file]);
1780
- case 10:
1781
- _context.next = 15;
1782
- break;
1783
1812
  case 12:
1813
+ _context.next = 17;
1814
+ break;
1815
+ case 14:
1784
1816
  _buildArtifacts2 = Object.keys(bundle).map(function (asset) {
1785
1817
  return path__namespace.join(path__namespace.resolve(), asset);
1786
1818
  });
1787
- _context.next = 15;
1819
+ _context.next = 17;
1788
1820
  return upload(_buildArtifacts2);
1789
- case 15:
1821
+ case 17:
1790
1822
  case "end":
1791
1823
  return _context.stop();
1792
1824
  }