noibu-react-native 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/api/clientConfig.js +225 -217
- package/dist/api/helpCode.js +61 -87
- package/dist/api/metroplexSocket.js +460 -463
- package/dist/api/storedPageVisit.js +150 -208
- package/dist/constants.js +10 -2
- package/dist/entry/init.js +65 -63
- package/dist/monitors/{appNavigationMonitor.js → AppNavigationMonitor.js} +12 -22
- package/dist/monitors/ClickMonitor.js +198 -0
- package/dist/monitors/ErrorMonitor.js +206 -0
- package/dist/monitors/KeyboardInputMonitor.js +60 -0
- package/dist/monitors/PageMonitor.js +98 -0
- package/dist/monitors/RequestMonitor.js +390 -0
- package/dist/monitors/http-tools/GqlErrorValidator.js +259 -0
- package/dist/monitors/http-tools/HTTPDataBundler.js +458 -0
- package/dist/monitors/integrations/react-native-navigation-integration.js +4 -2
- package/dist/pageVisit/EventDebouncer.js +99 -0
- package/dist/pageVisit/pageVisitEventError.js +2 -2
- package/dist/pageVisit/pageVisitEventHTTP.js +79 -93
- package/dist/react/ErrorBoundary.js +18 -15
- package/dist/sessionRecorder/nativeSessionRecorderSubscription.js +3 -2
- package/dist/sessionRecorder/sessionRecorder.js +152 -151
- package/dist/{api → src/api}/clientConfig.d.ts +2 -2
- package/dist/{api → src/api}/helpCode.d.ts +10 -16
- package/dist/{api → src/api}/metroplexSocket.d.ts +48 -67
- package/dist/{api → src/api}/storedPageVisit.d.ts +12 -21
- package/dist/{constants.d.ts → src/constants.d.ts} +45 -0
- package/dist/{entry → src/entry}/init.d.ts +1 -1
- package/dist/src/monitors/AppNavigationMonitor.d.ts +18 -0
- package/dist/src/monitors/ClickMonitor.d.ts +31 -0
- package/dist/src/monitors/ErrorMonitor.d.ts +63 -0
- package/dist/{monitors/keyboardInputMonitor.d.ts → src/monitors/KeyboardInputMonitor.d.ts} +7 -4
- package/dist/{monitors/pageMonitor.d.ts → src/monitors/PageMonitor.d.ts} +6 -8
- package/dist/src/monitors/RequestMonitor.d.ts +94 -0
- package/dist/src/monitors/http-tools/GqlErrorValidator.d.ts +59 -0
- package/dist/src/monitors/http-tools/HTTPDataBundler.d.ts +112 -0
- package/dist/{monitors → src/monitors}/integrations/react-native-navigation-integration.d.ts +3 -2
- package/dist/src/pageVisit/EventDebouncer.d.ts +24 -0
- package/dist/{pageVisit → src/pageVisit}/pageVisit.d.ts +1 -1
- package/dist/src/pageVisit/pageVisitEventHTTP.d.ts +25 -0
- package/dist/{sessionRecorder → src/sessionRecorder}/types.d.ts +1 -1
- package/dist/{storage → src/storage}/rnStorageProvider.d.ts +1 -1
- package/dist/{storage → src/storage}/storage.d.ts +2 -2
- package/dist/{storage → src/storage}/storageProvider.d.ts +3 -3
- package/dist/{utils → src/utils}/function.d.ts +27 -7
- package/dist/{utils → src/utils}/object.d.ts +11 -8
- package/dist/src/utils/piiRedactor.d.ts +11 -0
- package/dist/src/utils/polyfills.d.ts +4 -0
- package/dist/storage/rnStorageProvider.js +7 -4
- package/dist/storage/storage.js +43 -35
- package/dist/storage/storageProvider.js +23 -19
- package/dist/types/Config.d.ts +24 -20
- package/dist/types/Metroplex.types.d.ts +73 -0
- package/dist/types/Monitor.d.ts +11 -0
- package/dist/types/Monitor.js +19 -0
- package/dist/types/PageVisit.types.d.ts +8 -0
- package/dist/types/PageVisitErrors.types.d.ts +114 -0
- package/dist/types/PageVisitEvents.types.d.ts +91 -0
- package/dist/types/PageVisitMetrics.types.d.ts +27 -0
- package/dist/types/Storage.d.ts +1 -1
- package/dist/types/StoredPageVisit.types.d.ts +4 -47
- package/dist/types/WrappedObjects.d.ts +6 -0
- package/dist/utils/function.js +110 -77
- package/dist/utils/object.js +59 -6
- package/dist/utils/piiRedactor.js +98 -0
- package/dist/utils/polyfills.js +24 -0
- package/package.json +8 -8
- package/dist/monitors/appNavigationMonitor.d.ts +0 -22
- package/dist/monitors/clickMonitor.d.ts +0 -44
- package/dist/monitors/clickMonitor.js +0 -251
- package/dist/monitors/errorMonitor.d.ts +0 -28
- package/dist/monitors/errorMonitor.js +0 -180
- package/dist/monitors/gqlErrorValidator.d.ts +0 -82
- package/dist/monitors/gqlErrorValidator.js +0 -306
- package/dist/monitors/httpDataBundler.d.ts +0 -161
- package/dist/monitors/httpDataBundler.js +0 -725
- package/dist/monitors/inputMonitor.d.ts +0 -34
- package/dist/monitors/inputMonitor.js +0 -138
- package/dist/monitors/keyboardInputMonitor.js +0 -66
- package/dist/monitors/pageMonitor.js +0 -122
- package/dist/monitors/requestMonitor.d.ts +0 -10
- package/dist/monitors/requestMonitor.js +0 -401
- package/dist/pageVisit/pageVisitEventHTTP.d.ts +0 -18
- package/dist/types/PageVisit.d.ts +0 -22
- package/dist/types/ReactNative.d.ts +0 -4
- package/dist/types/globals.d.ts +0 -45
- /package/dist/{api → src/api}/inputManager.d.ts +0 -0
- /package/dist/{api → src/api}/storedMetrics.d.ts +0 -0
- /package/dist/{const_matchers.d.ts → src/const_matchers.d.ts} +0 -0
- /package/dist/{entry → src/entry}/index.d.ts +0 -0
- /package/dist/{pageVisit → src/pageVisit}/pageVisitEventError.d.ts +0 -0
- /package/dist/{pageVisit → src/pageVisit}/userStep.d.ts +0 -0
- /package/dist/{react → src/react}/ErrorBoundary.d.ts +0 -0
- /package/dist/{sessionRecorder → src/sessionRecorder}/nativeSessionRecorderSubscription.d.ts +0 -0
- /package/dist/{sessionRecorder → src/sessionRecorder}/sessionRecorder.d.ts +0 -0
- /package/dist/{utils → src/utils}/date.d.ts +0 -0
- /package/dist/{utils → src/utils}/eventlistener.d.ts +0 -0
- /package/dist/{utils → src/utils}/log.d.ts +0 -0
- /package/dist/{utils → src/utils}/performance.d.ts +0 -0
- /package/dist/{utils → src/utils}/stacktrace-parser.d.ts +0 -0
|
@@ -1,401 +0,0 @@
|
|
|
1
|
-
import 'react-native/Libraries/Network/fetch';
|
|
2
|
-
import { saveErrorToPagevisit } from '../pageVisit/pageVisitEventError.js';
|
|
3
|
-
import { PageVisitEventHTTP, isHttpCodeFailure } from '../pageVisit/pageVisitEventHTTP.js';
|
|
4
|
-
import { propWriteableOrMadeWriteable, replace } from '../utils/object.js';
|
|
5
|
-
import { SEVERITY, PV_SEQ_ATT_NAME, RESPONSE_ERROR_TYPE, GQL_ERROR_TYPE, HTTP_METHOD_ATT_NAME, HTTP_RESP_CODE_ATT_NAME, URL_ATT_NAME, HTTP_RESP_TIME_ATT_NAME, HTTP_RESP_LENGTH_ATT_NAME, FETCH_EXCEPTION_ERROR_TYPE } from '../constants.js';
|
|
6
|
-
import ClientConfig from '../api/clientConfig.js';
|
|
7
|
-
import { HTTPDataBundler } from './httpDataBundler.js';
|
|
8
|
-
import GqlErrorValidator from './gqlErrorValidator.js';
|
|
9
|
-
import { noibuLog } from '../utils/log.js';
|
|
10
|
-
|
|
11
|
-
/** @module RequestMonitor */
|
|
12
|
-
// todo no idea why this works but it fixes fetch replacement
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Called in the fetch() wrapper function, this specifically gets called after the promises which
|
|
16
|
-
* return the request and response body complete.
|
|
17
|
-
* @param {object} request a Request object
|
|
18
|
-
* @param {object} response a Response object
|
|
19
|
-
* @param {object} options the options parameter from the original fetch() call
|
|
20
|
-
* @param {string[]} bodyStrings an array of string HTTP bodies from the wrapped fetch() function.
|
|
21
|
-
* [0] is the response body, [1] is an optional response body.
|
|
22
|
-
* @param {string} url the URL of the request
|
|
23
|
-
* @param {string} method the method used in the fetch call
|
|
24
|
-
* @param {boolean} shouldCollectPayload
|
|
25
|
-
* @returns the return from the bundleHTTPData() call
|
|
26
|
-
*/
|
|
27
|
-
function _handleFetchOnPromiseCompletion(
|
|
28
|
-
request,
|
|
29
|
-
response,
|
|
30
|
-
options,
|
|
31
|
-
bodyStrings,
|
|
32
|
-
url,
|
|
33
|
-
method,
|
|
34
|
-
shouldCollectPayload,
|
|
35
|
-
) {
|
|
36
|
-
noibuLog('_handleFetchOnPromiseCompletion', method, url);
|
|
37
|
-
let reqBody; //
|
|
38
|
-
let reqHeaders = new Map();
|
|
39
|
-
let respHeaders = new Map();
|
|
40
|
-
if (bodyStrings[1]) {
|
|
41
|
-
// Get reqBody from request obj if it exists
|
|
42
|
-
// I don't like this notation, but the linter enforces it.
|
|
43
|
-
// This is the same as reqBody = values[1]
|
|
44
|
-
[, reqBody] = bodyStrings;
|
|
45
|
-
|
|
46
|
-
// Get reqHeaders from request obj
|
|
47
|
-
if (request.headers) {
|
|
48
|
-
reqHeaders = HTTPDataBundler.headersMapFromIterable(
|
|
49
|
-
request.headers.entries(),
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
// Get reqBody from options if it hasn't been defined above.
|
|
54
|
-
// Double-equals null check on reqBody to get null or undefined but not an empty string
|
|
55
|
-
if (reqBody == null && !!options && !!options.body) reqBody = options.body;
|
|
56
|
-
|
|
57
|
-
// Get reqHeaders from options.headers
|
|
58
|
-
if (reqHeaders.size < 1 && !!options && !!options.headers) {
|
|
59
|
-
// Two cases here: headers will either be a simple object (key/value), or
|
|
60
|
-
// a Headers type object.
|
|
61
|
-
|
|
62
|
-
// Case 1: headers has a .entries() property, it is a Header object
|
|
63
|
-
if (options.headers instanceof Headers) {
|
|
64
|
-
reqHeaders = HTTPDataBundler.headersMapFromIterable(
|
|
65
|
-
options.headers.entries(),
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
// Case 2: headers is a simple object, same logic as above but we call it as
|
|
69
|
-
// Object.entries()
|
|
70
|
-
else {
|
|
71
|
-
reqHeaders = HTTPDataBundler.headersMapFromIterable(
|
|
72
|
-
Object.entries(options.headers),
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// response.headers will always be a Headers object.
|
|
78
|
-
if (!!response && !!response.headers) {
|
|
79
|
-
respHeaders = HTTPDataBundler.headersMapFromIterable(
|
|
80
|
-
response.headers.entries(),
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return HTTPDataBundler.getInstance().bundleHTTPData(
|
|
85
|
-
url,
|
|
86
|
-
reqHeaders,
|
|
87
|
-
reqBody,
|
|
88
|
-
respHeaders,
|
|
89
|
-
bodyStrings[0],
|
|
90
|
-
method,
|
|
91
|
-
shouldCollectPayload,
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Returns the parameters to pass the PageVisitEventHTTP constructor. Specific to the fetch wrapper.
|
|
97
|
-
* @param {object} request a Request object
|
|
98
|
-
* @param {object} response a Response object cloned() from the original
|
|
99
|
-
* @param {string} method the method used in the fetch call
|
|
100
|
-
* @param {string} url the URL of the request
|
|
101
|
-
* @param {object} options the options parameter from the original fetch() call
|
|
102
|
-
* @param {number} respTime the time between the fetch() call and the the resolution of the
|
|
103
|
-
* original implementation's return
|
|
104
|
-
* @param {Promise<string>} requestTextPromise
|
|
105
|
-
* @returns an array in the form [httpEvent, httpData]
|
|
106
|
-
*/
|
|
107
|
-
async function _buildHttpEventDataObjectsForFetch(
|
|
108
|
-
request,
|
|
109
|
-
response,
|
|
110
|
-
method,
|
|
111
|
-
url,
|
|
112
|
-
options,
|
|
113
|
-
respTime,
|
|
114
|
-
requestTextPromise,
|
|
115
|
-
) {
|
|
116
|
-
noibuLog('_buildHttpEventDataObjectsForFetch started', method, url);
|
|
117
|
-
const httpEvent = {
|
|
118
|
-
[HTTP_METHOD_ATT_NAME]: method,
|
|
119
|
-
[HTTP_RESP_CODE_ATT_NAME]: response.status,
|
|
120
|
-
[URL_ATT_NAME]: url,
|
|
121
|
-
[HTTP_RESP_TIME_ATT_NAME]: respTime,
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
let httpData = null;
|
|
125
|
-
// Only get the bodies of the request and response if the URL is one we care about.
|
|
126
|
-
if (HTTPDataBundler.getInstance().shouldContinueForURL(url)) {
|
|
127
|
-
// add response payload length, if any
|
|
128
|
-
if (response && response.headers) {
|
|
129
|
-
const contentLength = HTTPDataBundler.getInstance().contentLength(
|
|
130
|
-
response.headers,
|
|
131
|
-
);
|
|
132
|
-
if (contentLength > 0) {
|
|
133
|
-
httpEvent[HTTP_RESP_LENGTH_ATT_NAME] = contentLength;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
let responseText = '';
|
|
138
|
-
const shouldCollectPayload =
|
|
139
|
-
HTTPDataBundler.getInstance().shouldCollectPayloadForURL(url);
|
|
140
|
-
if (shouldCollectPayload && response instanceof Response) {
|
|
141
|
-
noibuLog('_buildHttpEventDataObjectsForFetch collecting response');
|
|
142
|
-
const droppedResponseText =
|
|
143
|
-
HTTPDataBundler.getInstance().dropPayloadIfNecessaryFromHeaders(
|
|
144
|
-
response.headers,
|
|
145
|
-
);
|
|
146
|
-
responseText = droppedResponseText || response.clone().text();
|
|
147
|
-
} else {
|
|
148
|
-
noibuLog(
|
|
149
|
-
'_buildHttpEventDataObjectsForFetch not collecting payload, because of',
|
|
150
|
-
{
|
|
151
|
-
shouldCollectPayloadForURL:
|
|
152
|
-
HTTPDataBundler.getInstance().shouldCollectPayloadForURL(url),
|
|
153
|
-
instanceOfCheck: response instanceof Response,
|
|
154
|
-
},
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
const responseTextPromise = Promise.resolve(responseText);
|
|
158
|
-
|
|
159
|
-
// Array to pass to Promise.all(). We conditionally include requestTextPromise as a
|
|
160
|
-
// second element if it was defined earlier.
|
|
161
|
-
const promises = [
|
|
162
|
-
responseTextPromise,
|
|
163
|
-
...(requestTextPromise ? [requestTextPromise] : []),
|
|
164
|
-
];
|
|
165
|
-
|
|
166
|
-
// Wait on the promises for the response and the request (if applicable) to resolve,
|
|
167
|
-
// then call our handler
|
|
168
|
-
await Promise.all(promises)
|
|
169
|
-
.then(data =>
|
|
170
|
-
_handleFetchOnPromiseCompletion(
|
|
171
|
-
request,
|
|
172
|
-
response,
|
|
173
|
-
options,
|
|
174
|
-
data,
|
|
175
|
-
url,
|
|
176
|
-
method,
|
|
177
|
-
shouldCollectPayload,
|
|
178
|
-
),
|
|
179
|
-
)
|
|
180
|
-
.then(httpDataReturn => {
|
|
181
|
-
httpData = httpDataReturn;
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
noibuLog('_buildHttpEventDataObjectsForFetch ended');
|
|
185
|
-
// This return will await the _handleFetchOnPromiseCompletion() call if necessary,
|
|
186
|
-
// but won't if not. (See if above).
|
|
187
|
-
return [httpEvent, httpData];
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Handles fetch failure
|
|
192
|
-
* @param {} err
|
|
193
|
-
* @param {} url
|
|
194
|
-
*/
|
|
195
|
-
function handleFetchFailure(err, url) {
|
|
196
|
-
if (!err) {
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// we do not need this error if we cannot extract both the message and stack
|
|
201
|
-
if (!err.message || !err.stack) {
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// making sure we have a url
|
|
206
|
-
const checkedURL = !url ? '' : url;
|
|
207
|
-
const errorFromFetch = new Error();
|
|
208
|
-
errorFromFetch.stack = err.stack;
|
|
209
|
-
const urlMessage = checkedURL.trim() === '' ? '' : ` on url ${checkedURL}`;
|
|
210
|
-
errorFromFetch.message = `${err.message}${urlMessage}`;
|
|
211
|
-
const errorPayload = {
|
|
212
|
-
error: errorFromFetch,
|
|
213
|
-
};
|
|
214
|
-
saveErrorToPagevisit(FETCH_EXCEPTION_ERROR_TYPE, errorPayload);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Setting up the wrapper around fetch functions to try and
|
|
219
|
-
* catch http errors
|
|
220
|
-
*/
|
|
221
|
-
function setupGlobalFetchWrapper() {
|
|
222
|
-
const proto = global;
|
|
223
|
-
// Ensure we're able to replace the fetch() function
|
|
224
|
-
if (!propWriteableOrMadeWriteable(proto, 'fetch')) {
|
|
225
|
-
noibuLog('setupGlobalFetchWrapper fetch is not writable');
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
noibuLog('setupGlobalFetchWrapper replacing fetch');
|
|
229
|
-
replace(
|
|
230
|
-
proto,
|
|
231
|
-
'fetch',
|
|
232
|
-
originalFunction =>
|
|
233
|
-
// We set nbuWrapper to the handler function so if this returns an error
|
|
234
|
-
// the trace message will start with nbuWrapper which would allow us to
|
|
235
|
-
// detect that this is a wrapped function and not a NoibuJS error
|
|
236
|
-
function nbuGlobalFetchWrapper(resource, options) {
|
|
237
|
-
let method;
|
|
238
|
-
let url;
|
|
239
|
-
|
|
240
|
-
// These two variables will only be defined if the resource param is a request object.
|
|
241
|
-
// request, if defined, will be a clone of the request object
|
|
242
|
-
let request;
|
|
243
|
-
// requestTextPromise, if defined, will be a promise obtained from request that resolves
|
|
244
|
-
// to the response body as text
|
|
245
|
-
let requestTextPromise;
|
|
246
|
-
|
|
247
|
-
// We wrap everything in try/catch to ensure the original function is called even if we throw
|
|
248
|
-
// an unexpected error.
|
|
249
|
-
try {
|
|
250
|
-
noibuLog('nbuGlobalFetchWrapper start call', { resource });
|
|
251
|
-
// There is no valid reason for fetch() to be called without a resource but we
|
|
252
|
-
// see it on a bunch of websites. It seems to work the same as empty string
|
|
253
|
-
if (!resource) {
|
|
254
|
-
method = 'GET';
|
|
255
|
-
url = '';
|
|
256
|
-
} else {
|
|
257
|
-
if (resource.method) {
|
|
258
|
-
method = resource.method;
|
|
259
|
-
url = resource.url;
|
|
260
|
-
} else {
|
|
261
|
-
// If options or options.method is missing, fallback to GET.
|
|
262
|
-
method = options && options.method ? options.method : 'GET';
|
|
263
|
-
url = resource.toString() ? resource.toString() : '';
|
|
264
|
-
}
|
|
265
|
-
// resource is defined
|
|
266
|
-
// Two possibilities: resource could be either any object with a .toString() function,
|
|
267
|
-
// or it could be a Request object. If it's a Request, we'll have to clone it, and read
|
|
268
|
-
// its body asynchronously. We check for the existence of a .method property on the
|
|
269
|
-
// resource to check whether it is a Request object.
|
|
270
|
-
if (
|
|
271
|
-
HTTPDataBundler.getInstance().shouldCollectPayloadForURL(url) &&
|
|
272
|
-
resource.clone &&
|
|
273
|
-
resource.text
|
|
274
|
-
) {
|
|
275
|
-
noibuLog('nbuGlobalFetchWrapper collecting request object');
|
|
276
|
-
// We clone the request object, as its body can only be read once per instance.
|
|
277
|
-
// It's important that we do this before the original function is called, as it
|
|
278
|
-
// cannot be cloned afterwards.
|
|
279
|
-
request = resource.clone();
|
|
280
|
-
requestTextPromise = request.text();
|
|
281
|
-
} else {
|
|
282
|
-
noibuLog(
|
|
283
|
-
'nbuGlobalFetchWrapper not collecting request object, because one of these is false',
|
|
284
|
-
{
|
|
285
|
-
shouldCollectPayloadForURL:
|
|
286
|
-
HTTPDataBundler.getInstance().shouldCollectPayloadForURL(
|
|
287
|
-
url,
|
|
288
|
-
),
|
|
289
|
-
clone: !!resource.clone,
|
|
290
|
-
text: !!resource.text,
|
|
291
|
-
},
|
|
292
|
-
);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
} catch (e) {
|
|
296
|
-
ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(
|
|
297
|
-
`Error in fetch() wrapper: ${e}`,
|
|
298
|
-
false,
|
|
299
|
-
SEVERITY.error,
|
|
300
|
-
);
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
// Break out of the try wrapper momentarily to make the original call
|
|
304
|
-
|
|
305
|
-
noibuLog('nbuGlobalFetchWrapper call original');
|
|
306
|
-
// Can't put this inside finally as const needs to be defined outside it.
|
|
307
|
-
const promiseFromOriginalFetch = originalFunction.call(
|
|
308
|
-
this,
|
|
309
|
-
resource,
|
|
310
|
-
options,
|
|
311
|
-
);
|
|
312
|
-
// not using safePerformanceNow as there is a 75% hit with using it.
|
|
313
|
-
// We don't want every request to get impacted by this.
|
|
314
|
-
const rCreatedAt = new Date();
|
|
315
|
-
promiseFromOriginalFetch
|
|
316
|
-
.then(async response => {
|
|
317
|
-
noibuLog('nbuGlobalFetchWrapper got response');
|
|
318
|
-
// We wrap the callback in try in order to only catch real fetch failures in the promise's
|
|
319
|
-
// .catch() call
|
|
320
|
-
try {
|
|
321
|
-
const graphqlResponse = response.clone();
|
|
322
|
-
const httpEventDataResponse = response.clone();
|
|
323
|
-
const pageVisitErrorResponse = response.clone();
|
|
324
|
-
|
|
325
|
-
const gqlError = await GqlErrorValidator.fromFetch(
|
|
326
|
-
url,
|
|
327
|
-
options,
|
|
328
|
-
request,
|
|
329
|
-
graphqlResponse,
|
|
330
|
-
);
|
|
331
|
-
|
|
332
|
-
const rEndedAt = new Date();
|
|
333
|
-
const respTime = Math.abs(rEndedAt - rCreatedAt);
|
|
334
|
-
const [httpEvent, httpData] =
|
|
335
|
-
await _buildHttpEventDataObjectsForFetch(
|
|
336
|
-
request,
|
|
337
|
-
httpEventDataResponse,
|
|
338
|
-
method,
|
|
339
|
-
url,
|
|
340
|
-
options,
|
|
341
|
-
respTime,
|
|
342
|
-
requestTextPromise,
|
|
343
|
-
);
|
|
344
|
-
|
|
345
|
-
let pageVisitEventHTTP = new PageVisitEventHTTP(
|
|
346
|
-
httpEvent,
|
|
347
|
-
httpData,
|
|
348
|
-
);
|
|
349
|
-
pageVisitEventHTTP.saveHTTPEvent();
|
|
350
|
-
|
|
351
|
-
const seq =
|
|
352
|
-
pageVisitEventHTTP.httpData &&
|
|
353
|
-
pageVisitEventHTTP.httpData[PV_SEQ_ATT_NAME];
|
|
354
|
-
|
|
355
|
-
if (isHttpCodeFailure(response.status)) {
|
|
356
|
-
saveErrorToPagevisit(
|
|
357
|
-
RESPONSE_ERROR_TYPE,
|
|
358
|
-
pageVisitErrorResponse,
|
|
359
|
-
seq,
|
|
360
|
-
);
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
if (gqlError) {
|
|
364
|
-
gqlError.forEach(error =>
|
|
365
|
-
saveErrorToPagevisit(GQL_ERROR_TYPE, error, seq),
|
|
366
|
-
);
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
// helping gc
|
|
370
|
-
pageVisitEventHTTP = null;
|
|
371
|
-
} catch (e) {
|
|
372
|
-
// Catch errors with our logic in the .then() callback above
|
|
373
|
-
ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(
|
|
374
|
-
`Error in custom fetch() callback: ${e}`,
|
|
375
|
-
false,
|
|
376
|
-
SEVERITY.error,
|
|
377
|
-
);
|
|
378
|
-
}
|
|
379
|
-
})
|
|
380
|
-
.catch(err => {
|
|
381
|
-
// Catch errors in the call to the original fetch() implementation
|
|
382
|
-
handleFetchFailure(err, url);
|
|
383
|
-
});
|
|
384
|
-
|
|
385
|
-
// Can't put this inside finally as linter does not allow return statements inside finally.
|
|
386
|
-
return promiseFromOriginalFetch;
|
|
387
|
-
},
|
|
388
|
-
);
|
|
389
|
-
}
|
|
390
|
-
/**
|
|
391
|
-
* Monitors all requests
|
|
392
|
-
*/
|
|
393
|
-
function monitorRequests() {
|
|
394
|
-
noibuLog('monitorRequests started');
|
|
395
|
-
/** todo: disabling xmlhttp since it seems to duplicate fetch wrapper, but lacks response body capture */
|
|
396
|
-
// setupGlobalXMLHttpWrapper();
|
|
397
|
-
setupGlobalFetchWrapper();
|
|
398
|
-
noibuLog('monitorRequests ended');
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
export { handleFetchFailure, monitorRequests };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Determines if a response is a failure
|
|
3
|
-
* @param {number} code
|
|
4
|
-
*/
|
|
5
|
-
export function isHttpCodeFailure(code: number): boolean;
|
|
6
|
-
/** Class representing a PageVisitEventHTTP */
|
|
7
|
-
export class PageVisitEventHTTP {
|
|
8
|
-
/**
|
|
9
|
-
* Creates an instance of the http event for the pv
|
|
10
|
-
* @param {} httpEvent
|
|
11
|
-
* @param {} httpData
|
|
12
|
-
*/
|
|
13
|
-
constructor(httpEvent: any, httpData: any);
|
|
14
|
-
httpEvent: any;
|
|
15
|
-
httpData: any;
|
|
16
|
-
/** Saves the HTTP event to the pageVisit Queue */
|
|
17
|
-
saveHTTPEvent(): void;
|
|
18
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export type Event = {
|
|
2
|
-
type: string;
|
|
3
|
-
};
|
|
4
|
-
export type EventPayload = Partial<{
|
|
5
|
-
txt: string;
|
|
6
|
-
src: string;
|
|
7
|
-
hid: string;
|
|
8
|
-
tag: string;
|
|
9
|
-
type: string;
|
|
10
|
-
class: string;
|
|
11
|
-
pvp: string;
|
|
12
|
-
}>;
|
|
13
|
-
export interface JError {
|
|
14
|
-
frames: JStackFrame[];
|
|
15
|
-
msg: string;
|
|
16
|
-
}
|
|
17
|
-
export interface JStackFrame {
|
|
18
|
-
column?: number;
|
|
19
|
-
line: string;
|
|
20
|
-
mname: string;
|
|
21
|
-
file: string;
|
|
22
|
-
}
|
package/dist/types/globals.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
declare global {
|
|
2
|
-
const METROPLEX_BASE_SOCKET_URL: string;
|
|
3
|
-
const BETA_METROPLEX_BASE_SOCKET_URL: string;
|
|
4
|
-
const METROPLEX_BASE_HTTP_URL: string;
|
|
5
|
-
const BETA_METROPLEX_BASE_HTTP_URL: string;
|
|
6
|
-
const CURR_ENV: string;
|
|
7
|
-
const MAX_PAGE_VISIT_BUFFER_SIZE: string;
|
|
8
|
-
const DEBOUNCE_PV_POST_ON_CLICK_FREQ: string;
|
|
9
|
-
const VID_POST_FREQUENCY: string;
|
|
10
|
-
const PAGEVISIT_POST_FREQUENCY: string;
|
|
11
|
-
const WRITE_TO_METROPLEX_FREQUENCY: number;
|
|
12
|
-
const CLIENT_SCRIPT_ID: string;
|
|
13
|
-
const MAX_METROPLEX_RECONNECTION_NUMBER: number;
|
|
14
|
-
const METROPLEX_CONSECUTIVE_CONNECTION_DELAY: number;
|
|
15
|
-
const SCRIPT_ID: string;
|
|
16
|
-
const ENABLE_LOGGING: string;
|
|
17
|
-
const ENV: string;
|
|
18
|
-
const DEVICE_ENV: string | undefined;
|
|
19
|
-
type Window = {
|
|
20
|
-
noibuJSLoaded?: boolean;
|
|
21
|
-
};
|
|
22
|
-
type PromiseRejectionTrackerOptions = Partial<{
|
|
23
|
-
allRejections: boolean;
|
|
24
|
-
whitelist: (typeof Error)[];
|
|
25
|
-
onUnhandled: (id: number, reason: any) => void;
|
|
26
|
-
onHandled: (id: number, reason: any) => void;
|
|
27
|
-
}>;
|
|
28
|
-
type global = {
|
|
29
|
-
window: Window;
|
|
30
|
-
console: Console;
|
|
31
|
-
noibuJSLoaded?: boolean;
|
|
32
|
-
ErrorUtils: any;
|
|
33
|
-
HermesInternal: null | {
|
|
34
|
-
enablePromiseRejectionTracker?: (options: PromiseRejectionTrackerOptions) => void;
|
|
35
|
-
setPromiseRejectionTrackingHook?: (enable: (options: PromiseRejectionTrackerOptions) => void) => void;
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
interface PromiseConstructor {
|
|
39
|
-
_m: <T>(promise: Promise<T>, error: any) => void;
|
|
40
|
-
}
|
|
41
|
-
const global: global;
|
|
42
|
-
const globalThis: global;
|
|
43
|
-
const window: Window & global;
|
|
44
|
-
}
|
|
45
|
-
export {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/{sessionRecorder → src/sessionRecorder}/nativeSessionRecorderSubscription.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|