Newer
Older
238001
238002
238003
238004
238005
238006
238007
238008
238009
238010
238011
238012
238013
238014
238015
238016
238017
* @inheritDoc
*/
__init() {this.name = Mongo.id;}
/**
* @inheritDoc
*/
constructor(options = {}) {;Mongo.prototype.__init.call(this);
this._operations = Array.isArray(options.operations) ? options.operations : (OPERATIONS );
this._describeOperations = 'describeOperations' in options ? options.describeOperations : true;
this._useMongoose = !!options.useMongoose;
}
/**
* @inheritDoc
*/
setupOnce(_, getCurrentHub) {
if ((0,_utils_node_utils_js__WEBPACK_IMPORTED_MODULE_0__.shouldDisableAutoInstrumentation)(getCurrentHub)) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.log('Mongo Integration is skipped because of instrumenter configuration.');
return;
}
const moduleName = this._useMongoose ? 'mongoose' : 'mongodb';
const pkg = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.loadModule)(moduleName);
if (!pkg) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.error(`Mongo Integration was unable to require \`${moduleName}\` package.`);
238028
238029
238030
238031
238032
238033
238034
238035
238036
238037
238038
238039
238040
238041
238042
238043
238044
238045
238046
238047
238048
return;
}
this._instrumentOperations(pkg.Collection, this._operations, getCurrentHub);
}
/**
* Patches original collection methods
*/
_instrumentOperations(collection, operations, getCurrentHub) {
operations.forEach((operation) => this._patchOperation(collection, operation, getCurrentHub));
}
/**
* Patches original collection to utilize our tracing functionality
*/
_patchOperation(collection, operation, getCurrentHub) {
if (!(operation in collection.prototype)) return;
const getSpanContext = this._getSpanContextFromOperationArguments.bind(this);
(0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.fill)(collection.prototype, operation, function (orig) {
return function ( ...args) {
const lastArg = args[args.length - 1];
const scope = getCurrentHub().getScope();
const parentSpan = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([scope, 'optionalAccess', _2 => _2.getSpan, 'call', _3 => _3()]);
// Check if the operation was passed a callback. (mapReduce requires a different check, as
// its (non-callback) arguments can also be functions.)
if (typeof lastArg !== 'function' || (operation === 'mapReduce' && args.length === 2)) {
const span = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([parentSpan, 'optionalAccess', _4 => _4.startChild, 'call', _5 => _5(getSpanContext(this, operation, args))]);
const maybePromiseOrCursor = orig.call(this, ...args);
if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_5__.isThenable)(maybePromiseOrCursor)) {
return maybePromiseOrCursor.then((res) => {
(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([span, 'optionalAccess', _6 => _6.finish, 'call', _7 => _7()]);
return res;
});
238066
238067
238068
238069
238070
238071
238072
238073
238074
238075
238076
238077
238078
238079
238080
238081
238082
}
// If the operation returns a Cursor
// we need to attach a listener to it to finish the span when the cursor is closed.
else if (isCursor(maybePromiseOrCursor)) {
const cursor = maybePromiseOrCursor ;
try {
cursor.once('close', () => {
(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([span, 'optionalAccess', _8 => _8.finish, 'call', _9 => _9()]);
});
} catch (e) {
// If the cursor is already closed, `once` will throw an error. In that case, we can
// finish the span immediately.
(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([span, 'optionalAccess', _10 => _10.finish, 'call', _11 => _11()]);
}
return cursor;
} else {
(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([span, 'optionalAccess', _12 => _12.finish, 'call', _13 => _13()]);
return maybePromiseOrCursor;
}
}
const span = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([parentSpan, 'optionalAccess', _14 => _14.startChild, 'call', _15 => _15(getSpanContext(this, operation, args.slice(0, -1)))]);
return orig.call(this, ...args.slice(0, -1), function (err, result) {
(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([span, 'optionalAccess', _16 => _16.finish, 'call', _17 => _17()]);
238093
238094
238095
238096
238097
238098
238099
238100
238101
238102
238103
238104
238105
238106
238107
238108
238109
238110
238111
238112
238113
238114
238115
238116
238117
238118
238119
238120
238121
238122
238123
238124
238125
238126
238127
238128
238129
238130
238131
238132
238133
238134
238135
238136
238137
238138
238139
238140
238141
238142
238143
238144
238145
238146
238147
238148
238149
238150
238151
238152
lastArg(err, result);
});
};
});
}
/**
* Form a SpanContext based on the user input to a given operation.
*/
_getSpanContextFromOperationArguments(
collection,
operation,
args,
) {
const data = {
collectionName: collection.collectionName,
dbName: collection.dbName,
namespace: collection.namespace,
};
const spanContext = {
op: 'db',
description: operation,
data,
};
// If the operation takes no arguments besides `options` and `callback`, or if argument
// collection is disabled for this operation, just return early.
const signature = OPERATION_SIGNATURES[operation];
const shouldDescribe = Array.isArray(this._describeOperations)
? this._describeOperations.includes(operation)
: this._describeOperations;
if (!signature || !shouldDescribe) {
return spanContext;
}
try {
// Special case for `mapReduce`, as the only one accepting functions as arguments.
if (operation === 'mapReduce') {
const [map, reduce] = args ;
data[signature[0]] = typeof map === 'string' ? map : map.name || '<anonymous>';
data[signature[1]] = typeof reduce === 'string' ? reduce : reduce.name || '<anonymous>';
} else {
for (let i = 0; i < signature.length; i++) {
data[signature[i]] = JSON.stringify(args[i]);
}
}
} catch (_oO) {
// no-empty
}
return spanContext;
}
}Mongo.__initStatic();
//# sourceMappingURL=mongo.js.map
/***/ }),
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Prisma": () => (/* binding */ Prisma)
/* harmony export */ });
/* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1558);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1548);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1544);
/* harmony import */ var _utils_node_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1620);
238165
238166
238167
238168
238169
238170
238171
238172
238173
238174
238175
238176
238177
238178
238179
238180
238181
238182
238183
238184
238185
238186
238187
238188
238189
238190
238191
238192
238193
238194
238195
238196
function isValidPrismaClient(possibleClient) {
return possibleClient && !!(possibleClient )['$use'];
}
/** Tracing integration for @prisma/client package */
class Prisma {
/**
* @inheritDoc
*/
static __initStatic() {this.id = 'Prisma';}
/**
* @inheritDoc
*/
__init() {this.name = Prisma.id;}
/**
* Prisma ORM Client Instance
*/
/**
* @inheritDoc
*/
constructor(options = {}) {;Prisma.prototype.__init.call(this);
if (isValidPrismaClient(options.client)) {
this._client = options.client;
} else {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) &&
_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.logger.warn(
`Unsupported Prisma client provided to PrismaIntegration. Provided client: ${JSON.stringify(options.client)}`,
);
}
}
/**
* @inheritDoc
*/
setupOnce(_, getCurrentHub) {
if (!this._client) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.logger.error('PrismaIntegration is missing a Prisma Client Instance');
return;
}
if ((0,_utils_node_utils_js__WEBPACK_IMPORTED_MODULE_1__.shouldDisableAutoInstrumentation)(getCurrentHub)) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.logger.log('Prisma Integration is skipped because of instrumenter configuration.');
return;
}
this._client.$use((params, next) => {
const scope = getCurrentHub().getScope();
const parentSpan = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([scope, 'optionalAccess', _2 => _2.getSpan, 'call', _3 => _3()]);
const action = params.action;
const model = params.model;
const span = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([parentSpan, 'optionalAccess', _4 => _4.startChild, 'call', _5 => _5({
description: model ? `${model} ${action}` : action,
op: 'db.sql.prisma',
})]);
const rv = next(params);
if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.isThenable)(rv)) {
return rv.then((res) => {
(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([span, 'optionalAccess', _6 => _6.finish, 'call', _7 => _7()]);
return res;
});
}
(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([span, 'optionalAccess', _8 => _8.finish, 'call', _9 => _9()]);
return rv;
});
}
}Prisma.__initStatic();
//# sourceMappingURL=prisma.js.map
/***/ }),
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "GraphQL": () => (/* binding */ GraphQL)
/* harmony export */ });
/* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1558);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1548);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1540);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1545);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1544);
/* harmony import */ var _utils_node_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1620);
238263
238264
238265
238266
238267
238268
238269
238270
238271
238272
238273
238274
238275
238276
238277
238278
238279
238280
238281
238282
/** Tracing integration for graphql package */
class GraphQL {constructor() { GraphQL.prototype.__init.call(this); }
/**
* @inheritDoc
*/
static __initStatic() {this.id = 'GraphQL';}
/**
* @inheritDoc
*/
__init() {this.name = GraphQL.id;}
/**
* @inheritDoc
*/
setupOnce(_, getCurrentHub) {
if ((0,_utils_node_utils_js__WEBPACK_IMPORTED_MODULE_0__.shouldDisableAutoInstrumentation)(getCurrentHub)) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.log('GraphQL Integration is skipped because of instrumenter configuration.');
return;
}
const pkg = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.loadModule)
('graphql/execution/execute.js');
if (!pkg) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.error('GraphQL Integration was unable to require graphql/execution package.');
return;
}
(0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.fill)(pkg, 'execute', function (orig) {
return function ( ...args) {
const scope = getCurrentHub().getScope();
const parentSpan = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([scope, 'optionalAccess', _2 => _2.getSpan, 'call', _3 => _3()]);
const span = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([parentSpan, 'optionalAccess', _4 => _4.startChild, 'call', _5 => _5({
description: 'execute',
op: 'graphql.execute',
})]);
(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([scope, 'optionalAccess', _6 => _6.setSpan, 'call', _7 => _7(span)]);
const rv = orig.call(this, ...args);
if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_5__.isThenable)(rv)) {
return rv.then((res) => {
(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([span, 'optionalAccess', _8 => _8.finish, 'call', _9 => _9()]);
(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([scope, 'optionalAccess', _10 => _10.setSpan, 'call', _11 => _11(parentSpan)]);
return res;
});
}
(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([span, 'optionalAccess', _12 => _12.finish, 'call', _13 => _13()]);
(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([scope, 'optionalAccess', _14 => _14.setSpan, 'call', _15 => _15(parentSpan)]);
return rv;
};
});
}
}GraphQL.__initStatic();
//# sourceMappingURL=graphql.js.map
/***/ }),
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Apollo": () => (/* binding */ Apollo)
/* harmony export */ });
/* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1558);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1548);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1540);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1545);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1542);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1544);
/* harmony import */ var _utils_node_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1620);
238348
238349
238350
238351
238352
238353
238354
238355
238356
238357
238358
238359
238360
238361
238362
238363
238364
238365
238366
238367
/** Tracing integration for Apollo */
class Apollo {constructor() { Apollo.prototype.__init.call(this); }
/**
* @inheritDoc
*/
static __initStatic() {this.id = 'Apollo';}
/**
* @inheritDoc
*/
__init() {this.name = Apollo.id;}
/**
* @inheritDoc
*/
setupOnce(_, getCurrentHub) {
if ((0,_utils_node_utils_js__WEBPACK_IMPORTED_MODULE_0__.shouldDisableAutoInstrumentation)(getCurrentHub)) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.log('Apollo Integration is skipped because of instrumenter configuration.');
return;
}
const pkg = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.loadModule)
('apollo-server-core');
if (!pkg) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.error('Apollo Integration was unable to require apollo-server-core package.');
return;
}
/**
* Iterate over resolvers of the ApolloServer instance before schemas are constructed.
*/
(0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.fill)(pkg.ApolloServerBase.prototype, 'constructSchema', function (orig) {
return function () {
if (!this.config.resolvers) {
if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__)) {
if (this.config.schema) {
_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.warn(
'Apollo integration is not able to trace `ApolloServer` instances constructed via `schema` property.',
);
} else if (this.config.modules) {
_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.warn(
'Apollo integration is not able to trace `ApolloServer` instances constructed via `modules` property.',
);
}
_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.error('Skipping tracing as no resolvers found on the `ApolloServer` instance.');
}
return orig.call(this);
}
const resolvers = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.arrayify)(this.config.resolvers);
238406
238407
238408
238409
238410
238411
238412
238413
238414
238415
238416
238417
238418
238419
238420
238421
238422
238423
238424
238425
238426
238427
238428
238429
238430
238431
238432
238433
238434
238435
this.config.resolvers = resolvers.map(model => {
Object.keys(model).forEach(resolverGroupName => {
Object.keys(model[resolverGroupName]).forEach(resolverName => {
if (typeof model[resolverGroupName][resolverName] !== 'function') {
return;
}
wrapResolver(model, resolverGroupName, resolverName, getCurrentHub);
});
});
return model;
});
return orig.call(this);
};
});
}
}Apollo.__initStatic();
/**
* Wrap a single resolver which can be a parent of other resolvers and/or db operations.
*/
function wrapResolver(
model,
resolverGroupName,
resolverName,
getCurrentHub,
) {
(0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.fill)(model[resolverGroupName], resolverName, function (orig) {
return function ( ...args) {
const scope = getCurrentHub().getScope();
const parentSpan = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_5__._optionalChain)([scope, 'optionalAccess', _2 => _2.getSpan, 'call', _3 => _3()]);
const span = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_5__._optionalChain)([parentSpan, 'optionalAccess', _4 => _4.startChild, 'call', _5 => _5({
description: `${resolverGroupName}.${resolverName}`,
op: 'graphql.resolve',
})]);
const rv = orig.call(this, ...args);
if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_6__.isThenable)(rv)) {
return rv.then((res) => {
(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_5__._optionalChain)([span, 'optionalAccess', _6 => _6.finish, 'call', _7 => _7()]);
return res;
});
}
(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_5__._optionalChain)([span, 'optionalAccess', _8 => _8.finish, 'call', _9 => _9()]);
return rv;
};
});
}
//# sourceMappingURL=apollo.js.map
/***/ }),
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "BROWSER_TRACING_INTEGRATION_ID": () => (/* binding */ BROWSER_TRACING_INTEGRATION_ID),
/* harmony export */ "BrowserTracing": () => (/* binding */ BrowserTracing),
/* harmony export */ "getMetaContent": () => (/* binding */ getMetaContent)
/* harmony export */ });
/* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1558);
/* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(1576);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1548);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(1607);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(1583);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(1546);
/* harmony import */ var _hubextensions_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(1610);
/* harmony import */ var _idletransaction_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1614);
/* harmony import */ var _backgroundtab_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1644);
/* harmony import */ var _metrics_index_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1631);
/* harmony import */ var _request_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1630);
/* harmony import */ var _router_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1628);
/* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(1629);
238496
238497
238498
238499
238500
238501
238502
238503
238504
238505
238506
238507
238508
238509
238510
238511
238512
238513
238514
238515
238516
238517
238518
238519
238520
238521
238522
238523
238524
238525
238526
238527
238528
238529
238530
238531
238532
238533
238534
238535
238536
238537
238538
238539
238540
238541
238542
238543
238544
238545
238546
238547
238548
238549
238550
238551
238552
238553
238554
238555
238556
238557
238558
238559
238560
238561
238562
238563
238564
238565
238566
238567
238568
238569
238570
238571
238572
238573
238574
238575
238576
238577
238578
238579
238580
238581
238582
238583
238584
238585
238586
238587
238588
238589
238590
238591
238592
238593
238594
238595
238596
238597
238598
238599
238600
238601
238602
238603
238604
238605
238606
238607
238608
238609
238610
238611
238612
238613
238614
238615
238616
238617
238618
238619
238620
238621
238622
238623
238624
238625
238626
238627
238628
238629
238630
238631
238632
238633
238634
238635
238636
238637
238638
238639
238640
238641
238642
238643
238644
238645
238646
238647
238648
238649
238650
238651
238652
238653
238654
238655
238656
238657
238658
238659
238660
238661
238662
238663
238664
238665
238666
238667
238668
238669
238670
238671
238672
238673
238674
238675
238676
238677
238678
238679
238680
238681
238682
238683
238684
238685
238686
238687
238688
238689
238690
238691
238692
238693
238694
238695
238696
238697
238698
238699
238700
238701
238702
238703
238704
238705
238706
238707
238708
238709
238710
238711
238712
238713
238714
238715
238716
238717
238718
238719
238720
238721
238722
238723
238724
238725
238726
238727
238728
238729
238730
238731
const BROWSER_TRACING_INTEGRATION_ID = 'BrowserTracing';
/** Options for Browser Tracing integration */
const DEFAULT_BROWSER_TRACING_OPTIONS = {
idleTimeout: _idletransaction_js__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_IDLE_TIMEOUT,
finalTimeout: _idletransaction_js__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_FINAL_TIMEOUT,
heartbeatInterval: _idletransaction_js__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_HEARTBEAT_INTERVAL,
markBackgroundTransactions: true,
routingInstrumentation: _router_js__WEBPACK_IMPORTED_MODULE_1__.instrumentRoutingWithDefaults,
startTransactionOnLocationChange: true,
startTransactionOnPageLoad: true,
_experiments: { enableLongTask: true, enableInteractions: false },
..._request_js__WEBPACK_IMPORTED_MODULE_2__.defaultRequestInstrumentationOptions,
};
/**
* The Browser Tracing integration automatically instruments browser pageload/navigation
* actions as transactions, and captures requests, metrics and errors as spans.
*
* The integration can be configured with a variety of options, and can be extended to use
* any routing library. This integration uses {@see IdleTransaction} to create transactions.
*/
class BrowserTracing {
// This class currently doesn't have a static `id` field like the other integration classes, because it prevented
// @sentry/tracing from being treeshaken. Tree shakers do not like static fields, because they behave like side effects.
// TODO: Come up with a better plan, than using static fields on integration classes, and use that plan on all
// integrations.
/** Browser Tracing integration options */
/**
* @inheritDoc
*/
__init() {this.name = BROWSER_TRACING_INTEGRATION_ID;}
constructor(_options) {;BrowserTracing.prototype.__init.call(this);
this.options = {
...DEFAULT_BROWSER_TRACING_OPTIONS,
..._options,
};
// TODO (v8): remove this block after tracingOrigins is removed
// Set tracePropagationTargets to tracingOrigins if specified by the user
// In case both are specified, tracePropagationTargets takes precedence
// eslint-disable-next-line deprecation/deprecation
if (_options && !_options.tracePropagationTargets && _options.tracingOrigins) {
// eslint-disable-next-line deprecation/deprecation
this.options.tracePropagationTargets = _options.tracingOrigins;
}
(0,_metrics_index_js__WEBPACK_IMPORTED_MODULE_3__.startTrackingWebVitals)();
if ((0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([this, 'access', _2 => _2.options, 'access', _3 => _3._experiments, 'optionalAccess', _4 => _4.enableLongTask])) {
(0,_metrics_index_js__WEBPACK_IMPORTED_MODULE_3__.startTrackingLongTasks)();
}
}
/**
* @inheritDoc
*/
setupOnce(_, getCurrentHub) {
this._getCurrentHub = getCurrentHub;
const {
routingInstrumentation: instrumentRouting,
startTransactionOnLocationChange,
startTransactionOnPageLoad,
markBackgroundTransactions,
traceFetch,
traceXHR,
tracePropagationTargets,
shouldCreateSpanForRequest,
_experiments,
} = this.options;
instrumentRouting(
(context) => this._createRouteTransaction(context),
startTransactionOnPageLoad,
startTransactionOnLocationChange,
);
if (markBackgroundTransactions) {
(0,_backgroundtab_js__WEBPACK_IMPORTED_MODULE_5__.registerBackgroundTabDetection)();
}
if ((0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([_experiments, 'optionalAccess', _5 => _5.enableInteractions])) {
this._registerInteractionListener();
}
(0,_request_js__WEBPACK_IMPORTED_MODULE_2__.instrumentOutgoingRequests)({
traceFetch,
traceXHR,
tracePropagationTargets,
shouldCreateSpanForRequest,
});
}
/** Create routing idle transaction. */
_createRouteTransaction(context) {
if (!this._getCurrentHub) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) &&
_sentry_utils__WEBPACK_IMPORTED_MODULE_6__.logger.warn(`[Tracing] Did not create ${context.op} transaction because _getCurrentHub is invalid.`);
return undefined;
}
const { beforeNavigate, idleTimeout, finalTimeout, heartbeatInterval } = this.options;
const isPageloadTransaction = context.op === 'pageload';
const sentryTraceMetaTagValue = isPageloadTransaction ? getMetaContent('sentry-trace') : null;
const baggageMetaTagValue = isPageloadTransaction ? getMetaContent('baggage') : null;
const traceParentData = sentryTraceMetaTagValue ? (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_7__.extractTraceparentData)(sentryTraceMetaTagValue) : undefined;
const dynamicSamplingContext = baggageMetaTagValue
? (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_8__.baggageHeaderToDynamicSamplingContext)(baggageMetaTagValue)
: undefined;
const expandedContext = {
...context,
...traceParentData,
metadata: {
...context.metadata,
dynamicSamplingContext: traceParentData && !dynamicSamplingContext ? {} : dynamicSamplingContext,
},
trimEnd: true,
};
const modifiedContext = typeof beforeNavigate === 'function' ? beforeNavigate(expandedContext) : expandedContext;
// For backwards compatibility reasons, beforeNavigate can return undefined to "drop" the transaction (prevent it
// from being sent to Sentry).
const finalContext = modifiedContext === undefined ? { ...expandedContext, sampled: false } : modifiedContext;
// If `beforeNavigate` set a custom name, record that fact
finalContext.metadata =
finalContext.name !== expandedContext.name
? { ...finalContext.metadata, source: 'custom' }
: finalContext.metadata;
this._latestRouteName = finalContext.name;
this._latestRouteSource = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([finalContext, 'access', _6 => _6.metadata, 'optionalAccess', _7 => _7.source]);
if (finalContext.sampled === false) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) &&
_sentry_utils__WEBPACK_IMPORTED_MODULE_6__.logger.log(`[Tracing] Will not send ${finalContext.op} transaction because of beforeNavigate.`);
}
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_6__.logger.log(`[Tracing] Starting ${finalContext.op} transaction on scope`);
const hub = this._getCurrentHub();
const { location } = _types_js__WEBPACK_IMPORTED_MODULE_9__.WINDOW;
const idleTransaction = (0,_hubextensions_js__WEBPACK_IMPORTED_MODULE_10__.startIdleTransaction)(
hub,
finalContext,
idleTimeout,
finalTimeout,
true,
{ location }, // for use in the tracesSampler
heartbeatInterval,
);
idleTransaction.registerBeforeFinishCallback(transaction => {
(0,_metrics_index_js__WEBPACK_IMPORTED_MODULE_3__.addPerformanceEntries)(transaction);
});
return idleTransaction ;
}
/** Start listener for interaction transactions */
_registerInteractionListener() {
let inflightInteractionTransaction;
const registerInteractionTransaction = () => {
const { idleTimeout, finalTimeout, heartbeatInterval } = this.options;
const op = 'ui.action.click';
if (inflightInteractionTransaction) {
inflightInteractionTransaction.finish();
inflightInteractionTransaction = undefined;
}
if (!this._getCurrentHub) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_6__.logger.warn(`[Tracing] Did not create ${op} transaction because _getCurrentHub is invalid.`);
return undefined;
}
if (!this._latestRouteName) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) &&
_sentry_utils__WEBPACK_IMPORTED_MODULE_6__.logger.warn(`[Tracing] Did not create ${op} transaction because _latestRouteName is missing.`);
return undefined;
}
const hub = this._getCurrentHub();
const { location } = _types_js__WEBPACK_IMPORTED_MODULE_9__.WINDOW;
const context = {
name: this._latestRouteName,
op,
trimEnd: true,
metadata: {
source: (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_11__._nullishCoalesce)(this._latestRouteSource, () => ( 'url')),
},
};
inflightInteractionTransaction = (0,_hubextensions_js__WEBPACK_IMPORTED_MODULE_10__.startIdleTransaction)(
hub,
context,
idleTimeout,
finalTimeout,
true,
{ location }, // for use in the tracesSampler
heartbeatInterval,
);
};
['click'].forEach(type => {
addEventListener(type, registerInteractionTransaction, { once: false, capture: true });
});
}
}
/** Returns the value of a meta tag */
function getMetaContent(metaName) {
// Can't specify generic to `getDomElement` because tracing can be used
// in a variety of environments, have to disable `no-unsafe-member-access`
// as a result.
const metaTag = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_12__.getDomElement)(`meta[name=${metaName}]`);
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
return metaTag ? metaTag.getAttribute('content') : null;
}
//# sourceMappingURL=browsertracing.js.map
/***/ }),
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "instrumentRoutingWithDefaults": () => (/* binding */ instrumentRoutingWithDefaults)
/* harmony export */ });
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1548);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1616);
/* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1629);
238746
238747
238748
238749
238750
238751
238752
238753
238754
238755
238756
238757
238758
238759
238760
238761
238762
238763
238764
238765
238766
238767
238768
238769
238770
238771
238772
238773
238774
238775
238776
238777
238778
238779
238780
238781
238782
238783
238784
238785
238786
238787
238788
238789
238790
238791
238792
238793
238794
238795
238796
238797
238798
238799
238800
238801
238802
238803
238804
238805
238806
238807
238808
238809
238810
/**
* Default function implementing pageload and navigation transactions
*/
function instrumentRoutingWithDefaults(
customStartTransaction,
startTransactionOnPageLoad = true,
startTransactionOnLocationChange = true,
) {
if (!_types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW || !_types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW.location) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.warn('Could not initialize routing instrumentation due to invalid location');
return;
}
let startingUrl = _types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW.location.href;
let activeTransaction;
if (startTransactionOnPageLoad) {
activeTransaction = customStartTransaction({
name: _types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW.location.pathname,
op: 'pageload',
metadata: { source: 'url' },
});
}
if (startTransactionOnLocationChange) {
(0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.addInstrumentationHandler)('history', ({ to, from }) => {
/**
* This early return is there to account for some cases where a navigation transaction starts right after
* long-running pageload. We make sure that if `from` is undefined and a valid `startingURL` exists, we don't
* create an uneccessary navigation transaction.
*
* This was hard to duplicate, but this behavior stopped as soon as this fix was applied. This issue might also
* only be caused in certain development environments where the usage of a hot module reloader is causing
* errors.
*/
if (from === undefined && startingUrl && startingUrl.indexOf(to) !== -1) {
startingUrl = undefined;
return;
}
if (from !== to) {
startingUrl = undefined;
if (activeTransaction) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.log(`[Tracing] Finishing current transaction with op: ${activeTransaction.op}`);
// If there's an open transaction on the scope, we need to finish it before creating an new one.
activeTransaction.finish();
}
activeTransaction = customStartTransaction({
name: _types_js__WEBPACK_IMPORTED_MODULE_0__.WINDOW.location.pathname,
op: 'navigation',
metadata: { source: 'url' },
});
}
});
}
}
//# sourceMappingURL=router.js.map
/***/ }),
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "WINDOW": () => (/* binding */ WINDOW)
/* harmony export */ });
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1539);
const WINDOW = _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.GLOBAL_OBJ ;
//# sourceMappingURL=types.js.map
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "DEFAULT_TRACE_PROPAGATION_TARGETS": () => (/* binding */ DEFAULT_TRACE_PROPAGATION_TARGETS),
/* harmony export */ "defaultRequestInstrumentationOptions": () => (/* binding */ defaultRequestInstrumentationOptions),
/* harmony export */ "fetchCallback": () => (/* binding */ fetchCallback),
/* harmony export */ "instrumentOutgoingRequests": () => (/* binding */ instrumentOutgoingRequests),
/* harmony export */ "shouldAttachHeaders": () => (/* binding */ shouldAttachHeaders),
/* harmony export */ "xhrCallback": () => (/* binding */ xhrCallback)
/* harmony export */ });
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1616);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1543);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1583);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1544);
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1611);
238850
238851
238852
238853
238854
238855
238856
238857
238858
238859
238860
238861
238862
238863
238864
238865
238866
238867
238868
238869
238870
238871
238872
const DEFAULT_TRACE_PROPAGATION_TARGETS = ['localhost', /^\//];
/** Options for Request Instrumentation */
const defaultRequestInstrumentationOptions = {
traceFetch: true,
traceXHR: true,
// TODO (v8): Remove this property
tracingOrigins: DEFAULT_TRACE_PROPAGATION_TARGETS,
tracePropagationTargets: DEFAULT_TRACE_PROPAGATION_TARGETS,
};
/** Registers span creators for xhr and fetch requests */
function instrumentOutgoingRequests(_options) {
// eslint-disable-next-line deprecation/deprecation
const { traceFetch, traceXHR, tracePropagationTargets, tracingOrigins, shouldCreateSpanForRequest } = {
traceFetch: defaultRequestInstrumentationOptions.traceFetch,
traceXHR: defaultRequestInstrumentationOptions.traceXHR,
..._options,
};
const shouldCreateSpan =
typeof shouldCreateSpanForRequest === 'function' ? shouldCreateSpanForRequest : (_) => true;
// TODO(v8) Remove tracingOrigins here
// The only reason we're passing it in here is because this instrumentOutgoingRequests function is publicly exported
// and we don't want to break the API. We can remove it in v8.
const shouldAttachHeadersWithTargets = (url) =>
shouldAttachHeaders(url, tracePropagationTargets || tracingOrigins);
if (traceFetch) {
(0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.addInstrumentationHandler)('fetch', (handlerData) => {
fetchCallback(handlerData, shouldCreateSpan, shouldAttachHeadersWithTargets, spans);
});
}
if (traceXHR) {
(0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.addInstrumentationHandler)('xhr', (handlerData) => {
xhrCallback(handlerData, shouldCreateSpan, shouldAttachHeadersWithTargets, spans);
});
}
}
/**
* A function that determines whether to attach tracing headers to a request.
* This was extracted from `instrumentOutgoingRequests` to make it easier to test shouldAttachHeaders.
* We only export this fuction for testing purposes.
function shouldAttachHeaders(url, tracePropagationTargets) {
return (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.stringMatchesSomePattern)(url, tracePropagationTargets || DEFAULT_TRACE_PROPAGATION_TARGETS);
}
/**
* Create and track fetch request spans
*/
function fetchCallback(
handlerData,
shouldCreateSpan,
shouldAttachHeaders,
spans,
) {
if (!(0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.hasTracingEnabled)() || !(handlerData.fetchData && shouldCreateSpan(handlerData.fetchData.url))) {
return;
}
if (handlerData.endTimestamp) {
const spanId = handlerData.fetchData.__span;
if (!spanId) return;
const span = spans[spanId];
if (span) {
if (handlerData.response) {
// TODO (kmclb) remove this once types PR goes through
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
span.setHttpStatus(handlerData.response.status);
} else if (handlerData.error) {
span.setStatus('internal_error');
}
span.finish();
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete spans[spanId];
}
const activeTransaction = (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.getActiveTransaction)();
if (activeTransaction) {
const span = activeTransaction.startChild({
data: {
...handlerData.fetchData,
type: 'fetch',
},
description: `${handlerData.fetchData.method} ${handlerData.fetchData.url}`,
op: 'http.client',
});
handlerData.fetchData.__span = span.spanId;
spans[span.spanId] = span;
const request = handlerData.args[0];
// In case the user hasn't set the second argument of a fetch call we default it to `{}`.
handlerData.args[1] = handlerData.args[1] || {};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const options = handlerData.args[1];
if (shouldAttachHeaders(handlerData.fetchData.url)) {
options.headers = addTracingHeadersToFetchRequest(
request,
activeTransaction.getDynamicSamplingContext(),
span,
options,
);
activeTransaction.metadata.propagations++;
}
}
}
function addTracingHeadersToFetchRequest(
request,
dynamicSamplingContext,
span,
options
,
) {
const sentryBaggageHeader = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.dynamicSamplingContextToSentryBaggageHeader)(dynamicSamplingContext);
const sentryTraceHeader = span.toTraceparent();
const headers =
typeof Request !== 'undefined' && (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.isInstanceOf)(request, Request) ? (request ).headers : options.headers;
if (!headers) {
return { 'sentry-trace': sentryTraceHeader, baggage: sentryBaggageHeader };
} else if (typeof Headers !== 'undefined' && (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.isInstanceOf)(headers, Headers)) {
const newHeaders = new Headers(headers );
newHeaders.append('sentry-trace', sentryTraceHeader);
if (sentryBaggageHeader) {
// If the same header is appended miultiple times the browser will merge the values into a single request header.
// Its therefore safe to simply push a "baggage" entry, even though there might already be another baggage header.
newHeaders.append(_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.BAGGAGE_HEADER_NAME, sentryBaggageHeader);
}