@sentry/bundler-plugin-core 2.0.0-alpha.0 → 2.0.0-alpha.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.
@@ -1,9 +1,42 @@
1
- import { createUnplugin } from 'unplugin';
2
- import MagicString from 'magic-string';
3
1
  import SentryCli from '@sentry/cli';
4
- import { NodeClient, defaultStackParser, makeNodeTransport, Hub, makeMain } from '@sentry/node';
5
- import '@sentry/tracing';
2
+ import fs from 'fs';
3
+ import MagicString from 'magic-string';
4
+ import { createUnplugin } from 'unplugin';
5
+ import findUp from 'find-up';
6
6
  import path from 'path';
7
+ import os from 'os';
8
+ import crypto from 'crypto';
9
+ import childProcess from 'child_process';
10
+ import { glob } from 'glob';
11
+ import * as util from 'util';
12
+ import { promisify } from 'util';
13
+ import { NodeClient, defaultStackParser, makeNodeTransport, Hub } from '@sentry/node';
14
+
15
+ function ownKeys(object, enumerableOnly) {
16
+ var keys = Object.keys(object);
17
+
18
+ if (Object.getOwnPropertySymbols) {
19
+ var symbols = Object.getOwnPropertySymbols(object);
20
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
21
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
22
+ })), keys.push.apply(keys, symbols);
23
+ }
24
+
25
+ return keys;
26
+ }
27
+
28
+ function _objectSpread2(target) {
29
+ for (var i = 1; i < arguments.length; i++) {
30
+ var source = null != arguments[i] ? arguments[i] : {};
31
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
32
+ _defineProperty(target, key, source[key]);
33
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
34
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
35
+ });
36
+ }
37
+
38
+ return target;
39
+ }
7
40
 
8
41
  function _regeneratorRuntime() {
9
42
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
@@ -386,502 +419,260 @@ function _asyncToGenerator(fn) {
386
419
  };
387
420
  }
388
421
 
389
- /** Internal global with common properties and Sentry extensions */
390
-
391
- // The code below for 'isGlobalObj' and 'GLOBAL_OBJ' was copied from core-js before modification
392
- // https://github.com/zloirock/core-js/blob/1b944df55282cdc99c90db5f49eb0b6eda2cc0a3/packages/core-js/internals/global.js
393
- // core-js has the following licence:
394
- //
395
- // Copyright (c) 2014-2022 Denis Pushkarev
396
- //
397
- // Permission is hereby granted, free of charge, to any person obtaining a copy
398
- // of this software and associated documentation files (the "Software"), to deal
399
- // in the Software without restriction, including without limitation the rights
400
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
401
- // copies of the Software, and to permit persons to whom the Software is
402
- // furnished to do so, subject to the following conditions:
403
- //
404
- // The above copyright notice and this permission notice shall be included in
405
- // all copies or substantial portions of the Software.
406
- //
407
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
408
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
409
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
410
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
411
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
412
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
413
- // THE SOFTWARE.
414
-
415
- /** Returns 'obj' if it's the global object, otherwise returns undefined */
416
- function isGlobalObj(obj) {
417
- return obj && obj.Math == Math ? obj : undefined;
418
- }
419
-
420
- /** Get's the global object for the current JavaScript runtime */
421
- const GLOBAL_OBJ =
422
- (typeof globalThis == 'object' && isGlobalObj(globalThis)) ||
423
- // eslint-disable-next-line no-restricted-globals
424
- (typeof window == 'object' && isGlobalObj(window)) ||
425
- (typeof self == 'object' && isGlobalObj(self)) ||
426
- (typeof global == 'object' && isGlobalObj(global)) ||
427
- (function () {
428
- return this;
429
- })() ||
430
- {};
422
+ function _defineProperty(obj, key, value) {
423
+ if (key in obj) {
424
+ Object.defineProperty(obj, key, {
425
+ value: value,
426
+ enumerable: true,
427
+ configurable: true,
428
+ writable: true
429
+ });
430
+ } else {
431
+ obj[key] = value;
432
+ }
431
433
 
432
- /**
433
- * @deprecated Use GLOBAL_OBJ instead or WINDOW from @sentry/browser. This will be removed in v8
434
- */
435
- function getGlobalObject() {
436
- return GLOBAL_OBJ ;
434
+ return obj;
437
435
  }
438
436
 
439
437
  /**
440
- * Returns a global singleton contained in the global `__SENTRY__` object.
441
- *
442
- * If the singleton doesn't already exist in `__SENTRY__`, it will be created using the given factory
443
- * function and added to the `__SENTRY__` object.
438
+ * Checks whether the given input is already an array, and if it isn't, wraps it in one.
444
439
  *
445
- * @param name name of the global singleton on __SENTRY__
446
- * @param creator creator Factory function to create the singleton if it doesn't already exist on `__SENTRY__`
447
- * @param obj (Optional) The global object on which to look for `__SENTRY__`, if not `GLOBAL_OBJ`'s return value
448
- * @returns the singleton
440
+ * @param maybeArray Input to turn into an array, if necessary
441
+ * @returns The input, if already an array, or an array with the input as the only element, if not
449
442
  */
450
- function getGlobalSingleton(name, creator, obj) {
451
- const gbl = (obj || GLOBAL_OBJ) ;
452
- const __SENTRY__ = (gbl.__SENTRY__ = gbl.__SENTRY__ || {});
453
- const singleton = __SENTRY__[name] || (__SENTRY__[name] = creator());
454
- return singleton;
455
- }
456
443
 
457
- /** Prefix for logging strings */
458
- const PREFIX = 'Sentry Logger ';
459
-
460
- const CONSOLE_LEVELS = ['debug', 'info', 'warn', 'error', 'log', 'assert', 'trace'] ;
444
+ function arrayify(maybeArray) {
445
+ return Array.isArray(maybeArray) ? maybeArray : [maybeArray];
446
+ }
461
447
 
462
448
  /**
463
- * Temporarily disable sentry console instrumentations.
464
- *
465
- * @param callback The function to run against the original `console` messages
466
- * @returns The results of the callback
449
+ * Get the closes package.json from a given starting point upwards.
450
+ * This handles a few edge cases:
451
+ * * Check if a given file package.json appears to be an actual NPM package.json file
452
+ * * Stop at the home dir, to avoid looking too deeply
467
453
  */
468
- function consoleSandbox(callback) {
469
- if (!('console' in GLOBAL_OBJ)) {
470
- return callback();
471
- }
454
+ function getPackageJson() {
455
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
456
+ cwd = _ref.cwd,
457
+ stopAt = _ref.stopAt;
472
458
 
473
- const originalConsole = GLOBAL_OBJ.console ;
474
- const wrappedLevels = {};
475
-
476
- // Restore all wrapped console methods
477
- CONSOLE_LEVELS.forEach(level => {
478
- // TODO(v7): Remove this check as it's only needed for Node 6
479
- const originalWrappedFunc =
480
- originalConsole[level] && (originalConsole[level] ).__sentry_original__;
481
- if (level in originalConsole && originalWrappedFunc) {
482
- wrappedLevels[level] = originalConsole[level] ;
483
- originalConsole[level] = originalWrappedFunc ;
484
- }
485
- });
486
-
487
- try {
488
- return callback();
489
- } finally {
490
- // Revert restoration to wrapped state
491
- Object.keys(wrappedLevels).forEach(level => {
492
- originalConsole[level] = wrappedLevels[level ];
493
- });
494
- }
459
+ return lookupPackageJson(cwd !== null && cwd !== void 0 ? cwd : process.cwd(), path.normalize(stopAt !== null && stopAt !== void 0 ? stopAt : os.homedir()));
495
460
  }
461
+ function parseMajorVersion(version) {
462
+ // if it has a `v` prefix, remove it
463
+ if (version.startsWith("v")) {
464
+ version = version.slice(1);
465
+ } // First, try simple lookup of exact, ~ and ^ versions
496
466
 
497
- function makeLogger() {
498
- let enabled = false;
499
- const logger = {
500
- enable: () => {
501
- enabled = true;
502
- },
503
- disable: () => {
504
- enabled = false;
505
- },
506
- };
507
467
 
508
- if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__)) {
509
- CONSOLE_LEVELS.forEach(name => {
510
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
511
- logger[name] = (...args) => {
512
- if (enabled) {
513
- consoleSandbox(() => {
514
- GLOBAL_OBJ.console[name](`${PREFIX}[${name}]:`, ...args);
515
- });
516
- }
517
- };
518
- });
519
- } else {
520
- CONSOLE_LEVELS.forEach(name => {
521
- logger[name] = () => undefined;
522
- });
523
- }
468
+ var regex = /^[\^~]?(\d+)(\.\d+)?(\.\d+)?(-.+)?/;
469
+ var match = version.match(regex);
524
470
 
525
- return logger ;
526
- }
471
+ if (match) {
472
+ return parseInt(match[1], 10);
473
+ } // Try to parse e.g. 1.x
527
474
 
528
- // Ensure we only have a single logger instance, even if multiple versions of @sentry/utils are being used
529
- let logger;
530
- if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__)) {
531
- logger = getGlobalSingleton('logger', makeLogger);
532
- } else {
533
- logger = makeLogger();
534
- }
535
475
 
536
- /*
537
- * This module exists for optimizations in the build process through rollup and terser. We define some global
538
- * constants, which can be overridden during build. By guarding certain pieces of code with functions that return these
539
- * constants, we can control whether or not they appear in the final bundle. (Any code guarded by a false condition will
540
- * never run, and will hence be dropped during treeshaking.) The two primary uses for this are stripping out calls to
541
- * `logger` and preventing node-related code from appearing in browser bundles.
542
- *
543
- * Attention:
544
- * This file should not be used to define constants/flags that are intended to be used for tree-shaking conducted by
545
- * users. These fags should live in their respective packages, as we identified user tooling (specifically webpack)
546
- * having issues tree-shaking these constants across package boundaries.
547
- * An example for this is the __SENTRY_DEBUG__ constant. It is declared in each package individually because we want
548
- * users to be able to shake away expressions that it guards.
549
- */
476
+ var coerced = parseInt(version, 10);
550
477
 
551
- /**
552
- * Figures out if we're building a browser bundle.
553
- *
554
- * @returns true if this is a browser bundle build.
555
- */
556
- function isBrowserBundle() {
557
- return typeof __SENTRY_BROWSER_BUNDLE__ !== 'undefined' && !!__SENTRY_BROWSER_BUNDLE__;
558
- }
478
+ if (!Number.isNaN(coerced)) {
479
+ return coerced;
480
+ } // Match <= and >= ranges.
559
481
 
560
- /**
561
- * NOTE: In order to avoid circular dependencies, if you add a function to this module and it needs to print something,
562
- * you must either a) use `console.log` rather than the logger, or b) put your function elsewhere.
563
- */
564
482
 
565
- /**
566
- * Checks whether we're in the Node.js or Browser environment
567
- *
568
- * @returns Answer to given question
569
- */
570
- function isNodeEnv() {
571
- // explicitly check for browser bundles as those can be optimized statically
572
- // by terser/rollup.
573
- return (
574
- !isBrowserBundle() &&
575
- Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]'
576
- );
577
- }
483
+ var gteLteRegex = /^[<>]=\s*(\d+)(\.\d+)?(\.\d+)?(-.+)?/;
484
+ var gteLteMatch = version.match(gteLteRegex);
578
485
 
579
- /**
580
- * Requires a module which is protected against bundler minification.
581
- *
582
- * @param request The module path to resolve
583
- */
584
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
585
- function dynamicRequire(mod, request) {
586
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
587
- return mod.require(request);
588
- }
486
+ if (gteLteMatch) {
487
+ return parseInt(gteLteMatch[1], 10);
488
+ } // match < ranges
589
489
 
590
- /* eslint-disable @typescript-eslint/explicit-function-return-type */
591
490
 
592
- /** SyncPromise internal states */
593
- var States; (function (States) {
594
- /** Pending */
595
- const PENDING = 0; States[States["PENDING"] = PENDING] = "PENDING";
596
- /** Resolved / OK */
597
- const RESOLVED = 1; States[States["RESOLVED"] = RESOLVED] = "RESOLVED";
598
- /** Rejected / Error */
599
- const REJECTED = 2; States[States["REJECTED"] = REJECTED] = "REJECTED";
600
- })(States || (States = {}));
491
+ var ltRegex = /^<\s*(\d+)(\.\d+)?(\.\d+)?(-.+)?/;
492
+ var ltMatch = version.match(ltRegex);
601
493
 
602
- // eslint-disable-next-line deprecation/deprecation
603
- const WINDOW = getGlobalObject();
494
+ if (ltMatch) {
495
+ // Two scenarios:
496
+ // a) < 2.0.0 --> return 1
497
+ // b) < 2.1.0 --> return 2
498
+ var major = parseInt(ltMatch[1], 10);
604
499
 
605
- /**
606
- * An object that can return the current timestamp in seconds since the UNIX epoch.
607
- */
500
+ if ( // minor version > 0
501
+ typeof ltMatch[2] === "string" && parseInt(ltMatch[2].slice(1), 10) > 0 || // patch version > 0
502
+ typeof ltMatch[3] === "string" && parseInt(ltMatch[3].slice(1), 10) > 0) {
503
+ return major;
504
+ }
608
505
 
609
- /**
610
- * A TimestampSource implementation for environments that do not support the Performance Web API natively.
611
- *
612
- * Note that this TimestampSource does not use a monotonic clock. A call to `nowSeconds` may return a timestamp earlier
613
- * than a previously returned value. We do not try to emulate a monotonic behavior in order to facilitate debugging. It
614
- * is more obvious to explain "why does my span have negative duration" than "why my spans have zero duration".
615
- */
616
- const dateTimestampSource = {
617
- nowSeconds: () => Date.now() / 1000,
618
- };
506
+ return major - 1;
507
+ } // match > ranges
619
508
 
620
- /**
621
- * A partial definition of the [Performance Web API]{@link https://developer.mozilla.org/en-US/docs/Web/API/Performance}
622
- * for accessing a high-resolution monotonic clock.
623
- */
624
509
 
625
- /**
626
- * Returns a wrapper around the native Performance API browser implementation, or undefined for browsers that do not
627
- * support the API.
628
- *
629
- * Wrapping the native API works around differences in behavior from different browsers.
630
- */
631
- function getBrowserPerformance() {
632
- const { performance } = WINDOW;
633
- if (!performance || !performance.now) {
634
- return undefined;
510
+ var gtRegex = /^>\s*(\d+)(\.\d+)?(\.\d+)?(-.+)?/;
511
+ var gtMatch = version.match(gtRegex);
512
+
513
+ if (gtMatch) {
514
+ // We always return the version here, even though it _may_ be incorrect
515
+ // E.g. if given > 2.0.0, it should be 2 if there exists any 2.x.x version, else 3
516
+ // Since there is no way for us to know this, we're going to assume any kind of patch/feature release probably exists
517
+ return parseInt(gtMatch[1], 10);
635
518
  }
636
519
 
637
- // Replace performance.timeOrigin with our own timeOrigin based on Date.now().
638
- //
639
- // This is a partial workaround for browsers reporting performance.timeOrigin such that performance.timeOrigin +
640
- // performance.now() gives a date arbitrarily in the past.
641
- //
642
- // Additionally, computing timeOrigin in this way fills the gap for browsers where performance.timeOrigin is
643
- // undefined.
644
- //
645
- // The assumption that performance.timeOrigin + performance.now() ~= Date.now() is flawed, but we depend on it to
646
- // interact with data coming out of performance entries.
647
- //
648
- // Note that despite recommendations against it in the spec, browsers implement the Performance API with a clock that
649
- // might stop when the computer is asleep (and perhaps under other circumstances). Such behavior causes
650
- // performance.timeOrigin + performance.now() to have an arbitrary skew over Date.now(). In laptop computers, we have
651
- // observed skews that can be as long as days, weeks or months.
652
- //
653
- // See https://github.com/getsentry/sentry-javascript/issues/2590.
654
- //
655
- // BUG: despite our best intentions, this workaround has its limitations. It mostly addresses timings of pageload
656
- // transactions, but ignores the skew built up over time that can aversely affect timestamps of navigation
657
- // transactions of long-lived web pages.
658
- const timeOrigin = Date.now() - performance.now();
520
+ return undefined;
521
+ } // This is an explicit list of packages where we want to include the (major) version number.
659
522
 
523
+ var PACKAGES_TO_INCLUDE_VERSION = ["react", "@angular/core", "vue", "ember-source", "svelte", "@sveltejs/kit", "webpack", "vite", "gatsby", "next", "remix", "rollup", "esbuild"];
524
+ function getDependencies(packageJson) {
525
+ var _packageJson$devDepen, _packageJson$dependen;
526
+
527
+ var dependencies = Object.assign({}, (_packageJson$devDepen = packageJson["devDependencies"]) !== null && _packageJson$devDepen !== void 0 ? _packageJson$devDepen : {}, (_packageJson$dependen = packageJson["dependencies"]) !== null && _packageJson$dependen !== void 0 ? _packageJson$dependen : {});
528
+ var deps = Object.keys(dependencies).sort();
529
+ var depsVersions = deps.reduce(function (depsVersions, depName) {
530
+ if (PACKAGES_TO_INCLUDE_VERSION.includes(depName)) {
531
+ var version = dependencies[depName];
532
+ var majorVersion = parseMajorVersion(version);
533
+
534
+ if (majorVersion) {
535
+ depsVersions[depName] = majorVersion;
536
+ }
537
+ }
538
+
539
+ return depsVersions;
540
+ }, {});
660
541
  return {
661
- now: () => performance.now(),
662
- timeOrigin,
542
+ deps: deps,
543
+ depsVersions: depsVersions
663
544
  };
664
545
  }
665
546
 
666
- /**
667
- * Returns the native Performance API implementation from Node.js. Returns undefined in old Node.js versions that don't
668
- * implement the API.
669
- */
670
- function getNodePerformance() {
671
- try {
672
- const perfHooks = dynamicRequire(module, 'perf_hooks') ;
673
- return perfHooks.performance;
674
- } catch (_) {
547
+ function lookupPackageJson(cwd, stopAt) {
548
+ var jsonPath = findUp.sync(function (dirName) {
549
+ // Stop if we reach this dir
550
+ if (path.normalize(dirName) === stopAt) {
551
+ return findUp.stop;
552
+ }
553
+
554
+ return findUp.sync.exists(dirName + "/package.json") ? "package.json" : undefined;
555
+ }, {
556
+ cwd: cwd
557
+ });
558
+
559
+ if (!jsonPath) {
675
560
  return undefined;
676
561
  }
677
- }
678
562
 
679
- /**
680
- * The Performance API implementation for the current platform, if available.
681
- */
682
- const platformPerformance = isNodeEnv() ? getNodePerformance() : getBrowserPerformance();
563
+ try {
564
+ var jsonStr = fs.readFileSync(jsonPath, "utf8");
565
+ var json = JSON.parse(jsonStr); // Ensure it is an actual package.json
566
+ // This is very much not bulletproof, but should be good enough
683
567
 
684
- const timestampSource =
685
- platformPerformance === undefined
686
- ? dateTimestampSource
687
- : {
688
- nowSeconds: () => (platformPerformance.timeOrigin + platformPerformance.now()) / 1000,
689
- };
568
+ if ("name" in json || "private" in json) {
569
+ return json;
570
+ }
571
+ } catch (error) {// Ignore and walk up
572
+ } // Continue up the tree, if we find a fitting package.json
690
573
 
691
- /**
692
- * Returns a timestamp in seconds since the UNIX epoch using the Date API.
693
- */
694
- dateTimestampSource.nowSeconds.bind(dateTimestampSource);
695
574
 
575
+ var newCwd = path.dirname(path.resolve(jsonPath + "/.."));
576
+ return lookupPackageJson(newCwd, stopAt);
577
+ }
696
578
  /**
697
- * Returns a timestamp in seconds since the UNIX epoch using either the Performance or Date APIs, depending on the
698
- * availability of the Performance API.
699
- *
700
- * See `usingPerformanceAPI` to test whether the Performance API is used.
701
- *
702
- * BUG: Note that because of how browsers implement the Performance API, the clock might stop when the computer is
703
- * asleep. This creates a skew between `dateTimestampInSeconds` and `timestampInSeconds`. The
704
- * skew can grow to arbitrary amounts like days, weeks or months.
705
- * See https://github.com/getsentry/sentry-javascript/issues/2590.
579
+ * Deterministically hashes a string and turns the hash into a uuid.
706
580
  */
707
- timestampSource.nowSeconds.bind(timestampSource);
708
581
 
582
+
583
+ function stringToUUID(str) {
584
+ var md5sum = crypto.createHash("md5");
585
+ md5sum.update(str);
586
+ var md5Hash = md5sum.digest("hex");
587
+ return (md5Hash.substring(0, 8) + "-" + md5Hash.substring(8, 12) + "-4" + md5Hash.substring(13, 16) + "-" + md5Hash.substring(16, 20) + "-" + md5Hash.substring(20)).toLowerCase();
588
+ }
709
589
  /**
710
- * The number of milliseconds since the UNIX epoch. This value is only usable in a browser, and only when the
711
- * performance API is available.
590
+ * Tries to guess a release name based on environmental data.
712
591
  */
713
- (() => {
714
- // Unfortunately browsers may report an inaccurate time origin data, through either performance.timeOrigin or
715
- // performance.timing.navigationStart, which results in poor results in performance data. We only treat time origin
716
- // data as reliable if they are within a reasonable threshold of the current time.
717
592
 
718
- const { performance } = WINDOW;
719
- if (!performance || !performance.now) {
720
- return undefined;
721
- }
593
+ function determineReleaseName() {
594
+ var gitRevision;
722
595
 
723
- const threshold = 3600 * 1000;
724
- const performanceNow = performance.now();
725
- const dateNow = Date.now();
726
-
727
- // if timeOrigin isn't available set delta to threshold so it isn't used
728
- const timeOriginDelta = performance.timeOrigin
729
- ? Math.abs(performance.timeOrigin + performanceNow - dateNow)
730
- : threshold;
731
- const timeOriginIsReliable = timeOriginDelta < threshold;
732
-
733
- // While performance.timing.navigationStart is deprecated in favor of performance.timeOrigin, performance.timeOrigin
734
- // is not as widely supported. Namely, performance.timeOrigin is undefined in Safari as of writing.
735
- // Also as of writing, performance.timing is not available in Web Workers in mainstream browsers, so it is not always
736
- // a valid fallback. In the absence of an initial time provided by the browser, fallback to the current time from the
737
- // Date API.
738
- // eslint-disable-next-line deprecation/deprecation
739
- const navigationStart = performance.timing && performance.timing.navigationStart;
740
- const hasNavigationStart = typeof navigationStart === 'number';
741
- // if navigationStart isn't available set delta to threshold so it isn't used
742
- const navigationStartDelta = hasNavigationStart ? Math.abs(navigationStart + performanceNow - dateNow) : threshold;
743
- const navigationStartIsReliable = navigationStartDelta < threshold;
744
-
745
- if (timeOriginIsReliable || navigationStartIsReliable) {
746
- // Use the more reliable time origin
747
- if (timeOriginDelta <= navigationStartDelta) {
748
- return performance.timeOrigin;
749
- } else {
750
- return navigationStart;
751
- }
596
+ try {
597
+ gitRevision = childProcess.execSync("git rev-parse --short HEAD").toString().trim();
598
+ } catch (e) {// noop
752
599
  }
753
- return dateNow;
754
- })();
755
600
 
601
+ return (// GitHub Actions - https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
602
+ process.env["GITHUB_SHA"] || // Netlify - https://docs.netlify.com/configure-builds/environment-variables/#build-metadata
603
+ process.env["COMMIT_REF"] || // Cloudflare Pages - https://developers.cloudflare.com/pages/platform/build-configuration/#environment-variables
604
+ process.env["CF_PAGES_COMMIT_SHA"] || // AWS CodeBuild - https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
605
+ process.env["CODEBUILD_RESOLVED_SOURCE_VERSION"] || // CircleCI - https://circleci.com/docs/2.0/env-vars/
606
+ process.env["CIRCLE_SHA1"] || // Vercel - https://vercel.com/docs/v2/build-step#system-environment-variables
607
+ process.env["VERCEL_GIT_COMMIT_SHA"] || process.env["VERCEL_GITHUB_COMMIT_SHA"] || process.env["VERCEL_GITLAB_COMMIT_SHA"] || process.env["VERCEL_BITBUCKET_COMMIT_SHA"] || // Zeit (now known as Vercel)
608
+ process.env["ZEIT_GITHUB_COMMIT_SHA"] || process.env["ZEIT_GITLAB_COMMIT_SHA"] || process.env["ZEIT_BITBUCKET_COMMIT_SHA"] || gitRevision
609
+ );
610
+ }
756
611
  /**
757
- * Checks whether the given input is already an array, and if it isn't, wraps it in one.
758
- *
759
- * @param maybeArray Input to turn into an array, if necessary
760
- * @returns The input, if already an array, or an array with the input as the only element, if not
612
+ * Generates code for the global injector which is responsible for setting the global
613
+ * `SENTRY_RELEASE` & `SENTRY_BUILD_INFO` variables.
761
614
  */
762
- function arrayify(maybeArray) {
763
- return Array.isArray(maybeArray) ? maybeArray : [maybeArray];
615
+
616
+ function generateGlobalInjectorCode(_ref2) {
617
+ var release = _ref2.release,
618
+ injectBuildInformation = _ref2.injectBuildInformation;
619
+ // The code below is mostly ternary operators because it saves bundle size.
620
+ // The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
621
+ var code = "\n var _global =\n typeof window !== 'undefined' ?\n window :\n typeof global !== 'undefined' ?\n global :\n typeof self !== 'undefined' ?\n self :\n {};\n\n _global.SENTRY_RELEASE={id:\"".concat(release, "\"};");
622
+
623
+ if (injectBuildInformation) {
624
+ var buildInfo = getBuildInformation$1();
625
+ code += "\n _global.SENTRY_BUILD_INFO=".concat(JSON.stringify(buildInfo), ";");
626
+ }
627
+
628
+ return code;
629
+ }
630
+
631
+ function getBuildInformation$1() {
632
+ var packageJson = getPackageJson();
633
+
634
+ var _ref3 = packageJson ? getDependencies(packageJson) : {
635
+ deps: [],
636
+ depsVersions: {}
637
+ },
638
+ deps = _ref3.deps,
639
+ depsVersions = _ref3.depsVersions;
640
+
641
+ return {
642
+ deps: deps,
643
+ depsVersions: depsVersions,
644
+ nodeVersion: parseMajorVersion(process.version)
645
+ };
764
646
  }
765
647
 
766
648
  var SENTRY_SAAS_URL = "https://sentry.io";
767
649
  function normalizeUserOptions(userOptions) {
768
- var _userOptions$org, _userOptions$project, _ref, _userOptions$release, _ref2, _userOptions$url, _userOptions$finalize, _userOptions$cleanArt, _userOptions$dryRun, _userOptions$debug, _userOptions$silent, _userOptions$telemetr, _userOptions$injectRe;
650
+ var _userOptions$org, _userOptions$project, _userOptions$authToke, _ref, _userOptions$url, _userOptions$debug, _userOptions$silent, _userOptions$telemetr, _userOptions$disable, _process$env$SENTRY_V, _userOptions$_experim;
769
651
 
770
652
  var options = {
771
- // include is the only strictly required option
772
- // (normalizeInclude needs all userOptions to access top-level include options)
773
- include: normalizeInclude(userOptions),
774
- // These options must be set b/c we need them for release injection.
775
- // They can also be set as environment variables. Technically, they
776
- // could be set in the config file but this would be too late for
777
- // release injection because we only pass the config file path
778
- // to the CLI
779
653
  org: (_userOptions$org = userOptions.org) !== null && _userOptions$org !== void 0 ? _userOptions$org : process.env["SENTRY_ORG"],
780
654
  project: (_userOptions$project = userOptions.project) !== null && _userOptions$project !== void 0 ? _userOptions$project : process.env["SENTRY_PROJECT"],
781
- // Falling back to the empty string here b/c at a later point, we use
782
- // Sentry CLI to determine a release if none was specified via options
783
- // or env vars. In case we don't find one, we'll bail at that point.
784
- release: (_ref = (_userOptions$release = userOptions.release) !== null && _userOptions$release !== void 0 ? _userOptions$release : process.env["SENTRY_RELEASE"]) !== null && _ref !== void 0 ? _ref : "",
785
- // We technically don't need the URL for anything release-specific
786
- // but we want to make sure that we're only sending Sentry data
787
- // of SaaS customers. Hence we want to read it anyway.
788
- url: (_ref2 = (_userOptions$url = userOptions.url) !== null && _userOptions$url !== void 0 ? _userOptions$url : process.env["SENTRY_URL"]) !== null && _ref2 !== void 0 ? _ref2 : SENTRY_SAAS_URL,
789
- // Options with default values
790
- finalize: (_userOptions$finalize = userOptions.finalize) !== null && _userOptions$finalize !== void 0 ? _userOptions$finalize : true,
791
- cleanArtifacts: (_userOptions$cleanArt = userOptions.cleanArtifacts) !== null && _userOptions$cleanArt !== void 0 ? _userOptions$cleanArt : false,
792
- dryRun: (_userOptions$dryRun = userOptions.dryRun) !== null && _userOptions$dryRun !== void 0 ? _userOptions$dryRun : false,
655
+ authToken: (_userOptions$authToke = userOptions.authToken) !== null && _userOptions$authToke !== void 0 ? _userOptions$authToke : process.env["SENTRY_AUTH_TOKEN"],
656
+ url: (_ref = (_userOptions$url = userOptions.url) !== null && _userOptions$url !== void 0 ? _userOptions$url : process.env["SENTRY_URL"]) !== null && _ref !== void 0 ? _ref : SENTRY_SAAS_URL,
657
+ headers: userOptions.headers,
793
658
  debug: (_userOptions$debug = userOptions.debug) !== null && _userOptions$debug !== void 0 ? _userOptions$debug : false,
794
659
  silent: (_userOptions$silent = userOptions.silent) !== null && _userOptions$silent !== void 0 ? _userOptions$silent : false,
795
- telemetry: (_userOptions$telemetr = userOptions.telemetry) !== null && _userOptions$telemetr !== void 0 ? _userOptions$telemetr : true,
796
- injectReleasesMap: (_userOptions$injectRe = userOptions.injectReleasesMap) !== null && _userOptions$injectRe !== void 0 ? _userOptions$injectRe : false,
797
- // These options and can also be set via env variables or the config file.
798
- // If they're set in the options, we simply pass them to the CLI constructor.
799
- // Sentry CLI will internally query env variables and read its config file if
800
- // the passed options are undefined.
801
- authToken: userOptions.authToken,
802
- // env var: `SENTRY_AUTH_TOKEN`
803
- headers: userOptions.headers,
804
- vcsRemote: userOptions.vcsRemote,
805
- // env var: `SENTRY_VSC_REMOTE`
806
- // Optional options
807
- setCommits: userOptions.setCommits,
808
- deploy: userOptions.deploy,
809
- releaseInjectionTargets: normalizeReleaseInjectionTargets(userOptions.releaseInjectionTargets),
810
- dist: userOptions.dist,
811
660
  errorHandler: userOptions.errorHandler,
812
- configFile: userOptions.configFile
661
+ telemetry: (_userOptions$telemetr = userOptions.telemetry) !== null && _userOptions$telemetr !== void 0 ? _userOptions$telemetr : true,
662
+ disable: (_userOptions$disable = userOptions.disable) !== null && _userOptions$disable !== void 0 ? _userOptions$disable : false,
663
+ sourcemaps: userOptions.sourcemaps,
664
+ release: _objectSpread2({
665
+ name: determineReleaseName(),
666
+ inject: true,
667
+ create: true,
668
+ finalize: true,
669
+ vcsRemote: (_process$env$SENTRY_V = process.env["SENTRY_VSC_REMOTE"]) !== null && _process$env$SENTRY_V !== void 0 ? _process$env$SENTRY_V : "origin",
670
+ cleanArtifacts: false
671
+ }, userOptions.release),
672
+ _experiments: (_userOptions$_experim = userOptions._experiments) !== null && _userOptions$_experim !== void 0 ? _userOptions$_experim : {}
813
673
  };
814
674
  return options;
815
675
  }
816
- /**
817
- * Converts the user-facing `releaseInjectionTargets` option to the internal
818
- * `releaseInjectionTargets` option
819
- */
820
-
821
- function normalizeReleaseInjectionTargets(userReleaseInjectionTargets) {
822
- if (userReleaseInjectionTargets === undefined) {
823
- return undefined;
824
- } else if (typeof userReleaseInjectionTargets === "function") {
825
- return userReleaseInjectionTargets;
826
- } else {
827
- return arrayify(userReleaseInjectionTargets);
828
- }
829
- }
830
- /**
831
- * Converts the user-facing `include` option to the internal `include` option,
832
- * resulting in an array of `InternalIncludeEntry` objects. This later on lets us
833
- * work with only one type of include data structure instead of multiple.
834
- *
835
- * During the process, we hoist top-level include options (e.g. urlPrefix) into each
836
- * object if they were not alrady specified in an `IncludeEntry`, making every object
837
- * fully self-contained. This is also the reason why we pass the entire options
838
- * object and not just `include`.
839
- *
840
- * @param userOptions the entire user-facing `options` object
841
- *
842
- * @return an array of `InternalIncludeEntry` objects.
843
- */
844
-
845
-
846
- function normalizeInclude(userOptions) {
847
- return arrayify(userOptions.include).map(function (includeItem) {
848
- return typeof includeItem === "string" ? {
849
- paths: [includeItem]
850
- } : includeItem;
851
- }).map(function (userIncludeEntry) {
852
- return normalizeIncludeEntry(userOptions, userIncludeEntry);
853
- });
854
- }
855
- /**
856
- * Besides array-ifying the `ignore` option, this function hoists top level options into the items of the `include`
857
- * option. This is to simplify the handling of of the `include` items later on.
858
- */
859
-
860
-
861
- function normalizeIncludeEntry(userOptions, includeEntry) {
862
- var _ref3, _includeEntry$ignore, _ref4, _includeEntry$ext, _includeEntry$ignoreF, _includeEntry$urlPref, _includeEntry$urlSuff, _includeEntry$stripPr, _ref5, _includeEntry$stripCo, _ref6, _includeEntry$sourceM, _ref7, _includeEntry$rewrite, _ref8, _includeEntry$validat;
863
-
864
- var ignoreOption = (_ref3 = (_includeEntry$ignore = includeEntry.ignore) !== null && _includeEntry$ignore !== void 0 ? _includeEntry$ignore : userOptions.ignore) !== null && _ref3 !== void 0 ? _ref3 : ["node_modules"];
865
- var ignore = Array.isArray(ignoreOption) ? ignoreOption : [ignoreOption]; // We're prefixing all entries in the `ext` option with a `.` (if it isn't already) to align with Node.js' `path.extname()`
866
-
867
- var ext = (_ref4 = (_includeEntry$ext = includeEntry.ext) !== null && _includeEntry$ext !== void 0 ? _includeEntry$ext : userOptions.ext) !== null && _ref4 !== void 0 ? _ref4 : ["js", "map", "jsbundle", "bundle"];
868
- var dotPrefixedExt = ext.map(function (extension) {
869
- return ".".concat(extension.replace(/^\./, ""));
870
- });
871
- return {
872
- paths: includeEntry.paths,
873
- ignore: ignore,
874
- ignoreFile: (_includeEntry$ignoreF = includeEntry.ignoreFile) !== null && _includeEntry$ignoreF !== void 0 ? _includeEntry$ignoreF : userOptions.ignoreFile,
875
- ext: dotPrefixedExt,
876
- urlPrefix: (_includeEntry$urlPref = includeEntry.urlPrefix) !== null && _includeEntry$urlPref !== void 0 ? _includeEntry$urlPref : userOptions.urlPrefix,
877
- urlSuffix: (_includeEntry$urlSuff = includeEntry.urlSuffix) !== null && _includeEntry$urlSuff !== void 0 ? _includeEntry$urlSuff : userOptions.urlSuffix,
878
- stripPrefix: (_includeEntry$stripPr = includeEntry.stripPrefix) !== null && _includeEntry$stripPr !== void 0 ? _includeEntry$stripPr : userOptions.stripPrefix,
879
- stripCommonPrefix: (_ref5 = (_includeEntry$stripCo = includeEntry.stripCommonPrefix) !== null && _includeEntry$stripCo !== void 0 ? _includeEntry$stripCo : userOptions.stripCommonPrefix) !== null && _ref5 !== void 0 ? _ref5 : false,
880
- sourceMapReference: (_ref6 = (_includeEntry$sourceM = includeEntry.sourceMapReference) !== null && _includeEntry$sourceM !== void 0 ? _includeEntry$sourceM : userOptions.sourceMapReference) !== null && _ref6 !== void 0 ? _ref6 : true,
881
- rewrite: (_ref7 = (_includeEntry$rewrite = includeEntry.rewrite) !== null && _includeEntry$rewrite !== void 0 ? _includeEntry$rewrite : userOptions.rewrite) !== null && _ref7 !== void 0 ? _ref7 : true,
882
- validate: (_ref8 = (_includeEntry$validat = includeEntry.validate) !== null && _includeEntry$validat !== void 0 ? _includeEntry$validat : userOptions.validate) !== null && _ref8 !== void 0 ? _ref8 : false
883
- };
884
- }
885
676
  /**
886
677
  * Validates a few combinations of options that are not checked by Sentry CLI.
887
678
  *
@@ -895,14 +686,10 @@ function normalizeIncludeEntry(userOptions, includeEntry) {
895
686
  * @returns `true` if the options are valid, `false` otherwise
896
687
  */
897
688
 
898
-
899
689
  function validateOptions(options, logger) {
900
- if (options.injectReleasesMap && !options.org) {
901
- logger.error("The `injectReleasesMap` option was set but it is only supported when the `org` option is also specified.", "Please set the `org` option (you can also set the SENTRY_ORG environment variable) or disable the `injectReleasesMap` option.");
902
- return false;
903
- }
690
+ var _options$release, _options$release2, _options$release3;
904
691
 
905
- var setCommits = options.setCommits;
692
+ var setCommits = (_options$release = options.release) === null || _options$release === void 0 ? void 0 : _options$release.setCommits;
906
693
 
907
694
  if (setCommits) {
908
695
  if (!setCommits.auto && !(setCommits.repo && setCommits.commit)) {
@@ -915,7 +702,7 @@ function validateOptions(options, logger) {
915
702
  }
916
703
  }
917
704
 
918
- if (options.deploy && !options.deploy.env) {
705
+ if ((_options$release2 = options.release) !== null && _options$release2 !== void 0 && _options$release2.deploy && !((_options$release3 = options.release) !== null && _options$release3 !== void 0 && _options$release3.deploy.env)) {
919
706
  logger.error("The `deploy` option was specified but is missing the required `env` property.", "Please set the `env` property.");
920
707
  return false;
921
708
  }
@@ -923,606 +710,513 @@ function validateOptions(options, logger) {
923
710
  return true;
924
711
  }
925
712
 
926
- var SENTRY_SAAS_HOSTNAME = "sentry.io";
927
- function makeSentryClient(dsn, allowedToSendTelemetryPromise, userProject) {
928
- var client = new NodeClient({
929
- dsn: dsn,
930
- tracesSampleRate: 1,
931
- sampleRate: 1,
932
- // We're also sending the user project in dist because it is an indexed fieldso we can use this data effectively in
933
- // a dashboard.
934
- // Yes, this is slightly abusing the purpose of this field.
935
- dist: userProject,
936
- release: "2.0.0-alpha.0",
937
- integrations: [],
938
- tracePropagationTargets: ["sentry.io/api"],
939
- stackParser: defaultStackParser,
940
- beforeSend: function beforeSend(event) {
941
- var _event$exception, _event$exception$valu;
942
-
943
- (_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) {
944
- delete exception.stacktrace;
945
- });
946
- delete event.server_name; // Server name might contain PII
713
+ function debugIdUploadPlugin(_ref) {
714
+ var assets = _ref.assets,
715
+ ignore = _ref.ignore,
716
+ logger = _ref.logger,
717
+ releaseName = _ref.releaseName,
718
+ dist = _ref.dist,
719
+ handleRecoverableError = _ref.handleRecoverableError,
720
+ sentryHub = _ref.sentryHub,
721
+ sentryClient = _ref.sentryClient,
722
+ sentryCliOptions = _ref.sentryCliOptions;
723
+ return {
724
+ name: "sentry-debug-id-upload-plugin",
725
+ writeBundle: function writeBundle() {
726
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
727
+ var folderToCleanUp, cliInstance, tmpUploadFolder, debugIdChunkFilePaths;
728
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
729
+ while (1) {
730
+ switch (_context2.prev = _context2.next) {
731
+ case 0:
732
+ cliInstance = new SentryCli(null, sentryCliOptions);
733
+ _context2.prev = 1;
734
+ _context2.next = 4;
735
+ return fs.promises.mkdtemp(path.join(os.tmpdir(), "sentry-bundler-plugin-upload-"));
736
+
737
+ case 4:
738
+ tmpUploadFolder = _context2.sent;
739
+ folderToCleanUp = tmpUploadFolder;
740
+ _context2.next = 8;
741
+ return glob(assets, {
742
+ absolute: true,
743
+ nodir: true,
744
+ ignore: ignore
745
+ });
947
746
 
948
- return event;
949
- },
950
- beforeSendTransaction: function beforeSendTransaction(event) {
951
- delete event.server_name; // Server name might contain PII
747
+ case 8:
748
+ debugIdChunkFilePaths = _context2.sent.filter(function (debugIdChunkFilePath) {
749
+ return debugIdChunkFilePath.endsWith(".js") || debugIdChunkFilePath.endsWith(".mjs") || debugIdChunkFilePath.endsWith(".cjs");
750
+ });
751
+ _context2.next = 11;
752
+ return Promise.all(debugIdChunkFilePaths.map( /*#__PURE__*/function () {
753
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(chunkFilePath, chunkIndex) {
754
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
755
+ while (1) {
756
+ switch (_context.prev = _context.next) {
757
+ case 0:
758
+ _context.next = 2;
759
+ return prepareBundleForDebugIdUpload(chunkFilePath, tmpUploadFolder, String(chunkIndex), logger);
760
+
761
+ case 2:
762
+ case "end":
763
+ return _context.stop();
764
+ }
765
+ }
766
+ }, _callee);
767
+ }));
768
+
769
+ return function (_x, _x2) {
770
+ return _ref2.apply(this, arguments);
771
+ };
772
+ }()));
952
773
 
953
- return event;
954
- },
955
- // We create a transport that stalls sending events until we know that we're allowed to (i.e. when Sentry CLI told
956
- // us that the upload URL is the Sentry SaaS URL)
957
- transport: function transport(nodeTransportOptions) {
958
- var nodeTransport = makeNodeTransport(nodeTransportOptions);
959
- return {
960
- flush: function flush(timeout) {
961
- return nodeTransport.flush(timeout);
962
- },
963
- send: function () {
964
- var _send = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
965
- var isAllowedToSend;
966
- return _regeneratorRuntime().wrap(function _callee$(_context) {
967
- while (1) {
968
- switch (_context.prev = _context.next) {
969
- case 0:
970
- _context.next = 2;
971
- return allowedToSendTelemetryPromise;
774
+ case 11:
775
+ _context2.next = 13;
776
+ return cliInstance.releases.uploadSourceMaps(releaseName !== null && releaseName !== void 0 ? releaseName : "", {
777
+ include: [{
778
+ paths: [tmpUploadFolder],
779
+ rewrite: false,
780
+ dist: dist
781
+ }],
782
+ useArtifactBundle: true
783
+ });
972
784
 
973
- case 2:
974
- isAllowedToSend = _context.sent;
785
+ case 13:
786
+ _context2.next = 21;
787
+ break;
975
788
 
976
- if (!isAllowedToSend) {
977
- _context.next = 7;
978
- break;
979
- }
789
+ case 15:
790
+ _context2.prev = 15;
791
+ _context2.t0 = _context2["catch"](1);
792
+ sentryHub.captureException('Error in "debugIdUploadPlugin" writeBundle hook');
793
+ _context2.next = 20;
794
+ return sentryClient.flush();
980
795
 
981
- return _context.abrupt("return", nodeTransport.send(request));
796
+ case 20:
797
+ handleRecoverableError(_context2.t0);
982
798
 
983
- case 7:
984
- return _context.abrupt("return", undefined);
799
+ case 21:
800
+ _context2.prev = 21;
985
801
 
986
- case 8:
987
- case "end":
988
- return _context.stop();
802
+ if (folderToCleanUp) {
803
+ void fs.promises.rm(folderToCleanUp, {
804
+ recursive: true,
805
+ force: true
806
+ });
989
807
  }
990
- }
991
- }, _callee);
992
- }));
993
808
 
994
- function send(_x) {
995
- return _send.apply(this, arguments);
996
- }
809
+ return _context2.finish(21);
997
810
 
998
- return send;
999
- }()
1000
- };
811
+ case 24:
812
+ case "end":
813
+ return _context2.stop();
814
+ }
815
+ }
816
+ }, _callee2, null, [[1, 15, 21, 24]]);
817
+ }))();
1001
818
  }
1002
- });
1003
- var hub = new Hub(client);
1004
- return {
1005
- sentryClient: client,
1006
- sentryHub: hub
1007
819
  };
1008
820
  }
821
+ function prepareBundleForDebugIdUpload(_x3, _x4, _x5, _x6) {
822
+ return _prepareBundleForDebugIdUpload.apply(this, arguments);
823
+ }
1009
824
  /**
1010
- * Adds a span to the passed parentSpan or to the current transaction that's on the passed hub's scope.
825
+ * Looks for a particular string pattern (`sdbid-[debug ID]`) in the bundle
826
+ * source and extracts the bundle's debug ID from it.
827
+ *
828
+ * The string pattern is injected via the debug ID injection snipped.
1011
829
  */
1012
830
 
1013
- function addSpanToTransaction(ctx, op, description) {
1014
- var _hub$getScope;
831
+ function _prepareBundleForDebugIdUpload() {
832
+ _prepareBundleForDebugIdUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(bundleFilePath, uploadFolder, uniqueUploadName, logger) {
833
+ var bundleContent, debugId, writeSourceFilePromise, writeSourceMapFilePromise;
834
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
835
+ while (1) {
836
+ switch (_context4.prev = _context4.next) {
837
+ case 0:
838
+ _context4.prev = 0;
839
+ _context4.next = 3;
840
+ return promisify(fs.readFile)(bundleFilePath, "utf8");
1015
841
 
1016
- var hub = ctx.hub,
1017
- parentSpan = ctx.parentSpan;
1018
- var actualSpan = parentSpan || ((_hub$getScope = hub.getScope()) === null || _hub$getScope === void 0 ? void 0 : _hub$getScope.getTransaction());
1019
- var span = actualSpan === null || actualSpan === void 0 ? void 0 : actualSpan.startChild({
1020
- op: op,
1021
- description: description
1022
- });
1023
- hub.configureScope(function (scope) {
1024
- return scope.setSpan(span);
1025
- });
1026
- return span;
1027
- }
1028
- function addPluginOptionInformationToHub(options, hub, bundler) {
1029
- var org = options.org,
1030
- project = options.project,
1031
- cleanArtifacts = options.cleanArtifacts,
1032
- finalize = options.finalize,
1033
- setCommits = options.setCommits,
1034
- injectReleasesMap = options.injectReleasesMap,
1035
- dryRun = options.dryRun,
1036
- errorHandler = options.errorHandler,
1037
- deploy = options.deploy,
1038
- include = options.include;
1039
- hub.setTag("include", include.length > 1 ? "multiple-entries" : "single-entry"); // Optional release pipeline steps
842
+ case 3:
843
+ bundleContent = _context4.sent;
844
+ _context4.next = 10;
845
+ break;
1040
846
 
1041
- if (cleanArtifacts) {
1042
- hub.setTag("clean-artifacts", true);
1043
- }
847
+ case 6:
848
+ _context4.prev = 6;
849
+ _context4.t0 = _context4["catch"](0);
850
+ logger.error("Could not read bundle to determine debug ID and source map: ".concat(bundleFilePath), _context4.t0);
851
+ return _context4.abrupt("return");
1044
852
 
1045
- if (setCommits) {
1046
- hub.setTag("set-commits", setCommits.auto === true ? "auto" : "manual");
1047
- }
853
+ case 10:
854
+ debugId = determineDebugIdFromBundleSource(bundleContent);
1048
855
 
1049
- if (finalize) {
1050
- hub.setTag("finalize-release", true);
1051
- }
856
+ if (!(debugId === undefined)) {
857
+ _context4.next = 14;
858
+ break;
859
+ }
1052
860
 
1053
- if (deploy) {
1054
- hub.setTag("add-deploy", true);
1055
- } // Miscelaneous options
861
+ logger.warn("Could not determine debug ID from bundle. This can happen if you did not clean your output folder before installing the Sentry plugin. File will not be source mapped: ".concat(bundleFilePath));
862
+ return _context4.abrupt("return");
1056
863
 
864
+ case 14:
865
+ bundleContent += "\n//# debugId=".concat(debugId);
866
+ writeSourceFilePromise = fs.promises.writeFile(path.join(uploadFolder, "".concat(uniqueUploadName, ".js")), bundleContent, "utf-8");
867
+ writeSourceMapFilePromise = determineSourceMapPathFromBundle(bundleFilePath, bundleContent, logger).then( /*#__PURE__*/function () {
868
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(sourceMapPath) {
869
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
870
+ while (1) {
871
+ switch (_context3.prev = _context3.next) {
872
+ case 0:
873
+ if (!sourceMapPath) {
874
+ _context3.next = 4;
875
+ break;
876
+ }
877
+
878
+ _context3.next = 3;
879
+ return prepareSourceMapForDebugIdUpload(sourceMapPath, path.join(uploadFolder, "".concat(uniqueUploadName, ".js.map")), debugId, logger);
880
+
881
+ case 3:
882
+ return _context3.abrupt("return", _context3.sent);
883
+
884
+ case 4:
885
+ case "end":
886
+ return _context3.stop();
887
+ }
888
+ }
889
+ }, _callee3);
890
+ }));
1057
891
 
1058
- if (dryRun) {
1059
- hub.setTag("dry-run", true);
1060
- }
892
+ return function (_x14) {
893
+ return _ref3.apply(this, arguments);
894
+ };
895
+ }());
896
+ return _context4.abrupt("return", Promise.all([writeSourceFilePromise, writeSourceMapFilePromise]));
1061
897
 
1062
- if (injectReleasesMap) {
1063
- hub.setTag("inject-releases-map", true);
1064
- }
898
+ case 18:
899
+ case "end":
900
+ return _context4.stop();
901
+ }
902
+ }
903
+ }, _callee4, null, [[0, 6]]);
904
+ }));
905
+ return _prepareBundleForDebugIdUpload.apply(this, arguments);
906
+ }
1065
907
 
1066
- if (errorHandler) {
1067
- hub.setTag("error-handler", "custom");
1068
- }
908
+ function determineDebugIdFromBundleSource(code) {
909
+ var match = code.match(/sentry-dbid-([0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12})/);
1069
910
 
1070
- hub.setTag("node", process.version);
1071
- hub.setTags({
1072
- organization: org,
1073
- project: project,
1074
- bundler: bundler
1075
- });
1076
- hub.setUser({
1077
- id: org
1078
- });
911
+ if (match) {
912
+ return match[1];
913
+ } else {
914
+ return undefined;
915
+ }
1079
916
  }
1080
- function shouldSendTelemetry(_x2) {
1081
- return _shouldSendTelemetry.apply(this, arguments);
917
+ /**
918
+ * Applies a set of heuristics to find the source map for a particular bundle.
919
+ *
920
+ * @returns the path to the bundle's source map or `undefined` if none could be found.
921
+ */
922
+
923
+
924
+ function determineSourceMapPathFromBundle(_x7, _x8, _x9) {
925
+ return _determineSourceMapPathFromBundle.apply(this, arguments);
1082
926
  }
927
+ /**
928
+ * Reads a source map, injects debug ID fields, and writes the source map to the target path.
929
+ */
1083
930
 
1084
- function _shouldSendTelemetry() {
1085
- _shouldSendTelemetry = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
1086
- var _cliInfo$split$, _cliInfo$split$$repla;
1087
931
 
1088
- var silent, org, project, authToken, url, vcsRemote, headers, telemetry, dryRun, cli, cliInfo, cliInfoUrl;
1089
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
932
+ function _determineSourceMapPathFromBundle() {
933
+ _determineSourceMapPathFromBundle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(bundlePath, bundleSource, logger) {
934
+ var sourceMappingUrlMatch, sourceMappingUrl, adjacentSourceMapFilePath;
935
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
1090
936
  while (1) {
1091
- switch (_context2.prev = _context2.next) {
937
+ switch (_context5.prev = _context5.next) {
1092
938
  case 0:
1093
- silent = options.silent, org = options.org, project = options.project, authToken = options.authToken, url = options.url, vcsRemote = options.vcsRemote, headers = options.headers, telemetry = options.telemetry, dryRun = options.dryRun; // `options.telemetry` defaults to true
1094
-
1095
- if (!(telemetry === false)) {
1096
- _context2.next = 3;
1097
- break;
1098
- }
1099
-
1100
- return _context2.abrupt("return", false);
939
+ // 1. try to find source map at `sourceMappingURL` location
940
+ sourceMappingUrlMatch = bundleSource.match(/^\/\/# sourceMappingURL=(.*)$/);
1101
941
 
1102
- case 3:
1103
- if (!dryRun) {
1104
- _context2.next = 5;
942
+ if (!sourceMappingUrlMatch) {
943
+ _context5.next = 8;
1105
944
  break;
1106
945
  }
1107
946
 
1108
- return _context2.abrupt("return", false);
947
+ sourceMappingUrl = path.normalize(sourceMappingUrlMatch[1]);
1109
948
 
1110
- case 5:
1111
- if (!(url === SENTRY_SAAS_URL)) {
1112
- _context2.next = 7;
949
+ if (!path.isAbsolute(sourceMappingUrl)) {
950
+ _context5.next = 7;
1113
951
  break;
1114
952
  }
1115
953
 
1116
- return _context2.abrupt("return", true);
954
+ return _context5.abrupt("return", sourceMappingUrl);
1117
955
 
1118
956
  case 7:
1119
- cli = new SentryCli(options.configFile, {
1120
- url: url,
1121
- authToken: authToken,
1122
- org: org,
1123
- project: project,
1124
- vcsRemote: vcsRemote,
1125
- silent: silent,
1126
- headers: headers
1127
- });
1128
- _context2.prev = 8;
1129
- _context2.next = 11;
1130
- return cli.execute(["info"], false);
1131
-
1132
- case 11:
1133
- cliInfo = _context2.sent;
1134
- _context2.next = 17;
1135
- break;
1136
-
1137
- case 14:
1138
- _context2.prev = 14;
1139
- _context2.t0 = _context2["catch"](8);
1140
- throw new Error('Sentry CLI "info" command failed, make sure you have an auth token configured, and your `url` option is correct.');
957
+ return _context5.abrupt("return", path.join(path.dirname(bundlePath), sourceMappingUrl));
1141
958
 
1142
- case 17:
1143
- cliInfoUrl = (_cliInfo$split$ = cliInfo.split(/(\r\n|\n|\r)/)[0]) === null || _cliInfo$split$ === void 0 ? void 0 : (_cliInfo$split$$repla = _cliInfo$split$.replace(/^Sentry Server: /, "")) === null || _cliInfo$split$$repla === void 0 ? void 0 : _cliInfo$split$$repla.trim();
959
+ case 8:
960
+ _context5.prev = 8;
961
+ adjacentSourceMapFilePath = bundlePath + ".map";
962
+ _context5.next = 12;
963
+ return util.promisify(fs.access)(adjacentSourceMapFilePath);
1144
964
 
1145
- if (!(cliInfoUrl === undefined)) {
1146
- _context2.next = 20;
1147
- break;
1148
- }
965
+ case 12:
966
+ return _context5.abrupt("return", adjacentSourceMapFilePath);
1149
967
 
1150
- return _context2.abrupt("return", false);
968
+ case 15:
969
+ _context5.prev = 15;
970
+ _context5.t0 = _context5["catch"](8);
1151
971
 
1152
- case 20:
1153
- return _context2.abrupt("return", new URL(cliInfoUrl).hostname === SENTRY_SAAS_HOSTNAME);
972
+ case 17:
973
+ logger.warn("Could not determine source map path for bundle: ".concat(bundlePath));
974
+ return _context5.abrupt("return", undefined);
1154
975
 
1155
- case 21:
976
+ case 19:
1156
977
  case "end":
1157
- return _context2.stop();
978
+ return _context5.stop();
1158
979
  }
1159
980
  }
1160
- }, _callee2, null, [[8, 14]]);
981
+ }, _callee5, null, [[8, 15]]);
1161
982
  }));
1162
- return _shouldSendTelemetry.apply(this, arguments);
983
+ return _determineSourceMapPathFromBundle.apply(this, arguments);
1163
984
  }
1164
985
 
1165
- function createNewRelease(_x, _x2, _x3) {
1166
- return _createNewRelease.apply(this, arguments);
986
+ function prepareSourceMapForDebugIdUpload(_x10, _x11, _x12, _x13) {
987
+ return _prepareSourceMapForDebugIdUpload.apply(this, arguments);
1167
988
  }
1168
989
 
1169
- function _createNewRelease() {
1170
- _createNewRelease = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options, ctx, releaseName) {
1171
- var span;
1172
- return _regeneratorRuntime().wrap(function _callee$(_context) {
990
+ function _prepareSourceMapForDebugIdUpload() {
991
+ _prepareSourceMapForDebugIdUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(sourceMapPath, targetPath, debugId, logger) {
992
+ var sourceMapFileContent, map;
993
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
1173
994
  while (1) {
1174
- switch (_context.prev = _context.next) {
995
+ switch (_context6.prev = _context6.next) {
1175
996
  case 0:
1176
- span = addSpanToTransaction(ctx, "function.plugin.create_release");
1177
- _context.prev = 1;
1178
- _context.next = 4;
1179
- return ctx.cli.releases["new"](releaseName);
997
+ _context6.prev = 0;
998
+ _context6.next = 3;
999
+ return util.promisify(fs.readFile)(sourceMapPath, {
1000
+ encoding: "utf8"
1001
+ });
1180
1002
 
1181
- case 4:
1182
- _context.next = 10;
1003
+ case 3:
1004
+ sourceMapFileContent = _context6.sent;
1005
+ _context6.next = 10;
1183
1006
  break;
1184
1007
 
1185
1008
  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;
1009
+ _context6.prev = 6;
1010
+ _context6.t0 = _context6["catch"](0);
1011
+ logger.error("Failed to read source map for debug ID upload: ".concat(sourceMapPath), _context6.t0);
1012
+ return _context6.abrupt("return");
1190
1013
 
1191
1014
  case 10:
1192
- _context.prev = 10;
1193
- span === null || span === void 0 ? void 0 : span.finish();
1194
- return _context.finish(10);
1195
-
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:
1204
- case "end":
1205
- return _context.stop();
1206
- }
1207
- }
1208
- }, _callee, null, [[1, 6, 10, 13]]);
1209
- }));
1210
- return _createNewRelease.apply(this, arguments);
1211
- }
1212
-
1213
- function cleanArtifacts(_x4, _x5, _x6) {
1214
- return _cleanArtifacts.apply(this, arguments);
1215
- }
1216
-
1217
- function _cleanArtifacts() {
1218
- _cleanArtifacts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options, ctx, releaseName) {
1219
- var span;
1220
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1221
- while (1) {
1222
- switch (_context2.prev = _context2.next) {
1223
- case 0:
1224
- if (options.cleanArtifacts) {
1225
- _context2.next = 3;
1226
- break;
1227
- }
1228
-
1229
- logger.debug("Skipping artifact cleanup.");
1230
- return _context2.abrupt("return");
1231
-
1232
- case 3:
1233
- span = addSpanToTransaction(ctx, "function.plugin.clean_artifacts");
1234
- _context2.prev = 4;
1235
- _context2.next = 7;
1236
- return ctx.cli.releases.execute(["releases", "files", releaseName, "delete", "--all"], true);
1015
+ _context6.prev = 10;
1016
+ map = JSON.parse(sourceMapFileContent); // For now we write both fields until we know what will become the standard - if ever.
1237
1017
 
1238
- case 7:
1239
- _context2.next = 13;
1018
+ map["debug_id"] = debugId;
1019
+ map["debugId"] = debugId;
1020
+ _context6.next = 20;
1240
1021
  break;
1241
1022
 
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;
1250
- span === null || span === void 0 ? void 0 : span.finish();
1251
- return _context2.finish(13);
1252
-
1253
1023
  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:
1261
- case "end":
1262
- return _context2.stop();
1263
- }
1264
- }
1265
- }, _callee2, null, [[4, 9, 13, 16]]);
1266
- }));
1267
- return _cleanArtifacts.apply(this, arguments);
1268
- }
1269
-
1270
- function uploadSourceMaps(_x7, _x8, _x9) {
1271
- return _uploadSourceMaps.apply(this, arguments);
1272
- }
1024
+ _context6.prev = 16;
1025
+ _context6.t1 = _context6["catch"](10);
1026
+ logger.error("Failed to parse source map for debug ID upload: ".concat(sourceMapPath));
1027
+ return _context6.abrupt("return");
1273
1028
 
1274
- function _uploadSourceMaps() {
1275
- _uploadSourceMaps = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(options, ctx, releaseName) {
1276
- var span;
1277
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1278
- while (1) {
1279
- switch (_context3.prev = _context3.next) {
1280
- case 0:
1281
- span = addSpanToTransaction(ctx, "function.plugin.upload_sourcemaps");
1282
- ctx.logger.info("Uploading Sourcemaps."); // Since our internal include entries contain all top-level sourcemaps options,
1283
- // we only need to pass the include option here.
1284
-
1285
- _context3.prev = 2;
1286
- _context3.next = 5;
1287
- return ctx.cli.releases.uploadSourceMaps(releaseName, {
1288
- include: options.include,
1289
- dist: options.dist
1029
+ case 20:
1030
+ _context6.prev = 20;
1031
+ _context6.next = 23;
1032
+ return util.promisify(fs.writeFile)(targetPath, JSON.stringify(map), {
1033
+ encoding: "utf8"
1290
1034
  });
1291
1035
 
1292
- case 5:
1293
- _context3.next = 11;
1036
+ case 23:
1037
+ _context6.next = 29;
1294
1038
  break;
1295
1039
 
1296
- case 7:
1297
- _context3.prev = 7;
1298
- _context3.t0 = _context3["catch"](2);
1299
- ctx.hub.captureException(new Error("CLI Error: Uploading source maps failed"));
1300
- throw _context3.t0;
1301
-
1302
- case 11:
1303
- _context3.prev = 11;
1304
- span === null || span === void 0 ? void 0 : span.finish();
1305
- return _context3.finish(11);
1306
-
1307
- case 14:
1308
- ctx.hub.addBreadcrumb({
1309
- level: "info",
1310
- message: "Successfully uploaded source maps."
1311
- });
1312
- ctx.logger.info("Successfully uploaded source maps.");
1040
+ case 25:
1041
+ _context6.prev = 25;
1042
+ _context6.t2 = _context6["catch"](20);
1043
+ logger.error("Failed to prepare source map for debug ID upload: ".concat(sourceMapPath), _context6.t2);
1044
+ return _context6.abrupt("return");
1313
1045
 
1314
- case 16:
1046
+ case 29:
1315
1047
  case "end":
1316
- return _context3.stop();
1048
+ return _context6.stop();
1317
1049
  }
1318
1050
  }
1319
- }, _callee3, null, [[2, 7, 11, 14]]);
1051
+ }, _callee6, null, [[0, 6], [10, 16], [20, 25]]);
1320
1052
  }));
1321
- return _uploadSourceMaps.apply(this, arguments);
1053
+ return _prepareSourceMapForDebugIdUpload.apply(this, arguments);
1322
1054
  }
1323
1055
 
1324
- function setCommits(_x10, _x11, _x12) {
1325
- return _setCommits.apply(this, arguments);
1326
- }
1056
+ function releaseManagementPlugin(_ref) {
1057
+ var releaseName = _ref.releaseName,
1058
+ include = _ref.include,
1059
+ dist = _ref.dist,
1060
+ setCommitsOption = _ref.setCommitsOption,
1061
+ shouldCreateRelease = _ref.shouldCreateRelease,
1062
+ shouldCleanArtifacts = _ref.shouldCleanArtifacts,
1063
+ shouldFinalizeRelease = _ref.shouldFinalizeRelease,
1064
+ deployOptions = _ref.deployOptions,
1065
+ handleRecoverableError = _ref.handleRecoverableError,
1066
+ sentryHub = _ref.sentryHub,
1067
+ sentryClient = _ref.sentryClient,
1068
+ sentryCliOptions = _ref.sentryCliOptions;
1069
+ return {
1070
+ name: "sentry-debug-id-upload-plugin",
1071
+ writeBundle: function writeBundle() {
1072
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1073
+ var cliInstance, normalizedInclude;
1074
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1075
+ while (1) {
1076
+ switch (_context.prev = _context.next) {
1077
+ case 0:
1078
+ _context.prev = 0;
1079
+ cliInstance = new SentryCli(null, sentryCliOptions);
1327
1080
 
1328
- function _setCommits() {
1329
- _setCommits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(options, ctx, releaseName) {
1330
- var span, _options$setCommits, auto, repo, commit, previousCommit, ignoreMissing, ignoreEmpty;
1081
+ if (!shouldCreateRelease) {
1082
+ _context.next = 5;
1083
+ break;
1084
+ }
1331
1085
 
1332
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
1333
- while (1) {
1334
- switch (_context4.prev = _context4.next) {
1335
- case 0:
1336
- if (options.setCommits) {
1337
- _context4.next = 3;
1338
- break;
1339
- }
1086
+ _context.next = 5;
1087
+ return cliInstance.releases["new"](releaseName);
1340
1088
 
1341
- logger.debug("Skipping setting commits to release.");
1342
- return _context4.abrupt("return");
1089
+ case 5:
1090
+ if (!shouldCleanArtifacts) {
1091
+ _context.next = 8;
1092
+ break;
1093
+ }
1343
1094
 
1344
- case 3:
1345
- span = addSpanToTransaction(ctx, "function.plugin.set_commits");
1346
- _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;
1347
- _context4.prev = 5;
1348
- _context4.next = 8;
1349
- return ctx.cli.releases.setCommits(releaseName, {
1350
- commit: commit,
1351
- previousCommit: previousCommit,
1352
- repo: repo,
1353
- auto: auto,
1354
- ignoreMissing: ignoreMissing,
1355
- ignoreEmpty: ignoreEmpty
1356
- });
1095
+ _context.next = 8;
1096
+ return cliInstance.releases.execute(["releases", "files", releaseName, "delete", "--all"], true);
1357
1097
 
1358
- case 8:
1359
- _context4.next = 14;
1360
- break;
1098
+ case 8:
1099
+ if (!include) {
1100
+ _context.next = 12;
1101
+ break;
1102
+ }
1361
1103
 
1362
- case 10:
1363
- _context4.prev = 10;
1364
- _context4.t0 = _context4["catch"](5);
1365
- ctx.hub.captureException(new Error("CLI Error: Setting commits failed"));
1366
- throw _context4.t0;
1104
+ normalizedInclude = arrayify(include).map(function (includeItem) {
1105
+ return typeof includeItem === "string" ? {
1106
+ paths: [includeItem]
1107
+ } : includeItem;
1108
+ }).map(function (includeEntry) {
1109
+ var _includeEntry$validat;
1110
+
1111
+ return _objectSpread2(_objectSpread2({}, includeEntry), {}, {
1112
+ validate: (_includeEntry$validat = includeEntry.validate) !== null && _includeEntry$validat !== void 0 ? _includeEntry$validat : false,
1113
+ ext: includeEntry.ext ? includeEntry.ext.map(function (extension) {
1114
+ return ".".concat(extension.replace(/^\./, ""));
1115
+ }) : [".js", ".map", ".jsbundle", ".bundle"],
1116
+ ignore: includeEntry.ignore ? arrayify(includeEntry.ignore) : undefined
1117
+ });
1118
+ });
1119
+ _context.next = 12;
1120
+ return cliInstance.releases.uploadSourceMaps(releaseName, {
1121
+ include: normalizedInclude,
1122
+ dist: dist
1123
+ });
1367
1124
 
1368
- case 14:
1369
- _context4.prev = 14;
1370
- span === null || span === void 0 ? void 0 : span.finish();
1371
- return _context4.finish(14);
1125
+ case 12:
1126
+ if (!setCommitsOption) {
1127
+ _context.next = 15;
1128
+ break;
1129
+ }
1372
1130
 
1373
- case 17:
1374
- ctx.logger.info("Successfully set commits.");
1131
+ _context.next = 15;
1132
+ return cliInstance.releases.setCommits(releaseName, setCommitsOption);
1375
1133
 
1376
- case 18:
1377
- case "end":
1378
- return _context4.stop();
1379
- }
1380
- }
1381
- }, _callee4, null, [[5, 10, 14, 17]]);
1382
- }));
1383
- return _setCommits.apply(this, arguments);
1384
- }
1134
+ case 15:
1135
+ if (!shouldFinalizeRelease) {
1136
+ _context.next = 18;
1137
+ break;
1138
+ }
1385
1139
 
1386
- function finalizeRelease(_x13, _x14, _x15) {
1387
- return _finalizeRelease.apply(this, arguments);
1388
- }
1140
+ _context.next = 18;
1141
+ return cliInstance.releases.finalize(releaseName);
1389
1142
 
1390
- function _finalizeRelease() {
1391
- _finalizeRelease = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(options, ctx, releaseName) {
1392
- var span;
1393
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
1394
- while (1) {
1395
- switch (_context5.prev = _context5.next) {
1396
- case 0:
1397
- if (options.finalize) {
1398
- _context5.next = 4;
1399
- break;
1400
- }
1143
+ case 18:
1144
+ if (!deployOptions) {
1145
+ _context.next = 21;
1146
+ break;
1147
+ }
1401
1148
 
1402
- ctx.hub.addBreadcrumb({
1403
- level: "info",
1404
- message: "Skipping release finalization."
1405
- });
1406
- logger.debug("Skipping release finalization.");
1407
- return _context5.abrupt("return");
1149
+ _context.next = 21;
1150
+ return cliInstance.releases.newDeploy(releaseName, deployOptions);
1408
1151
 
1409
- case 4:
1410
- span = addSpanToTransaction(ctx, "function.plugin.finalize_release");
1411
- _context5.prev = 5;
1412
- _context5.next = 8;
1413
- return ctx.cli.releases.finalize(releaseName);
1152
+ case 21:
1153
+ _context.next = 29;
1154
+ break;
1414
1155
 
1415
- case 8:
1416
- _context5.next = 14;
1417
- break;
1156
+ case 23:
1157
+ _context.prev = 23;
1158
+ _context.t0 = _context["catch"](0);
1159
+ sentryHub.captureException('Error in "releaseManagementPlugin" writeBundle hook');
1160
+ _context.next = 28;
1161
+ return sentryClient.flush();
1418
1162
 
1419
- case 10:
1420
- _context5.prev = 10;
1421
- _context5.t0 = _context5["catch"](5);
1422
- ctx.hub.captureException(new Error("CLI Error: Finalizing release failed"));
1423
- throw _context5.t0;
1163
+ case 28:
1164
+ handleRecoverableError(_context.t0);
1424
1165
 
1425
- case 14:
1426
- _context5.prev = 14;
1427
- span === null || span === void 0 ? void 0 : span.finish();
1428
- return _context5.finish(14);
1166
+ case 29:
1167
+ case "end":
1168
+ return _context.stop();
1169
+ }
1170
+ }
1171
+ }, _callee, null, [[0, 23]]);
1172
+ }))();
1173
+ }
1174
+ };
1175
+ }
1429
1176
 
1430
- case 17:
1431
- ctx.hub.addBreadcrumb({
1432
- level: "info",
1433
- message: "Successfully finalized release."
1434
- });
1435
- ctx.logger.info("Successfully finalized release.");
1177
+ function telemetryPlugin(_ref) {
1178
+ var sentryClient = _ref.sentryClient,
1179
+ pluginExecutionTransaction = _ref.pluginExecutionTransaction,
1180
+ shouldSendTelemetry = _ref.shouldSendTelemetry,
1181
+ logger = _ref.logger;
1182
+ return {
1183
+ name: "sentry-telemetry-plugin",
1184
+ buildStart: function buildStart() {
1185
+ void shouldSendTelemetry.then(function () {
1186
+ logger.info("Sending error and performance telemetry data to Sentry. To disable telemetry, set `options.telemetry` to `false`.");
1187
+ });
1188
+ pluginExecutionTransaction.startTimestamp = Date.now() / 1000;
1189
+ },
1190
+ writeBundle: function writeBundle() {
1191
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1192
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1193
+ while (1) {
1194
+ switch (_context.prev = _context.next) {
1195
+ case 0:
1196
+ pluginExecutionTransaction.finish();
1197
+ _context.next = 3;
1198
+ return sentryClient.flush();
1436
1199
 
1437
- case 19:
1438
- case "end":
1439
- return _context5.stop();
1440
- }
1441
- }
1442
- }, _callee5, null, [[5, 10, 14, 17]]);
1443
- }));
1444
- return _finalizeRelease.apply(this, arguments);
1200
+ case 3:
1201
+ case "end":
1202
+ return _context.stop();
1203
+ }
1204
+ }
1205
+ }, _callee);
1206
+ }))();
1207
+ }
1208
+ };
1445
1209
  }
1446
1210
 
1447
- function addDeploy(_x16, _x17, _x18) {
1448
- return _addDeploy.apply(this, arguments);
1449
- }
1211
+ function createLogger(options) {
1212
+ return {
1213
+ info: function info(message) {
1214
+ if (!options.silent) {
1215
+ var _console;
1450
1216
 
1451
- function _addDeploy() {
1452
- _addDeploy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(options, ctx, releaseName) {
1453
- var span, _options$deploy, env, started, finished, time, name, url;
1454
-
1455
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
1456
- while (1) {
1457
- switch (_context6.prev = _context6.next) {
1458
- case 0:
1459
- if (options.deploy) {
1460
- _context6.next = 4;
1461
- break;
1462
- }
1463
-
1464
- ctx.hub.addBreadcrumb({
1465
- level: "info",
1466
- message: "Skipping adding deploy info to release."
1467
- });
1468
- logger.debug("Skipping adding deploy info to release.");
1469
- return _context6.abrupt("return");
1470
-
1471
- case 4:
1472
- span = addSpanToTransaction(ctx, "function.plugin.deploy");
1473
- _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;
1474
- _context6.prev = 6;
1475
- _context6.next = 9;
1476
- return ctx.cli.releases.newDeploy(releaseName, {
1477
- env: env,
1478
- started: started,
1479
- finished: finished,
1480
- time: time,
1481
- name: name,
1482
- url: url
1483
- });
1484
-
1485
- case 9:
1486
- _context6.next = 15;
1487
- break;
1488
-
1489
- case 11:
1490
- _context6.prev = 11;
1491
- _context6.t0 = _context6["catch"](6);
1492
- ctx.hub.captureException(new Error("CLI Error: Adding deploy info failed"));
1493
- throw _context6.t0;
1494
-
1495
- case 15:
1496
- _context6.prev = 15;
1497
- span === null || span === void 0 ? void 0 : span.finish();
1498
- return _context6.finish(15);
1499
-
1500
- case 18:
1501
- ctx.hub.addBreadcrumb({
1502
- level: "info",
1503
- message: "Successfully added deploy."
1504
- });
1505
- ctx.logger.info("Successfully added deploy.");
1506
-
1507
- case 20:
1508
- case "end":
1509
- return _context6.stop();
1510
- }
1511
- }
1512
- }, _callee6, null, [[6, 11, 15, 18]]);
1513
- }));
1514
- return _addDeploy.apply(this, arguments);
1515
- }
1516
-
1517
- function createLogger(options) {
1518
- return {
1519
- info: function info(message) {
1520
- if (!options.silent) {
1521
- var _console;
1522
-
1523
- for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1524
- params[_key - 1] = arguments[_key];
1525
- }
1217
+ for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1218
+ params[_key - 1] = arguments[_key];
1219
+ }
1526
1220
 
1527
1221
  // eslint-disable-next-line no-console
1528
1222
  (_console = console).log.apply(_console, ["".concat(options.prefix, " Info: ").concat(message)].concat(params));
@@ -1567,91 +1261,222 @@ function createLogger(options) {
1567
1261
  };
1568
1262
  }
1569
1263
 
1570
- /**
1571
- * Creates a new Sentry CLI instance.
1572
- *
1573
- * In case, users selected the `dryRun` options, this returns a stub
1574
- * that makes no-ops out of most CLI operations
1575
- */
1576
- function getSentryCli(internalOptions, logger) {
1577
- var silent = internalOptions.silent,
1578
- org = internalOptions.org,
1579
- project = internalOptions.project,
1580
- authToken = internalOptions.authToken,
1581
- url = internalOptions.url,
1582
- vcsRemote = internalOptions.vcsRemote,
1583
- headers = internalOptions.headers;
1584
- var cli = new SentryCli(internalOptions.configFile, {
1585
- url: url,
1586
- authToken: authToken,
1587
- org: org,
1588
- project: project,
1589
- vcsRemote: vcsRemote,
1590
- silent: silent,
1591
- headers: headers
1264
+ var SENTRY_SAAS_HOSTNAME = "sentry.io";
1265
+ function createSentryInstance(options, shouldSendTelemetry, bundler) {
1266
+ var client = new NodeClient({
1267
+ dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
1268
+ tracesSampleRate: 1,
1269
+ sampleRate: 1,
1270
+ release: "2.0.0-alpha.2",
1271
+ integrations: [],
1272
+ tracePropagationTargets: ["sentry.io/api"],
1273
+ stackParser: defaultStackParser,
1274
+ beforeSend: function beforeSend(event) {
1275
+ var _event$exception, _event$exception$valu;
1276
+
1277
+ (_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) {
1278
+ delete exception.stacktrace;
1279
+ });
1280
+ delete event.server_name; // Server name might contain PII
1281
+
1282
+ return event;
1283
+ },
1284
+ beforeSendTransaction: function beforeSendTransaction(event) {
1285
+ delete event.server_name; // Server name might contain PII
1286
+
1287
+ return event;
1288
+ },
1289
+ // We create a transport that stalls sending events until we know that we're allowed to (i.e. when Sentry CLI told
1290
+ // us that the upload URL is the Sentry SaaS URL)
1291
+ transport: function transport(nodeTransportOptions) {
1292
+ var nodeTransport = makeNodeTransport(nodeTransportOptions);
1293
+ return {
1294
+ flush: function flush(timeout) {
1295
+ return nodeTransport.flush(timeout);
1296
+ },
1297
+ send: function () {
1298
+ var _send = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
1299
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1300
+ while (1) {
1301
+ switch (_context.prev = _context.next) {
1302
+ case 0:
1303
+ _context.next = 2;
1304
+ return shouldSendTelemetry;
1305
+
1306
+ case 2:
1307
+ if (!_context.sent) {
1308
+ _context.next = 6;
1309
+ break;
1310
+ }
1311
+
1312
+ return _context.abrupt("return", nodeTransport.send(request));
1313
+
1314
+ case 6:
1315
+ return _context.abrupt("return", undefined);
1316
+
1317
+ case 7:
1318
+ case "end":
1319
+ return _context.stop();
1320
+ }
1321
+ }
1322
+ }, _callee);
1323
+ }));
1324
+
1325
+ function send(_x) {
1326
+ return _send.apply(this, arguments);
1327
+ }
1328
+
1329
+ return send;
1330
+ }()
1331
+ };
1332
+ }
1592
1333
  });
1334
+ var hub = new Hub(client);
1335
+ setTelemetryDataOnHub(options, hub, bundler);
1336
+ return {
1337
+ sentryHub: hub,
1338
+ sentryClient: client
1339
+ };
1340
+ }
1341
+ function setTelemetryDataOnHub(options, hub, bundler) {
1342
+ var org = options.org,
1343
+ project = options.project,
1344
+ release = options.release,
1345
+ errorHandler = options.errorHandler,
1346
+ sourcemaps = options.sourcemaps;
1347
+
1348
+ if (release.uploadLegacySourcemaps) {
1349
+ hub.setTag("uploadLegacySourcemapsEntries", Array.isArray(release.uploadLegacySourcemaps) ? release.uploadLegacySourcemaps.length : 1);
1350
+ } // Optional release pipeline steps
1351
+
1352
+
1353
+ if (release.cleanArtifacts) {
1354
+ hub.setTag("clean-artifacts", true);
1355
+ }
1356
+
1357
+ if (release.setCommits) {
1358
+ hub.setTag("set-commits", release.setCommits.auto === true ? "auto" : "manual");
1359
+ }
1360
+
1361
+ if (release.finalize) {
1362
+ hub.setTag("finalize-release", true);
1363
+ }
1364
+
1365
+ if (release.deploy) {
1366
+ hub.setTag("add-deploy", true);
1367
+ } // Miscelaneous options
1368
+
1369
+
1370
+ if (errorHandler) {
1371
+ hub.setTag("error-handler", "custom");
1372
+ }
1373
+
1374
+ if (sourcemaps !== null && sourcemaps !== void 0 && sourcemaps.assets) {
1375
+ hub.setTag("debug-id-upload", true);
1376
+ }
1593
1377
 
1594
- if (internalOptions.dryRun) {
1595
- logger.info("In DRY RUN Mode");
1596
- return getDryRunCLI(cli, logger);
1378
+ if (sourcemaps !== null && sourcemaps !== void 0 && sourcemaps.deleteAfterUpload) {
1379
+ hub.setTag("delete-after-upload", true);
1597
1380
  }
1598
1381
 
1599
- return cli;
1382
+ hub.setTag("node", process.version);
1383
+ hub.setTags({
1384
+ organization: org,
1385
+ project: project,
1386
+ bundler: bundler
1387
+ });
1388
+ hub.setUser({
1389
+ id: org
1390
+ });
1391
+ }
1392
+ function allowedToSendTelemetry(_x2) {
1393
+ return _allowedToSendTelemetry.apply(this, arguments);
1600
1394
  }
1601
1395
 
1602
- function getDryRunCLI(cli, logger) {
1603
- return {
1604
- releases: {
1605
- proposeVersion: function proposeVersion() {
1606
- return cli.releases.proposeVersion().then(function (version) {
1607
- logger.info("Proposed version:\n", version);
1608
- return version;
1609
- });
1610
- },
1611
- "new": function _new(release) {
1612
- logger.info("Creating new release:\n", release);
1613
- return Promise.resolve(release);
1614
- },
1615
- uploadSourceMaps: function uploadSourceMaps(release, config) {
1616
- logger.info("Calling upload-sourcemaps with:\n", config);
1617
- return Promise.resolve(release);
1618
- },
1619
- finalize: function finalize(release) {
1620
- logger.info("Finalizing release:\n", release);
1621
- return Promise.resolve(release);
1622
- },
1623
- setCommits: function setCommits(release, config) {
1624
- logger.info("Calling set-commits with:\n", config);
1625
- return Promise.resolve(release);
1626
- },
1627
- newDeploy: function newDeploy(release, config) {
1628
- logger.info("Calling deploy with:\n", config);
1629
- return Promise.resolve(release);
1630
- },
1631
- execute: function execute(args, live) {
1632
- logger.info("Executing", args, "live:", live);
1633
- return Promise.resolve("");
1396
+ function _allowedToSendTelemetry() {
1397
+ _allowedToSendTelemetry = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
1398
+ var _cliInfo$split$, _cliInfo$split$$repla;
1399
+
1400
+ var silent, org, project, authToken, url, headers, telemetry, release, cli, cliInfo, cliInfoUrl;
1401
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1402
+ while (1) {
1403
+ switch (_context2.prev = _context2.next) {
1404
+ case 0:
1405
+ silent = options.silent, org = options.org, project = options.project, authToken = options.authToken, url = options.url, headers = options.headers, telemetry = options.telemetry, release = options.release; // `options.telemetry` defaults to true
1406
+
1407
+ if (!(telemetry === false)) {
1408
+ _context2.next = 3;
1409
+ break;
1410
+ }
1411
+
1412
+ return _context2.abrupt("return", false);
1413
+
1414
+ case 3:
1415
+ if (!(url === SENTRY_SAAS_URL)) {
1416
+ _context2.next = 5;
1417
+ break;
1418
+ }
1419
+
1420
+ return _context2.abrupt("return", true);
1421
+
1422
+ case 5:
1423
+ cli = new SentryCli(null, {
1424
+ url: url,
1425
+ authToken: authToken,
1426
+ org: org,
1427
+ project: project,
1428
+ vcsRemote: release.vcsRemote,
1429
+ silent: silent,
1430
+ headers: headers
1431
+ });
1432
+ _context2.prev = 6;
1433
+ _context2.next = 9;
1434
+ return cli.execute(["info"], false);
1435
+
1436
+ case 9:
1437
+ cliInfo = _context2.sent;
1438
+ _context2.next = 15;
1439
+ break;
1440
+
1441
+ case 12:
1442
+ _context2.prev = 12;
1443
+ _context2.t0 = _context2["catch"](6);
1444
+ return _context2.abrupt("return", false);
1445
+
1446
+ case 15:
1447
+ cliInfoUrl = (_cliInfo$split$ = cliInfo.split(/(\r\n|\n|\r)/)[0]) === null || _cliInfo$split$ === void 0 ? void 0 : (_cliInfo$split$$repla = _cliInfo$split$.replace(/^Sentry Server: /, "")) === null || _cliInfo$split$$repla === void 0 ? void 0 : _cliInfo$split$$repla.trim();
1448
+
1449
+ if (!(cliInfoUrl === undefined)) {
1450
+ _context2.next = 18;
1451
+ break;
1452
+ }
1453
+
1454
+ return _context2.abrupt("return", false);
1455
+
1456
+ case 18:
1457
+ return _context2.abrupt("return", new URL(cliInfoUrl).hostname === SENTRY_SAAS_HOSTNAME);
1458
+
1459
+ case 19:
1460
+ case "end":
1461
+ return _context2.stop();
1462
+ }
1634
1463
  }
1635
- },
1636
- execute: function execute(args, live) {
1637
- logger.info("Executing", args, "live:", live);
1638
- return Promise.resolve("Executed");
1639
- }
1640
- };
1464
+ }, _callee2, null, [[6, 12]]);
1465
+ }));
1466
+ return _allowedToSendTelemetry.apply(this, arguments);
1641
1467
  }
1642
1468
 
1643
- var ALLOWED_TRANSFORMATION_FILE_ENDINGS = [".js", ".ts", ".jsx", ".tsx", ".mjs"];
1644
1469
  /**
1645
1470
  * The sentry bundler plugin concerns itself with two things:
1646
1471
  * - Release injection
1647
1472
  * - Sourcemaps upload
1648
1473
  *
1649
1474
  * Release injection:
1650
- * Per default the sentry bundler plugin will inject a global `SENTRY_RELEASE` into
1651
- * each JavaScript/TypeScript entrypoint. On a technical level this is done by identifying
1652
- * entrypoints in the `resolveId` hook and prepending user code in the `transform` hook.
1653
- * If a user wants to inject the release into a particular set of modules instead,
1654
- * they can use the `releaseInjectionTargets` option.
1475
+ * Per default the sentry bundler plugin will inject a global `SENTRY_RELEASE` into each JavaScript/TypeScript module
1476
+ * that is part of the bundle. On a technical level this is done by appending an import (`import "sentry-release-injector;"`)
1477
+ * to all entrypoint files of the user code (see `transformInclude` and `transform` hooks). This import is then resolved
1478
+ * by the sentry plugin to a virtual module that sets the global variable (see `resolveId` and `load` hooks).
1479
+ * If a user wants to inject the release into a particular set of modules they can use the `releaseInjectionTargets` option.
1655
1480
  *
1656
1481
  * Source maps upload:
1657
1482
  *
@@ -1668,392 +1493,266 @@ var ALLOWED_TRANSFORMATION_FILE_ENDINGS = [".js", ".ts", ".jsx", ".tsx", ".mjs"]
1668
1493
  *
1669
1494
  * This release creation pipeline relies on Sentry CLI to execute the different steps.
1670
1495
  */
1671
-
1672
- var unplugin = createUnplugin(function (options, unpluginMetaContext) {
1673
- var internalOptions = normalizeUserOptions(options);
1674
- var allowedToSendTelemetryPromise = shouldSendTelemetry(internalOptions);
1675
-
1676
- var _makeSentryClient = makeSentryClient("https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737", allowedToSendTelemetryPromise, internalOptions.project),
1677
- sentryHub = _makeSentryClient.sentryHub,
1678
- sentryClient = _makeSentryClient.sentryClient;
1679
-
1680
- addPluginOptionInformationToHub(internalOptions, sentryHub, unpluginMetaContext.framework); //TODO: This call is problematic because as soon as we set our hub as the current hub
1681
- // we might interfere with other plugins that use Sentry. However, for now, we'll
1682
- // leave it in because without it, we can't get distributed traces (which are pretty nice)
1683
- // Let's keep it until someone complains about interference.
1684
- // The ideal solution would be a code change in the JS SDK but it's not a straight-forward fix.
1685
-
1686
- makeMain(sentryHub);
1687
- var logger = createLogger({
1688
- prefix: "[sentry-".concat(unpluginMetaContext.framework, "-plugin]"),
1689
- silent: internalOptions.silent,
1690
- debug: internalOptions.debug
1691
- });
1692
-
1693
- if (!validateOptions(internalOptions, logger)) {
1694
- handleError(new Error("Options were not set correctly. See output above for more details."), logger, internalOptions.errorHandler);
1695
- }
1696
-
1697
- var cli = getSentryCli(internalOptions, logger);
1698
- var releaseNamePromise = new Promise(function (resolve) {
1699
- if (options.release) {
1700
- resolve(options.release);
1701
- } else {
1702
- resolve(cli.releases.proposeVersion());
1496
+ function sentryUnpluginFactory(_ref) {
1497
+ var releaseInjectionPlugin = _ref.releaseInjectionPlugin,
1498
+ debugIdInjectionPlugin = _ref.debugIdInjectionPlugin;
1499
+ return createUnplugin(function (userOptions, unpluginMetaContext) {
1500
+ var options = normalizeUserOptions(userOptions);
1501
+
1502
+ if (unpluginMetaContext.watchMode || options.disable) {
1503
+ return [{
1504
+ name: "sentry-noop-plugin"
1505
+ }];
1703
1506
  }
1704
- });
1705
- var transaction;
1706
- var releaseInjectionSpan;
1707
- var absolueEntrypointPaths = new Set();
1708
- return {
1709
- name: "sentry-plugin",
1710
- enforce: "pre",
1711
- // needed for Vite to call resolveId hook
1712
1507
 
1713
- /**
1714
- * Responsible for starting the plugin execution transaction and the release injection span
1715
- */
1716
- buildStart: function buildStart() {
1717
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1718
- var isAllowedToSendToSendTelemetry, releaseName;
1719
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1720
- while (1) {
1721
- switch (_context.prev = _context.next) {
1722
- case 0:
1723
- logger.debug("Called 'buildStart'");
1724
- _context.next = 3;
1725
- return allowedToSendTelemetryPromise;
1508
+ var shouldSendTelemetry = allowedToSendTelemetry(options);
1726
1509
 
1727
- case 3:
1728
- isAllowedToSendToSendTelemetry = _context.sent;
1729
-
1730
- if (isAllowedToSendToSendTelemetry) {
1731
- logger.info("Sending error and performance telemetry data to Sentry.");
1732
- logger.info("To disable telemetry, set `options.telemetry` to `false`.");
1733
- sentryHub.addBreadcrumb({
1734
- level: "info",
1735
- message: "Telemetry enabled."
1736
- });
1737
- } else {
1738
- sentryHub.addBreadcrumb({
1739
- level: "info",
1740
- message: "Telemetry disabled. This should never show up in a Sentry event."
1741
- });
1742
- }
1510
+ var _createSentryInstance = createSentryInstance(options, shouldSendTelemetry, unpluginMetaContext.framework),
1511
+ sentryHub = _createSentryInstance.sentryHub,
1512
+ sentryClient = _createSentryInstance.sentryClient;
1743
1513
 
1744
- _context.next = 7;
1745
- return releaseNamePromise;
1514
+ var pluginExecutionTransaction = sentryHub.startTransaction({
1515
+ name: "Sentry Bundler Plugin execution"
1516
+ });
1517
+ sentryHub.getScope().setSpan(pluginExecutionTransaction);
1518
+ var logger = createLogger({
1519
+ prefix: "[sentry-".concat(unpluginMetaContext.framework, "-plugin]"),
1520
+ silent: options.silent,
1521
+ debug: options.debug
1522
+ });
1746
1523
 
1747
- case 7:
1748
- releaseName = _context.sent;
1524
+ function handleRecoverableError(unknownError) {
1525
+ pluginExecutionTransaction.setStatus("internal_error");
1749
1526
 
1750
- // At this point, we either have determined a release or we have to bail
1751
- if (!releaseName) {
1752
- 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);
1753
- }
1527
+ if (options.errorHandler) {
1528
+ if (unknownError instanceof Error) {
1529
+ options.errorHandler(unknownError);
1530
+ } else {
1531
+ options.errorHandler(new Error("An unknown error occured"));
1532
+ }
1533
+ } else {
1534
+ throw unknownError;
1535
+ }
1536
+ }
1754
1537
 
1755
- transaction = sentryHub.startTransaction({
1756
- op: "function.plugin",
1757
- name: "Sentry Bundler Plugin execution"
1758
- });
1759
- releaseInjectionSpan = addSpanToTransaction({
1760
- hub: sentryHub,
1761
- parentSpan: transaction,
1762
- logger: logger,
1763
- cli: cli
1764
- }, "function.plugin.inject_release", "Release injection");
1538
+ if (!validateOptions(options, logger)) {
1539
+ handleRecoverableError(new Error("Options were not set correctly. See output above for more details."));
1540
+ }
1765
1541
 
1766
- case 11:
1767
- case "end":
1768
- return _context.stop();
1769
- }
1770
- }
1771
- }, _callee);
1772
- }))();
1773
- },
1542
+ if (process.cwd().match(/\\node_modules\\|\/node_modules\//)) {
1543
+ logger.warn("Running Sentry plugin from within a `node_modules` folder. Some features may not work.");
1544
+ }
1774
1545
 
1775
- /**
1776
- * Responsible for returning the "sentry-release-injector" ID when we encounter it. We return the ID so load is
1777
- * called and we can "virtually" load the module. See `load` hook for more info on why it's virtual.
1778
- *
1779
- * We also record the id (i.e. absolute path) of any non-entrypoint.
1780
- *
1781
- * @param id For imports: The absolute path of the module to be imported. For entrypoints: The path the user defined as entrypoint - may also be relative.
1782
- * @param importer For imports: The absolute path of the module that imported this module. For entrypoints: `undefined`.
1783
- * @param options Additional information to use for making a resolving decision.
1784
- * @returns `"sentry-release-injector"` when the imported file is called `"sentry-release-injector"`. Otherwise returns `undefined`.
1785
- */
1786
- resolveId: function resolveId(id, importer, _ref) {
1787
- var isEntry = _ref.isEntry;
1788
- logger.debug('Called "resolveId":', {
1789
- id: id,
1790
- importer: importer,
1791
- isEntry: isEntry
1546
+ var plugins = [];
1547
+ plugins.push(telemetryPlugin({
1548
+ pluginExecutionTransaction: pluginExecutionTransaction,
1549
+ logger: logger,
1550
+ shouldSendTelemetry: shouldSendTelemetry,
1551
+ sentryClient: sentryClient
1552
+ }));
1553
+
1554
+ if (!options.release.inject) {
1555
+ logger.debug("Release injection disabled via `release.inject` option. Will not inject release.");
1556
+ } else if (!options.release.name) {
1557
+ logger.warn("No release name provided. Will not inject release. Please set the `release.name` option to identifiy your release.");
1558
+ } else {
1559
+ var _injectionCode = generateGlobalInjectorCode({
1560
+ release: options.release.name,
1561
+ injectBuildInformation: options._experiments.injectBuildInformation || false
1792
1562
  });
1793
1563
 
1794
- if (isEntry) {
1795
- absolueEntrypointPaths.add(path.resolve(path.normalize(id)));
1796
- }
1797
-
1798
- return undefined;
1799
- },
1564
+ plugins.push(releaseInjectionPlugin(_injectionCode));
1565
+ }
1800
1566
 
1801
- /**
1802
- * This hook determines whether we want to transform a module. In the sentry bundler plugin we want to transform every entrypoint
1803
- * unless configured otherwise with the `releaseInjectionTargets` option.
1804
- *
1805
- * @param id Always the absolute (fully resolved) path to the module.
1806
- * @returns `true` or `false` depending on whether we want to transform the module. For the sentry bundler plugin we only
1807
- * want to transform the release injector file.
1808
- */
1809
- transformInclude: function transformInclude(id) {
1810
- logger.debug('Called "transformInclude":', {
1811
- id: id
1812
- }); // We normalize the id because vite always passes `id` as a unix style path which causes problems when a user passes
1813
- // a windows style path to `releaseInjectionTargets`
1814
-
1815
- var normalizedId = path.normalize(id);
1816
-
1817
- if (internalOptions.releaseInjectionTargets) {
1818
- // If there's an `releaseInjectionTargets` option transform (ie. inject the release varible) when the file path matches the option.
1819
- if (typeof internalOptions.releaseInjectionTargets === "function") {
1820
- return internalOptions.releaseInjectionTargets(normalizedId);
1567
+ if (!options.release.name) {
1568
+ logger.warn("No release name provided. Will not create release. Please set the `release.name` option to identifiy your release.");
1569
+ } else if (!options.authToken) {
1570
+ 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/");
1571
+ } else if (!options.org) {
1572
+ logger.warn("No organization slug provided. Will not create release. Please set the `org` option to your Sentry organization slug.");
1573
+ } else if (!options.project) {
1574
+ logger.warn("No project provided. Will not create release. Please set the `project` option to your Sentry project slug.");
1575
+ } else {
1576
+ plugins.push(releaseManagementPlugin({
1577
+ logger: logger,
1578
+ releaseName: options.release.name,
1579
+ shouldCreateRelease: options.release.create,
1580
+ shouldCleanArtifacts: options.release.cleanArtifacts,
1581
+ shouldFinalizeRelease: options.release.finalize,
1582
+ include: options.release.uploadLegacySourcemaps,
1583
+ setCommitsOption: options.release.setCommits,
1584
+ deployOptions: options.release.deploy,
1585
+ dist: options.release.dist,
1586
+ handleRecoverableError: handleRecoverableError,
1587
+ sentryHub: sentryHub,
1588
+ sentryClient: sentryClient,
1589
+ sentryCliOptions: {
1590
+ authToken: options.authToken,
1591
+ org: options.org,
1592
+ project: options.project,
1593
+ silent: options.silent,
1594
+ url: options.url,
1595
+ vcsRemote: options.release.vcsRemote,
1596
+ headers: options.headers
1821
1597
  }
1598
+ }));
1599
+ }
1822
1600
 
1823
- return internalOptions.releaseInjectionTargets.some(function (entry) {
1824
- if (entry instanceof RegExp) {
1825
- return entry.test(normalizedId);
1826
- } else {
1827
- var normalizedEntry = path.normalize(entry);
1828
- return normalizedId === normalizedEntry;
1829
- }
1830
- });
1831
- } else if (absolueEntrypointPaths.has(normalizedId)) {
1832
- var pathIsOrdinary = !normalizedId.includes("?") && !normalizedId.includes("#");
1833
- var pathHasAllowedFileEnding = ALLOWED_TRANSFORMATION_FILE_ENDINGS.some(function (allowedFileEnding) {
1834
- return normalizedId.endsWith(allowedFileEnding);
1835
- });
1836
- return pathIsOrdinary && pathHasAllowedFileEnding;
1601
+ if (options.sourcemaps) {
1602
+ if (!options.authToken) {
1603
+ 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/");
1604
+ } else if (!options.org) {
1605
+ logger.warn("No org provided. Will not upload source maps. Please set the `org` option to your Sentry organization slug.");
1606
+ } else if (!options.project) {
1607
+ logger.warn("No project provided. Will not upload source maps. Please set the `project` option to your Sentry project slug.");
1608
+ } else if (!options.sourcemaps.assets) {
1609
+ logger.warn("No assets defined. Will not upload source maps. Please provide set the `assets` option to your build-output folder.");
1837
1610
  } else {
1838
- return false;
1611
+ plugins.push(debugIdInjectionPlugin());
1612
+ plugins.push(debugIdUploadPlugin({
1613
+ assets: options.sourcemaps.assets,
1614
+ ignore: options.sourcemaps.ignore,
1615
+ dist: options.release.dist,
1616
+ releaseName: options.release.name,
1617
+ logger: logger,
1618
+ handleRecoverableError: handleRecoverableError,
1619
+ sentryHub: sentryHub,
1620
+ sentryClient: sentryClient,
1621
+ sentryCliOptions: {
1622
+ authToken: options.authToken,
1623
+ org: options.org,
1624
+ project: options.project,
1625
+ silent: options.silent,
1626
+ url: options.url,
1627
+ vcsRemote: options.release.vcsRemote,
1628
+ headers: options.headers
1629
+ }
1630
+ }));
1839
1631
  }
1840
- },
1632
+ }
1841
1633
 
1842
- /**
1843
- * This hook is responsible for injecting the "sentry release injector" imoprt statement into each entrypoint unless
1844
- * configured otherwise with the `releaseInjectionTargets` option (logic for that is in the `transformInclude` hook).
1845
- *
1846
- * @param code Code of the file to transform.
1847
- * @param id Always the absolute (fully resolved) path to the module.
1848
- * @returns transformed code + source map
1849
- */
1850
- transform: function transform(code, id) {
1851
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
1852
- var ms;
1853
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1854
- while (1) {
1855
- switch (_context2.prev = _context2.next) {
1856
- case 0:
1857
- logger.debug('Called "transform":', {
1858
- id: id
1859
- }); // The MagicString library allows us to generate sourcemaps for the changes we make to the user code.
1860
-
1861
- ms = new MagicString(code);
1862
- _context2.t0 = ms;
1863
- _context2.t1 = generateGlobalInjectorCode;
1864
- _context2.next = 6;
1865
- return releaseNamePromise;
1866
-
1867
- case 6:
1868
- _context2.t2 = _context2.sent;
1869
- _context2.t3 = internalOptions.injectReleasesMap;
1870
- _context2.t4 = internalOptions.org;
1871
- _context2.t5 = internalOptions.project;
1872
- _context2.t6 = {
1873
- release: _context2.t2,
1874
- injectReleasesMap: _context2.t3,
1875
- org: _context2.t4,
1876
- project: _context2.t5
1877
- };
1878
- _context2.t7 = (0, _context2.t1)(_context2.t6);
1879
-
1880
- _context2.t0.prepend.call(_context2.t0, _context2.t7);
1881
-
1882
- if (!(unpluginMetaContext.framework === "esbuild")) {
1883
- _context2.next = 17;
1884
- break;
1885
- }
1634
+ return plugins;
1635
+ });
1636
+ }
1637
+ function getBuildInformation() {
1638
+ var packageJson = getPackageJson();
1886
1639
 
1887
- return _context2.abrupt("return", ms.toString());
1640
+ var _ref2 = packageJson ? getDependencies(packageJson) : {
1641
+ deps: [],
1642
+ depsVersions: {}
1643
+ },
1644
+ deps = _ref2.deps,
1645
+ depsVersions = _ref2.depsVersions;
1888
1646
 
1889
- case 17:
1890
- return _context2.abrupt("return", {
1891
- code: ms.toString(),
1892
- map: ms.generateMap()
1893
- });
1647
+ return {
1648
+ deps: deps,
1649
+ depsVersions: depsVersions,
1650
+ nodeVersion: parseMajorVersion(process.version)
1651
+ };
1652
+ }
1653
+ /**
1654
+ * Determines whether the Sentry CLI binary is in its expected location.
1655
+ * This function is useful since `@sentry/cli` installs the binary via a post-install
1656
+ * script and post-install scripts may not always run. E.g. with `npm i --ignore-scripts`.
1657
+ */
1894
1658
 
1895
- case 18:
1896
- case "end":
1897
- return _context2.stop();
1898
- }
1899
- }
1900
- }, _callee2);
1901
- }))();
1659
+ function sentryCliBinaryExists() {
1660
+ return fs.existsSync(SentryCli.getPath());
1661
+ }
1662
+ function createRollupReleaseInjectionHooks(injectionCode) {
1663
+ var virtualReleaseInjectionFileId = "\0sentry-release-injection-file";
1664
+ return {
1665
+ resolveId: function resolveId(id) {
1666
+ if (id === virtualReleaseInjectionFileId) {
1667
+ return {
1668
+ id: virtualReleaseInjectionFileId,
1669
+ external: false,
1670
+ moduleSideEffects: true
1671
+ };
1672
+ } else {
1673
+ return null;
1674
+ }
1902
1675
  },
1676
+ load: function load(id) {
1677
+ if (id === virtualReleaseInjectionFileId) {
1678
+ return injectionCode;
1679
+ } else {
1680
+ return null;
1681
+ }
1682
+ },
1683
+ transform: function transform(code, id) {
1684
+ if (id === virtualReleaseInjectionFileId) {
1685
+ return null;
1686
+ }
1903
1687
 
1904
- /**
1905
- * Responsible for executing the sentry release creation pipeline (i.e. creating a release on
1906
- * Sentry.io, uploading sourcemaps, associating commits and deploys and finalizing the release)
1907
- */
1908
- writeBundle: function writeBundle() {
1909
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
1910
- var _releaseInjectionSpan;
1911
-
1912
- var releasePipelineSpan, ctx, releaseName, _transaction, _transaction2, _transaction3;
1913
-
1914
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1915
- while (1) {
1916
- switch (_context3.prev = _context3.next) {
1917
- case 0:
1918
- logger.debug('Called "writeBundle"');
1919
- (_releaseInjectionSpan = releaseInjectionSpan) === null || _releaseInjectionSpan === void 0 ? void 0 : _releaseInjectionSpan.finish();
1920
- releasePipelineSpan = transaction && addSpanToTransaction({
1921
- hub: sentryHub,
1922
- parentSpan: transaction,
1923
- logger: logger,
1924
- cli: cli
1925
- }, "function.plugin.release", "Release pipeline");
1926
- sentryHub.addBreadcrumb({
1927
- category: "writeBundle:start",
1928
- level: "info"
1929
- });
1930
- ctx = {
1931
- hub: sentryHub,
1932
- parentSpan: releasePipelineSpan,
1933
- logger: logger,
1934
- cli: cli
1935
- };
1936
- _context3.next = 7;
1937
- return releaseNamePromise;
1938
-
1939
- case 7:
1940
- releaseName = _context3.sent;
1941
- _context3.prev = 8;
1942
- _context3.next = 11;
1943
- return createNewRelease(internalOptions, ctx, releaseName);
1944
-
1945
- case 11:
1946
- _context3.next = 13;
1947
- return cleanArtifacts(internalOptions, ctx, releaseName);
1948
-
1949
- case 13:
1950
- _context3.next = 15;
1951
- return uploadSourceMaps(internalOptions, ctx, releaseName);
1952
-
1953
- case 15:
1954
- _context3.next = 17;
1955
- return setCommits(internalOptions, ctx, releaseName);
1956
-
1957
- case 17:
1958
- _context3.next = 19;
1959
- return finalizeRelease(internalOptions, ctx, releaseName);
1960
-
1961
- case 19:
1962
- _context3.next = 21;
1963
- return addDeploy(internalOptions, ctx, releaseName);
1964
-
1965
- case 21:
1966
- (_transaction = transaction) === null || _transaction === void 0 ? void 0 : _transaction.setStatus("ok");
1967
- _context3.next = 29;
1968
- break;
1969
-
1970
- case 24:
1971
- _context3.prev = 24;
1972
- _context3.t0 = _context3["catch"](8);
1973
- (_transaction2 = transaction) === null || _transaction2 === void 0 ? void 0 : _transaction2.setStatus("cancelled");
1974
- sentryHub.addBreadcrumb({
1975
- level: "error",
1976
- message: "Error during writeBundle"
1977
- });
1978
- handleError(_context3.t0, logger, internalOptions.errorHandler);
1979
-
1980
- case 29:
1981
- _context3.prev = 29;
1982
- releasePipelineSpan === null || releasePipelineSpan === void 0 ? void 0 : releasePipelineSpan.finish();
1983
- (_transaction3 = transaction) === null || _transaction3 === void 0 ? void 0 : _transaction3.finish();
1984
- _context3.next = 34;
1985
- return sentryClient.flush().then(null, function () {
1986
- logger.warn("Sending of telemetry failed");
1987
- });
1688
+ if (id.match(/\\node_modules\\|\/node_modules\//)) {
1689
+ return null;
1690
+ }
1988
1691
 
1989
- case 34:
1990
- return _context3.finish(29);
1692
+ if (![".js", ".ts", ".jsx", ".tsx", ".mjs"].some(function (ending) {
1693
+ return id.endsWith(ending);
1694
+ })) {
1695
+ return null;
1696
+ }
1991
1697
 
1992
- case 35:
1993
- sentryHub.addBreadcrumb({
1994
- category: "writeBundle:finish",
1995
- level: "info"
1996
- });
1698
+ var ms = new MagicString(code); // Appending instead of prepending has less probability of mucking with user's source maps.
1699
+ // Luckily import statements get hoisted to the top anyways.
1997
1700
 
1998
- case 36:
1999
- case "end":
2000
- return _context3.stop();
2001
- }
2002
- }
2003
- }, _callee3, null, [[8, 24, 29, 35]]);
2004
- }))();
1701
+ ms.append("\n\n;import \"".concat(virtualReleaseInjectionFileId, "\";"));
1702
+ return {
1703
+ code: ms.toString(),
1704
+ map: ms.generateMap()
1705
+ };
2005
1706
  }
2006
1707
  };
2007
- });
2008
-
2009
- function handleError(unknownError, logger, errorHandler) {
2010
- if (unknownError instanceof Error) {
2011
- logger.error(unknownError.message);
2012
- } else {
2013
- logger.error(String(unknownError));
2014
- }
1708
+ }
1709
+ function createRollupDebugIdInjectionHooks() {
1710
+ return {
1711
+ renderChunk: function renderChunk(code, chunk) {
1712
+ if ([".js", ".mjs", ".cjs"].some(function (ending) {
1713
+ return chunk.fileName.endsWith(ending);
1714
+ }) // chunks could be any file (html, md, ...)
1715
+ ) {
1716
+ var _code$match;
1717
+
1718
+ var debugId = stringToUUID(code); // generate a deterministic debug ID
1719
+
1720
+ var codeToInject = getDebugIdSnippet(debugId);
1721
+ var ms = new MagicString(code, {
1722
+ filename: chunk.fileName
1723
+ }); // We need to be careful not to inject the snippet before any `"use strict";`s.
1724
+ // As an additional complication `"use strict";`s may come after any number of comments.
1725
+
1726
+ var commentUseStrictRegex = // Note: CodeQL complains that this regex potentially has n^2 runtime. This likely won't affect realistic files.
1727
+ /^(?:\s*|\/\*(?:.|\r|\n)*\*\/|\/\/.*[\n\r])*(?:"[^"]*";|'[^']*';)?/;
1728
+
1729
+ if ((_code$match = code.match(commentUseStrictRegex)) !== null && _code$match !== void 0 && _code$match[0]) {
1730
+ // Add injected code after any comments or "use strict" at the beginning of the bundle.
1731
+ ms.replace(commentUseStrictRegex, function (match) {
1732
+ return "".concat(match).concat(codeToInject);
1733
+ });
1734
+ } else {
1735
+ // ms.replace() doesn't work when there is an empty string match (which happens if
1736
+ // there is neither, a comment, nor a "use strict" at the top of the chunk) so we
1737
+ // need this special case here.
1738
+ ms.prepend(codeToInject);
1739
+ }
2015
1740
 
2016
- if (errorHandler) {
2017
- if (unknownError instanceof Error) {
2018
- errorHandler(unknownError);
2019
- } else {
2020
- errorHandler(new Error("An unknown error occured"));
1741
+ return {
1742
+ code: ms.toString(),
1743
+ map: ms.generateMap({
1744
+ file: chunk.fileName
1745
+ })
1746
+ };
1747
+ } else {
1748
+ return null; // returning null means not modifying the chunk at all
1749
+ }
2021
1750
  }
2022
- } else {
2023
- throw unknownError;
2024
- }
1751
+ };
1752
+ }
1753
+ function getDebugIdSnippet(debugId) {
1754
+ return ";!function(){try{var e=\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]=\"".concat(debugId, "\",e._sentryDebugIdIdentifier=\"sentry-dbid-").concat(debugId, "\")}catch(e){}}();");
2025
1755
  }
2026
- /**
2027
- * Generates code for the "sentry-release-injector" which is responsible for setting the global `SENTRY_RELEASE`
2028
- * variable.
2029
- */
2030
-
2031
-
2032
- function generateGlobalInjectorCode(_ref2) {
2033
- var release = _ref2.release,
2034
- injectReleasesMap = _ref2.injectReleasesMap,
2035
- org = _ref2.org,
2036
- project = _ref2.project;
2037
- // The code below is mostly ternary operators because it saves bundle size.
2038
- // The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
2039
- var code = "\n var _global =\n typeof window !== 'undefined' ?\n window :\n typeof global !== 'undefined' ?\n global :\n typeof self !== 'undefined' ?\n self :\n {};\n\n _global.SENTRY_RELEASE={id:\"".concat(release, "\"};");
2040
-
2041
- if (injectReleasesMap && project) {
2042
- var key = org ? "".concat(project, "@").concat(org) : project;
2043
- code += "\n _global.SENTRY_RELEASES=_global.SENTRY_RELEASES || {};\n _global.SENTRY_RELEASES[\"".concat(key, "\"]={id:\"").concat(release, "\"};");
2044
- }
2045
-
2046
- return code;
2047
- } // eslint-disable-next-line @typescript-eslint/no-explicit-any
2048
-
2049
-
2050
- var sentryVitePlugin = unplugin.vite; // eslint-disable-next-line @typescript-eslint/no-explicit-any
2051
-
2052
- var sentryRollupPlugin = unplugin.rollup; // eslint-disable-next-line @typescript-eslint/no-explicit-any
2053
-
2054
- var sentryWebpackPlugin = unplugin.webpack; // eslint-disable-next-line @typescript-eslint/no-explicit-any
2055
-
2056
- var sentryEsbuildPlugin = unplugin.esbuild;
2057
1756
 
2058
- export { sentryEsbuildPlugin, sentryRollupPlugin, sentryVitePlugin, sentryWebpackPlugin };
1757
+ export { createRollupDebugIdInjectionHooks, createRollupReleaseInjectionHooks, getBuildInformation, getDebugIdSnippet, sentryCliBinaryExists, sentryUnpluginFactory };
2059
1758
  //# sourceMappingURL=index.mjs.map