@cloudcare/browser-core 1.1.3 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/cjs/{cookie.js → browser/cookie.js} +6 -37
  2. package/cjs/browser/fetchObservable.js +91 -0
  3. package/cjs/browser/xhrObservable.js +118 -0
  4. package/cjs/configuration/configuration.js +70 -0
  5. package/cjs/configuration/transportConfiguration.js +64 -0
  6. package/cjs/console/consoleObservable.js +84 -0
  7. package/cjs/dataMap.js +26 -21
  8. package/cjs/error/trackRuntimeError.js +27 -0
  9. package/cjs/helper/catchUserErrors.js +20 -0
  10. package/cjs/helper/contextHistory.js +134 -0
  11. package/cjs/helper/createEventRateLimiter.js +47 -0
  12. package/cjs/helper/deviceInfo.js +8 -25
  13. package/cjs/helper/display.js +31 -0
  14. package/cjs/helper/enums.js +28 -2
  15. package/cjs/helper/errorTools.js +63 -2
  16. package/cjs/helper/instrumentMethod.js +93 -0
  17. package/cjs/helper/lifeCycle.js +5 -3
  18. package/cjs/helper/observable.js +40 -2
  19. package/cjs/helper/tools.js +185 -9
  20. package/cjs/index.js +153 -23
  21. package/cjs/init.js +17 -27
  22. package/cjs/report/reportObservable.js +112 -0
  23. package/cjs/session/sessionConstants.js +13 -0
  24. package/cjs/session/sessionCookieStore.js +188 -0
  25. package/cjs/session/sessionManagement.js +96 -0
  26. package/cjs/session/sessionStore.js +150 -0
  27. package/cjs/synthetics/syntheticsWorkerValues.js +32 -0
  28. package/cjs/synthetics/usr.js +32 -0
  29. package/cjs/tracekit/computeStackTrace.js +73 -563
  30. package/cjs/tracekit/index.js +3 -15
  31. package/cjs/tracekit/tracekit.js +113 -0
  32. package/cjs/transport/batch.js +332 -0
  33. package/cjs/transport/httpRequest.js +112 -0
  34. package/cjs/transport/index.js +29 -0
  35. package/cjs/transport/sendWithRetryStrategy.js +177 -0
  36. package/cjs/transport/startBatchWithReplica.js +24 -0
  37. package/esm/{cookie.js → browser/cookie.js} +4 -35
  38. package/esm/browser/fetchObservable.js +77 -0
  39. package/esm/browser/xhrObservable.js +106 -0
  40. package/esm/configuration/configuration.js +55 -0
  41. package/esm/configuration/transportConfiguration.js +54 -0
  42. package/esm/console/consoleObservable.js +70 -0
  43. package/esm/dataMap.js +26 -21
  44. package/esm/error/trackRuntimeError.js +16 -0
  45. package/esm/helper/catchUserErrors.js +12 -0
  46. package/esm/helper/contextHistory.js +106 -0
  47. package/esm/helper/createEventRateLimiter.js +38 -0
  48. package/esm/helper/deviceInfo.js +6 -25
  49. package/esm/helper/display.js +21 -0
  50. package/esm/helper/enums.js +25 -1
  51. package/esm/helper/errorTools.js +58 -3
  52. package/esm/helper/instrumentMethod.js +81 -0
  53. package/esm/helper/lifeCycle.js +5 -3
  54. package/esm/helper/observable.js +39 -3
  55. package/esm/helper/tools.js +147 -1
  56. package/esm/index.js +17 -7
  57. package/esm/init.js +17 -22
  58. package/esm/report/reportObservable.js +98 -0
  59. package/esm/session/sessionConstants.js +3 -0
  60. package/esm/session/sessionCookieStore.js +168 -0
  61. package/esm/session/sessionManagement.js +78 -0
  62. package/esm/session/sessionStore.js +139 -0
  63. package/esm/synthetics/syntheticsWorkerValues.js +15 -0
  64. package/esm/synthetics/usr.js +18 -0
  65. package/esm/tracekit/computeStackTrace.js +73 -557
  66. package/esm/tracekit/index.js +1 -1
  67. package/esm/tracekit/tracekit.js +103 -0
  68. package/esm/transport/batch.js +316 -0
  69. package/esm/transport/httpRequest.js +104 -0
  70. package/esm/transport/index.js +3 -0
  71. package/esm/transport/sendWithRetryStrategy.js +165 -0
  72. package/esm/transport/startBatchWithReplica.js +15 -0
  73. package/package.json +2 -2
  74. package/src/.DS_Store +0 -0
  75. package/src/{cookie.js → browser/cookie.js} +6 -34
  76. package/src/browser/fetchObservable.js +86 -0
  77. package/src/browser/xhrObservable.js +102 -0
  78. package/src/configuration/configuration.js +61 -0
  79. package/src/configuration/transportConfiguration.js +42 -0
  80. package/src/console/consoleObservable.js +65 -0
  81. package/src/dataMap.js +26 -21
  82. package/src/error/trackRuntimeError.js +19 -0
  83. package/src/helper/catchUserErrors.js +12 -0
  84. package/src/helper/contextHistory.js +85 -0
  85. package/src/helper/createEventRateLimiter.js +37 -0
  86. package/src/helper/deviceInfo.js +5 -51
  87. package/src/helper/display.js +21 -0
  88. package/src/helper/enums.js +38 -14
  89. package/src/helper/errorTools.js +76 -12
  90. package/src/helper/instrumentMethod.js +97 -0
  91. package/src/helper/lifeCycle.js +5 -3
  92. package/src/helper/observable.js +33 -2
  93. package/src/helper/tools.js +135 -4
  94. package/src/index.js +18 -7
  95. package/src/init.js +17 -18
  96. package/src/report/reportObservable.js +113 -0
  97. package/src/session/sessionConstants.js +3 -0
  98. package/src/session/sessionCookieStore.js +159 -0
  99. package/src/session/sessionManagement.js +89 -0
  100. package/src/session/sessionStore.js +139 -0
  101. package/src/synthetics/syntheticsWorkerValues.js +22 -0
  102. package/src/synthetics/usr.js +18 -0
  103. package/src/tracekit/computeStackTrace.js +75 -551
  104. package/src/tracekit/index.js +1 -1
  105. package/src/tracekit/tracekit.js +100 -0
  106. package/src/transport/batch.js +289 -0
  107. package/src/transport/httpRequest.js +109 -0
  108. package/src/transport/index.js +3 -0
  109. package/src/transport/sendWithRetryStrategy.js +186 -0
  110. package/src/transport/startBatchWithReplica.js +26 -0
  111. package/cjs/configuration.js +0 -193
  112. package/cjs/errorCollection.js +0 -167
  113. package/cjs/fetchProxy.js +0 -161
  114. package/cjs/helper/errorFilter.js +0 -47
  115. package/cjs/sessionManagement.js +0 -221
  116. package/cjs/tracekit/report.js +0 -289
  117. package/cjs/transport.js +0 -373
  118. package/cjs/xhrProxy.js +0 -122
  119. package/esm/configuration.js +0 -176
  120. package/esm/errorCollection.js +0 -141
  121. package/esm/fetchProxy.js +0 -115
  122. package/esm/helper/errorFilter.js +0 -38
  123. package/esm/sessionManagement.js +0 -195
  124. package/esm/tracekit/report.js +0 -273
  125. package/esm/transport.js +0 -357
  126. package/esm/xhrProxy.js +0 -110
  127. package/src/configuration.js +0 -161
  128. package/src/errorCollection.js +0 -170
  129. package/src/fetchProxy.js +0 -108
  130. package/src/helper/errorFilter.js +0 -38
  131. package/src/sessionManagement.js +0 -224
  132. package/src/tracekit/report.js +0 -284
  133. package/src/transport.js +0 -380
  134. package/src/xhrProxy.js +0 -106
@@ -1,221 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.VISIBILITY_CHECK_DELAY = exports.SESSION_TIME_OUT_DELAY = exports.SESSION_EXPIRATION_DELAY = exports.SESSION_COOKIE_NAME = exports.ANONYMOUS_ID_EXPIRATION = exports.ANONYMOUS_ID_COOKIE_NAME = void 0;
7
- exports.isValidSessionString = isValidSessionString;
8
- exports.persistSession = persistSession;
9
- exports.startSessionManagement = startSessionManagement;
10
- exports.stopSessionManagement = stopSessionManagement;
11
- exports.trackActivity = trackActivity;
12
-
13
- var _cookie = require("./cookie");
14
-
15
- var _observable = require("./helper/observable");
16
-
17
- var _tools = require("./helper/tools");
18
-
19
- var _enums = require("./helper/enums");
20
-
21
- var SESSION_COOKIE_NAME = '_dataflux_s';
22
- exports.SESSION_COOKIE_NAME = SESSION_COOKIE_NAME;
23
- var SESSION_EXPIRATION_DELAY = 15 * _tools.ONE_MINUTE;
24
- exports.SESSION_EXPIRATION_DELAY = SESSION_EXPIRATION_DELAY;
25
- var SESSION_TIME_OUT_DELAY = 4 * _tools.ONE_HOUR;
26
- exports.SESSION_TIME_OUT_DELAY = SESSION_TIME_OUT_DELAY;
27
- var VISIBILITY_CHECK_DELAY = _tools.ONE_MINUTE;
28
- exports.VISIBILITY_CHECK_DELAY = VISIBILITY_CHECK_DELAY;
29
- var ANONYMOUS_ID_COOKIE_NAME = '_dataflulx_an_id';
30
- exports.ANONYMOUS_ID_COOKIE_NAME = ANONYMOUS_ID_COOKIE_NAME;
31
- var ANONYMOUS_ID_EXPIRATION = 60 * 24 * _tools.ONE_HOUR;
32
- exports.ANONYMOUS_ID_EXPIRATION = ANONYMOUS_ID_EXPIRATION;
33
-
34
- function cacheAnonymousID(options) {
35
- var anonymousCookie = (0, _cookie.cacheCookieAccess)(ANONYMOUS_ID_COOKIE_NAME, options);
36
- var anonymouseId = anonymousCookie.get();
37
-
38
- if (!anonymouseId) {
39
- anonymousCookie.set((0, _tools.UUID)(), ANONYMOUS_ID_EXPIRATION);
40
- }
41
-
42
- return anonymousCookie;
43
- }
44
- /**
45
- * Limit access to cookie to avoid performance issues
46
- */
47
-
48
-
49
- function startSessionManagement(options, productKey, computeSessionState) {
50
- var anonymousCookie = cacheAnonymousID(options);
51
- var sessionCookie = (0, _cookie.cacheCookieAccess)(SESSION_COOKIE_NAME, options);
52
- var renewObservable = new _observable.Observable();
53
- var currentSession = retrieveActiveSession(sessionCookie);
54
- var currentSessionId = currentSession.id;
55
- var expandOrRenewSession = (0, _tools.throttle)(function () {
56
- sessionCookie.clearCache();
57
- var session = retrieveActiveSession(sessionCookie);
58
- var state = computeSessionState(session[productKey]);
59
- session[productKey] = state.trackingType;
60
-
61
- if (state.isTracked && !session.id) {
62
- session.id = (0, _tools.UUID)();
63
- session.created = String(Date.now());
64
- } // save changes and expand session duration
65
-
66
-
67
- persistSession(session, sessionCookie); // If the session id has changed, notify that the session has been renewed
68
-
69
- if (state.isTracked && currentSessionId !== session.id) {
70
- currentSessionId = session.id;
71
- renewObservable.notify();
72
- }
73
- }, _cookie.COOKIE_ACCESS_DELAY);
74
-
75
- var expandSession = function expandSession() {
76
- sessionCookie.clearCache();
77
- var session = retrieveActiveSession(sessionCookie);
78
- persistSession(session, sessionCookie);
79
- };
80
-
81
- expandOrRenewSession();
82
- trackActivity(expandOrRenewSession);
83
- trackVisibility(expandSession);
84
- return {
85
- getAnonymousID: function getAnonymousID() {
86
- return anonymousCookie.get();
87
- },
88
- getId: function getId() {
89
- // 先获取debug id
90
- var session = retrieveActiveSession(sessionCookie);
91
- return session.did || session.id;
92
- },
93
- getTrackingType: function getTrackingType() {
94
- return retrieveActiveSession(sessionCookie)[productKey];
95
- },
96
- getDebugSession: function getDebugSession() {
97
- var session = retrieveActiveSession(sessionCookie);
98
-
99
- if ((0, _tools.isEmptyObject)(session) || !session.did) {
100
- return {};
101
- }
102
-
103
- return {
104
- id: session.did,
105
- created: session.dcreated
106
- };
107
- },
108
- addDebugSession: function addDebugSession(id, created) {
109
- var session = retrieveActiveSession(sessionCookie);
110
-
111
- if (!(0, _tools.isEmptyObject)(session)) {
112
- session.did = id || _tools.UUID;
113
- session.dcreated = created || String(Date.now());
114
- persistSession(session, sessionCookie);
115
- }
116
- },
117
- clearDebugSession: function clearDebugSession() {
118
- var session = retrieveActiveSession(sessionCookie);
119
- var newSession = {};
120
- (0, _tools.each)((0, _tools.objectEntries)(session), function (item) {
121
- if (item[0] !== 'did' && item[0] !== 'dcreated') {
122
- newSession[item[0]] = item[1];
123
- }
124
- });
125
- persistSession(newSession, sessionCookie);
126
- },
127
- renewObservable: renewObservable
128
- };
129
- }
130
-
131
- var SESSION_ENTRY_REGEXP = /^([a-z]+)=([a-z0-9-]+)$/;
132
- var SESSION_ENTRY_SEPARATOR = '&';
133
-
134
- function isValidSessionString(sessionString) {
135
- return sessionString !== undefined && (sessionString.indexOf(SESSION_ENTRY_SEPARATOR) !== -1 || SESSION_ENTRY_REGEXP.test(sessionString));
136
- }
137
-
138
- function retrieveActiveSession(sessionCookie) {
139
- var session = retrieveSession(sessionCookie);
140
-
141
- if (isActiveSession(session)) {
142
- return session;
143
- }
144
-
145
- clearSession(sessionCookie);
146
- return {};
147
- }
148
-
149
- function isActiveSession(session) {
150
- return (session.created === undefined || Date.now() - Number(session.created) < SESSION_TIME_OUT_DELAY) && (session.expire === undefined || Date.now() < Number(session.expire));
151
- }
152
-
153
- function retrieveSession(sessionCookie) {
154
- var sessionString = sessionCookie.get();
155
- var session = {};
156
-
157
- if (isValidSessionString(sessionString)) {
158
- (0, _tools.each)(sessionString.split(SESSION_ENTRY_SEPARATOR), function (entry) {
159
- var matches = SESSION_ENTRY_REGEXP.exec(entry);
160
-
161
- if (matches !== null) {
162
- var key = matches[1];
163
- var value = matches[2];
164
- session[key] = value;
165
- }
166
- });
167
- }
168
-
169
- return session;
170
- }
171
-
172
- function persistSession(session, cookie) {
173
- if ((0, _tools.isEmptyObject)(session)) {
174
- clearSession(cookie);
175
- return;
176
- }
177
-
178
- session.expire = String(Date.now() + SESSION_EXPIRATION_DELAY);
179
- var cookieArray = [];
180
- (0, _tools.each)((0, _tools.objectEntries)(session), function (item) {
181
- cookieArray.push(item[0] + '=' + item[1]);
182
- });
183
- var cookieString = cookieArray.join(SESSION_ENTRY_SEPARATOR);
184
- cookie.set(cookieString, SESSION_EXPIRATION_DELAY);
185
- }
186
-
187
- function clearSession(cookie) {
188
- cookie.set('', 0);
189
- }
190
-
191
- function stopSessionManagement() {
192
- (0, _tools.each)(stopCallbacks, function (e) {
193
- e();
194
- });
195
- stopCallbacks = [];
196
- }
197
-
198
- var stopCallbacks = [];
199
-
200
- function trackActivity(expandOrRenewSession) {
201
- var listeners = (0, _tools.addEventListeners)(window, [_enums.DOM_EVENT.CLICK, _enums.DOM_EVENT.TOUCH_START, _enums.DOM_EVENT.KEY_DOWN, _enums.DOM_EVENT.SCROLL], expandOrRenewSession, {
202
- capture: true,
203
- passive: true
204
- });
205
- stopCallbacks.push(listeners.stop);
206
- }
207
-
208
- function trackVisibility(expandSession) {
209
- var expandSessionWhenVisible = function expandSessionWhenVisible() {
210
- if (document.visibilityState === 'visible') {
211
- expandSession();
212
- }
213
- };
214
-
215
- var listener = (0, _tools.addEventListener)(document, _enums.DOM_EVENT.VISIBILITY_CHANGE, expandSessionWhenVisible);
216
- stopCallbacks.push(listener.stop);
217
- var visibilityCheckInterval = window.setInterval(expandSessionWhenVisible, VISIBILITY_CHECK_DELAY);
218
- stopCallbacks.push(function () {
219
- clearInterval(visibilityCheckInterval);
220
- });
221
- }
@@ -1,289 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.report = report;
7
- exports.subscribe = subscribe;
8
- exports.traceKitWindowOnError = traceKitWindowOnError;
9
- exports.unsubscribe = unsubscribe;
10
-
11
- var _computeStackTrace = require("./computeStackTrace");
12
-
13
- var _tools = require("../helper/tools");
14
-
15
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Error_types
16
- // eslint-disable-next-line max-len
17
- var ERROR_TYPES_RE = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/;
18
- /**
19
- * Cross-browser processing of unhandled exceptions
20
- *
21
- * Syntax:
22
- * ```js
23
- * subscribe(function(stackInfo) { ... })
24
- * unsubscribe(function(stackInfo) { ... })
25
- * report(exception)
26
- * try { ...code... } catch(ex) { report(ex); }
27
- * ```
28
- *
29
- * Supports:
30
- * - Firefox: full stack trace with line numbers, plus column number
31
- * on top frame; column number is not guaranteed
32
- * - Opera: full stack trace with line and column numbers
33
- * - Chrome: full stack trace with line and column numbers
34
- * - Safari: line and column number for the top frame only; some frames
35
- * may be missing, and column number is not guaranteed
36
- * - IE: line and column number for the top frame only; some frames
37
- * may be missing, and column number is not guaranteed
38
- *
39
- * In theory, TraceKit should work on all of the following versions:
40
- * - IE5.5+ (only 8.0 tested)
41
- * - Firefox 0.9+ (only 3.5+ tested)
42
- * - Opera 7+ (only 10.50 tested; versions 9 and earlier may require
43
- * Exceptions Have Stacktrace to be enabled in opera:config)
44
- * - Safari 3+ (only 4+ tested)
45
- * - Chrome 1+ (only 5+ tested)
46
- * - Konqueror 3.5+ (untested)
47
- *
48
- * Requires computeStackTrace.
49
- *
50
- * Tries to catch all unhandled exceptions and report them to the
51
- * subscribed handlers. Please note that report will rethrow the
52
- * exception. This is REQUIRED in order to get a useful stack trace in IE.
53
- * If the exception does not reach the top of the browser, you will only
54
- * get a stack trace from the point where report was called.
55
- *
56
- * Handlers receive a StackTrace object as described in the
57
- * computeStackTrace docs.
58
- *
59
- * @memberof TraceKit
60
- * @namespace
61
- */
62
-
63
- /**
64
- * Reports an unhandled Error.
65
- * @param {Error} ex
66
- * @memberof report
67
- * @throws An exception if an incomplete stack trace is detected (old IE browsers).
68
- */
69
-
70
- function report(ex) {
71
- if (lastExceptionStack) {
72
- if (lastException === ex) {
73
- return; // already caught by an inner catch block, ignore
74
- }
75
-
76
- processLastException();
77
- }
78
-
79
- var stack = (0, _computeStackTrace.computeStackTrace)(ex);
80
- lastExceptionStack = stack;
81
- lastException = ex; // If the stack trace is incomplete, wait for 2 seconds for
82
- // slow slow IE to see if onerror occurs or not before reporting
83
- // this exception; otherwise, we will end up with an incomplete
84
- // stack trace
85
-
86
- setTimeout(function () {
87
- if (lastException === ex) {
88
- processLastException();
89
- }
90
- }, stack.incomplete ? 2000 : 0);
91
- throw ex; // re-throw to propagate to the top level (and cause window.onerror)
92
- }
93
-
94
- var handlers = [];
95
- var lastException;
96
- var lastExceptionStack;
97
- /**
98
- * Add a crash handler.
99
- * @param {Function} handler
100
- * @memberof report
101
- */
102
-
103
- function subscribe(handler) {
104
- installGlobalHandler();
105
- installGlobalUnhandledRejectionHandler();
106
- handlers.push(handler);
107
- }
108
- /**
109
- * Remove a crash handler.
110
- * @param {Function} handler
111
- * @memberof report
112
- */
113
-
114
-
115
- function unsubscribe(handler) {
116
- for (var i = handlers.length - 1; i >= 0; i -= 1) {
117
- if (handlers[i] === handler) {
118
- handlers.splice(i, 1);
119
- }
120
- }
121
-
122
- if (handlers.length === 0) {
123
- uninstallGlobalHandler();
124
- uninstallGlobalUnhandledRejectionHandler();
125
- }
126
- }
127
- /**
128
- * Dispatch stack information to all handlers.
129
- * @param {StackTrace} stack
130
- * @param {boolean} isWindowError Is this a top-level window error?
131
- * @param {Error=} error The error that's being handled (if available, null otherwise)
132
- * @memberof report
133
- * @throws An exception if an error occurs while calling an handler.
134
- */
135
-
136
-
137
- function notifyHandlers(stack, isWindowError, error) {
138
- var exception;
139
- (0, _tools.each)(handlers, function (handler) {
140
- try {
141
- handler(stack, isWindowError, error);
142
- } catch (inner) {
143
- exception = inner;
144
- }
145
- });
146
-
147
- if (exception) {
148
- throw exception;
149
- }
150
- }
151
-
152
- var oldOnerrorHandler;
153
- var onErrorHandlerInstalled;
154
- var oldOnunhandledrejectionHandler;
155
- var onUnhandledRejectionHandlerInstalled;
156
- /**
157
- * Ensures all global unhandled exceptions are recorded.
158
- * Supported by Gecko and IE.
159
- * @param {Event|string} message Error message.
160
- * @param {string=} url URL of script that generated the exception.
161
- * @param {(number|string)=} lineNo The line number at which the error occurred.
162
- * @param {(number|string)=} columnNo The column number at which the error occurred.
163
- * @param {Error=} errorObj The actual Error object.
164
- * @memberof report
165
- */
166
-
167
- function traceKitWindowOnError(message, url, lineNo, columnNo, errorObj) {
168
- var stack;
169
-
170
- if (lastExceptionStack) {
171
- (0, _computeStackTrace.augmentStackTraceWithInitialElement)(lastExceptionStack, url, lineNo);
172
- processLastException();
173
- } else if (errorObj) {
174
- stack = (0, _computeStackTrace.computeStackTrace)(errorObj);
175
- notifyHandlers(stack, true, errorObj);
176
- } else {
177
- var location = {
178
- url: url,
179
- column: columnNo,
180
- line: lineNo
181
- };
182
- var name;
183
- var msg = message;
184
-
185
- if ({}.toString.call(message) === '[object String]') {
186
- var groups = ERROR_TYPES_RE.exec(msg);
187
-
188
- if (groups) {
189
- name = groups[1];
190
- msg = groups[2];
191
- }
192
- }
193
-
194
- stack = {
195
- name: name,
196
- message: typeof msg === 'string' ? msg : undefined,
197
- stack: [location]
198
- };
199
- notifyHandlers(stack, true, message);
200
- }
201
-
202
- if (oldOnerrorHandler) {
203
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
204
- return oldOnerrorHandler.apply(this, arguments);
205
- }
206
-
207
- return false;
208
- }
209
- /**
210
- * Ensures all unhandled rejections are recorded.
211
- * @param {PromiseRejectionEvent} e event.
212
- * @memberof report
213
- * @see https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onunhandledrejection
214
- * @see https://developer.mozilla.org/en-US/docs/Web/API/PromiseRejectionEvent
215
- */
216
-
217
-
218
- function traceKitWindowOnUnhandledRejection(e) {
219
- var reason = e.reason || 'Empty reason';
220
- var stack = (0, _computeStackTrace.computeStackTrace)(reason);
221
- notifyHandlers(stack, true, reason);
222
- }
223
- /**
224
- * Install a global onerror handler
225
- * @memberof report
226
- */
227
-
228
-
229
- function installGlobalHandler() {
230
- if (onErrorHandlerInstalled) {
231
- return;
232
- }
233
-
234
- oldOnerrorHandler = window.onerror;
235
- window.onerror = traceKitWindowOnError;
236
- onErrorHandlerInstalled = true;
237
- }
238
- /**
239
- * Uninstall the global onerror handler
240
- * @memberof report
241
- */
242
-
243
-
244
- function uninstallGlobalHandler() {
245
- if (onErrorHandlerInstalled) {
246
- window.onerror = oldOnerrorHandler;
247
- onErrorHandlerInstalled = false;
248
- }
249
- }
250
- /**
251
- * Install a global onunhandledrejection handler
252
- * @memberof report
253
- */
254
-
255
-
256
- function installGlobalUnhandledRejectionHandler() {
257
- if (onUnhandledRejectionHandlerInstalled) {
258
- return;
259
- }
260
-
261
- oldOnunhandledrejectionHandler = window.onunhandledrejection !== null ? window.onunhandledrejection : undefined;
262
- window.onunhandledrejection = traceKitWindowOnUnhandledRejection;
263
- onUnhandledRejectionHandlerInstalled = true;
264
- }
265
- /**
266
- * Uninstall the global onunhandledrejection handler
267
- * @memberof report
268
- */
269
-
270
-
271
- function uninstallGlobalUnhandledRejectionHandler() {
272
- if (onUnhandledRejectionHandlerInstalled) {
273
- window.onunhandledrejection = oldOnunhandledrejectionHandler;
274
- onUnhandledRejectionHandlerInstalled = false;
275
- }
276
- }
277
- /**
278
- * Process the most recent exception
279
- * @memberof report
280
- */
281
-
282
-
283
- function processLastException() {
284
- var currentLastExceptionStack = lastExceptionStack;
285
- var currentLastException = lastException;
286
- lastExceptionStack = undefined;
287
- lastException = undefined;
288
- notifyHandlers(currentLastExceptionStack, false, currentLastException);
289
- }