@sentry/browser 6.14.3 → 6.17.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bundle.es6.js +1271 -1393
- package/build/bundle.es6.js.map +1 -1
- package/build/bundle.es6.min.js +2 -2
- package/build/bundle.es6.min.js.map +1 -1
- package/build/bundle.js +1367 -1520
- package/build/bundle.js.map +1 -1
- package/build/bundle.min.js +2 -2
- package/build/bundle.min.js.map +1 -1
- package/dist/backend.d.ts +2 -2
- package/dist/backend.d.ts.map +1 -1
- package/dist/backend.js +1 -2
- package/dist/backend.js.map +1 -1
- package/dist/eventbuilder.d.ts +2 -2
- package/dist/eventbuilder.d.ts.map +1 -1
- package/dist/eventbuilder.js +20 -13
- package/dist/eventbuilder.js.map +1 -1
- package/dist/exports.d.ts +1 -1
- package/dist/exports.d.ts.map +1 -1
- package/dist/exports.js +0 -3
- package/dist/exports.js.map +1 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +26 -37
- package/dist/helpers.js.map +1 -1
- package/dist/integrations/breadcrumbs.d.ts +0 -20
- package/dist/integrations/breadcrumbs.d.ts.map +1 -1
- package/dist/integrations/breadcrumbs.js +132 -174
- package/dist/integrations/breadcrumbs.js.map +1 -1
- package/dist/integrations/dedupe.d.ts +0 -14
- package/dist/integrations/dedupe.d.ts.map +1 -1
- package/dist/integrations/dedupe.js +126 -126
- package/dist/integrations/dedupe.js.map +1 -1
- package/dist/integrations/globalhandlers.d.ts +7 -25
- package/dist/integrations/globalhandlers.d.ts.map +1 -1
- package/dist/integrations/globalhandlers.js +176 -169
- package/dist/integrations/globalhandlers.js.map +1 -1
- package/dist/integrations/linkederrors.d.ts +15 -13
- package/dist/integrations/linkederrors.d.ts.map +1 -1
- package/dist/integrations/linkederrors.js +26 -28
- package/dist/integrations/linkederrors.js.map +1 -1
- package/dist/integrations/trycatch.d.ts +0 -8
- package/dist/integrations/trycatch.d.ts.map +1 -1
- package/dist/integrations/trycatch.js +154 -153
- package/dist/integrations/trycatch.js.map +1 -1
- package/dist/integrations/useragent.js +2 -3
- package/dist/integrations/useragent.js.map +1 -1
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +23 -19
- package/dist/sdk.js.map +1 -1
- package/dist/transports/base.d.ts +9 -4
- package/dist/transports/base.d.ts.map +1 -1
- package/dist/transports/base.js +23 -19
- package/dist/transports/base.js.map +1 -1
- package/dist/transports/fetch.d.ts +2 -10
- package/dist/transports/fetch.d.ts.map +1 -1
- package/dist/transports/fetch.js +3 -17
- package/dist/transports/fetch.js.map +1 -1
- package/dist/transports/utils.d.ts.map +1 -1
- package/dist/transports/utils.js +7 -5
- package/dist/transports/utils.js.map +1 -1
- package/dist/transports/xhr.d.ts +2 -10
- package/dist/transports/xhr.d.ts.map +1 -1
- package/dist/transports/xhr.js +3 -17
- package/dist/transports/xhr.js.map +1 -1
- package/esm/backend.d.ts +2 -2
- package/esm/backend.d.ts.map +1 -1
- package/esm/backend.js +1 -2
- package/esm/backend.js.map +1 -1
- package/esm/eventbuilder.d.ts +2 -2
- package/esm/eventbuilder.d.ts.map +1 -1
- package/esm/eventbuilder.js +21 -14
- package/esm/eventbuilder.js.map +1 -1
- package/esm/exports.d.ts +1 -1
- package/esm/exports.d.ts.map +1 -1
- package/esm/exports.js +0 -1
- package/esm/exports.js.map +1 -1
- package/esm/helpers.d.ts.map +1 -1
- package/esm/helpers.js +28 -39
- package/esm/helpers.js.map +1 -1
- package/esm/integrations/breadcrumbs.d.ts +0 -20
- package/esm/integrations/breadcrumbs.d.ts.map +1 -1
- package/esm/integrations/breadcrumbs.js +134 -176
- package/esm/integrations/breadcrumbs.js.map +1 -1
- package/esm/integrations/dedupe.d.ts +0 -14
- package/esm/integrations/dedupe.d.ts.map +1 -1
- package/esm/integrations/dedupe.js +126 -126
- package/esm/integrations/dedupe.js.map +1 -1
- package/esm/integrations/globalhandlers.d.ts +7 -25
- package/esm/integrations/globalhandlers.d.ts.map +1 -1
- package/esm/integrations/globalhandlers.js +178 -171
- package/esm/integrations/globalhandlers.js.map +1 -1
- package/esm/integrations/linkederrors.d.ts +15 -13
- package/esm/integrations/linkederrors.d.ts.map +1 -1
- package/esm/integrations/linkederrors.js +24 -28
- package/esm/integrations/linkederrors.js.map +1 -1
- package/esm/integrations/trycatch.d.ts +0 -8
- package/esm/integrations/trycatch.d.ts.map +1 -1
- package/esm/integrations/trycatch.js +155 -154
- package/esm/integrations/trycatch.js.map +1 -1
- package/esm/integrations/useragent.js +2 -3
- package/esm/integrations/useragent.js.map +1 -1
- package/esm/sdk.d.ts.map +1 -1
- package/esm/sdk.js +24 -20
- package/esm/sdk.js.map +1 -1
- package/esm/transports/base.d.ts +9 -4
- package/esm/transports/base.d.ts.map +1 -1
- package/esm/transports/base.js +25 -21
- package/esm/transports/base.js.map +1 -1
- package/esm/transports/fetch.d.ts +2 -10
- package/esm/transports/fetch.d.ts.map +1 -1
- package/esm/transports/fetch.js +3 -17
- package/esm/transports/fetch.js.map +1 -1
- package/esm/transports/utils.d.ts.map +1 -1
- package/esm/transports/utils.js +8 -6
- package/esm/transports/utils.js.map +1 -1
- package/esm/transports/xhr.d.ts +2 -10
- package/esm/transports/xhr.d.ts.map +1 -1
- package/esm/transports/xhr.js +3 -17
- package/esm/transports/xhr.js.map +1 -1
- package/package.json +15 -17
|
@@ -52,180 +52,181 @@ var TryCatch = /** @class */ (function () {
|
|
|
52
52
|
TryCatch.prototype.setupOnce = function () {
|
|
53
53
|
var global = utils_1.getGlobalObject();
|
|
54
54
|
if (this._options.setTimeout) {
|
|
55
|
-
utils_1.fill(global, 'setTimeout',
|
|
55
|
+
utils_1.fill(global, 'setTimeout', _wrapTimeFunction);
|
|
56
56
|
}
|
|
57
57
|
if (this._options.setInterval) {
|
|
58
|
-
utils_1.fill(global, 'setInterval',
|
|
58
|
+
utils_1.fill(global, 'setInterval', _wrapTimeFunction);
|
|
59
59
|
}
|
|
60
60
|
if (this._options.requestAnimationFrame) {
|
|
61
|
-
utils_1.fill(global, 'requestAnimationFrame',
|
|
61
|
+
utils_1.fill(global, 'requestAnimationFrame', _wrapRAF);
|
|
62
62
|
}
|
|
63
63
|
if (this._options.XMLHttpRequest && 'XMLHttpRequest' in global) {
|
|
64
|
-
utils_1.fill(XMLHttpRequest.prototype, 'send',
|
|
64
|
+
utils_1.fill(XMLHttpRequest.prototype, 'send', _wrapXHR);
|
|
65
65
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
eventTarget.
|
|
66
|
+
var eventTargetOption = this._options.eventTarget;
|
|
67
|
+
if (eventTargetOption) {
|
|
68
|
+
var eventTarget = Array.isArray(eventTargetOption) ? eventTargetOption : DEFAULT_EVENT_TARGET;
|
|
69
|
+
eventTarget.forEach(_wrapEventTarget);
|
|
69
70
|
}
|
|
70
71
|
};
|
|
71
|
-
/**
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
72
|
+
/**
|
|
73
|
+
* @inheritDoc
|
|
74
|
+
*/
|
|
75
|
+
TryCatch.id = 'TryCatch';
|
|
76
|
+
return TryCatch;
|
|
77
|
+
}());
|
|
78
|
+
exports.TryCatch = TryCatch;
|
|
79
|
+
/** JSDoc */
|
|
80
|
+
function _wrapTimeFunction(original) {
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
82
|
+
return function () {
|
|
83
|
+
var args = [];
|
|
84
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
85
|
+
args[_i] = arguments[_i];
|
|
86
|
+
}
|
|
87
|
+
var originalCallback = args[0];
|
|
88
|
+
args[0] = helpers_1.wrap(originalCallback, {
|
|
89
|
+
mechanism: {
|
|
90
|
+
data: { function: utils_1.getFunctionName(original) },
|
|
91
|
+
handled: true,
|
|
92
|
+
type: 'instrument',
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
return original.apply(this, args);
|
|
89
96
|
};
|
|
90
|
-
|
|
97
|
+
}
|
|
98
|
+
/** JSDoc */
|
|
99
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
100
|
+
function _wrapRAF(original) {
|
|
91
101
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
|
-
|
|
93
|
-
// eslint-disable-next-line @typescript-eslint/no-
|
|
94
|
-
return
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
function: 'requestAnimationFrame',
|
|
100
|
-
handler: utils_1.getFunctionName(original),
|
|
101
|
-
},
|
|
102
|
-
handled: true,
|
|
103
|
-
type: 'instrument',
|
|
102
|
+
return function (callback) {
|
|
103
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
104
|
+
return original.call(this, helpers_1.wrap(callback, {
|
|
105
|
+
mechanism: {
|
|
106
|
+
data: {
|
|
107
|
+
function: 'requestAnimationFrame',
|
|
108
|
+
handler: utils_1.getFunctionName(original),
|
|
104
109
|
},
|
|
105
|
-
|
|
106
|
-
|
|
110
|
+
handled: true,
|
|
111
|
+
type: 'instrument',
|
|
112
|
+
},
|
|
113
|
+
}));
|
|
107
114
|
};
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
var
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return;
|
|
115
|
+
}
|
|
116
|
+
/** JSDoc */
|
|
117
|
+
function _wrapXHR(originalSend) {
|
|
118
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
119
|
+
return function () {
|
|
120
|
+
var args = [];
|
|
121
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
122
|
+
args[_i] = arguments[_i];
|
|
117
123
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
mechanism: {
|
|
124
|
-
data: {
|
|
125
|
-
function: 'handleEvent',
|
|
126
|
-
handler: utils_1.getFunctionName(fn),
|
|
127
|
-
target: target,
|
|
128
|
-
},
|
|
129
|
-
handled: true,
|
|
130
|
-
type: 'instrument',
|
|
131
|
-
},
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
catch (err) {
|
|
136
|
-
// can sometimes get 'Permission denied to access property "handle Event'
|
|
137
|
-
}
|
|
138
|
-
return original.call(this, eventName,
|
|
124
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
125
|
+
var xhr = this;
|
|
126
|
+
var xmlHttpRequestProps = ['onload', 'onerror', 'onprogress', 'onreadystatechange'];
|
|
127
|
+
xmlHttpRequestProps.forEach(function (prop) {
|
|
128
|
+
if (prop in xhr && typeof xhr[prop] === 'function') {
|
|
139
129
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
130
|
+
utils_1.fill(xhr, prop, function (original) {
|
|
131
|
+
var wrapOptions = {
|
|
132
|
+
mechanism: {
|
|
133
|
+
data: {
|
|
134
|
+
function: prop,
|
|
135
|
+
handler: utils_1.getFunctionName(original),
|
|
136
|
+
},
|
|
137
|
+
handled: true,
|
|
138
|
+
type: 'instrument',
|
|
146
139
|
},
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
});
|
|
153
|
-
utils_1.fill(proto, 'removeEventListener', function (originalRemoveEventListener) {
|
|
154
|
-
return function (eventName, fn, options) {
|
|
155
|
-
var _a;
|
|
156
|
-
/**
|
|
157
|
-
* There are 2 possible scenarios here:
|
|
158
|
-
*
|
|
159
|
-
* 1. Someone passes a callback, which was attached prior to Sentry initialization, or by using unmodified
|
|
160
|
-
* method, eg. `document.addEventListener.call(el, name, handler). In this case, we treat this function
|
|
161
|
-
* as a pass-through, and call original `removeEventListener` with it.
|
|
162
|
-
*
|
|
163
|
-
* 2. Someone passes a callback, which was attached after Sentry was initialized, which means that it was using
|
|
164
|
-
* our wrapped version of `addEventListener`, which internally calls `wrap` helper.
|
|
165
|
-
* This helper "wraps" whole callback inside a try/catch statement, and attached appropriate metadata to it,
|
|
166
|
-
* in order for us to make a distinction between wrapped/non-wrapped functions possible.
|
|
167
|
-
* If a function was wrapped, it has additional property of `__sentry_wrapped__`, holding the handler.
|
|
168
|
-
*
|
|
169
|
-
* When someone adds a handler prior to initialization, and then do it again, but after,
|
|
170
|
-
* then we have to detach both of them. Otherwise, if we'd detach only wrapped one, it'd be impossible
|
|
171
|
-
* to get rid of the initial handler and it'd stick there forever.
|
|
172
|
-
*/
|
|
173
|
-
var wrappedEventHandler = fn;
|
|
174
|
-
try {
|
|
175
|
-
var originalEventHandler = (_a = wrappedEventHandler) === null || _a === void 0 ? void 0 : _a.__sentry_wrapped__;
|
|
176
|
-
if (originalEventHandler) {
|
|
177
|
-
originalRemoveEventListener.call(this, eventName, originalEventHandler, options);
|
|
140
|
+
};
|
|
141
|
+
// If Instrument integration has been called before TryCatch, get the name of original function
|
|
142
|
+
var originalFunction = utils_1.getOriginalFunction(original);
|
|
143
|
+
if (originalFunction) {
|
|
144
|
+
wrapOptions.mechanism.data.handler = utils_1.getFunctionName(originalFunction);
|
|
178
145
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
return originalRemoveEventListener.call(this, eventName, wrappedEventHandler, options);
|
|
184
|
-
};
|
|
146
|
+
// Otherwise wrap directly
|
|
147
|
+
return helpers_1.wrap(original, wrapOptions);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
185
150
|
});
|
|
151
|
+
return originalSend.apply(this, args);
|
|
186
152
|
};
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
handled: true,
|
|
209
|
-
type: 'instrument',
|
|
153
|
+
}
|
|
154
|
+
/** JSDoc */
|
|
155
|
+
function _wrapEventTarget(target) {
|
|
156
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
157
|
+
var global = utils_1.getGlobalObject();
|
|
158
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
159
|
+
var proto = global[target] && global[target].prototype;
|
|
160
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, no-prototype-builtins
|
|
161
|
+
if (!proto || !proto.hasOwnProperty || !proto.hasOwnProperty('addEventListener')) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
utils_1.fill(proto, 'addEventListener', function (original) {
|
|
165
|
+
return function (eventName, fn, options) {
|
|
166
|
+
try {
|
|
167
|
+
if (typeof fn.handleEvent === 'function') {
|
|
168
|
+
fn.handleEvent = helpers_1.wrap(fn.handleEvent.bind(fn), {
|
|
169
|
+
mechanism: {
|
|
170
|
+
data: {
|
|
171
|
+
function: 'handleEvent',
|
|
172
|
+
handler: utils_1.getFunctionName(fn),
|
|
173
|
+
target: target,
|
|
210
174
|
},
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
wrapOptions.mechanism.data.handler = utils_1.getFunctionName(original.__sentry_original__);
|
|
215
|
-
}
|
|
216
|
-
// Otherwise wrap directly
|
|
217
|
-
return helpers_1.wrap(original, wrapOptions);
|
|
175
|
+
handled: true,
|
|
176
|
+
type: 'instrument',
|
|
177
|
+
},
|
|
218
178
|
});
|
|
219
179
|
}
|
|
220
|
-
}
|
|
221
|
-
|
|
180
|
+
}
|
|
181
|
+
catch (err) {
|
|
182
|
+
// can sometimes get 'Permission denied to access property "handle Event'
|
|
183
|
+
}
|
|
184
|
+
return original.call(this, eventName,
|
|
185
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
186
|
+
helpers_1.wrap(fn, {
|
|
187
|
+
mechanism: {
|
|
188
|
+
data: {
|
|
189
|
+
function: 'addEventListener',
|
|
190
|
+
handler: utils_1.getFunctionName(fn),
|
|
191
|
+
target: target,
|
|
192
|
+
},
|
|
193
|
+
handled: true,
|
|
194
|
+
type: 'instrument',
|
|
195
|
+
},
|
|
196
|
+
}), options);
|
|
197
|
+
};
|
|
198
|
+
});
|
|
199
|
+
utils_1.fill(proto, 'removeEventListener', function (originalRemoveEventListener) {
|
|
200
|
+
return function (eventName, fn, options) {
|
|
201
|
+
/**
|
|
202
|
+
* There are 2 possible scenarios here:
|
|
203
|
+
*
|
|
204
|
+
* 1. Someone passes a callback, which was attached prior to Sentry initialization, or by using unmodified
|
|
205
|
+
* method, eg. `document.addEventListener.call(el, name, handler). In this case, we treat this function
|
|
206
|
+
* as a pass-through, and call original `removeEventListener` with it.
|
|
207
|
+
*
|
|
208
|
+
* 2. Someone passes a callback, which was attached after Sentry was initialized, which means that it was using
|
|
209
|
+
* our wrapped version of `addEventListener`, which internally calls `wrap` helper.
|
|
210
|
+
* This helper "wraps" whole callback inside a try/catch statement, and attached appropriate metadata to it,
|
|
211
|
+
* in order for us to make a distinction between wrapped/non-wrapped functions possible.
|
|
212
|
+
* If a function was wrapped, it has additional property of `__sentry_wrapped__`, holding the handler.
|
|
213
|
+
*
|
|
214
|
+
* When someone adds a handler prior to initialization, and then do it again, but after,
|
|
215
|
+
* then we have to detach both of them. Otherwise, if we'd detach only wrapped one, it'd be impossible
|
|
216
|
+
* to get rid of the initial handler and it'd stick there forever.
|
|
217
|
+
*/
|
|
218
|
+
var wrappedEventHandler = fn;
|
|
219
|
+
try {
|
|
220
|
+
var originalEventHandler = wrappedEventHandler && wrappedEventHandler.__sentry_wrapped__;
|
|
221
|
+
if (originalEventHandler) {
|
|
222
|
+
originalRemoveEventListener.call(this, eventName, originalEventHandler, options);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
catch (e) {
|
|
226
|
+
// ignore, accessing __sentry_wrapped__ will throw in some Selenium environments
|
|
227
|
+
}
|
|
228
|
+
return originalRemoveEventListener.call(this, eventName, wrappedEventHandler, options);
|
|
222
229
|
};
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
* @inheritDoc
|
|
226
|
-
*/
|
|
227
|
-
TryCatch.id = 'TryCatch';
|
|
228
|
-
return TryCatch;
|
|
229
|
-
}());
|
|
230
|
-
exports.TryCatch = TryCatch;
|
|
230
|
+
});
|
|
231
|
+
}
|
|
231
232
|
//# sourceMappingURL=trycatch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trycatch.js","sourceRoot":"","sources":["../../src/integrations/trycatch.ts"],"names":[],"mappings":";;AACA,uCAAuE;AAEvE,sCAAkC;AAElC,IAAM,oBAAoB,GAAG;IAC3B,aAAa;IACb,QAAQ;IACR,MAAM;IACN,kBAAkB;IAClB,gBAAgB;IAChB,mBAAmB;IACnB,iBAAiB;IACjB,aAAa;IACb,YAAY;IACZ,oBAAoB;IACpB,aAAa;IACb,YAAY;IACZ,gBAAgB;IAChB,cAAc;IACd,iBAAiB;IACjB,aAAa;IACb,aAAa;IACb,cAAc;IACd,oBAAoB;IACpB,QAAQ;IACR,WAAW;IACX,cAAc;IACd,eAAe;IACf,WAAW;IACX,iBAAiB;IACjB,QAAQ;IACR,gBAAgB;IAChB,2BAA2B;IAC3B,sBAAsB;CACvB,CAAC;AAaF,0FAA0F;AAC1F;IAcE;;OAEG;IACH,kBAAmB,OAAkC;QAXrD;;WAEG;QACI,SAAI,GAAW,QAAQ,CAAC,EAAE,CAAC;QAShC,IAAI,CAAC,QAAQ,sBACX,cAAc,EAAE,IAAI,EACpB,WAAW,EAAE,IAAI,EACjB,qBAAqB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oBACrC,CAAC,CAAC,CAAC;iBACJ;YACH,CAAC,CAAC,CAAC;YAEH,OAAO,YAAY,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACxC,CAAC,CAAC;IACJ,CAAC;IAxOD;;OAEG;IACW,WAAE,GAAW,UAAU,CAAC;IAsOxC,eAAC;CAAA,AA1OD,IA0OC;AA1OY,4BAAQ","sourcesContent":["import { Integration, WrappedFunction } from '@sentry/types';\nimport { fill, getFunctionName, getGlobalObject } from '@sentry/utils';\n\nimport { wrap } from '../helpers';\n\nconst DEFAULT_EVENT_TARGET = [\n 'EventTarget',\n 'Window',\n 'Node',\n 'ApplicationCache',\n 'AudioTrackList',\n 'ChannelMergerNode',\n 'CryptoOperation',\n 'EventSource',\n 'FileReader',\n 'HTMLUnknownElement',\n 'IDBDatabase',\n 'IDBRequest',\n 'IDBTransaction',\n 'KeyOperation',\n 'MediaController',\n 'MessagePort',\n 'ModalWindow',\n 'Notification',\n 'SVGElementInstance',\n 'Screen',\n 'TextTrack',\n 'TextTrackCue',\n 'TextTrackList',\n 'WebSocket',\n 'WebSocketWorker',\n 'Worker',\n 'XMLHttpRequest',\n 'XMLHttpRequestEventTarget',\n 'XMLHttpRequestUpload',\n];\n\ntype XMLHttpRequestProp = 'onload' | 'onerror' | 'onprogress' | 'onreadystatechange';\n\n/** JSDoc */\ninterface TryCatchOptions {\n setTimeout: boolean;\n setInterval: boolean;\n requestAnimationFrame: boolean;\n XMLHttpRequest: boolean;\n eventTarget: boolean | string[];\n}\n\n/** Wrap timer functions and event targets to catch errors and provide better meta data */\nexport class TryCatch implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'TryCatch';\n\n /**\n * @inheritDoc\n */\n public name: string = TryCatch.id;\n\n /** JSDoc */\n private readonly _options: TryCatchOptions;\n\n /**\n * @inheritDoc\n */\n public constructor(options?: Partial<TryCatchOptions>) {\n this._options = {\n XMLHttpRequest: true,\n eventTarget: true,\n requestAnimationFrame: true,\n setInterval: true,\n setTimeout: true,\n ...options,\n };\n }\n\n /**\n * Wrap timer functions and event targets to catch errors\n * and provide better metadata.\n */\n public setupOnce(): void {\n const global = getGlobalObject();\n\n if (this._options.setTimeout) {\n fill(global, 'setTimeout', this._wrapTimeFunction.bind(this));\n }\n\n if (this._options.setInterval) {\n fill(global, 'setInterval', this._wrapTimeFunction.bind(this));\n }\n\n if (this._options.requestAnimationFrame) {\n fill(global, 'requestAnimationFrame', this._wrapRAF.bind(this));\n }\n\n if (this._options.XMLHttpRequest && 'XMLHttpRequest' in global) {\n fill(XMLHttpRequest.prototype, 'send', this._wrapXHR.bind(this));\n }\n\n if (this._options.eventTarget) {\n const eventTarget = Array.isArray(this._options.eventTarget) ? this._options.eventTarget : DEFAULT_EVENT_TARGET;\n eventTarget.forEach(this._wrapEventTarget.bind(this));\n }\n }\n\n /** JSDoc */\n private _wrapTimeFunction(original: () => void): () => number {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function(this: any, ...args: any[]): number {\n const originalCallback = args[0];\n args[0] = wrap(originalCallback, {\n mechanism: {\n data: { function: getFunctionName(original) },\n handled: true,\n type: 'instrument',\n },\n });\n return original.apply(this, args);\n };\n }\n\n /** JSDoc */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private _wrapRAF(original: any): (callback: () => void) => any {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function(this: any, callback: () => void): () => void {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n return original.call(\n this,\n wrap(callback, {\n mechanism: {\n data: {\n function: 'requestAnimationFrame',\n handler: getFunctionName(original),\n },\n handled: true,\n type: 'instrument',\n },\n }),\n );\n };\n }\n\n /** JSDoc */\n private _wrapEventTarget(target: string): void {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const global = getGlobalObject() as { [key: string]: any };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const proto = global[target] && global[target].prototype;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, no-prototype-builtins\n if (!proto || !proto.hasOwnProperty || !proto.hasOwnProperty('addEventListener')) {\n return;\n }\n\n fill(proto, 'addEventListener', function(\n original: () => void,\n ): (eventName: string, fn: EventListenerObject, options?: boolean | AddEventListenerOptions) => void {\n return function(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this: any,\n eventName: string,\n fn: EventListenerObject,\n options?: boolean | AddEventListenerOptions,\n ): (eventName: string, fn: EventListenerObject, capture?: boolean, secure?: boolean) => void {\n try {\n if (typeof fn.handleEvent === 'function') {\n fn.handleEvent = wrap(fn.handleEvent.bind(fn), {\n mechanism: {\n data: {\n function: 'handleEvent',\n handler: getFunctionName(fn),\n target,\n },\n handled: true,\n type: 'instrument',\n },\n });\n }\n } catch (err) {\n // can sometimes get 'Permission denied to access property \"handle Event'\n }\n\n return original.call(\n this,\n eventName,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n wrap((fn as any) as WrappedFunction, {\n mechanism: {\n data: {\n function: 'addEventListener',\n handler: getFunctionName(fn),\n target,\n },\n handled: true,\n type: 'instrument',\n },\n }),\n options,\n );\n };\n });\n\n fill(proto, 'removeEventListener', function(\n originalRemoveEventListener: () => void,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): (this: any, eventName: string, fn: EventListenerObject, options?: boolean | EventListenerOptions) => () => void {\n return function(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this: any,\n eventName: string,\n fn: EventListenerObject,\n options?: boolean | EventListenerOptions,\n ): () => void {\n /**\n * There are 2 possible scenarios here:\n *\n * 1. Someone passes a callback, which was attached prior to Sentry initialization, or by using unmodified\n * method, eg. `document.addEventListener.call(el, name, handler). In this case, we treat this function\n * as a pass-through, and call original `removeEventListener` with it.\n *\n * 2. Someone passes a callback, which was attached after Sentry was initialized, which means that it was using\n * our wrapped version of `addEventListener`, which internally calls `wrap` helper.\n * This helper \"wraps\" whole callback inside a try/catch statement, and attached appropriate metadata to it,\n * in order for us to make a distinction between wrapped/non-wrapped functions possible.\n * If a function was wrapped, it has additional property of `__sentry_wrapped__`, holding the handler.\n *\n * When someone adds a handler prior to initialization, and then do it again, but after,\n * then we have to detach both of them. Otherwise, if we'd detach only wrapped one, it'd be impossible\n * to get rid of the initial handler and it'd stick there forever.\n */\n const wrappedEventHandler = (fn as unknown) as WrappedFunction;\n try {\n const originalEventHandler = wrappedEventHandler?.__sentry_wrapped__;\n if (originalEventHandler) {\n originalRemoveEventListener.call(this, eventName, originalEventHandler, options);\n }\n } catch (e) {\n // ignore, accessing __sentry_wrapped__ will throw in some Selenium environments\n }\n return originalRemoveEventListener.call(this, eventName, wrappedEventHandler, options);\n };\n });\n }\n\n /** JSDoc */\n private _wrapXHR(originalSend: () => void): () => void {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function(this: XMLHttpRequest, ...args: any[]): void {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const xhr = this;\n const xmlHttpRequestProps: XMLHttpRequestProp[] = ['onload', 'onerror', 'onprogress', 'onreadystatechange'];\n\n xmlHttpRequestProps.forEach(prop => {\n if (prop in xhr && typeof xhr[prop] === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n fill(xhr, prop, function(original: WrappedFunction): () => any {\n const wrapOptions = {\n mechanism: {\n data: {\n function: prop,\n handler: getFunctionName(original),\n },\n handled: true,\n type: 'instrument',\n },\n };\n\n // If Instrument integration has been called before TryCatch, get the name of original function\n if (original.__sentry_original__) {\n wrapOptions.mechanism.data.handler = getFunctionName(original.__sentry_original__);\n }\n\n // Otherwise wrap directly\n return wrap(original, wrapOptions);\n });\n }\n });\n\n return originalSend.apply(this, args);\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"trycatch.js","sourceRoot":"","sources":["../../src/integrations/trycatch.ts"],"names":[],"mappings":";;AACA,uCAA4F;AAE5F,sCAAkC;AAElC,IAAM,oBAAoB,GAAG;IAC3B,aAAa;IACb,QAAQ;IACR,MAAM;IACN,kBAAkB;IA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EAAE,qBAAqB,EAAE,UACjC,2BAAuC;QAGvC,OAAO,UAGL,SAAiB,EACjB,EAAuB,EACvB,OAAwC;YAExC;;;;;;;;;;;;;;;;eAgBG;YACH,IAAM,mBAAmB,GAAI,EAAiC,CAAC;YAC/D,IAAI;gBACF,IAAM,oBAAoB,GAAG,mBAAmB,IAAI,mBAAmB,CAAC,kBAAkB,CAAC;gBAC3F,IAAI,oBAAoB,EAAE;oBACxB,2BAA2B,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,oBAAoB,EAAE,OAAO,CAAC,CAAC;iBAClF;aACF;YAAC,OAAO,CAAC,EAAE;gBACV,gFAAgF;aACjF;YACD,OAAO,2BAA2B,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,mBAAmB,EAAE,OAAO,CAAC,CAAC;QACzF,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { Integration, WrappedFunction } from '@sentry/types';\nimport { fill, getFunctionName, getGlobalObject, getOriginalFunction } from '@sentry/utils';\n\nimport { wrap } from '../helpers';\n\nconst DEFAULT_EVENT_TARGET = [\n 'EventTarget',\n 'Window',\n 'Node',\n 'ApplicationCache',\n 'AudioTrackList',\n 'ChannelMergerNode',\n 'CryptoOperation',\n 'EventSource',\n 'FileReader',\n 'HTMLUnknownElement',\n 'IDBDatabase',\n 'IDBRequest',\n 'IDBTransaction',\n 'KeyOperation',\n 'MediaController',\n 'MessagePort',\n 'ModalWindow',\n 'Notification',\n 'SVGElementInstance',\n 'Screen',\n 'TextTrack',\n 'TextTrackCue',\n 'TextTrackList',\n 'WebSocket',\n 'WebSocketWorker',\n 'Worker',\n 'XMLHttpRequest',\n 'XMLHttpRequestEventTarget',\n 'XMLHttpRequestUpload',\n];\n\ntype XMLHttpRequestProp = 'onload' | 'onerror' | 'onprogress' | 'onreadystatechange';\n\n/** JSDoc */\ninterface TryCatchOptions {\n setTimeout: boolean;\n setInterval: boolean;\n requestAnimationFrame: boolean;\n XMLHttpRequest: boolean;\n eventTarget: boolean | string[];\n}\n\n/** Wrap timer functions and event targets to catch errors and provide better meta data */\nexport class TryCatch implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'TryCatch';\n\n /**\n * @inheritDoc\n */\n public name: string = TryCatch.id;\n\n /** JSDoc */\n private readonly _options: TryCatchOptions;\n\n /**\n * @inheritDoc\n */\n public constructor(options?: Partial<TryCatchOptions>) {\n this._options = {\n XMLHttpRequest: true,\n eventTarget: true,\n requestAnimationFrame: true,\n setInterval: true,\n setTimeout: true,\n ...options,\n };\n }\n\n /**\n * Wrap timer functions and event targets to catch errors\n * and provide better metadata.\n */\n public setupOnce(): void {\n const global = getGlobalObject();\n\n if (this._options.setTimeout) {\n fill(global, 'setTimeout', _wrapTimeFunction);\n }\n\n if (this._options.setInterval) {\n fill(global, 'setInterval', _wrapTimeFunction);\n }\n\n if (this._options.requestAnimationFrame) {\n fill(global, 'requestAnimationFrame', _wrapRAF);\n }\n\n if (this._options.XMLHttpRequest && 'XMLHttpRequest' in global) {\n fill(XMLHttpRequest.prototype, 'send', _wrapXHR);\n }\n\n const eventTargetOption = this._options.eventTarget;\n if (eventTargetOption) {\n const eventTarget = Array.isArray(eventTargetOption) ? eventTargetOption : DEFAULT_EVENT_TARGET;\n eventTarget.forEach(_wrapEventTarget);\n }\n }\n}\n\n/** JSDoc */\nfunction _wrapTimeFunction(original: () => void): () => number {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function(this: any, ...args: any[]): number {\n const originalCallback = args[0];\n args[0] = wrap(originalCallback, {\n mechanism: {\n data: { function: getFunctionName(original) },\n handled: true,\n type: 'instrument',\n },\n });\n return original.apply(this, args);\n };\n}\n\n/** JSDoc */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction _wrapRAF(original: any): (callback: () => void) => any {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function(this: any, callback: () => void): () => void {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n return original.call(\n this,\n wrap(callback, {\n mechanism: {\n data: {\n function: 'requestAnimationFrame',\n handler: getFunctionName(original),\n },\n handled: true,\n type: 'instrument',\n },\n }),\n );\n };\n}\n\n/** JSDoc */\nfunction _wrapXHR(originalSend: () => void): () => void {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function(this: XMLHttpRequest, ...args: any[]): void {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const xhr = this;\n const xmlHttpRequestProps: XMLHttpRequestProp[] = ['onload', 'onerror', 'onprogress', 'onreadystatechange'];\n\n xmlHttpRequestProps.forEach(prop => {\n if (prop in xhr && typeof xhr[prop] === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n fill(xhr, prop, function(original: WrappedFunction): () => any {\n const wrapOptions = {\n mechanism: {\n data: {\n function: prop,\n handler: getFunctionName(original),\n },\n handled: true,\n type: 'instrument',\n },\n };\n\n // If Instrument integration has been called before TryCatch, get the name of original function\n const originalFunction = getOriginalFunction(original);\n if (originalFunction) {\n wrapOptions.mechanism.data.handler = getFunctionName(originalFunction);\n }\n\n // Otherwise wrap directly\n return wrap(original, wrapOptions);\n });\n }\n });\n\n return originalSend.apply(this, args);\n };\n}\n\n/** JSDoc */\nfunction _wrapEventTarget(target: string): void {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const global = getGlobalObject() as { [key: string]: any };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const proto = global[target] && global[target].prototype;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, no-prototype-builtins\n if (!proto || !proto.hasOwnProperty || !proto.hasOwnProperty('addEventListener')) {\n return;\n }\n\n fill(proto, 'addEventListener', function(\n original: () => void,\n ): (eventName: string, fn: EventListenerObject, options?: boolean | AddEventListenerOptions) => void {\n return function(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this: any,\n eventName: string,\n fn: EventListenerObject,\n options?: boolean | AddEventListenerOptions,\n ): (eventName: string, fn: EventListenerObject, capture?: boolean, secure?: boolean) => void {\n try {\n if (typeof fn.handleEvent === 'function') {\n fn.handleEvent = wrap(fn.handleEvent.bind(fn), {\n mechanism: {\n data: {\n function: 'handleEvent',\n handler: getFunctionName(fn),\n target,\n },\n handled: true,\n type: 'instrument',\n },\n });\n }\n } catch (err) {\n // can sometimes get 'Permission denied to access property \"handle Event'\n }\n\n return original.call(\n this,\n eventName,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n wrap((fn as any) as WrappedFunction, {\n mechanism: {\n data: {\n function: 'addEventListener',\n handler: getFunctionName(fn),\n target,\n },\n handled: true,\n type: 'instrument',\n },\n }),\n options,\n );\n };\n });\n\n fill(proto, 'removeEventListener', function(\n originalRemoveEventListener: () => void,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): (this: any, eventName: string, fn: EventListenerObject, options?: boolean | EventListenerOptions) => () => void {\n return function(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this: any,\n eventName: string,\n fn: EventListenerObject,\n options?: boolean | EventListenerOptions,\n ): () => void {\n /**\n * There are 2 possible scenarios here:\n *\n * 1. Someone passes a callback, which was attached prior to Sentry initialization, or by using unmodified\n * method, eg. `document.addEventListener.call(el, name, handler). In this case, we treat this function\n * as a pass-through, and call original `removeEventListener` with it.\n *\n * 2. Someone passes a callback, which was attached after Sentry was initialized, which means that it was using\n * our wrapped version of `addEventListener`, which internally calls `wrap` helper.\n * This helper \"wraps\" whole callback inside a try/catch statement, and attached appropriate metadata to it,\n * in order for us to make a distinction between wrapped/non-wrapped functions possible.\n * If a function was wrapped, it has additional property of `__sentry_wrapped__`, holding the handler.\n *\n * When someone adds a handler prior to initialization, and then do it again, but after,\n * then we have to detach both of them. Otherwise, if we'd detach only wrapped one, it'd be impossible\n * to get rid of the initial handler and it'd stick there forever.\n */\n const wrappedEventHandler = (fn as unknown) as WrappedFunction;\n try {\n const originalEventHandler = wrappedEventHandler && wrappedEventHandler.__sentry_wrapped__;\n if (originalEventHandler) {\n originalRemoveEventListener.call(this, eventName, originalEventHandler, options);\n }\n } catch (e) {\n // ignore, accessing __sentry_wrapped__ will throw in some Selenium environments\n }\n return originalRemoveEventListener.call(this, eventName, wrappedEventHandler, options);\n };\n });\n}\n"]}
|
|
@@ -16,17 +16,16 @@ var UserAgent = /** @class */ (function () {
|
|
|
16
16
|
*/
|
|
17
17
|
UserAgent.prototype.setupOnce = function () {
|
|
18
18
|
core_1.addGlobalEventProcessor(function (event) {
|
|
19
|
-
var _a, _b, _c;
|
|
20
19
|
if (core_1.getCurrentHub().getIntegration(UserAgent)) {
|
|
21
20
|
// if none of the information we want exists, don't bother
|
|
22
21
|
if (!global.navigator && !global.location && !global.document) {
|
|
23
22
|
return event;
|
|
24
23
|
}
|
|
25
24
|
// grab as much info as exists and add it to the event
|
|
26
|
-
var url = (
|
|
25
|
+
var url = (event.request && event.request.url) || (global.location && global.location.href);
|
|
27
26
|
var referrer = (global.document || {}).referrer;
|
|
28
27
|
var userAgent = (global.navigator || {}).userAgent;
|
|
29
|
-
var headers = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, (
|
|
28
|
+
var headers = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, (event.request && event.request.headers)), (referrer && { Referer: referrer })), (userAgent && { 'User-Agent': userAgent }));
|
|
30
29
|
var request = tslib_1.__assign(tslib_1.__assign({}, (url && { url: url })), { headers: headers });
|
|
31
30
|
return tslib_1.__assign(tslib_1.__assign({}, event), { request: request });
|
|
32
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useragent.js","sourceRoot":"","sources":["../../src/integrations/useragent.ts"],"names":[],"mappings":";;AAAA,qCAAsE;AAEtE,uCAAgD;AAEhD,IAAM,MAAM,GAAG,uBAAe,EAAU,CAAC;AAEzC,gBAAgB;AAChB;IAAA;QAME;;WAEG;QACI,SAAI,GAAW,SAAS,CAAC,EAAE,CAAC;IA8BrC,CAAC;IA5BC;;OAEG;IACI,6BAAS,GA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CAAC,CAAC;IACL,CAAC;IArCD;;OAEG;IACW,YAAE,GAAW,WAAW,CAAC;IAmCzC,gBAAC;CAAA,AAvCD,IAuCC;AAvCY,8BAAS","sourcesContent":["import { addGlobalEventProcessor, getCurrentHub } from '@sentry/core';\nimport { Event, Integration } from '@sentry/types';\nimport { getGlobalObject } from '@sentry/utils';\n\nconst global = getGlobalObject<Window>();\n\n/** UserAgent */\nexport class UserAgent implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'UserAgent';\n\n /**\n * @inheritDoc\n */\n public name: string = UserAgent.id;\n\n /**\n * @inheritDoc\n */\n public setupOnce(): void {\n addGlobalEventProcessor((event: Event) => {\n if (getCurrentHub().getIntegration(UserAgent)) {\n // if none of the information we want exists, don't bother\n if (!global.navigator && !global.location && !global.document) {\n return event;\n }\n\n // grab as much info as exists and add it to the event\n const url = (event.request && event.request.url) || (global.location && global.location.href);\n const { referrer } = global.document || {};\n const { userAgent } = global.navigator || {};\n\n const headers = {\n ...(event.request && event.request.headers),\n ...(referrer && { Referer: referrer }),\n ...(userAgent && { 'User-Agent': userAgent }),\n };\n const request = { ...(url && { url }), headers };\n\n return { ...event, request };\n }\n return event;\n });\n }\n}\n"]}
|
package/dist/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,YAAY,IAAI,gBAAgB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,YAAY,IAAI,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAI5F,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,mBAAmB,EAAwB,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAExG,eAAO,MAAM,mBAAmB,uJAS/B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,IAAI,CAAC,OAAO,GAAE,cAAmB,GAAG,IAAI,CAuBvD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,mBAAwB,GAAG,IAAI,CAiBxE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,IAAI,MAAM,GAAG,SAAS,CAEhD;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,IAAI,CAEhC;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAEjD;AAED;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,CAS5D;AAED;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,CAS5D;AAED;;;;;;GAMG;AAEH,wBAAgB,IAAI,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,GAAG,GAAG,CAEnD"}
|
package/dist/sdk.js
CHANGED
|
@@ -155,8 +155,10 @@ function flush(timeout) {
|
|
|
155
155
|
if (client) {
|
|
156
156
|
return client.flush(timeout);
|
|
157
157
|
}
|
|
158
|
-
utils_1.
|
|
159
|
-
|
|
158
|
+
if (utils_1.isDebugBuild()) {
|
|
159
|
+
utils_1.logger.warn('Cannot flush events. No client defined.');
|
|
160
|
+
}
|
|
161
|
+
return utils_1.resolvedSyncPromise(false);
|
|
160
162
|
}
|
|
161
163
|
exports.flush = flush;
|
|
162
164
|
/**
|
|
@@ -172,8 +174,10 @@ function close(timeout) {
|
|
|
172
174
|
if (client) {
|
|
173
175
|
return client.close(timeout);
|
|
174
176
|
}
|
|
175
|
-
utils_1.
|
|
176
|
-
|
|
177
|
+
if (utils_1.isDebugBuild()) {
|
|
178
|
+
utils_1.logger.warn('Cannot flush events and disable SDK. No client defined.');
|
|
179
|
+
}
|
|
180
|
+
return utils_1.resolvedSyncPromise(false);
|
|
177
181
|
}
|
|
178
182
|
exports.close = close;
|
|
179
183
|
/**
|
|
@@ -188,6 +192,10 @@ function wrap(fn) {
|
|
|
188
192
|
return helpers_1.wrap(fn)();
|
|
189
193
|
}
|
|
190
194
|
exports.wrap = wrap;
|
|
195
|
+
function startSessionOnHub(hub) {
|
|
196
|
+
hub.startSession({ ignoreDuration: true });
|
|
197
|
+
hub.captureSession();
|
|
198
|
+
}
|
|
191
199
|
/**
|
|
192
200
|
* Enable automatic Session Tracking for the initial page load.
|
|
193
201
|
*/
|
|
@@ -195,7 +203,9 @@ function startSessionTracking() {
|
|
|
195
203
|
var window = utils_1.getGlobalObject();
|
|
196
204
|
var document = window.document;
|
|
197
205
|
if (typeof document === 'undefined') {
|
|
198
|
-
utils_1.
|
|
206
|
+
if (utils_1.isDebugBuild()) {
|
|
207
|
+
utils_1.logger.warn('Session tracking in non-browser environment with @sentry/browser is not supported.');
|
|
208
|
+
}
|
|
199
209
|
return;
|
|
200
210
|
}
|
|
201
211
|
var hub = core_1.getCurrentHub();
|
|
@@ -205,27 +215,21 @@ function startSessionTracking() {
|
|
|
205
215
|
// https://github.com/getsentry/sentry-javascript/issues/3207 and
|
|
206
216
|
// https://github.com/getsentry/sentry-javascript/issues/3234 and
|
|
207
217
|
// https://github.com/getsentry/sentry-javascript/issues/3278.
|
|
208
|
-
if (
|
|
218
|
+
if (!hub.captureSession) {
|
|
209
219
|
return;
|
|
210
220
|
}
|
|
211
221
|
// The session duration for browser sessions does not track a meaningful
|
|
212
222
|
// concept that can be used as a metric.
|
|
213
223
|
// Automatically captured sessions are akin to page views, and thus we
|
|
214
224
|
// discard their duration.
|
|
215
|
-
hub
|
|
216
|
-
hub.captureSession();
|
|
225
|
+
startSessionOnHub(hub);
|
|
217
226
|
// We want to create a session for every navigation as well
|
|
218
|
-
utils_1.addInstrumentationHandler({
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
hub.startSession({ ignoreDuration: true });
|
|
226
|
-
hub.captureSession();
|
|
227
|
-
},
|
|
228
|
-
type: 'history',
|
|
227
|
+
utils_1.addInstrumentationHandler('history', function (_a) {
|
|
228
|
+
var from = _a.from, to = _a.to;
|
|
229
|
+
// Don't create an additional session for the initial route or if the location did not change
|
|
230
|
+
if (!(from === undefined || from === to)) {
|
|
231
|
+
startSessionOnHub(core_1.getCurrentHub());
|
|
232
|
+
}
|
|
229
233
|
});
|
|
230
234
|
}
|
|
231
235
|
//# sourceMappingURL=sdk.js.map
|
package/dist/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":";;AAAA,qCAA4F;AAC5F,uCAAgG;AAGhG,mCAAyC;AACzC,qCAAsE;AACtE,+CAAwG;AAE3F,QAAA,mBAAmB,GAAG;IACjC,IAAI,mBAAgB,CAAC,cAAc,EAAE;IACrC,IAAI,mBAAgB,CAAC,gBAAgB,EAAE;IACvC,IAAI,uBAAQ,EAAE;IACd,IAAI,0BAAW,EAAE;IACjB,IAAI,6BAAc,EAAE;IACpB,IAAI,2BAAY,EAAE;IAClB,IAAI,qBAAM,EAAE;IACZ,IAAI,wBAAS,EAAE;CAChB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,SAAgB,IAAI,CAAC,OAA4B;IAA5B,wBAAA,EAAA,YAA4B;IAC/C,IAAI,OAAO,CAAC,mBAAmB,KAAK,SAAS,EAAE;QAC7C,OAAO,C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,CAAC,oFAAoF,CAAC,CAAC;QAClG,OAAO;KACR;IAED,IAAM,GAAG,GAAG,oBAAa,EAAE,CAAC;IAE5B,iHAAiH;IACjH,gHAAgH;IAChH,gGAAgG;IAChG,iEAAiE;IACjE,iEAAiE;IACjE,8DAA8D;IAC9D,IAAI,OAAO,GAAG,CAAC,YAAY,KAAK,UAAU,IAAI,OAAO,GAAG,CAAC,cAAc,KAAK,UAAU,EAAE;QACtF,OAAO;KACR;IAED,wEAAwE;IACxE,wCAAwC;IACxC,sEAAsE;IACtE,0BAA0B;IAC1B,GAAG,CAAC,YAAY,CAAC,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3C,GAAG,CAAC,cAAc,EAAE,CAAC;IAErB,2DAA2D;IAC3D,iCAAyB,CAAC;QACxB,QAAQ,EAAE,UAAC,EAAY;gBAAV,cAAI,EAAE,UAAE;YACnB,6FAA6F;YAC7F,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,EAAE,EAAE;gBACrC,OAAO;aACR;YACD,GAAG,CAAC,YAAY,CAAC,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC;YAC3C,GAAG,CAAC,cAAc,EAAE,CAAC;QACvB,CAAC;QACD,IAAI,EAAE,SAAS;KAChB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { getCurrentHub, initAndBind, Integrations as CoreIntegrations } from '@sentry/core';\nimport { addInstrumentationHandler, getGlobalObject, logger, SyncPromise } from '@sentry/utils';\n\nimport { BrowserOptions } from './backend';\nimport { BrowserClient } from './client';\nimport { ReportDialogOptions, wrap as internalWrap } from './helpers';\nimport { Breadcrumbs, Dedupe, GlobalHandlers, LinkedErrors, TryCatch, UserAgent } from './integrations';\n\nexport const defaultIntegrations = [\n new CoreIntegrations.InboundFilters(),\n new CoreIntegrations.FunctionToString(),\n new TryCatch(),\n new Breadcrumbs(),\n new GlobalHandlers(),\n new LinkedErrors(),\n new Dedupe(),\n new UserAgent(),\n];\n\n/**\n * The Sentry Browser SDK Client.\n *\n * To use this SDK, call the {@link init} function as early as possible when\n * loading the web page. To set context information or send manual events, use\n * the provided methods.\n *\n * @example\n *\n * ```\n *\n * import { init } from '@sentry/browser';\n *\n * init({\n * dsn: '__DSN__',\n * // ...\n * });\n * ```\n *\n * @example\n * ```\n *\n * import { configureScope } from '@sentry/browser';\n * configureScope((scope: Scope) => {\n * scope.setExtra({ battery: 0.7 });\n * scope.setTag({ user_mode: 'admin' });\n * scope.setUser({ id: '4711' });\n * });\n * ```\n *\n * @example\n * ```\n *\n * import { addBreadcrumb } from '@sentry/browser';\n * addBreadcrumb({\n * message: 'My Breadcrumb',\n * // ...\n * });\n * ```\n *\n * @example\n *\n * ```\n *\n * import * as Sentry from '@sentry/browser';\n * Sentry.captureMessage('Hello, world!');\n * Sentry.captureException(new Error('Good bye'));\n * Sentry.captureEvent({\n * message: 'Manual',\n * stacktrace: [\n * // ...\n * ],\n * });\n * ```\n *\n * @see {@link BrowserOptions} for documentation on configuration options.\n */\nexport function init(options: BrowserOptions = {}): void {\n if (options.defaultIntegrations === undefined) {\n options.defaultIntegrations = defaultIntegrations;\n }\n if (options.release === undefined) {\n const window = getGlobalObject<Window>();\n // This supports the variable that sentry-webpack-plugin injects\n if (window.SENTRY_RELEASE && window.SENTRY_RELEASE.id) {\n options.release = window.SENTRY_RELEASE.id;\n }\n }\n if (options.autoSessionTracking === undefined) {\n options.autoSessionTracking = true;\n }\n if (options.sendClientReports === undefined) {\n options.sendClientReports = true;\n }\n\n initAndBind(BrowserClient, options);\n\n if (options.autoSessionTracking) {\n startSessionTracking();\n }\n}\n\n/**\n * Present the user with a report dialog.\n *\n * @param options Everything is optional, we try to fetch all info need from the global scope.\n */\nexport function showReportDialog(options: ReportDialogOptions = {}): void {\n const hub = getCurrentHub();\n const scope = hub.getScope();\n if (scope) {\n options.user = {\n ...scope.getUser(),\n ...options.user,\n };\n }\n\n if (!options.eventId) {\n options.eventId = hub.lastEventId();\n }\n const client = hub.getClient<BrowserClient>();\n if (client) {\n client.showReportDialog(options);\n }\n}\n\n/**\n * This is the getter for lastEventId.\n *\n * @returns The last event id of a captured event.\n */\nexport function lastEventId(): string | undefined {\n return getCurrentHub().lastEventId();\n}\n\n/**\n * This function is here to be API compatible with the loader.\n * @hidden\n */\nexport function forceLoad(): void {\n // Noop\n}\n\n/**\n * This function is here to be API compatible with the loader.\n * @hidden\n */\nexport function onLoad(callback: () => void): void {\n callback();\n}\n\n/**\n * Call `flush()` on the current client, if there is one. See {@link Client.flush}.\n *\n * @param timeout Maximum time in ms the client should wait to flush its event queue. Omitting this parameter will cause\n * the client to wait until all events are sent before resolving the promise.\n * @returns A promise which resolves to `true` if the queue successfully drains before the timeout, or `false` if it\n * doesn't (or if there's no client defined).\n */\nexport function flush(timeout?: number): PromiseLike<boolean> {\n const client = getCurrentHub().getClient<BrowserClient>();\n if (client) {\n return client.flush(timeout);\n }\n logger.warn('Cannot flush events. No client defined.');\n return SyncPromise.resolve(false);\n}\n\n/**\n * Call `close()` on the current client, if there is one. See {@link Client.close}.\n *\n * @param timeout Maximum time in ms the client should wait to flush its event queue before shutting down. Omitting this\n * parameter will cause the client to wait until all events are sent before disabling itself.\n * @returns A promise which resolves to `true` if the queue successfully drains before the timeout, or `false` if it\n * doesn't (or if there's no client defined).\n */\nexport function close(timeout?: number): PromiseLike<boolean> {\n const client = getCurrentHub().getClient<BrowserClient>();\n if (client) {\n return client.close(timeout);\n }\n logger.warn('Cannot flush events and disable SDK. No client defined.');\n return SyncPromise.resolve(false);\n}\n\n/**\n * Wrap code within a try/catch block so the SDK is able to capture errors.\n *\n * @param fn A function to wrap.\n *\n * @returns The result of wrapped function call.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function wrap(fn: (...args: any) => any): any {\n return internalWrap(fn)();\n}\n\n/**\n * Enable automatic Session Tracking for the initial page load.\n */\nfunction startSessionTracking(): void {\n const window = getGlobalObject<Window>();\n const document = window.document;\n\n if (typeof document === 'undefined') {\n logger.warn('Session tracking in non-browser environment with @sentry/browser is not supported.');\n return;\n }\n\n const hub = getCurrentHub();\n\n // The only way for this to be false is for there to be a version mismatch between @sentry/browser (>= 6.0.0) and\n // @sentry/hub (< 5.27.0). In the simple case, there won't ever be such a mismatch, because the two packages are\n // pinned at the same version in package.json, but there are edge cases where it's possible. See\n // https://github.com/getsentry/sentry-javascript/issues/3207 and\n // https://github.com/getsentry/sentry-javascript/issues/3234 and\n // https://github.com/getsentry/sentry-javascript/issues/3278.\n if (typeof hub.startSession !== 'function' || typeof hub.captureSession !== 'function') {\n return;\n }\n\n // The session duration for browser sessions does not track a meaningful\n // concept that can be used as a metric.\n // Automatically captured sessions are akin to page views, and thus we\n // discard their duration.\n hub.startSession({ ignoreDuration: true });\n hub.captureSession();\n\n // We want to create a session for every navigation as well\n addInstrumentationHandler({\n callback: ({ from, to }) => {\n // Don't create an additional session for the initial route or if the location did not change\n if (from === undefined || from === to) {\n return;\n }\n hub.startSession({ ignoreDuration: true });\n hub.captureSession();\n },\n type: 'history',\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":";;AAAA,qCAA4F;AAE5F,uCAAsH;AAGtH,mCAAyC;AACzC,qCAAsE;AACtE,+CAAwG;AAE3F,QAAA,mBAAmB,GAAG;IACjC,IAAI,mBAAgB,CAAC,cAAc,EAAE;IACrC,IAAI,mBAAgB,CAAC,gBAAgB,EAAE;IACvC,IAAI,uBAAQ,EAAE;IACd,IAAI,0BAAW,EAAE;IACjB,IAAI,6BAAc,EAAE;IACpB,IAAI,2BAAY,EAAE;IAClB,IAAI,qBAAM,EAAE;IACZ,IAAI,wBAAS,EAAE;CAChB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,SAAgB,IAAI,CAAC,OAA4B;IAA5B,wBAAA,EAAA,YAA4B;IAC/C,IAAI,OAAO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AAC;IAC3C,GAAG,CAAC,cAAc,EAAE,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,SAAS,oBAAoB;IAC3B,IAAM,MAAM,GAAG,uBAAe,EAAU,CAAC;IACzC,IAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IAEjC,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;QACnC,IAAI,oBAAY,EAAE,EAAE;YAClB,cAAM,CAAC,IAAI,CAAC,oFAAoF,CAAC,CAAC;SACnG;QACD,OAAO;KACR;IAED,IAAM,GAAG,GAAG,oBAAa,EAAE,CAAC;IAE5B,iHAAiH;IACjH,gHAAgH;IAChH,gGAAgG;IAChG,iEAAiE;IACjE,iEAAiE;IACjE,8DAA8D;IAC9D,IAAI,CAAC,GAAG,CAAC,cAAc,EAAE;QACvB,OAAO;KACR;IAED,wEAAwE;IACxE,wCAAwC;IACxC,sEAAsE;IACtE,0BAA0B;IAC1B,iBAAiB,CAAC,GAAG,CAAC,CAAC;IAEvB,2DAA2D;IAC3D,iCAAyB,CAAC,SAAS,EAAE,UAAC,EAAY;YAAV,cAAI,EAAE,UAAE;QAC9C,6FAA6F;QAC7F,IAAI,CAAC,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,EAAE,CAAC,EAAE;YACxC,iBAAiB,CAAC,oBAAa,EAAE,CAAC,CAAC;SACpC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { getCurrentHub, initAndBind, Integrations as CoreIntegrations } from '@sentry/core';\nimport { Hub } from '@sentry/types';\nimport { addInstrumentationHandler, getGlobalObject, isDebugBuild, logger, resolvedSyncPromise } from '@sentry/utils';\n\nimport { BrowserOptions } from './backend';\nimport { BrowserClient } from './client';\nimport { ReportDialogOptions, wrap as internalWrap } from './helpers';\nimport { Breadcrumbs, Dedupe, GlobalHandlers, LinkedErrors, TryCatch, UserAgent } from './integrations';\n\nexport const defaultIntegrations = [\n new CoreIntegrations.InboundFilters(),\n new CoreIntegrations.FunctionToString(),\n new TryCatch(),\n new Breadcrumbs(),\n new GlobalHandlers(),\n new LinkedErrors(),\n new Dedupe(),\n new UserAgent(),\n];\n\n/**\n * The Sentry Browser SDK Client.\n *\n * To use this SDK, call the {@link init} function as early as possible when\n * loading the web page. To set context information or send manual events, use\n * the provided methods.\n *\n * @example\n *\n * ```\n *\n * import { init } from '@sentry/browser';\n *\n * init({\n * dsn: '__DSN__',\n * // ...\n * });\n * ```\n *\n * @example\n * ```\n *\n * import { configureScope } from '@sentry/browser';\n * configureScope((scope: Scope) => {\n * scope.setExtra({ battery: 0.7 });\n * scope.setTag({ user_mode: 'admin' });\n * scope.setUser({ id: '4711' });\n * });\n * ```\n *\n * @example\n * ```\n *\n * import { addBreadcrumb } from '@sentry/browser';\n * addBreadcrumb({\n * message: 'My Breadcrumb',\n * // ...\n * });\n * ```\n *\n * @example\n *\n * ```\n *\n * import * as Sentry from '@sentry/browser';\n * Sentry.captureMessage('Hello, world!');\n * Sentry.captureException(new Error('Good bye'));\n * Sentry.captureEvent({\n * message: 'Manual',\n * stacktrace: [\n * // ...\n * ],\n * });\n * ```\n *\n * @see {@link BrowserOptions} for documentation on configuration options.\n */\nexport function init(options: BrowserOptions = {}): void {\n if (options.defaultIntegrations === undefined) {\n options.defaultIntegrations = defaultIntegrations;\n }\n if (options.release === undefined) {\n const window = getGlobalObject<Window>();\n // This supports the variable that sentry-webpack-plugin injects\n if (window.SENTRY_RELEASE && window.SENTRY_RELEASE.id) {\n options.release = window.SENTRY_RELEASE.id;\n }\n }\n if (options.autoSessionTracking === undefined) {\n options.autoSessionTracking = true;\n }\n if (options.sendClientReports === undefined) {\n options.sendClientReports = true;\n }\n\n initAndBind(BrowserClient, options);\n\n if (options.autoSessionTracking) {\n startSessionTracking();\n }\n}\n\n/**\n * Present the user with a report dialog.\n *\n * @param options Everything is optional, we try to fetch all info need from the global scope.\n */\nexport function showReportDialog(options: ReportDialogOptions = {}): void {\n const hub = getCurrentHub();\n const scope = hub.getScope();\n if (scope) {\n options.user = {\n ...scope.getUser(),\n ...options.user,\n };\n }\n\n if (!options.eventId) {\n options.eventId = hub.lastEventId();\n }\n const client = hub.getClient<BrowserClient>();\n if (client) {\n client.showReportDialog(options);\n }\n}\n\n/**\n * This is the getter for lastEventId.\n *\n * @returns The last event id of a captured event.\n */\nexport function lastEventId(): string | undefined {\n return getCurrentHub().lastEventId();\n}\n\n/**\n * This function is here to be API compatible with the loader.\n * @hidden\n */\nexport function forceLoad(): void {\n // Noop\n}\n\n/**\n * This function is here to be API compatible with the loader.\n * @hidden\n */\nexport function onLoad(callback: () => void): void {\n callback();\n}\n\n/**\n * Call `flush()` on the current client, if there is one. See {@link Client.flush}.\n *\n * @param timeout Maximum time in ms the client should wait to flush its event queue. Omitting this parameter will cause\n * the client to wait until all events are sent before resolving the promise.\n * @returns A promise which resolves to `true` if the queue successfully drains before the timeout, or `false` if it\n * doesn't (or if there's no client defined).\n */\nexport function flush(timeout?: number): PromiseLike<boolean> {\n const client = getCurrentHub().getClient<BrowserClient>();\n if (client) {\n return client.flush(timeout);\n }\n if (isDebugBuild()) {\n logger.warn('Cannot flush events. No client defined.');\n }\n return resolvedSyncPromise(false);\n}\n\n/**\n * Call `close()` on the current client, if there is one. See {@link Client.close}.\n *\n * @param timeout Maximum time in ms the client should wait to flush its event queue before shutting down. Omitting this\n * parameter will cause the client to wait until all events are sent before disabling itself.\n * @returns A promise which resolves to `true` if the queue successfully drains before the timeout, or `false` if it\n * doesn't (or if there's no client defined).\n */\nexport function close(timeout?: number): PromiseLike<boolean> {\n const client = getCurrentHub().getClient<BrowserClient>();\n if (client) {\n return client.close(timeout);\n }\n if (isDebugBuild()) {\n logger.warn('Cannot flush events and disable SDK. No client defined.');\n }\n return resolvedSyncPromise(false);\n}\n\n/**\n * Wrap code within a try/catch block so the SDK is able to capture errors.\n *\n * @param fn A function to wrap.\n *\n * @returns The result of wrapped function call.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function wrap(fn: (...args: any) => any): any {\n return internalWrap(fn)();\n}\n\nfunction startSessionOnHub(hub: Hub): void {\n hub.startSession({ ignoreDuration: true });\n hub.captureSession();\n}\n\n/**\n * Enable automatic Session Tracking for the initial page load.\n */\nfunction startSessionTracking(): void {\n const window = getGlobalObject<Window>();\n const document = window.document;\n\n if (typeof document === 'undefined') {\n if (isDebugBuild()) {\n logger.warn('Session tracking in non-browser environment with @sentry/browser is not supported.');\n }\n return;\n }\n\n const hub = getCurrentHub();\n\n // The only way for this to be false is for there to be a version mismatch between @sentry/browser (>= 6.0.0) and\n // @sentry/hub (< 5.27.0). In the simple case, there won't ever be such a mismatch, because the two packages are\n // pinned at the same version in package.json, but there are edge cases where it's possible. See\n // https://github.com/getsentry/sentry-javascript/issues/3207 and\n // https://github.com/getsentry/sentry-javascript/issues/3234 and\n // https://github.com/getsentry/sentry-javascript/issues/3278.\n if (!hub.captureSession) {\n return;\n }\n\n // The session duration for browser sessions does not track a meaningful\n // concept that can be used as a metric.\n // Automatically captured sessions are akin to page views, and thus we\n // discard their duration.\n startSessionOnHub(hub);\n\n // We want to create a session for every navigation as well\n addInstrumentationHandler('history', ({ from, to }) => {\n // Don't create an additional session for the initial route or if the location did not change\n if (!(from === undefined || from === to)) {\n startSessionOnHub(getCurrentHub());\n }\n });\n}\n"]}
|