@sentry/bundler-plugin-core 2.17.0 → 2.19.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.
@@ -572,30 +572,77 @@ function gitRevision() {
572
572
  * Tries to guess a release name based on environmental data.
573
573
  */
574
574
  function determineReleaseName() {
575
- return (
576
- // GitHub Actions - https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
577
- process.env["GITHUB_SHA"] ||
578
- // Netlify - https://docs.netlify.com/configure-builds/environment-variables/#build-metadata
579
- process.env["COMMIT_REF"] ||
580
- // Cloudflare Pages - https://developers.cloudflare.com/pages/platform/build-configuration/#environment-variables
581
- process.env["CF_PAGES_COMMIT_SHA"] ||
582
- // AWS CodeBuild - https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
583
- process.env["CODEBUILD_RESOLVED_SOURCE_VERSION"] ||
584
- // Bitbucket - https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/
585
- process.env["BITBUCKET_COMMIT"] ||
586
- // CircleCI - https://circleci.com/docs/2.0/env-vars/
587
- process.env["CIRCLE_SHA1"] ||
588
- // Vercel - https://vercel.com/docs/v2/build-step#system-environment-variables
589
- process.env["VERCEL_GIT_COMMIT_SHA"] || process.env["VERCEL_GITHUB_COMMIT_SHA"] || process.env["VERCEL_GITLAB_COMMIT_SHA"] || process.env["VERCEL_BITBUCKET_COMMIT_SHA"] ||
590
- // Zeit (now known as Vercel)
591
- process.env["ZEIT_GITHUB_COMMIT_SHA"] || process.env["ZEIT_GITLAB_COMMIT_SHA"] || process.env["ZEIT_BITBUCKET_COMMIT_SHA"] ||
592
- // Flightcontrol - https://www.flightcontrol.dev/docs/guides/flightcontrol/environment-variables#built-in-environment-variables
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()
598
- );
575
+ // This list is in approximate alpha order, separated into 3 categories:
576
+ // 1. Git providers
577
+ // 2. CI providers with specific environment variables (has the provider name in the variable name)
578
+ // 3. CI providers with generic environment variables (checked for last to prevent possible false positives)
579
+
580
+ var possibleReleaseNameOfGitProvider =
581
+ // GitHub Actions - https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
582
+ process.env["GITHUB_SHA"] ||
583
+ // GitLab CI - https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
584
+ process.env["CI_MERGE_REQUEST_SOURCE_BRANCH_SHA"] || process.env["CI_BUILD_REF"] || process.env["CI_COMMIT_SHA"] ||
585
+ // Bitbucket - https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/
586
+ process.env["BITBUCKET_COMMIT"];
587
+ var possibleReleaseNameOfCiProvidersWithSpecificEnvVar =
588
+ // AppVeyor - https://www.appveyor.com/docs/environment-variables/
589
+ process.env["APPVEYOR_PULL_REQUEST_HEAD_COMMIT"] || process.env["APPVEYOR_REPO_COMMIT"] ||
590
+ // AWS CodeBuild - https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
591
+ process.env["CODEBUILD_RESOLVED_SOURCE_VERSION"] ||
592
+ // AWS Amplify - https://docs.aws.amazon.com/amplify/latest/userguide/environment-variables.html
593
+ process.env["AWS_COMMIT_ID"] ||
594
+ // Azure Pipelines - https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml
595
+ process.env["BUILD_SOURCEVERSION"] ||
596
+ // Bitrise - https://devcenter.bitrise.io/builds/available-environment-variables/
597
+ process.env["GIT_CLONE_COMMIT_HASH"] ||
598
+ // Buddy CI - https://buddy.works/docs/pipelines/environment-variables#default-environment-variables
599
+ process.env["BUDDY_EXECUTION_REVISION"] ||
600
+ // Builtkite - https://buildkite.com/docs/pipelines/environment-variables
601
+ process.env["BUILDKITE_COMMIT"] ||
602
+ // CircleCI - https://circleci.com/docs/variables/
603
+ process.env["CIRCLE_SHA1"] ||
604
+ // Cirrus CI - https://cirrus-ci.org/guide/writing-tasks/#environment-variables
605
+ process.env["CIRRUS_CHANGE_IN_REPO"] ||
606
+ // Codefresh - https://codefresh.io/docs/docs/codefresh-yaml/variables/
607
+ process.env["CF_REVISION"] ||
608
+ // Codemagic - https://docs.codemagic.io/yaml-basic-configuration/environment-variables/
609
+ process.env["CM_COMMIT"] ||
610
+ // Cloudflare Pages - https://developers.cloudflare.com/pages/platform/build-configuration/#environment-variables
611
+ process.env["CF_PAGES_COMMIT_SHA"] ||
612
+ // Drone - https://docs.drone.io/pipeline/environment/reference/
613
+ process.env["DRONE_COMMIT_SHA"] ||
614
+ // Flightcontrol - https://www.flightcontrol.dev/docs/guides/flightcontrol/environment-variables#built-in-environment-variables
615
+ process.env["FC_GIT_COMMIT_SHA"] ||
616
+ // Heroku #1 https://devcenter.heroku.com/articles/heroku-ci
617
+ process.env["HEROKU_TEST_RUN_COMMIT_VERSION"] ||
618
+ // Heroku #2 https://docs.sentry.io/product/integrations/deployment/heroku/#configure-releases
619
+ process.env["HEROKU_SLUG_COMMIT"] ||
620
+ // Render - https://render.com/docs/environment-variables
621
+ process.env["RENDER_GIT_COMMIT"] ||
622
+ // Semaphore CI - https://docs.semaphoreci.com/ci-cd-environment/environment-variables
623
+ process.env["SEMAPHORE_GIT_SHA"] ||
624
+ // TravisCI - https://docs.travis-ci.com/user/environment-variables/#default-environment-variables
625
+ process.env["TRAVIS_PULL_REQUEST_SHA"] ||
626
+ // Vercel - https://vercel.com/docs/v2/build-step#system-environment-variables
627
+ process.env["VERCEL_GIT_COMMIT_SHA"] || process.env["VERCEL_GITHUB_COMMIT_SHA"] || process.env["VERCEL_GITLAB_COMMIT_SHA"] || process.env["VERCEL_BITBUCKET_COMMIT_SHA"] ||
628
+ // Zeit (now known as Vercel)
629
+ process.env["ZEIT_GITHUB_COMMIT_SHA"] || process.env["ZEIT_GITLAB_COMMIT_SHA"] || process.env["ZEIT_BITBUCKET_COMMIT_SHA"];
630
+ var possibleReleaseNameOfCiProvidersWithGenericEnvVar =
631
+ // CloudBees CodeShip - https://docs.cloudbees.com/docs/cloudbees-codeship/latest/pro-builds-and-configuration/environment-variables
632
+ process.env["CI_COMMIT_ID"] ||
633
+ // Coolify - https://coolify.io/docs/knowledge-base/environment-variables
634
+ process.env["SOURCE_COMMIT"] ||
635
+ // Heroku #3 https://devcenter.heroku.com/changelog-items/630
636
+ process.env["SOURCE_VERSION"] ||
637
+ // Jenkins - https://plugins.jenkins.io/git/#environment-variables
638
+ process.env["GIT_COMMIT"] ||
639
+ // Netlify - https://docs.netlify.com/configure-builds/environment-variables/#build-metadata
640
+ process.env["COMMIT_REF"] ||
641
+ // TeamCity - https://www.jetbrains.com/help/teamcity/predefined-build-parameters.html
642
+ process.env["BUILD_VCS_NUMBER"] ||
643
+ // Woodpecker CI - https://woodpecker-ci.org/docs/usage/environment
644
+ process.env["CI_COMMIT_SHA"];
645
+ return possibleReleaseNameOfGitProvider || possibleReleaseNameOfCiProvidersWithSpecificEnvVar || possibleReleaseNameOfCiProvidersWithGenericEnvVar || gitRevision();
599
646
  }
600
647
 
601
648
  /**
@@ -619,7 +666,8 @@ function generateGlobalInjectorCode(_ref2) {
619
666
  function generateModuleMetadataInjectorCode(metadata) {
620
667
  // The code below is mostly ternary operators because it saves bundle size.
621
668
  // The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
622
- 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), ";");
669
+ // We are merging the metadata objects in case modules are bundled twice with the plugin
670
+ 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}");
623
671
  }
624
672
  function getBuildInformation$1() {
625
673
  var packageJson = getPackageJson();
@@ -660,7 +708,7 @@ function replaceBooleanFlagsInCode(code, replacementValues) {
660
708
 
661
709
  var SENTRY_SAAS_URL = "https://sentry.io";
662
710
  function normalizeUserOptions(userOptions) {
663
- 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$_experim;
711
+ 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;
664
712
  var options = {
665
713
  org: (_userOptions$org = userOptions.org) !== null && _userOptions$org !== void 0 ? _userOptions$org : process.env["SENTRY_ORG"],
666
714
  project: (_userOptions$project = userOptions.project) !== null && _userOptions$project !== void 0 ? _userOptions$project : process.env["SENTRY_PROJECT"],
@@ -682,7 +730,14 @@ function normalizeUserOptions(userOptions) {
682
730
  }),
683
731
  bundleSizeOptimizations: userOptions.bundleSizeOptimizations,
684
732
  reactComponentAnnotation: userOptions.reactComponentAnnotation,
685
- _experiments: (_userOptions$_experim = userOptions._experiments) !== null && _userOptions$_experim !== void 0 ? _userOptions$_experim : {}
733
+ _metaOptions: {
734
+ telemetry: {
735
+ 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
736
+ }
737
+ },
738
+ applicationKey: userOptions.applicationKey,
739
+ moduleMetadata: userOptions.moduleMetadata || ((_userOptions$_experim = userOptions._experiments) === null || _userOptions$_experim === void 0 ? void 0 : _userOptions$_experim.moduleMetadata),
740
+ _experiments: (_userOptions$_experim2 = userOptions._experiments) !== null && _userOptions$_experim2 !== void 0 ? _userOptions$_experim2 : {}
686
741
  };
687
742
  return options;
688
743
  }
@@ -13564,7 +13619,7 @@ function createSentryInstance(options, shouldSendTelemetry, bundler) {
13564
13619
  dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
13565
13620
  tracesSampleRate: 1,
13566
13621
  sampleRate: 1,
13567
- release: "2.17.0",
13622
+ release: "2.19.0",
13568
13623
  integrations: [],
13569
13624
  tracePropagationTargets: ["sentry.io/api"],
13570
13625
  stackParser: defaultStackParser,
@@ -13625,6 +13680,7 @@ function createSentryInstance(options, shouldSendTelemetry, bundler) {
13625
13680
  };
13626
13681
  }
13627
13682
  function setTelemetryDataOnHub(options, hub, bundler) {
13683
+ var _options$_metaOptions;
13628
13684
  var org = options.org,
13629
13685
  project = options.project,
13630
13686
  release = options.release,
@@ -13635,7 +13691,7 @@ function setTelemetryDataOnHub(options, hub, bundler) {
13635
13691
  if (release.uploadLegacySourcemaps) {
13636
13692
  hub.setTag("uploadLegacySourcemapsEntries", Array.isArray(release.uploadLegacySourcemaps) ? release.uploadLegacySourcemaps.length : 1);
13637
13693
  }
13638
- hub.setTag("module-metadata", !!options._experiments.moduleMetadata);
13694
+ hub.setTag("module-metadata", !!options.moduleMetadata);
13639
13695
  hub.setTag("inject-build-information", !!options._experiments.injectBuildInformation);
13640
13696
 
13641
13697
  // Optional release pipeline steps
@@ -13654,6 +13710,7 @@ function setTelemetryDataOnHub(options, hub, bundler) {
13654
13710
  hub.setTag("react-annotate", !!(reactComponentAnnotation !== null && reactComponentAnnotation !== void 0 && reactComponentAnnotation.enabled));
13655
13711
  hub.setTag("node", process.version);
13656
13712
  hub.setTag("platform", process.platform);
13713
+ hub.setTag("meta-framework", (_options$_metaOptions = options._metaOptions.telemetry.metaFramework) !== null && _options$_metaOptions !== void 0 ? _options$_metaOptions : "none");
13657
13714
  hub.setTags({
13658
13715
  organization: org,
13659
13716
  project: project,
@@ -13764,10 +13821,10 @@ function createDebugIdUploadFunction(_ref) {
13764
13821
  sentryClient = _ref.sentryClient,
13765
13822
  sentryCliOptions = _ref.sentryCliOptions,
13766
13823
  rewriteSourcesHook = _ref.rewriteSourcesHook,
13767
- filesToDeleteAfterUpload = _ref.filesToDeleteAfterUpload;
13824
+ deleteFilesUpForDeletion = _ref.deleteFilesUpForDeletion;
13768
13825
  return /*#__PURE__*/function () {
13769
13826
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(buildArtifactPaths) {
13770
- var artifactBundleUploadTransaction, folderToCleanUp, mkdtempSpan, tmpUploadFolder, globAssets, globSpan, globResult, debugIdChunkFilePaths, prepareSpan, preparationTasks, workers, worker, workerIndex, files, stats, uploadSize, uploadSpan, cliInstance, deleteGlobSpan, filePathsToDelete, deleteSpan, cleanupSpan;
13827
+ var artifactBundleUploadTransaction, folderToCleanUp, mkdtempSpan, tmpUploadFolder, globAssets, globSpan, globResult, debugIdChunkFilePaths, prepareSpan, preparationTasks, workers, worker, workerIndex, files, stats, uploadSize, uploadSpan, cliInstance, cleanupSpan;
13771
13828
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
13772
13829
  while (1) switch (_context3.prev = _context3.next) {
13773
13830
  case 0:
@@ -13920,51 +13977,21 @@ function createDebugIdUploadFunction(_ref) {
13920
13977
  uploadSpan.finish();
13921
13978
  logger.info("Successfully uploaded source maps to Sentry");
13922
13979
  case 47:
13923
- if (!filesToDeleteAfterUpload) {
13924
- _context3.next = 58;
13925
- break;
13926
- }
13927
- deleteGlobSpan = artifactBundleUploadTransaction.startChild({
13928
- description: "delete-glob"
13929
- });
13930
- _context3.next = 51;
13931
- return glob(filesToDeleteAfterUpload, {
13932
- absolute: true,
13933
- nodir: true
13934
- });
13935
- case 51:
13936
- filePathsToDelete = _context3.sent;
13937
- deleteGlobSpan.finish();
13938
- filePathsToDelete.forEach(function (filePathToDelete) {
13939
- logger.debug("Deleting asset after upload: ".concat(filePathToDelete));
13940
- });
13941
- deleteSpan = artifactBundleUploadTransaction.startChild({
13942
- description: "delete-files-after-upload"
13943
- });
13944
- _context3.next = 57;
13945
- return Promise.all(filePathsToDelete.map(function (filePathToDelete) {
13946
- return fs__default.promises.rm(filePathToDelete, {
13947
- force: true
13948
- })["catch"](function (e) {
13949
- // This is allowed to fail - we just don't do anything
13950
- logger.debug("An error occured while attempting to delete asset: ".concat(filePathToDelete), e);
13951
- });
13952
- }));
13953
- case 57:
13954
- deleteSpan.finish();
13955
- case 58:
13956
- _context3.next = 64;
13980
+ _context3.next = 49;
13981
+ return deleteFilesUpForDeletion();
13982
+ case 49:
13983
+ _context3.next = 55;
13957
13984
  break;
13958
- case 60:
13959
- _context3.prev = 60;
13985
+ case 51:
13986
+ _context3.prev = 51;
13960
13987
  _context3.t0 = _context3["catch"](1);
13961
13988
  sentryHub.withScope(function (scope) {
13962
13989
  scope.setSpan(artifactBundleUploadTransaction);
13963
13990
  sentryHub.captureException('Error in "debugIdUploadPlugin" writeBundle hook');
13964
13991
  });
13965
13992
  handleRecoverableError(_context3.t0);
13966
- case 64:
13967
- _context3.prev = 64;
13993
+ case 55:
13994
+ _context3.prev = 55;
13968
13995
  if (folderToCleanUp) {
13969
13996
  cleanupSpan = artifactBundleUploadTransaction.startChild({
13970
13997
  description: "cleanup"
@@ -13976,15 +14003,15 @@ function createDebugIdUploadFunction(_ref) {
13976
14003
  cleanupSpan.finish();
13977
14004
  }
13978
14005
  artifactBundleUploadTransaction.finish();
13979
- _context3.next = 69;
14006
+ _context3.next = 60;
13980
14007
  return safeFlushTelemetry(sentryClient);
13981
- case 69:
13982
- return _context3.finish(64);
13983
- case 70:
14008
+ case 60:
14009
+ return _context3.finish(55);
14010
+ case 61:
13984
14011
  case "end":
13985
14012
  return _context3.stop();
13986
14013
  }
13987
- }, _callee3, null, [[1, 60, 64, 70]]);
14014
+ }, _callee3, null, [[1, 51, 55, 61]]);
13988
14015
  }));
13989
14016
  return function (_x) {
13990
14017
  return _ref2.apply(this, arguments);
@@ -14230,7 +14257,8 @@ function releaseManagementPlugin(_ref) {
14230
14257
  handleRecoverableError = _ref.handleRecoverableError,
14231
14258
  sentryHub = _ref.sentryHub,
14232
14259
  sentryClient = _ref.sentryClient,
14233
- sentryCliOptions = _ref.sentryCliOptions;
14260
+ sentryCliOptions = _ref.sentryCliOptions,
14261
+ deleteFilesUpForDeletion = _ref.deleteFilesUpForDeletion;
14234
14262
  return {
14235
14263
  name: "sentry-debug-id-upload-plugin",
14236
14264
  writeBundle: function writeBundle() {
@@ -14293,21 +14321,24 @@ function releaseManagementPlugin(_ref) {
14293
14321
  _context.next = 18;
14294
14322
  return cliInstance.releases.newDeploy(releaseName, deployOptions);
14295
14323
  case 18:
14296
- _context.next = 26;
14297
- break;
14324
+ _context.next = 20;
14325
+ return deleteFilesUpForDeletion();
14298
14326
  case 20:
14299
- _context.prev = 20;
14327
+ _context.next = 28;
14328
+ break;
14329
+ case 22:
14330
+ _context.prev = 22;
14300
14331
  _context.t0 = _context["catch"](0);
14301
14332
  sentryHub.captureException('Error in "releaseManagementPlugin" writeBundle hook');
14302
- _context.next = 25;
14333
+ _context.next = 27;
14303
14334
  return safeFlushTelemetry(sentryClient);
14304
- case 25:
14335
+ case 27:
14305
14336
  handleRecoverableError(_context.t0);
14306
- case 26:
14337
+ case 28:
14307
14338
  case "end":
14308
14339
  return _context.stop();
14309
14340
  }
14310
- }, _callee, null, [[0, 20]]);
14341
+ }, _callee, null, [[0, 22]]);
14311
14342
  }))();
14312
14343
  }
14313
14344
  };
@@ -14332,7 +14363,7 @@ function telemetryPlugin(_ref) {
14332
14363
  _context.next = 7;
14333
14364
  break;
14334
14365
  }
14335
- logger.info("Sending error and performance telemetry data to Sentry. To disable telemetry, set `options.telemetry` to `false`.");
14366
+ logger.info("Sending telemetry data on issues and performance to Sentry. To disable telemetry, set `options.telemetry` to `false`.");
14336
14367
  sentryHub.startTransaction({
14337
14368
  name: "Sentry Bundler Plugin execution"
14338
14369
  }).finish();
@@ -14393,6 +14424,42 @@ function createLogger(options) {
14393
14424
  };
14394
14425
  }
14395
14426
 
14427
+ function fileDeletionPlugin(_ref) {
14428
+ var handleRecoverableError = _ref.handleRecoverableError,
14429
+ sentryHub = _ref.sentryHub,
14430
+ sentryClient = _ref.sentryClient,
14431
+ deleteFilesUpForDeletion = _ref.deleteFilesUpForDeletion;
14432
+ return {
14433
+ name: "sentry-file-deletion-plugin",
14434
+ writeBundle: function writeBundle() {
14435
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
14436
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
14437
+ while (1) switch (_context.prev = _context.next) {
14438
+ case 0:
14439
+ _context.prev = 0;
14440
+ _context.next = 3;
14441
+ return deleteFilesUpForDeletion();
14442
+ case 3:
14443
+ _context.next = 11;
14444
+ break;
14445
+ case 5:
14446
+ _context.prev = 5;
14447
+ _context.t0 = _context["catch"](0);
14448
+ sentryHub.captureException('Error in "sentry-file-deletion-plugin" buildEnd hook');
14449
+ _context.next = 10;
14450
+ return safeFlushTelemetry(sentryClient);
14451
+ case 10:
14452
+ handleRecoverableError(_context.t0);
14453
+ case 11:
14454
+ case "end":
14455
+ return _context.stop();
14456
+ }
14457
+ }, _callee, null, [[0, 5]]);
14458
+ }))();
14459
+ }
14460
+ };
14461
+ }
14462
+
14396
14463
  /**
14397
14464
  * The sentry bundler plugin concerns itself with two things:
14398
14465
  * - Release injection
@@ -14427,7 +14494,7 @@ function sentryUnpluginFactory(_ref) {
14427
14494
  debugIdUploadPlugin = _ref.debugIdUploadPlugin,
14428
14495
  bundleSizeOptimizationsPlugin = _ref.bundleSizeOptimizationsPlugin;
14429
14496
  return createUnplugin(function () {
14430
- var _userOptions$_metaOpt, _userOptions$_metaOpt2, _userOptions$silent, _userOptions$debug;
14497
+ var _userOptions$_metaOpt, _userOptions$_metaOpt2, _userOptions$silent, _userOptions$debug, _userOptions$_experim;
14431
14498
  var userOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
14432
14499
  var unpluginMetaContext = arguments.length > 1 ? arguments[1] : undefined;
14433
14500
  var logger = createLogger({
@@ -14439,7 +14506,10 @@ function sentryUnpluginFactory(_ref) {
14439
14506
  var dotenvFile = fs.readFileSync(path.join(process.cwd(), ".env.sentry-build-plugin"), "utf-8");
14440
14507
  // NOTE: Do not use the dotenv.config API directly to read the dotenv file! For some ungodly reason, it falls back to reading `${process.cwd()}/.env` which is absolutely not what we want.
14441
14508
  var dotenvResult = dotenv.parse(dotenvFile);
14442
- process.env = _objectSpread2(_objectSpread2({}, process.env), dotenvResult);
14509
+
14510
+ // Vite has a bug/behaviour where spreading into process.env will cause it to crash
14511
+ // https://github.com/vitest-dev/vitest/issues/1870#issuecomment-1501140251
14512
+ Object.assign(process.env, dotenvResult);
14443
14513
  logger.info('Using environment variables configured in ".env.sentry-build-plugin".');
14444
14514
  } catch (e) {
14445
14515
  // Ignore "file not found" errors but throw all others
@@ -14448,6 +14518,11 @@ function sentryUnpluginFactory(_ref) {
14448
14518
  }
14449
14519
  }
14450
14520
  var options = normalizeUserOptions(userOptions);
14521
+
14522
+ // TODO(v3): Remove this warning
14523
+ if ((_userOptions$_experim = userOptions._experiments) !== null && _userOptions$_experim !== void 0 && _userOptions$_experim.moduleMetadata) {
14524
+ logger.warn("The `_experiments.moduleMetadata` option has been promoted to being stable. You can safely move the option out of the `_experiments` object scope.");
14525
+ }
14451
14526
  if (unpluginMetaContext.watchMode || options.disable) {
14452
14527
  return [{
14453
14528
  name: "sentry-noop-plugin"
@@ -14469,7 +14544,7 @@ function sentryUnpluginFactory(_ref) {
14469
14544
  });
14470
14545
 
14471
14546
  // Set the User-Agent that Sentry CLI will use when interacting with Sentry
14472
- process.env["SENTRY_PIPELINE"] = "".concat(unpluginMetaContext.framework, "-plugin/", "2.17.0");
14547
+ process.env["SENTRY_PIPELINE"] = "".concat(unpluginMetaContext.framework, "-plugin/", "2.19.0");
14473
14548
  function handleRecoverableError(unknownError) {
14474
14549
  sentrySession.status = "abnormal";
14475
14550
  try {
@@ -14505,6 +14580,48 @@ function sentryUnpluginFactory(_ref) {
14505
14580
  logger: logger,
14506
14581
  shouldSendTelemetry: shouldSendTelemetry
14507
14582
  }));
14583
+ function deleteFilesUpForDeletion() {
14584
+ return _deleteFilesUpForDeletion.apply(this, arguments);
14585
+ }
14586
+ function _deleteFilesUpForDeletion() {
14587
+ _deleteFilesUpForDeletion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
14588
+ var _options$sourcemaps$f, _options$sourcemaps4, _options$sourcemaps5;
14589
+ var filesToDeleteAfterUpload, filePathsToDelete;
14590
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
14591
+ while (1) switch (_context.prev = _context.next) {
14592
+ case 0:
14593
+ filesToDeleteAfterUpload = (_options$sourcemaps$f = (_options$sourcemaps4 = options.sourcemaps) === null || _options$sourcemaps4 === void 0 ? void 0 : _options$sourcemaps4.filesToDeleteAfterUpload) !== null && _options$sourcemaps$f !== void 0 ? _options$sourcemaps$f : (_options$sourcemaps5 = options.sourcemaps) === null || _options$sourcemaps5 === void 0 ? void 0 : _options$sourcemaps5.deleteFilesAfterUpload;
14594
+ if (!filesToDeleteAfterUpload) {
14595
+ _context.next = 8;
14596
+ break;
14597
+ }
14598
+ _context.next = 4;
14599
+ return glob(filesToDeleteAfterUpload, {
14600
+ absolute: true,
14601
+ nodir: true
14602
+ });
14603
+ case 4:
14604
+ filePathsToDelete = _context.sent;
14605
+ filePathsToDelete.forEach(function (filePathToDelete) {
14606
+ logger.debug("Deleting asset after upload: ".concat(filePathToDelete));
14607
+ });
14608
+ _context.next = 8;
14609
+ return Promise.all(filePathsToDelete.map(function (filePathToDelete) {
14610
+ return fs.promises.rm(filePathToDelete, {
14611
+ force: true
14612
+ })["catch"](function (e) {
14613
+ // This is allowed to fail - we just don't do anything
14614
+ logger.debug("An error occurred while attempting to delete asset: ".concat(filePathToDelete), e);
14615
+ });
14616
+ }));
14617
+ case 8:
14618
+ case "end":
14619
+ return _context.stop();
14620
+ }
14621
+ }, _callee);
14622
+ }));
14623
+ return _deleteFilesUpForDeletion.apply(this, arguments);
14624
+ }
14508
14625
  if (options.bundleSizeOptimizations) {
14509
14626
  var bundleSizeOptimizations = options.bundleSizeOptimizations;
14510
14627
  var replacementValues = {};
@@ -14541,24 +14658,31 @@ function sentryUnpluginFactory(_ref) {
14541
14658
  });
14542
14659
  plugins.push(releaseInjectionPlugin(_injectionCode));
14543
14660
  }
14544
- if (moduleMetadataInjectionPlugin && options._experiments.moduleMetadata) {
14545
- var metadata;
14546
- if (typeof options._experiments.moduleMetadata === "function") {
14661
+ if (options.moduleMetadata || options.applicationKey) {
14662
+ var metadata = {};
14663
+ if (options.applicationKey) {
14664
+ // We use different keys so that if user-code receives multiple bundling passes, we will store the application keys of all the passes.
14665
+ // It is a bit unfortunate that we have to inject the metadata snippet at the top, because after multiple
14666
+ // injections, the first injection will always "win" because it comes last in the code. We would generally be
14667
+ // fine with making the last bundling pass win. But because it cannot win, we have to use a workaround of storing
14668
+ // the app keys in different object keys.
14669
+ // We can simply use the `_sentryBundlerPluginAppKey:` to filter for app keys in the SDK.
14670
+ metadata["_sentryBundlerPluginAppKey:".concat(options.applicationKey)] = true;
14671
+ }
14672
+ if (typeof options.moduleMetadata === "function") {
14547
14673
  var args = {
14548
14674
  org: options.org,
14549
14675
  project: options.project,
14550
14676
  release: options.release.name
14551
14677
  };
14552
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
14553
- metadata = options._experiments.moduleMetadata(args);
14678
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
14679
+ metadata = _objectSpread2(_objectSpread2({}, metadata), options.moduleMetadata(args));
14554
14680
  } else {
14555
14681
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
14556
- metadata = options._experiments.moduleMetadata;
14682
+ metadata = _objectSpread2(_objectSpread2({}, metadata), options.moduleMetadata);
14557
14683
  }
14558
14684
  var _injectionCode2 = generateModuleMetadataInjectorCode(metadata);
14559
14685
  plugins.push(moduleMetadataInjectionPlugin(_injectionCode2));
14560
- } else if (options._experiments.moduleMetadata) {
14561
- logger.warn("'moduleMetadata' is currently only supported by '@sentry/webpack-plugin'");
14562
14686
  }
14563
14687
  if (!options.release.name) {
14564
14688
  logger.warn("No release name provided. Will not create release. Please set the `release.name` option to identify your release.");
@@ -14589,10 +14713,17 @@ function sentryUnpluginFactory(_ref) {
14589
14713
  url: options.url,
14590
14714
  vcsRemote: options.release.vcsRemote,
14591
14715
  headers: options.headers
14592
- }
14716
+ },
14717
+ deleteFilesUpForDeletion: deleteFilesUpForDeletion
14593
14718
  }));
14594
14719
  }
14595
14720
  plugins.push(debugIdInjectionPlugin(logger));
14721
+ plugins.push(fileDeletionPlugin({
14722
+ deleteFilesUpForDeletion: deleteFilesUpForDeletion,
14723
+ handleRecoverableError: handleRecoverableError,
14724
+ sentryHub: sentryHub,
14725
+ sentryClient: sentryClient
14726
+ }));
14596
14727
  if (!options.authToken) {
14597
14728
  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/");
14598
14729
  } else if (!options.org && !options.authToken.startsWith("sntrys_")) {
@@ -14600,16 +14731,16 @@ function sentryUnpluginFactory(_ref) {
14600
14731
  } else if (!options.project) {
14601
14732
  logger.warn("No project provided. Will not upload source maps. Please set the `project` option to your Sentry project slug.");
14602
14733
  } else {
14603
- var _options$sourcemaps, _options$sourcemaps2, _options$sourcemaps$f, _options$sourcemaps3, _options$sourcemaps4, _options$sourcemaps5;
14734
+ var _options$sourcemaps, _options$sourcemaps2, _options$sourcemaps3;
14604
14735
  plugins.push(debugIdUploadPlugin(createDebugIdUploadFunction({
14605
14736
  assets: (_options$sourcemaps = options.sourcemaps) === null || _options$sourcemaps === void 0 ? void 0 : _options$sourcemaps.assets,
14606
14737
  ignore: (_options$sourcemaps2 = options.sourcemaps) === null || _options$sourcemaps2 === void 0 ? void 0 : _options$sourcemaps2.ignore,
14607
- filesToDeleteAfterUpload: (_options$sourcemaps$f = (_options$sourcemaps3 = options.sourcemaps) === null || _options$sourcemaps3 === void 0 ? void 0 : _options$sourcemaps3.filesToDeleteAfterUpload) !== null && _options$sourcemaps$f !== void 0 ? _options$sourcemaps$f : (_options$sourcemaps4 = options.sourcemaps) === null || _options$sourcemaps4 === void 0 ? void 0 : _options$sourcemaps4.deleteFilesAfterUpload,
14738
+ deleteFilesUpForDeletion: deleteFilesUpForDeletion,
14608
14739
  dist: options.release.dist,
14609
14740
  releaseName: options.release.name,
14610
14741
  logger: logger,
14611
14742
  handleRecoverableError: handleRecoverableError,
14612
- rewriteSourcesHook: (_options$sourcemaps5 = options.sourcemaps) === null || _options$sourcemaps5 === void 0 ? void 0 : _options$sourcemaps5.rewriteSources,
14743
+ rewriteSourcesHook: (_options$sourcemaps3 = options.sourcemaps) === null || _options$sourcemaps3 === void 0 ? void 0 : _options$sourcemaps3.rewriteSources,
14613
14744
  sentryHub: sentryHub,
14614
14745
  sentryClient: sentryClient,
14615
14746
  sentryCliOptions: {
@@ -14796,50 +14927,50 @@ function createRollupModuleMetadataInjectionHooks(injectionCode) {
14796
14927
  function createRollupDebugIdUploadHooks(upload) {
14797
14928
  return {
14798
14929
  writeBundle: function writeBundle(outputOptions, bundle) {
14799
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
14930
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
14800
14931
  var outputDir, _buildArtifacts, _buildArtifacts2;
14801
- return _regeneratorRuntime().wrap(function _callee$(_context) {
14802
- while (1) switch (_context.prev = _context.next) {
14932
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
14933
+ while (1) switch (_context2.prev = _context2.next) {
14803
14934
  case 0:
14804
14935
  if (!outputOptions.dir) {
14805
- _context.next = 9;
14936
+ _context2.next = 9;
14806
14937
  break;
14807
14938
  }
14808
14939
  outputDir = outputOptions.dir;
14809
- _context.next = 4;
14940
+ _context2.next = 4;
14810
14941
  return glob(["/**/*.js", "/**/*.mjs", "/**/*.cjs", "/**/*.js.map", "/**/*.mjs.map", "/**/*.cjs.map"], {
14811
14942
  root: outputDir,
14812
14943
  absolute: true,
14813
14944
  nodir: true
14814
14945
  });
14815
14946
  case 4:
14816
- _buildArtifacts = _context.sent;
14817
- _context.next = 7;
14947
+ _buildArtifacts = _context2.sent;
14948
+ _context2.next = 7;
14818
14949
  return upload(_buildArtifacts);
14819
14950
  case 7:
14820
- _context.next = 17;
14951
+ _context2.next = 17;
14821
14952
  break;
14822
14953
  case 9:
14823
14954
  if (!outputOptions.file) {
14824
- _context.next = 14;
14955
+ _context2.next = 14;
14825
14956
  break;
14826
14957
  }
14827
- _context.next = 12;
14958
+ _context2.next = 12;
14828
14959
  return upload([outputOptions.file]);
14829
14960
  case 12:
14830
- _context.next = 17;
14961
+ _context2.next = 17;
14831
14962
  break;
14832
14963
  case 14:
14833
14964
  _buildArtifacts2 = Object.keys(bundle).map(function (asset) {
14834
14965
  return path.join(path.resolve(), asset);
14835
14966
  });
14836
- _context.next = 17;
14967
+ _context2.next = 17;
14837
14968
  return upload(_buildArtifacts2);
14838
14969
  case 17:
14839
14970
  case "end":
14840
- return _context.stop();
14971
+ return _context2.stop();
14841
14972
  }
14842
- }, _callee);
14973
+ }, _callee2);
14843
14974
  }))();
14844
14975
  }
14845
14976
  };
@@ -14847,26 +14978,26 @@ function createRollupDebugIdUploadHooks(upload) {
14847
14978
  function createComponentNameAnnotateHooks() {
14848
14979
  return {
14849
14980
  transform: function transform(code, id) {
14850
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
14981
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
14851
14982
  var idWithoutQueryAndHash, parserPlugins, _result$code, result;
14852
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
14853
- while (1) switch (_context2.prev = _context2.next) {
14983
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
14984
+ while (1) switch (_context3.prev = _context3.next) {
14854
14985
  case 0:
14855
14986
  // id may contain query and hash which will trip up our file extension logic below
14856
14987
  idWithoutQueryAndHash = stripQueryAndHashFromPath(id);
14857
14988
  if (!idWithoutQueryAndHash.match(/\\node_modules\\|\/node_modules\//)) {
14858
- _context2.next = 3;
14989
+ _context3.next = 3;
14859
14990
  break;
14860
14991
  }
14861
- return _context2.abrupt("return", null);
14992
+ return _context3.abrupt("return", null);
14862
14993
  case 3:
14863
14994
  if ([".jsx", ".tsx"].some(function (ending) {
14864
14995
  return idWithoutQueryAndHash.endsWith(ending);
14865
14996
  })) {
14866
- _context2.next = 5;
14997
+ _context3.next = 5;
14867
14998
  break;
14868
14999
  }
14869
- return _context2.abrupt("return", null);
15000
+ return _context3.abrupt("return", null);
14870
15001
  case 5:
14871
15002
  parserPlugins = [];
14872
15003
  if (idWithoutQueryAndHash.endsWith(".jsx")) {
@@ -14874,8 +15005,8 @@ function createComponentNameAnnotateHooks() {
14874
15005
  } else if (idWithoutQueryAndHash.endsWith(".tsx")) {
14875
15006
  parserPlugins.push("jsx", "typescript");
14876
15007
  }
14877
- _context2.prev = 7;
14878
- _context2.next = 10;
15008
+ _context3.prev = 7;
15009
+ _context3.next = 10;
14879
15010
  return transformAsync(code, {
14880
15011
  plugins: [[componentNameAnnotatePlugin]],
14881
15012
  filename: id,
@@ -14890,24 +15021,24 @@ function createComponentNameAnnotateHooks() {
14890
15021
  sourceMaps: true
14891
15022
  });
14892
15023
  case 10:
14893
- result = _context2.sent;
14894
- return _context2.abrupt("return", {
15024
+ result = _context3.sent;
15025
+ return _context3.abrupt("return", {
14895
15026
  code: (_result$code = result === null || result === void 0 ? void 0 : result.code) !== null && _result$code !== void 0 ? _result$code : code,
14896
15027
  map: result === null || result === void 0 ? void 0 : result.map
14897
15028
  });
14898
15029
  case 14:
14899
- _context2.prev = 14;
14900
- _context2.t0 = _context2["catch"](7);
14901
- logger.error("Failed to apply react annotate plugin", _context2.t0);
15030
+ _context3.prev = 14;
15031
+ _context3.t0 = _context3["catch"](7);
15032
+ logger.error("Failed to apply react annotate plugin", _context3.t0);
14902
15033
  case 17:
14903
- return _context2.abrupt("return", {
15034
+ return _context3.abrupt("return", {
14904
15035
  code: code
14905
15036
  });
14906
15037
  case 18:
14907
15038
  case "end":
14908
- return _context2.stop();
15039
+ return _context3.stop();
14909
15040
  }
14910
- }, _callee2, null, [[7, 14]]);
15041
+ }, _callee3, null, [[7, 14]]);
14911
15042
  }))();
14912
15043
  }
14913
15044
  };