@sentry/browser 7.0.0-alpha.1 → 7.0.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/cjs/client.d.ts +23 -18
- package/cjs/client.d.ts.map +1 -1
- package/cjs/client.js +75 -51
- package/cjs/client.js.map +1 -1
- package/cjs/eventbuilder.d.ts +1 -1
- package/cjs/eventbuilder.js +31 -33
- package/cjs/eventbuilder.js.map +1 -1
- package/cjs/exports.d.ts +5 -4
- package/cjs/exports.d.ts.map +1 -1
- package/cjs/exports.js +20 -8
- package/cjs/exports.js.map +1 -1
- package/cjs/helpers.d.ts +0 -5
- package/cjs/helpers.d.ts.map +1 -1
- package/cjs/helpers.js +15 -49
- package/cjs/helpers.js.map +1 -1
- package/cjs/index.d.ts +1 -2
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js +7 -9
- package/cjs/index.js.map +1 -1
- package/cjs/integrations/breadcrumbs.d.ts +6 -7
- package/cjs/integrations/breadcrumbs.d.ts.map +1 -1
- package/cjs/integrations/breadcrumbs.js +37 -54
- package/cjs/integrations/breadcrumbs.js.map +1 -1
- package/cjs/integrations/dedupe.js +25 -26
- package/cjs/integrations/dedupe.js.map +1 -1
- package/cjs/integrations/globalhandlers.d.ts.map +1 -1
- package/cjs/integrations/globalhandlers.js +52 -53
- package/cjs/integrations/globalhandlers.js.map +1 -1
- package/cjs/integrations/linkederrors.d.ts.map +1 -1
- package/cjs/integrations/linkederrors.js +26 -29
- package/cjs/integrations/linkederrors.js.map +1 -1
- package/cjs/integrations/trycatch.js +30 -40
- package/cjs/integrations/trycatch.js.map +1 -1
- package/cjs/integrations/useragent.js +19 -21
- package/cjs/integrations/useragent.js.map +1 -1
- package/cjs/sdk.d.ts +2 -2
- package/cjs/sdk.d.ts.map +1 -1
- package/cjs/sdk.js +47 -34
- package/cjs/sdk.js.map +1 -1
- package/cjs/stack-parsers.d.ts +7 -6
- package/cjs/stack-parsers.d.ts.map +1 -1
- package/cjs/stack-parsers.js +45 -45
- package/cjs/stack-parsers.js.map +1 -1
- package/cjs/transports/fetch.d.ts +7 -14
- package/cjs/transports/fetch.d.ts.map +1 -1
- package/cjs/transports/fetch.js +17 -78
- package/cjs/transports/fetch.js.map +1 -1
- package/cjs/transports/index.d.ts +2 -6
- package/cjs/transports/index.d.ts.map +1 -1
- package/cjs/transports/index.js +2 -10
- package/cjs/transports/index.js.map +1 -1
- package/cjs/transports/utils.d.ts.map +1 -1
- package/cjs/transports/utils.js +17 -17
- package/cjs/transports/utils.js.map +1 -1
- package/cjs/transports/xhr.d.ts +9 -9
- package/cjs/transports/xhr.d.ts.map +1 -1
- package/cjs/transports/xhr.js +39 -59
- package/cjs/transports/xhr.js.map +1 -1
- package/esm/client.d.ts +23 -18
- package/esm/client.d.ts.map +1 -1
- package/esm/client.js +73 -50
- package/esm/client.js.map +1 -1
- package/esm/eventbuilder.d.ts +1 -1
- package/esm/eventbuilder.js +30 -32
- package/esm/eventbuilder.js.map +1 -1
- package/esm/exports.d.ts +5 -4
- package/esm/exports.d.ts.map +1 -1
- package/esm/exports.js +4 -3
- package/esm/exports.js.map +1 -1
- package/esm/flags.js +1 -1
- package/esm/flags.js.map +1 -1
- package/esm/helpers.d.ts +0 -5
- package/esm/helpers.d.ts.map +1 -1
- package/esm/helpers.js +15 -48
- package/esm/helpers.js.map +1 -1
- package/esm/index.d.ts +1 -2
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +4 -6
- package/esm/index.js.map +1 -1
- package/esm/integrations/breadcrumbs.d.ts +6 -7
- package/esm/integrations/breadcrumbs.d.ts.map +1 -1
- package/esm/integrations/breadcrumbs.js +36 -54
- package/esm/integrations/breadcrumbs.js.map +1 -1
- package/esm/integrations/dedupe.js +23 -25
- package/esm/integrations/dedupe.js.map +1 -1
- package/esm/integrations/globalhandlers.d.ts.map +1 -1
- package/esm/integrations/globalhandlers.js +48 -50
- package/esm/integrations/globalhandlers.js.map +1 -1
- 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.js +28 -39
- package/esm/integrations/trycatch.js.map +1 -1
- package/esm/integrations/useragent.js +17 -20
- package/esm/integrations/useragent.js.map +1 -1
- package/esm/sdk.d.ts +2 -2
- package/esm/sdk.d.ts.map +1 -1
- package/esm/sdk.js +44 -31
- package/esm/sdk.js.map +1 -1
- package/esm/stack-parsers.d.ts +7 -6
- package/esm/stack-parsers.d.ts.map +1 -1
- package/esm/stack-parsers.js +45 -45
- package/esm/stack-parsers.js.map +1 -1
- package/esm/transports/fetch.d.ts +7 -14
- package/esm/transports/fetch.d.ts.map +1 -1
- package/esm/transports/fetch.js +15 -77
- package/esm/transports/fetch.js.map +1 -1
- package/esm/transports/index.d.ts +2 -6
- package/esm/transports/index.d.ts.map +1 -1
- package/esm/transports/index.js +2 -6
- package/esm/transports/index.js.map +1 -1
- package/esm/transports/utils.d.ts.map +1 -1
- package/esm/transports/utils.js +16 -16
- package/esm/transports/utils.js.map +1 -1
- package/esm/transports/xhr.d.ts +9 -9
- package/esm/transports/xhr.d.ts.map +1 -1
- package/esm/transports/xhr.js +38 -59
- package/esm/transports/xhr.js.map +1 -1
- package/esm/version.js +1 -1
- package/esm/version.js.map +1 -1
- package/package.json +4 -4
- package/types/client.d.ts +23 -18
- package/types/client.d.ts.map +1 -1
- package/types/eventbuilder.d.ts +1 -1
- package/types/exports.d.ts +5 -4
- package/types/exports.d.ts.map +1 -1
- package/types/helpers.d.ts +0 -5
- package/types/helpers.d.ts.map +1 -1
- package/types/index.d.ts +1 -2
- package/types/index.d.ts.map +1 -1
- package/types/integrations/breadcrumbs.d.ts +6 -7
- package/types/integrations/breadcrumbs.d.ts.map +1 -1
- package/types/integrations/globalhandlers.d.ts.map +1 -1
- package/types/integrations/linkederrors.d.ts.map +1 -1
- package/types/sdk.d.ts +2 -2
- package/types/sdk.d.ts.map +1 -1
- package/types/stack-parsers.d.ts +7 -6
- package/types/stack-parsers.d.ts.map +1 -1
- package/types/transports/fetch.d.ts +7 -14
- package/types/transports/fetch.d.ts.map +1 -1
- package/types/transports/index.d.ts +2 -6
- package/types/transports/index.d.ts.map +1 -1
- package/types/transports/utils.d.ts.map +1 -1
- package/types/transports/xhr.d.ts +9 -9
- package/types/transports/xhr.d.ts.map +1 -1
- package/cjs/transports/base.d.ts +0 -65
- package/cjs/transports/base.d.ts.map +0 -1
- package/cjs/transports/base.js +0 -141
- package/cjs/transports/base.js.map +0 -1
- package/cjs/transports/new-fetch.d.ts +0 -10
- package/cjs/transports/new-fetch.d.ts.map +0 -1
- package/cjs/transports/new-fetch.js +0 -27
- package/cjs/transports/new-fetch.js.map +0 -1
- package/cjs/transports/new-xhr.d.ts +0 -11
- package/cjs/transports/new-xhr.d.ts.map +0 -1
- package/cjs/transports/new-xhr.js +0 -46
- package/cjs/transports/new-xhr.js.map +0 -1
- package/cjs/transports/setup.d.ts +0 -22
- package/cjs/transports/setup.d.ts.map +0 -1
- package/cjs/transports/setup.js +0 -44
- package/cjs/transports/setup.js.map +0 -1
- package/esm/transports/base.d.ts +0 -65
- package/esm/transports/base.d.ts.map +0 -1
- package/esm/transports/base.js +0 -140
- package/esm/transports/base.js.map +0 -1
- package/esm/transports/new-fetch.d.ts +0 -10
- package/esm/transports/new-fetch.d.ts.map +0 -1
- package/esm/transports/new-fetch.js +0 -25
- package/esm/transports/new-fetch.js.map +0 -1
- package/esm/transports/new-xhr.d.ts +0 -11
- package/esm/transports/new-xhr.d.ts.map +0 -1
- package/esm/transports/new-xhr.js +0 -44
- package/esm/transports/new-xhr.js.map +0 -1
- package/esm/transports/setup.d.ts +0 -22
- package/esm/transports/setup.d.ts.map +0 -1
- package/esm/transports/setup.js +0 -42
- package/esm/transports/setup.js.map +0 -1
- package/types/transports/base.d.ts +0 -65
- package/types/transports/base.d.ts.map +0 -1
- package/types/transports/new-fetch.d.ts +0 -10
- package/types/transports/new-fetch.d.ts.map +0 -1
- package/types/transports/new-xhr.d.ts +0 -11
- package/types/transports/new-xhr.d.ts.map +0 -1
- package/types/transports/setup.d.ts +0 -22
- package/types/transports/setup.d.ts.map +0 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import { fill, getFunctionName, getGlobalObject, getOriginalFunction } from '@sentry/utils';
|
|
3
2
|
import { wrap } from '../helpers';
|
|
4
|
-
|
|
3
|
+
const DEFAULT_EVENT_TARGET = [
|
|
5
4
|
'EventTarget',
|
|
6
5
|
'Window',
|
|
7
6
|
'Node',
|
|
@@ -33,23 +32,23 @@ var DEFAULT_EVENT_TARGET = [
|
|
|
33
32
|
'XMLHttpRequestUpload',
|
|
34
33
|
];
|
|
35
34
|
/** Wrap timer functions and event targets to catch errors and provide better meta data */
|
|
36
|
-
|
|
35
|
+
export class TryCatch {
|
|
37
36
|
/**
|
|
38
37
|
* @inheritDoc
|
|
39
38
|
*/
|
|
40
|
-
|
|
39
|
+
constructor(options) {
|
|
41
40
|
/**
|
|
42
41
|
* @inheritDoc
|
|
43
42
|
*/
|
|
44
43
|
this.name = TryCatch.id;
|
|
45
|
-
this._options =
|
|
44
|
+
this._options = Object.assign({ XMLHttpRequest: true, eventTarget: true, requestAnimationFrame: true, setInterval: true, setTimeout: true }, options);
|
|
46
45
|
}
|
|
47
46
|
/**
|
|
48
47
|
* Wrap timer functions and event targets to catch errors
|
|
49
48
|
* and provide better metadata.
|
|
50
49
|
*/
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
setupOnce() {
|
|
51
|
+
const global = getGlobalObject();
|
|
53
52
|
if (this._options.setTimeout) {
|
|
54
53
|
fill(global, 'setTimeout', _wrapTimeFunction);
|
|
55
54
|
}
|
|
@@ -62,28 +61,22 @@ var TryCatch = /** @class */ (function () {
|
|
|
62
61
|
if (this._options.XMLHttpRequest && 'XMLHttpRequest' in global) {
|
|
63
62
|
fill(XMLHttpRequest.prototype, 'send', _wrapXHR);
|
|
64
63
|
}
|
|
65
|
-
|
|
64
|
+
const eventTargetOption = this._options.eventTarget;
|
|
66
65
|
if (eventTargetOption) {
|
|
67
|
-
|
|
66
|
+
const eventTarget = Array.isArray(eventTargetOption) ? eventTargetOption : DEFAULT_EVENT_TARGET;
|
|
68
67
|
eventTarget.forEach(_wrapEventTarget);
|
|
69
68
|
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}());
|
|
77
|
-
export { TryCatch };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* @inheritDoc
|
|
73
|
+
*/
|
|
74
|
+
TryCatch.id = 'TryCatch';
|
|
78
75
|
/** JSDoc */
|
|
79
76
|
function _wrapTimeFunction(original) {
|
|
80
77
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
|
-
return function () {
|
|
82
|
-
|
|
83
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
84
|
-
args[_i] = arguments[_i];
|
|
85
|
-
}
|
|
86
|
-
var originalCallback = args[0];
|
|
78
|
+
return function (...args) {
|
|
79
|
+
const originalCallback = args[0];
|
|
87
80
|
args[0] = wrap(originalCallback, {
|
|
88
81
|
mechanism: {
|
|
89
82
|
data: { function: getFunctionName(original) },
|
|
@@ -117,19 +110,15 @@ function _wrapRAF(original) {
|
|
|
117
110
|
/** JSDoc */
|
|
118
111
|
function _wrapXHR(originalSend) {
|
|
119
112
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
120
|
-
return function () {
|
|
121
|
-
var args = [];
|
|
122
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
123
|
-
args[_i] = arguments[_i];
|
|
124
|
-
}
|
|
113
|
+
return function (...args) {
|
|
125
114
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
xmlHttpRequestProps.forEach(
|
|
115
|
+
const xhr = this;
|
|
116
|
+
const xmlHttpRequestProps = ['onload', 'onerror', 'onprogress', 'onreadystatechange'];
|
|
117
|
+
xmlHttpRequestProps.forEach(prop => {
|
|
129
118
|
if (prop in xhr && typeof xhr[prop] === 'function') {
|
|
130
119
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
131
120
|
fill(xhr, prop, function (original) {
|
|
132
|
-
|
|
121
|
+
const wrapOptions = {
|
|
133
122
|
mechanism: {
|
|
134
123
|
data: {
|
|
135
124
|
function: prop,
|
|
@@ -140,7 +129,7 @@ function _wrapXHR(originalSend) {
|
|
|
140
129
|
},
|
|
141
130
|
};
|
|
142
131
|
// If Instrument integration has been called before TryCatch, get the name of original function
|
|
143
|
-
|
|
132
|
+
const originalFunction = getOriginalFunction(original);
|
|
144
133
|
if (originalFunction) {
|
|
145
134
|
wrapOptions.mechanism.data.handler = getFunctionName(originalFunction);
|
|
146
135
|
}
|
|
@@ -155,9 +144,9 @@ function _wrapXHR(originalSend) {
|
|
|
155
144
|
/** JSDoc */
|
|
156
145
|
function _wrapEventTarget(target) {
|
|
157
146
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
158
|
-
|
|
147
|
+
const global = getGlobalObject();
|
|
159
148
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
160
|
-
|
|
149
|
+
const proto = global[target] && global[target].prototype;
|
|
161
150
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, no-prototype-builtins
|
|
162
151
|
if (!proto || !proto.hasOwnProperty || !proto.hasOwnProperty('addEventListener')) {
|
|
163
152
|
return;
|
|
@@ -171,7 +160,7 @@ function _wrapEventTarget(target) {
|
|
|
171
160
|
data: {
|
|
172
161
|
function: 'handleEvent',
|
|
173
162
|
handler: getFunctionName(fn),
|
|
174
|
-
target
|
|
163
|
+
target,
|
|
175
164
|
},
|
|
176
165
|
handled: true,
|
|
177
166
|
type: 'instrument',
|
|
@@ -190,7 +179,7 @@ function _wrapEventTarget(target) {
|
|
|
190
179
|
data: {
|
|
191
180
|
function: 'addEventListener',
|
|
192
181
|
handler: getFunctionName(fn),
|
|
193
|
-
target
|
|
182
|
+
target,
|
|
194
183
|
},
|
|
195
184
|
handled: true,
|
|
196
185
|
type: 'instrument',
|
|
@@ -219,9 +208,9 @@ function _wrapEventTarget(target) {
|
|
|
219
208
|
* then we have to detach both of them. Otherwise, if we'd detach only wrapped one, it'd be impossible
|
|
220
209
|
* to get rid of the initial handler and it'd stick there forever.
|
|
221
210
|
*/
|
|
222
|
-
|
|
211
|
+
const wrappedEventHandler = fn;
|
|
223
212
|
try {
|
|
224
|
-
|
|
213
|
+
const originalEventHandler = wrappedEventHandler && wrappedEventHandler.__sentry_wrapped__;
|
|
225
214
|
if (originalEventHandler) {
|
|
226
215
|
originalRemoveEventListener.call(this, eventName, originalEventHandler, options);
|
|
227
216
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trycatch.js","sourceRoot":"","sources":["../../../../src/integrations/trycatch.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAE5F,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;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;Q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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,CACF,CAAC;AACJ,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.apply(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 (original: () => void): (\n eventName: string,\n fn: EventListenerObject,\n options?: boolean | AddEventListenerOptions,\n ) => 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.apply(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(\n proto,\n 'removeEventListener',\n 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}\n"]}
|
|
1
|
+
{"version":3,"file":"trycatch.js","sourceRoot":"","sources":["../../../../src/integrations/trycatch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAE5F,OAAO,EAAE,IAAI,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ACrB,UACE,2BAAuC;QAGvC,OAAO,UAGL,SAAiB,EACjB,EAAuB,EACvB,OAAwC;YAExC;;;;;;;;;;;;;;;;eAgBG;YACH,MAAM,mBAAmB,GAAG,EAAgC,CAAC;YAC7D,IAAI;gBACF,MAAM,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,CACF,CAAC;AACJ,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.apply(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 (original: () => void): (\n eventName: string,\n fn: EventListenerObject,\n options?: boolean | AddEventListenerOptions,\n ) => 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.apply(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(\n proto,\n 'removeEventListener',\n 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}\n"]}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import { addGlobalEventProcessor, getCurrentHub } from '@sentry/core';
|
|
3
2
|
import { getGlobalObject } from '@sentry/utils';
|
|
4
|
-
|
|
3
|
+
const global = getGlobalObject();
|
|
5
4
|
/** UserAgent */
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
export class UserAgent {
|
|
6
|
+
constructor() {
|
|
8
7
|
/**
|
|
9
8
|
* @inheritDoc
|
|
10
9
|
*/
|
|
@@ -13,29 +12,27 @@ var UserAgent = /** @class */ (function () {
|
|
|
13
12
|
/**
|
|
14
13
|
* @inheritDoc
|
|
15
14
|
*/
|
|
16
|
-
|
|
17
|
-
addGlobalEventProcessor(
|
|
15
|
+
setupOnce() {
|
|
16
|
+
addGlobalEventProcessor((event) => {
|
|
18
17
|
if (getCurrentHub().getIntegration(UserAgent)) {
|
|
19
18
|
// if none of the information we want exists, don't bother
|
|
20
19
|
if (!global.navigator && !global.location && !global.document) {
|
|
21
20
|
return event;
|
|
22
21
|
}
|
|
23
22
|
// grab as much info as exists and add it to the event
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return
|
|
23
|
+
const url = (event.request && event.request.url) || (global.location && global.location.href);
|
|
24
|
+
const { referrer } = global.document || {};
|
|
25
|
+
const { userAgent } = global.navigator || {};
|
|
26
|
+
const headers = Object.assign(Object.assign(Object.assign({}, (event.request && event.request.headers)), (referrer && { Referer: referrer })), (userAgent && { 'User-Agent': userAgent }));
|
|
27
|
+
const request = Object.assign(Object.assign({}, (url && { url })), { headers });
|
|
28
|
+
return Object.assign(Object.assign({}, event), { request });
|
|
30
29
|
}
|
|
31
30
|
return event;
|
|
32
31
|
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}());
|
|
40
|
-
export { UserAgent };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @inheritDoc
|
|
36
|
+
*/
|
|
37
|
+
UserAgent.id = 'UserAgent';
|
|
41
38
|
//# sourceMappingURL=useragent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useragent.js","sourceRoot":"","sources":["../../../../src/integrations/useragent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useragent.js","sourceRoot":"","sources":["../../../../src/integrations/useragent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,MAAM,GAAG,eAAe,EAAU,CAAC;AAEzC,gBAAgB;AAChB,MAAM,OAAO,SAAS;IAAtB;QAME;;WAEG;QACI,SAAI,GAAW,SAAS,CAAC,EAAE,CAAC;IA8BrC,CAAC;IA5BC;;OAEG;IACI,SAAS;QACd,uBAAuB,CAAC,CAAC,KAAY,EAAE,EAAE;YACvC,IAAI,aAAa,EAAE,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE;gBAC7C,0DAA0D;gBAC1D,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;oBAC7D,OAAO,KAAK,CAAC;iBACd;gBAED,sDAAsD;gBACtD,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;gBAC9F,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC;gBAC3C,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC;gBAE7C,MAAM,OAAO,iDACR,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,GACxC,CAAC,QAAQ,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,GACnC,CAAC,SAAS,IAAI,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC,CAC9C,CAAC;gBACF,MAAM,OAAO,mCAAQ,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,CAAC,KAAE,OAAO,GAAE,CAAC;gBAEjD,uCAAY,KAAK,KAAE,OAAO,IAAG;aAC9B;YACD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;;AArCD;;GAEG;AACW,YAAE,GAAW,WAAW,CAAC","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/esm/sdk.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Integrations as CoreIntegrations } from '@sentry/core';
|
|
1
|
+
import { Hub, Integrations as CoreIntegrations } from '@sentry/core';
|
|
2
2
|
import { BrowserOptions } from './client';
|
|
3
3
|
import { ReportDialogOptions } from './helpers';
|
|
4
4
|
import { Breadcrumbs, Dedupe, GlobalHandlers, LinkedErrors, TryCatch, UserAgent } from './integrations';
|
|
@@ -66,7 +66,7 @@ export declare function init(options?: BrowserOptions): void;
|
|
|
66
66
|
*
|
|
67
67
|
* @param options Everything is optional, we try to fetch all info need from the global scope.
|
|
68
68
|
*/
|
|
69
|
-
export declare function showReportDialog(options?: ReportDialogOptions): void;
|
|
69
|
+
export declare function showReportDialog(options?: ReportDialogOptions, hub?: Hub): void;
|
|
70
70
|
/**
|
|
71
71
|
* This is the getter for lastEventId.
|
|
72
72
|
*
|
package/esm/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,GAAG,EAEH,YAAY,IAAI,gBAAgB,EACjC,MAAM,cAAc,CAAC;AAUtB,OAAO,EAAuC,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/E,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;AAIxG,eAAO,MAAM,mBAAmB,uJAS/B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,IAAI,CAAC,OAAO,GAAE,cAAmB,GAAG,IAAI,CA8BvD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,mBAAwB,EAAE,GAAG,GAAE,GAAqB,GAAG,IAAI,CAyCpG;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,CAO5D;AAED;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,CAO5D;AAED;;;;;;GAMG;AAEH,wBAAgB,IAAI,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,GAAG,GAAG,CAEnD"}
|
package/esm/sdk.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { addInstrumentationHandler, getGlobalObject, logger, resolvedSyncPromise } from '@sentry/utils';
|
|
1
|
+
import { getCurrentHub, getIntegrationsToSetup, getReportDialogEndpoint, initAndBind, Integrations as CoreIntegrations, } from '@sentry/core';
|
|
2
|
+
import { addInstrumentationHandler, getGlobalObject, logger, resolvedSyncPromise, stackParserFromStackParserOptions, supportsFetch, } from '@sentry/utils';
|
|
4
3
|
import { BrowserClient } from './client';
|
|
5
4
|
import { IS_DEBUG_BUILD } from './flags';
|
|
6
5
|
import { wrap as internalWrap } from './helpers';
|
|
7
6
|
import { Breadcrumbs, Dedupe, GlobalHandlers, LinkedErrors, TryCatch, UserAgent } from './integrations';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
export
|
|
7
|
+
import { defaultStackParser } from './stack-parsers';
|
|
8
|
+
import { makeFetchTransport, makeXHRTransport } from './transports';
|
|
9
|
+
export const defaultIntegrations = [
|
|
11
10
|
new CoreIntegrations.InboundFilters(),
|
|
12
11
|
new CoreIntegrations.FunctionToString(),
|
|
13
12
|
new TryCatch(),
|
|
@@ -74,16 +73,15 @@ export var defaultIntegrations = [
|
|
|
74
73
|
*
|
|
75
74
|
* @see {@link BrowserOptions} for documentation on configuration options.
|
|
76
75
|
*/
|
|
77
|
-
export function init(options) {
|
|
78
|
-
if (options === void 0) { options = {}; }
|
|
76
|
+
export function init(options = {}) {
|
|
79
77
|
if (options.defaultIntegrations === undefined) {
|
|
80
78
|
options.defaultIntegrations = defaultIntegrations;
|
|
81
79
|
}
|
|
82
80
|
if (options.release === undefined) {
|
|
83
|
-
|
|
81
|
+
const window = getGlobalObject();
|
|
84
82
|
// This supports the variable that sentry-webpack-plugin injects
|
|
85
|
-
if (
|
|
86
|
-
options.release =
|
|
83
|
+
if (window.SENTRY_RELEASE && window.SENTRY_RELEASE.id) {
|
|
84
|
+
options.release = window.SENTRY_RELEASE.id;
|
|
87
85
|
}
|
|
88
86
|
}
|
|
89
87
|
if (options.autoSessionTracking === undefined) {
|
|
@@ -92,11 +90,8 @@ export function init(options) {
|
|
|
92
90
|
if (options.sendClientReports === undefined) {
|
|
93
91
|
options.sendClientReports = true;
|
|
94
92
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
var _a = setupBrowserTransport(options), transport = _a.transport, newTransport = _a.newTransport;
|
|
99
|
-
initAndBind(BrowserClient, options, transport, newTransport);
|
|
93
|
+
const clientOptions = Object.assign(Object.assign({}, options), { stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser), integrations: getIntegrationsToSetup(options), transport: options.transport || (supportsFetch() ? makeFetchTransport : makeXHRTransport) });
|
|
94
|
+
initAndBind(BrowserClient, clientOptions);
|
|
100
95
|
if (options.autoSessionTracking) {
|
|
101
96
|
startSessionTracking();
|
|
102
97
|
}
|
|
@@ -106,19 +101,38 @@ export function init(options) {
|
|
|
106
101
|
*
|
|
107
102
|
* @param options Everything is optional, we try to fetch all info need from the global scope.
|
|
108
103
|
*/
|
|
109
|
-
export function showReportDialog(options) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
104
|
+
export function showReportDialog(options = {}, hub = getCurrentHub()) {
|
|
105
|
+
// doesn't work without a document (React Native)
|
|
106
|
+
const global = getGlobalObject();
|
|
107
|
+
if (!global.document) {
|
|
108
|
+
IS_DEBUG_BUILD && logger.error('Global document not defined in showReportDialog call');
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const { client, scope } = hub.getStackTop();
|
|
112
|
+
const dsn = options.dsn || (client && client.getDsn());
|
|
113
|
+
if (!dsn) {
|
|
114
|
+
IS_DEBUG_BUILD && logger.error('DSN not configured for showReportDialog call');
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
113
117
|
if (scope) {
|
|
114
|
-
options.user =
|
|
118
|
+
options.user = Object.assign(Object.assign({}, scope.getUser()), options.user);
|
|
115
119
|
}
|
|
116
120
|
if (!options.eventId) {
|
|
117
121
|
options.eventId = hub.lastEventId();
|
|
118
122
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
123
|
+
const script = global.document.createElement('script');
|
|
124
|
+
script.async = true;
|
|
125
|
+
script.src = getReportDialogEndpoint(dsn, options);
|
|
126
|
+
if (options.onLoad) {
|
|
127
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
128
|
+
script.onload = options.onLoad;
|
|
129
|
+
}
|
|
130
|
+
const injectionPoint = global.document.head || global.document.body;
|
|
131
|
+
if (injectionPoint) {
|
|
132
|
+
injectionPoint.appendChild(script);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
IS_DEBUG_BUILD && logger.error('Not injecting report dialog. No injection point found in HTML');
|
|
122
136
|
}
|
|
123
137
|
}
|
|
124
138
|
/**
|
|
@@ -152,7 +166,7 @@ export function onLoad(callback) {
|
|
|
152
166
|
* doesn't (or if there's no client defined).
|
|
153
167
|
*/
|
|
154
168
|
export function flush(timeout) {
|
|
155
|
-
|
|
169
|
+
const client = getCurrentHub().getClient();
|
|
156
170
|
if (client) {
|
|
157
171
|
return client.flush(timeout);
|
|
158
172
|
}
|
|
@@ -168,7 +182,7 @@ export function flush(timeout) {
|
|
|
168
182
|
* doesn't (or if there's no client defined).
|
|
169
183
|
*/
|
|
170
184
|
export function close(timeout) {
|
|
171
|
-
|
|
185
|
+
const client = getCurrentHub().getClient();
|
|
172
186
|
if (client) {
|
|
173
187
|
return client.close(timeout);
|
|
174
188
|
}
|
|
@@ -194,13 +208,13 @@ function startSessionOnHub(hub) {
|
|
|
194
208
|
* Enable automatic Session Tracking for the initial page load.
|
|
195
209
|
*/
|
|
196
210
|
function startSessionTracking() {
|
|
197
|
-
|
|
198
|
-
|
|
211
|
+
const window = getGlobalObject();
|
|
212
|
+
const document = window.document;
|
|
199
213
|
if (typeof document === 'undefined') {
|
|
200
214
|
IS_DEBUG_BUILD && logger.warn('Session tracking in non-browser environment with @sentry/browser is not supported.');
|
|
201
215
|
return;
|
|
202
216
|
}
|
|
203
|
-
|
|
217
|
+
const hub = getCurrentHub();
|
|
204
218
|
// The only way for this to be false is for there to be a version mismatch between @sentry/browser (>= 6.0.0) and
|
|
205
219
|
// @sentry/hub (< 5.27.0). In the simple case, there won't ever be such a mismatch, because the two packages are
|
|
206
220
|
// pinned at the same version in package.json, but there are edge cases where it's possible. See
|
|
@@ -216,8 +230,7 @@ function startSessionTracking() {
|
|
|
216
230
|
// discard their duration.
|
|
217
231
|
startSessionOnHub(hub);
|
|
218
232
|
// We want to create a session for every navigation as well
|
|
219
|
-
addInstrumentationHandler('history',
|
|
220
|
-
var from = _a.from, to = _a.to;
|
|
233
|
+
addInstrumentationHandler('history', ({ from, to }) => {
|
|
221
234
|
// Don't create an additional session for the initial route or if the location did not change
|
|
222
235
|
if (!(from === undefined || from === to)) {
|
|
223
236
|
startSessionOnHub(getCurrentHub());
|
package/esm/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../../src/sdk.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAE5F,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAExG,OAAO,EAAE,aAAa,EAAkB,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAuB,IAAI,IAAI,YAAY,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACxG,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,MAAM,CAAC,IAAM,mBAAmB,GAAG;IACjC,IAAI,gBAAgB,CAAC,cAAc,EAAE;IACrC,IAAI,gBAAgB,CAAC,gBAAgB,EAAE;IACvC,IAAI,QAAQ,EAAE;IACd,IAAI,WAAW,EAAE;IACjB,IAAI,cAAc,EAAE;IACpB,IAAI,YAAY,EAAE;IAClB,IAAI,MAAM,EAAE;IACZ,IAAI,SAAS,EAAE;CAChB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,MAAM,UAAU,IAAI,CAAC,OAA4B;IAA5B,wBAAA,EAAA,YAA4B;IAC/C,IAAI,OAAO,CAAC,mBAAmB,KAAK,SAAS,EAAE;QAC7C,OAAO,CAAC,mBAAmB,GAA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AG,CAAC,cAAc,EAAE,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,SAAS,oBAAoB;IAC3B,IAAM,MAAM,GAAG,eAAe,EAAU,CAAC;IACzC,IAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IAEjC,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;QACnC,cAAc,IAAI,MAAM,CAAC,IAAI,CAAC,oFAAoF,CAAC,CAAC;QACpH,OAAO;KACR;IAED,IAAM,GAAG,GAAG,aAAa,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,yBAAyB,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,aAAa,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, logger, resolvedSyncPromise } from '@sentry/utils';\n\nimport { BrowserClient, BrowserOptions } from './client';\nimport { IS_DEBUG_BUILD } from './flags';\nimport { ReportDialogOptions, wrap as internalWrap } from './helpers';\nimport { Breadcrumbs, Dedupe, GlobalHandlers, LinkedErrors, TryCatch, UserAgent } from './integrations';\nimport { defaultStackParsers } from './stack-parsers';\nimport { setupBrowserTransport } from './transports/setup';\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 if (options.stackParser === undefined) {\n options.stackParser = defaultStackParsers;\n }\n\n const { transport, newTransport } = setupBrowserTransport(options);\n initAndBind(BrowserClient, options, transport, newTransport);\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 IS_DEBUG_BUILD && logger.warn('Cannot flush events. No client defined.');\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 IS_DEBUG_BUILD && logger.warn('Cannot flush events and disable SDK. No client defined.');\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 IS_DEBUG_BUILD && 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 (!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"]}
|
|
1
|
+
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,uBAAuB,EAEvB,WAAW,EACX,YAAY,IAAI,gBAAgB,GACjC,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,yBAAyB,EACzB,eAAe,EACf,MAAM,EACN,mBAAmB,EACnB,iCAAiC,EACjC,aAAa,GACd,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,aAAa,EA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S,IAAI,IAAI,KAAK,EAAE,CAAC,EAAE;YACxC,iBAAiB,CAAC,aAAa,EAAE,CAAC,CAAC;SACpC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n getCurrentHub,\n getIntegrationsToSetup,\n getReportDialogEndpoint,\n Hub,\n initAndBind,\n Integrations as CoreIntegrations,\n} from '@sentry/core';\nimport {\n addInstrumentationHandler,\n getGlobalObject,\n logger,\n resolvedSyncPromise,\n stackParserFromStackParserOptions,\n supportsFetch,\n} from '@sentry/utils';\n\nimport { BrowserClient, BrowserClientOptions, BrowserOptions } from './client';\nimport { IS_DEBUG_BUILD } from './flags';\nimport { ReportDialogOptions, wrap as internalWrap } from './helpers';\nimport { Breadcrumbs, Dedupe, GlobalHandlers, LinkedErrors, TryCatch, UserAgent } from './integrations';\nimport { defaultStackParser } from './stack-parsers';\nimport { makeFetchTransport, makeXHRTransport } from './transports';\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 const clientOptions: BrowserClientOptions = {\n ...options,\n stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n integrations: getIntegrationsToSetup(options),\n transport: options.transport || (supportsFetch() ? makeFetchTransport : makeXHRTransport),\n };\n\n initAndBind(BrowserClient, clientOptions);\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 = {}, hub: Hub = getCurrentHub()): void {\n // doesn't work without a document (React Native)\n const global = getGlobalObject<Window>();\n if (!global.document) {\n IS_DEBUG_BUILD && logger.error('Global document not defined in showReportDialog call');\n return;\n }\n\n const { client, scope } = hub.getStackTop();\n const dsn = options.dsn || (client && client.getDsn());\n if (!dsn) {\n IS_DEBUG_BUILD && logger.error('DSN not configured for showReportDialog call');\n return;\n }\n\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\n const script = global.document.createElement('script');\n script.async = true;\n script.src = getReportDialogEndpoint(dsn, options);\n\n if (options.onLoad) {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n script.onload = options.onLoad;\n }\n\n const injectionPoint = global.document.head || global.document.body;\n if (injectionPoint) {\n injectionPoint.appendChild(script);\n } else {\n IS_DEBUG_BUILD && logger.error('Not injecting report dialog. No injection point found in HTML');\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 IS_DEBUG_BUILD && logger.warn('Cannot flush events. No client defined.');\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 IS_DEBUG_BUILD && logger.warn('Cannot flush events and disable SDK. No client defined.');\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 IS_DEBUG_BUILD && 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 (!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"]}
|
package/esm/stack-parsers.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { StackLineParser } from '@sentry/types';
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
2
|
+
export declare const chromeStackLineParser: StackLineParser;
|
|
3
|
+
export declare const geckoStackLineParser: StackLineParser;
|
|
4
|
+
export declare const winjsStackLineParser: StackLineParser;
|
|
5
|
+
export declare const opera10StackLineParser: StackLineParser;
|
|
6
|
+
export declare const opera11StackLineParser: StackLineParser;
|
|
7
|
+
export declare const defaultStackLineParsers: StackLineParser[];
|
|
8
|
+
export declare const defaultStackParser: import("@sentry/types").StackParser;
|
|
8
9
|
//# sourceMappingURL=stack-parsers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack-parsers.d.ts","sourceRoot":"","sources":["../../../src/stack-parsers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,eAAe,EAAqB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"stack-parsers.d.ts","sourceRoot":"","sources":["../../../src/stack-parsers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,eAAe,EAAqB,MAAM,eAAe,CAAC;AA+D/E,eAAO,MAAM,qBAAqB,EAAE,eAA2C,CAAC;AAoChF,eAAO,MAAM,oBAAoB,EAAE,eAAyC,CAAC;AAa7E,eAAO,MAAM,oBAAoB,EAAE,eAAyC,CAAC;AAS7E,eAAO,MAAM,sBAAsB,EAAE,eAA6C,CAAC;AAUnF,eAAO,MAAM,sBAAsB,EAAE,eAA6C,CAAC;AAEnF,eAAO,MAAM,uBAAuB,mBAAsE,CAAC;AAE3G,eAAO,MAAM,kBAAkB,qCAAgD,CAAC"}
|