@sentry/bundler-plugin-core 3.3.1 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +1650 -1480
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.mjs +1667 -1499
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/build-plugin-manager.d.ts +66 -0
- package/dist/types/build-plugin-manager.d.ts.map +1 -0
- package/dist/types/debug-id-upload.d.ts +13 -28
- package/dist/types/debug-id-upload.d.ts.map +1 -1
- package/dist/types/index.d.ts +10 -29
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logger.d.ts.map +1 -0
- package/dist/types/options-mapping.d.ts +32 -31
- package/dist/types/options-mapping.d.ts.map +1 -1
- package/dist/types/sentry/telemetry.d.ts +2 -2
- package/dist/types/sentry/telemetry.d.ts.map +1 -1
- package/dist/types/types.d.ts +23 -1
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils.d.ts +1 -0
- package/dist/types/utils.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/types/plugins/release-management.d.ts +0 -40
- package/dist/types/plugins/release-management.d.ts.map +0 -1
- package/dist/types/plugins/sourcemap-deletion.d.ts +0 -16
- package/dist/types/plugins/sourcemap-deletion.d.ts.map +0 -1
- package/dist/types/plugins/telemetry.d.ts +0 -13
- package/dist/types/plugins/telemetry.d.ts.map +0 -1
- package/dist/types/sentry/logger.d.ts.map +0 -1
- /package/dist/types/{sentry/logger.d.ts → logger.d.ts} +0 -0
package/dist/cjs/index.js
CHANGED
|
@@ -2,23 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var SentryCli = require('@sentry/cli');
|
|
6
5
|
var core = require('@babel/core');
|
|
7
6
|
var componentNameAnnotatePlugin = require('@sentry/babel-plugin-component-annotate');
|
|
7
|
+
var SentryCli = require('@sentry/cli');
|
|
8
8
|
var fs = require('fs');
|
|
9
|
-
var
|
|
9
|
+
var glob = require('glob');
|
|
10
10
|
var MagicString = require('magic-string');
|
|
11
|
+
var path = require('path');
|
|
11
12
|
var unplugin = require('unplugin');
|
|
12
|
-
var
|
|
13
|
+
var dotenv = require('dotenv');
|
|
13
14
|
var os = require('os');
|
|
15
|
+
var findUp = require('find-up');
|
|
14
16
|
var crypto = require('crypto');
|
|
15
17
|
var childProcess = require('child_process');
|
|
16
|
-
var glob = require('glob');
|
|
17
|
-
var util = require('util');
|
|
18
18
|
var https = require('node:https');
|
|
19
19
|
var node_stream = require('node:stream');
|
|
20
20
|
var node_zlib = require('node:zlib');
|
|
21
|
-
var
|
|
21
|
+
var url = require('url');
|
|
22
|
+
var util = require('util');
|
|
22
23
|
|
|
23
24
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
24
25
|
|
|
@@ -40,20 +41,22 @@ function _interopNamespace(e) {
|
|
|
40
41
|
return Object.freeze(n);
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
var SentryCli__default = /*#__PURE__*/_interopDefaultLegacy(SentryCli);
|
|
44
44
|
var componentNameAnnotatePlugin__default = /*#__PURE__*/_interopDefaultLegacy(componentNameAnnotatePlugin);
|
|
45
|
+
var SentryCli__default = /*#__PURE__*/_interopDefaultLegacy(SentryCli);
|
|
45
46
|
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
46
47
|
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
48
|
+
var MagicString__default = /*#__PURE__*/_interopDefaultLegacy(MagicString);
|
|
47
49
|
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
48
50
|
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
49
|
-
var
|
|
50
|
-
var findUp__default = /*#__PURE__*/_interopDefaultLegacy(findUp);
|
|
51
|
+
var dotenv__namespace = /*#__PURE__*/_interopNamespace(dotenv);
|
|
51
52
|
var os__default = /*#__PURE__*/_interopDefaultLegacy(os);
|
|
53
|
+
var os__namespace = /*#__PURE__*/_interopNamespace(os);
|
|
54
|
+
var findUp__default = /*#__PURE__*/_interopDefaultLegacy(findUp);
|
|
52
55
|
var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto);
|
|
53
56
|
var childProcess__default = /*#__PURE__*/_interopDefaultLegacy(childProcess);
|
|
54
|
-
var util__namespace = /*#__PURE__*/_interopNamespace(util);
|
|
55
57
|
var https__namespace = /*#__PURE__*/_interopNamespace(https);
|
|
56
|
-
var
|
|
58
|
+
var url__namespace = /*#__PURE__*/_interopNamespace(url);
|
|
59
|
+
var util__namespace = /*#__PURE__*/_interopNamespace(util);
|
|
57
60
|
|
|
58
61
|
function ownKeys(object, enumerableOnly) {
|
|
59
62
|
var keys = Object.keys(object);
|
|
@@ -445,559 +448,168 @@ function _toPropertyKey(arg) {
|
|
|
445
448
|
return typeof key === "symbol" ? key : String(key);
|
|
446
449
|
}
|
|
447
450
|
|
|
451
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
452
|
+
const objectToString = Object.prototype.toString;
|
|
453
|
+
|
|
448
454
|
/**
|
|
449
|
-
* Checks whether
|
|
455
|
+
* Checks whether given value's type is one of a few Error or Error-like
|
|
456
|
+
* {@link isError}.
|
|
450
457
|
*
|
|
451
|
-
* @param
|
|
452
|
-
* @returns
|
|
458
|
+
* @param wat A value to be checked.
|
|
459
|
+
* @returns A boolean representing the result.
|
|
453
460
|
*/
|
|
454
|
-
function
|
|
455
|
-
|
|
461
|
+
function isError(wat) {
|
|
462
|
+
switch (objectToString.call(wat)) {
|
|
463
|
+
case '[object Error]':
|
|
464
|
+
case '[object Exception]':
|
|
465
|
+
case '[object DOMException]':
|
|
466
|
+
return true;
|
|
467
|
+
default:
|
|
468
|
+
return isInstanceOf(wat, Error);
|
|
469
|
+
}
|
|
456
470
|
}
|
|
457
471
|
/**
|
|
458
|
-
*
|
|
459
|
-
*
|
|
460
|
-
*
|
|
461
|
-
*
|
|
472
|
+
* Checks whether given value is an instance of the given built-in class.
|
|
473
|
+
*
|
|
474
|
+
* @param wat The value to be checked
|
|
475
|
+
* @param className
|
|
476
|
+
* @returns A boolean representing the result.
|
|
462
477
|
*/
|
|
463
|
-
function
|
|
464
|
-
|
|
465
|
-
cwd = _ref.cwd,
|
|
466
|
-
stopAt = _ref.stopAt;
|
|
467
|
-
return lookupPackageJson(cwd !== null && cwd !== void 0 ? cwd : process.cwd(), path__default["default"].normalize(stopAt !== null && stopAt !== void 0 ? stopAt : os__default["default"].homedir()));
|
|
478
|
+
function isBuiltin(wat, className) {
|
|
479
|
+
return objectToString.call(wat) === `[object ${className}]`;
|
|
468
480
|
}
|
|
469
|
-
function parseMajorVersion(version) {
|
|
470
|
-
// if it has a `v` prefix, remove it
|
|
471
|
-
if (version.startsWith("v")) {
|
|
472
|
-
version = version.slice(1);
|
|
473
|
-
}
|
|
474
481
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
if (!Number.isNaN(coerced)) {
|
|
485
|
-
return coerced;
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
// Match <= and >= ranges.
|
|
489
|
-
var gteLteRegex = /^[<>]=\s*(\d+)(\.\d+)?(\.\d+)?(-.+)?/;
|
|
490
|
-
var gteLteMatch = version.match(gteLteRegex);
|
|
491
|
-
if (gteLteMatch) {
|
|
492
|
-
return parseInt(gteLteMatch[1], 10);
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
// match < ranges
|
|
496
|
-
var ltRegex = /^<\s*(\d+)(\.\d+)?(\.\d+)?(-.+)?/;
|
|
497
|
-
var ltMatch = version.match(ltRegex);
|
|
498
|
-
if (ltMatch) {
|
|
499
|
-
// Two scenarios:
|
|
500
|
-
// a) < 2.0.0 --> return 1
|
|
501
|
-
// b) < 2.1.0 --> return 2
|
|
502
|
-
|
|
503
|
-
var major = parseInt(ltMatch[1], 10);
|
|
504
|
-
if (
|
|
505
|
-
// minor version > 0
|
|
506
|
-
typeof ltMatch[2] === "string" && parseInt(ltMatch[2].slice(1), 10) > 0 ||
|
|
507
|
-
// patch version > 0
|
|
508
|
-
typeof ltMatch[3] === "string" && parseInt(ltMatch[3].slice(1), 10) > 0) {
|
|
509
|
-
return major;
|
|
510
|
-
}
|
|
511
|
-
return major - 1;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
// match > ranges
|
|
515
|
-
var gtRegex = /^>\s*(\d+)(\.\d+)?(\.\d+)?(-.+)?/;
|
|
516
|
-
var gtMatch = version.match(gtRegex);
|
|
517
|
-
if (gtMatch) {
|
|
518
|
-
// We always return the version here, even though it _may_ be incorrect
|
|
519
|
-
// E.g. if given > 2.0.0, it should be 2 if there exists any 2.x.x version, else 3
|
|
520
|
-
// Since there is no way for us to know this, we're going to assume any kind of patch/feature release probably exists
|
|
521
|
-
return parseInt(gtMatch[1], 10);
|
|
522
|
-
}
|
|
523
|
-
return undefined;
|
|
482
|
+
/**
|
|
483
|
+
* Checks whether given value's type is ErrorEvent
|
|
484
|
+
* {@link isErrorEvent}.
|
|
485
|
+
*
|
|
486
|
+
* @param wat A value to be checked.
|
|
487
|
+
* @returns A boolean representing the result.
|
|
488
|
+
*/
|
|
489
|
+
function isErrorEvent$1(wat) {
|
|
490
|
+
return isBuiltin(wat, 'ErrorEvent');
|
|
524
491
|
}
|
|
525
492
|
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
var majorVersion = parseMajorVersion(version);
|
|
536
|
-
if (majorVersion) {
|
|
537
|
-
depsVersions[depName] = majorVersion;
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
return depsVersions;
|
|
541
|
-
}, {});
|
|
542
|
-
return {
|
|
543
|
-
deps: deps,
|
|
544
|
-
depsVersions: depsVersions
|
|
545
|
-
};
|
|
493
|
+
/**
|
|
494
|
+
* Checks whether given value's type is a string
|
|
495
|
+
* {@link isString}.
|
|
496
|
+
*
|
|
497
|
+
* @param wat A value to be checked.
|
|
498
|
+
* @returns A boolean representing the result.
|
|
499
|
+
*/
|
|
500
|
+
function isString(wat) {
|
|
501
|
+
return isBuiltin(wat, 'String');
|
|
546
502
|
}
|
|
547
|
-
function lookupPackageJson(cwd, stopAt) {
|
|
548
|
-
var jsonPath = findUp__default["default"].sync(function (dirName) {
|
|
549
|
-
// Stop if we reach this dir
|
|
550
|
-
if (path__default["default"].normalize(dirName) === stopAt) {
|
|
551
|
-
return findUp__default["default"].stop;
|
|
552
|
-
}
|
|
553
|
-
return findUp__default["default"].sync.exists(dirName + "/package.json") ? "package.json" : undefined;
|
|
554
|
-
}, {
|
|
555
|
-
cwd: cwd
|
|
556
|
-
});
|
|
557
|
-
if (!jsonPath) {
|
|
558
|
-
return undefined;
|
|
559
|
-
}
|
|
560
|
-
try {
|
|
561
|
-
var jsonStr = fs__default["default"].readFileSync(jsonPath, "utf8");
|
|
562
|
-
var json = JSON.parse(jsonStr);
|
|
563
|
-
|
|
564
|
-
// Ensure it is an actual package.json
|
|
565
|
-
// This is very much not bulletproof, but should be good enough
|
|
566
|
-
if ("name" in json || "private" in json) {
|
|
567
|
-
return json;
|
|
568
|
-
}
|
|
569
|
-
} catch (error) {
|
|
570
|
-
// Ignore and walk up
|
|
571
|
-
}
|
|
572
503
|
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
504
|
+
/**
|
|
505
|
+
* Checks whether given string is parameterized
|
|
506
|
+
* {@link isParameterizedString}.
|
|
507
|
+
*
|
|
508
|
+
* @param wat A value to be checked.
|
|
509
|
+
* @returns A boolean representing the result.
|
|
510
|
+
*/
|
|
511
|
+
function isParameterizedString(wat) {
|
|
512
|
+
return (
|
|
513
|
+
typeof wat === 'object' &&
|
|
514
|
+
wat !== null &&
|
|
515
|
+
'__sentry_template_string__' in wat &&
|
|
516
|
+
'__sentry_template_values__' in wat
|
|
517
|
+
);
|
|
576
518
|
}
|
|
577
519
|
|
|
578
520
|
/**
|
|
579
|
-
*
|
|
521
|
+
* Checks whether given value is a primitive (undefined, null, number, boolean, string, bigint, symbol)
|
|
522
|
+
* {@link isPrimitive}.
|
|
523
|
+
*
|
|
524
|
+
* @param wat A value to be checked.
|
|
525
|
+
* @returns A boolean representing the result.
|
|
580
526
|
*/
|
|
581
|
-
function
|
|
582
|
-
|
|
527
|
+
function isPrimitive(wat) {
|
|
528
|
+
return wat === null || isParameterizedString(wat) || (typeof wat !== 'object' && typeof wat !== 'function');
|
|
529
|
+
}
|
|
583
530
|
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
531
|
+
/**
|
|
532
|
+
* Checks whether given value's type is an object literal, or a class instance.
|
|
533
|
+
* {@link isPlainObject}.
|
|
534
|
+
*
|
|
535
|
+
* @param wat A value to be checked.
|
|
536
|
+
* @returns A boolean representing the result.
|
|
537
|
+
*/
|
|
538
|
+
function isPlainObject(wat) {
|
|
539
|
+
return isBuiltin(wat, 'Object');
|
|
588
540
|
}
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
return
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* Checks whether given value's type is an Event instance
|
|
544
|
+
* {@link isEvent}.
|
|
545
|
+
*
|
|
546
|
+
* @param wat A value to be checked.
|
|
547
|
+
* @returns A boolean representing the result.
|
|
548
|
+
*/
|
|
549
|
+
function isEvent(wat) {
|
|
550
|
+
return typeof Event !== 'undefined' && isInstanceOf(wat, Event);
|
|
599
551
|
}
|
|
600
552
|
|
|
601
553
|
/**
|
|
602
|
-
*
|
|
554
|
+
* Checks whether given value's type is an Element instance
|
|
555
|
+
* {@link isElement}.
|
|
556
|
+
*
|
|
557
|
+
* @param wat A value to be checked.
|
|
558
|
+
* @returns A boolean representing the result.
|
|
603
559
|
*/
|
|
604
|
-
function
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
// 2. CI providers with specific environment variables (has the provider name in the variable name)
|
|
608
|
-
// 3. CI providers with generic environment variables (checked for last to prevent possible false positives)
|
|
609
|
-
|
|
610
|
-
var possibleReleaseNameOfGitProvider =
|
|
611
|
-
// GitHub Actions - https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
|
|
612
|
-
process.env["GITHUB_SHA"] ||
|
|
613
|
-
// GitLab CI - https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
|
|
614
|
-
process.env["CI_MERGE_REQUEST_SOURCE_BRANCH_SHA"] || process.env["CI_BUILD_REF"] || process.env["CI_COMMIT_SHA"] ||
|
|
615
|
-
// Bitbucket - https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/
|
|
616
|
-
process.env["BITBUCKET_COMMIT"];
|
|
617
|
-
var possibleReleaseNameOfCiProvidersWithSpecificEnvVar =
|
|
618
|
-
// AppVeyor - https://www.appveyor.com/docs/environment-variables/
|
|
619
|
-
process.env["APPVEYOR_PULL_REQUEST_HEAD_COMMIT"] || process.env["APPVEYOR_REPO_COMMIT"] ||
|
|
620
|
-
// AWS CodeBuild - https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
|
|
621
|
-
process.env["CODEBUILD_RESOLVED_SOURCE_VERSION"] ||
|
|
622
|
-
// AWS Amplify - https://docs.aws.amazon.com/amplify/latest/userguide/environment-variables.html
|
|
623
|
-
process.env["AWS_COMMIT_ID"] ||
|
|
624
|
-
// Azure Pipelines - https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml
|
|
625
|
-
process.env["BUILD_SOURCEVERSION"] ||
|
|
626
|
-
// Bitrise - https://devcenter.bitrise.io/builds/available-environment-variables/
|
|
627
|
-
process.env["GIT_CLONE_COMMIT_HASH"] ||
|
|
628
|
-
// Buddy CI - https://buddy.works/docs/pipelines/environment-variables#default-environment-variables
|
|
629
|
-
process.env["BUDDY_EXECUTION_REVISION"] ||
|
|
630
|
-
// Builtkite - https://buildkite.com/docs/pipelines/environment-variables
|
|
631
|
-
process.env["BUILDKITE_COMMIT"] ||
|
|
632
|
-
// CircleCI - https://circleci.com/docs/variables/
|
|
633
|
-
process.env["CIRCLE_SHA1"] ||
|
|
634
|
-
// Cirrus CI - https://cirrus-ci.org/guide/writing-tasks/#environment-variables
|
|
635
|
-
process.env["CIRRUS_CHANGE_IN_REPO"] ||
|
|
636
|
-
// Codefresh - https://codefresh.io/docs/docs/codefresh-yaml/variables/
|
|
637
|
-
process.env["CF_REVISION"] ||
|
|
638
|
-
// Codemagic - https://docs.codemagic.io/yaml-basic-configuration/environment-variables/
|
|
639
|
-
process.env["CM_COMMIT"] ||
|
|
640
|
-
// Cloudflare Pages - https://developers.cloudflare.com/pages/platform/build-configuration/#environment-variables
|
|
641
|
-
process.env["CF_PAGES_COMMIT_SHA"] ||
|
|
642
|
-
// Drone - https://docs.drone.io/pipeline/environment/reference/
|
|
643
|
-
process.env["DRONE_COMMIT_SHA"] ||
|
|
644
|
-
// Flightcontrol - https://www.flightcontrol.dev/docs/guides/flightcontrol/environment-variables#built-in-environment-variables
|
|
645
|
-
process.env["FC_GIT_COMMIT_SHA"] ||
|
|
646
|
-
// Heroku #1 https://devcenter.heroku.com/articles/heroku-ci
|
|
647
|
-
process.env["HEROKU_TEST_RUN_COMMIT_VERSION"] ||
|
|
648
|
-
// Heroku #2 https://docs.sentry.io/product/integrations/deployment/heroku/#configure-releases
|
|
649
|
-
process.env["HEROKU_SLUG_COMMIT"] ||
|
|
650
|
-
// Railway - https://docs.railway.app/reference/variables#git-variables
|
|
651
|
-
process.env["RAILWAY_GIT_COMMIT_SHA"] ||
|
|
652
|
-
// Render - https://render.com/docs/environment-variables
|
|
653
|
-
process.env["RENDER_GIT_COMMIT"] ||
|
|
654
|
-
// Semaphore CI - https://docs.semaphoreci.com/ci-cd-environment/environment-variables
|
|
655
|
-
process.env["SEMAPHORE_GIT_SHA"] ||
|
|
656
|
-
// TravisCI - https://docs.travis-ci.com/user/environment-variables/#default-environment-variables
|
|
657
|
-
process.env["TRAVIS_PULL_REQUEST_SHA"] ||
|
|
658
|
-
// Vercel - https://vercel.com/docs/v2/build-step#system-environment-variables
|
|
659
|
-
process.env["VERCEL_GIT_COMMIT_SHA"] || process.env["VERCEL_GITHUB_COMMIT_SHA"] || process.env["VERCEL_GITLAB_COMMIT_SHA"] || process.env["VERCEL_BITBUCKET_COMMIT_SHA"] ||
|
|
660
|
-
// Zeit (now known as Vercel)
|
|
661
|
-
process.env["ZEIT_GITHUB_COMMIT_SHA"] || process.env["ZEIT_GITLAB_COMMIT_SHA"] || process.env["ZEIT_BITBUCKET_COMMIT_SHA"];
|
|
662
|
-
var possibleReleaseNameOfCiProvidersWithGenericEnvVar =
|
|
663
|
-
// CloudBees CodeShip - https://docs.cloudbees.com/docs/cloudbees-codeship/latest/pro-builds-and-configuration/environment-variables
|
|
664
|
-
process.env["CI_COMMIT_ID"] ||
|
|
665
|
-
// Coolify - https://coolify.io/docs/knowledge-base/environment-variables
|
|
666
|
-
process.env["SOURCE_COMMIT"] ||
|
|
667
|
-
// Heroku #3 https://devcenter.heroku.com/changelog-items/630
|
|
668
|
-
process.env["SOURCE_VERSION"] ||
|
|
669
|
-
// Jenkins - https://plugins.jenkins.io/git/#environment-variables
|
|
670
|
-
process.env["GIT_COMMIT"] ||
|
|
671
|
-
// Netlify - https://docs.netlify.com/configure-builds/environment-variables/#build-metadata
|
|
672
|
-
process.env["COMMIT_REF"] ||
|
|
673
|
-
// TeamCity - https://www.jetbrains.com/help/teamcity/predefined-build-parameters.html
|
|
674
|
-
process.env["BUILD_VCS_NUMBER"] ||
|
|
675
|
-
// Woodpecker CI - https://woodpecker-ci.org/docs/usage/environment
|
|
676
|
-
process.env["CI_COMMIT_SHA"];
|
|
677
|
-
return possibleReleaseNameOfGitProvider || possibleReleaseNameOfCiProvidersWithSpecificEnvVar || possibleReleaseNameOfCiProvidersWithGenericEnvVar || gitRevision();
|
|
678
|
-
}
|
|
560
|
+
function isElement(wat) {
|
|
561
|
+
return typeof Element !== 'undefined' && isInstanceOf(wat, Element);
|
|
562
|
+
}
|
|
679
563
|
|
|
680
564
|
/**
|
|
681
|
-
*
|
|
682
|
-
*
|
|
565
|
+
* Checks whether given value has a then function.
|
|
566
|
+
* @param wat A value to be checked.
|
|
683
567
|
*/
|
|
684
|
-
function
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
// The code below is mostly ternary operators because it saves bundle size.
|
|
688
|
-
// The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
|
|
689
|
-
var code = "{\n let _global =\n typeof window !== 'undefined' ?\n window :\n typeof global !== 'undefined' ?\n global :\n typeof globalThis !== 'undefined' ?\n globalThis :\n typeof self !== 'undefined' ?\n self :\n {};\n\n _global.SENTRY_RELEASE={id:".concat(JSON.stringify(release), "};");
|
|
690
|
-
if (injectBuildInformation) {
|
|
691
|
-
var buildInfo = getBuildInformation$1();
|
|
692
|
-
code += "\n _global.SENTRY_BUILD_INFO=".concat(JSON.stringify(buildInfo), ";");
|
|
693
|
-
}
|
|
694
|
-
code += "}";
|
|
695
|
-
return code;
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
699
|
-
function generateModuleMetadataInjectorCode(metadata) {
|
|
700
|
-
// The code below is mostly ternary operators because it saves bundle size.
|
|
701
|
-
// The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
|
|
702
|
-
// We are merging the metadata objects in case modules are bundled twice with the plugin
|
|
703
|
-
return "{\n let _sentryModuleMetadataGlobal =\n typeof window !== \"undefined\"\n ? window\n : typeof global !== \"undefined\"\n ? global\n : typeof globalThis !== \"undefined\"\n ? globalThis\n : typeof self !== \"undefined\"\n ? self\n : {};\n\n _sentryModuleMetadataGlobal._sentryModuleMetadata =\n _sentryModuleMetadataGlobal._sentryModuleMetadata || {};\n\n _sentryModuleMetadataGlobal._sentryModuleMetadata[new _sentryModuleMetadataGlobal.Error().stack] =\n Object.assign(\n {},\n _sentryModuleMetadataGlobal._sentryModuleMetadata[new _sentryModuleMetadataGlobal.Error().stack],\n ".concat(JSON.stringify(metadata), "\n );\n}");
|
|
704
|
-
}
|
|
705
|
-
function getBuildInformation$1() {
|
|
706
|
-
var packageJson = getPackageJson();
|
|
707
|
-
var _ref3 = packageJson ? getDependencies(packageJson) : {
|
|
708
|
-
deps: [],
|
|
709
|
-
depsVersions: {}
|
|
710
|
-
},
|
|
711
|
-
deps = _ref3.deps,
|
|
712
|
-
depsVersions = _ref3.depsVersions;
|
|
713
|
-
return {
|
|
714
|
-
deps: deps,
|
|
715
|
-
depsVersions: depsVersions,
|
|
716
|
-
nodeVersion: parseMajorVersion(process.version)
|
|
717
|
-
};
|
|
718
|
-
}
|
|
719
|
-
function stripQueryAndHashFromPath(path) {
|
|
720
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
721
|
-
return path.split("?")[0].split("#")[0];
|
|
722
|
-
}
|
|
723
|
-
function replaceBooleanFlagsInCode(code, replacementValues) {
|
|
724
|
-
var ms = new MagicString__default["default"](code);
|
|
725
|
-
Object.keys(replacementValues).forEach(function (key) {
|
|
726
|
-
var value = replacementValues[key];
|
|
727
|
-
if (typeof value === "boolean") {
|
|
728
|
-
ms.replaceAll(key, JSON.stringify(value));
|
|
729
|
-
}
|
|
730
|
-
});
|
|
731
|
-
if (ms.hasChanged()) {
|
|
732
|
-
return {
|
|
733
|
-
code: ms.toString(),
|
|
734
|
-
map: ms.generateMap({
|
|
735
|
-
hires: "boundary"
|
|
736
|
-
})
|
|
737
|
-
};
|
|
738
|
-
}
|
|
739
|
-
return null;
|
|
568
|
+
function isThenable(wat) {
|
|
569
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
570
|
+
return Boolean(wat && wat.then && typeof wat.then === 'function');
|
|
740
571
|
}
|
|
741
572
|
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
debug: (_userOptions$debug = userOptions.debug) !== null && _userOptions$debug !== void 0 ? _userOptions$debug : false,
|
|
752
|
-
silent: (_userOptions$silent = userOptions.silent) !== null && _userOptions$silent !== void 0 ? _userOptions$silent : false,
|
|
753
|
-
errorHandler: userOptions.errorHandler,
|
|
754
|
-
telemetry: (_userOptions$telemetr = userOptions.telemetry) !== null && _userOptions$telemetr !== void 0 ? _userOptions$telemetr : true,
|
|
755
|
-
disable: (_userOptions$disable = userOptions.disable) !== null && _userOptions$disable !== void 0 ? _userOptions$disable : false,
|
|
756
|
-
sourcemaps: userOptions.sourcemaps,
|
|
757
|
-
release: _objectSpread2(_objectSpread2({}, userOptions.release), {}, {
|
|
758
|
-
name: (_ref2 = (_userOptions$release$ = (_userOptions$release = userOptions.release) === null || _userOptions$release === void 0 ? void 0 : _userOptions$release.name) !== null && _userOptions$release$ !== void 0 ? _userOptions$release$ : process.env["SENTRY_RELEASE"]) !== null && _ref2 !== void 0 ? _ref2 : determineReleaseName(),
|
|
759
|
-
inject: (_userOptions$release$2 = (_userOptions$release2 = userOptions.release) === null || _userOptions$release2 === void 0 ? void 0 : _userOptions$release2.inject) !== null && _userOptions$release$2 !== void 0 ? _userOptions$release$2 : true,
|
|
760
|
-
create: (_userOptions$release$3 = (_userOptions$release3 = userOptions.release) === null || _userOptions$release3 === void 0 ? void 0 : _userOptions$release3.create) !== null && _userOptions$release$3 !== void 0 ? _userOptions$release$3 : true,
|
|
761
|
-
finalize: (_userOptions$release$4 = (_userOptions$release4 = userOptions.release) === null || _userOptions$release4 === void 0 ? void 0 : _userOptions$release4.finalize) !== null && _userOptions$release$4 !== void 0 ? _userOptions$release$4 : true,
|
|
762
|
-
vcsRemote: (_ref3 = (_userOptions$release$5 = (_userOptions$release5 = userOptions.release) === null || _userOptions$release5 === void 0 ? void 0 : _userOptions$release5.vcsRemote) !== null && _userOptions$release$5 !== void 0 ? _userOptions$release$5 : process.env["SENTRY_VSC_REMOTE"]) !== null && _ref3 !== void 0 ? _ref3 : "origin",
|
|
763
|
-
setCommits: (_userOptions$release6 = userOptions.release) === null || _userOptions$release6 === void 0 ? void 0 : _userOptions$release6.setCommits
|
|
764
|
-
}),
|
|
765
|
-
bundleSizeOptimizations: userOptions.bundleSizeOptimizations,
|
|
766
|
-
reactComponentAnnotation: userOptions.reactComponentAnnotation,
|
|
767
|
-
_metaOptions: {
|
|
768
|
-
telemetry: {
|
|
769
|
-
metaFramework: (_userOptions$_metaOpt = userOptions._metaOptions) === null || _userOptions$_metaOpt === void 0 ? void 0 : (_userOptions$_metaOpt2 = _userOptions$_metaOpt.telemetry) === null || _userOptions$_metaOpt2 === void 0 ? void 0 : _userOptions$_metaOpt2.metaFramework
|
|
770
|
-
}
|
|
771
|
-
},
|
|
772
|
-
applicationKey: userOptions.applicationKey,
|
|
773
|
-
moduleMetadata: userOptions.moduleMetadata,
|
|
774
|
-
_experiments: (_userOptions$_experim = userOptions._experiments) !== null && _userOptions$_experim !== void 0 ? _userOptions$_experim : {}
|
|
775
|
-
};
|
|
776
|
-
if (options.release.setCommits === undefined) {
|
|
777
|
-
if (process.env["VERCEL"] && process.env["VERCEL_GIT_COMMIT_SHA"] && process.env["VERCEL_GIT_REPO_SLUG"] && process.env["VERCEL_GIT_REPO_OWNER"] &&
|
|
778
|
-
// We only want to set commits for the production env because Sentry becomes extremely noisy (eg on slack) for
|
|
779
|
-
// preview environments because the previous commit is always the "stem" commit of the preview/PR causing Sentry
|
|
780
|
-
// to notify you for other people creating PRs.
|
|
781
|
-
process.env["VERCEL_TARGET_ENV"] === "production") {
|
|
782
|
-
options.release.setCommits = {
|
|
783
|
-
shouldNotThrowOnFailure: true,
|
|
784
|
-
commit: process.env["VERCEL_GIT_COMMIT_SHA"],
|
|
785
|
-
previousCommit: process.env["VERCEL_GIT_PREVIOUS_SHA"],
|
|
786
|
-
repo: "".concat(process.env["VERCEL_GIT_REPO_OWNER"], "/").concat(process.env["VERCEL_GIT_REPO_SLUG"]),
|
|
787
|
-
ignoreEmpty: true,
|
|
788
|
-
ignoreMissing: true
|
|
789
|
-
};
|
|
790
|
-
} else {
|
|
791
|
-
options.release.setCommits = {
|
|
792
|
-
shouldNotThrowOnFailure: true,
|
|
793
|
-
auto: true,
|
|
794
|
-
ignoreEmpty: true,
|
|
795
|
-
ignoreMissing: true
|
|
796
|
-
};
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
if (options.release.deploy === undefined && process.env["VERCEL"] && process.env["VERCEL_TARGET_ENV"]) {
|
|
800
|
-
options.release.deploy = {
|
|
801
|
-
env: "vercel-".concat(process.env["VERCEL_TARGET_ENV"]),
|
|
802
|
-
url: process.env["VERCEL_URL"] ? "https://".concat(process.env["VERCEL_URL"]) : undefined
|
|
803
|
-
};
|
|
804
|
-
}
|
|
805
|
-
return options;
|
|
573
|
+
/**
|
|
574
|
+
* Checks whether given value's type is a SyntheticEvent
|
|
575
|
+
* {@link isSyntheticEvent}.
|
|
576
|
+
*
|
|
577
|
+
* @param wat A value to be checked.
|
|
578
|
+
* @returns A boolean representing the result.
|
|
579
|
+
*/
|
|
580
|
+
function isSyntheticEvent(wat) {
|
|
581
|
+
return isPlainObject(wat) && 'nativeEvent' in wat && 'preventDefault' in wat && 'stopPropagation' in wat;
|
|
806
582
|
}
|
|
807
583
|
|
|
808
584
|
/**
|
|
809
|
-
*
|
|
810
|
-
*
|
|
811
|
-
* For all other options, we can rely on Sentry CLI to validate them. In fact,
|
|
812
|
-
* we can't validate them in the plugin because Sentry CLI might pick up options from
|
|
813
|
-
* its config file.
|
|
814
|
-
*
|
|
815
|
-
* @param options the internal options
|
|
816
|
-
* @param logger the logger
|
|
585
|
+
* Checks whether given value's type is an instance of provided constructor.
|
|
586
|
+
* {@link isInstanceOf}.
|
|
817
587
|
*
|
|
818
|
-
* @
|
|
588
|
+
* @param wat A value to be checked.
|
|
589
|
+
* @param base A constructor to be used in a check.
|
|
590
|
+
* @returns A boolean representing the result.
|
|
819
591
|
*/
|
|
820
|
-
function
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
if (!setCommits.auto && !(setCommits.repo && setCommits.commit)) {
|
|
825
|
-
logger.error("The `setCommits` option was specified but is missing required properties.", "Please set either `auto` or both, `repo` and `commit`.");
|
|
826
|
-
return false;
|
|
827
|
-
}
|
|
828
|
-
if (setCommits.auto && setCommits.repo && setCommits) {
|
|
829
|
-
logger.warn("The `setCommits` options includes `auto` but also `repo` and `commit`.", "Ignoring `repo` and `commit`.", "Please only set either `auto` or both, `repo` and `commit`.");
|
|
830
|
-
}
|
|
831
|
-
}
|
|
832
|
-
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)) {
|
|
833
|
-
logger.error("The `deploy` option was specified but is missing the required `env` property.", "Please set the `env` property.");
|
|
592
|
+
function isInstanceOf(wat, base) {
|
|
593
|
+
try {
|
|
594
|
+
return wat instanceof base;
|
|
595
|
+
} catch (_e) {
|
|
834
596
|
return false;
|
|
835
597
|
}
|
|
836
|
-
return true;
|
|
837
598
|
}
|
|
838
599
|
|
|
839
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
840
|
-
const objectToString = Object.prototype.toString;
|
|
841
|
-
|
|
842
600
|
/**
|
|
843
|
-
* Checks whether given value's type is
|
|
844
|
-
* {@link isError}.
|
|
601
|
+
* Checks whether given value's type is a Vue ViewModel.
|
|
845
602
|
*
|
|
846
603
|
* @param wat A value to be checked.
|
|
847
604
|
* @returns A boolean representing the result.
|
|
848
605
|
*/
|
|
849
|
-
function
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
case '[object Exception]':
|
|
853
|
-
case '[object DOMException]':
|
|
854
|
-
return true;
|
|
855
|
-
default:
|
|
856
|
-
return isInstanceOf(wat, Error);
|
|
857
|
-
}
|
|
606
|
+
function isVueViewModel(wat) {
|
|
607
|
+
// Not using Object.prototype.toString because in Vue 3 it would read the instance's Symbol(Symbol.toStringTag) property.
|
|
608
|
+
return !!(typeof wat === 'object' && wat !== null && ((wat ).__isVue || (wat )._isVue));
|
|
858
609
|
}
|
|
610
|
+
|
|
859
611
|
/**
|
|
860
|
-
*
|
|
861
|
-
*
|
|
862
|
-
* @param wat The value to be checked
|
|
863
|
-
* @param className
|
|
864
|
-
* @returns A boolean representing the result.
|
|
865
|
-
*/
|
|
866
|
-
function isBuiltin(wat, className) {
|
|
867
|
-
return objectToString.call(wat) === `[object ${className}]`;
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
/**
|
|
871
|
-
* Checks whether given value's type is ErrorEvent
|
|
872
|
-
* {@link isErrorEvent}.
|
|
873
|
-
*
|
|
874
|
-
* @param wat A value to be checked.
|
|
875
|
-
* @returns A boolean representing the result.
|
|
876
|
-
*/
|
|
877
|
-
function isErrorEvent$1(wat) {
|
|
878
|
-
return isBuiltin(wat, 'ErrorEvent');
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
/**
|
|
882
|
-
* Checks whether given value's type is a string
|
|
883
|
-
* {@link isString}.
|
|
884
|
-
*
|
|
885
|
-
* @param wat A value to be checked.
|
|
886
|
-
* @returns A boolean representing the result.
|
|
887
|
-
*/
|
|
888
|
-
function isString(wat) {
|
|
889
|
-
return isBuiltin(wat, 'String');
|
|
890
|
-
}
|
|
891
|
-
|
|
892
|
-
/**
|
|
893
|
-
* Checks whether given string is parameterized
|
|
894
|
-
* {@link isParameterizedString}.
|
|
895
|
-
*
|
|
896
|
-
* @param wat A value to be checked.
|
|
897
|
-
* @returns A boolean representing the result.
|
|
898
|
-
*/
|
|
899
|
-
function isParameterizedString(wat) {
|
|
900
|
-
return (
|
|
901
|
-
typeof wat === 'object' &&
|
|
902
|
-
wat !== null &&
|
|
903
|
-
'__sentry_template_string__' in wat &&
|
|
904
|
-
'__sentry_template_values__' in wat
|
|
905
|
-
);
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
/**
|
|
909
|
-
* Checks whether given value is a primitive (undefined, null, number, boolean, string, bigint, symbol)
|
|
910
|
-
* {@link isPrimitive}.
|
|
911
|
-
*
|
|
912
|
-
* @param wat A value to be checked.
|
|
913
|
-
* @returns A boolean representing the result.
|
|
914
|
-
*/
|
|
915
|
-
function isPrimitive(wat) {
|
|
916
|
-
return wat === null || isParameterizedString(wat) || (typeof wat !== 'object' && typeof wat !== 'function');
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
/**
|
|
920
|
-
* Checks whether given value's type is an object literal, or a class instance.
|
|
921
|
-
* {@link isPlainObject}.
|
|
922
|
-
*
|
|
923
|
-
* @param wat A value to be checked.
|
|
924
|
-
* @returns A boolean representing the result.
|
|
925
|
-
*/
|
|
926
|
-
function isPlainObject(wat) {
|
|
927
|
-
return isBuiltin(wat, 'Object');
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
/**
|
|
931
|
-
* Checks whether given value's type is an Event instance
|
|
932
|
-
* {@link isEvent}.
|
|
933
|
-
*
|
|
934
|
-
* @param wat A value to be checked.
|
|
935
|
-
* @returns A boolean representing the result.
|
|
936
|
-
*/
|
|
937
|
-
function isEvent(wat) {
|
|
938
|
-
return typeof Event !== 'undefined' && isInstanceOf(wat, Event);
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
/**
|
|
942
|
-
* Checks whether given value's type is an Element instance
|
|
943
|
-
* {@link isElement}.
|
|
944
|
-
*
|
|
945
|
-
* @param wat A value to be checked.
|
|
946
|
-
* @returns A boolean representing the result.
|
|
947
|
-
*/
|
|
948
|
-
function isElement(wat) {
|
|
949
|
-
return typeof Element !== 'undefined' && isInstanceOf(wat, Element);
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
/**
|
|
953
|
-
* Checks whether given value has a then function.
|
|
954
|
-
* @param wat A value to be checked.
|
|
955
|
-
*/
|
|
956
|
-
function isThenable(wat) {
|
|
957
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
958
|
-
return Boolean(wat && wat.then && typeof wat.then === 'function');
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
/**
|
|
962
|
-
* Checks whether given value's type is a SyntheticEvent
|
|
963
|
-
* {@link isSyntheticEvent}.
|
|
964
|
-
*
|
|
965
|
-
* @param wat A value to be checked.
|
|
966
|
-
* @returns A boolean representing the result.
|
|
967
|
-
*/
|
|
968
|
-
function isSyntheticEvent(wat) {
|
|
969
|
-
return isPlainObject(wat) && 'nativeEvent' in wat && 'preventDefault' in wat && 'stopPropagation' in wat;
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
/**
|
|
973
|
-
* Checks whether given value's type is an instance of provided constructor.
|
|
974
|
-
* {@link isInstanceOf}.
|
|
975
|
-
*
|
|
976
|
-
* @param wat A value to be checked.
|
|
977
|
-
* @param base A constructor to be used in a check.
|
|
978
|
-
* @returns A boolean representing the result.
|
|
979
|
-
*/
|
|
980
|
-
function isInstanceOf(wat, base) {
|
|
981
|
-
try {
|
|
982
|
-
return wat instanceof base;
|
|
983
|
-
} catch (_e) {
|
|
984
|
-
return false;
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
|
|
988
|
-
/**
|
|
989
|
-
* Checks whether given value's type is a Vue ViewModel.
|
|
990
|
-
*
|
|
991
|
-
* @param wat A value to be checked.
|
|
992
|
-
* @returns A boolean representing the result.
|
|
993
|
-
*/
|
|
994
|
-
function isVueViewModel(wat) {
|
|
995
|
-
// Not using Object.prototype.toString because in Vue 3 it would read the instance's Symbol(Symbol.toStringTag) property.
|
|
996
|
-
return !!(typeof wat === 'object' && wat !== null && ((wat ).__isVue || (wat )._isVue));
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
/**
|
|
1000
|
-
* Truncates given string to the maximum characters count
|
|
612
|
+
* Truncates given string to the maximum characters count
|
|
1001
613
|
*
|
|
1002
614
|
* @param str An object that contains serializable values
|
|
1003
615
|
* @param max Maximum number of characters in truncated string (0 = unlimited)
|
|
@@ -2109,7 +1721,7 @@ function checkOrSetAlreadyCaught(exception) {
|
|
|
2109
1721
|
* @param maybeArray Input to turn into an array, if necessary
|
|
2110
1722
|
* @returns The input, if already an array, or an array with the input as the only element, if not
|
|
2111
1723
|
*/
|
|
2112
|
-
function arrayify(maybeArray) {
|
|
1724
|
+
function arrayify$1(maybeArray) {
|
|
2113
1725
|
return Array.isArray(maybeArray) ? maybeArray : [maybeArray];
|
|
2114
1726
|
}
|
|
2115
1727
|
|
|
@@ -6229,7 +5841,7 @@ function applySpanToEvent(event, span) {
|
|
|
6229
5841
|
*/
|
|
6230
5842
|
function applyFingerprintToEvent(event, fingerprint) {
|
|
6231
5843
|
// Make sure it's an array first and we actually have something in place
|
|
6232
|
-
event.fingerprint = event.fingerprint ? arrayify(event.fingerprint) : [];
|
|
5844
|
+
event.fingerprint = event.fingerprint ? arrayify$1(event.fingerprint) : [];
|
|
6233
5845
|
|
|
6234
5846
|
// If we have something on the scope, then merge it with event
|
|
6235
5847
|
if (fingerprint) {
|
|
@@ -7955,49 +7567,491 @@ function createTransport(
|
|
|
7955
7567
|
},
|
|
7956
7568
|
);
|
|
7957
7569
|
}
|
|
7958
|
-
|
|
7959
|
-
return {
|
|
7960
|
-
send,
|
|
7961
|
-
flush,
|
|
7962
|
-
};
|
|
7963
|
-
}
|
|
7964
|
-
|
|
7965
|
-
function getEventForEnvelopeItem(item, type) {
|
|
7966
|
-
if (type !== 'event' && type !== 'transaction') {
|
|
7967
|
-
return undefined;
|
|
7570
|
+
|
|
7571
|
+
return {
|
|
7572
|
+
send,
|
|
7573
|
+
flush,
|
|
7574
|
+
};
|
|
7575
|
+
}
|
|
7576
|
+
|
|
7577
|
+
function getEventForEnvelopeItem(item, type) {
|
|
7578
|
+
if (type !== 'event' && type !== 'transaction') {
|
|
7579
|
+
return undefined;
|
|
7580
|
+
}
|
|
7581
|
+
|
|
7582
|
+
return Array.isArray(item) ? (item )[1] : undefined;
|
|
7583
|
+
}
|
|
7584
|
+
|
|
7585
|
+
/**
|
|
7586
|
+
* A builder for the SDK metadata in the options for the SDK initialization.
|
|
7587
|
+
*
|
|
7588
|
+
* Note: This function is identical to `buildMetadata` in Remix and NextJS and SvelteKit.
|
|
7589
|
+
* We don't extract it for bundle size reasons.
|
|
7590
|
+
* @see https://github.com/getsentry/sentry-javascript/pull/7404
|
|
7591
|
+
* @see https://github.com/getsentry/sentry-javascript/pull/4196
|
|
7592
|
+
*
|
|
7593
|
+
* If you make changes to this function consider updating the others as well.
|
|
7594
|
+
*
|
|
7595
|
+
* @param options SDK options object that gets mutated
|
|
7596
|
+
* @param names list of package names
|
|
7597
|
+
*/
|
|
7598
|
+
function applySdkMetadata(options, name, names = [name], source = 'npm') {
|
|
7599
|
+
const metadata = options._metadata || {};
|
|
7600
|
+
|
|
7601
|
+
if (!metadata.sdk) {
|
|
7602
|
+
metadata.sdk = {
|
|
7603
|
+
name: `sentry.javascript.${name}`,
|
|
7604
|
+
packages: names.map(name => ({
|
|
7605
|
+
name: `${source}:@sentry/${name}`,
|
|
7606
|
+
version: SDK_VERSION,
|
|
7607
|
+
})),
|
|
7608
|
+
version: SDK_VERSION,
|
|
7609
|
+
};
|
|
7610
|
+
}
|
|
7611
|
+
|
|
7612
|
+
options._metadata = metadata;
|
|
7613
|
+
}
|
|
7614
|
+
|
|
7615
|
+
/**
|
|
7616
|
+
* Checks whether the given input is already an array, and if it isn't, wraps it in one.
|
|
7617
|
+
*
|
|
7618
|
+
* @param maybeArray Input to turn into an array, if necessary
|
|
7619
|
+
* @returns The input, if already an array, or an array with the input as the only element, if not
|
|
7620
|
+
*/
|
|
7621
|
+
function arrayify(maybeArray) {
|
|
7622
|
+
return Array.isArray(maybeArray) ? maybeArray : [maybeArray];
|
|
7623
|
+
}
|
|
7624
|
+
/**
|
|
7625
|
+
* Get the closes package.json from a given starting point upwards.
|
|
7626
|
+
* This handles a few edge cases:
|
|
7627
|
+
* * Check if a given file package.json appears to be an actual NPM package.json file
|
|
7628
|
+
* * Stop at the home dir, to avoid looking too deeply
|
|
7629
|
+
*/
|
|
7630
|
+
function getPackageJson() {
|
|
7631
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
7632
|
+
cwd = _ref.cwd,
|
|
7633
|
+
stopAt = _ref.stopAt;
|
|
7634
|
+
return lookupPackageJson(cwd !== null && cwd !== void 0 ? cwd : process.cwd(), path__default["default"].normalize(stopAt !== null && stopAt !== void 0 ? stopAt : os__default["default"].homedir()));
|
|
7635
|
+
}
|
|
7636
|
+
function parseMajorVersion(version) {
|
|
7637
|
+
// if it has a `v` prefix, remove it
|
|
7638
|
+
if (version.startsWith("v")) {
|
|
7639
|
+
version = version.slice(1);
|
|
7640
|
+
}
|
|
7641
|
+
|
|
7642
|
+
// First, try simple lookup of exact, ~ and ^ versions
|
|
7643
|
+
var regex = /^[\^~]?(\d+)(\.\d+)?(\.\d+)?(-.+)?/;
|
|
7644
|
+
var match = version.match(regex);
|
|
7645
|
+
if (match) {
|
|
7646
|
+
return parseInt(match[1], 10);
|
|
7647
|
+
}
|
|
7648
|
+
|
|
7649
|
+
// Try to parse e.g. 1.x
|
|
7650
|
+
var coerced = parseInt(version, 10);
|
|
7651
|
+
if (!Number.isNaN(coerced)) {
|
|
7652
|
+
return coerced;
|
|
7653
|
+
}
|
|
7654
|
+
|
|
7655
|
+
// Match <= and >= ranges.
|
|
7656
|
+
var gteLteRegex = /^[<>]=\s*(\d+)(\.\d+)?(\.\d+)?(-.+)?/;
|
|
7657
|
+
var gteLteMatch = version.match(gteLteRegex);
|
|
7658
|
+
if (gteLteMatch) {
|
|
7659
|
+
return parseInt(gteLteMatch[1], 10);
|
|
7660
|
+
}
|
|
7661
|
+
|
|
7662
|
+
// match < ranges
|
|
7663
|
+
var ltRegex = /^<\s*(\d+)(\.\d+)?(\.\d+)?(-.+)?/;
|
|
7664
|
+
var ltMatch = version.match(ltRegex);
|
|
7665
|
+
if (ltMatch) {
|
|
7666
|
+
// Two scenarios:
|
|
7667
|
+
// a) < 2.0.0 --> return 1
|
|
7668
|
+
// b) < 2.1.0 --> return 2
|
|
7669
|
+
|
|
7670
|
+
var major = parseInt(ltMatch[1], 10);
|
|
7671
|
+
if (
|
|
7672
|
+
// minor version > 0
|
|
7673
|
+
typeof ltMatch[2] === "string" && parseInt(ltMatch[2].slice(1), 10) > 0 ||
|
|
7674
|
+
// patch version > 0
|
|
7675
|
+
typeof ltMatch[3] === "string" && parseInt(ltMatch[3].slice(1), 10) > 0) {
|
|
7676
|
+
return major;
|
|
7677
|
+
}
|
|
7678
|
+
return major - 1;
|
|
7679
|
+
}
|
|
7680
|
+
|
|
7681
|
+
// match > ranges
|
|
7682
|
+
var gtRegex = /^>\s*(\d+)(\.\d+)?(\.\d+)?(-.+)?/;
|
|
7683
|
+
var gtMatch = version.match(gtRegex);
|
|
7684
|
+
if (gtMatch) {
|
|
7685
|
+
// We always return the version here, even though it _may_ be incorrect
|
|
7686
|
+
// E.g. if given > 2.0.0, it should be 2 if there exists any 2.x.x version, else 3
|
|
7687
|
+
// Since there is no way for us to know this, we're going to assume any kind of patch/feature release probably exists
|
|
7688
|
+
return parseInt(gtMatch[1], 10);
|
|
7689
|
+
}
|
|
7690
|
+
return undefined;
|
|
7691
|
+
}
|
|
7692
|
+
|
|
7693
|
+
// This is an explicit list of packages where we want to include the (major) version number.
|
|
7694
|
+
var PACKAGES_TO_INCLUDE_VERSION = ["react", "@angular/core", "vue", "ember-source", "svelte", "@sveltejs/kit", "webpack", "vite", "gatsby", "next", "remix", "rollup", "esbuild"];
|
|
7695
|
+
function getDependencies(packageJson) {
|
|
7696
|
+
var _packageJson$devDepen, _packageJson$dependen;
|
|
7697
|
+
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 : {});
|
|
7698
|
+
var deps = Object.keys(dependencies).sort();
|
|
7699
|
+
var depsVersions = deps.reduce(function (depsVersions, depName) {
|
|
7700
|
+
if (PACKAGES_TO_INCLUDE_VERSION.includes(depName)) {
|
|
7701
|
+
var version = dependencies[depName];
|
|
7702
|
+
var majorVersion = parseMajorVersion(version);
|
|
7703
|
+
if (majorVersion) {
|
|
7704
|
+
depsVersions[depName] = majorVersion;
|
|
7705
|
+
}
|
|
7706
|
+
}
|
|
7707
|
+
return depsVersions;
|
|
7708
|
+
}, {});
|
|
7709
|
+
return {
|
|
7710
|
+
deps: deps,
|
|
7711
|
+
depsVersions: depsVersions
|
|
7712
|
+
};
|
|
7713
|
+
}
|
|
7714
|
+
function lookupPackageJson(cwd, stopAt) {
|
|
7715
|
+
var jsonPath = findUp__default["default"].sync(function (dirName) {
|
|
7716
|
+
// Stop if we reach this dir
|
|
7717
|
+
if (path__default["default"].normalize(dirName) === stopAt) {
|
|
7718
|
+
return findUp__default["default"].stop;
|
|
7719
|
+
}
|
|
7720
|
+
return findUp__default["default"].sync.exists(dirName + "/package.json") ? "package.json" : undefined;
|
|
7721
|
+
}, {
|
|
7722
|
+
cwd: cwd
|
|
7723
|
+
});
|
|
7724
|
+
if (!jsonPath) {
|
|
7725
|
+
return undefined;
|
|
7726
|
+
}
|
|
7727
|
+
try {
|
|
7728
|
+
var jsonStr = fs__default["default"].readFileSync(jsonPath, "utf8");
|
|
7729
|
+
var json = JSON.parse(jsonStr);
|
|
7730
|
+
|
|
7731
|
+
// Ensure it is an actual package.json
|
|
7732
|
+
// This is very much not bulletproof, but should be good enough
|
|
7733
|
+
if ("name" in json || "private" in json) {
|
|
7734
|
+
return json;
|
|
7735
|
+
}
|
|
7736
|
+
} catch (error) {
|
|
7737
|
+
// Ignore and walk up
|
|
7738
|
+
}
|
|
7739
|
+
|
|
7740
|
+
// Continue up the tree, if we find a fitting package.json
|
|
7741
|
+
var newCwd = path__default["default"].dirname(path__default["default"].resolve(jsonPath + "/.."));
|
|
7742
|
+
return lookupPackageJson(newCwd, stopAt);
|
|
7743
|
+
}
|
|
7744
|
+
|
|
7745
|
+
/**
|
|
7746
|
+
* Deterministically hashes a string and turns the hash into a uuid.
|
|
7747
|
+
*/
|
|
7748
|
+
function stringToUUID(str) {
|
|
7749
|
+
var sha256Hash = crypto__default["default"].createHash("sha256").update(str).digest("hex");
|
|
7750
|
+
|
|
7751
|
+
// Position 16 is fixed to either 8, 9, a, or b in the uuid v4 spec (10xx in binary)
|
|
7752
|
+
// RFC 4122 section 4.4
|
|
7753
|
+
var v4variant = ["8", "9", "a", "b"][sha256Hash.substring(16, 17).charCodeAt(0) % 4];
|
|
7754
|
+
return (sha256Hash.substring(0, 8) + "-" + sha256Hash.substring(8, 12) + "-4" + sha256Hash.substring(13, 16) + "-" + v4variant + sha256Hash.substring(17, 20) + "-" + sha256Hash.substring(20, 32)).toLowerCase();
|
|
7755
|
+
}
|
|
7756
|
+
function gitRevision() {
|
|
7757
|
+
var gitRevision;
|
|
7758
|
+
try {
|
|
7759
|
+
gitRevision = childProcess__default["default"].execSync("git rev-parse HEAD", {
|
|
7760
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
7761
|
+
}).toString().trim();
|
|
7762
|
+
} catch (e) {
|
|
7763
|
+
// noop
|
|
7764
|
+
}
|
|
7765
|
+
return gitRevision;
|
|
7766
|
+
}
|
|
7767
|
+
|
|
7768
|
+
/**
|
|
7769
|
+
* Tries to guess a release name based on environmental data.
|
|
7770
|
+
*/
|
|
7771
|
+
function determineReleaseName() {
|
|
7772
|
+
// This list is in approximate alpha order, separated into 3 categories:
|
|
7773
|
+
// 1. Git providers
|
|
7774
|
+
// 2. CI providers with specific environment variables (has the provider name in the variable name)
|
|
7775
|
+
// 3. CI providers with generic environment variables (checked for last to prevent possible false positives)
|
|
7776
|
+
|
|
7777
|
+
var possibleReleaseNameOfGitProvider =
|
|
7778
|
+
// GitHub Actions - https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
|
|
7779
|
+
process.env["GITHUB_SHA"] ||
|
|
7780
|
+
// GitLab CI - https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
|
|
7781
|
+
process.env["CI_MERGE_REQUEST_SOURCE_BRANCH_SHA"] || process.env["CI_BUILD_REF"] || process.env["CI_COMMIT_SHA"] ||
|
|
7782
|
+
// Bitbucket - https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/
|
|
7783
|
+
process.env["BITBUCKET_COMMIT"];
|
|
7784
|
+
var possibleReleaseNameOfCiProvidersWithSpecificEnvVar =
|
|
7785
|
+
// AppVeyor - https://www.appveyor.com/docs/environment-variables/
|
|
7786
|
+
process.env["APPVEYOR_PULL_REQUEST_HEAD_COMMIT"] || process.env["APPVEYOR_REPO_COMMIT"] ||
|
|
7787
|
+
// AWS CodeBuild - https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
|
|
7788
|
+
process.env["CODEBUILD_RESOLVED_SOURCE_VERSION"] ||
|
|
7789
|
+
// AWS Amplify - https://docs.aws.amazon.com/amplify/latest/userguide/environment-variables.html
|
|
7790
|
+
process.env["AWS_COMMIT_ID"] ||
|
|
7791
|
+
// Azure Pipelines - https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml
|
|
7792
|
+
process.env["BUILD_SOURCEVERSION"] ||
|
|
7793
|
+
// Bitrise - https://devcenter.bitrise.io/builds/available-environment-variables/
|
|
7794
|
+
process.env["GIT_CLONE_COMMIT_HASH"] ||
|
|
7795
|
+
// Buddy CI - https://buddy.works/docs/pipelines/environment-variables#default-environment-variables
|
|
7796
|
+
process.env["BUDDY_EXECUTION_REVISION"] ||
|
|
7797
|
+
// Builtkite - https://buildkite.com/docs/pipelines/environment-variables
|
|
7798
|
+
process.env["BUILDKITE_COMMIT"] ||
|
|
7799
|
+
// CircleCI - https://circleci.com/docs/variables/
|
|
7800
|
+
process.env["CIRCLE_SHA1"] ||
|
|
7801
|
+
// Cirrus CI - https://cirrus-ci.org/guide/writing-tasks/#environment-variables
|
|
7802
|
+
process.env["CIRRUS_CHANGE_IN_REPO"] ||
|
|
7803
|
+
// Codefresh - https://codefresh.io/docs/docs/codefresh-yaml/variables/
|
|
7804
|
+
process.env["CF_REVISION"] ||
|
|
7805
|
+
// Codemagic - https://docs.codemagic.io/yaml-basic-configuration/environment-variables/
|
|
7806
|
+
process.env["CM_COMMIT"] ||
|
|
7807
|
+
// Cloudflare Pages - https://developers.cloudflare.com/pages/platform/build-configuration/#environment-variables
|
|
7808
|
+
process.env["CF_PAGES_COMMIT_SHA"] ||
|
|
7809
|
+
// Drone - https://docs.drone.io/pipeline/environment/reference/
|
|
7810
|
+
process.env["DRONE_COMMIT_SHA"] ||
|
|
7811
|
+
// Flightcontrol - https://www.flightcontrol.dev/docs/guides/flightcontrol/environment-variables#built-in-environment-variables
|
|
7812
|
+
process.env["FC_GIT_COMMIT_SHA"] ||
|
|
7813
|
+
// Heroku #1 https://devcenter.heroku.com/articles/heroku-ci
|
|
7814
|
+
process.env["HEROKU_TEST_RUN_COMMIT_VERSION"] ||
|
|
7815
|
+
// Heroku #2 https://docs.sentry.io/product/integrations/deployment/heroku/#configure-releases
|
|
7816
|
+
process.env["HEROKU_SLUG_COMMIT"] ||
|
|
7817
|
+
// Railway - https://docs.railway.app/reference/variables#git-variables
|
|
7818
|
+
process.env["RAILWAY_GIT_COMMIT_SHA"] ||
|
|
7819
|
+
// Render - https://render.com/docs/environment-variables
|
|
7820
|
+
process.env["RENDER_GIT_COMMIT"] ||
|
|
7821
|
+
// Semaphore CI - https://docs.semaphoreci.com/ci-cd-environment/environment-variables
|
|
7822
|
+
process.env["SEMAPHORE_GIT_SHA"] ||
|
|
7823
|
+
// TravisCI - https://docs.travis-ci.com/user/environment-variables/#default-environment-variables
|
|
7824
|
+
process.env["TRAVIS_PULL_REQUEST_SHA"] ||
|
|
7825
|
+
// Vercel - https://vercel.com/docs/v2/build-step#system-environment-variables
|
|
7826
|
+
process.env["VERCEL_GIT_COMMIT_SHA"] || process.env["VERCEL_GITHUB_COMMIT_SHA"] || process.env["VERCEL_GITLAB_COMMIT_SHA"] || process.env["VERCEL_BITBUCKET_COMMIT_SHA"] ||
|
|
7827
|
+
// Zeit (now known as Vercel)
|
|
7828
|
+
process.env["ZEIT_GITHUB_COMMIT_SHA"] || process.env["ZEIT_GITLAB_COMMIT_SHA"] || process.env["ZEIT_BITBUCKET_COMMIT_SHA"];
|
|
7829
|
+
var possibleReleaseNameOfCiProvidersWithGenericEnvVar =
|
|
7830
|
+
// CloudBees CodeShip - https://docs.cloudbees.com/docs/cloudbees-codeship/latest/pro-builds-and-configuration/environment-variables
|
|
7831
|
+
process.env["CI_COMMIT_ID"] ||
|
|
7832
|
+
// Coolify - https://coolify.io/docs/knowledge-base/environment-variables
|
|
7833
|
+
process.env["SOURCE_COMMIT"] ||
|
|
7834
|
+
// Heroku #3 https://devcenter.heroku.com/changelog-items/630
|
|
7835
|
+
process.env["SOURCE_VERSION"] ||
|
|
7836
|
+
// Jenkins - https://plugins.jenkins.io/git/#environment-variables
|
|
7837
|
+
process.env["GIT_COMMIT"] ||
|
|
7838
|
+
// Netlify - https://docs.netlify.com/configure-builds/environment-variables/#build-metadata
|
|
7839
|
+
process.env["COMMIT_REF"] ||
|
|
7840
|
+
// TeamCity - https://www.jetbrains.com/help/teamcity/predefined-build-parameters.html
|
|
7841
|
+
process.env["BUILD_VCS_NUMBER"] ||
|
|
7842
|
+
// Woodpecker CI - https://woodpecker-ci.org/docs/usage/environment
|
|
7843
|
+
process.env["CI_COMMIT_SHA"];
|
|
7844
|
+
return possibleReleaseNameOfGitProvider || possibleReleaseNameOfCiProvidersWithSpecificEnvVar || possibleReleaseNameOfCiProvidersWithGenericEnvVar || gitRevision();
|
|
7845
|
+
}
|
|
7846
|
+
|
|
7847
|
+
/**
|
|
7848
|
+
* Generates code for the global injector which is responsible for setting the global
|
|
7849
|
+
* `SENTRY_RELEASE` & `SENTRY_BUILD_INFO` variables.
|
|
7850
|
+
*/
|
|
7851
|
+
function generateGlobalInjectorCode(_ref2) {
|
|
7852
|
+
var release = _ref2.release,
|
|
7853
|
+
injectBuildInformation = _ref2.injectBuildInformation;
|
|
7854
|
+
// The code below is mostly ternary operators because it saves bundle size.
|
|
7855
|
+
// The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
|
|
7856
|
+
var code = "{\n let _global =\n typeof window !== 'undefined' ?\n window :\n typeof global !== 'undefined' ?\n global :\n typeof globalThis !== 'undefined' ?\n globalThis :\n typeof self !== 'undefined' ?\n self :\n {};\n\n _global.SENTRY_RELEASE={id:".concat(JSON.stringify(release), "};");
|
|
7857
|
+
if (injectBuildInformation) {
|
|
7858
|
+
var buildInfo = getBuildInformation$1();
|
|
7859
|
+
code += "\n _global.SENTRY_BUILD_INFO=".concat(JSON.stringify(buildInfo), ";");
|
|
7860
|
+
}
|
|
7861
|
+
code += "}";
|
|
7862
|
+
return code;
|
|
7863
|
+
}
|
|
7864
|
+
|
|
7865
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7866
|
+
function generateModuleMetadataInjectorCode(metadata) {
|
|
7867
|
+
// The code below is mostly ternary operators because it saves bundle size.
|
|
7868
|
+
// The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
|
|
7869
|
+
// We are merging the metadata objects in case modules are bundled twice with the plugin
|
|
7870
|
+
return "{\n let _sentryModuleMetadataGlobal =\n typeof window !== \"undefined\"\n ? window\n : typeof global !== \"undefined\"\n ? global\n : typeof globalThis !== \"undefined\"\n ? globalThis\n : typeof self !== \"undefined\"\n ? self\n : {};\n\n _sentryModuleMetadataGlobal._sentryModuleMetadata =\n _sentryModuleMetadataGlobal._sentryModuleMetadata || {};\n\n _sentryModuleMetadataGlobal._sentryModuleMetadata[new _sentryModuleMetadataGlobal.Error().stack] =\n Object.assign(\n {},\n _sentryModuleMetadataGlobal._sentryModuleMetadata[new _sentryModuleMetadataGlobal.Error().stack],\n ".concat(JSON.stringify(metadata), "\n );\n}");
|
|
7871
|
+
}
|
|
7872
|
+
function getBuildInformation$1() {
|
|
7873
|
+
var packageJson = getPackageJson();
|
|
7874
|
+
var _ref3 = packageJson ? getDependencies(packageJson) : {
|
|
7875
|
+
deps: [],
|
|
7876
|
+
depsVersions: {}
|
|
7877
|
+
},
|
|
7878
|
+
deps = _ref3.deps,
|
|
7879
|
+
depsVersions = _ref3.depsVersions;
|
|
7880
|
+
return {
|
|
7881
|
+
deps: deps,
|
|
7882
|
+
depsVersions: depsVersions,
|
|
7883
|
+
nodeVersion: parseMajorVersion(process.version)
|
|
7884
|
+
};
|
|
7885
|
+
}
|
|
7886
|
+
function stripQueryAndHashFromPath(path) {
|
|
7887
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
7888
|
+
return path.split("?")[0].split("#")[0];
|
|
7889
|
+
}
|
|
7890
|
+
function replaceBooleanFlagsInCode(code, replacementValues) {
|
|
7891
|
+
var ms = new MagicString__default["default"](code);
|
|
7892
|
+
Object.keys(replacementValues).forEach(function (key) {
|
|
7893
|
+
var value = replacementValues[key];
|
|
7894
|
+
if (typeof value === "boolean") {
|
|
7895
|
+
ms.replaceAll(key, JSON.stringify(value));
|
|
7896
|
+
}
|
|
7897
|
+
});
|
|
7898
|
+
if (ms.hasChanged()) {
|
|
7899
|
+
return {
|
|
7900
|
+
code: ms.toString(),
|
|
7901
|
+
map: ms.generateMap({
|
|
7902
|
+
hires: "boundary"
|
|
7903
|
+
})
|
|
7904
|
+
};
|
|
7905
|
+
}
|
|
7906
|
+
return null;
|
|
7907
|
+
}
|
|
7908
|
+
|
|
7909
|
+
// https://turbo.build/repo/docs/reference/system-environment-variables#environment-variables-in-tasks
|
|
7910
|
+
function getTurborepoEnvPassthroughWarning(envVarName) {
|
|
7911
|
+
return process.env["TURBO_HASH"] ? "\nYou seem to be using Turborepo, did you forget to put ".concat(envVarName, " in `passThroughEnv`? https://turbo.build/repo/docs/reference/configuration#passthroughenv") : "";
|
|
7912
|
+
}
|
|
7913
|
+
|
|
7914
|
+
var SENTRY_SAAS_URL = "https://sentry.io";
|
|
7915
|
+
function normalizeUserOptions(userOptions) {
|
|
7916
|
+
var _userOptions$org, _userOptions$project, _userOptions$authToke, _ref, _userOptions$url, _userOptions$debug, _userOptions$silent, _userOptions$telemetr, _userOptions$disable, _ref2, _userOptions$release$, _userOptions$release, _userOptions$release$2, _userOptions$release2, _userOptions$release$3, _userOptions$release3, _userOptions$release$4, _userOptions$release4, _ref3, _userOptions$release$5, _userOptions$release5, _userOptions$release6, _userOptions$_metaOpt, _userOptions$_metaOpt2, _userOptions$_experim;
|
|
7917
|
+
var options = {
|
|
7918
|
+
org: (_userOptions$org = userOptions.org) !== null && _userOptions$org !== void 0 ? _userOptions$org : process.env["SENTRY_ORG"],
|
|
7919
|
+
project: (_userOptions$project = userOptions.project) !== null && _userOptions$project !== void 0 ? _userOptions$project : process.env["SENTRY_PROJECT"],
|
|
7920
|
+
authToken: (_userOptions$authToke = userOptions.authToken) !== null && _userOptions$authToke !== void 0 ? _userOptions$authToke : process.env["SENTRY_AUTH_TOKEN"],
|
|
7921
|
+
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,
|
|
7922
|
+
headers: userOptions.headers,
|
|
7923
|
+
debug: (_userOptions$debug = userOptions.debug) !== null && _userOptions$debug !== void 0 ? _userOptions$debug : false,
|
|
7924
|
+
silent: (_userOptions$silent = userOptions.silent) !== null && _userOptions$silent !== void 0 ? _userOptions$silent : false,
|
|
7925
|
+
errorHandler: userOptions.errorHandler,
|
|
7926
|
+
telemetry: (_userOptions$telemetr = userOptions.telemetry) !== null && _userOptions$telemetr !== void 0 ? _userOptions$telemetr : true,
|
|
7927
|
+
disable: (_userOptions$disable = userOptions.disable) !== null && _userOptions$disable !== void 0 ? _userOptions$disable : false,
|
|
7928
|
+
sourcemaps: userOptions.sourcemaps,
|
|
7929
|
+
release: _objectSpread2(_objectSpread2({}, userOptions.release), {}, {
|
|
7930
|
+
name: (_ref2 = (_userOptions$release$ = (_userOptions$release = userOptions.release) === null || _userOptions$release === void 0 ? void 0 : _userOptions$release.name) !== null && _userOptions$release$ !== void 0 ? _userOptions$release$ : process.env["SENTRY_RELEASE"]) !== null && _ref2 !== void 0 ? _ref2 : determineReleaseName(),
|
|
7931
|
+
inject: (_userOptions$release$2 = (_userOptions$release2 = userOptions.release) === null || _userOptions$release2 === void 0 ? void 0 : _userOptions$release2.inject) !== null && _userOptions$release$2 !== void 0 ? _userOptions$release$2 : true,
|
|
7932
|
+
create: (_userOptions$release$3 = (_userOptions$release3 = userOptions.release) === null || _userOptions$release3 === void 0 ? void 0 : _userOptions$release3.create) !== null && _userOptions$release$3 !== void 0 ? _userOptions$release$3 : true,
|
|
7933
|
+
finalize: (_userOptions$release$4 = (_userOptions$release4 = userOptions.release) === null || _userOptions$release4 === void 0 ? void 0 : _userOptions$release4.finalize) !== null && _userOptions$release$4 !== void 0 ? _userOptions$release$4 : true,
|
|
7934
|
+
vcsRemote: (_ref3 = (_userOptions$release$5 = (_userOptions$release5 = userOptions.release) === null || _userOptions$release5 === void 0 ? void 0 : _userOptions$release5.vcsRemote) !== null && _userOptions$release$5 !== void 0 ? _userOptions$release$5 : process.env["SENTRY_VSC_REMOTE"]) !== null && _ref3 !== void 0 ? _ref3 : "origin",
|
|
7935
|
+
setCommits: (_userOptions$release6 = userOptions.release) === null || _userOptions$release6 === void 0 ? void 0 : _userOptions$release6.setCommits
|
|
7936
|
+
}),
|
|
7937
|
+
bundleSizeOptimizations: userOptions.bundleSizeOptimizations,
|
|
7938
|
+
reactComponentAnnotation: userOptions.reactComponentAnnotation,
|
|
7939
|
+
_metaOptions: {
|
|
7940
|
+
telemetry: {
|
|
7941
|
+
metaFramework: (_userOptions$_metaOpt = userOptions._metaOptions) === null || _userOptions$_metaOpt === void 0 ? void 0 : (_userOptions$_metaOpt2 = _userOptions$_metaOpt.telemetry) === null || _userOptions$_metaOpt2 === void 0 ? void 0 : _userOptions$_metaOpt2.metaFramework
|
|
7942
|
+
}
|
|
7943
|
+
},
|
|
7944
|
+
applicationKey: userOptions.applicationKey,
|
|
7945
|
+
moduleMetadata: userOptions.moduleMetadata,
|
|
7946
|
+
_experiments: (_userOptions$_experim = userOptions._experiments) !== null && _userOptions$_experim !== void 0 ? _userOptions$_experim : {}
|
|
7947
|
+
};
|
|
7948
|
+
if (options.release.setCommits === undefined) {
|
|
7949
|
+
if (process.env["VERCEL"] && process.env["VERCEL_GIT_COMMIT_SHA"] && process.env["VERCEL_GIT_REPO_SLUG"] && process.env["VERCEL_GIT_REPO_OWNER"] &&
|
|
7950
|
+
// We only want to set commits for the production env because Sentry becomes extremely noisy (eg on slack) for
|
|
7951
|
+
// preview environments because the previous commit is always the "stem" commit of the preview/PR causing Sentry
|
|
7952
|
+
// to notify you for other people creating PRs.
|
|
7953
|
+
process.env["VERCEL_TARGET_ENV"] === "production") {
|
|
7954
|
+
options.release.setCommits = {
|
|
7955
|
+
shouldNotThrowOnFailure: true,
|
|
7956
|
+
commit: process.env["VERCEL_GIT_COMMIT_SHA"],
|
|
7957
|
+
previousCommit: process.env["VERCEL_GIT_PREVIOUS_SHA"],
|
|
7958
|
+
repo: "".concat(process.env["VERCEL_GIT_REPO_OWNER"], "/").concat(process.env["VERCEL_GIT_REPO_SLUG"]),
|
|
7959
|
+
ignoreEmpty: true,
|
|
7960
|
+
ignoreMissing: true
|
|
7961
|
+
};
|
|
7962
|
+
} else {
|
|
7963
|
+
options.release.setCommits = {
|
|
7964
|
+
shouldNotThrowOnFailure: true,
|
|
7965
|
+
auto: true,
|
|
7966
|
+
ignoreEmpty: true,
|
|
7967
|
+
ignoreMissing: true
|
|
7968
|
+
};
|
|
7969
|
+
}
|
|
7970
|
+
}
|
|
7971
|
+
if (options.release.deploy === undefined && process.env["VERCEL"] && process.env["VERCEL_TARGET_ENV"]) {
|
|
7972
|
+
options.release.deploy = {
|
|
7973
|
+
env: "vercel-".concat(process.env["VERCEL_TARGET_ENV"]),
|
|
7974
|
+
url: process.env["VERCEL_URL"] ? "https://".concat(process.env["VERCEL_URL"]) : undefined
|
|
7975
|
+
};
|
|
7968
7976
|
}
|
|
7969
|
-
|
|
7970
|
-
return Array.isArray(item) ? (item )[1] : undefined;
|
|
7977
|
+
return options;
|
|
7971
7978
|
}
|
|
7972
7979
|
|
|
7973
7980
|
/**
|
|
7974
|
-
*
|
|
7981
|
+
* Validates a few combinations of options that are not checked by Sentry CLI.
|
|
7975
7982
|
*
|
|
7976
|
-
*
|
|
7977
|
-
*
|
|
7978
|
-
*
|
|
7979
|
-
* @see https://github.com/getsentry/sentry-javascript/pull/4196
|
|
7983
|
+
* For all other options, we can rely on Sentry CLI to validate them. In fact,
|
|
7984
|
+
* we can't validate them in the plugin because Sentry CLI might pick up options from
|
|
7985
|
+
* its config file.
|
|
7980
7986
|
*
|
|
7981
|
-
*
|
|
7987
|
+
* @param options the internal options
|
|
7988
|
+
* @param logger the logger
|
|
7982
7989
|
*
|
|
7983
|
-
* @
|
|
7984
|
-
* @param names list of package names
|
|
7990
|
+
* @returns `true` if the options are valid, `false` otherwise
|
|
7985
7991
|
*/
|
|
7986
|
-
function
|
|
7987
|
-
|
|
7988
|
-
|
|
7989
|
-
if (
|
|
7990
|
-
|
|
7991
|
-
|
|
7992
|
-
|
|
7993
|
-
|
|
7994
|
-
|
|
7995
|
-
|
|
7996
|
-
|
|
7997
|
-
|
|
7992
|
+
function validateOptions(options, logger) {
|
|
7993
|
+
var _options$release, _options$release2, _options$release3;
|
|
7994
|
+
var setCommits = (_options$release = options.release) === null || _options$release === void 0 ? void 0 : _options$release.setCommits;
|
|
7995
|
+
if (setCommits) {
|
|
7996
|
+
if (!setCommits.auto && !(setCommits.repo && setCommits.commit)) {
|
|
7997
|
+
logger.error("The `setCommits` option was specified but is missing required properties.", "Please set either `auto` or both, `repo` and `commit`.");
|
|
7998
|
+
return false;
|
|
7999
|
+
}
|
|
8000
|
+
if (setCommits.auto && setCommits.repo && setCommits) {
|
|
8001
|
+
logger.warn("The `setCommits` options includes `auto` but also `repo` and `commit`.", "Ignoring `repo` and `commit`.", "Please only set either `auto` or both, `repo` and `commit`.");
|
|
8002
|
+
}
|
|
8003
|
+
}
|
|
8004
|
+
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)) {
|
|
8005
|
+
logger.error("The `deploy` option was specified but is missing the required `env` property.", "Please set the `env` property.");
|
|
8006
|
+
return false;
|
|
7998
8007
|
}
|
|
8008
|
+
return true;
|
|
8009
|
+
}
|
|
7999
8010
|
|
|
8000
|
-
|
|
8011
|
+
// Logging everything to stderr not to interfere with stdout
|
|
8012
|
+
function createLogger(options) {
|
|
8013
|
+
return {
|
|
8014
|
+
info: function info(message) {
|
|
8015
|
+
if (!options.silent) {
|
|
8016
|
+
var _console;
|
|
8017
|
+
for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
8018
|
+
params[_key - 1] = arguments[_key];
|
|
8019
|
+
}
|
|
8020
|
+
// eslint-disable-next-line no-console
|
|
8021
|
+
(_console = console).info.apply(_console, ["".concat(options.prefix, " Info: ").concat(message)].concat(params));
|
|
8022
|
+
}
|
|
8023
|
+
},
|
|
8024
|
+
warn: function warn(message) {
|
|
8025
|
+
if (!options.silent) {
|
|
8026
|
+
var _console2;
|
|
8027
|
+
for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
8028
|
+
params[_key2 - 1] = arguments[_key2];
|
|
8029
|
+
}
|
|
8030
|
+
// eslint-disable-next-line no-console
|
|
8031
|
+
(_console2 = console).warn.apply(_console2, ["".concat(options.prefix, " Warning: ").concat(message)].concat(params));
|
|
8032
|
+
}
|
|
8033
|
+
},
|
|
8034
|
+
error: function error(message) {
|
|
8035
|
+
if (!options.silent) {
|
|
8036
|
+
var _console3;
|
|
8037
|
+
for (var _len3 = arguments.length, params = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
8038
|
+
params[_key3 - 1] = arguments[_key3];
|
|
8039
|
+
}
|
|
8040
|
+
// eslint-disable-next-line no-console
|
|
8041
|
+
(_console3 = console).error.apply(_console3, ["".concat(options.prefix, " Error: ").concat(message)].concat(params));
|
|
8042
|
+
}
|
|
8043
|
+
},
|
|
8044
|
+
debug: function debug(message) {
|
|
8045
|
+
if (!options.silent && options.debug) {
|
|
8046
|
+
var _console4;
|
|
8047
|
+
for (var _len4 = arguments.length, params = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
8048
|
+
params[_key4 - 1] = arguments[_key4];
|
|
8049
|
+
}
|
|
8050
|
+
// eslint-disable-next-line no-console
|
|
8051
|
+
(_console4 = console).debug.apply(_console4, ["".concat(options.prefix, " Debug: ").concat(message)].concat(params));
|
|
8052
|
+
}
|
|
8053
|
+
}
|
|
8054
|
+
};
|
|
8001
8055
|
}
|
|
8002
8056
|
|
|
8003
8057
|
// Estimated maximum size for reasonable standalone event
|
|
@@ -8131,7 +8185,7 @@ function makeOptionallyEnabledNodeTransport(shouldSendTelemetry) {
|
|
|
8131
8185
|
|
|
8132
8186
|
var SENTRY_SAAS_HOSTNAME = "sentry.io";
|
|
8133
8187
|
var stackParser = createStackParser(nodeStackLineParser());
|
|
8134
|
-
function createSentryInstance(options, shouldSendTelemetry,
|
|
8188
|
+
function createSentryInstance(options, shouldSendTelemetry, buildTool) {
|
|
8135
8189
|
var clientOptions = {
|
|
8136
8190
|
platform: "node",
|
|
8137
8191
|
runtime: {
|
|
@@ -8141,7 +8195,7 @@ function createSentryInstance(options, shouldSendTelemetry, bundler) {
|
|
|
8141
8195
|
dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
|
|
8142
8196
|
tracesSampleRate: 1,
|
|
8143
8197
|
sampleRate: 1,
|
|
8144
|
-
release: "3.
|
|
8198
|
+
release: "3.5.0",
|
|
8145
8199
|
integrations: [],
|
|
8146
8200
|
tracePropagationTargets: ["sentry.io/api"],
|
|
8147
8201
|
stackParser: stackParser,
|
|
@@ -8165,13 +8219,13 @@ function createSentryInstance(options, shouldSendTelemetry, bundler) {
|
|
|
8165
8219
|
var client = new ServerRuntimeClient(clientOptions);
|
|
8166
8220
|
var scope = new Scope();
|
|
8167
8221
|
scope.setClient(client);
|
|
8168
|
-
setTelemetryDataOnScope(options, scope,
|
|
8222
|
+
setTelemetryDataOnScope(options, scope, buildTool);
|
|
8169
8223
|
return {
|
|
8170
8224
|
sentryScope: scope,
|
|
8171
8225
|
sentryClient: client
|
|
8172
8226
|
};
|
|
8173
8227
|
}
|
|
8174
|
-
function setTelemetryDataOnScope(options, scope,
|
|
8228
|
+
function setTelemetryDataOnScope(options, scope, buildTool) {
|
|
8175
8229
|
var _options$_metaOptions;
|
|
8176
8230
|
var org = options.org,
|
|
8177
8231
|
project = options.project,
|
|
@@ -8209,7 +8263,7 @@ function setTelemetryDataOnScope(options, scope, bundler) {
|
|
|
8209
8263
|
scope.setTags({
|
|
8210
8264
|
organization: org,
|
|
8211
8265
|
project: project,
|
|
8212
|
-
bundler:
|
|
8266
|
+
bundler: buildTool
|
|
8213
8267
|
});
|
|
8214
8268
|
scope.setUser({
|
|
8215
8269
|
id: org
|
|
@@ -8306,297 +8360,26 @@ function _safeFlushTelemetry() {
|
|
|
8306
8360
|
}
|
|
8307
8361
|
|
|
8308
8362
|
function createDebugIdUploadFunction(_ref) {
|
|
8309
|
-
var
|
|
8310
|
-
ignore = _ref.ignore,
|
|
8311
|
-
logger = _ref.logger,
|
|
8312
|
-
releaseName = _ref.releaseName,
|
|
8313
|
-
dist = _ref.dist,
|
|
8314
|
-
handleRecoverableError = _ref.handleRecoverableError,
|
|
8315
|
-
sentryScope = _ref.sentryScope,
|
|
8316
|
-
sentryClient = _ref.sentryClient,
|
|
8317
|
-
sentryCliOptions = _ref.sentryCliOptions,
|
|
8318
|
-
rewriteSourcesHook = _ref.rewriteSourcesHook,
|
|
8319
|
-
createDependencyOnSourcemapFiles = _ref.createDependencyOnSourcemapFiles;
|
|
8320
|
-
var freeGlobalDependencyOnSourcemapFiles = createDependencyOnSourcemapFiles();
|
|
8363
|
+
var sentryBuildPluginManager = _ref.sentryBuildPluginManager;
|
|
8321
8364
|
return /*#__PURE__*/function () {
|
|
8322
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8323
|
-
return _regeneratorRuntime().wrap(function
|
|
8324
|
-
while (1) switch (
|
|
8365
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(buildArtifactPaths) {
|
|
8366
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
8367
|
+
while (1) switch (_context.prev = _context.next) {
|
|
8325
8368
|
case 0:
|
|
8326
|
-
|
|
8327
|
-
return
|
|
8328
|
-
// This is `forceTransaction`ed because this span is used in dashboards in the form of indexed transactions.
|
|
8329
|
-
{
|
|
8330
|
-
name: "debug-id-sourcemap-upload",
|
|
8331
|
-
scope: sentryScope,
|
|
8332
|
-
forceTransaction: true
|
|
8333
|
-
}, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
8334
|
-
var folderToCleanUp, freeUploadDependencyOnSourcemapFiles, tmpUploadFolder, globAssets, globResult, debugIdChunkFilePaths;
|
|
8335
|
-
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
8336
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
8337
|
-
case 0:
|
|
8338
|
-
// It is possible that this writeBundle hook (which calls this function) is called multiple times in one build (for example when reusing the plugin, or when using build tooling like `@vitejs/plugin-legacy`)
|
|
8339
|
-
// Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.
|
|
8340
|
-
freeUploadDependencyOnSourcemapFiles = createDependencyOnSourcemapFiles();
|
|
8341
|
-
_context8.prev = 1;
|
|
8342
|
-
_context8.next = 4;
|
|
8343
|
-
return startSpan({
|
|
8344
|
-
name: "mkdtemp",
|
|
8345
|
-
scope: sentryScope
|
|
8346
|
-
}, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
8347
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
8348
|
-
while (1) switch (_context.prev = _context.next) {
|
|
8349
|
-
case 0:
|
|
8350
|
-
_context.next = 2;
|
|
8351
|
-
return fs__default["default"].promises.mkdtemp(path__default["default"].join(os__default["default"].tmpdir(), "sentry-bundler-plugin-upload-"));
|
|
8352
|
-
case 2:
|
|
8353
|
-
return _context.abrupt("return", _context.sent);
|
|
8354
|
-
case 3:
|
|
8355
|
-
case "end":
|
|
8356
|
-
return _context.stop();
|
|
8357
|
-
}
|
|
8358
|
-
}, _callee);
|
|
8359
|
-
})));
|
|
8360
|
-
case 4:
|
|
8361
|
-
tmpUploadFolder = _context8.sent;
|
|
8362
|
-
folderToCleanUp = tmpUploadFolder;
|
|
8363
|
-
if (assets) {
|
|
8364
|
-
globAssets = assets;
|
|
8365
|
-
} else {
|
|
8366
|
-
logger.debug("No `sourcemaps.assets` option provided, falling back to uploading detected build artifacts.");
|
|
8367
|
-
globAssets = buildArtifactPaths;
|
|
8368
|
-
}
|
|
8369
|
-
_context8.next = 9;
|
|
8370
|
-
return startSpan({
|
|
8371
|
-
name: "glob",
|
|
8372
|
-
scope: sentryScope
|
|
8373
|
-
}, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
8374
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
8375
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
8376
|
-
case 0:
|
|
8377
|
-
_context2.next = 2;
|
|
8378
|
-
return glob.glob(globAssets, {
|
|
8379
|
-
absolute: true,
|
|
8380
|
-
nodir: true,
|
|
8381
|
-
ignore: ignore
|
|
8382
|
-
});
|
|
8383
|
-
case 2:
|
|
8384
|
-
return _context2.abrupt("return", _context2.sent);
|
|
8385
|
-
case 3:
|
|
8386
|
-
case "end":
|
|
8387
|
-
return _context2.stop();
|
|
8388
|
-
}
|
|
8389
|
-
}, _callee2);
|
|
8390
|
-
})));
|
|
8391
|
-
case 9:
|
|
8392
|
-
globResult = _context8.sent;
|
|
8393
|
-
debugIdChunkFilePaths = globResult.filter(function (debugIdChunkFilePath) {
|
|
8394
|
-
return !!stripQueryAndHashFromPath(debugIdChunkFilePath).match(/\.(js|mjs|cjs)$/);
|
|
8395
|
-
}); // The order of the files output by glob() is not deterministic
|
|
8396
|
-
// Ensure order within the files so that {debug-id}-{chunkIndex} coupling is consistent
|
|
8397
|
-
debugIdChunkFilePaths.sort();
|
|
8398
|
-
if (!(Array.isArray(assets) && assets.length === 0)) {
|
|
8399
|
-
_context8.next = 16;
|
|
8400
|
-
break;
|
|
8401
|
-
}
|
|
8402
|
-
logger.debug("Empty `sourcemaps.assets` option provided. Will not upload sourcemaps with debug ID.");
|
|
8403
|
-
_context8.next = 23;
|
|
8404
|
-
break;
|
|
8405
|
-
case 16:
|
|
8406
|
-
if (!(debugIdChunkFilePaths.length === 0)) {
|
|
8407
|
-
_context8.next = 20;
|
|
8408
|
-
break;
|
|
8409
|
-
}
|
|
8410
|
-
logger.warn("Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option.");
|
|
8411
|
-
_context8.next = 23;
|
|
8412
|
-
break;
|
|
8413
|
-
case 20:
|
|
8414
|
-
_context8.next = 22;
|
|
8415
|
-
return startSpan({
|
|
8416
|
-
name: "prepare-bundles",
|
|
8417
|
-
scope: sentryScope
|
|
8418
|
-
}, /*#__PURE__*/function () {
|
|
8419
|
-
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(prepBundlesSpan) {
|
|
8420
|
-
var preparationTasks, workers, worker, workerIndex, files, stats, uploadSize;
|
|
8421
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
8422
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
8423
|
-
case 0:
|
|
8424
|
-
// Preparing the bundles can be a lot of work and doing it all at once has the potential of nuking the heap so
|
|
8425
|
-
// instead we do it with a maximum of 16 concurrent workers
|
|
8426
|
-
preparationTasks = debugIdChunkFilePaths.map(function (chunkFilePath, chunkIndex) {
|
|
8427
|
-
return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
8428
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
8429
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
8430
|
-
case 0:
|
|
8431
|
-
_context3.next = 2;
|
|
8432
|
-
return prepareBundleForDebugIdUpload(chunkFilePath, tmpUploadFolder, chunkIndex, logger, rewriteSourcesHook !== null && rewriteSourcesHook !== void 0 ? rewriteSourcesHook : defaultRewriteSourcesHook);
|
|
8433
|
-
case 2:
|
|
8434
|
-
case "end":
|
|
8435
|
-
return _context3.stop();
|
|
8436
|
-
}
|
|
8437
|
-
}, _callee3);
|
|
8438
|
-
}));
|
|
8439
|
-
});
|
|
8440
|
-
workers = [];
|
|
8441
|
-
worker = /*#__PURE__*/function () {
|
|
8442
|
-
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
8443
|
-
var task;
|
|
8444
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
8445
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
8446
|
-
case 0:
|
|
8447
|
-
if (!(preparationTasks.length > 0)) {
|
|
8448
|
-
_context4.next = 7;
|
|
8449
|
-
break;
|
|
8450
|
-
}
|
|
8451
|
-
task = preparationTasks.shift();
|
|
8452
|
-
if (!task) {
|
|
8453
|
-
_context4.next = 5;
|
|
8454
|
-
break;
|
|
8455
|
-
}
|
|
8456
|
-
_context4.next = 5;
|
|
8457
|
-
return task();
|
|
8458
|
-
case 5:
|
|
8459
|
-
_context4.next = 0;
|
|
8460
|
-
break;
|
|
8461
|
-
case 7:
|
|
8462
|
-
case "end":
|
|
8463
|
-
return _context4.stop();
|
|
8464
|
-
}
|
|
8465
|
-
}, _callee4);
|
|
8466
|
-
}));
|
|
8467
|
-
return function worker() {
|
|
8468
|
-
return _ref8.apply(this, arguments);
|
|
8469
|
-
};
|
|
8470
|
-
}();
|
|
8471
|
-
for (workerIndex = 0; workerIndex < 16; workerIndex++) {
|
|
8472
|
-
workers.push(worker());
|
|
8473
|
-
}
|
|
8474
|
-
_context6.next = 6;
|
|
8475
|
-
return Promise.all(workers);
|
|
8476
|
-
case 6:
|
|
8477
|
-
_context6.next = 8;
|
|
8478
|
-
return fs__default["default"].promises.readdir(tmpUploadFolder);
|
|
8479
|
-
case 8:
|
|
8480
|
-
files = _context6.sent;
|
|
8481
|
-
stats = files.map(function (file) {
|
|
8482
|
-
return fs__default["default"].promises.stat(path__default["default"].join(tmpUploadFolder, file));
|
|
8483
|
-
});
|
|
8484
|
-
_context6.next = 12;
|
|
8485
|
-
return Promise.all(stats);
|
|
8486
|
-
case 12:
|
|
8487
|
-
uploadSize = _context6.sent.reduce(function (accumulator, _ref9) {
|
|
8488
|
-
var size = _ref9.size;
|
|
8489
|
-
return accumulator + size;
|
|
8490
|
-
}, 0);
|
|
8491
|
-
setMeasurement("files", files.length, "none", prepBundlesSpan);
|
|
8492
|
-
setMeasurement("upload_size", uploadSize, "byte", prepBundlesSpan);
|
|
8493
|
-
_context6.next = 17;
|
|
8494
|
-
return startSpan({
|
|
8495
|
-
name: "upload",
|
|
8496
|
-
scope: sentryScope
|
|
8497
|
-
}, /*#__PURE__*/function () {
|
|
8498
|
-
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(uploadSpan) {
|
|
8499
|
-
var cliInstance;
|
|
8500
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
8501
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
8502
|
-
case 0:
|
|
8503
|
-
cliInstance = new SentryCli__default["default"](null, _objectSpread2(_objectSpread2({}, sentryCliOptions), {}, {
|
|
8504
|
-
headers: _objectSpread2({
|
|
8505
|
-
"sentry-trace": spanToTraceHeader(uploadSpan),
|
|
8506
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
8507
|
-
baggage: dynamicSamplingContextToSentryBaggageHeader(getDynamicSamplingContextFromSpan(uploadSpan))
|
|
8508
|
-
}, sentryCliOptions.headers)
|
|
8509
|
-
}));
|
|
8510
|
-
_context5.next = 3;
|
|
8511
|
-
return cliInstance.releases.uploadSourceMaps(releaseName !== null && releaseName !== void 0 ? releaseName : "undefined",
|
|
8512
|
-
// unfortunately this needs a value for now but it will not matter since debug IDs overpower releases anyhow
|
|
8513
|
-
{
|
|
8514
|
-
include: [{
|
|
8515
|
-
paths: [tmpUploadFolder],
|
|
8516
|
-
rewrite: false,
|
|
8517
|
-
dist: dist
|
|
8518
|
-
}]
|
|
8519
|
-
});
|
|
8520
|
-
case 3:
|
|
8521
|
-
case "end":
|
|
8522
|
-
return _context5.stop();
|
|
8523
|
-
}
|
|
8524
|
-
}, _callee5);
|
|
8525
|
-
}));
|
|
8526
|
-
return function (_x3) {
|
|
8527
|
-
return _ref10.apply(this, arguments);
|
|
8528
|
-
};
|
|
8529
|
-
}());
|
|
8530
|
-
case 17:
|
|
8531
|
-
case "end":
|
|
8532
|
-
return _context6.stop();
|
|
8533
|
-
}
|
|
8534
|
-
}, _callee6);
|
|
8535
|
-
}));
|
|
8536
|
-
return function (_x2) {
|
|
8537
|
-
return _ref6.apply(this, arguments);
|
|
8538
|
-
};
|
|
8539
|
-
}());
|
|
8540
|
-
case 22:
|
|
8541
|
-
logger.info("Successfully uploaded source maps to Sentry");
|
|
8542
|
-
case 23:
|
|
8543
|
-
_context8.next = 29;
|
|
8544
|
-
break;
|
|
8545
|
-
case 25:
|
|
8546
|
-
_context8.prev = 25;
|
|
8547
|
-
_context8.t0 = _context8["catch"](1);
|
|
8548
|
-
sentryScope.captureException('Error in "debugIdUploadPlugin" writeBundle hook');
|
|
8549
|
-
handleRecoverableError(_context8.t0, false);
|
|
8550
|
-
case 29:
|
|
8551
|
-
_context8.prev = 29;
|
|
8552
|
-
if (folderToCleanUp) {
|
|
8553
|
-
void startSpan({
|
|
8554
|
-
name: "cleanup",
|
|
8555
|
-
scope: sentryScope
|
|
8556
|
-
}, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
8557
|
-
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
8558
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
8559
|
-
case 0:
|
|
8560
|
-
if (!folderToCleanUp) {
|
|
8561
|
-
_context7.next = 3;
|
|
8562
|
-
break;
|
|
8563
|
-
}
|
|
8564
|
-
_context7.next = 3;
|
|
8565
|
-
return fs__default["default"].promises.rm(folderToCleanUp, {
|
|
8566
|
-
recursive: true,
|
|
8567
|
-
force: true
|
|
8568
|
-
});
|
|
8569
|
-
case 3:
|
|
8570
|
-
case "end":
|
|
8571
|
-
return _context7.stop();
|
|
8572
|
-
}
|
|
8573
|
-
}, _callee7);
|
|
8574
|
-
})));
|
|
8575
|
-
}
|
|
8576
|
-
freeGlobalDependencyOnSourcemapFiles();
|
|
8577
|
-
freeUploadDependencyOnSourcemapFiles();
|
|
8578
|
-
_context8.next = 35;
|
|
8579
|
-
return safeFlushTelemetry(sentryClient);
|
|
8580
|
-
case 35:
|
|
8581
|
-
return _context8.finish(29);
|
|
8582
|
-
case 36:
|
|
8583
|
-
case "end":
|
|
8584
|
-
return _context8.stop();
|
|
8585
|
-
}
|
|
8586
|
-
}, _callee8, null, [[1, 25, 29, 36]]);
|
|
8587
|
-
})));
|
|
8369
|
+
_context.next = 2;
|
|
8370
|
+
return sentryBuildPluginManager.uploadSourcemaps(buildArtifactPaths);
|
|
8588
8371
|
case 2:
|
|
8589
8372
|
case "end":
|
|
8590
|
-
return
|
|
8373
|
+
return _context.stop();
|
|
8591
8374
|
}
|
|
8592
|
-
},
|
|
8375
|
+
}, _callee);
|
|
8593
8376
|
}));
|
|
8594
8377
|
return function (_x) {
|
|
8595
8378
|
return _ref2.apply(this, arguments);
|
|
8596
8379
|
};
|
|
8597
8380
|
}();
|
|
8598
8381
|
}
|
|
8599
|
-
function prepareBundleForDebugIdUpload(_x4, _x5, _x6, _x7
|
|
8382
|
+
function prepareBundleForDebugIdUpload(_x2, _x3, _x4, _x5, _x6, _x7) {
|
|
8600
8383
|
return _prepareBundleForDebugIdUpload.apply(this, arguments);
|
|
8601
8384
|
}
|
|
8602
8385
|
|
|
@@ -8607,66 +8390,66 @@ function prepareBundleForDebugIdUpload(_x4, _x5, _x6, _x7, _x8) {
|
|
|
8607
8390
|
* The string pattern is injected via the debug ID injection snipped.
|
|
8608
8391
|
*/
|
|
8609
8392
|
function _prepareBundleForDebugIdUpload() {
|
|
8610
|
-
_prepareBundleForDebugIdUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8393
|
+
_prepareBundleForDebugIdUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(bundleFilePath, uploadFolder, chunkIndex, logger, rewriteSourcesHook, resolveSourceMapHook) {
|
|
8611
8394
|
var bundleContent, debugId, uniqueUploadName, writeSourceFilePromise, writeSourceMapFilePromise;
|
|
8612
|
-
return _regeneratorRuntime().wrap(function
|
|
8613
|
-
while (1) switch (
|
|
8395
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
8396
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
8614
8397
|
case 0:
|
|
8615
|
-
|
|
8616
|
-
|
|
8398
|
+
_context3.prev = 0;
|
|
8399
|
+
_context3.next = 3;
|
|
8617
8400
|
return util.promisify(fs__default["default"].readFile)(bundleFilePath, "utf8");
|
|
8618
8401
|
case 3:
|
|
8619
|
-
bundleContent =
|
|
8620
|
-
|
|
8402
|
+
bundleContent = _context3.sent;
|
|
8403
|
+
_context3.next = 10;
|
|
8621
8404
|
break;
|
|
8622
8405
|
case 6:
|
|
8623
|
-
|
|
8624
|
-
|
|
8625
|
-
logger.error("Could not read bundle to determine debug ID and source map: ".concat(bundleFilePath),
|
|
8626
|
-
return
|
|
8406
|
+
_context3.prev = 6;
|
|
8407
|
+
_context3.t0 = _context3["catch"](0);
|
|
8408
|
+
logger.error("Could not read bundle to determine debug ID and source map: ".concat(bundleFilePath), _context3.t0);
|
|
8409
|
+
return _context3.abrupt("return");
|
|
8627
8410
|
case 10:
|
|
8628
8411
|
debugId = determineDebugIdFromBundleSource(bundleContent);
|
|
8629
8412
|
if (!(debugId === undefined)) {
|
|
8630
|
-
|
|
8413
|
+
_context3.next = 14;
|
|
8631
8414
|
break;
|
|
8632
8415
|
}
|
|
8633
8416
|
logger.debug("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));
|
|
8634
|
-
return
|
|
8417
|
+
return _context3.abrupt("return");
|
|
8635
8418
|
case 14:
|
|
8636
8419
|
uniqueUploadName = "".concat(debugId, "-").concat(chunkIndex);
|
|
8637
|
-
bundleContent
|
|
8420
|
+
bundleContent = addDebugIdToBundleSource(bundleContent, debugId);
|
|
8638
8421
|
writeSourceFilePromise = fs__default["default"].promises.writeFile(path__default["default"].join(uploadFolder, "".concat(uniqueUploadName, ".js")), bundleContent, "utf-8");
|
|
8639
|
-
writeSourceMapFilePromise = determineSourceMapPathFromBundle(bundleFilePath, bundleContent, logger).then( /*#__PURE__*/function () {
|
|
8640
|
-
var
|
|
8641
|
-
return _regeneratorRuntime().wrap(function
|
|
8642
|
-
while (1) switch (
|
|
8422
|
+
writeSourceMapFilePromise = determineSourceMapPathFromBundle(bundleFilePath, bundleContent, logger, resolveSourceMapHook).then( /*#__PURE__*/function () {
|
|
8423
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(sourceMapPath) {
|
|
8424
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
8425
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
8643
8426
|
case 0:
|
|
8644
8427
|
if (!sourceMapPath) {
|
|
8645
|
-
|
|
8428
|
+
_context2.next = 3;
|
|
8646
8429
|
break;
|
|
8647
8430
|
}
|
|
8648
|
-
|
|
8431
|
+
_context2.next = 3;
|
|
8649
8432
|
return prepareSourceMapForDebugIdUpload(sourceMapPath, path__default["default"].join(uploadFolder, "".concat(uniqueUploadName, ".js.map")), debugId, rewriteSourcesHook, logger);
|
|
8650
8433
|
case 3:
|
|
8651
8434
|
case "end":
|
|
8652
|
-
return
|
|
8435
|
+
return _context2.stop();
|
|
8653
8436
|
}
|
|
8654
|
-
},
|
|
8437
|
+
}, _callee2);
|
|
8655
8438
|
}));
|
|
8656
8439
|
return function (_x17) {
|
|
8657
|
-
return
|
|
8440
|
+
return _ref3.apply(this, arguments);
|
|
8658
8441
|
};
|
|
8659
8442
|
}());
|
|
8660
|
-
|
|
8443
|
+
_context3.next = 20;
|
|
8661
8444
|
return writeSourceFilePromise;
|
|
8662
8445
|
case 20:
|
|
8663
|
-
|
|
8446
|
+
_context3.next = 22;
|
|
8664
8447
|
return writeSourceMapFilePromise;
|
|
8665
8448
|
case 22:
|
|
8666
8449
|
case "end":
|
|
8667
|
-
return
|
|
8450
|
+
return _context3.stop();
|
|
8668
8451
|
}
|
|
8669
|
-
},
|
|
8452
|
+
}, _callee3, null, [[0, 6]]);
|
|
8670
8453
|
}));
|
|
8671
8454
|
return _prepareBundleForDebugIdUpload.apply(this, arguments);
|
|
8672
8455
|
}
|
|
@@ -8678,77 +8461,102 @@ function determineDebugIdFromBundleSource(code) {
|
|
|
8678
8461
|
return undefined;
|
|
8679
8462
|
}
|
|
8680
8463
|
}
|
|
8464
|
+
var SPEC_LAST_DEBUG_ID_REGEX = /\/\/# debugId=([a-fA-F0-9-]+)(?![\s\S]*\/\/# debugId=)/m;
|
|
8465
|
+
function hasSpecCompliantDebugId(bundleSource) {
|
|
8466
|
+
return SPEC_LAST_DEBUG_ID_REGEX.test(bundleSource);
|
|
8467
|
+
}
|
|
8468
|
+
function addDebugIdToBundleSource(bundleSource, debugId) {
|
|
8469
|
+
if (hasSpecCompliantDebugId(bundleSource)) {
|
|
8470
|
+
return bundleSource.replace(SPEC_LAST_DEBUG_ID_REGEX, "//# debugId=".concat(debugId));
|
|
8471
|
+
} else {
|
|
8472
|
+
return "".concat(bundleSource, "\n//# debugId=").concat(debugId);
|
|
8473
|
+
}
|
|
8474
|
+
}
|
|
8681
8475
|
|
|
8682
8476
|
/**
|
|
8683
8477
|
* Applies a set of heuristics to find the source map for a particular bundle.
|
|
8684
8478
|
*
|
|
8685
8479
|
* @returns the path to the bundle's source map or `undefined` if none could be found.
|
|
8686
8480
|
*/
|
|
8687
|
-
function determineSourceMapPathFromBundle(_x9, _x10, _x11) {
|
|
8481
|
+
function determineSourceMapPathFromBundle(_x8, _x9, _x10, _x11) {
|
|
8688
8482
|
return _determineSourceMapPathFromBundle.apply(this, arguments);
|
|
8689
8483
|
}
|
|
8484
|
+
|
|
8690
8485
|
/**
|
|
8691
8486
|
* Reads a source map, injects debug ID fields, and writes the source map to the target path.
|
|
8692
8487
|
*/
|
|
8693
8488
|
function _determineSourceMapPathFromBundle() {
|
|
8694
|
-
_determineSourceMapPathFromBundle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8695
|
-
var sourceMappingUrlMatch, sourceMappingUrl,
|
|
8696
|
-
return _regeneratorRuntime().wrap(function
|
|
8697
|
-
while (1) switch (
|
|
8489
|
+
_determineSourceMapPathFromBundle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(bundlePath, bundleSource, logger, resolveSourceMapHook) {
|
|
8490
|
+
var sourceMappingUrlMatch, sourceMappingUrl, searchLocations, customPath, parsedUrl, _i, _searchLocations, searchLocation;
|
|
8491
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
8492
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
8698
8493
|
case 0:
|
|
8699
|
-
// 1. try to find source map at `sourceMappingURL` location
|
|
8700
8494
|
sourceMappingUrlMatch = bundleSource.match(/^\s*\/\/# sourceMappingURL=(.*)$/m);
|
|
8701
|
-
|
|
8702
|
-
|
|
8495
|
+
sourceMappingUrl = sourceMappingUrlMatch ? sourceMappingUrlMatch[1] : undefined;
|
|
8496
|
+
searchLocations = [];
|
|
8497
|
+
if (!resolveSourceMapHook) {
|
|
8498
|
+
_context4.next = 10;
|
|
8703
8499
|
break;
|
|
8704
8500
|
}
|
|
8705
|
-
|
|
8706
|
-
|
|
8707
|
-
|
|
8708
|
-
|
|
8709
|
-
|
|
8710
|
-
|
|
8711
|
-
|
|
8712
|
-
|
|
8501
|
+
logger.debug("Calling sourcemaps.resolveSourceMap(".concat(JSON.stringify(bundlePath), ", ").concat(JSON.stringify(sourceMappingUrl), ")"));
|
|
8502
|
+
_context4.next = 7;
|
|
8503
|
+
return resolveSourceMapHook(bundlePath, sourceMappingUrl);
|
|
8504
|
+
case 7:
|
|
8505
|
+
customPath = _context4.sent;
|
|
8506
|
+
logger.debug("resolveSourceMap hook returned: ".concat(JSON.stringify(customPath)));
|
|
8507
|
+
if (customPath) {
|
|
8508
|
+
searchLocations.push(customPath);
|
|
8713
8509
|
}
|
|
8714
|
-
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
|
|
8718
|
-
|
|
8719
|
-
|
|
8510
|
+
case 10:
|
|
8511
|
+
// 1. try to find source map at `sourceMappingURL` location
|
|
8512
|
+
if (sourceMappingUrl) {
|
|
8513
|
+
try {
|
|
8514
|
+
parsedUrl = new URL(sourceMappingUrl);
|
|
8515
|
+
} catch (_unused) {
|
|
8516
|
+
// noop
|
|
8517
|
+
}
|
|
8518
|
+
if (parsedUrl && parsedUrl.protocol === "file:") {
|
|
8519
|
+
searchLocations.push(url__namespace.fileURLToPath(sourceMappingUrl));
|
|
8520
|
+
} else if (parsedUrl) ; else if (path__default["default"].isAbsolute(sourceMappingUrl)) {
|
|
8521
|
+
searchLocations.push(path__default["default"].normalize(sourceMappingUrl));
|
|
8522
|
+
} else {
|
|
8523
|
+
searchLocations.push(path__default["default"].normalize(path__default["default"].join(path__default["default"].dirname(bundlePath), sourceMappingUrl)));
|
|
8524
|
+
}
|
|
8720
8525
|
}
|
|
8721
|
-
|
|
8722
|
-
|
|
8526
|
+
|
|
8527
|
+
// 2. try to find source map at path adjacent to chunk source, but with `.map` appended
|
|
8528
|
+
searchLocations.push(bundlePath + ".map");
|
|
8529
|
+
_i = 0, _searchLocations = searchLocations;
|
|
8530
|
+
case 13:
|
|
8531
|
+
if (!(_i < _searchLocations.length)) {
|
|
8532
|
+
_context4.next = 27;
|
|
8723
8533
|
break;
|
|
8724
8534
|
}
|
|
8725
|
-
|
|
8726
|
-
|
|
8727
|
-
|
|
8728
|
-
|
|
8729
|
-
return _context12.abrupt("return", absoluteSourceMapPath);
|
|
8730
|
-
case 12:
|
|
8731
|
-
_context12.prev = 12;
|
|
8732
|
-
_context12.t0 = _context12["catch"](6);
|
|
8733
|
-
case 14:
|
|
8734
|
-
_context12.prev = 14;
|
|
8735
|
-
adjacentSourceMapFilePath = bundlePath + ".map";
|
|
8736
|
-
_context12.next = 18;
|
|
8737
|
-
return util__namespace.promisify(fs__default["default"].access)(adjacentSourceMapFilePath);
|
|
8535
|
+
searchLocation = _searchLocations[_i];
|
|
8536
|
+
_context4.prev = 15;
|
|
8537
|
+
_context4.next = 18;
|
|
8538
|
+
return util__namespace.promisify(fs__default["default"].access)(searchLocation);
|
|
8738
8539
|
case 18:
|
|
8739
|
-
|
|
8740
|
-
|
|
8741
|
-
|
|
8742
|
-
|
|
8743
|
-
|
|
8540
|
+
logger.debug("Source map found for bundle `".concat(bundlePath, "`: `").concat(searchLocation, "`"));
|
|
8541
|
+
return _context4.abrupt("return", searchLocation);
|
|
8542
|
+
case 22:
|
|
8543
|
+
_context4.prev = 22;
|
|
8544
|
+
_context4.t0 = _context4["catch"](15);
|
|
8545
|
+
case 24:
|
|
8546
|
+
_i++;
|
|
8547
|
+
_context4.next = 13;
|
|
8548
|
+
break;
|
|
8549
|
+
case 27:
|
|
8744
8550
|
// This is just a debug message because it can be quite spammy for some frameworks
|
|
8745
|
-
logger.debug("Could not determine source map path for bundle
|
|
8746
|
-
|
|
8747
|
-
|
|
8551
|
+
logger.debug("Could not determine source map path for bundle `".concat(bundlePath, "`") + " with sourceMappingURL=".concat(sourceMappingUrl === undefined ? "undefined" : "`".concat(sourceMappingUrl, "`")) + " - Did you turn on source map generation in your bundler?" + " (Attempted paths: ".concat(searchLocations.map(function (e) {
|
|
8552
|
+
return "`".concat(e, "`");
|
|
8553
|
+
}).join(", "), ")"));
|
|
8554
|
+
return _context4.abrupt("return", undefined);
|
|
8555
|
+
case 29:
|
|
8748
8556
|
case "end":
|
|
8749
|
-
return
|
|
8557
|
+
return _context4.stop();
|
|
8750
8558
|
}
|
|
8751
|
-
},
|
|
8559
|
+
}, _callee4, null, [[15, 22]]);
|
|
8752
8560
|
}));
|
|
8753
8561
|
return _determineSourceMapPathFromBundle.apply(this, arguments);
|
|
8754
8562
|
}
|
|
@@ -8756,62 +8564,62 @@ function prepareSourceMapForDebugIdUpload(_x12, _x13, _x14, _x15, _x16) {
|
|
|
8756
8564
|
return _prepareSourceMapForDebugIdUpload.apply(this, arguments);
|
|
8757
8565
|
}
|
|
8758
8566
|
function _prepareSourceMapForDebugIdUpload() {
|
|
8759
|
-
_prepareSourceMapForDebugIdUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8567
|
+
_prepareSourceMapForDebugIdUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(sourceMapPath, targetPath, debugId, rewriteSourcesHook, logger) {
|
|
8760
8568
|
var sourceMapFileContent, map;
|
|
8761
|
-
return _regeneratorRuntime().wrap(function
|
|
8762
|
-
while (1) switch (
|
|
8569
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
8570
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
8763
8571
|
case 0:
|
|
8764
|
-
|
|
8765
|
-
|
|
8572
|
+
_context5.prev = 0;
|
|
8573
|
+
_context5.next = 3;
|
|
8766
8574
|
return util__namespace.promisify(fs__default["default"].readFile)(sourceMapPath, {
|
|
8767
8575
|
encoding: "utf8"
|
|
8768
8576
|
});
|
|
8769
8577
|
case 3:
|
|
8770
|
-
sourceMapFileContent =
|
|
8771
|
-
|
|
8578
|
+
sourceMapFileContent = _context5.sent;
|
|
8579
|
+
_context5.next = 10;
|
|
8772
8580
|
break;
|
|
8773
8581
|
case 6:
|
|
8774
|
-
|
|
8775
|
-
|
|
8776
|
-
logger.error("Failed to read source map for debug ID upload: ".concat(sourceMapPath),
|
|
8777
|
-
return
|
|
8582
|
+
_context5.prev = 6;
|
|
8583
|
+
_context5.t0 = _context5["catch"](0);
|
|
8584
|
+
logger.error("Failed to read source map for debug ID upload: ".concat(sourceMapPath), _context5.t0);
|
|
8585
|
+
return _context5.abrupt("return");
|
|
8778
8586
|
case 10:
|
|
8779
|
-
|
|
8587
|
+
_context5.prev = 10;
|
|
8780
8588
|
map = JSON.parse(sourceMapFileContent);
|
|
8781
8589
|
// For now we write both fields until we know what will become the standard - if ever.
|
|
8782
8590
|
map["debug_id"] = debugId;
|
|
8783
8591
|
map["debugId"] = debugId;
|
|
8784
|
-
|
|
8592
|
+
_context5.next = 20;
|
|
8785
8593
|
break;
|
|
8786
8594
|
case 16:
|
|
8787
|
-
|
|
8788
|
-
|
|
8595
|
+
_context5.prev = 16;
|
|
8596
|
+
_context5.t1 = _context5["catch"](10);
|
|
8789
8597
|
logger.error("Failed to parse source map for debug ID upload: ".concat(sourceMapPath));
|
|
8790
|
-
return
|
|
8598
|
+
return _context5.abrupt("return");
|
|
8791
8599
|
case 20:
|
|
8792
8600
|
if (map["sources"] && Array.isArray(map["sources"])) {
|
|
8793
8601
|
map["sources"] = map["sources"].map(function (source) {
|
|
8794
8602
|
return rewriteSourcesHook(source, map);
|
|
8795
8603
|
});
|
|
8796
8604
|
}
|
|
8797
|
-
|
|
8798
|
-
|
|
8605
|
+
_context5.prev = 21;
|
|
8606
|
+
_context5.next = 24;
|
|
8799
8607
|
return util__namespace.promisify(fs__default["default"].writeFile)(targetPath, JSON.stringify(map), {
|
|
8800
8608
|
encoding: "utf8"
|
|
8801
8609
|
});
|
|
8802
8610
|
case 24:
|
|
8803
|
-
|
|
8611
|
+
_context5.next = 30;
|
|
8804
8612
|
break;
|
|
8805
8613
|
case 26:
|
|
8806
|
-
|
|
8807
|
-
|
|
8808
|
-
logger.error("Failed to prepare source map for debug ID upload: ".concat(sourceMapPath),
|
|
8809
|
-
return
|
|
8614
|
+
_context5.prev = 26;
|
|
8615
|
+
_context5.t2 = _context5["catch"](21);
|
|
8616
|
+
logger.error("Failed to prepare source map for debug ID upload: ".concat(sourceMapPath), _context5.t2);
|
|
8617
|
+
return _context5.abrupt("return");
|
|
8810
8618
|
case 30:
|
|
8811
8619
|
case "end":
|
|
8812
|
-
return
|
|
8620
|
+
return _context5.stop();
|
|
8813
8621
|
}
|
|
8814
|
-
},
|
|
8622
|
+
}, _callee5, null, [[0, 6], [10, 16], [21, 26]]);
|
|
8815
8623
|
}));
|
|
8816
8624
|
return _prepareSourceMapForDebugIdUpload.apply(this, arguments);
|
|
8817
8625
|
}
|
|
@@ -8822,53 +8630,411 @@ function defaultRewriteSourcesHook(source) {
|
|
|
8822
8630
|
} else {
|
|
8823
8631
|
return path__default["default"].relative(process.cwd(), path__default["default"].normalize(source));
|
|
8824
8632
|
}
|
|
8825
|
-
}
|
|
8826
|
-
|
|
8827
|
-
/**
|
|
8828
|
-
* Creates a plugin that
|
|
8829
|
-
*
|
|
8830
|
-
*
|
|
8831
|
-
*/
|
|
8832
|
-
function
|
|
8833
|
-
var
|
|
8834
|
-
|
|
8835
|
-
|
|
8836
|
-
|
|
8837
|
-
|
|
8838
|
-
|
|
8839
|
-
|
|
8840
|
-
|
|
8841
|
-
|
|
8842
|
-
|
|
8843
|
-
|
|
8844
|
-
|
|
8845
|
-
|
|
8846
|
-
|
|
8633
|
+
}
|
|
8634
|
+
|
|
8635
|
+
/**
|
|
8636
|
+
* Creates a build plugin manager that exposes primitives for everything that a Sentry JavaScript SDK or build tooling may do during a build.
|
|
8637
|
+
*
|
|
8638
|
+
* The build plugin manager's behavior strongly depends on the options that are passed in.
|
|
8639
|
+
*/
|
|
8640
|
+
function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
|
|
8641
|
+
var _userOptions$silent, _userOptions$debug;
|
|
8642
|
+
var logger = createLogger({
|
|
8643
|
+
prefix: bundlerPluginMetaContext.loggerPrefix,
|
|
8644
|
+
silent: (_userOptions$silent = userOptions.silent) !== null && _userOptions$silent !== void 0 ? _userOptions$silent : false,
|
|
8645
|
+
debug: (_userOptions$debug = userOptions.debug) !== null && _userOptions$debug !== void 0 ? _userOptions$debug : false
|
|
8646
|
+
});
|
|
8647
|
+
try {
|
|
8648
|
+
var dotenvFile = fs__namespace.readFileSync(path__namespace.join(process.cwd(), ".env.sentry-build-plugin"), "utf-8");
|
|
8649
|
+
// NOTE: Do not use the dotenv.config API directly to read the dotenv file! For some ungodly reason, it falls back to reading `${process.cwd()}/.env` which is absolutely not what we want.
|
|
8650
|
+
var dotenvResult = dotenv__namespace.parse(dotenvFile);
|
|
8651
|
+
|
|
8652
|
+
// Vite has a bug/behaviour where spreading into process.env will cause it to crash
|
|
8653
|
+
// https://github.com/vitest-dev/vitest/issues/1870#issuecomment-1501140251
|
|
8654
|
+
Object.assign(process.env, dotenvResult);
|
|
8655
|
+
logger.info('Using environment variables configured in ".env.sentry-build-plugin".');
|
|
8656
|
+
} catch (e) {
|
|
8657
|
+
// Ignore "file not found" errors but throw all others
|
|
8658
|
+
if (_typeof(e) === "object" && e && "code" in e && e.code !== "ENOENT") {
|
|
8659
|
+
throw e;
|
|
8660
|
+
}
|
|
8661
|
+
}
|
|
8662
|
+
var options = normalizeUserOptions(userOptions);
|
|
8663
|
+
if (options.disable) {
|
|
8664
|
+
// Early-return a noop build plugin manager instance so that we
|
|
8665
|
+
// don't continue validating options, setting up Sentry, etc.
|
|
8666
|
+
// Otherwise we might create side-effects or log messages that
|
|
8667
|
+
// users don't expect from a disabled plugin.
|
|
8668
|
+
return {
|
|
8669
|
+
normalizedOptions: options,
|
|
8670
|
+
logger: logger,
|
|
8671
|
+
bundleSizeOptimizationReplacementValues: {},
|
|
8672
|
+
telemetry: {
|
|
8673
|
+
emitBundlerPluginExecutionSignal: function () {
|
|
8674
|
+
var _emitBundlerPluginExecutionSignal = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
8675
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
8676
|
+
while (1) switch (_context.prev = _context.next) {
|
|
8677
|
+
case 0:
|
|
8678
|
+
case "end":
|
|
8679
|
+
return _context.stop();
|
|
8680
|
+
}
|
|
8681
|
+
}, _callee);
|
|
8682
|
+
}));
|
|
8683
|
+
function emitBundlerPluginExecutionSignal() {
|
|
8684
|
+
return _emitBundlerPluginExecutionSignal.apply(this, arguments);
|
|
8685
|
+
}
|
|
8686
|
+
return emitBundlerPluginExecutionSignal;
|
|
8687
|
+
}()
|
|
8688
|
+
},
|
|
8689
|
+
bundleMetadata: {},
|
|
8690
|
+
createRelease: function () {
|
|
8691
|
+
var _createRelease = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
8692
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
8693
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
8694
|
+
case 0:
|
|
8695
|
+
case "end":
|
|
8696
|
+
return _context2.stop();
|
|
8697
|
+
}
|
|
8698
|
+
}, _callee2);
|
|
8699
|
+
}));
|
|
8700
|
+
function createRelease() {
|
|
8701
|
+
return _createRelease.apply(this, arguments);
|
|
8702
|
+
}
|
|
8703
|
+
return createRelease;
|
|
8704
|
+
}(),
|
|
8705
|
+
uploadSourcemaps: function () {
|
|
8706
|
+
var _uploadSourcemaps = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
8707
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
8708
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
8709
|
+
case 0:
|
|
8710
|
+
case "end":
|
|
8711
|
+
return _context3.stop();
|
|
8712
|
+
}
|
|
8713
|
+
}, _callee3);
|
|
8714
|
+
}));
|
|
8715
|
+
function uploadSourcemaps() {
|
|
8716
|
+
return _uploadSourcemaps.apply(this, arguments);
|
|
8717
|
+
}
|
|
8718
|
+
return uploadSourcemaps;
|
|
8719
|
+
}(),
|
|
8720
|
+
deleteArtifacts: function () {
|
|
8721
|
+
var _deleteArtifacts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
8722
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
8723
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
8724
|
+
case 0:
|
|
8725
|
+
case "end":
|
|
8726
|
+
return _context4.stop();
|
|
8727
|
+
}
|
|
8728
|
+
}, _callee4);
|
|
8729
|
+
}));
|
|
8730
|
+
function deleteArtifacts() {
|
|
8731
|
+
return _deleteArtifacts.apply(this, arguments);
|
|
8732
|
+
}
|
|
8733
|
+
return deleteArtifacts;
|
|
8734
|
+
}(),
|
|
8735
|
+
createDependencyOnBuildArtifacts: function createDependencyOnBuildArtifacts() {
|
|
8736
|
+
return function () {
|
|
8737
|
+
/* noop */
|
|
8738
|
+
};
|
|
8739
|
+
}
|
|
8740
|
+
};
|
|
8741
|
+
}
|
|
8742
|
+
var shouldSendTelemetry = allowedToSendTelemetry(options);
|
|
8743
|
+
var _createSentryInstance = createSentryInstance(options, shouldSendTelemetry, bundlerPluginMetaContext.buildTool),
|
|
8744
|
+
sentryScope = _createSentryInstance.sentryScope,
|
|
8745
|
+
sentryClient = _createSentryInstance.sentryClient;
|
|
8746
|
+
var _sentryClient$getOpti = sentryClient.getOptions(),
|
|
8747
|
+
release = _sentryClient$getOpti.release,
|
|
8748
|
+
_sentryClient$getOpti2 = _sentryClient$getOpti.environment,
|
|
8749
|
+
environment = _sentryClient$getOpti2 === void 0 ? DEFAULT_ENVIRONMENT : _sentryClient$getOpti2;
|
|
8750
|
+
var sentrySession = makeSession({
|
|
8751
|
+
release: release,
|
|
8752
|
+
environment: environment
|
|
8753
|
+
});
|
|
8754
|
+
sentryScope.setSession(sentrySession);
|
|
8755
|
+
// Send the start of the session
|
|
8756
|
+
sentryClient.captureSession(sentrySession);
|
|
8757
|
+
var sessionHasEnded = false; // Just to prevent infinite loops with beforeExit, which is called whenever the event loop empties out
|
|
8758
|
+
|
|
8759
|
+
function endSession() {
|
|
8760
|
+
if (sessionHasEnded) {
|
|
8761
|
+
return;
|
|
8762
|
+
}
|
|
8763
|
+
closeSession(sentrySession);
|
|
8764
|
+
sentryClient.captureSession(sentrySession);
|
|
8765
|
+
sessionHasEnded = true;
|
|
8766
|
+
}
|
|
8767
|
+
|
|
8768
|
+
// We also need to manually end sessions on errors because beforeExit is not called on crashes
|
|
8769
|
+
process.on("beforeExit", function () {
|
|
8770
|
+
endSession();
|
|
8771
|
+
});
|
|
8772
|
+
|
|
8773
|
+
// Set the User-Agent that Sentry CLI will use when interacting with Sentry
|
|
8774
|
+
process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "3.5.0");
|
|
8775
|
+
|
|
8776
|
+
// Not a bulletproof check but should be good enough to at least sometimes determine
|
|
8777
|
+
// if the plugin is called in dev/watch mode or for a prod build. The important part
|
|
8778
|
+
// here is to avoid a false positive. False negatives are okay.
|
|
8779
|
+
var isDevMode = process.env["NODE_ENV"] === "development";
|
|
8780
|
+
|
|
8781
|
+
/**
|
|
8782
|
+
* Handles errors caught and emitted in various areas of the plugin.
|
|
8783
|
+
*
|
|
8784
|
+
* Also sets the sentry session status according to the error handling.
|
|
8785
|
+
*
|
|
8786
|
+
* If users specify their custom `errorHandler` we'll leave the decision to throw
|
|
8787
|
+
* or continue up to them. By default, @param throwByDefault controls if the plugin
|
|
8788
|
+
* should throw an error (which causes a build fail in most bundlers) or continue.
|
|
8789
|
+
*/
|
|
8790
|
+
function handleRecoverableError(unknownError, throwByDefault) {
|
|
8791
|
+
sentrySession.status = "abnormal";
|
|
8792
|
+
try {
|
|
8793
|
+
if (options.errorHandler) {
|
|
8794
|
+
try {
|
|
8795
|
+
if (unknownError instanceof Error) {
|
|
8796
|
+
options.errorHandler(unknownError);
|
|
8797
|
+
} else {
|
|
8798
|
+
options.errorHandler(new Error("An unknown error occurred"));
|
|
8799
|
+
}
|
|
8800
|
+
} catch (e) {
|
|
8801
|
+
sentrySession.status = "crashed";
|
|
8802
|
+
throw e;
|
|
8803
|
+
}
|
|
8804
|
+
} else {
|
|
8805
|
+
// setting the session to "crashed" b/c from a plugin perspective this run failed.
|
|
8806
|
+
// However, we're intentionally not rethrowing the error to avoid breaking the user build.
|
|
8807
|
+
sentrySession.status = "crashed";
|
|
8808
|
+
if (throwByDefault) {
|
|
8809
|
+
throw unknownError;
|
|
8810
|
+
}
|
|
8811
|
+
logger.error("An error occurred. Couldn't finish all operations:", unknownError);
|
|
8812
|
+
}
|
|
8813
|
+
} finally {
|
|
8814
|
+
endSession();
|
|
8815
|
+
}
|
|
8816
|
+
}
|
|
8817
|
+
if (!validateOptions(options, logger)) {
|
|
8818
|
+
// Throwing by default to avoid a misconfigured plugin going unnoticed.
|
|
8819
|
+
handleRecoverableError(new Error("Options were not set correctly. See output above for more details."), true);
|
|
8820
|
+
}
|
|
8821
|
+
|
|
8822
|
+
// We have multiple plugins depending on generated source map files. (debug ID upload, legacy upload)
|
|
8823
|
+
// Additionally, we also want to have the functionality to delete files after uploading sourcemaps.
|
|
8824
|
+
// All of these plugins and the delete functionality need to run in the same hook (`writeBundle`).
|
|
8825
|
+
// Since the plugins among themselves are not aware of when they run and finish, we need a system to
|
|
8826
|
+
// track their dependencies on the generated files, so that we can initiate the file deletion only after
|
|
8827
|
+
// nothing depends on the files anymore.
|
|
8828
|
+
var dependenciesOnBuildArtifacts = new Set();
|
|
8829
|
+
var buildArtifactsDependencySubscribers = [];
|
|
8830
|
+
function notifyBuildArtifactDependencySubscribers() {
|
|
8831
|
+
buildArtifactsDependencySubscribers.forEach(function (subscriber) {
|
|
8832
|
+
subscriber();
|
|
8833
|
+
});
|
|
8834
|
+
}
|
|
8835
|
+
function createDependencyOnBuildArtifacts() {
|
|
8836
|
+
var dependencyIdentifier = Symbol();
|
|
8837
|
+
dependenciesOnBuildArtifacts.add(dependencyIdentifier);
|
|
8838
|
+
return function freeDependencyOnBuildArtifacts() {
|
|
8839
|
+
dependenciesOnBuildArtifacts["delete"](dependencyIdentifier);
|
|
8840
|
+
notifyBuildArtifactDependencySubscribers();
|
|
8841
|
+
};
|
|
8842
|
+
}
|
|
8843
|
+
|
|
8844
|
+
/**
|
|
8845
|
+
* Returns a Promise that resolves when all the currently active dependencies are freed again.
|
|
8846
|
+
*
|
|
8847
|
+
* It is very important that this function is called as late as possible before wanting to await the Promise to give
|
|
8848
|
+
* the dependency producers as much time as possible to register themselves.
|
|
8849
|
+
*/
|
|
8850
|
+
function waitUntilBuildArtifactDependenciesAreFreed() {
|
|
8851
|
+
return new Promise(function (resolve) {
|
|
8852
|
+
buildArtifactsDependencySubscribers.push(function () {
|
|
8853
|
+
if (dependenciesOnBuildArtifacts.size === 0) {
|
|
8854
|
+
resolve();
|
|
8855
|
+
}
|
|
8856
|
+
});
|
|
8857
|
+
if (dependenciesOnBuildArtifacts.size === 0) {
|
|
8858
|
+
resolve();
|
|
8859
|
+
}
|
|
8860
|
+
});
|
|
8861
|
+
}
|
|
8862
|
+
var bundleSizeOptimizationReplacementValues = {};
|
|
8863
|
+
if (options.bundleSizeOptimizations) {
|
|
8864
|
+
var bundleSizeOptimizations = options.bundleSizeOptimizations;
|
|
8865
|
+
if (bundleSizeOptimizations.excludeDebugStatements) {
|
|
8866
|
+
bundleSizeOptimizationReplacementValues["__SENTRY_DEBUG__"] = false;
|
|
8867
|
+
}
|
|
8868
|
+
if (bundleSizeOptimizations.excludeTracing) {
|
|
8869
|
+
bundleSizeOptimizationReplacementValues["__SENTRY_TRACING__"] = false;
|
|
8870
|
+
}
|
|
8871
|
+
if (bundleSizeOptimizations.excludeReplayCanvas) {
|
|
8872
|
+
bundleSizeOptimizationReplacementValues["__RRWEB_EXCLUDE_CANVAS__"] = true;
|
|
8873
|
+
}
|
|
8874
|
+
if (bundleSizeOptimizations.excludeReplayIframe) {
|
|
8875
|
+
bundleSizeOptimizationReplacementValues["__RRWEB_EXCLUDE_IFRAME__"] = true;
|
|
8876
|
+
}
|
|
8877
|
+
if (bundleSizeOptimizations.excludeReplayShadowDom) {
|
|
8878
|
+
bundleSizeOptimizationReplacementValues["__RRWEB_EXCLUDE_SHADOW_DOM__"] = true;
|
|
8879
|
+
}
|
|
8880
|
+
if (bundleSizeOptimizations.excludeReplayWorker) {
|
|
8881
|
+
bundleSizeOptimizationReplacementValues["__SENTRY_EXCLUDE_REPLAY_WORKER__"] = true;
|
|
8882
|
+
}
|
|
8883
|
+
}
|
|
8884
|
+
var bundleMetadata = {};
|
|
8885
|
+
if (options.moduleMetadata || options.applicationKey) {
|
|
8886
|
+
if (options.applicationKey) {
|
|
8887
|
+
// We use different keys so that if user-code receives multiple bundling passes, we will store the application keys of all the passes.
|
|
8888
|
+
// It is a bit unfortunate that we have to inject the metadata snippet at the top, because after multiple
|
|
8889
|
+
// injections, the first injection will always "win" because it comes last in the code. We would generally be
|
|
8890
|
+
// fine with making the last bundling pass win. But because it cannot win, we have to use a workaround of storing
|
|
8891
|
+
// the app keys in different object keys.
|
|
8892
|
+
// We can simply use the `_sentryBundlerPluginAppKey:` to filter for app keys in the SDK.
|
|
8893
|
+
bundleMetadata["_sentryBundlerPluginAppKey:".concat(options.applicationKey)] = true;
|
|
8894
|
+
}
|
|
8895
|
+
if (typeof options.moduleMetadata === "function") {
|
|
8896
|
+
var args = {
|
|
8897
|
+
org: options.org,
|
|
8898
|
+
project: options.project,
|
|
8899
|
+
release: options.release.name
|
|
8900
|
+
};
|
|
8901
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
8902
|
+
bundleMetadata = _objectSpread2(_objectSpread2({}, bundleMetadata), options.moduleMetadata(args));
|
|
8903
|
+
} else {
|
|
8904
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
8905
|
+
bundleMetadata = _objectSpread2(_objectSpread2({}, bundleMetadata), options.moduleMetadata);
|
|
8906
|
+
}
|
|
8907
|
+
}
|
|
8847
8908
|
return {
|
|
8848
|
-
|
|
8849
|
-
|
|
8850
|
-
|
|
8909
|
+
/**
|
|
8910
|
+
* A logger instance that takes the options passed to the build plugin manager into account. (for silencing and log level etc.)
|
|
8911
|
+
*/
|
|
8912
|
+
logger: logger,
|
|
8913
|
+
/**
|
|
8914
|
+
* Options after normalization. Includes things like the inferred release name.
|
|
8915
|
+
*/
|
|
8916
|
+
normalizedOptions: options,
|
|
8917
|
+
/**
|
|
8918
|
+
* Magic strings and their replacement values that can be used for bundle size optimizations. This already takes
|
|
8919
|
+
* into account the options passed to the build plugin manager.
|
|
8920
|
+
*/
|
|
8921
|
+
bundleSizeOptimizationReplacementValues: bundleSizeOptimizationReplacementValues,
|
|
8922
|
+
/**
|
|
8923
|
+
* Metadata that should be injected into bundles if possible. Takes into account options passed to the build plugin manager.
|
|
8924
|
+
*/
|
|
8925
|
+
// See `generateModuleMetadataInjectorCode` for how this should be used exactly
|
|
8926
|
+
bundleMetadata: bundleMetadata,
|
|
8927
|
+
/**
|
|
8928
|
+
* Contains utility functions for emitting telemetry via the build plugin manager.
|
|
8929
|
+
*/
|
|
8930
|
+
telemetry: {
|
|
8931
|
+
/**
|
|
8932
|
+
* Emits a `Sentry Bundler Plugin execution` signal.
|
|
8933
|
+
*/
|
|
8934
|
+
emitBundlerPluginExecutionSignal: function emitBundlerPluginExecutionSignal() {
|
|
8935
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
8936
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
8937
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
8938
|
+
case 0:
|
|
8939
|
+
_context5.next = 2;
|
|
8940
|
+
return shouldSendTelemetry;
|
|
8941
|
+
case 2:
|
|
8942
|
+
if (!_context5.sent) {
|
|
8943
|
+
_context5.next = 7;
|
|
8944
|
+
break;
|
|
8945
|
+
}
|
|
8946
|
+
logger.info("Sending telemetry data on issues and performance to Sentry. To disable telemetry, set `options.telemetry` to `false`.");
|
|
8947
|
+
startSpan({
|
|
8948
|
+
name: "Sentry Bundler Plugin execution",
|
|
8949
|
+
scope: sentryScope
|
|
8950
|
+
}, function () {
|
|
8951
|
+
//
|
|
8952
|
+
});
|
|
8953
|
+
_context5.next = 7;
|
|
8954
|
+
return safeFlushTelemetry(sentryClient);
|
|
8955
|
+
case 7:
|
|
8956
|
+
case "end":
|
|
8957
|
+
return _context5.stop();
|
|
8958
|
+
}
|
|
8959
|
+
}, _callee5);
|
|
8960
|
+
}))();
|
|
8961
|
+
}
|
|
8962
|
+
},
|
|
8963
|
+
/**
|
|
8964
|
+
* Will potentially create a release based on the build plugin manager options.
|
|
8965
|
+
*
|
|
8966
|
+
* Also
|
|
8967
|
+
* - finalizes the release
|
|
8968
|
+
* - sets commits
|
|
8969
|
+
* - uploads legacy sourcemaps
|
|
8970
|
+
* - adds deploy information
|
|
8971
|
+
*/
|
|
8972
|
+
createRelease: function createRelease() {
|
|
8973
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
8851
8974
|
var freeWriteBundleInvocationDependencyOnSourcemapFiles, cliInstance, normalizedInclude;
|
|
8852
|
-
return _regeneratorRuntime().wrap(function
|
|
8853
|
-
while (1) switch (
|
|
8975
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
8976
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
8854
8977
|
case 0:
|
|
8978
|
+
if (options.release.name) {
|
|
8979
|
+
_context6.next = 5;
|
|
8980
|
+
break;
|
|
8981
|
+
}
|
|
8982
|
+
logger.debug("No release name provided. Will not create release. Please set the `release.name` option to identify your release.");
|
|
8983
|
+
return _context6.abrupt("return");
|
|
8984
|
+
case 5:
|
|
8985
|
+
if (!isDevMode) {
|
|
8986
|
+
_context6.next = 10;
|
|
8987
|
+
break;
|
|
8988
|
+
}
|
|
8989
|
+
logger.debug("Running in development mode. Will not create release.");
|
|
8990
|
+
return _context6.abrupt("return");
|
|
8991
|
+
case 10:
|
|
8992
|
+
if (options.authToken) {
|
|
8993
|
+
_context6.next = 15;
|
|
8994
|
+
break;
|
|
8995
|
+
}
|
|
8996
|
+
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/" + getTurborepoEnvPassthroughWarning("SENTRY_AUTH_TOKEN"));
|
|
8997
|
+
return _context6.abrupt("return");
|
|
8998
|
+
case 15:
|
|
8999
|
+
if (!(!options.org && !options.authToken.startsWith("sntrys_"))) {
|
|
9000
|
+
_context6.next = 20;
|
|
9001
|
+
break;
|
|
9002
|
+
}
|
|
9003
|
+
logger.warn("No organization slug provided. Will not create release. Please set the `org` option to your Sentry organization slug." + getTurborepoEnvPassthroughWarning("SENTRY_ORG"));
|
|
9004
|
+
return _context6.abrupt("return");
|
|
9005
|
+
case 20:
|
|
9006
|
+
if (options.project) {
|
|
9007
|
+
_context6.next = 23;
|
|
9008
|
+
break;
|
|
9009
|
+
}
|
|
9010
|
+
logger.warn("No project provided. Will not create release. Please set the `project` option to your Sentry project slug." + getTurborepoEnvPassthroughWarning("SENTRY_PROJECT"));
|
|
9011
|
+
return _context6.abrupt("return");
|
|
9012
|
+
case 23:
|
|
8855
9013
|
// It is possible that this writeBundle hook is called multiple times in one build (for example when reusing the plugin, or when using build tooling like `@vitejs/plugin-legacy`)
|
|
8856
9014
|
// Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.
|
|
8857
|
-
freeWriteBundleInvocationDependencyOnSourcemapFiles =
|
|
8858
|
-
|
|
8859
|
-
cliInstance = new SentryCli__default["default"](null,
|
|
8860
|
-
|
|
8861
|
-
|
|
9015
|
+
freeWriteBundleInvocationDependencyOnSourcemapFiles = createDependencyOnBuildArtifacts();
|
|
9016
|
+
_context6.prev = 24;
|
|
9017
|
+
cliInstance = new SentryCli__default["default"](null, {
|
|
9018
|
+
authToken: options.authToken,
|
|
9019
|
+
org: options.org,
|
|
9020
|
+
project: options.project,
|
|
9021
|
+
silent: options.silent,
|
|
9022
|
+
url: options.url,
|
|
9023
|
+
vcsRemote: options.release.vcsRemote,
|
|
9024
|
+
headers: options.headers
|
|
9025
|
+
});
|
|
9026
|
+
if (!options.release.create) {
|
|
9027
|
+
_context6.next = 29;
|
|
8862
9028
|
break;
|
|
8863
9029
|
}
|
|
8864
|
-
|
|
8865
|
-
return cliInstance.releases["new"](
|
|
8866
|
-
case
|
|
8867
|
-
if (!
|
|
8868
|
-
|
|
9030
|
+
_context6.next = 29;
|
|
9031
|
+
return cliInstance.releases["new"](options.release.name);
|
|
9032
|
+
case 29:
|
|
9033
|
+
if (!options.release.uploadLegacySourcemaps) {
|
|
9034
|
+
_context6.next = 33;
|
|
8869
9035
|
break;
|
|
8870
9036
|
}
|
|
8871
|
-
normalizedInclude = arrayify
|
|
9037
|
+
normalizedInclude = arrayify(options.release.uploadLegacySourcemaps).map(function (includeItem) {
|
|
8872
9038
|
return typeof includeItem === "string" ? {
|
|
8873
9039
|
paths: [includeItem]
|
|
8874
9040
|
} : includeItem;
|
|
@@ -8879,202 +9045,417 @@ function releaseManagementPlugin(_ref) {
|
|
|
8879
9045
|
ext: includeEntry.ext ? includeEntry.ext.map(function (extension) {
|
|
8880
9046
|
return ".".concat(extension.replace(/^\./, ""));
|
|
8881
9047
|
}) : [".js", ".map", ".jsbundle", ".bundle"],
|
|
8882
|
-
ignore: includeEntry.ignore ? arrayify
|
|
9048
|
+
ignore: includeEntry.ignore ? arrayify(includeEntry.ignore) : undefined
|
|
8883
9049
|
});
|
|
8884
9050
|
});
|
|
8885
|
-
|
|
8886
|
-
return cliInstance.releases.uploadSourceMaps(
|
|
9051
|
+
_context6.next = 33;
|
|
9052
|
+
return cliInstance.releases.uploadSourceMaps(options.release.name, {
|
|
8887
9053
|
include: normalizedInclude,
|
|
8888
|
-
dist: dist
|
|
9054
|
+
dist: options.release.dist
|
|
8889
9055
|
});
|
|
8890
|
-
case
|
|
8891
|
-
if (!(
|
|
8892
|
-
|
|
9056
|
+
case 33:
|
|
9057
|
+
if (!(options.release.setCommits !== false)) {
|
|
9058
|
+
_context6.next = 46;
|
|
8893
9059
|
break;
|
|
8894
9060
|
}
|
|
8895
|
-
|
|
8896
|
-
|
|
8897
|
-
return cliInstance.releases.setCommits(
|
|
8898
|
-
|
|
8899
|
-
|
|
9061
|
+
_context6.prev = 34;
|
|
9062
|
+
_context6.next = 37;
|
|
9063
|
+
return cliInstance.releases.setCommits(options.release.name,
|
|
9064
|
+
// set commits always exists due to the normalize function
|
|
9065
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
9066
|
+
options.release.setCommits);
|
|
9067
|
+
case 37:
|
|
9068
|
+
_context6.next = 46;
|
|
8900
9069
|
break;
|
|
8901
|
-
case
|
|
8902
|
-
|
|
8903
|
-
|
|
8904
|
-
if (!("shouldNotThrowOnFailure" in
|
|
8905
|
-
|
|
9070
|
+
case 39:
|
|
9071
|
+
_context6.prev = 39;
|
|
9072
|
+
_context6.t0 = _context6["catch"](34);
|
|
9073
|
+
if (!(options.release.setCommits && "shouldNotThrowOnFailure" in options.release.setCommits && options.release.setCommits.shouldNotThrowOnFailure)) {
|
|
9074
|
+
_context6.next = 45;
|
|
8906
9075
|
break;
|
|
8907
9076
|
}
|
|
8908
|
-
logger.debug("An error occurred setting commits on release (this message can be ignored unless you commits on release are desired):",
|
|
8909
|
-
|
|
9077
|
+
logger.debug("An error occurred setting commits on release (this message can be ignored unless you commits on release are desired):", _context6.t0);
|
|
9078
|
+
_context6.next = 46;
|
|
8910
9079
|
break;
|
|
8911
|
-
case
|
|
8912
|
-
throw
|
|
8913
|
-
case
|
|
8914
|
-
if (!
|
|
8915
|
-
|
|
9080
|
+
case 45:
|
|
9081
|
+
throw _context6.t0;
|
|
9082
|
+
case 46:
|
|
9083
|
+
if (!options.release.finalize) {
|
|
9084
|
+
_context6.next = 49;
|
|
8916
9085
|
break;
|
|
8917
9086
|
}
|
|
8918
|
-
|
|
8919
|
-
return cliInstance.releases.finalize(
|
|
8920
|
-
case
|
|
8921
|
-
if (!
|
|
8922
|
-
|
|
9087
|
+
_context6.next = 49;
|
|
9088
|
+
return cliInstance.releases.finalize(options.release.name);
|
|
9089
|
+
case 49:
|
|
9090
|
+
if (!options.release.deploy) {
|
|
9091
|
+
_context6.next = 52;
|
|
8923
9092
|
break;
|
|
8924
9093
|
}
|
|
8925
|
-
|
|
8926
|
-
return cliInstance.releases.newDeploy(
|
|
8927
|
-
case
|
|
8928
|
-
|
|
9094
|
+
_context6.next = 52;
|
|
9095
|
+
return cliInstance.releases.newDeploy(options.release.name, options.release.deploy);
|
|
9096
|
+
case 52:
|
|
9097
|
+
_context6.next = 60;
|
|
8929
9098
|
break;
|
|
8930
|
-
case
|
|
8931
|
-
|
|
8932
|
-
|
|
9099
|
+
case 54:
|
|
9100
|
+
_context6.prev = 54;
|
|
9101
|
+
_context6.t1 = _context6["catch"](24);
|
|
8933
9102
|
sentryScope.captureException('Error in "releaseManagementPlugin" writeBundle hook');
|
|
8934
|
-
|
|
9103
|
+
_context6.next = 59;
|
|
8935
9104
|
return safeFlushTelemetry(sentryClient);
|
|
8936
|
-
case
|
|
8937
|
-
handleRecoverableError(
|
|
8938
|
-
case
|
|
8939
|
-
|
|
8940
|
-
freeGlobalDependencyOnSourcemapFiles();
|
|
9105
|
+
case 59:
|
|
9106
|
+
handleRecoverableError(_context6.t1, false);
|
|
9107
|
+
case 60:
|
|
9108
|
+
_context6.prev = 60;
|
|
8941
9109
|
freeWriteBundleInvocationDependencyOnSourcemapFiles();
|
|
8942
|
-
return
|
|
8943
|
-
case
|
|
9110
|
+
return _context6.finish(60);
|
|
9111
|
+
case 63:
|
|
8944
9112
|
case "end":
|
|
8945
|
-
return
|
|
9113
|
+
return _context6.stop();
|
|
8946
9114
|
}
|
|
8947
|
-
},
|
|
9115
|
+
}, _callee6, null, [[24, 54, 60, 63], [34, 39]]);
|
|
8948
9116
|
}))();
|
|
8949
|
-
}
|
|
8950
|
-
|
|
8951
|
-
|
|
8952
|
-
|
|
8953
|
-
function
|
|
8954
|
-
|
|
8955
|
-
|
|
8956
|
-
|
|
8957
|
-
|
|
8958
|
-
return {
|
|
8959
|
-
name: "sentry-telemetry-plugin",
|
|
8960
|
-
buildStart: function buildStart() {
|
|
8961
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
8962
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
8963
|
-
while (1) switch (_context.prev = _context.next) {
|
|
9117
|
+
},
|
|
9118
|
+
/**
|
|
9119
|
+
* Uploads sourcemaps using the "Debug ID" method. This function takes a list of build artifact paths that will be uploaded
|
|
9120
|
+
*/
|
|
9121
|
+
uploadSourcemaps: function uploadSourcemaps(buildArtifactPaths) {
|
|
9122
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
9123
|
+
var _options$sourcemaps;
|
|
9124
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
9125
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
8964
9126
|
case 0:
|
|
8965
|
-
|
|
8966
|
-
|
|
8967
|
-
|
|
8968
|
-
|
|
8969
|
-
|
|
8970
|
-
|
|
9127
|
+
if ((_options$sourcemaps = options.sourcemaps) !== null && _options$sourcemaps !== void 0 && _options$sourcemaps.disable) {
|
|
9128
|
+
logger.debug("Source map upload was disabled. Will not upload sourcemaps using debug ID process.");
|
|
9129
|
+
} else if (isDevMode) {
|
|
9130
|
+
logger.debug("Running in development mode. Will not upload sourcemaps.");
|
|
9131
|
+
} else if (!options.authToken) {
|
|
9132
|
+
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/" + getTurborepoEnvPassthroughWarning("SENTRY_AUTH_TOKEN"));
|
|
9133
|
+
} else if (!options.org && !options.authToken.startsWith("sntrys_")) {
|
|
9134
|
+
logger.warn("No org provided. Will not upload source maps. Please set the `org` option to your Sentry organization slug." + getTurborepoEnvPassthroughWarning("SENTRY_ORG"));
|
|
9135
|
+
} else if (!options.project) {
|
|
9136
|
+
logger.warn("No project provided. Will not upload source maps. Please set the `project` option to your Sentry project slug." + getTurborepoEnvPassthroughWarning("SENTRY_PROJECT"));
|
|
8971
9137
|
}
|
|
8972
|
-
|
|
8973
|
-
startSpan(
|
|
8974
|
-
|
|
8975
|
-
|
|
8976
|
-
|
|
8977
|
-
|
|
8978
|
-
|
|
8979
|
-
|
|
8980
|
-
|
|
8981
|
-
|
|
9138
|
+
_context15.next = 3;
|
|
9139
|
+
return startSpan(
|
|
9140
|
+
// This is `forceTransaction`ed because this span is used in dashboards in the form of indexed transactions.
|
|
9141
|
+
{
|
|
9142
|
+
name: "debug-id-sourcemap-upload",
|
|
9143
|
+
scope: sentryScope,
|
|
9144
|
+
forceTransaction: true
|
|
9145
|
+
}, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
9146
|
+
var folderToCleanUp, freeUploadDependencyOnBuildArtifacts, _options$sourcemaps2, tmpUploadFolder, assets, globAssets, globResult, debugIdChunkFilePaths, _process$env2;
|
|
9147
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
9148
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
9149
|
+
case 0:
|
|
9150
|
+
// It is possible that this writeBundle hook (which calls this function) is called multiple times in one build (for example when reusing the plugin, or when using build tooling like `@vitejs/plugin-legacy`)
|
|
9151
|
+
// Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.
|
|
9152
|
+
freeUploadDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();
|
|
9153
|
+
_context14.prev = 1;
|
|
9154
|
+
_context14.next = 4;
|
|
9155
|
+
return startSpan({
|
|
9156
|
+
name: "mkdtemp",
|
|
9157
|
+
scope: sentryScope
|
|
9158
|
+
}, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
9159
|
+
var _process$env;
|
|
9160
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
9161
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
9162
|
+
case 0:
|
|
9163
|
+
_context7.t0 = (_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env["SENTRY_TEST_OVERRIDE_TEMP_DIR"];
|
|
9164
|
+
if (_context7.t0) {
|
|
9165
|
+
_context7.next = 5;
|
|
9166
|
+
break;
|
|
9167
|
+
}
|
|
9168
|
+
_context7.next = 4;
|
|
9169
|
+
return fs__namespace.promises.mkdtemp(path__namespace.join(os__namespace.tmpdir(), "sentry-bundler-plugin-upload-"));
|
|
9170
|
+
case 4:
|
|
9171
|
+
_context7.t0 = _context7.sent;
|
|
9172
|
+
case 5:
|
|
9173
|
+
return _context7.abrupt("return", _context7.t0);
|
|
9174
|
+
case 6:
|
|
9175
|
+
case "end":
|
|
9176
|
+
return _context7.stop();
|
|
9177
|
+
}
|
|
9178
|
+
}, _callee7);
|
|
9179
|
+
})));
|
|
9180
|
+
case 4:
|
|
9181
|
+
tmpUploadFolder = _context14.sent;
|
|
9182
|
+
folderToCleanUp = tmpUploadFolder;
|
|
9183
|
+
assets = (_options$sourcemaps2 = options.sourcemaps) === null || _options$sourcemaps2 === void 0 ? void 0 : _options$sourcemaps2.assets;
|
|
9184
|
+
if (assets) {
|
|
9185
|
+
globAssets = assets;
|
|
9186
|
+
} else {
|
|
9187
|
+
logger.debug("No `sourcemaps.assets` option provided, falling back to uploading detected build artifacts.");
|
|
9188
|
+
globAssets = buildArtifactPaths;
|
|
9189
|
+
}
|
|
9190
|
+
_context14.next = 10;
|
|
9191
|
+
return startSpan({
|
|
9192
|
+
name: "glob",
|
|
9193
|
+
scope: sentryScope
|
|
9194
|
+
}, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
9195
|
+
var _options$sourcemaps3;
|
|
9196
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
9197
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
9198
|
+
case 0:
|
|
9199
|
+
_context8.next = 2;
|
|
9200
|
+
return glob.glob(globAssets, {
|
|
9201
|
+
absolute: true,
|
|
9202
|
+
nodir: true,
|
|
9203
|
+
ignore: (_options$sourcemaps3 = options.sourcemaps) === null || _options$sourcemaps3 === void 0 ? void 0 : _options$sourcemaps3.ignore
|
|
9204
|
+
});
|
|
9205
|
+
case 2:
|
|
9206
|
+
return _context8.abrupt("return", _context8.sent);
|
|
9207
|
+
case 3:
|
|
9208
|
+
case "end":
|
|
9209
|
+
return _context8.stop();
|
|
9210
|
+
}
|
|
9211
|
+
}, _callee8);
|
|
9212
|
+
})));
|
|
9213
|
+
case 10:
|
|
9214
|
+
globResult = _context14.sent;
|
|
9215
|
+
debugIdChunkFilePaths = globResult.filter(function (debugIdChunkFilePath) {
|
|
9216
|
+
return !!stripQueryAndHashFromPath(debugIdChunkFilePath).match(/\.(js|mjs|cjs)$/);
|
|
9217
|
+
}); // The order of the files output by glob() is not deterministic
|
|
9218
|
+
// Ensure order within the files so that {debug-id}-{chunkIndex} coupling is consistent
|
|
9219
|
+
debugIdChunkFilePaths.sort();
|
|
9220
|
+
if (!(Array.isArray(assets) && assets.length === 0)) {
|
|
9221
|
+
_context14.next = 17;
|
|
9222
|
+
break;
|
|
9223
|
+
}
|
|
9224
|
+
logger.debug("Empty `sourcemaps.assets` option provided. Will not upload sourcemaps with debug ID.");
|
|
9225
|
+
_context14.next = 24;
|
|
9226
|
+
break;
|
|
9227
|
+
case 17:
|
|
9228
|
+
if (!(debugIdChunkFilePaths.length === 0)) {
|
|
9229
|
+
_context14.next = 21;
|
|
9230
|
+
break;
|
|
9231
|
+
}
|
|
9232
|
+
logger.warn("Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option.");
|
|
9233
|
+
_context14.next = 24;
|
|
9234
|
+
break;
|
|
9235
|
+
case 21:
|
|
9236
|
+
_context14.next = 23;
|
|
9237
|
+
return startSpan({
|
|
9238
|
+
name: "prepare-bundles",
|
|
9239
|
+
scope: sentryScope
|
|
9240
|
+
}, /*#__PURE__*/function () {
|
|
9241
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(prepBundlesSpan) {
|
|
9242
|
+
var preparationTasks, workers, worker, workerIndex, files, stats, uploadSize;
|
|
9243
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
9244
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
9245
|
+
case 0:
|
|
9246
|
+
// Preparing the bundles can be a lot of work and doing it all at once has the potential of nuking the heap so
|
|
9247
|
+
// instead we do it with a maximum of 16 concurrent workers
|
|
9248
|
+
preparationTasks = debugIdChunkFilePaths.map(function (chunkFilePath, chunkIndex) {
|
|
9249
|
+
return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
9250
|
+
var _options$sourcemaps$r, _options$sourcemaps4, _options$sourcemaps5;
|
|
9251
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
9252
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
9253
|
+
case 0:
|
|
9254
|
+
_context9.next = 2;
|
|
9255
|
+
return prepareBundleForDebugIdUpload(chunkFilePath, tmpUploadFolder, chunkIndex, logger, (_options$sourcemaps$r = (_options$sourcemaps4 = options.sourcemaps) === null || _options$sourcemaps4 === void 0 ? void 0 : _options$sourcemaps4.rewriteSources) !== null && _options$sourcemaps$r !== void 0 ? _options$sourcemaps$r : defaultRewriteSourcesHook, (_options$sourcemaps5 = options.sourcemaps) === null || _options$sourcemaps5 === void 0 ? void 0 : _options$sourcemaps5.resolveSourceMap);
|
|
9256
|
+
case 2:
|
|
9257
|
+
case "end":
|
|
9258
|
+
return _context9.stop();
|
|
9259
|
+
}
|
|
9260
|
+
}, _callee9);
|
|
9261
|
+
}));
|
|
9262
|
+
});
|
|
9263
|
+
workers = [];
|
|
9264
|
+
worker = /*#__PURE__*/function () {
|
|
9265
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
9266
|
+
var task;
|
|
9267
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
9268
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
9269
|
+
case 0:
|
|
9270
|
+
if (!(preparationTasks.length > 0)) {
|
|
9271
|
+
_context10.next = 7;
|
|
9272
|
+
break;
|
|
9273
|
+
}
|
|
9274
|
+
task = preparationTasks.shift();
|
|
9275
|
+
if (!task) {
|
|
9276
|
+
_context10.next = 5;
|
|
9277
|
+
break;
|
|
9278
|
+
}
|
|
9279
|
+
_context10.next = 5;
|
|
9280
|
+
return task();
|
|
9281
|
+
case 5:
|
|
9282
|
+
_context10.next = 0;
|
|
9283
|
+
break;
|
|
9284
|
+
case 7:
|
|
9285
|
+
case "end":
|
|
9286
|
+
return _context10.stop();
|
|
9287
|
+
}
|
|
9288
|
+
}, _callee10);
|
|
9289
|
+
}));
|
|
9290
|
+
return function worker() {
|
|
9291
|
+
return _ref6.apply(this, arguments);
|
|
9292
|
+
};
|
|
9293
|
+
}();
|
|
9294
|
+
for (workerIndex = 0; workerIndex < 16; workerIndex++) {
|
|
9295
|
+
workers.push(worker());
|
|
9296
|
+
}
|
|
9297
|
+
_context12.next = 6;
|
|
9298
|
+
return Promise.all(workers);
|
|
9299
|
+
case 6:
|
|
9300
|
+
_context12.next = 8;
|
|
9301
|
+
return fs__namespace.promises.readdir(tmpUploadFolder);
|
|
9302
|
+
case 8:
|
|
9303
|
+
files = _context12.sent;
|
|
9304
|
+
stats = files.map(function (file) {
|
|
9305
|
+
return fs__namespace.promises.stat(path__namespace.join(tmpUploadFolder, file));
|
|
9306
|
+
});
|
|
9307
|
+
_context12.next = 12;
|
|
9308
|
+
return Promise.all(stats);
|
|
9309
|
+
case 12:
|
|
9310
|
+
uploadSize = _context12.sent.reduce(function (accumulator, _ref7) {
|
|
9311
|
+
var size = _ref7.size;
|
|
9312
|
+
return accumulator + size;
|
|
9313
|
+
}, 0);
|
|
9314
|
+
setMeasurement("files", files.length, "none", prepBundlesSpan);
|
|
9315
|
+
setMeasurement("upload_size", uploadSize, "byte", prepBundlesSpan);
|
|
9316
|
+
_context12.next = 17;
|
|
9317
|
+
return startSpan({
|
|
9318
|
+
name: "upload",
|
|
9319
|
+
scope: sentryScope
|
|
9320
|
+
}, /*#__PURE__*/function () {
|
|
9321
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(uploadSpan) {
|
|
9322
|
+
var _options$release$name;
|
|
9323
|
+
var cliInstance;
|
|
9324
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
9325
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
9326
|
+
case 0:
|
|
9327
|
+
cliInstance = new SentryCli__default["default"](null, {
|
|
9328
|
+
authToken: options.authToken,
|
|
9329
|
+
org: options.org,
|
|
9330
|
+
project: options.project,
|
|
9331
|
+
silent: options.silent,
|
|
9332
|
+
url: options.url,
|
|
9333
|
+
vcsRemote: options.release.vcsRemote,
|
|
9334
|
+
headers: _objectSpread2({
|
|
9335
|
+
"sentry-trace": spanToTraceHeader(uploadSpan),
|
|
9336
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
9337
|
+
baggage: dynamicSamplingContextToSentryBaggageHeader(getDynamicSamplingContextFromSpan(uploadSpan))
|
|
9338
|
+
}, options.headers)
|
|
9339
|
+
});
|
|
9340
|
+
_context11.next = 3;
|
|
9341
|
+
return cliInstance.releases.uploadSourceMaps((_options$release$name = options.release.name) !== null && _options$release$name !== void 0 ? _options$release$name : "undefined",
|
|
9342
|
+
// unfortunately this needs a value for now but it will not matter since debug IDs overpower releases anyhow
|
|
9343
|
+
{
|
|
9344
|
+
include: [{
|
|
9345
|
+
paths: [tmpUploadFolder],
|
|
9346
|
+
rewrite: false,
|
|
9347
|
+
dist: options.release.dist
|
|
9348
|
+
}]
|
|
9349
|
+
});
|
|
9350
|
+
case 3:
|
|
9351
|
+
case "end":
|
|
9352
|
+
return _context11.stop();
|
|
9353
|
+
}
|
|
9354
|
+
}, _callee11);
|
|
9355
|
+
}));
|
|
9356
|
+
return function (_x2) {
|
|
9357
|
+
return _ref8.apply(this, arguments);
|
|
9358
|
+
};
|
|
9359
|
+
}());
|
|
9360
|
+
case 17:
|
|
9361
|
+
case "end":
|
|
9362
|
+
return _context12.stop();
|
|
9363
|
+
}
|
|
9364
|
+
}, _callee12);
|
|
9365
|
+
}));
|
|
9366
|
+
return function (_x) {
|
|
9367
|
+
return _ref4.apply(this, arguments);
|
|
9368
|
+
};
|
|
9369
|
+
}());
|
|
9370
|
+
case 23:
|
|
9371
|
+
logger.info("Successfully uploaded source maps to Sentry");
|
|
9372
|
+
case 24:
|
|
9373
|
+
_context14.next = 30;
|
|
9374
|
+
break;
|
|
9375
|
+
case 26:
|
|
9376
|
+
_context14.prev = 26;
|
|
9377
|
+
_context14.t0 = _context14["catch"](1);
|
|
9378
|
+
sentryScope.captureException('Error in "debugIdUploadPlugin" writeBundle hook');
|
|
9379
|
+
handleRecoverableError(_context14.t0, false);
|
|
9380
|
+
case 30:
|
|
9381
|
+
_context14.prev = 30;
|
|
9382
|
+
if (folderToCleanUp && !((_process$env2 = process.env) !== null && _process$env2 !== void 0 && _process$env2["SENTRY_TEST_OVERRIDE_TEMP_DIR"])) {
|
|
9383
|
+
void startSpan({
|
|
9384
|
+
name: "cleanup",
|
|
9385
|
+
scope: sentryScope
|
|
9386
|
+
}, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
9387
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
9388
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
9389
|
+
case 0:
|
|
9390
|
+
if (!folderToCleanUp) {
|
|
9391
|
+
_context13.next = 3;
|
|
9392
|
+
break;
|
|
9393
|
+
}
|
|
9394
|
+
_context13.next = 3;
|
|
9395
|
+
return fs__namespace.promises.rm(folderToCleanUp, {
|
|
9396
|
+
recursive: true,
|
|
9397
|
+
force: true
|
|
9398
|
+
});
|
|
9399
|
+
case 3:
|
|
9400
|
+
case "end":
|
|
9401
|
+
return _context13.stop();
|
|
9402
|
+
}
|
|
9403
|
+
}, _callee13);
|
|
9404
|
+
})));
|
|
9405
|
+
}
|
|
9406
|
+
freeUploadDependencyOnBuildArtifacts();
|
|
9407
|
+
_context14.next = 35;
|
|
9408
|
+
return safeFlushTelemetry(sentryClient);
|
|
9409
|
+
case 35:
|
|
9410
|
+
return _context14.finish(30);
|
|
9411
|
+
case 36:
|
|
9412
|
+
case "end":
|
|
9413
|
+
return _context14.stop();
|
|
9414
|
+
}
|
|
9415
|
+
}, _callee14, null, [[1, 26, 30, 36]]);
|
|
9416
|
+
})));
|
|
9417
|
+
case 3:
|
|
8982
9418
|
case "end":
|
|
8983
|
-
return
|
|
9419
|
+
return _context15.stop();
|
|
8984
9420
|
}
|
|
8985
|
-
},
|
|
9421
|
+
}, _callee15);
|
|
8986
9422
|
}))();
|
|
8987
|
-
}
|
|
8988
|
-
};
|
|
8989
|
-
}
|
|
8990
|
-
|
|
8991
|
-
// Logging everything to stderr not to interfere with stdout
|
|
8992
|
-
function createLogger(options) {
|
|
8993
|
-
return {
|
|
8994
|
-
info: function info(message) {
|
|
8995
|
-
if (!options.silent) {
|
|
8996
|
-
var _console;
|
|
8997
|
-
for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
8998
|
-
params[_key - 1] = arguments[_key];
|
|
8999
|
-
}
|
|
9000
|
-
// eslint-disable-next-line no-console
|
|
9001
|
-
(_console = console).info.apply(_console, ["".concat(options.prefix, " Info: ").concat(message)].concat(params));
|
|
9002
|
-
}
|
|
9003
|
-
},
|
|
9004
|
-
warn: function warn(message) {
|
|
9005
|
-
if (!options.silent) {
|
|
9006
|
-
var _console2;
|
|
9007
|
-
for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
9008
|
-
params[_key2 - 1] = arguments[_key2];
|
|
9009
|
-
}
|
|
9010
|
-
// eslint-disable-next-line no-console
|
|
9011
|
-
(_console2 = console).warn.apply(_console2, ["".concat(options.prefix, " Warning: ").concat(message)].concat(params));
|
|
9012
|
-
}
|
|
9013
|
-
},
|
|
9014
|
-
error: function error(message) {
|
|
9015
|
-
if (!options.silent) {
|
|
9016
|
-
var _console3;
|
|
9017
|
-
for (var _len3 = arguments.length, params = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
9018
|
-
params[_key3 - 1] = arguments[_key3];
|
|
9019
|
-
}
|
|
9020
|
-
// eslint-disable-next-line no-console
|
|
9021
|
-
(_console3 = console).error.apply(_console3, ["".concat(options.prefix, " Error: ").concat(message)].concat(params));
|
|
9022
|
-
}
|
|
9023
9423
|
},
|
|
9024
|
-
|
|
9025
|
-
|
|
9026
|
-
|
|
9027
|
-
|
|
9028
|
-
|
|
9029
|
-
|
|
9030
|
-
|
|
9031
|
-
|
|
9032
|
-
}
|
|
9033
|
-
}
|
|
9034
|
-
};
|
|
9035
|
-
}
|
|
9036
|
-
|
|
9037
|
-
function fileDeletionPlugin(_ref) {
|
|
9038
|
-
var handleRecoverableError = _ref.handleRecoverableError,
|
|
9039
|
-
sentryScope = _ref.sentryScope,
|
|
9040
|
-
sentryClient = _ref.sentryClient,
|
|
9041
|
-
filesToDeleteAfterUpload = _ref.filesToDeleteAfterUpload,
|
|
9042
|
-
waitUntilSourcemapFileDependenciesAreFreed = _ref.waitUntilSourcemapFileDependenciesAreFreed,
|
|
9043
|
-
logger = _ref.logger;
|
|
9044
|
-
return {
|
|
9045
|
-
name: "sentry-file-deletion-plugin",
|
|
9046
|
-
writeBundle: function writeBundle() {
|
|
9047
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
9048
|
-
var filesToDelete, filePathsToDelete;
|
|
9049
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
9050
|
-
while (1) switch (_context.prev = _context.next) {
|
|
9424
|
+
/**
|
|
9425
|
+
* Will delete artifacts based on the passed `sourcemaps.filesToDeleteAfterUpload` option.
|
|
9426
|
+
*/
|
|
9427
|
+
deleteArtifacts: function deleteArtifacts() {
|
|
9428
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
9429
|
+
var _options$sourcemaps6, filesToDelete, filePathsToDelete;
|
|
9430
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
9431
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
9051
9432
|
case 0:
|
|
9052
|
-
|
|
9053
|
-
|
|
9054
|
-
return filesToDeleteAfterUpload;
|
|
9433
|
+
_context16.prev = 0;
|
|
9434
|
+
_context16.next = 3;
|
|
9435
|
+
return (_options$sourcemaps6 = options.sourcemaps) === null || _options$sourcemaps6 === void 0 ? void 0 : _options$sourcemaps6.filesToDeleteAfterUpload;
|
|
9055
9436
|
case 3:
|
|
9056
|
-
filesToDelete =
|
|
9437
|
+
filesToDelete = _context16.sent;
|
|
9057
9438
|
if (!(filesToDelete !== undefined)) {
|
|
9058
|
-
|
|
9439
|
+
_context16.next = 14;
|
|
9059
9440
|
break;
|
|
9060
9441
|
}
|
|
9061
|
-
|
|
9442
|
+
_context16.next = 7;
|
|
9062
9443
|
return glob.glob(filesToDelete, {
|
|
9063
9444
|
absolute: true,
|
|
9064
9445
|
nodir: true
|
|
9065
9446
|
});
|
|
9066
9447
|
case 7:
|
|
9067
|
-
filePathsToDelete =
|
|
9448
|
+
filePathsToDelete = _context16.sent;
|
|
9068
9449
|
logger.debug("Waiting for dependencies on generated files to be freed before deleting...");
|
|
9069
|
-
|
|
9070
|
-
return
|
|
9450
|
+
_context16.next = 11;
|
|
9451
|
+
return waitUntilBuildArtifactDependenciesAreFreed();
|
|
9071
9452
|
case 11:
|
|
9072
9453
|
filePathsToDelete.forEach(function (filePathToDelete) {
|
|
9073
9454
|
logger.debug("Deleting asset after upload: ".concat(filePathToDelete));
|
|
9074
9455
|
});
|
|
9075
|
-
|
|
9456
|
+
_context16.next = 14;
|
|
9076
9457
|
return Promise.all(filePathsToDelete.map(function (filePathToDelete) {
|
|
9077
|
-
return
|
|
9458
|
+
return fs__namespace.promises.rm(filePathToDelete, {
|
|
9078
9459
|
force: true
|
|
9079
9460
|
})["catch"](function (e) {
|
|
9080
9461
|
// This is allowed to fail - we just don't do anything
|
|
@@ -9082,53 +9463,31 @@ function fileDeletionPlugin(_ref) {
|
|
|
9082
9463
|
});
|
|
9083
9464
|
}));
|
|
9084
9465
|
case 14:
|
|
9085
|
-
|
|
9466
|
+
_context16.next = 22;
|
|
9086
9467
|
break;
|
|
9087
9468
|
case 16:
|
|
9088
|
-
|
|
9089
|
-
|
|
9469
|
+
_context16.prev = 16;
|
|
9470
|
+
_context16.t0 = _context16["catch"](0);
|
|
9090
9471
|
sentryScope.captureException('Error in "sentry-file-deletion-plugin" buildEnd hook');
|
|
9091
|
-
|
|
9472
|
+
_context16.next = 21;
|
|
9092
9473
|
return safeFlushTelemetry(sentryClient);
|
|
9093
9474
|
case 21:
|
|
9094
9475
|
// We throw by default if we get here b/c not being able to delete
|
|
9095
9476
|
// source maps could leak them to production
|
|
9096
|
-
handleRecoverableError(
|
|
9477
|
+
handleRecoverableError(_context16.t0, true);
|
|
9097
9478
|
case 22:
|
|
9098
9479
|
case "end":
|
|
9099
|
-
return
|
|
9480
|
+
return _context16.stop();
|
|
9100
9481
|
}
|
|
9101
|
-
},
|
|
9482
|
+
}, _callee16, null, [[0, 16]]);
|
|
9102
9483
|
}))();
|
|
9103
|
-
}
|
|
9484
|
+
},
|
|
9485
|
+
createDependencyOnBuildArtifacts: createDependencyOnBuildArtifacts
|
|
9104
9486
|
};
|
|
9105
9487
|
}
|
|
9106
9488
|
|
|
9107
9489
|
/**
|
|
9108
|
-
*
|
|
9109
|
-
* - Release injection
|
|
9110
|
-
* - Sourcemaps upload
|
|
9111
|
-
*
|
|
9112
|
-
* Release injection:
|
|
9113
|
-
* Per default the sentry bundler plugin will inject a global `SENTRY_RELEASE` into each JavaScript/TypeScript module
|
|
9114
|
-
* that is part of the bundle. On a technical level this is done by appending an import (`import "sentry-release-injector";`)
|
|
9115
|
-
* to all entrypoint files of the user code (see `transformInclude` and `transform` hooks). This import is then resolved
|
|
9116
|
-
* by the sentry plugin to a virtual module that sets the global variable (see `resolveId` and `load` hooks).
|
|
9117
|
-
* If a user wants to inject the release into a particular set of modules they can use the `releaseInjectionTargets` option.
|
|
9118
|
-
*
|
|
9119
|
-
* Source maps upload:
|
|
9120
|
-
*
|
|
9121
|
-
* The sentry bundler plugin will also take care of uploading source maps to Sentry. This
|
|
9122
|
-
* is all done in the `writeBundle` hook. In this hook the sentry plugin will execute the
|
|
9123
|
-
* release creation pipeline:
|
|
9124
|
-
*
|
|
9125
|
-
* 1. Create a new release
|
|
9126
|
-
* 2. Upload sourcemaps based on `include` and source-map-specific options
|
|
9127
|
-
* 3. Associate a range of commits with the release (if `setCommits` is specified)
|
|
9128
|
-
* 4. Finalize the release (unless `finalize` is disabled)
|
|
9129
|
-
* 5. Add deploy information to the release (if `deploy` is specified)
|
|
9130
|
-
*
|
|
9131
|
-
* This release creation pipeline relies on Sentry CLI to execute the different steps.
|
|
9490
|
+
* Creates an unplugin instance used to create Sentry plugins for Vite, Rollup, esbuild, and Webpack.
|
|
9132
9491
|
*/
|
|
9133
9492
|
function sentryUnpluginFactory(_ref) {
|
|
9134
9493
|
var releaseInjectionPlugin = _ref.releaseInjectionPlugin,
|
|
@@ -9138,189 +9497,46 @@ function sentryUnpluginFactory(_ref) {
|
|
|
9138
9497
|
debugIdUploadPlugin = _ref.debugIdUploadPlugin,
|
|
9139
9498
|
bundleSizeOptimizationsPlugin = _ref.bundleSizeOptimizationsPlugin;
|
|
9140
9499
|
return unplugin.createUnplugin(function () {
|
|
9141
|
-
var _userOptions$_metaOpt, _userOptions$_metaOpt2,
|
|
9500
|
+
var _userOptions$_metaOpt, _userOptions$_metaOpt2, _options$sourcemaps;
|
|
9142
9501
|
var userOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
9143
9502
|
var unpluginMetaContext = arguments.length > 1 ? arguments[1] : undefined;
|
|
9144
|
-
var
|
|
9145
|
-
|
|
9146
|
-
|
|
9147
|
-
debug: (_userOptions$debug = userOptions.debug) !== null && _userOptions$debug !== void 0 ? _userOptions$debug : false
|
|
9503
|
+
var sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {
|
|
9504
|
+
loggerPrefix: (_userOptions$_metaOpt = (_userOptions$_metaOpt2 = userOptions._metaOptions) === null || _userOptions$_metaOpt2 === void 0 ? void 0 : _userOptions$_metaOpt2.loggerPrefixOverride) !== null && _userOptions$_metaOpt !== void 0 ? _userOptions$_metaOpt : "[sentry-".concat(unpluginMetaContext.framework, "-plugin]"),
|
|
9505
|
+
buildTool: unpluginMetaContext.framework
|
|
9148
9506
|
});
|
|
9149
|
-
|
|
9150
|
-
|
|
9151
|
-
|
|
9152
|
-
// here is to avoid a false positive. False negatives are okay.
|
|
9153
|
-
var isDevMode = process.env["NODE_ENV"] === "development";
|
|
9154
|
-
try {
|
|
9155
|
-
var dotenvFile = fs__namespace.readFileSync(path__namespace.join(process.cwd(), ".env.sentry-build-plugin"), "utf-8");
|
|
9156
|
-
// NOTE: Do not use the dotenv.config API directly to read the dotenv file! For some ungodly reason, it falls back to reading `${process.cwd()}/.env` which is absolutely not what we want.
|
|
9157
|
-
var dotenvResult = dotenv__namespace.parse(dotenvFile);
|
|
9158
|
-
|
|
9159
|
-
// Vite has a bug/behaviour where spreading into process.env will cause it to crash
|
|
9160
|
-
// https://github.com/vitest-dev/vitest/issues/1870#issuecomment-1501140251
|
|
9161
|
-
Object.assign(process.env, dotenvResult);
|
|
9162
|
-
logger.info('Using environment variables configured in ".env.sentry-build-plugin".');
|
|
9163
|
-
} catch (e) {
|
|
9164
|
-
// Ignore "file not found" errors but throw all others
|
|
9165
|
-
if (_typeof(e) === "object" && e && "code" in e && e.code !== "ENOENT") {
|
|
9166
|
-
throw e;
|
|
9167
|
-
}
|
|
9168
|
-
}
|
|
9169
|
-
var options = normalizeUserOptions(userOptions);
|
|
9507
|
+
var logger = sentryBuildPluginManager.logger,
|
|
9508
|
+
options = sentryBuildPluginManager.normalizedOptions,
|
|
9509
|
+
bundleSizeOptimizationReplacementValues = sentryBuildPluginManager.bundleSizeOptimizationReplacementValues;
|
|
9170
9510
|
if (options.disable) {
|
|
9171
9511
|
return [{
|
|
9172
9512
|
name: "sentry-noop-plugin"
|
|
9173
9513
|
}];
|
|
9174
9514
|
}
|
|
9175
|
-
var shouldSendTelemetry = allowedToSendTelemetry(options);
|
|
9176
|
-
var _createSentryInstance = createSentryInstance(options, shouldSendTelemetry, unpluginMetaContext.framework),
|
|
9177
|
-
sentryScope = _createSentryInstance.sentryScope,
|
|
9178
|
-
sentryClient = _createSentryInstance.sentryClient;
|
|
9179
|
-
var _sentryClient$getOpti = sentryClient.getOptions(),
|
|
9180
|
-
release = _sentryClient$getOpti.release,
|
|
9181
|
-
_sentryClient$getOpti2 = _sentryClient$getOpti.environment,
|
|
9182
|
-
environment = _sentryClient$getOpti2 === void 0 ? DEFAULT_ENVIRONMENT : _sentryClient$getOpti2;
|
|
9183
|
-
var sentrySession = makeSession({
|
|
9184
|
-
release: release,
|
|
9185
|
-
environment: environment
|
|
9186
|
-
});
|
|
9187
|
-
sentryScope.setSession(sentrySession);
|
|
9188
|
-
// Send the start of the session
|
|
9189
|
-
sentryClient.captureSession(sentrySession);
|
|
9190
|
-
var sessionHasEnded = false; // Just to prevent infinite loops with beforeExit, which is called whenever the event loop empties out
|
|
9191
|
-
|
|
9192
|
-
function endSession() {
|
|
9193
|
-
if (sessionHasEnded) {
|
|
9194
|
-
return;
|
|
9195
|
-
}
|
|
9196
|
-
closeSession(sentrySession);
|
|
9197
|
-
sentryClient.captureSession(sentrySession);
|
|
9198
|
-
sessionHasEnded = true;
|
|
9199
|
-
}
|
|
9200
|
-
|
|
9201
|
-
// We also need to manually end sessions on errors because beforeExit is not called on crashes
|
|
9202
|
-
process.on("beforeExit", function () {
|
|
9203
|
-
endSession();
|
|
9204
|
-
});
|
|
9205
|
-
|
|
9206
|
-
// Set the User-Agent that Sentry CLI will use when interacting with Sentry
|
|
9207
|
-
process.env["SENTRY_PIPELINE"] = "".concat(unpluginMetaContext.framework, "-plugin/", "3.3.1");
|
|
9208
|
-
|
|
9209
|
-
/**
|
|
9210
|
-
* Handles errors caught and emitted in various areas of the plugin.
|
|
9211
|
-
*
|
|
9212
|
-
* Also sets the sentry session status according to the error handling.
|
|
9213
|
-
*
|
|
9214
|
-
* If users specify their custom `errorHandler` we'll leave the decision to throw
|
|
9215
|
-
* or continue up to them. By default, @param throwByDefault controls if the plugin
|
|
9216
|
-
* should throw an error (which causes a build fail in most bundlers) or continue.
|
|
9217
|
-
*/
|
|
9218
|
-
function handleRecoverableError(unknownError, throwByDefault) {
|
|
9219
|
-
sentrySession.status = "abnormal";
|
|
9220
|
-
try {
|
|
9221
|
-
if (options.errorHandler) {
|
|
9222
|
-
try {
|
|
9223
|
-
if (unknownError instanceof Error) {
|
|
9224
|
-
options.errorHandler(unknownError);
|
|
9225
|
-
} else {
|
|
9226
|
-
options.errorHandler(new Error("An unknown error occured"));
|
|
9227
|
-
}
|
|
9228
|
-
} catch (e) {
|
|
9229
|
-
sentrySession.status = "crashed";
|
|
9230
|
-
throw e;
|
|
9231
|
-
}
|
|
9232
|
-
} else {
|
|
9233
|
-
// setting the session to "crashed" b/c from a plugin perspective this run failed.
|
|
9234
|
-
// However, we're intentionally not rethrowing the error to avoid breaking the user build.
|
|
9235
|
-
sentrySession.status = "crashed";
|
|
9236
|
-
if (throwByDefault) {
|
|
9237
|
-
throw unknownError;
|
|
9238
|
-
}
|
|
9239
|
-
logger.error("An error occurred. Couldn't finish all operations:", unknownError);
|
|
9240
|
-
}
|
|
9241
|
-
} finally {
|
|
9242
|
-
endSession();
|
|
9243
|
-
}
|
|
9244
|
-
}
|
|
9245
|
-
if (!validateOptions(options, logger)) {
|
|
9246
|
-
// Throwing by default to avoid a misconfigured plugin going unnoticed.
|
|
9247
|
-
handleRecoverableError(new Error("Options were not set correctly. See output above for more details."), true);
|
|
9248
|
-
}
|
|
9249
9515
|
if (process.cwd().match(/\\node_modules\\|\/node_modules\//)) {
|
|
9250
9516
|
logger.warn("Running Sentry plugin from within a `node_modules` folder. Some features may not work.");
|
|
9251
9517
|
}
|
|
9252
9518
|
var plugins = [];
|
|
9253
|
-
plugins.push(telemetryPlugin({
|
|
9254
|
-
sentryClient: sentryClient,
|
|
9255
|
-
sentryScope: sentryScope,
|
|
9256
|
-
logger: logger,
|
|
9257
|
-
shouldSendTelemetry: shouldSendTelemetry
|
|
9258
|
-
}));
|
|
9259
|
-
|
|
9260
|
-
// We have multiple plugins depending on generated source map files. (debug ID upload, legacy upload)
|
|
9261
|
-
// Additionally, we also want to have the functionality to delete files after uploading sourcemaps.
|
|
9262
|
-
// All of these plugins and the delete functionality need to run in the same hook (`writeBundle`).
|
|
9263
|
-
// Since the plugins among themselves are not aware of when they run and finish, we need a system to
|
|
9264
|
-
// track their dependencies on the generated files, so that we can initiate the file deletion only after
|
|
9265
|
-
// nothing depends on the files anymore.
|
|
9266
|
-
var dependenciesOnSourcemapFiles = new Set();
|
|
9267
|
-
var sourcemapFileDependencySubscribers = [];
|
|
9268
|
-
function notifySourcemapFileDependencySubscribers() {
|
|
9269
|
-
sourcemapFileDependencySubscribers.forEach(function (subscriber) {
|
|
9270
|
-
subscriber();
|
|
9271
|
-
});
|
|
9272
|
-
}
|
|
9273
|
-
function createDependencyOnSourcemapFiles() {
|
|
9274
|
-
var dependencyIdentifier = Symbol();
|
|
9275
|
-
dependenciesOnSourcemapFiles.add(dependencyIdentifier);
|
|
9276
|
-
return function freeDependencyOnSourcemapFiles() {
|
|
9277
|
-
dependenciesOnSourcemapFiles["delete"](dependencyIdentifier);
|
|
9278
|
-
notifySourcemapFileDependencySubscribers();
|
|
9279
|
-
};
|
|
9280
|
-
}
|
|
9281
9519
|
|
|
9282
|
-
|
|
9283
|
-
|
|
9284
|
-
|
|
9285
|
-
|
|
9286
|
-
|
|
9287
|
-
|
|
9288
|
-
|
|
9289
|
-
|
|
9290
|
-
|
|
9291
|
-
|
|
9292
|
-
|
|
9293
|
-
|
|
9294
|
-
|
|
9295
|
-
|
|
9296
|
-
|
|
9297
|
-
}
|
|
9298
|
-
});
|
|
9299
|
-
}
|
|
9300
|
-
if (options.bundleSizeOptimizations) {
|
|
9301
|
-
var bundleSizeOptimizations = options.bundleSizeOptimizations;
|
|
9302
|
-
var replacementValues = {};
|
|
9303
|
-
if (bundleSizeOptimizations.excludeDebugStatements) {
|
|
9304
|
-
replacementValues["__SENTRY_DEBUG__"] = false;
|
|
9305
|
-
}
|
|
9306
|
-
if (bundleSizeOptimizations.excludeTracing) {
|
|
9307
|
-
replacementValues["__SENTRY_TRACING__"] = false;
|
|
9308
|
-
}
|
|
9309
|
-
if (bundleSizeOptimizations.excludeReplayCanvas) {
|
|
9310
|
-
replacementValues["__RRWEB_EXCLUDE_CANVAS__"] = true;
|
|
9311
|
-
}
|
|
9312
|
-
if (bundleSizeOptimizations.excludeReplayIframe) {
|
|
9313
|
-
replacementValues["__RRWEB_EXCLUDE_IFRAME__"] = true;
|
|
9314
|
-
}
|
|
9315
|
-
if (bundleSizeOptimizations.excludeReplayShadowDom) {
|
|
9316
|
-
replacementValues["__RRWEB_EXCLUDE_SHADOW_DOM__"] = true;
|
|
9317
|
-
}
|
|
9318
|
-
if (bundleSizeOptimizations.excludeReplayWorker) {
|
|
9319
|
-
replacementValues["__SENTRY_EXCLUDE_REPLAY_WORKER__"] = true;
|
|
9320
|
-
}
|
|
9321
|
-
if (Object.keys(replacementValues).length > 0) {
|
|
9322
|
-
plugins.push(bundleSizeOptimizationsPlugin(replacementValues));
|
|
9520
|
+
// Add plugin to emit a telemetry signal when the build starts
|
|
9521
|
+
plugins.push({
|
|
9522
|
+
name: "sentry-telemetry-plugin",
|
|
9523
|
+
buildStart: function buildStart() {
|
|
9524
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
9525
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
9526
|
+
while (1) switch (_context.prev = _context.next) {
|
|
9527
|
+
case 0:
|
|
9528
|
+
_context.next = 2;
|
|
9529
|
+
return sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal();
|
|
9530
|
+
case 2:
|
|
9531
|
+
case "end":
|
|
9532
|
+
return _context.stop();
|
|
9533
|
+
}
|
|
9534
|
+
}, _callee);
|
|
9535
|
+
}))();
|
|
9323
9536
|
}
|
|
9537
|
+
});
|
|
9538
|
+
if (Object.keys(bundleSizeOptimizationReplacementValues).length > 0) {
|
|
9539
|
+
plugins.push(bundleSizeOptimizationsPlugin(bundleSizeOptimizationReplacementValues));
|
|
9324
9540
|
}
|
|
9325
9541
|
if (!options.release.inject) {
|
|
9326
9542
|
logger.debug("Release injection disabled via `release.inject` option. Will not inject release.");
|
|
@@ -9333,113 +9549,44 @@ function sentryUnpluginFactory(_ref) {
|
|
|
9333
9549
|
});
|
|
9334
9550
|
plugins.push(releaseInjectionPlugin(_injectionCode));
|
|
9335
9551
|
}
|
|
9336
|
-
if (
|
|
9337
|
-
var
|
|
9338
|
-
if (options.applicationKey) {
|
|
9339
|
-
// We use different keys so that if user-code receives multiple bundling passes, we will store the application keys of all the passes.
|
|
9340
|
-
// It is a bit unfortunate that we have to inject the metadata snippet at the top, because after multiple
|
|
9341
|
-
// injections, the first injection will always "win" because it comes last in the code. We would generally be
|
|
9342
|
-
// fine with making the last bundling pass win. But because it cannot win, we have to use a workaround of storing
|
|
9343
|
-
// the app keys in different object keys.
|
|
9344
|
-
// We can simply use the `_sentryBundlerPluginAppKey:` to filter for app keys in the SDK.
|
|
9345
|
-
metadata["_sentryBundlerPluginAppKey:".concat(options.applicationKey)] = true;
|
|
9346
|
-
}
|
|
9347
|
-
if (typeof options.moduleMetadata === "function") {
|
|
9348
|
-
var args = {
|
|
9349
|
-
org: options.org,
|
|
9350
|
-
project: options.project,
|
|
9351
|
-
release: options.release.name
|
|
9352
|
-
};
|
|
9353
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
9354
|
-
metadata = _objectSpread2(_objectSpread2({}, metadata), options.moduleMetadata(args));
|
|
9355
|
-
} else {
|
|
9356
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
9357
|
-
metadata = _objectSpread2(_objectSpread2({}, metadata), options.moduleMetadata);
|
|
9358
|
-
}
|
|
9359
|
-
var _injectionCode2 = generateModuleMetadataInjectorCode(metadata);
|
|
9552
|
+
if (Object.keys(sentryBuildPluginManager.bundleMetadata).length > 0) {
|
|
9553
|
+
var _injectionCode2 = generateModuleMetadataInjectorCode(sentryBuildPluginManager.bundleMetadata);
|
|
9360
9554
|
plugins.push(moduleMetadataInjectionPlugin(_injectionCode2));
|
|
9361
9555
|
}
|
|
9362
|
-
|
|
9363
|
-
|
|
9364
|
-
var
|
|
9365
|
-
|
|
9366
|
-
|
|
9367
|
-
|
|
9368
|
-
|
|
9369
|
-
|
|
9370
|
-
|
|
9371
|
-
|
|
9372
|
-
|
|
9373
|
-
|
|
9374
|
-
|
|
9375
|
-
|
|
9376
|
-
|
|
9377
|
-
|
|
9378
|
-
|
|
9379
|
-
|
|
9380
|
-
|
|
9381
|
-
|
|
9382
|
-
|
|
9383
|
-
|
|
9384
|
-
|
|
9385
|
-
|
|
9386
|
-
|
|
9387
|
-
deployOptions: options.release.deploy,
|
|
9388
|
-
dist: options.release.dist,
|
|
9389
|
-
handleRecoverableError: handleRecoverableError,
|
|
9390
|
-
sentryScope: sentryScope,
|
|
9391
|
-
sentryClient: sentryClient,
|
|
9392
|
-
sentryCliOptions: {
|
|
9393
|
-
authToken: options.authToken,
|
|
9394
|
-
org: options.org,
|
|
9395
|
-
project: options.project,
|
|
9396
|
-
silent: options.silent,
|
|
9397
|
-
url: options.url,
|
|
9398
|
-
vcsRemote: options.release.vcsRemote,
|
|
9399
|
-
headers: options.headers
|
|
9400
|
-
},
|
|
9401
|
-
createDependencyOnSourcemapFiles: createDependencyOnSourcemapFiles
|
|
9402
|
-
}));
|
|
9403
|
-
}
|
|
9556
|
+
|
|
9557
|
+
// Add plugin to create and finalize releases, and also take care of adding commits and legacy sourcemaps
|
|
9558
|
+
var freeGlobalDependencyOnBuildArtifacts = sentryBuildPluginManager.createDependencyOnBuildArtifacts();
|
|
9559
|
+
plugins.push({
|
|
9560
|
+
name: "sentry-release-management-plugin",
|
|
9561
|
+
writeBundle: function writeBundle() {
|
|
9562
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
9563
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
9564
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
9565
|
+
case 0:
|
|
9566
|
+
_context2.prev = 0;
|
|
9567
|
+
_context2.next = 3;
|
|
9568
|
+
return sentryBuildPluginManager.createRelease();
|
|
9569
|
+
case 3:
|
|
9570
|
+
_context2.prev = 3;
|
|
9571
|
+
freeGlobalDependencyOnBuildArtifacts();
|
|
9572
|
+
return _context2.finish(3);
|
|
9573
|
+
case 6:
|
|
9574
|
+
case "end":
|
|
9575
|
+
return _context2.stop();
|
|
9576
|
+
}
|
|
9577
|
+
}, _callee2, null, [[0,, 3, 6]]);
|
|
9578
|
+
}))();
|
|
9579
|
+
}
|
|
9580
|
+
});
|
|
9404
9581
|
if (!((_options$sourcemaps = options.sourcemaps) !== null && _options$sourcemaps !== void 0 && _options$sourcemaps.disable)) {
|
|
9405
9582
|
plugins.push(debugIdInjectionPlugin(logger));
|
|
9406
9583
|
}
|
|
9407
|
-
|
|
9408
|
-
|
|
9409
|
-
|
|
9410
|
-
|
|
9411
|
-
|
|
9412
|
-
|
|
9413
|
-
} else if (!options.org && !options.authToken.startsWith("sntrys_")) {
|
|
9414
|
-
logger.warn("No org provided. Will not upload source maps. Please set the `org` option to your Sentry organization slug." + getTurborepoEnvPassthroughWarning("SENTRY_ORG"));
|
|
9415
|
-
} else if (!options.project) {
|
|
9416
|
-
logger.warn("No project provided. Will not upload source maps. Please set the `project` option to your Sentry project slug." + getTurborepoEnvPassthroughWarning("SENTRY_PROJECT"));
|
|
9417
|
-
} else {
|
|
9418
|
-
var _options$sourcemaps3, _options$sourcemaps4, _options$sourcemaps5;
|
|
9419
|
-
// This option is only strongly typed for the webpack plugin, where it is used. It has no effect on other plugins
|
|
9420
|
-
var _webpack_forceExitOnBuildComplete = typeof options._experiments["forceExitOnBuildCompletion"] === "boolean" ? options._experiments["forceExitOnBuildCompletion"] : undefined;
|
|
9421
|
-
plugins.push(debugIdUploadPlugin(createDebugIdUploadFunction({
|
|
9422
|
-
assets: (_options$sourcemaps3 = options.sourcemaps) === null || _options$sourcemaps3 === void 0 ? void 0 : _options$sourcemaps3.assets,
|
|
9423
|
-
ignore: (_options$sourcemaps4 = options.sourcemaps) === null || _options$sourcemaps4 === void 0 ? void 0 : _options$sourcemaps4.ignore,
|
|
9424
|
-
createDependencyOnSourcemapFiles: createDependencyOnSourcemapFiles,
|
|
9425
|
-
dist: options.release.dist,
|
|
9426
|
-
releaseName: options.release.name,
|
|
9427
|
-
logger: logger,
|
|
9428
|
-
handleRecoverableError: handleRecoverableError,
|
|
9429
|
-
rewriteSourcesHook: (_options$sourcemaps5 = options.sourcemaps) === null || _options$sourcemaps5 === void 0 ? void 0 : _options$sourcemaps5.rewriteSources,
|
|
9430
|
-
sentryScope: sentryScope,
|
|
9431
|
-
sentryClient: sentryClient,
|
|
9432
|
-
sentryCliOptions: {
|
|
9433
|
-
authToken: options.authToken,
|
|
9434
|
-
org: options.org,
|
|
9435
|
-
project: options.project,
|
|
9436
|
-
silent: options.silent,
|
|
9437
|
-
url: options.url,
|
|
9438
|
-
vcsRemote: options.release.vcsRemote,
|
|
9439
|
-
headers: options.headers
|
|
9440
|
-
}
|
|
9441
|
-
}), logger, _webpack_forceExitOnBuildComplete));
|
|
9442
|
-
}
|
|
9584
|
+
|
|
9585
|
+
// This option is only strongly typed for the webpack plugin, where it is used. It has no effect on other plugins
|
|
9586
|
+
var webpack_forceExitOnBuildComplete = typeof options._experiments["forceExitOnBuildCompletion"] === "boolean" ? options._experiments["forceExitOnBuildCompletion"] : undefined;
|
|
9587
|
+
plugins.push(debugIdUploadPlugin(createDebugIdUploadFunction({
|
|
9588
|
+
sentryBuildPluginManager: sentryBuildPluginManager
|
|
9589
|
+
}), logger, sentryBuildPluginManager.createDependencyOnBuildArtifacts, webpack_forceExitOnBuildComplete));
|
|
9443
9590
|
if (options.reactComponentAnnotation) {
|
|
9444
9591
|
if (!options.reactComponentAnnotation.enabled) {
|
|
9445
9592
|
logger.debug("The component name annotate plugin is currently disabled. Skipping component name annotations.");
|
|
@@ -9449,17 +9596,33 @@ function sentryUnpluginFactory(_ref) {
|
|
|
9449
9596
|
componentNameAnnotatePlugin && plugins.push(componentNameAnnotatePlugin(options.reactComponentAnnotation.ignoredComponents));
|
|
9450
9597
|
}
|
|
9451
9598
|
}
|
|
9452
|
-
|
|
9453
|
-
|
|
9454
|
-
|
|
9455
|
-
|
|
9456
|
-
|
|
9457
|
-
|
|
9458
|
-
|
|
9459
|
-
|
|
9599
|
+
|
|
9600
|
+
// Add plugin to delete unwanted artifacts like source maps after the uploads have completed
|
|
9601
|
+
plugins.push({
|
|
9602
|
+
name: "sentry-file-deletion-plugin",
|
|
9603
|
+
writeBundle: function writeBundle() {
|
|
9604
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
9605
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
9606
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
9607
|
+
case 0:
|
|
9608
|
+
_context3.next = 2;
|
|
9609
|
+
return sentryBuildPluginManager.deleteArtifacts();
|
|
9610
|
+
case 2:
|
|
9611
|
+
case "end":
|
|
9612
|
+
return _context3.stop();
|
|
9613
|
+
}
|
|
9614
|
+
}, _callee3);
|
|
9615
|
+
}))();
|
|
9616
|
+
}
|
|
9617
|
+
});
|
|
9460
9618
|
return plugins;
|
|
9461
9619
|
});
|
|
9462
9620
|
}
|
|
9621
|
+
|
|
9622
|
+
/**
|
|
9623
|
+
* @deprecated
|
|
9624
|
+
*/
|
|
9625
|
+
// TODO(v4): Don't export this from the package
|
|
9463
9626
|
function getBuildInformation() {
|
|
9464
9627
|
var packageJson = getPackageJson();
|
|
9465
9628
|
var _ref2 = packageJson ? getDependencies(packageJson) : {
|
|
@@ -9620,20 +9783,22 @@ function createRollupModuleMetadataInjectionHooks(injectionCode) {
|
|
|
9620
9783
|
};
|
|
9621
9784
|
}
|
|
9622
9785
|
|
|
9623
|
-
function createRollupDebugIdUploadHooks(upload) {
|
|
9786
|
+
function createRollupDebugIdUploadHooks(upload, _logger, createDependencyOnBuildArtifacts) {
|
|
9787
|
+
var freeGlobalDependencyOnDebugIdSourcemapArtifacts = createDependencyOnBuildArtifacts();
|
|
9624
9788
|
return {
|
|
9625
9789
|
writeBundle: function writeBundle(outputOptions, bundle) {
|
|
9626
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
9790
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
9627
9791
|
var outputDir, _buildArtifacts, _buildArtifacts2;
|
|
9628
|
-
return _regeneratorRuntime().wrap(function
|
|
9629
|
-
while (1) switch (
|
|
9792
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
9793
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
9630
9794
|
case 0:
|
|
9795
|
+
_context4.prev = 0;
|
|
9631
9796
|
if (!outputOptions.dir) {
|
|
9632
|
-
|
|
9797
|
+
_context4.next = 10;
|
|
9633
9798
|
break;
|
|
9634
9799
|
}
|
|
9635
9800
|
outputDir = outputOptions.dir;
|
|
9636
|
-
|
|
9801
|
+
_context4.next = 5;
|
|
9637
9802
|
return glob.glob(["/**/*.js", "/**/*.mjs", "/**/*.cjs", "/**/*.js.map", "/**/*.mjs.map", "/**/*.cjs.map"].map(function (q) {
|
|
9638
9803
|
return "".concat(q, "?(\\?*)?(#*)");
|
|
9639
9804
|
}),
|
|
@@ -9643,34 +9808,38 @@ function createRollupDebugIdUploadHooks(upload) {
|
|
|
9643
9808
|
absolute: true,
|
|
9644
9809
|
nodir: true
|
|
9645
9810
|
});
|
|
9646
|
-
case
|
|
9647
|
-
_buildArtifacts =
|
|
9648
|
-
|
|
9811
|
+
case 5:
|
|
9812
|
+
_buildArtifacts = _context4.sent;
|
|
9813
|
+
_context4.next = 8;
|
|
9649
9814
|
return upload(_buildArtifacts);
|
|
9650
|
-
case
|
|
9651
|
-
|
|
9815
|
+
case 8:
|
|
9816
|
+
_context4.next = 18;
|
|
9652
9817
|
break;
|
|
9653
|
-
case
|
|
9818
|
+
case 10:
|
|
9654
9819
|
if (!outputOptions.file) {
|
|
9655
|
-
|
|
9820
|
+
_context4.next = 15;
|
|
9656
9821
|
break;
|
|
9657
9822
|
}
|
|
9658
|
-
|
|
9823
|
+
_context4.next = 13;
|
|
9659
9824
|
return upload([outputOptions.file]);
|
|
9660
|
-
case
|
|
9661
|
-
|
|
9825
|
+
case 13:
|
|
9826
|
+
_context4.next = 18;
|
|
9662
9827
|
break;
|
|
9663
|
-
case
|
|
9828
|
+
case 15:
|
|
9664
9829
|
_buildArtifacts2 = Object.keys(bundle).map(function (asset) {
|
|
9665
9830
|
return path__namespace.join(path__namespace.resolve(), asset);
|
|
9666
9831
|
});
|
|
9667
|
-
|
|
9832
|
+
_context4.next = 18;
|
|
9668
9833
|
return upload(_buildArtifacts2);
|
|
9669
|
-
case
|
|
9834
|
+
case 18:
|
|
9835
|
+
_context4.prev = 18;
|
|
9836
|
+
freeGlobalDependencyOnDebugIdSourcemapArtifacts();
|
|
9837
|
+
return _context4.finish(18);
|
|
9838
|
+
case 21:
|
|
9670
9839
|
case "end":
|
|
9671
|
-
return
|
|
9840
|
+
return _context4.stop();
|
|
9672
9841
|
}
|
|
9673
|
-
},
|
|
9842
|
+
}, _callee4, null, [[0,, 18, 21]]);
|
|
9674
9843
|
}))();
|
|
9675
9844
|
}
|
|
9676
9845
|
};
|
|
@@ -9678,26 +9847,26 @@ function createRollupDebugIdUploadHooks(upload) {
|
|
|
9678
9847
|
function createComponentNameAnnotateHooks(ignoredComponents) {
|
|
9679
9848
|
return {
|
|
9680
9849
|
transform: function transform(code, id) {
|
|
9681
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
9850
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
9682
9851
|
var idWithoutQueryAndHash, parserPlugins, _result$code, result;
|
|
9683
|
-
return _regeneratorRuntime().wrap(function
|
|
9684
|
-
while (1) switch (
|
|
9852
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
9853
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
9685
9854
|
case 0:
|
|
9686
9855
|
// id may contain query and hash which will trip up our file extension logic below
|
|
9687
9856
|
idWithoutQueryAndHash = stripQueryAndHashFromPath(id);
|
|
9688
9857
|
if (!idWithoutQueryAndHash.match(/\\node_modules\\|\/node_modules\//)) {
|
|
9689
|
-
|
|
9858
|
+
_context5.next = 3;
|
|
9690
9859
|
break;
|
|
9691
9860
|
}
|
|
9692
|
-
return
|
|
9861
|
+
return _context5.abrupt("return", null);
|
|
9693
9862
|
case 3:
|
|
9694
9863
|
if ([".jsx", ".tsx"].some(function (ending) {
|
|
9695
9864
|
return idWithoutQueryAndHash.endsWith(ending);
|
|
9696
9865
|
})) {
|
|
9697
|
-
|
|
9866
|
+
_context5.next = 5;
|
|
9698
9867
|
break;
|
|
9699
9868
|
}
|
|
9700
|
-
return
|
|
9869
|
+
return _context5.abrupt("return", null);
|
|
9701
9870
|
case 5:
|
|
9702
9871
|
parserPlugins = [];
|
|
9703
9872
|
if (idWithoutQueryAndHash.endsWith(".jsx")) {
|
|
@@ -9705,8 +9874,8 @@ function createComponentNameAnnotateHooks(ignoredComponents) {
|
|
|
9705
9874
|
} else if (idWithoutQueryAndHash.endsWith(".tsx")) {
|
|
9706
9875
|
parserPlugins.push("jsx", "typescript");
|
|
9707
9876
|
}
|
|
9708
|
-
|
|
9709
|
-
|
|
9877
|
+
_context5.prev = 7;
|
|
9878
|
+
_context5.next = 10;
|
|
9710
9879
|
return core.transformAsync(code, {
|
|
9711
9880
|
plugins: [[componentNameAnnotatePlugin__default["default"], {
|
|
9712
9881
|
ignoredComponents: ignoredComponents
|
|
@@ -9723,24 +9892,24 @@ function createComponentNameAnnotateHooks(ignoredComponents) {
|
|
|
9723
9892
|
sourceMaps: true
|
|
9724
9893
|
});
|
|
9725
9894
|
case 10:
|
|
9726
|
-
result =
|
|
9727
|
-
return
|
|
9895
|
+
result = _context5.sent;
|
|
9896
|
+
return _context5.abrupt("return", {
|
|
9728
9897
|
code: (_result$code = result === null || result === void 0 ? void 0 : result.code) !== null && _result$code !== void 0 ? _result$code : code,
|
|
9729
9898
|
map: result === null || result === void 0 ? void 0 : result.map
|
|
9730
9899
|
});
|
|
9731
9900
|
case 14:
|
|
9732
|
-
|
|
9733
|
-
|
|
9734
|
-
logger.error("Failed to apply react annotate plugin",
|
|
9901
|
+
_context5.prev = 14;
|
|
9902
|
+
_context5.t0 = _context5["catch"](7);
|
|
9903
|
+
logger.error("Failed to apply react annotate plugin", _context5.t0);
|
|
9735
9904
|
case 17:
|
|
9736
|
-
return
|
|
9905
|
+
return _context5.abrupt("return", {
|
|
9737
9906
|
code: code
|
|
9738
9907
|
});
|
|
9739
9908
|
case 18:
|
|
9740
9909
|
case "end":
|
|
9741
|
-
return
|
|
9910
|
+
return _context5.stop();
|
|
9742
9911
|
}
|
|
9743
|
-
},
|
|
9912
|
+
}, _callee5, null, [[7, 14]]);
|
|
9744
9913
|
}))();
|
|
9745
9914
|
}
|
|
9746
9915
|
};
|
|
@@ -9755,6 +9924,7 @@ exports.createRollupDebugIdInjectionHooks = createRollupDebugIdInjectionHooks;
|
|
|
9755
9924
|
exports.createRollupDebugIdUploadHooks = createRollupDebugIdUploadHooks;
|
|
9756
9925
|
exports.createRollupModuleMetadataInjectionHooks = createRollupModuleMetadataInjectionHooks;
|
|
9757
9926
|
exports.createRollupReleaseInjectionHooks = createRollupReleaseInjectionHooks;
|
|
9927
|
+
exports.createSentryBuildPluginManager = createSentryBuildPluginManager;
|
|
9758
9928
|
exports.getBuildInformation = getBuildInformation;
|
|
9759
9929
|
exports.getDebugIdSnippet = getDebugIdSnippet;
|
|
9760
9930
|
exports.replaceBooleanFlagsInCode = replaceBooleanFlagsInCode;
|