@sentry/bundler-plugin-core 2.3.0 → 2.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 +52 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.mjs +51 -10
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/options-mapping.d.ts +1 -0
- package/dist/types/options-mapping.d.ts.map +1 -1
- package/dist/types/types.d.ts +22 -2
- 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 +7 -6
package/dist/esm/index.mjs
CHANGED
|
@@ -14,6 +14,7 @@ import * as util from 'util';
|
|
|
14
14
|
import { promisify } from 'util';
|
|
15
15
|
import { dynamicSamplingContextToSentryBaggageHeader } from '@sentry/utils';
|
|
16
16
|
import { NodeClient, defaultStackParser, makeNodeTransport, Hub } from '@sentry/node';
|
|
17
|
+
import * as dotenv from 'dotenv';
|
|
17
18
|
|
|
18
19
|
function ownKeys(object, enumerableOnly) {
|
|
19
20
|
var keys = Object.keys(object);
|
|
@@ -546,7 +547,7 @@ function stringToUUID(str) {
|
|
|
546
547
|
function determineReleaseName() {
|
|
547
548
|
var gitRevision;
|
|
548
549
|
try {
|
|
549
|
-
gitRevision = childProcess.execSync("git rev-parse
|
|
550
|
+
gitRevision = childProcess.execSync("git rev-parse HEAD").toString().trim();
|
|
550
551
|
} catch (e) {
|
|
551
552
|
// noop
|
|
552
553
|
}
|
|
@@ -584,6 +585,13 @@ function generateGlobalInjectorCode(_ref2) {
|
|
|
584
585
|
}
|
|
585
586
|
return code;
|
|
586
587
|
}
|
|
588
|
+
|
|
589
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
590
|
+
function generateModuleMetadataInjectorCode(metadata) {
|
|
591
|
+
// The code below is mostly ternary operators because it saves bundle size.
|
|
592
|
+
// The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
|
|
593
|
+
return "\n var _global2 =\n typeof window !== 'undefined' ?\n window :\n typeof global !== 'undefined' ?\n global :\n typeof self !== 'undefined' ?\n self :\n {};\n\n _global2._sentryModuleMetadata = _global2._sentryModuleMetadata || {};\n _global2._sentryModuleMetadata[new Error().stack] = ".concat(JSON.stringify(metadata), ";");
|
|
594
|
+
}
|
|
587
595
|
function getBuildInformation$1() {
|
|
588
596
|
var packageJson = getPackageJson();
|
|
589
597
|
var _ref3 = packageJson ? getDependencies(packageJson) : {
|
|
@@ -1258,7 +1266,7 @@ function createSentryInstance(options, shouldSendTelemetry, bundler) {
|
|
|
1258
1266
|
dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
|
|
1259
1267
|
tracesSampleRate: 1,
|
|
1260
1268
|
sampleRate: 1,
|
|
1261
|
-
release: "2.
|
|
1269
|
+
release: "2.5.0",
|
|
1262
1270
|
integrations: [],
|
|
1263
1271
|
tracePropagationTargets: ["sentry.io/api"],
|
|
1264
1272
|
stackParser: defaultStackParser,
|
|
@@ -1444,9 +1452,28 @@ function _allowedToSendTelemetry() {
|
|
|
1444
1452
|
*/
|
|
1445
1453
|
function sentryUnpluginFactory(_ref) {
|
|
1446
1454
|
var releaseInjectionPlugin = _ref.releaseInjectionPlugin,
|
|
1455
|
+
moduleMetadataInjectionPlugin = _ref.moduleMetadataInjectionPlugin,
|
|
1447
1456
|
debugIdInjectionPlugin = _ref.debugIdInjectionPlugin,
|
|
1448
1457
|
debugIdUploadPlugin = _ref.debugIdUploadPlugin;
|
|
1449
1458
|
return createUnplugin(function (userOptions, unpluginMetaContext) {
|
|
1459
|
+
var _userOptions$silent, _userOptions$debug;
|
|
1460
|
+
var logger = createLogger({
|
|
1461
|
+
prefix: "[sentry-".concat(unpluginMetaContext.framework, "-plugin]"),
|
|
1462
|
+
silent: (_userOptions$silent = userOptions.silent) !== null && _userOptions$silent !== void 0 ? _userOptions$silent : false,
|
|
1463
|
+
debug: (_userOptions$debug = userOptions.debug) !== null && _userOptions$debug !== void 0 ? _userOptions$debug : false
|
|
1464
|
+
});
|
|
1465
|
+
var dotenvResult = dotenv.config({
|
|
1466
|
+
path: path.join(process.cwd(), ".env.sentry-build-plugin")
|
|
1467
|
+
});
|
|
1468
|
+
|
|
1469
|
+
// Ignore "file not found" errors but throw all others
|
|
1470
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1471
|
+
// @ts-ignore Accessing `code` on error should be safe
|
|
1472
|
+
if (dotenvResult.error && dotenvResult.error.code !== "ENOENT") {
|
|
1473
|
+
throw dotenvResult.error;
|
|
1474
|
+
} else if (dotenvResult.parsed) {
|
|
1475
|
+
logger.info('Using environment variables configured in ".env.sentry-build-plugin".');
|
|
1476
|
+
}
|
|
1450
1477
|
var options = normalizeUserOptions(userOptions);
|
|
1451
1478
|
if (unpluginMetaContext.watchMode || options.disable) {
|
|
1452
1479
|
return [{
|
|
@@ -1467,14 +1494,9 @@ function sentryUnpluginFactory(_ref) {
|
|
|
1467
1494
|
sentEndSession = true;
|
|
1468
1495
|
}
|
|
1469
1496
|
});
|
|
1470
|
-
var logger = createLogger({
|
|
1471
|
-
prefix: "[sentry-".concat(unpluginMetaContext.framework, "-plugin]"),
|
|
1472
|
-
silent: options.silent,
|
|
1473
|
-
debug: options.debug
|
|
1474
|
-
});
|
|
1475
1497
|
|
|
1476
1498
|
// Set the User-Agent that Sentry CLI will use when interacting with Sentry
|
|
1477
|
-
process.env["SENTRY_PIPELINE"] = "".concat(unpluginMetaContext.framework, "-plugin/", "2.
|
|
1499
|
+
process.env["SENTRY_PIPELINE"] = "".concat(unpluginMetaContext.framework, "-plugin/", "2.5.0");
|
|
1478
1500
|
function handleRecoverableError(unknownError) {
|
|
1479
1501
|
sentrySession.status = "abnormal";
|
|
1480
1502
|
try {
|
|
@@ -1513,7 +1535,7 @@ function sentryUnpluginFactory(_ref) {
|
|
|
1513
1535
|
if (!options.release.inject) {
|
|
1514
1536
|
logger.debug("Release injection disabled via `release.inject` option. Will not inject release.");
|
|
1515
1537
|
} else if (!options.release.name) {
|
|
1516
|
-
logger.warn("No release name provided. Will not inject release. Please set the `release.name` option to
|
|
1538
|
+
logger.warn("No release name provided. Will not inject release. Please set the `release.name` option to identify your release.");
|
|
1517
1539
|
} else {
|
|
1518
1540
|
var _injectionCode = generateGlobalInjectorCode({
|
|
1519
1541
|
release: options.release.name,
|
|
@@ -1521,8 +1543,27 @@ function sentryUnpluginFactory(_ref) {
|
|
|
1521
1543
|
});
|
|
1522
1544
|
plugins.push(releaseInjectionPlugin(_injectionCode));
|
|
1523
1545
|
}
|
|
1546
|
+
if (moduleMetadataInjectionPlugin && options._experiments.moduleMetadata) {
|
|
1547
|
+
var metadata;
|
|
1548
|
+
if (typeof options._experiments.moduleMetadata === "function") {
|
|
1549
|
+
var args = {
|
|
1550
|
+
org: options.org,
|
|
1551
|
+
project: options.project,
|
|
1552
|
+
release: options.release.name
|
|
1553
|
+
};
|
|
1554
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
|
|
1555
|
+
metadata = options._experiments.moduleMetadata(args);
|
|
1556
|
+
} else {
|
|
1557
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
1558
|
+
metadata = options._experiments.moduleMetadata;
|
|
1559
|
+
}
|
|
1560
|
+
var _injectionCode2 = generateModuleMetadataInjectorCode(metadata);
|
|
1561
|
+
plugins.push(moduleMetadataInjectionPlugin(_injectionCode2));
|
|
1562
|
+
} else if (options._experiments.moduleMetadata) {
|
|
1563
|
+
logger.warn("'moduleMetadata' is currently only supported by '@sentry/webpack-plugin'");
|
|
1564
|
+
}
|
|
1524
1565
|
if (!options.release.name) {
|
|
1525
|
-
logger.warn("No release name provided. Will not create release. Please set the `release.name` option to
|
|
1566
|
+
logger.warn("No release name provided. Will not create release. Please set the `release.name` option to identify your release.");
|
|
1526
1567
|
} else if (!options.authToken) {
|
|
1527
1568
|
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/");
|
|
1528
1569
|
} else if (!options.org) {
|