@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/esm/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createUnplugin } from 'unplugin';
|
|
2
2
|
import MagicString from 'magic-string';
|
|
3
|
-
import { NodeClient, Integrations, defaultStackParser, makeNodeTransport, Hub, makeMain } from '@sentry/node';
|
|
4
|
-
import '@sentry/tracing';
|
|
5
3
|
import SentryCli from '@sentry/cli';
|
|
4
|
+
import { NodeClient, defaultStackParser, makeNodeTransport, Hub, makeMain } from '@sentry/node';
|
|
5
|
+
import '@sentry/tracing';
|
|
6
|
+
import path from 'path';
|
|
6
7
|
|
|
7
8
|
function _regeneratorRuntime() {
|
|
8
9
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
@@ -822,12 +823,7 @@ function normalizeUserOptions(userOptions) {
|
|
|
822
823
|
dist: userOptions.dist,
|
|
823
824
|
errorHandler: userOptions.errorHandler,
|
|
824
825
|
configFile: userOptions.configFile
|
|
825
|
-
};
|
|
826
|
-
// This is not the final check (we need to call Sentry CLI at a later point)
|
|
827
|
-
// but we can already at this point make a first decision.
|
|
828
|
-
// @see `turnOffTelemetryForSelfHostedSentry` (telemetry.ts) for the second check.
|
|
829
|
-
|
|
830
|
-
options.telemetry = options.telemetry && options.url === SENTRY_SAAS_URL;
|
|
826
|
+
};
|
|
831
827
|
return options;
|
|
832
828
|
}
|
|
833
829
|
/**
|
|
@@ -940,30 +936,68 @@ function validateOptions(options, logger) {
|
|
|
940
936
|
return true;
|
|
941
937
|
}
|
|
942
938
|
|
|
943
|
-
|
|
939
|
+
var SENTRY_SAAS_HOSTNAME = "sentry.io";
|
|
940
|
+
function makeSentryClient(dsn, allowedToSendTelemetryPromise) {
|
|
944
941
|
var client = new NodeClient({
|
|
945
942
|
dsn: dsn,
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
integrations: [new Integrations.Http({
|
|
951
|
-
tracing: true
|
|
952
|
-
})],
|
|
943
|
+
tracesSampleRate: 1,
|
|
944
|
+
sampleRate: 1,
|
|
945
|
+
release: "0.2.1",
|
|
946
|
+
integrations: [],
|
|
953
947
|
tracePropagationTargets: ["sentry.io/api"],
|
|
954
948
|
stackParser: defaultStackParser,
|
|
955
|
-
transport
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
949
|
+
// We create a transport that stalls sending events until we know that we're allowed to (i.e. when Sentry CLI told
|
|
950
|
+
// us that the upload URL is the Sentry SaaS URL)
|
|
951
|
+
transport: function transport(nodeTransportOptions) {
|
|
952
|
+
var nodeTransport = makeNodeTransport(nodeTransportOptions);
|
|
953
|
+
return {
|
|
954
|
+
flush: function flush(timeout) {
|
|
955
|
+
return nodeTransport.flush(timeout);
|
|
956
|
+
},
|
|
957
|
+
send: function () {
|
|
958
|
+
var _send = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
|
|
959
|
+
var isAllowedToSend;
|
|
960
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
961
|
+
while (1) {
|
|
962
|
+
switch (_context.prev = _context.next) {
|
|
963
|
+
case 0:
|
|
964
|
+
_context.next = 2;
|
|
965
|
+
return allowedToSendTelemetryPromise;
|
|
966
|
+
|
|
967
|
+
case 2:
|
|
968
|
+
isAllowedToSend = _context.sent;
|
|
969
|
+
|
|
970
|
+
if (!isAllowedToSend) {
|
|
971
|
+
_context.next = 7;
|
|
972
|
+
break;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
return _context.abrupt("return", nodeTransport.send(request));
|
|
976
|
+
|
|
977
|
+
case 7:
|
|
978
|
+
return _context.abrupt("return", undefined);
|
|
979
|
+
|
|
980
|
+
case 8:
|
|
981
|
+
case "end":
|
|
982
|
+
return _context.stop();
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
}, _callee);
|
|
986
|
+
}));
|
|
962
987
|
|
|
963
|
-
|
|
988
|
+
function send(_x) {
|
|
989
|
+
return _send.apply(this, arguments);
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
return send;
|
|
993
|
+
}()
|
|
994
|
+
};
|
|
995
|
+
}
|
|
996
|
+
});
|
|
997
|
+
var hub = new Hub(client);
|
|
964
998
|
return {
|
|
965
|
-
|
|
966
|
-
|
|
999
|
+
sentryClient: client,
|
|
1000
|
+
sentryHub: hub
|
|
967
1001
|
};
|
|
968
1002
|
}
|
|
969
1003
|
/**
|
|
@@ -1005,8 +1039,10 @@ function captureMinimalError(error, hub) {
|
|
|
1005
1039
|
|
|
1006
1040
|
hub.captureException(sentryError);
|
|
1007
1041
|
}
|
|
1008
|
-
function
|
|
1009
|
-
var
|
|
1042
|
+
function addPluginOptionInformationToHub(options, hub, bundler) {
|
|
1043
|
+
var org = options.org,
|
|
1044
|
+
project = options.project,
|
|
1045
|
+
cleanArtifacts = options.cleanArtifacts,
|
|
1010
1046
|
finalize = options.finalize,
|
|
1011
1047
|
setCommits = options.setCommits,
|
|
1012
1048
|
injectReleasesMap = options.injectReleasesMap,
|
|
@@ -1046,61 +1082,107 @@ function addPluginOptionTags(options, hub) {
|
|
|
1046
1082
|
}
|
|
1047
1083
|
|
|
1048
1084
|
hub.setTag("node", process.version);
|
|
1085
|
+
hub.setTags({
|
|
1086
|
+
organization: org,
|
|
1087
|
+
project: project,
|
|
1088
|
+
bundler: bundler
|
|
1089
|
+
});
|
|
1090
|
+
hub.setUser({
|
|
1091
|
+
id: org
|
|
1092
|
+
});
|
|
1049
1093
|
}
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
*
|
|
1053
|
-
* We need to check and decide to use telemetry based on the CLI's respone to this call
|
|
1054
|
-
* because only at this time we checked a possibly existing .sentryclirc file. This file
|
|
1055
|
-
* could point to another URL than the default URL.
|
|
1056
|
-
*/
|
|
1057
|
-
|
|
1058
|
-
function turnOffTelemetryForSelfHostedSentry(_x, _x2) {
|
|
1059
|
-
return _turnOffTelemetryForSelfHostedSentry.apply(this, arguments);
|
|
1094
|
+
function shouldSendTelemetry(_x2) {
|
|
1095
|
+
return _shouldSendTelemetry.apply(this, arguments);
|
|
1060
1096
|
}
|
|
1061
1097
|
|
|
1062
|
-
function
|
|
1063
|
-
|
|
1098
|
+
function _shouldSendTelemetry() {
|
|
1099
|
+
_shouldSendTelemetry = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
1064
1100
|
var _cliInfo$split$, _cliInfo$split$$repla;
|
|
1065
1101
|
|
|
1066
|
-
var
|
|
1067
|
-
return _regeneratorRuntime().wrap(function
|
|
1102
|
+
var silent, org, project, authToken, url, vcsRemote, customHeader, dist, telemetry, dryRun, cli, cliInfo, cliInfoUrl;
|
|
1103
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1068
1104
|
while (1) {
|
|
1069
|
-
switch (
|
|
1105
|
+
switch (_context2.prev = _context2.next) {
|
|
1070
1106
|
case 0:
|
|
1071
|
-
|
|
1072
|
-
return cli.execute(["info"], false);
|
|
1107
|
+
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
|
|
1073
1108
|
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1109
|
+
if (!(telemetry === false)) {
|
|
1110
|
+
_context2.next = 3;
|
|
1111
|
+
break;
|
|
1112
|
+
}
|
|
1077
1113
|
|
|
1078
|
-
|
|
1079
|
-
client = hub.getClient();
|
|
1114
|
+
return _context2.abrupt("return", false);
|
|
1080
1115
|
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
}
|
|
1116
|
+
case 3:
|
|
1117
|
+
if (!dryRun) {
|
|
1118
|
+
_context2.next = 5;
|
|
1119
|
+
break;
|
|
1086
1120
|
}
|
|
1087
1121
|
|
|
1122
|
+
return _context2.abrupt("return", false);
|
|
1123
|
+
|
|
1088
1124
|
case 5:
|
|
1125
|
+
if (!(url === SENTRY_SAAS_URL)) {
|
|
1126
|
+
_context2.next = 7;
|
|
1127
|
+
break;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
return _context2.abrupt("return", true);
|
|
1131
|
+
|
|
1132
|
+
case 7:
|
|
1133
|
+
cli = new SentryCli(options.configFile, {
|
|
1134
|
+
url: url,
|
|
1135
|
+
authToken: authToken,
|
|
1136
|
+
org: org,
|
|
1137
|
+
project: project,
|
|
1138
|
+
vcsRemote: vcsRemote,
|
|
1139
|
+
dist: dist,
|
|
1140
|
+
silent: silent,
|
|
1141
|
+
customHeader: customHeader
|
|
1142
|
+
});
|
|
1143
|
+
_context2.prev = 8;
|
|
1144
|
+
_context2.next = 11;
|
|
1145
|
+
return cli.execute(["info"], false);
|
|
1146
|
+
|
|
1147
|
+
case 11:
|
|
1148
|
+
cliInfo = _context2.sent;
|
|
1149
|
+
_context2.next = 17;
|
|
1150
|
+
break;
|
|
1151
|
+
|
|
1152
|
+
case 14:
|
|
1153
|
+
_context2.prev = 14;
|
|
1154
|
+
_context2.t0 = _context2["catch"](8);
|
|
1155
|
+
throw new Error('Sentry CLI "info" command failed, make sure you have an auth token configured, and your `url` option is correct.');
|
|
1156
|
+
|
|
1157
|
+
case 17:
|
|
1158
|
+
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();
|
|
1159
|
+
|
|
1160
|
+
if (!(cliInfoUrl === undefined)) {
|
|
1161
|
+
_context2.next = 20;
|
|
1162
|
+
break;
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
return _context2.abrupt("return", false);
|
|
1166
|
+
|
|
1167
|
+
case 20:
|
|
1168
|
+
return _context2.abrupt("return", new URL(cliInfoUrl).hostname === SENTRY_SAAS_HOSTNAME);
|
|
1169
|
+
|
|
1170
|
+
case 21:
|
|
1089
1171
|
case "end":
|
|
1090
|
-
return
|
|
1172
|
+
return _context2.stop();
|
|
1091
1173
|
}
|
|
1092
1174
|
}
|
|
1093
|
-
},
|
|
1175
|
+
}, _callee2, null, [[8, 14]]);
|
|
1094
1176
|
}));
|
|
1095
|
-
return
|
|
1177
|
+
return _shouldSendTelemetry.apply(this, arguments);
|
|
1096
1178
|
}
|
|
1097
1179
|
|
|
1098
|
-
function createNewRelease(_x, _x2) {
|
|
1180
|
+
function createNewRelease(_x, _x2, _x3) {
|
|
1099
1181
|
return _createNewRelease.apply(this, arguments);
|
|
1100
1182
|
}
|
|
1101
1183
|
|
|
1102
1184
|
function _createNewRelease() {
|
|
1103
|
-
_createNewRelease = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options, ctx) {
|
|
1185
|
+
_createNewRelease = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options, ctx, releaseName) {
|
|
1104
1186
|
var span;
|
|
1105
1187
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1106
1188
|
while (1) {
|
|
@@ -1108,7 +1190,7 @@ function _createNewRelease() {
|
|
|
1108
1190
|
case 0:
|
|
1109
1191
|
span = addSpanToTransaction(ctx, "function.plugin.create_release");
|
|
1110
1192
|
_context.next = 3;
|
|
1111
|
-
return ctx.cli.releases["new"](
|
|
1193
|
+
return ctx.cli.releases["new"](releaseName);
|
|
1112
1194
|
|
|
1113
1195
|
case 3:
|
|
1114
1196
|
ctx.logger.info("Successfully created release.");
|
|
@@ -1124,12 +1206,12 @@ function _createNewRelease() {
|
|
|
1124
1206
|
return _createNewRelease.apply(this, arguments);
|
|
1125
1207
|
}
|
|
1126
1208
|
|
|
1127
|
-
function cleanArtifacts(
|
|
1209
|
+
function cleanArtifacts(_x4, _x5, _x6) {
|
|
1128
1210
|
return _cleanArtifacts.apply(this, arguments);
|
|
1129
1211
|
}
|
|
1130
1212
|
|
|
1131
1213
|
function _cleanArtifacts() {
|
|
1132
|
-
_cleanArtifacts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options, ctx) {
|
|
1214
|
+
_cleanArtifacts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options, ctx, releaseName) {
|
|
1133
1215
|
var span;
|
|
1134
1216
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1135
1217
|
while (1) {
|
|
@@ -1146,7 +1228,7 @@ function _cleanArtifacts() {
|
|
|
1146
1228
|
case 3:
|
|
1147
1229
|
span = addSpanToTransaction(ctx, "function.plugin.clean_artifacts");
|
|
1148
1230
|
_context2.next = 6;
|
|
1149
|
-
return ctx.cli.releases.execute(["releases", "files",
|
|
1231
|
+
return ctx.cli.releases.execute(["releases", "files", releaseName, "delete", "--all"], true);
|
|
1150
1232
|
|
|
1151
1233
|
case 6:
|
|
1152
1234
|
ctx.logger.info("Successfully cleaned previous artifacts.");
|
|
@@ -1162,12 +1244,12 @@ function _cleanArtifacts() {
|
|
|
1162
1244
|
return _cleanArtifacts.apply(this, arguments);
|
|
1163
1245
|
}
|
|
1164
1246
|
|
|
1165
|
-
function uploadSourceMaps(
|
|
1247
|
+
function uploadSourceMaps(_x7, _x8, _x9) {
|
|
1166
1248
|
return _uploadSourceMaps.apply(this, arguments);
|
|
1167
1249
|
}
|
|
1168
1250
|
|
|
1169
1251
|
function _uploadSourceMaps() {
|
|
1170
|
-
_uploadSourceMaps = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(options, ctx) {
|
|
1252
|
+
_uploadSourceMaps = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(options, ctx, releaseName) {
|
|
1171
1253
|
var span;
|
|
1172
1254
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1173
1255
|
while (1) {
|
|
@@ -1178,7 +1260,7 @@ function _uploadSourceMaps() {
|
|
|
1178
1260
|
// we only need to pass the include option here.
|
|
1179
1261
|
|
|
1180
1262
|
_context3.next = 4;
|
|
1181
|
-
return ctx.cli.releases.uploadSourceMaps(
|
|
1263
|
+
return ctx.cli.releases.uploadSourceMaps(releaseName, {
|
|
1182
1264
|
include: options.include
|
|
1183
1265
|
});
|
|
1184
1266
|
|
|
@@ -1196,12 +1278,12 @@ function _uploadSourceMaps() {
|
|
|
1196
1278
|
return _uploadSourceMaps.apply(this, arguments);
|
|
1197
1279
|
}
|
|
1198
1280
|
|
|
1199
|
-
function setCommits(
|
|
1281
|
+
function setCommits(_x10, _x11, _x12) {
|
|
1200
1282
|
return _setCommits.apply(this, arguments);
|
|
1201
1283
|
}
|
|
1202
1284
|
|
|
1203
1285
|
function _setCommits() {
|
|
1204
|
-
_setCommits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(options, ctx) {
|
|
1286
|
+
_setCommits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(options, ctx, releaseName) {
|
|
1205
1287
|
var span, _options$setCommits, auto, repo, commit, previousCommit, ignoreMissing, ignoreEmpty;
|
|
1206
1288
|
|
|
1207
1289
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
@@ -1220,7 +1302,7 @@ function _setCommits() {
|
|
|
1220
1302
|
span = addSpanToTransaction(ctx, "function.plugin.set_commits");
|
|
1221
1303
|
_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;
|
|
1222
1304
|
_context4.next = 7;
|
|
1223
|
-
return ctx.cli.releases.setCommits(
|
|
1305
|
+
return ctx.cli.releases.setCommits(releaseName, {
|
|
1224
1306
|
commit: commit,
|
|
1225
1307
|
previousCommit: previousCommit,
|
|
1226
1308
|
repo: repo,
|
|
@@ -1243,12 +1325,12 @@ function _setCommits() {
|
|
|
1243
1325
|
return _setCommits.apply(this, arguments);
|
|
1244
1326
|
}
|
|
1245
1327
|
|
|
1246
|
-
function finalizeRelease(
|
|
1328
|
+
function finalizeRelease(_x13, _x14, _x15) {
|
|
1247
1329
|
return _finalizeRelease.apply(this, arguments);
|
|
1248
1330
|
}
|
|
1249
1331
|
|
|
1250
1332
|
function _finalizeRelease() {
|
|
1251
|
-
_finalizeRelease = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(options, ctx) {
|
|
1333
|
+
_finalizeRelease = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(options, ctx, releaseName) {
|
|
1252
1334
|
var span;
|
|
1253
1335
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
1254
1336
|
while (1) {
|
|
@@ -1265,7 +1347,7 @@ function _finalizeRelease() {
|
|
|
1265
1347
|
case 3:
|
|
1266
1348
|
span = addSpanToTransaction(ctx, "function.plugin.finalize_release");
|
|
1267
1349
|
_context5.next = 6;
|
|
1268
|
-
return ctx.cli.releases.finalize(
|
|
1350
|
+
return ctx.cli.releases.finalize(releaseName);
|
|
1269
1351
|
|
|
1270
1352
|
case 6:
|
|
1271
1353
|
ctx.logger.info("Successfully finalized release.");
|
|
@@ -1281,12 +1363,12 @@ function _finalizeRelease() {
|
|
|
1281
1363
|
return _finalizeRelease.apply(this, arguments);
|
|
1282
1364
|
}
|
|
1283
1365
|
|
|
1284
|
-
function addDeploy(
|
|
1366
|
+
function addDeploy(_x16, _x17, _x18) {
|
|
1285
1367
|
return _addDeploy.apply(this, arguments);
|
|
1286
1368
|
}
|
|
1287
1369
|
|
|
1288
1370
|
function _addDeploy() {
|
|
1289
|
-
_addDeploy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(options, ctx) {
|
|
1371
|
+
_addDeploy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(options, ctx, releaseName) {
|
|
1290
1372
|
var span, _options$deploy, env, started, finished, time, name, url;
|
|
1291
1373
|
|
|
1292
1374
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
@@ -1305,7 +1387,7 @@ function _addDeploy() {
|
|
|
1305
1387
|
span = addSpanToTransaction(ctx, "function.plugin.deploy");
|
|
1306
1388
|
_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;
|
|
1307
1389
|
_context6.next = 7;
|
|
1308
|
-
return ctx.cli.releases.newDeploy(
|
|
1390
|
+
return ctx.cli.releases.newDeploy(releaseName, {
|
|
1309
1391
|
env: env,
|
|
1310
1392
|
started: started,
|
|
1311
1393
|
finished: finished,
|
|
@@ -1389,10 +1471,9 @@ function createLogger(options) {
|
|
|
1389
1471
|
}
|
|
1390
1472
|
|
|
1391
1473
|
// eslint-disable-next-line no-console
|
|
1392
|
-
(_console4 = console).log.apply(_console4, ["".concat(options.prefix, " Debug: ").concat(message)].concat(params));
|
|
1393
|
-
}
|
|
1474
|
+
(_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
|
|
1394
1475
|
|
|
1395
|
-
|
|
1476
|
+
}
|
|
1396
1477
|
}
|
|
1397
1478
|
};
|
|
1398
1479
|
}
|
|
@@ -1472,9 +1553,9 @@ function getDryRunCLI(cli, logger) {
|
|
|
1472
1553
|
};
|
|
1473
1554
|
}
|
|
1474
1555
|
|
|
1475
|
-
// We prefix the polyfill id with \0 to tell other plugins not to try to load or transform it.
|
|
1476
1556
|
// This hack is taken straight from https://rollupjs.org/guide/en/#resolveid.
|
|
1477
1557
|
// This probably doesn't work for all bundlers but for rollup it does.
|
|
1558
|
+
|
|
1478
1559
|
var RELEASE_INJECTOR_ID = "\0sentry-release-injector";
|
|
1479
1560
|
var ALLOWED_TRANSFORMATION_FILE_ENDINGS = [".js", ".ts", ".jsx", ".tsx", ".cjs", ".mjs"];
|
|
1480
1561
|
/**
|
|
@@ -1507,11 +1588,19 @@ var ALLOWED_TRANSFORMATION_FILE_ENDINGS = [".js", ".ts", ".jsx", ".tsx", ".cjs",
|
|
|
1507
1588
|
|
|
1508
1589
|
var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
1509
1590
|
var internalOptions = normalizeUserOptions(options);
|
|
1591
|
+
var allowedToSendTelemetryPromise = shouldSendTelemetry(internalOptions);
|
|
1510
1592
|
|
|
1511
|
-
var _makeSentryClient = makeSentryClient("https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
|
|
1512
|
-
sentryHub = _makeSentryClient.
|
|
1593
|
+
var _makeSentryClient = makeSentryClient("https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737", allowedToSendTelemetryPromise),
|
|
1594
|
+
sentryHub = _makeSentryClient.sentryHub,
|
|
1595
|
+
sentryClient = _makeSentryClient.sentryClient;
|
|
1513
1596
|
|
|
1514
|
-
|
|
1597
|
+
addPluginOptionInformationToHub(internalOptions, sentryHub, unpluginMetaContext.framework); //TODO: This call is problematic because as soon as we set our hub as the current hub
|
|
1598
|
+
// we might interfere with other plugins that use Sentry. However, for now, we'll
|
|
1599
|
+
// leave it in because without it, we can't get distributed traces (which are pretty nice)
|
|
1600
|
+
// Let's keep it until someone complains about interference.
|
|
1601
|
+
// The ideal solution would be a code change in the JS SDK but it's not a straight-forward fix.
|
|
1602
|
+
|
|
1603
|
+
makeMain(sentryHub);
|
|
1515
1604
|
var logger = createLogger({
|
|
1516
1605
|
hub: sentryHub,
|
|
1517
1606
|
prefix: "[sentry-".concat(unpluginMetaContext.framework, "-plugin]"),
|
|
@@ -1524,19 +1613,12 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1524
1613
|
}
|
|
1525
1614
|
|
|
1526
1615
|
var cli = getSentryCli(internalOptions, logger);
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
sentryHub.setTags({
|
|
1534
|
-
organization: internalOptions.org,
|
|
1535
|
-
project: internalOptions.project,
|
|
1536
|
-
bundler: unpluginMetaContext.framework
|
|
1537
|
-
});
|
|
1538
|
-
sentryHub.setUser({
|
|
1539
|
-
id: internalOptions.org
|
|
1616
|
+
var releaseNamePromise = new Promise(function (resolve) {
|
|
1617
|
+
if (options.release) {
|
|
1618
|
+
resolve(options.release);
|
|
1619
|
+
} else {
|
|
1620
|
+
resolve(cli.releases.proposeVersion());
|
|
1621
|
+
}
|
|
1540
1622
|
});
|
|
1541
1623
|
var transaction;
|
|
1542
1624
|
var releaseInjectionSpan;
|
|
@@ -1550,28 +1632,31 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1550
1632
|
*/
|
|
1551
1633
|
buildStart: function buildStart() {
|
|
1552
1634
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1635
|
+
var isAllowedToSendToSendTelemetry, releaseName;
|
|
1553
1636
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1554
1637
|
while (1) {
|
|
1555
1638
|
switch (_context.prev = _context.next) {
|
|
1556
1639
|
case 0:
|
|
1557
|
-
|
|
1558
|
-
|
|
1640
|
+
logger.debug("Called 'buildStart'");
|
|
1641
|
+
_context.next = 3;
|
|
1642
|
+
return allowedToSendTelemetryPromise;
|
|
1559
1643
|
|
|
1560
|
-
case
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1644
|
+
case 3:
|
|
1645
|
+
isAllowedToSendToSendTelemetry = _context.sent;
|
|
1646
|
+
|
|
1647
|
+
if (isAllowedToSendToSendTelemetry) {
|
|
1648
|
+
logger.info("Sending error and performance telemetry data to Sentry.");
|
|
1649
|
+
logger.info("To disable telemetry, set `options.telemetry` to `false`.");
|
|
1564
1650
|
}
|
|
1565
1651
|
|
|
1566
|
-
_context.next =
|
|
1567
|
-
return
|
|
1652
|
+
_context.next = 7;
|
|
1653
|
+
return releaseNamePromise;
|
|
1568
1654
|
|
|
1569
|
-
case
|
|
1570
|
-
|
|
1655
|
+
case 7:
|
|
1656
|
+
releaseName = _context.sent;
|
|
1571
1657
|
|
|
1572
|
-
case 6:
|
|
1573
1658
|
// At this point, we either have determined a release or we have to bail
|
|
1574
|
-
if (!
|
|
1659
|
+
if (!releaseName) {
|
|
1575
1660
|
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);
|
|
1576
1661
|
}
|
|
1577
1662
|
|
|
@@ -1586,7 +1671,7 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1586
1671
|
cli: cli
|
|
1587
1672
|
}, "function.plugin.inject_release", "Release injection");
|
|
1588
1673
|
|
|
1589
|
-
case
|
|
1674
|
+
case 11:
|
|
1590
1675
|
case "end":
|
|
1591
1676
|
return _context.stop();
|
|
1592
1677
|
}
|
|
@@ -1608,10 +1693,10 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1608
1693
|
*/
|
|
1609
1694
|
resolveId: function resolveId(id, importer, _ref) {
|
|
1610
1695
|
var isEntry = _ref.isEntry;
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1696
|
+
logger.debug('Called "resolveId":', {
|
|
1697
|
+
id: id,
|
|
1698
|
+
importer: importer,
|
|
1699
|
+
isEntry: isEntry
|
|
1615
1700
|
});
|
|
1616
1701
|
|
|
1617
1702
|
if (id === RELEASE_INJECTOR_ID) {
|
|
@@ -1621,9 +1706,9 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1621
1706
|
}
|
|
1622
1707
|
},
|
|
1623
1708
|
loadInclude: function loadInclude(id) {
|
|
1624
|
-
logger.
|
|
1709
|
+
logger.debug('Called "loadInclude":', {
|
|
1625
1710
|
id: id
|
|
1626
|
-
})
|
|
1711
|
+
});
|
|
1627
1712
|
return id === RELEASE_INJECTOR_ID;
|
|
1628
1713
|
},
|
|
1629
1714
|
|
|
@@ -1635,21 +1720,47 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1635
1720
|
* @returns The global injector code when we load the "sentry-release-injector" module. Otherwise returns `undefined`.
|
|
1636
1721
|
*/
|
|
1637
1722
|
load: function load(id) {
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1723
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
1724
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1725
|
+
while (1) {
|
|
1726
|
+
switch (_context2.prev = _context2.next) {
|
|
1727
|
+
case 0:
|
|
1728
|
+
logger.debug('Called "load":', {
|
|
1729
|
+
id: id
|
|
1730
|
+
});
|
|
1642
1731
|
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1732
|
+
if (!(id === RELEASE_INJECTOR_ID)) {
|
|
1733
|
+
_context2.next = 13;
|
|
1734
|
+
break;
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
_context2.t0 = generateGlobalInjectorCode;
|
|
1738
|
+
_context2.next = 5;
|
|
1739
|
+
return releaseNamePromise;
|
|
1740
|
+
|
|
1741
|
+
case 5:
|
|
1742
|
+
_context2.t1 = _context2.sent;
|
|
1743
|
+
_context2.t2 = internalOptions.injectReleasesMap;
|
|
1744
|
+
_context2.t3 = internalOptions.org;
|
|
1745
|
+
_context2.t4 = internalOptions.project;
|
|
1746
|
+
_context2.t5 = {
|
|
1747
|
+
release: _context2.t1,
|
|
1748
|
+
injectReleasesMap: _context2.t2,
|
|
1749
|
+
org: _context2.t3,
|
|
1750
|
+
project: _context2.t4
|
|
1751
|
+
};
|
|
1752
|
+
return _context2.abrupt("return", (0, _context2.t0)(_context2.t5));
|
|
1753
|
+
|
|
1754
|
+
case 13:
|
|
1755
|
+
return _context2.abrupt("return", undefined);
|
|
1756
|
+
|
|
1757
|
+
case 14:
|
|
1758
|
+
case "end":
|
|
1759
|
+
return _context2.stop();
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
}, _callee2);
|
|
1763
|
+
}))();
|
|
1653
1764
|
},
|
|
1654
1765
|
|
|
1655
1766
|
/**
|
|
@@ -1661,32 +1772,35 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1661
1772
|
* want to transform the release injector file.
|
|
1662
1773
|
*/
|
|
1663
1774
|
transformInclude: function transformInclude(id) {
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1775
|
+
logger.debug('Called "transformInclude":', {
|
|
1776
|
+
id: id
|
|
1777
|
+
}); // We normalize the id because vite always passes `id` as a unix style path which causes problems when a user passes
|
|
1778
|
+
// a windows style path to `releaseInjectionTargets`
|
|
1668
1779
|
|
|
1669
|
-
|
|
1780
|
+
var normalizedId = path.normalize(id); // We don't want to transform our injected code.
|
|
1781
|
+
|
|
1782
|
+
if (normalizedId === RELEASE_INJECTOR_ID) {
|
|
1670
1783
|
return false;
|
|
1671
1784
|
}
|
|
1672
1785
|
|
|
1673
1786
|
if (internalOptions.releaseInjectionTargets) {
|
|
1674
1787
|
// If there's an `releaseInjectionTargets` option transform (ie. inject the release varible) when the file path matches the option.
|
|
1675
1788
|
if (typeof internalOptions.releaseInjectionTargets === "function") {
|
|
1676
|
-
return internalOptions.releaseInjectionTargets(
|
|
1789
|
+
return internalOptions.releaseInjectionTargets(normalizedId);
|
|
1677
1790
|
}
|
|
1678
1791
|
|
|
1679
1792
|
return internalOptions.releaseInjectionTargets.some(function (entry) {
|
|
1680
1793
|
if (entry instanceof RegExp) {
|
|
1681
|
-
return entry.test(
|
|
1794
|
+
return entry.test(normalizedId);
|
|
1682
1795
|
} else {
|
|
1683
|
-
|
|
1796
|
+
var normalizedEntry = path.normalize(entry);
|
|
1797
|
+
return normalizedId === normalizedEntry;
|
|
1684
1798
|
}
|
|
1685
1799
|
});
|
|
1686
1800
|
} else {
|
|
1687
|
-
var pathIsOrdinary = !
|
|
1801
|
+
var pathIsOrdinary = !normalizedId.includes("?") && !normalizedId.includes("#");
|
|
1688
1802
|
var pathHasAllowedFileEnding = ALLOWED_TRANSFORMATION_FILE_ENDINGS.some(function (allowedFileEnding) {
|
|
1689
|
-
return
|
|
1803
|
+
return normalizedId.endsWith(allowedFileEnding);
|
|
1690
1804
|
});
|
|
1691
1805
|
return pathIsOrdinary && pathHasAllowedFileEnding;
|
|
1692
1806
|
}
|
|
@@ -1700,10 +1814,9 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1700
1814
|
* @param id Always the absolute (fully resolved) path to the module.
|
|
1701
1815
|
* @returns transformed code + source map
|
|
1702
1816
|
*/
|
|
1703
|
-
transform: function transform(code) {
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
level: "info"
|
|
1817
|
+
transform: function transform(code, id) {
|
|
1818
|
+
logger.debug('Called "transform":', {
|
|
1819
|
+
id: id
|
|
1707
1820
|
}); // The MagicString library allows us to generate sourcemaps for the changes we make to the user code.
|
|
1708
1821
|
|
|
1709
1822
|
var ms = new MagicString(code); // Appending instead of prepending has less probability of mucking with user's source maps.
|
|
@@ -1729,69 +1842,119 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1729
1842
|
* Sentry.io, uploading sourcemaps, associating commits and deploys and finalizing the release)
|
|
1730
1843
|
*/
|
|
1731
1844
|
writeBundle: function writeBundle() {
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
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
|
-
|
|
1845
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
1846
|
+
var _releaseInjectionSpan;
|
|
1847
|
+
|
|
1848
|
+
var releasePipelineSpan, ctx, releaseName, _transaction, _transaction2, _transaction3;
|
|
1849
|
+
|
|
1850
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1851
|
+
while (1) {
|
|
1852
|
+
switch (_context3.prev = _context3.next) {
|
|
1853
|
+
case 0:
|
|
1854
|
+
logger.debug('Called "writeBundle"');
|
|
1855
|
+
(_releaseInjectionSpan = releaseInjectionSpan) === null || _releaseInjectionSpan === void 0 ? void 0 : _releaseInjectionSpan.finish();
|
|
1856
|
+
releasePipelineSpan = transaction && addSpanToTransaction({
|
|
1857
|
+
hub: sentryHub,
|
|
1858
|
+
parentSpan: transaction,
|
|
1859
|
+
logger: logger,
|
|
1860
|
+
cli: cli
|
|
1861
|
+
}, "function.plugin.release", "Release pipeline");
|
|
1862
|
+
sentryHub.addBreadcrumb({
|
|
1863
|
+
category: "writeBundle:start",
|
|
1864
|
+
level: "info"
|
|
1865
|
+
});
|
|
1866
|
+
ctx = {
|
|
1867
|
+
hub: sentryHub,
|
|
1868
|
+
parentSpan: releasePipelineSpan,
|
|
1869
|
+
logger: logger,
|
|
1870
|
+
cli: cli
|
|
1871
|
+
};
|
|
1872
|
+
_context3.next = 7;
|
|
1873
|
+
return releaseNamePromise;
|
|
1874
|
+
|
|
1875
|
+
case 7:
|
|
1876
|
+
releaseName = _context3.sent;
|
|
1877
|
+
_context3.prev = 8;
|
|
1878
|
+
_context3.next = 11;
|
|
1879
|
+
return createNewRelease(internalOptions, ctx, releaseName);
|
|
1880
|
+
|
|
1881
|
+
case 11:
|
|
1882
|
+
_context3.next = 13;
|
|
1883
|
+
return cleanArtifacts(internalOptions, ctx, releaseName);
|
|
1884
|
+
|
|
1885
|
+
case 13:
|
|
1886
|
+
_context3.next = 15;
|
|
1887
|
+
return uploadSourceMaps(internalOptions, ctx, releaseName);
|
|
1888
|
+
|
|
1889
|
+
case 15:
|
|
1890
|
+
_context3.next = 17;
|
|
1891
|
+
return setCommits(internalOptions, ctx, releaseName);
|
|
1892
|
+
|
|
1893
|
+
case 17:
|
|
1894
|
+
_context3.next = 19;
|
|
1895
|
+
return finalizeRelease(internalOptions, ctx, releaseName);
|
|
1896
|
+
|
|
1897
|
+
case 19:
|
|
1898
|
+
_context3.next = 21;
|
|
1899
|
+
return addDeploy(internalOptions, ctx, releaseName);
|
|
1900
|
+
|
|
1901
|
+
case 21:
|
|
1902
|
+
(_transaction = transaction) === null || _transaction === void 0 ? void 0 : _transaction.setStatus("ok");
|
|
1903
|
+
_context3.next = 28;
|
|
1904
|
+
break;
|
|
1905
|
+
|
|
1906
|
+
case 24:
|
|
1907
|
+
_context3.prev = 24;
|
|
1908
|
+
_context3.t0 = _context3["catch"](8);
|
|
1909
|
+
(_transaction2 = transaction) === null || _transaction2 === void 0 ? void 0 : _transaction2.setStatus("cancelled");
|
|
1910
|
+
handleError(_context3.t0, logger, internalOptions.errorHandler, sentryHub);
|
|
1911
|
+
|
|
1912
|
+
case 28:
|
|
1913
|
+
_context3.prev = 28;
|
|
1914
|
+
sentryHub.addBreadcrumb({
|
|
1915
|
+
category: "writeBundle:finish",
|
|
1916
|
+
level: "info"
|
|
1917
|
+
});
|
|
1918
|
+
releasePipelineSpan === null || releasePipelineSpan === void 0 ? void 0 : releasePipelineSpan.finish();
|
|
1919
|
+
(_transaction3 = transaction) === null || _transaction3 === void 0 ? void 0 : _transaction3.finish();
|
|
1920
|
+
_context3.next = 34;
|
|
1921
|
+
return sentryClient.flush().then(null, function () {
|
|
1922
|
+
logger.warn("Sending of telemetry failed");
|
|
1923
|
+
});
|
|
1924
|
+
|
|
1925
|
+
case 34:
|
|
1926
|
+
return _context3.finish(28);
|
|
1927
|
+
|
|
1928
|
+
case 35:
|
|
1929
|
+
case "end":
|
|
1930
|
+
return _context3.stop();
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
}, _callee3, null, [[8, 24, 28, 35]]);
|
|
1934
|
+
}))();
|
|
1780
1935
|
}
|
|
1781
1936
|
};
|
|
1782
1937
|
});
|
|
1783
1938
|
|
|
1784
|
-
function handleError(
|
|
1785
|
-
|
|
1939
|
+
function handleError(unknownError, logger, errorHandler, sentryHub) {
|
|
1940
|
+
if (unknownError instanceof Error) {
|
|
1941
|
+
logger.error(unknownError.message);
|
|
1942
|
+
} else {
|
|
1943
|
+
logger.error(String(unknownError));
|
|
1944
|
+
}
|
|
1786
1945
|
|
|
1787
1946
|
if (sentryHub) {
|
|
1788
|
-
captureMinimalError(
|
|
1947
|
+
captureMinimalError(unknownError, sentryHub);
|
|
1789
1948
|
}
|
|
1790
1949
|
|
|
1791
1950
|
if (errorHandler) {
|
|
1792
|
-
|
|
1951
|
+
if (unknownError instanceof Error) {
|
|
1952
|
+
errorHandler(unknownError);
|
|
1953
|
+
} else {
|
|
1954
|
+
errorHandler(new Error("An unknown error occured"));
|
|
1955
|
+
}
|
|
1793
1956
|
} else {
|
|
1794
|
-
throw
|
|
1957
|
+
throw unknownError;
|
|
1795
1958
|
}
|
|
1796
1959
|
}
|
|
1797
1960
|
/**
|