@sentry/bundler-plugin-core 0.2.0 → 0.2.1
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/README.md +0 -2
- package/dist/cjs/index.js +359 -195
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +359 -196
- package/dist/esm/index.js.map +1 -1
- package/dist/types/options-mapping.d.ts +1 -1
- package/dist/types/sentry/releasePipeline.d.ts +6 -6
- package/dist/types/sentry/telemetry.d.ts +5 -13
- package/package.json +3 -3
package/dist/cjs/index.js
CHANGED
|
@@ -4,14 +4,16 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var unplugin$1 = require('unplugin');
|
|
6
6
|
var MagicString = require('magic-string');
|
|
7
|
+
var SentryCli = require('@sentry/cli');
|
|
7
8
|
var node = require('@sentry/node');
|
|
8
9
|
require('@sentry/tracing');
|
|
9
|
-
var
|
|
10
|
+
var path = require('path');
|
|
10
11
|
|
|
11
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
13
|
|
|
13
14
|
var MagicString__default = /*#__PURE__*/_interopDefaultLegacy(MagicString);
|
|
14
15
|
var SentryCli__default = /*#__PURE__*/_interopDefaultLegacy(SentryCli);
|
|
16
|
+
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
15
17
|
|
|
16
18
|
function _regeneratorRuntime() {
|
|
17
19
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
@@ -831,12 +833,7 @@ function normalizeUserOptions(userOptions) {
|
|
|
831
833
|
dist: userOptions.dist,
|
|
832
834
|
errorHandler: userOptions.errorHandler,
|
|
833
835
|
configFile: userOptions.configFile
|
|
834
|
-
};
|
|
835
|
-
// This is not the final check (we need to call Sentry CLI at a later point)
|
|
836
|
-
// but we can already at this point make a first decision.
|
|
837
|
-
// @see `turnOffTelemetryForSelfHostedSentry` (telemetry.ts) for the second check.
|
|
838
|
-
|
|
839
|
-
options.telemetry = options.telemetry && options.url === SENTRY_SAAS_URL;
|
|
836
|
+
};
|
|
840
837
|
return options;
|
|
841
838
|
}
|
|
842
839
|
/**
|
|
@@ -949,30 +946,68 @@ function validateOptions(options, logger) {
|
|
|
949
946
|
return true;
|
|
950
947
|
}
|
|
951
948
|
|
|
952
|
-
|
|
949
|
+
var SENTRY_SAAS_HOSTNAME = "sentry.io";
|
|
950
|
+
function makeSentryClient(dsn, allowedToSendTelemetryPromise) {
|
|
953
951
|
var client = new node.NodeClient({
|
|
954
952
|
dsn: dsn,
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
integrations: [new node.Integrations.Http({
|
|
960
|
-
tracing: true
|
|
961
|
-
})],
|
|
953
|
+
tracesSampleRate: 1,
|
|
954
|
+
sampleRate: 1,
|
|
955
|
+
release: "0.2.1",
|
|
956
|
+
integrations: [],
|
|
962
957
|
tracePropagationTargets: ["sentry.io/api"],
|
|
963
958
|
stackParser: node.defaultStackParser,
|
|
964
|
-
transport
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
959
|
+
// We create a transport that stalls sending events until we know that we're allowed to (i.e. when Sentry CLI told
|
|
960
|
+
// us that the upload URL is the Sentry SaaS URL)
|
|
961
|
+
transport: function transport(nodeTransportOptions) {
|
|
962
|
+
var nodeTransport = node.makeNodeTransport(nodeTransportOptions);
|
|
963
|
+
return {
|
|
964
|
+
flush: function flush(timeout) {
|
|
965
|
+
return nodeTransport.flush(timeout);
|
|
966
|
+
},
|
|
967
|
+
send: function () {
|
|
968
|
+
var _send = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
|
|
969
|
+
var isAllowedToSend;
|
|
970
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
971
|
+
while (1) {
|
|
972
|
+
switch (_context.prev = _context.next) {
|
|
973
|
+
case 0:
|
|
974
|
+
_context.next = 2;
|
|
975
|
+
return allowedToSendTelemetryPromise;
|
|
976
|
+
|
|
977
|
+
case 2:
|
|
978
|
+
isAllowedToSend = _context.sent;
|
|
979
|
+
|
|
980
|
+
if (!isAllowedToSend) {
|
|
981
|
+
_context.next = 7;
|
|
982
|
+
break;
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
return _context.abrupt("return", nodeTransport.send(request));
|
|
986
|
+
|
|
987
|
+
case 7:
|
|
988
|
+
return _context.abrupt("return", undefined);
|
|
989
|
+
|
|
990
|
+
case 8:
|
|
991
|
+
case "end":
|
|
992
|
+
return _context.stop();
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
}, _callee);
|
|
996
|
+
}));
|
|
971
997
|
|
|
972
|
-
|
|
998
|
+
function send(_x) {
|
|
999
|
+
return _send.apply(this, arguments);
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
return send;
|
|
1003
|
+
}()
|
|
1004
|
+
};
|
|
1005
|
+
}
|
|
1006
|
+
});
|
|
1007
|
+
var hub = new node.Hub(client);
|
|
973
1008
|
return {
|
|
974
|
-
|
|
975
|
-
|
|
1009
|
+
sentryClient: client,
|
|
1010
|
+
sentryHub: hub
|
|
976
1011
|
};
|
|
977
1012
|
}
|
|
978
1013
|
/**
|
|
@@ -1014,8 +1049,10 @@ function captureMinimalError(error, hub) {
|
|
|
1014
1049
|
|
|
1015
1050
|
hub.captureException(sentryError);
|
|
1016
1051
|
}
|
|
1017
|
-
function
|
|
1018
|
-
var
|
|
1052
|
+
function addPluginOptionInformationToHub(options, hub, bundler) {
|
|
1053
|
+
var org = options.org,
|
|
1054
|
+
project = options.project,
|
|
1055
|
+
cleanArtifacts = options.cleanArtifacts,
|
|
1019
1056
|
finalize = options.finalize,
|
|
1020
1057
|
setCommits = options.setCommits,
|
|
1021
1058
|
injectReleasesMap = options.injectReleasesMap,
|
|
@@ -1055,61 +1092,107 @@ function addPluginOptionTags(options, hub) {
|
|
|
1055
1092
|
}
|
|
1056
1093
|
|
|
1057
1094
|
hub.setTag("node", process.version);
|
|
1095
|
+
hub.setTags({
|
|
1096
|
+
organization: org,
|
|
1097
|
+
project: project,
|
|
1098
|
+
bundler: bundler
|
|
1099
|
+
});
|
|
1100
|
+
hub.setUser({
|
|
1101
|
+
id: org
|
|
1102
|
+
});
|
|
1058
1103
|
}
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
*
|
|
1062
|
-
* We need to check and decide to use telemetry based on the CLI's respone to this call
|
|
1063
|
-
* because only at this time we checked a possibly existing .sentryclirc file. This file
|
|
1064
|
-
* could point to another URL than the default URL.
|
|
1065
|
-
*/
|
|
1066
|
-
|
|
1067
|
-
function turnOffTelemetryForSelfHostedSentry(_x, _x2) {
|
|
1068
|
-
return _turnOffTelemetryForSelfHostedSentry.apply(this, arguments);
|
|
1104
|
+
function shouldSendTelemetry(_x2) {
|
|
1105
|
+
return _shouldSendTelemetry.apply(this, arguments);
|
|
1069
1106
|
}
|
|
1070
1107
|
|
|
1071
|
-
function
|
|
1072
|
-
|
|
1108
|
+
function _shouldSendTelemetry() {
|
|
1109
|
+
_shouldSendTelemetry = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
1073
1110
|
var _cliInfo$split$, _cliInfo$split$$repla;
|
|
1074
1111
|
|
|
1075
|
-
var
|
|
1076
|
-
return _regeneratorRuntime().wrap(function
|
|
1112
|
+
var silent, org, project, authToken, url, vcsRemote, customHeader, dist, telemetry, dryRun, cli, cliInfo, cliInfoUrl;
|
|
1113
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1077
1114
|
while (1) {
|
|
1078
|
-
switch (
|
|
1115
|
+
switch (_context2.prev = _context2.next) {
|
|
1079
1116
|
case 0:
|
|
1080
|
-
|
|
1081
|
-
return cli.execute(["info"], false);
|
|
1117
|
+
silent = options.silent, org = options.org, project = options.project, authToken = options.authToken, url = options.url, vcsRemote = options.vcsRemote, customHeader = options.customHeader, dist = options.dist, telemetry = options.telemetry, dryRun = options.dryRun; // `options.telemetry` defaults to true
|
|
1082
1118
|
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1119
|
+
if (!(telemetry === false)) {
|
|
1120
|
+
_context2.next = 3;
|
|
1121
|
+
break;
|
|
1122
|
+
}
|
|
1086
1123
|
|
|
1087
|
-
|
|
1088
|
-
client = hub.getClient();
|
|
1124
|
+
return _context2.abrupt("return", false);
|
|
1089
1125
|
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
}
|
|
1126
|
+
case 3:
|
|
1127
|
+
if (!dryRun) {
|
|
1128
|
+
_context2.next = 5;
|
|
1129
|
+
break;
|
|
1095
1130
|
}
|
|
1096
1131
|
|
|
1132
|
+
return _context2.abrupt("return", false);
|
|
1133
|
+
|
|
1097
1134
|
case 5:
|
|
1135
|
+
if (!(url === SENTRY_SAAS_URL)) {
|
|
1136
|
+
_context2.next = 7;
|
|
1137
|
+
break;
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
return _context2.abrupt("return", true);
|
|
1141
|
+
|
|
1142
|
+
case 7:
|
|
1143
|
+
cli = new SentryCli__default["default"](options.configFile, {
|
|
1144
|
+
url: url,
|
|
1145
|
+
authToken: authToken,
|
|
1146
|
+
org: org,
|
|
1147
|
+
project: project,
|
|
1148
|
+
vcsRemote: vcsRemote,
|
|
1149
|
+
dist: dist,
|
|
1150
|
+
silent: silent,
|
|
1151
|
+
customHeader: customHeader
|
|
1152
|
+
});
|
|
1153
|
+
_context2.prev = 8;
|
|
1154
|
+
_context2.next = 11;
|
|
1155
|
+
return cli.execute(["info"], false);
|
|
1156
|
+
|
|
1157
|
+
case 11:
|
|
1158
|
+
cliInfo = _context2.sent;
|
|
1159
|
+
_context2.next = 17;
|
|
1160
|
+
break;
|
|
1161
|
+
|
|
1162
|
+
case 14:
|
|
1163
|
+
_context2.prev = 14;
|
|
1164
|
+
_context2.t0 = _context2["catch"](8);
|
|
1165
|
+
throw new Error('Sentry CLI "info" command failed, make sure you have an auth token configured, and your `url` option is correct.');
|
|
1166
|
+
|
|
1167
|
+
case 17:
|
|
1168
|
+
cliInfoUrl = (_cliInfo$split$ = cliInfo.split(/(\r\n|\n|\r)/)[0]) === null || _cliInfo$split$ === void 0 ? void 0 : (_cliInfo$split$$repla = _cliInfo$split$.replace(/^Sentry Server: /, "")) === null || _cliInfo$split$$repla === void 0 ? void 0 : _cliInfo$split$$repla.trim();
|
|
1169
|
+
|
|
1170
|
+
if (!(cliInfoUrl === undefined)) {
|
|
1171
|
+
_context2.next = 20;
|
|
1172
|
+
break;
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
return _context2.abrupt("return", false);
|
|
1176
|
+
|
|
1177
|
+
case 20:
|
|
1178
|
+
return _context2.abrupt("return", new URL(cliInfoUrl).hostname === SENTRY_SAAS_HOSTNAME);
|
|
1179
|
+
|
|
1180
|
+
case 21:
|
|
1098
1181
|
case "end":
|
|
1099
|
-
return
|
|
1182
|
+
return _context2.stop();
|
|
1100
1183
|
}
|
|
1101
1184
|
}
|
|
1102
|
-
},
|
|
1185
|
+
}, _callee2, null, [[8, 14]]);
|
|
1103
1186
|
}));
|
|
1104
|
-
return
|
|
1187
|
+
return _shouldSendTelemetry.apply(this, arguments);
|
|
1105
1188
|
}
|
|
1106
1189
|
|
|
1107
|
-
function createNewRelease(_x, _x2) {
|
|
1190
|
+
function createNewRelease(_x, _x2, _x3) {
|
|
1108
1191
|
return _createNewRelease.apply(this, arguments);
|
|
1109
1192
|
}
|
|
1110
1193
|
|
|
1111
1194
|
function _createNewRelease() {
|
|
1112
|
-
_createNewRelease = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options, ctx) {
|
|
1195
|
+
_createNewRelease = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options, ctx, releaseName) {
|
|
1113
1196
|
var span;
|
|
1114
1197
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1115
1198
|
while (1) {
|
|
@@ -1117,7 +1200,7 @@ function _createNewRelease() {
|
|
|
1117
1200
|
case 0:
|
|
1118
1201
|
span = addSpanToTransaction(ctx, "function.plugin.create_release");
|
|
1119
1202
|
_context.next = 3;
|
|
1120
|
-
return ctx.cli.releases["new"](
|
|
1203
|
+
return ctx.cli.releases["new"](releaseName);
|
|
1121
1204
|
|
|
1122
1205
|
case 3:
|
|
1123
1206
|
ctx.logger.info("Successfully created release.");
|
|
@@ -1133,12 +1216,12 @@ function _createNewRelease() {
|
|
|
1133
1216
|
return _createNewRelease.apply(this, arguments);
|
|
1134
1217
|
}
|
|
1135
1218
|
|
|
1136
|
-
function cleanArtifacts(
|
|
1219
|
+
function cleanArtifacts(_x4, _x5, _x6) {
|
|
1137
1220
|
return _cleanArtifacts.apply(this, arguments);
|
|
1138
1221
|
}
|
|
1139
1222
|
|
|
1140
1223
|
function _cleanArtifacts() {
|
|
1141
|
-
_cleanArtifacts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options, ctx) {
|
|
1224
|
+
_cleanArtifacts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options, ctx, releaseName) {
|
|
1142
1225
|
var span;
|
|
1143
1226
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1144
1227
|
while (1) {
|
|
@@ -1155,7 +1238,7 @@ function _cleanArtifacts() {
|
|
|
1155
1238
|
case 3:
|
|
1156
1239
|
span = addSpanToTransaction(ctx, "function.plugin.clean_artifacts");
|
|
1157
1240
|
_context2.next = 6;
|
|
1158
|
-
return ctx.cli.releases.execute(["releases", "files",
|
|
1241
|
+
return ctx.cli.releases.execute(["releases", "files", releaseName, "delete", "--all"], true);
|
|
1159
1242
|
|
|
1160
1243
|
case 6:
|
|
1161
1244
|
ctx.logger.info("Successfully cleaned previous artifacts.");
|
|
@@ -1171,12 +1254,12 @@ function _cleanArtifacts() {
|
|
|
1171
1254
|
return _cleanArtifacts.apply(this, arguments);
|
|
1172
1255
|
}
|
|
1173
1256
|
|
|
1174
|
-
function uploadSourceMaps(
|
|
1257
|
+
function uploadSourceMaps(_x7, _x8, _x9) {
|
|
1175
1258
|
return _uploadSourceMaps.apply(this, arguments);
|
|
1176
1259
|
}
|
|
1177
1260
|
|
|
1178
1261
|
function _uploadSourceMaps() {
|
|
1179
|
-
_uploadSourceMaps = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(options, ctx) {
|
|
1262
|
+
_uploadSourceMaps = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(options, ctx, releaseName) {
|
|
1180
1263
|
var span;
|
|
1181
1264
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1182
1265
|
while (1) {
|
|
@@ -1187,7 +1270,7 @@ function _uploadSourceMaps() {
|
|
|
1187
1270
|
// we only need to pass the include option here.
|
|
1188
1271
|
|
|
1189
1272
|
_context3.next = 4;
|
|
1190
|
-
return ctx.cli.releases.uploadSourceMaps(
|
|
1273
|
+
return ctx.cli.releases.uploadSourceMaps(releaseName, {
|
|
1191
1274
|
include: options.include
|
|
1192
1275
|
});
|
|
1193
1276
|
|
|
@@ -1205,12 +1288,12 @@ function _uploadSourceMaps() {
|
|
|
1205
1288
|
return _uploadSourceMaps.apply(this, arguments);
|
|
1206
1289
|
}
|
|
1207
1290
|
|
|
1208
|
-
function setCommits(
|
|
1291
|
+
function setCommits(_x10, _x11, _x12) {
|
|
1209
1292
|
return _setCommits.apply(this, arguments);
|
|
1210
1293
|
}
|
|
1211
1294
|
|
|
1212
1295
|
function _setCommits() {
|
|
1213
|
-
_setCommits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(options, ctx) {
|
|
1296
|
+
_setCommits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(options, ctx, releaseName) {
|
|
1214
1297
|
var span, _options$setCommits, auto, repo, commit, previousCommit, ignoreMissing, ignoreEmpty;
|
|
1215
1298
|
|
|
1216
1299
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
@@ -1229,7 +1312,7 @@ function _setCommits() {
|
|
|
1229
1312
|
span = addSpanToTransaction(ctx, "function.plugin.set_commits");
|
|
1230
1313
|
_options$setCommits = options.setCommits, auto = _options$setCommits.auto, repo = _options$setCommits.repo, commit = _options$setCommits.commit, previousCommit = _options$setCommits.previousCommit, ignoreMissing = _options$setCommits.ignoreMissing, ignoreEmpty = _options$setCommits.ignoreEmpty;
|
|
1231
1314
|
_context4.next = 7;
|
|
1232
|
-
return ctx.cli.releases.setCommits(
|
|
1315
|
+
return ctx.cli.releases.setCommits(releaseName, {
|
|
1233
1316
|
commit: commit,
|
|
1234
1317
|
previousCommit: previousCommit,
|
|
1235
1318
|
repo: repo,
|
|
@@ -1252,12 +1335,12 @@ function _setCommits() {
|
|
|
1252
1335
|
return _setCommits.apply(this, arguments);
|
|
1253
1336
|
}
|
|
1254
1337
|
|
|
1255
|
-
function finalizeRelease(
|
|
1338
|
+
function finalizeRelease(_x13, _x14, _x15) {
|
|
1256
1339
|
return _finalizeRelease.apply(this, arguments);
|
|
1257
1340
|
}
|
|
1258
1341
|
|
|
1259
1342
|
function _finalizeRelease() {
|
|
1260
|
-
_finalizeRelease = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(options, ctx) {
|
|
1343
|
+
_finalizeRelease = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(options, ctx, releaseName) {
|
|
1261
1344
|
var span;
|
|
1262
1345
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
1263
1346
|
while (1) {
|
|
@@ -1274,7 +1357,7 @@ function _finalizeRelease() {
|
|
|
1274
1357
|
case 3:
|
|
1275
1358
|
span = addSpanToTransaction(ctx, "function.plugin.finalize_release");
|
|
1276
1359
|
_context5.next = 6;
|
|
1277
|
-
return ctx.cli.releases.finalize(
|
|
1360
|
+
return ctx.cli.releases.finalize(releaseName);
|
|
1278
1361
|
|
|
1279
1362
|
case 6:
|
|
1280
1363
|
ctx.logger.info("Successfully finalized release.");
|
|
@@ -1290,12 +1373,12 @@ function _finalizeRelease() {
|
|
|
1290
1373
|
return _finalizeRelease.apply(this, arguments);
|
|
1291
1374
|
}
|
|
1292
1375
|
|
|
1293
|
-
function addDeploy(
|
|
1376
|
+
function addDeploy(_x16, _x17, _x18) {
|
|
1294
1377
|
return _addDeploy.apply(this, arguments);
|
|
1295
1378
|
}
|
|
1296
1379
|
|
|
1297
1380
|
function _addDeploy() {
|
|
1298
|
-
_addDeploy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(options, ctx) {
|
|
1381
|
+
_addDeploy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(options, ctx, releaseName) {
|
|
1299
1382
|
var span, _options$deploy, env, started, finished, time, name, url;
|
|
1300
1383
|
|
|
1301
1384
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
@@ -1314,7 +1397,7 @@ function _addDeploy() {
|
|
|
1314
1397
|
span = addSpanToTransaction(ctx, "function.plugin.deploy");
|
|
1315
1398
|
_options$deploy = options.deploy, env = _options$deploy.env, started = _options$deploy.started, finished = _options$deploy.finished, time = _options$deploy.time, name = _options$deploy.name, url = _options$deploy.url;
|
|
1316
1399
|
_context6.next = 7;
|
|
1317
|
-
return ctx.cli.releases.newDeploy(
|
|
1400
|
+
return ctx.cli.releases.newDeploy(releaseName, {
|
|
1318
1401
|
env: env,
|
|
1319
1402
|
started: started,
|
|
1320
1403
|
finished: finished,
|
|
@@ -1398,10 +1481,9 @@ function createLogger(options) {
|
|
|
1398
1481
|
}
|
|
1399
1482
|
|
|
1400
1483
|
// eslint-disable-next-line no-console
|
|
1401
|
-
(_console4 = console).log.apply(_console4, ["".concat(options.prefix, " Debug: ").concat(message)].concat(params));
|
|
1402
|
-
}
|
|
1484
|
+
(_console4 = console).log.apply(_console4, ["".concat(options.prefix, " Debug: ").concat(message)].concat(params)); // We're not creating breadcrumbs for debug logs because it is super spammy
|
|
1403
1485
|
|
|
1404
|
-
|
|
1486
|
+
}
|
|
1405
1487
|
}
|
|
1406
1488
|
};
|
|
1407
1489
|
}
|
|
@@ -1481,9 +1563,9 @@ function getDryRunCLI(cli, logger) {
|
|
|
1481
1563
|
};
|
|
1482
1564
|
}
|
|
1483
1565
|
|
|
1484
|
-
// We prefix the polyfill id with \0 to tell other plugins not to try to load or transform it.
|
|
1485
1566
|
// This hack is taken straight from https://rollupjs.org/guide/en/#resolveid.
|
|
1486
1567
|
// This probably doesn't work for all bundlers but for rollup it does.
|
|
1568
|
+
|
|
1487
1569
|
var RELEASE_INJECTOR_ID = "\0sentry-release-injector";
|
|
1488
1570
|
var ALLOWED_TRANSFORMATION_FILE_ENDINGS = [".js", ".ts", ".jsx", ".tsx", ".cjs", ".mjs"];
|
|
1489
1571
|
/**
|
|
@@ -1516,11 +1598,19 @@ var ALLOWED_TRANSFORMATION_FILE_ENDINGS = [".js", ".ts", ".jsx", ".tsx", ".cjs",
|
|
|
1516
1598
|
|
|
1517
1599
|
var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext) {
|
|
1518
1600
|
var internalOptions = normalizeUserOptions(options);
|
|
1601
|
+
var allowedToSendTelemetryPromise = shouldSendTelemetry(internalOptions);
|
|
1519
1602
|
|
|
1520
|
-
var _makeSentryClient = makeSentryClient("https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
|
|
1521
|
-
sentryHub = _makeSentryClient.
|
|
1603
|
+
var _makeSentryClient = makeSentryClient("https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737", allowedToSendTelemetryPromise),
|
|
1604
|
+
sentryHub = _makeSentryClient.sentryHub,
|
|
1605
|
+
sentryClient = _makeSentryClient.sentryClient;
|
|
1522
1606
|
|
|
1523
|
-
|
|
1607
|
+
addPluginOptionInformationToHub(internalOptions, sentryHub, unpluginMetaContext.framework); //TODO: This call is problematic because as soon as we set our hub as the current hub
|
|
1608
|
+
// we might interfere with other plugins that use Sentry. However, for now, we'll
|
|
1609
|
+
// leave it in because without it, we can't get distributed traces (which are pretty nice)
|
|
1610
|
+
// Let's keep it until someone complains about interference.
|
|
1611
|
+
// The ideal solution would be a code change in the JS SDK but it's not a straight-forward fix.
|
|
1612
|
+
|
|
1613
|
+
node.makeMain(sentryHub);
|
|
1524
1614
|
var logger = createLogger({
|
|
1525
1615
|
hub: sentryHub,
|
|
1526
1616
|
prefix: "[sentry-".concat(unpluginMetaContext.framework, "-plugin]"),
|
|
@@ -1533,19 +1623,12 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
1533
1623
|
}
|
|
1534
1624
|
|
|
1535
1625
|
var cli = getSentryCli(internalOptions, logger);
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
sentryHub.setTags({
|
|
1543
|
-
organization: internalOptions.org,
|
|
1544
|
-
project: internalOptions.project,
|
|
1545
|
-
bundler: unpluginMetaContext.framework
|
|
1546
|
-
});
|
|
1547
|
-
sentryHub.setUser({
|
|
1548
|
-
id: internalOptions.org
|
|
1626
|
+
var releaseNamePromise = new Promise(function (resolve) {
|
|
1627
|
+
if (options.release) {
|
|
1628
|
+
resolve(options.release);
|
|
1629
|
+
} else {
|
|
1630
|
+
resolve(cli.releases.proposeVersion());
|
|
1631
|
+
}
|
|
1549
1632
|
});
|
|
1550
1633
|
var transaction;
|
|
1551
1634
|
var releaseInjectionSpan;
|
|
@@ -1559,28 +1642,31 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
1559
1642
|
*/
|
|
1560
1643
|
buildStart: function buildStart() {
|
|
1561
1644
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1645
|
+
var isAllowedToSendToSendTelemetry, releaseName;
|
|
1562
1646
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1563
1647
|
while (1) {
|
|
1564
1648
|
switch (_context.prev = _context.next) {
|
|
1565
1649
|
case 0:
|
|
1566
|
-
|
|
1567
|
-
|
|
1650
|
+
logger.debug("Called 'buildStart'");
|
|
1651
|
+
_context.next = 3;
|
|
1652
|
+
return allowedToSendTelemetryPromise;
|
|
1568
1653
|
|
|
1569
|
-
case
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1654
|
+
case 3:
|
|
1655
|
+
isAllowedToSendToSendTelemetry = _context.sent;
|
|
1656
|
+
|
|
1657
|
+
if (isAllowedToSendToSendTelemetry) {
|
|
1658
|
+
logger.info("Sending error and performance telemetry data to Sentry.");
|
|
1659
|
+
logger.info("To disable telemetry, set `options.telemetry` to `false`.");
|
|
1573
1660
|
}
|
|
1574
1661
|
|
|
1575
|
-
_context.next =
|
|
1576
|
-
return
|
|
1662
|
+
_context.next = 7;
|
|
1663
|
+
return releaseNamePromise;
|
|
1577
1664
|
|
|
1578
|
-
case
|
|
1579
|
-
|
|
1665
|
+
case 7:
|
|
1666
|
+
releaseName = _context.sent;
|
|
1580
1667
|
|
|
1581
|
-
case 6:
|
|
1582
1668
|
// At this point, we either have determined a release or we have to bail
|
|
1583
|
-
if (!
|
|
1669
|
+
if (!releaseName) {
|
|
1584
1670
|
handleError(new Error("Unable to determine a release name. Make sure to set the `release` option or use an environment that supports auto-detection https://docs.sentry.io/cli/releases/#creating-releases`"), logger, internalOptions.errorHandler, sentryHub);
|
|
1585
1671
|
}
|
|
1586
1672
|
|
|
@@ -1595,7 +1681,7 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
1595
1681
|
cli: cli
|
|
1596
1682
|
}, "function.plugin.inject_release", "Release injection");
|
|
1597
1683
|
|
|
1598
|
-
case
|
|
1684
|
+
case 11:
|
|
1599
1685
|
case "end":
|
|
1600
1686
|
return _context.stop();
|
|
1601
1687
|
}
|
|
@@ -1617,10 +1703,10 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
1617
1703
|
*/
|
|
1618
1704
|
resolveId: function resolveId(id, importer, _ref) {
|
|
1619
1705
|
var isEntry = _ref.isEntry;
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1706
|
+
logger.debug('Called "resolveId":', {
|
|
1707
|
+
id: id,
|
|
1708
|
+
importer: importer,
|
|
1709
|
+
isEntry: isEntry
|
|
1624
1710
|
});
|
|
1625
1711
|
|
|
1626
1712
|
if (id === RELEASE_INJECTOR_ID) {
|
|
@@ -1630,9 +1716,9 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
1630
1716
|
}
|
|
1631
1717
|
},
|
|
1632
1718
|
loadInclude: function loadInclude(id) {
|
|
1633
|
-
logger.
|
|
1719
|
+
logger.debug('Called "loadInclude":', {
|
|
1634
1720
|
id: id
|
|
1635
|
-
})
|
|
1721
|
+
});
|
|
1636
1722
|
return id === RELEASE_INJECTOR_ID;
|
|
1637
1723
|
},
|
|
1638
1724
|
|
|
@@ -1644,21 +1730,47 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
1644
1730
|
* @returns The global injector code when we load the "sentry-release-injector" module. Otherwise returns `undefined`.
|
|
1645
1731
|
*/
|
|
1646
1732
|
load: function load(id) {
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1733
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
1734
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1735
|
+
while (1) {
|
|
1736
|
+
switch (_context2.prev = _context2.next) {
|
|
1737
|
+
case 0:
|
|
1738
|
+
logger.debug('Called "load":', {
|
|
1739
|
+
id: id
|
|
1740
|
+
});
|
|
1651
1741
|
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1742
|
+
if (!(id === RELEASE_INJECTOR_ID)) {
|
|
1743
|
+
_context2.next = 13;
|
|
1744
|
+
break;
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
_context2.t0 = generateGlobalInjectorCode;
|
|
1748
|
+
_context2.next = 5;
|
|
1749
|
+
return releaseNamePromise;
|
|
1750
|
+
|
|
1751
|
+
case 5:
|
|
1752
|
+
_context2.t1 = _context2.sent;
|
|
1753
|
+
_context2.t2 = internalOptions.injectReleasesMap;
|
|
1754
|
+
_context2.t3 = internalOptions.org;
|
|
1755
|
+
_context2.t4 = internalOptions.project;
|
|
1756
|
+
_context2.t5 = {
|
|
1757
|
+
release: _context2.t1,
|
|
1758
|
+
injectReleasesMap: _context2.t2,
|
|
1759
|
+
org: _context2.t3,
|
|
1760
|
+
project: _context2.t4
|
|
1761
|
+
};
|
|
1762
|
+
return _context2.abrupt("return", (0, _context2.t0)(_context2.t5));
|
|
1763
|
+
|
|
1764
|
+
case 13:
|
|
1765
|
+
return _context2.abrupt("return", undefined);
|
|
1766
|
+
|
|
1767
|
+
case 14:
|
|
1768
|
+
case "end":
|
|
1769
|
+
return _context2.stop();
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
}, _callee2);
|
|
1773
|
+
}))();
|
|
1662
1774
|
},
|
|
1663
1775
|
|
|
1664
1776
|
/**
|
|
@@ -1670,32 +1782,35 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
1670
1782
|
* want to transform the release injector file.
|
|
1671
1783
|
*/
|
|
1672
1784
|
transformInclude: function transformInclude(id) {
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1785
|
+
logger.debug('Called "transformInclude":', {
|
|
1786
|
+
id: id
|
|
1787
|
+
}); // We normalize the id because vite always passes `id` as a unix style path which causes problems when a user passes
|
|
1788
|
+
// a windows style path to `releaseInjectionTargets`
|
|
1677
1789
|
|
|
1678
|
-
|
|
1790
|
+
var normalizedId = path__default["default"].normalize(id); // We don't want to transform our injected code.
|
|
1791
|
+
|
|
1792
|
+
if (normalizedId === RELEASE_INJECTOR_ID) {
|
|
1679
1793
|
return false;
|
|
1680
1794
|
}
|
|
1681
1795
|
|
|
1682
1796
|
if (internalOptions.releaseInjectionTargets) {
|
|
1683
1797
|
// If there's an `releaseInjectionTargets` option transform (ie. inject the release varible) when the file path matches the option.
|
|
1684
1798
|
if (typeof internalOptions.releaseInjectionTargets === "function") {
|
|
1685
|
-
return internalOptions.releaseInjectionTargets(
|
|
1799
|
+
return internalOptions.releaseInjectionTargets(normalizedId);
|
|
1686
1800
|
}
|
|
1687
1801
|
|
|
1688
1802
|
return internalOptions.releaseInjectionTargets.some(function (entry) {
|
|
1689
1803
|
if (entry instanceof RegExp) {
|
|
1690
|
-
return entry.test(
|
|
1804
|
+
return entry.test(normalizedId);
|
|
1691
1805
|
} else {
|
|
1692
|
-
|
|
1806
|
+
var normalizedEntry = path__default["default"].normalize(entry);
|
|
1807
|
+
return normalizedId === normalizedEntry;
|
|
1693
1808
|
}
|
|
1694
1809
|
});
|
|
1695
1810
|
} else {
|
|
1696
|
-
var pathIsOrdinary = !
|
|
1811
|
+
var pathIsOrdinary = !normalizedId.includes("?") && !normalizedId.includes("#");
|
|
1697
1812
|
var pathHasAllowedFileEnding = ALLOWED_TRANSFORMATION_FILE_ENDINGS.some(function (allowedFileEnding) {
|
|
1698
|
-
return
|
|
1813
|
+
return normalizedId.endsWith(allowedFileEnding);
|
|
1699
1814
|
});
|
|
1700
1815
|
return pathIsOrdinary && pathHasAllowedFileEnding;
|
|
1701
1816
|
}
|
|
@@ -1709,10 +1824,9 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
1709
1824
|
* @param id Always the absolute (fully resolved) path to the module.
|
|
1710
1825
|
* @returns transformed code + source map
|
|
1711
1826
|
*/
|
|
1712
|
-
transform: function transform(code) {
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
level: "info"
|
|
1827
|
+
transform: function transform(code, id) {
|
|
1828
|
+
logger.debug('Called "transform":', {
|
|
1829
|
+
id: id
|
|
1716
1830
|
}); // The MagicString library allows us to generate sourcemaps for the changes we make to the user code.
|
|
1717
1831
|
|
|
1718
1832
|
var ms = new MagicString__default["default"](code); // Appending instead of prepending has less probability of mucking with user's source maps.
|
|
@@ -1738,69 +1852,119 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
1738
1852
|
* Sentry.io, uploading sourcemaps, associating commits and deploys and finalizing the release)
|
|
1739
1853
|
*/
|
|
1740
1854
|
writeBundle: function writeBundle() {
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1855
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
1856
|
+
var _releaseInjectionSpan;
|
|
1857
|
+
|
|
1858
|
+
var releasePipelineSpan, ctx, releaseName, _transaction, _transaction2, _transaction3;
|
|
1859
|
+
|
|
1860
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1861
|
+
while (1) {
|
|
1862
|
+
switch (_context3.prev = _context3.next) {
|
|
1863
|
+
case 0:
|
|
1864
|
+
logger.debug('Called "writeBundle"');
|
|
1865
|
+
(_releaseInjectionSpan = releaseInjectionSpan) === null || _releaseInjectionSpan === void 0 ? void 0 : _releaseInjectionSpan.finish();
|
|
1866
|
+
releasePipelineSpan = transaction && addSpanToTransaction({
|
|
1867
|
+
hub: sentryHub,
|
|
1868
|
+
parentSpan: transaction,
|
|
1869
|
+
logger: logger,
|
|
1870
|
+
cli: cli
|
|
1871
|
+
}, "function.plugin.release", "Release pipeline");
|
|
1872
|
+
sentryHub.addBreadcrumb({
|
|
1873
|
+
category: "writeBundle:start",
|
|
1874
|
+
level: "info"
|
|
1875
|
+
});
|
|
1876
|
+
ctx = {
|
|
1877
|
+
hub: sentryHub,
|
|
1878
|
+
parentSpan: releasePipelineSpan,
|
|
1879
|
+
logger: logger,
|
|
1880
|
+
cli: cli
|
|
1881
|
+
};
|
|
1882
|
+
_context3.next = 7;
|
|
1883
|
+
return releaseNamePromise;
|
|
1884
|
+
|
|
1885
|
+
case 7:
|
|
1886
|
+
releaseName = _context3.sent;
|
|
1887
|
+
_context3.prev = 8;
|
|
1888
|
+
_context3.next = 11;
|
|
1889
|
+
return createNewRelease(internalOptions, ctx, releaseName);
|
|
1890
|
+
|
|
1891
|
+
case 11:
|
|
1892
|
+
_context3.next = 13;
|
|
1893
|
+
return cleanArtifacts(internalOptions, ctx, releaseName);
|
|
1894
|
+
|
|
1895
|
+
case 13:
|
|
1896
|
+
_context3.next = 15;
|
|
1897
|
+
return uploadSourceMaps(internalOptions, ctx, releaseName);
|
|
1898
|
+
|
|
1899
|
+
case 15:
|
|
1900
|
+
_context3.next = 17;
|
|
1901
|
+
return setCommits(internalOptions, ctx, releaseName);
|
|
1902
|
+
|
|
1903
|
+
case 17:
|
|
1904
|
+
_context3.next = 19;
|
|
1905
|
+
return finalizeRelease(internalOptions, ctx, releaseName);
|
|
1906
|
+
|
|
1907
|
+
case 19:
|
|
1908
|
+
_context3.next = 21;
|
|
1909
|
+
return addDeploy(internalOptions, ctx, releaseName);
|
|
1910
|
+
|
|
1911
|
+
case 21:
|
|
1912
|
+
(_transaction = transaction) === null || _transaction === void 0 ? void 0 : _transaction.setStatus("ok");
|
|
1913
|
+
_context3.next = 28;
|
|
1914
|
+
break;
|
|
1915
|
+
|
|
1916
|
+
case 24:
|
|
1917
|
+
_context3.prev = 24;
|
|
1918
|
+
_context3.t0 = _context3["catch"](8);
|
|
1919
|
+
(_transaction2 = transaction) === null || _transaction2 === void 0 ? void 0 : _transaction2.setStatus("cancelled");
|
|
1920
|
+
handleError(_context3.t0, logger, internalOptions.errorHandler, sentryHub);
|
|
1921
|
+
|
|
1922
|
+
case 28:
|
|
1923
|
+
_context3.prev = 28;
|
|
1924
|
+
sentryHub.addBreadcrumb({
|
|
1925
|
+
category: "writeBundle:finish",
|
|
1926
|
+
level: "info"
|
|
1927
|
+
});
|
|
1928
|
+
releasePipelineSpan === null || releasePipelineSpan === void 0 ? void 0 : releasePipelineSpan.finish();
|
|
1929
|
+
(_transaction3 = transaction) === null || _transaction3 === void 0 ? void 0 : _transaction3.finish();
|
|
1930
|
+
_context3.next = 34;
|
|
1931
|
+
return sentryClient.flush().then(null, function () {
|
|
1932
|
+
logger.warn("Sending of telemetry failed");
|
|
1933
|
+
});
|
|
1934
|
+
|
|
1935
|
+
case 34:
|
|
1936
|
+
return _context3.finish(28);
|
|
1937
|
+
|
|
1938
|
+
case 35:
|
|
1939
|
+
case "end":
|
|
1940
|
+
return _context3.stop();
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
}, _callee3, null, [[8, 24, 28, 35]]);
|
|
1944
|
+
}))();
|
|
1789
1945
|
}
|
|
1790
1946
|
};
|
|
1791
1947
|
});
|
|
1792
1948
|
|
|
1793
|
-
function handleError(
|
|
1794
|
-
|
|
1949
|
+
function handleError(unknownError, logger, errorHandler, sentryHub) {
|
|
1950
|
+
if (unknownError instanceof Error) {
|
|
1951
|
+
logger.error(unknownError.message);
|
|
1952
|
+
} else {
|
|
1953
|
+
logger.error(String(unknownError));
|
|
1954
|
+
}
|
|
1795
1955
|
|
|
1796
1956
|
if (sentryHub) {
|
|
1797
|
-
captureMinimalError(
|
|
1957
|
+
captureMinimalError(unknownError, sentryHub);
|
|
1798
1958
|
}
|
|
1799
1959
|
|
|
1800
1960
|
if (errorHandler) {
|
|
1801
|
-
|
|
1961
|
+
if (unknownError instanceof Error) {
|
|
1962
|
+
errorHandler(unknownError);
|
|
1963
|
+
} else {
|
|
1964
|
+
errorHandler(new Error("An unknown error occured"));
|
|
1965
|
+
}
|
|
1802
1966
|
} else {
|
|
1803
|
-
throw
|
|
1967
|
+
throw unknownError;
|
|
1804
1968
|
}
|
|
1805
1969
|
}
|
|
1806
1970
|
/**
|