@sentry/bundler-plugin-core 2.16.1 → 2.18.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.
@@ -590,7 +590,11 @@ function determineReleaseName() {
590
590
  // Zeit (now known as Vercel)
591
591
  process.env["ZEIT_GITHUB_COMMIT_SHA"] || process.env["ZEIT_GITLAB_COMMIT_SHA"] || process.env["ZEIT_BITBUCKET_COMMIT_SHA"] ||
592
592
  // Flightcontrol - https://www.flightcontrol.dev/docs/guides/flightcontrol/environment-variables#built-in-environment-variables
593
- process.env["FC_GIT_COMMIT_SHA"] || gitRevision()
593
+ process.env["FC_GIT_COMMIT_SHA"] ||
594
+ // Heroku #1 https://devcenter.heroku.com/changelog-items/630
595
+ process.env["SOURCE_VERSION"] ||
596
+ // Heroku #2 https://docs.sentry.io/product/integrations/deployment/heroku/#configure-releases
597
+ process.env["HEROKU_SLUG_COMMIT"] || gitRevision()
594
598
  );
595
599
  }
596
600
 
@@ -615,7 +619,8 @@ function generateGlobalInjectorCode(_ref2) {
615
619
  function generateModuleMetadataInjectorCode(metadata) {
616
620
  // The code below is mostly ternary operators because it saves bundle size.
617
621
  // The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
618
- 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), ";");
622
+ // We are merging the metadata objects in case modules are bundled twice with the plugin
623
+ return "{\n var _sentryModuleMetadataGlobal =\n typeof window !== \"undefined\"\n ? window\n : typeof global !== \"undefined\"\n ? global\n : typeof self !== \"undefined\"\n ? self\n : {};\n\n _sentryModuleMetadataGlobal._sentryModuleMetadata =\n _sentryModuleMetadataGlobal._sentryModuleMetadata || {};\n\n _sentryModuleMetadataGlobal._sentryModuleMetadata[new Error().stack] =\n Object.assign(\n {},\n _sentryModuleMetadataGlobal._sentryModuleMetadata[new Error().stack],\n ".concat(JSON.stringify(metadata), "\n );\n}");
619
624
  }
620
625
  function getBuildInformation$1() {
621
626
  var packageJson = getPackageJson();
@@ -656,7 +661,7 @@ function replaceBooleanFlagsInCode(code, replacementValues) {
656
661
 
657
662
  var SENTRY_SAAS_URL = "https://sentry.io";
658
663
  function normalizeUserOptions(userOptions) {
659
- var _userOptions$org, _userOptions$project, _userOptions$authToke, _ref, _userOptions$url, _userOptions$debug, _userOptions$silent, _userOptions$telemetr, _userOptions$disable, _ref2, _userOptions$release$, _userOptions$release, _userOptions$release$2, _userOptions$release2, _userOptions$release$3, _userOptions$release3, _userOptions$release$4, _userOptions$release4, _ref3, _userOptions$release$5, _userOptions$release5, _userOptions$release$6, _userOptions$release6, _userOptions$_experim;
664
+ var _userOptions$org, _userOptions$project, _userOptions$authToke, _ref, _userOptions$url, _userOptions$debug, _userOptions$silent, _userOptions$telemetr, _userOptions$disable, _ref2, _userOptions$release$, _userOptions$release, _userOptions$release$2, _userOptions$release2, _userOptions$release$3, _userOptions$release3, _userOptions$release$4, _userOptions$release4, _ref3, _userOptions$release$5, _userOptions$release5, _userOptions$_metaOpt, _userOptions$_metaOpt2, _userOptions$_experim, _userOptions$_experim2;
660
665
  var options = {
661
666
  org: (_userOptions$org = userOptions.org) !== null && _userOptions$org !== void 0 ? _userOptions$org : process.env["SENTRY_ORG"],
662
667
  project: (_userOptions$project = userOptions.project) !== null && _userOptions$project !== void 0 ? _userOptions$project : process.env["SENTRY_PROJECT"],
@@ -674,12 +679,18 @@ function normalizeUserOptions(userOptions) {
674
679
  inject: (_userOptions$release$2 = (_userOptions$release2 = userOptions.release) === null || _userOptions$release2 === void 0 ? void 0 : _userOptions$release2.inject) !== null && _userOptions$release$2 !== void 0 ? _userOptions$release$2 : true,
675
680
  create: (_userOptions$release$3 = (_userOptions$release3 = userOptions.release) === null || _userOptions$release3 === void 0 ? void 0 : _userOptions$release3.create) !== null && _userOptions$release$3 !== void 0 ? _userOptions$release$3 : true,
676
681
  finalize: (_userOptions$release$4 = (_userOptions$release4 = userOptions.release) === null || _userOptions$release4 === void 0 ? void 0 : _userOptions$release4.finalize) !== null && _userOptions$release$4 !== void 0 ? _userOptions$release$4 : true,
677
- vcsRemote: (_ref3 = (_userOptions$release$5 = (_userOptions$release5 = userOptions.release) === null || _userOptions$release5 === void 0 ? void 0 : _userOptions$release5.vcsRemote) !== null && _userOptions$release$5 !== void 0 ? _userOptions$release$5 : process.env["SENTRY_VSC_REMOTE"]) !== null && _ref3 !== void 0 ? _ref3 : "origin",
678
- cleanArtifacts: (_userOptions$release$6 = (_userOptions$release6 = userOptions.release) === null || _userOptions$release6 === void 0 ? void 0 : _userOptions$release6.cleanArtifacts) !== null && _userOptions$release$6 !== void 0 ? _userOptions$release$6 : false
682
+ vcsRemote: (_ref3 = (_userOptions$release$5 = (_userOptions$release5 = userOptions.release) === null || _userOptions$release5 === void 0 ? void 0 : _userOptions$release5.vcsRemote) !== null && _userOptions$release$5 !== void 0 ? _userOptions$release$5 : process.env["SENTRY_VSC_REMOTE"]) !== null && _ref3 !== void 0 ? _ref3 : "origin"
679
683
  }),
680
684
  bundleSizeOptimizations: userOptions.bundleSizeOptimizations,
681
685
  reactComponentAnnotation: userOptions.reactComponentAnnotation,
682
- _experiments: (_userOptions$_experim = userOptions._experiments) !== null && _userOptions$_experim !== void 0 ? _userOptions$_experim : {}
686
+ _metaOptions: {
687
+ telemetry: {
688
+ metaFramework: (_userOptions$_metaOpt = userOptions._metaOptions) === null || _userOptions$_metaOpt === void 0 ? void 0 : (_userOptions$_metaOpt2 = _userOptions$_metaOpt.telemetry) === null || _userOptions$_metaOpt2 === void 0 ? void 0 : _userOptions$_metaOpt2.metaFramework
689
+ }
690
+ },
691
+ applicationKey: userOptions.applicationKey,
692
+ moduleMetadata: userOptions.moduleMetadata || ((_userOptions$_experim = userOptions._experiments) === null || _userOptions$_experim === void 0 ? void 0 : _userOptions$_experim.moduleMetadata),
693
+ _experiments: (_userOptions$_experim2 = userOptions._experiments) !== null && _userOptions$_experim2 !== void 0 ? _userOptions$_experim2 : {}
683
694
  };
684
695
  return options;
685
696
  }
@@ -13561,7 +13572,7 @@ function createSentryInstance(options, shouldSendTelemetry, bundler) {
13561
13572
  dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
13562
13573
  tracesSampleRate: 1,
13563
13574
  sampleRate: 1,
13564
- release: "2.16.1",
13575
+ release: "2.18.0",
13565
13576
  integrations: [],
13566
13577
  tracePropagationTargets: ["sentry.io/api"],
13567
13578
  stackParser: defaultStackParser,
@@ -13622,6 +13633,7 @@ function createSentryInstance(options, shouldSendTelemetry, bundler) {
13622
13633
  };
13623
13634
  }
13624
13635
  function setTelemetryDataOnHub(options, hub, bundler) {
13636
+ var _options$_metaOptions;
13625
13637
  var org = options.org,
13626
13638
  project = options.project,
13627
13639
  release = options.release,
@@ -13632,11 +13644,10 @@ function setTelemetryDataOnHub(options, hub, bundler) {
13632
13644
  if (release.uploadLegacySourcemaps) {
13633
13645
  hub.setTag("uploadLegacySourcemapsEntries", Array.isArray(release.uploadLegacySourcemaps) ? release.uploadLegacySourcemaps.length : 1);
13634
13646
  }
13635
- hub.setTag("module-metadata", !!options._experiments.moduleMetadata);
13647
+ hub.setTag("module-metadata", !!options.moduleMetadata);
13636
13648
  hub.setTag("inject-build-information", !!options._experiments.injectBuildInformation);
13637
13649
 
13638
13650
  // Optional release pipeline steps
13639
- hub.setTag("clean-artifacts", release.cleanArtifacts);
13640
13651
  if (release.setCommits) {
13641
13652
  hub.setTag("set-commits", release.setCommits.auto === true ? "auto" : "manual");
13642
13653
  } else {
@@ -13652,6 +13663,7 @@ function setTelemetryDataOnHub(options, hub, bundler) {
13652
13663
  hub.setTag("react-annotate", !!(reactComponentAnnotation !== null && reactComponentAnnotation !== void 0 && reactComponentAnnotation.enabled));
13653
13664
  hub.setTag("node", process.version);
13654
13665
  hub.setTag("platform", process.platform);
13666
+ hub.setTag("meta-framework", (_options$_metaOptions = options._metaOptions.telemetry.metaFramework) !== null && _options$_metaOptions !== void 0 ? _options$_metaOptions : "none");
13655
13667
  hub.setTags({
13656
13668
  organization: org,
13657
13669
  project: project,
@@ -14223,7 +14235,6 @@ function releaseManagementPlugin(_ref) {
14223
14235
  dist = _ref.dist,
14224
14236
  setCommitsOption = _ref.setCommitsOption,
14225
14237
  shouldCreateRelease = _ref.shouldCreateRelease,
14226
- shouldCleanArtifacts = _ref.shouldCleanArtifacts,
14227
14238
  shouldFinalizeRelease = _ref.shouldFinalizeRelease,
14228
14239
  deployOptions = _ref.deployOptions,
14229
14240
  handleRecoverableError = _ref.handleRecoverableError,
@@ -14247,15 +14258,8 @@ function releaseManagementPlugin(_ref) {
14247
14258
  _context.next = 5;
14248
14259
  return cliInstance.releases["new"](releaseName);
14249
14260
  case 5:
14250
- if (!shouldCleanArtifacts) {
14251
- _context.next = 8;
14252
- break;
14253
- }
14254
- _context.next = 8;
14255
- return cliInstance.releases.execute(["releases", "files", releaseName, "delete", "--all"], true);
14256
- case 8:
14257
14261
  if (!include) {
14258
- _context.next = 12;
14262
+ _context.next = 9;
14259
14263
  break;
14260
14264
  }
14261
14265
  normalizedInclude = arrayify$1(include).map(function (includeItem) {
@@ -14272,48 +14276,48 @@ function releaseManagementPlugin(_ref) {
14272
14276
  ignore: includeEntry.ignore ? arrayify$1(includeEntry.ignore) : undefined
14273
14277
  });
14274
14278
  });
14275
- _context.next = 12;
14279
+ _context.next = 9;
14276
14280
  return cliInstance.releases.uploadSourceMaps(releaseName, {
14277
14281
  include: normalizedInclude,
14278
14282
  dist: dist
14279
14283
  });
14280
- case 12:
14284
+ case 9:
14281
14285
  if (!setCommitsOption) {
14282
- _context.next = 15;
14286
+ _context.next = 12;
14283
14287
  break;
14284
14288
  }
14285
- _context.next = 15;
14289
+ _context.next = 12;
14286
14290
  return cliInstance.releases.setCommits(releaseName, setCommitsOption);
14287
- case 15:
14291
+ case 12:
14288
14292
  if (!shouldFinalizeRelease) {
14289
- _context.next = 18;
14293
+ _context.next = 15;
14290
14294
  break;
14291
14295
  }
14292
- _context.next = 18;
14296
+ _context.next = 15;
14293
14297
  return cliInstance.releases.finalize(releaseName);
14294
- case 18:
14298
+ case 15:
14295
14299
  if (!deployOptions) {
14296
- _context.next = 21;
14300
+ _context.next = 18;
14297
14301
  break;
14298
14302
  }
14299
- _context.next = 21;
14303
+ _context.next = 18;
14300
14304
  return cliInstance.releases.newDeploy(releaseName, deployOptions);
14301
- case 21:
14302
- _context.next = 29;
14305
+ case 18:
14306
+ _context.next = 26;
14303
14307
  break;
14304
- case 23:
14305
- _context.prev = 23;
14308
+ case 20:
14309
+ _context.prev = 20;
14306
14310
  _context.t0 = _context["catch"](0);
14307
14311
  sentryHub.captureException('Error in "releaseManagementPlugin" writeBundle hook');
14308
- _context.next = 28;
14312
+ _context.next = 25;
14309
14313
  return safeFlushTelemetry(sentryClient);
14310
- case 28:
14314
+ case 25:
14311
14315
  handleRecoverableError(_context.t0);
14312
- case 29:
14316
+ case 26:
14313
14317
  case "end":
14314
14318
  return _context.stop();
14315
14319
  }
14316
- }, _callee, null, [[0, 23]]);
14320
+ }, _callee, null, [[0, 20]]);
14317
14321
  }))();
14318
14322
  }
14319
14323
  };
@@ -14418,11 +14422,10 @@ function createLogger(options) {
14418
14422
  * release creation pipeline:
14419
14423
  *
14420
14424
  * 1. Create a new release
14421
- * 2. Delete already uploaded artifacts for this release (if `cleanArtifacts` is enabled)
14422
- * 3. Upload sourcemaps based on `include` and source-map-specific options
14423
- * 4. Associate a range of commits with the release (if `setCommits` is specified)
14424
- * 5. Finalize the release (unless `finalize` is disabled)
14425
- * 6. Add deploy information to the release (if `deploy` is specified)
14425
+ * 2. Upload sourcemaps based on `include` and source-map-specific options
14426
+ * 3. Associate a range of commits with the release (if `setCommits` is specified)
14427
+ * 4. Finalize the release (unless `finalize` is disabled)
14428
+ * 5. Add deploy information to the release (if `deploy` is specified)
14426
14429
  *
14427
14430
  * This release creation pipeline relies on Sentry CLI to execute the different steps.
14428
14431
  */
@@ -14434,7 +14437,7 @@ function sentryUnpluginFactory(_ref) {
14434
14437
  debugIdUploadPlugin = _ref.debugIdUploadPlugin,
14435
14438
  bundleSizeOptimizationsPlugin = _ref.bundleSizeOptimizationsPlugin;
14436
14439
  return createUnplugin(function () {
14437
- var _userOptions$_metaOpt, _userOptions$_metaOpt2, _userOptions$silent, _userOptions$debug;
14440
+ var _userOptions$_metaOpt, _userOptions$_metaOpt2, _userOptions$silent, _userOptions$debug, _userOptions$_experim;
14438
14441
  var userOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
14439
14442
  var unpluginMetaContext = arguments.length > 1 ? arguments[1] : undefined;
14440
14443
  var logger = createLogger({
@@ -14455,6 +14458,11 @@ function sentryUnpluginFactory(_ref) {
14455
14458
  }
14456
14459
  }
14457
14460
  var options = normalizeUserOptions(userOptions);
14461
+
14462
+ // TODO(v3): Remove this warning
14463
+ if ((_userOptions$_experim = userOptions._experiments) !== null && _userOptions$_experim !== void 0 && _userOptions$_experim.moduleMetadata) {
14464
+ logger.warn("The `_experiments.moduleMetadata` option has been promoted to being stable. You can safely move the option out of the `_experiments` object scope.");
14465
+ }
14458
14466
  if (unpluginMetaContext.watchMode || options.disable) {
14459
14467
  return [{
14460
14468
  name: "sentry-noop-plugin"
@@ -14476,7 +14484,7 @@ function sentryUnpluginFactory(_ref) {
14476
14484
  });
14477
14485
 
14478
14486
  // Set the User-Agent that Sentry CLI will use when interacting with Sentry
14479
- process.env["SENTRY_PIPELINE"] = "".concat(unpluginMetaContext.framework, "-plugin/", "2.16.1");
14487
+ process.env["SENTRY_PIPELINE"] = "".concat(unpluginMetaContext.framework, "-plugin/", "2.18.0");
14480
14488
  function handleRecoverableError(unknownError) {
14481
14489
  sentrySession.status = "abnormal";
14482
14490
  try {
@@ -14548,24 +14556,31 @@ function sentryUnpluginFactory(_ref) {
14548
14556
  });
14549
14557
  plugins.push(releaseInjectionPlugin(_injectionCode));
14550
14558
  }
14551
- if (moduleMetadataInjectionPlugin && options._experiments.moduleMetadata) {
14552
- var metadata;
14553
- if (typeof options._experiments.moduleMetadata === "function") {
14559
+ if (options.moduleMetadata || options.applicationKey) {
14560
+ var metadata = {};
14561
+ if (options.applicationKey) {
14562
+ // We use different keys so that if user-code receives multiple bundling passes, we will store the application keys of all the passes.
14563
+ // It is a bit unfortunate that we have to inject the metadata snippet at the top, because after multiple
14564
+ // injections, the first injection will always "win" because it comes last in the code. We would generally be
14565
+ // fine with making the last bundling pass win. But because it cannot win, we have to use a workaround of storing
14566
+ // the app keys in different object keys.
14567
+ // We can simply use the `_sentryBundlerPluginAppKey:` to filter for app keys in the SDK.
14568
+ metadata["_sentryBundlerPluginAppKey:".concat(options.applicationKey)] = true;
14569
+ }
14570
+ if (typeof options.moduleMetadata === "function") {
14554
14571
  var args = {
14555
14572
  org: options.org,
14556
14573
  project: options.project,
14557
14574
  release: options.release.name
14558
14575
  };
14559
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
14560
- metadata = options._experiments.moduleMetadata(args);
14576
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
14577
+ metadata = _objectSpread2(_objectSpread2({}, metadata), options.moduleMetadata(args));
14561
14578
  } else {
14562
14579
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
14563
- metadata = options._experiments.moduleMetadata;
14580
+ metadata = _objectSpread2(_objectSpread2({}, metadata), options.moduleMetadata);
14564
14581
  }
14565
14582
  var _injectionCode2 = generateModuleMetadataInjectorCode(metadata);
14566
14583
  plugins.push(moduleMetadataInjectionPlugin(_injectionCode2));
14567
- } else if (options._experiments.moduleMetadata) {
14568
- logger.warn("'moduleMetadata' is currently only supported by '@sentry/webpack-plugin'");
14569
14584
  }
14570
14585
  if (!options.release.name) {
14571
14586
  logger.warn("No release name provided. Will not create release. Please set the `release.name` option to identify your release.");
@@ -14580,7 +14595,6 @@ function sentryUnpluginFactory(_ref) {
14580
14595
  logger: logger,
14581
14596
  releaseName: options.release.name,
14582
14597
  shouldCreateRelease: options.release.create,
14583
- shouldCleanArtifacts: options.release.cleanArtifacts,
14584
14598
  shouldFinalizeRelease: options.release.finalize,
14585
14599
  include: options.release.uploadLegacySourcemaps,
14586
14600
  setCommitsOption: options.release.setCommits,
@@ -14600,7 +14614,7 @@ function sentryUnpluginFactory(_ref) {
14600
14614
  }
14601
14615
  }));
14602
14616
  }
14603
- plugins.push(debugIdInjectionPlugin());
14617
+ plugins.push(debugIdInjectionPlugin(logger));
14604
14618
  if (!options.authToken) {
14605
14619
  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/");
14606
14620
  } else if (!options.org && !options.authToken.startsWith("sntrys_")) {