noibu-react-native 0.2.6 → 0.2.7

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 (97) hide show
  1. package/README.md +15 -15
  2. package/dist/api/{clientConfig.js → ClientConfig.js} +69 -52
  3. package/dist/api/{helpCode.js → HelpCode.js} +6 -13
  4. package/dist/api/InputManager.js +156 -0
  5. package/dist/api/{metroplexSocket.js → MetroplexSocket.js} +189 -178
  6. package/dist/api/StoredMetrics.js +158 -0
  7. package/dist/api/{storedPageVisit.js → StoredPageVisit.js} +61 -48
  8. package/dist/const_matchers.js +1 -5
  9. package/dist/constants.js +15 -390
  10. package/dist/entry/index.js +3 -4
  11. package/dist/entry/init.js +33 -19
  12. package/dist/monitors/AppNavigationMonitor.js +19 -19
  13. package/dist/monitors/BaseMonitor.js +9 -4
  14. package/dist/monitors/ClickMonitor.js +72 -76
  15. package/dist/monitors/ErrorMonitor.js +45 -55
  16. package/dist/monitors/KeyboardInputMonitor.js +13 -11
  17. package/dist/monitors/PageMonitor.js +25 -2
  18. package/dist/monitors/RequestMonitor.js +46 -57
  19. package/dist/monitors/http-tools/GqlErrorValidator.js +39 -69
  20. package/dist/monitors/http-tools/HTTPDataBundler.js +71 -66
  21. package/dist/monitors/integrations/{react-native-navigation-integration.js → ReactNativeNavigationIntegration.js} +15 -12
  22. package/dist/pageVisit/EventDebouncer.js +43 -74
  23. package/dist/pageVisit/HttpEventManager.js +88 -0
  24. package/dist/pageVisit/PageVisitManager.js +99 -0
  25. package/dist/pageVisit/pageVisitEventError.js +170 -280
  26. package/dist/react/ErrorBoundary.js +3 -6
  27. package/dist/sessionRecorder/{sessionRecorder.js → SessionRecorder.js} +58 -70
  28. package/dist/sessionRecorder/nativeSessionRecorderSubscription.js +3 -5
  29. package/dist/storage/{rnStorageProvider.js → RNStorageProvider.js} +3 -7
  30. package/dist/storage/{storage.js → Storage.js} +17 -30
  31. package/dist/storage/{storageProvider.js → StorageProvider.js} +7 -8
  32. package/dist/utils/date.js +39 -50
  33. package/dist/utils/eventlistener.js +5 -12
  34. package/dist/utils/function.js +42 -113
  35. package/dist/utils/log.js +5 -5
  36. package/dist/utils/object.js +12 -12
  37. package/dist/utils/piiRedactor.js +31 -3
  38. package/dist/utils/stacktrace-parser.js +29 -21
  39. package/package.json +14 -14
  40. package/dist/api/inputManager.js +0 -227
  41. package/dist/api/storedMetrics.js +0 -198
  42. package/dist/pageVisit/pageVisit.js +0 -181
  43. package/dist/pageVisit/pageVisitEventHTTP.js +0 -98
  44. package/dist/pageVisit/userStep.js +0 -20
  45. package/dist/src/api/clientConfig.d.ts +0 -100
  46. package/dist/src/api/clientConfig.test.d.ts +0 -1
  47. package/dist/src/api/helpCode.d.ts +0 -23
  48. package/dist/src/api/inputManager.d.ts +0 -87
  49. package/dist/src/api/metroplexSocket.d.ts +0 -137
  50. package/dist/src/api/storedMetrics.d.ts +0 -73
  51. package/dist/src/api/storedPageVisit.d.ts +0 -40
  52. package/dist/src/const_matchers.d.ts +0 -1
  53. package/dist/src/constants.d.ts +0 -290
  54. package/dist/src/entry/index.d.ts +0 -14
  55. package/dist/src/entry/init.d.ts +0 -5
  56. package/dist/src/monitors/AppNavigationMonitor.d.ts +0 -18
  57. package/dist/src/monitors/BaseMonitor.d.ts +0 -13
  58. package/dist/src/monitors/BaseMonitor.test.d.ts +0 -1
  59. package/dist/src/monitors/ClickMonitor.d.ts +0 -31
  60. package/dist/src/monitors/ErrorMonitor.d.ts +0 -63
  61. package/dist/src/monitors/KeyboardInputMonitor.d.ts +0 -20
  62. package/dist/src/monitors/PageMonitor.d.ts +0 -20
  63. package/dist/src/monitors/RequestMonitor.d.ts +0 -94
  64. package/dist/src/monitors/http-tools/GqlErrorValidator.d.ts +0 -59
  65. package/dist/src/monitors/http-tools/HTTPDataBundler.d.ts +0 -112
  66. package/dist/src/monitors/integrations/react-native-navigation-integration.d.ts +0 -20
  67. package/dist/src/pageVisit/EventDebouncer.d.ts +0 -24
  68. package/dist/src/pageVisit/pageVisit.d.ts +0 -52
  69. package/dist/src/pageVisit/pageVisitEventError.d.ts +0 -15
  70. package/dist/src/pageVisit/pageVisitEventHTTP.d.ts +0 -25
  71. package/dist/src/pageVisit/userStep.d.ts +0 -5
  72. package/dist/src/react/ErrorBoundary.d.ts +0 -72
  73. package/dist/src/sessionRecorder/nativeSessionRecorderSubscription.d.ts +0 -79
  74. package/dist/src/sessionRecorder/sessionRecorder.d.ts +0 -60
  75. package/dist/src/sessionRecorder/types.d.ts +0 -91
  76. package/dist/src/storage/rnStorageProvider.d.ts +0 -23
  77. package/dist/src/storage/storage.d.ts +0 -39
  78. package/dist/src/storage/storageProvider.d.ts +0 -26
  79. package/dist/src/utils/date.d.ts +0 -6
  80. package/dist/src/utils/eventlistener.d.ts +0 -8
  81. package/dist/src/utils/function.d.ts +0 -102
  82. package/dist/src/utils/log.d.ts +0 -4
  83. package/dist/src/utils/object.d.ts +0 -44
  84. package/dist/src/utils/performance.d.ts +0 -6
  85. package/dist/src/utils/piiRedactor.d.ts +0 -11
  86. package/dist/src/utils/polyfills.d.ts +0 -4
  87. package/dist/src/utils/stacktrace-parser.d.ts +0 -7
  88. package/dist/types/Config.d.ts +0 -31
  89. package/dist/types/Metroplex.types.d.ts +0 -73
  90. package/dist/types/NavigationIntegration.d.ts +0 -6
  91. package/dist/types/PageVisit.types.d.ts +0 -8
  92. package/dist/types/PageVisitErrors.types.d.ts +0 -114
  93. package/dist/types/PageVisitEvents.types.d.ts +0 -91
  94. package/dist/types/PageVisitMetrics.types.d.ts +0 -27
  95. package/dist/types/Storage.d.ts +0 -14
  96. package/dist/types/StoredPageVisit.types.d.ts +0 -11
  97. package/dist/types/WrappedObjects.d.ts +0 -6
@@ -1,320 +1,210 @@
1
+ import { __awaiter } from 'tslib';
1
2
  import { isValidURL, getJSStack, stringifyJSON, getMaxSubstringAllowed, asString } from '../utils/function.js';
2
- import { EVENT_ERROR_TYPE, URL_ATT_NAME, BLOCKLISTED_DOMAINS, ERROR_EVENT_TYPE, ERROR_EVENT_ERROR_TYPE, CUSTOM_ERROR_EVENT_TYPE, ERROR_EVENT_UNHANDLED_REJECTION_TYPE, ERROR_LOG_EVENT_ERROR_TYPE, FETCH_EXCEPTION_ERROR_TYPE, WRAPPED_EXCEPTION_ERROR_TYPE, GQL_ERROR_TYPE, RESPONSE_ERROR_TYPE, XML_HTTP_REQUEST_ERROR_TYPE, ERROR_SOURCE_ATT_NAME, TYPE_ATT_NAME, JS_EVENT_TYPE, JS_ERROR_ATT_NAME, JS_STACK_FRAMES_ATT_NAME, JS_STACK_FILE_ATT_NAME, JS_STACK_METHOD_ATT_NAME, SEVERITY, JS_STACK_MESSAGE_ATT_NAME, HTTP_EVENT_TYPE, NOIBU_INPUT_URLS, HTTP_CODE_ATT_NAME, PV_SEQ_ATT_NAME, GQL_EVENT_TYPE, GQL_ERROR_ATT_NAME } from '../constants.js';
3
- import ClientConfig from '../api/clientConfig.js';
4
- import StoredMetrics from '../api/storedMetrics.js';
3
+ import { SEVERITY } from '../constants.js';
4
+ import ClientConfig from '../api/ClientConfig.js';
5
+ import StoredMetrics from '../api/StoredMetrics.js';
5
6
  import { EventDebouncer } from './EventDebouncer.js';
6
-
7
- /** @module PageVisitEventError */
8
-
7
+ import '../node_modules/@noibu/metroplex-ts-bindings/dist/index.js';
8
+ import { PageVisitErrorSource } from '../node_modules/@noibu/metroplex-ts-bindings/dist/PageVisitErrorSource.js';
9
+ import { EventType } from '../node_modules/@noibu/metroplex-ts-bindings/dist/EventType.js';
10
+ import { ErrorType } from '../node_modules/@noibu/metroplex-ts-bindings/dist/ErrorType.js';
11
+
12
+ const BLOCKLISTED_DOMAINS = {
13
+ 'input.noibu.com': true,
14
+ 'input.staging.noibu.com': true,
15
+ 'vf.noibu.com': true,
16
+ 'vf.staging.noibu.com': true,
17
+ 'cdn.noibu.com': true,
18
+ };
19
+ // All urls that NoibuJS may talk to
20
+ const NOIBU_INPUT_URLS = [
21
+ 'i.noibu',
22
+ 'i.staging.noibu',
23
+ 'input.staging.noibu',
24
+ 'input.b.noibu',
25
+ 'input.noibu',
26
+ 'vf.staging.noibu',
27
+ 'vf.noibu',
28
+ ];
9
29
  /**
10
30
  * gets the onURL of a string, defaulting to the location of the webpage
11
31
  */
12
32
  function getOnURL(realOnURL) {
13
- if (realOnURL && realOnURL.trim() !== '' && realOnURL !== 'undefined') {
14
- return asString(getMaxSubstringAllowed(realOnURL));
15
- }
16
-
17
- return ClientConfig.getInstance().globalUrl;
33
+ if (typeof realOnURL === 'string' && !!realOnURL.trim() && realOnURL !== 'undefined') {
34
+ return asString(getMaxSubstringAllowed(realOnURL));
35
+ }
36
+ return ClientConfig.getInstance().globalUrl;
18
37
  }
19
-
20
38
  /**
21
39
  * getPVErrorFromResponse will create the error information from an
22
- * http response error type.
23
- * @param {} errPayload
24
- * @param {} httpDataSeqNum
25
- */
26
- function getPVErrorFromResponse(errPayload, httpDataSeqNum) {
27
- const errorObject = {
28
- [URL_ATT_NAME]: getOnURL(errPayload.url),
29
- [TYPE_ATT_NAME]: HTTP_EVENT_TYPE,
30
- [HTTP_CODE_ATT_NAME]: errPayload.status,
31
- };
32
- if (httpDataSeqNum || httpDataSeqNum === 0) {
33
- errorObject[PV_SEQ_ATT_NAME] = httpDataSeqNum;
34
- }
35
- return errorObject;
36
- }
37
-
38
- /**
39
- * getPVErrorFromGqlError will create the error information from an
40
- * GraphQL error payload.
41
- * @param payload
42
- * @param {} httpDataSeqNum
43
- */
44
- function getPVErrorFromGqlError(payload, httpDataSeqNum) {
45
- const result = {
46
- [URL_ATT_NAME]: getOnURL(payload.url),
47
- [TYPE_ATT_NAME]: GQL_EVENT_TYPE,
48
- [GQL_ERROR_ATT_NAME]: payload,
49
- };
50
-
51
- if (httpDataSeqNum || httpDataSeqNum === 0) {
52
- result[PV_SEQ_ATT_NAME] = httpDataSeqNum;
53
- }
54
-
55
- return result;
56
- }
57
-
58
- /**
59
- * getPVErrorFromXMLHttpRequest will create the error information from
60
- * an HttpRequest error type
61
- * @param {} errPayload
62
- * @param {} httpDataSeqNum
40
+ * http response error source.
63
41
  */
64
- function getPVErrorFromXMLHttpRequest(errPayload, httpDataSeqNum) {
65
- const errorObject = {
66
- [URL_ATT_NAME]: getOnURL(errPayload.responseURL),
67
- [TYPE_ATT_NAME]: HTTP_EVENT_TYPE,
68
- [HTTP_CODE_ATT_NAME]: errPayload.status,
69
- };
70
- if (httpDataSeqNum || httpDataSeqNum === 0) {
71
- errorObject[PV_SEQ_ATT_NAME] = httpDataSeqNum;
72
- }
73
- return errorObject;
42
+ function getPVErrorFromResponse(errPayload, seq) {
43
+ const errorObject = {
44
+ url: getOnURL(errPayload.url),
45
+ type: ErrorType.Http,
46
+ h_code: errPayload.status,
47
+ gql_err: errPayload.gql_err,
48
+ err_src: errPayload.type,
49
+ };
50
+ if (seq || seq === 0) {
51
+ errorObject.seq = seq;
52
+ }
53
+ return errorObject;
74
54
  }
75
55
  /**
76
56
  * getPVErrorFromErrorEvent will create the error information from an
77
- * error event type
78
- * @param {} errPayload
57
+ * error event source
79
58
  */
80
59
  function getPVErrorFromErrorEvent(errPayload) {
81
- return {
82
- [URL_ATT_NAME]: getOnURL(
83
- errPayload.filename || ClientConfig.getInstance().globalUrl,
84
- ),
85
- [TYPE_ATT_NAME]: JS_EVENT_TYPE,
86
- [JS_ERROR_ATT_NAME]: getJSStack(errPayload.error),
87
- };
60
+ return {
61
+ url: getOnURL(errPayload.filename || ClientConfig.getInstance().globalUrl),
62
+ type: ErrorType.Js,
63
+ j_err: getJSStack(errPayload.error),
64
+ err_src: errPayload.type,
65
+ };
88
66
  }
89
-
90
- /** getPVErrorFromErrorLog extracts an error from an error log
91
- * @param {} errPayload
92
- */
67
+ /** getPVErrorFromErrorLog extracts an error from an error log */
93
68
  function getPVErrorFromErrorLog(errPayload) {
94
- return {
95
- [URL_ATT_NAME]: getOnURL(ClientConfig.getInstance().globalUrl),
96
- [TYPE_ATT_NAME]: JS_EVENT_TYPE,
97
- [JS_ERROR_ATT_NAME]: getJSStack(errPayload),
98
- };
69
+ return {
70
+ url: ClientConfig.getInstance().globalUrl,
71
+ type: ErrorType.Js,
72
+ j_err: getJSStack(errPayload),
73
+ err_src: PageVisitErrorSource.ErrorLogEvent,
74
+ };
99
75
  }
100
-
101
- /**
102
- * Sets an error message to pvError by a given error event.
103
- * @param {string} type
104
- * @param {} pvError
105
- * @param {} originalError
106
- */
107
- function setErrorMessageForUnhandledEvent(type, pvError, originalError) {
108
- let detail = null;
109
- if (originalError.detail) {
76
+ /** getPVErrorFromCustomType extracts an error from a custom error type */
77
+ function getPVErrorFromCustomType(event) {
78
+ let updatedEvent = event;
110
79
  try {
111
- detail = stringifyJSON(originalError.detail);
112
- } catch (e) {
113
- detail = 'non-serializable';
80
+ if (window.Event && event instanceof window.Event) {
81
+ let message = `Fire error event of type ${event.type}.`;
82
+ const detail = stringifyJSON(event.detail);
83
+ if (detail) {
84
+ message += ` Detail: ${detail}.`;
85
+ }
86
+ if ('error' in updatedEvent && typeof updatedEvent.error === 'object')
87
+ updatedEvent = Object.assign(Object.assign({}, updatedEvent), { type: PageVisitErrorSource.ErrorEvent, error: Object.assign(Object.assign({}, updatedEvent.error), { message: getMaxSubstringAllowed(message) }) });
88
+ }
89
+ return getPVErrorFromErrorEvent(updatedEvent);
90
+ }
91
+ catch (e) {
92
+ // TODO: report to us that this failed
93
+ return null;
94
+ }
95
+ }
96
+ /** Inner method to get the error from a PageVisitErrorInput based on its type */
97
+ function getPVEventErrorInner(event, sequence) {
98
+ switch (event.type) {
99
+ case PageVisitErrorSource.XMLHttpRequest:
100
+ case PageVisitErrorSource.Response: {
101
+ return getPVErrorFromResponse(event, sequence);
102
+ }
103
+ case PageVisitErrorSource.WrappedException:
104
+ case PageVisitErrorSource.FetchException:
105
+ case PageVisitErrorSource.UnhandledRejectionError:
106
+ case PageVisitErrorSource.CustomError:
107
+ case PageVisitErrorSource.ErrorEvent: {
108
+ return getPVErrorFromErrorEvent(event);
109
+ }
110
+ case PageVisitErrorSource.ErrorLogEvent: {
111
+ return getPVErrorFromErrorLog(event);
112
+ }
113
+ default: {
114
+ return getPVErrorFromCustomType(event);
115
+ }
114
116
  }
115
- }
116
- let message = `Fire error event of type ${type}.`;
117
- if (detail != null) {
118
- message += ` Detail: ${detail}.`;
119
- }
120
- pvError.j_err.msg = getMaxSubstringAllowed(message); // eslint-disable-line no-param-reassign
121
117
  }
122
-
123
118
  /**
124
119
  * createPageVisitEventError returns creates an error information
125
- * object based on the type of error
126
- * @param {} type
127
- * @param {} errPayload
128
- * @param {} httpDataSeqNum
120
+ * object based on the source of error
129
121
  */
130
- function createPageVisitEventError(type, errPayload, httpDataSeqNum) {
131
- // We have seen that errors from requireJS contain the originalError
132
- // attribute which is the real error. If we do not extract the originalError we are
133
- // not looking at the full error available.
134
- // https://github.com/requirejs/requirejs/blob/master/require.js#L172
135
- let originalError = errPayload;
136
- if (errPayload.error && errPayload.error.originalError) {
137
- originalError = errPayload.error.originalError;
138
- }
139
-
140
- let pvError = {};
141
- switch (type) {
142
- case XML_HTTP_REQUEST_ERROR_TYPE: {
143
- pvError = getPVErrorFromXMLHttpRequest(originalError, httpDataSeqNum);
144
- break;
145
- }
146
- case ERROR_EVENT_ERROR_TYPE: {
147
- pvError = getPVErrorFromErrorEvent(originalError);
148
- break;
149
- }
150
- case RESPONSE_ERROR_TYPE: {
151
- pvError = getPVErrorFromResponse(originalError, httpDataSeqNum);
152
- break;
153
- }
154
- case GQL_ERROR_TYPE: {
155
- // The error is retrieved from the response of the server
156
- // eslint-disable-next-line no-param-reassign
157
- type = RESPONSE_ERROR_TYPE;
158
- pvError = getPVErrorFromGqlError(originalError, httpDataSeqNum);
159
- break;
160
- }
161
- case WRAPPED_EXCEPTION_ERROR_TYPE: {
162
- pvError = getPVErrorFromErrorEvent(originalError);
163
- break;
164
- }
165
- // the fetch handler makes sure that we create the appropriate
166
- // error type before sending it for processing thus we do not
167
- // need a specific error handler for fetch errors.
168
- case FETCH_EXCEPTION_ERROR_TYPE: {
169
- pvError = getPVErrorFromErrorEvent(originalError);
170
- break;
171
- }
172
- case ERROR_LOG_EVENT_ERROR_TYPE: {
173
- pvError = getPVErrorFromErrorLog(originalError);
174
- break;
122
+ function createPageVisitEventError(payload, httpDataSeqNum) {
123
+ // We have seen that errors from requireJS contain the originalError
124
+ // attribute which is the real error. If we do not extract the originalError we are
125
+ // not looking at the full error available.
126
+ // https://github.com/requirejs/requirejs/blob/master/require.js#L172
127
+ let originalError = payload;
128
+ if ('error' in originalError &&
129
+ originalError.error &&
130
+ typeof originalError.error === 'object' &&
131
+ 'originalError' in originalError.error &&
132
+ originalError.error.originalError) {
133
+ originalError = Object.assign({ type: payload.type }, originalError.error.originalError);
175
134
  }
176
- case ERROR_EVENT_UNHANDLED_REJECTION_TYPE: {
177
- pvError = getPVErrorFromErrorEvent(originalError);
178
- break;
179
- }
180
- case CUSTOM_ERROR_EVENT_TYPE: {
181
- pvError = getPVErrorFromErrorEvent(originalError);
182
- break;
183
- }
184
- default: {
185
- // TODO: report to us that we sent an invalid type
186
- // users have their own type that they will be passing, does not warrant
187
- // a failure. We try to process it as an error.
188
- try {
189
- pvError = getPVErrorFromErrorEvent(originalError);
190
- if (window.Event && originalError instanceof window.Event) {
191
- // generate error message
192
- setErrorMessageForUnhandledEvent(type, pvError, originalError);
193
- // override type so metroplex can accept it
194
- type = ERROR_EVENT_ERROR_TYPE; // eslint-disable-line no-param-reassign
135
+ return getPVEventErrorInner(originalError, httpDataSeqNum);
136
+ }
137
+ /** getMsg returns the message of the error if it is a Noibu error */
138
+ function getCollectErrorMsg(pvError) {
139
+ var _a, _b;
140
+ switch (pvError.type) {
141
+ case ErrorType.Js: {
142
+ if (!((_b = (_a = pvError.j_err) === null || _a === void 0 ? void 0 : _a.frames) === null || _b === void 0 ? void 0 : _b.length)) {
143
+ return false;
144
+ }
145
+ const frames = pvError.j_err.frames;
146
+ const lowerCapFile = frames[0].file.toLowerCase();
147
+ const lowerCapMethod = frames[0].mname.toLowerCase();
148
+ const lowerCapMessage = pvError.j_err.msg.toLowerCase();
149
+ if (!(lowerCapMessage.includes('input.noibu') ||
150
+ lowerCapMessage.includes('input.b.noibu') ||
151
+ (lowerCapFile.includes('noibu') && !lowerCapMethod.includes('nbuwrapper')))) {
152
+ return false;
153
+ }
154
+ return pvError.j_err.msg;
155
+ }
156
+ case ErrorType.Http: {
157
+ if (!NOIBU_INPUT_URLS.some(url => { var _a, _b; return (_b = (_a = pvError.url) === null || _a === void 0 ? void 0 : _a.includes) === null || _b === void 0 ? void 0 : _b.call(_a, url); })) {
158
+ return false;
159
+ }
160
+ return 'Noibu endpoint failed';
195
161
  }
196
- } catch (e) {
197
- // TODO: report to us that this failed
198
- return null;
199
- }
200
162
  }
201
- }
202
-
203
- // setting the source of this error to be the type
204
- pvError[ERROR_SOURCE_ATT_NAME] = type;
205
- return pvError;
163
+ return false;
206
164
  }
207
-
208
165
  /**
209
166
  * determines if an error is a collect error
210
- * @param {} pvError
211
167
  */
212
168
  function isErrorCollectedByNoibu(pvError) {
213
- // checking if this error originated from the Noibu script
214
- if (pvError[TYPE_ATT_NAME] === JS_EVENT_TYPE) {
215
- if (pvError[JS_ERROR_ATT_NAME]) {
216
- const frames = pvError[JS_ERROR_ATT_NAME][JS_STACK_FRAMES_ATT_NAME];
217
- if (frames && frames.length > 0) {
218
- const lowerCapFile = frames[0][JS_STACK_FILE_ATT_NAME].toLowerCase();
219
- const lowerCapMethod =
220
- frames[0][JS_STACK_METHOD_ATT_NAME].toLowerCase();
221
-
222
- if (
223
- lowerCapFile.includes('noibu') &&
224
- !lowerCapFile.includes('examplenoibureactnativeapp') &&
225
- !lowerCapMethod.includes('nbuwrapper')
226
- ) {
227
- // if the first file in the stack is Noibu then we do not
228
- // queue this error for analytics, we send it to another
229
- // endpoint to alert us
230
- ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(
231
- pvError,
232
- false,
233
- SEVERITY.error,
234
- );
235
- return true;
169
+ return __awaiter(this, void 0, void 0, function* () {
170
+ // checking if this error originated from the Noibu script
171
+ const msg = getCollectErrorMsg(pvError);
172
+ if (msg) {
173
+ return ClientConfig.getInstance().postInternalError({ msg, pvError }, false, SEVERITY.error);
236
174
  }
237
- }
175
+ return false;
176
+ });
177
+ }
178
+ /** Saves the error to the Error queue */
179
+ function saveErrorToPagevisit(payload, httpDataSeqNum) {
180
+ // We do not want to process errors events as errors (yet)
181
+ if (payload.type === PageVisitErrorSource.Event) {
182
+ return;
238
183
  }
239
- // checking if the message contains noibu.
240
- if (pvError[JS_STACK_MESSAGE_ATT_NAME]) {
241
- const lowerCapMessage = pvError[JS_STACK_MESSAGE_ATT_NAME].toLowerCase();
242
- // we do not want all errors that contain noibu in their messages to be ignored
243
- // only the errors that we are confident are not impact the user.
244
- if (
245
- lowerCapMessage.includes('input.noibu') ||
246
- lowerCapMessage.includes('input.b.noibu')
247
- ) {
248
- ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(
249
- pvError,
250
- false,
251
- SEVERITY.error,
252
- );
253
- return true;
254
- }
184
+ const pvError = createPageVisitEventError(payload, httpDataSeqNum);
185
+ // making sure we have the error object defined
186
+ if (!pvError || !pvError.url) {
187
+ return;
255
188
  }
256
- } else if (
257
- pvError[TYPE_ATT_NAME] === HTTP_EVENT_TYPE &&
258
- pvError[URL_ATT_NAME]
259
- ) {
260
- const currURL = pvError[URL_ATT_NAME];
261
- if (typeof currURL === 'string') {
262
- // this means that our endpoing has failed and we need to
263
- // send an alert to stack driver
264
- for (let i = 0; i < NOIBU_INPUT_URLS.length; i += 1) {
265
- const inputURL = NOIBU_INPUT_URLS[i];
266
- if (currURL.includes(inputURL)) {
267
- ClientConfig.getInstance().postNoibuErrorAndOptionallyDisableClient(
268
- pvError,
269
- false,
270
- SEVERITY.error,
271
- );
272
- return true;
189
+ const currErrURL = pvError.url;
190
+ // We need valid URLs in order to check their blacklist status
191
+ if (isValidURL(currErrURL)) {
192
+ const urlOb = new URL(currErrURL);
193
+ // if the domain is blacklisted we drop the error
194
+ if (urlOb.hostname in BLOCKLISTED_DOMAINS) {
195
+ return;
273
196
  }
274
- }
275
197
  }
276
- }
277
-
278
- return false;
279
- }
280
-
281
- /** Saves the error to the ErrorQueue
282
- * @param {} type
283
- * @param {} payload
284
- * @param {} [httpDataSeqNum]
285
- */
286
- function saveErrorToPagevisit(type, payload, httpDataSeqNum) {
287
- // We do not want to process errors events as errors (yet)
288
- if (type === EVENT_ERROR_TYPE) {
289
- return;
290
- }
291
- const pvError = createPageVisitEventError(type, payload, httpDataSeqNum);
292
-
293
- // making sure we have the error object defined
294
- if (!pvError || !pvError[URL_ATT_NAME]) {
295
- return;
296
- }
297
-
298
- const currErrURL = pvError[URL_ATT_NAME];
299
-
300
- // We need valid URLs in order to check their blacklist status
301
- if (isValidURL(currErrURL)) {
302
- const urlOb = new URL(currErrURL);
303
-
304
- // if the domain is blacklisted we drop the error
305
- if (urlOb.hostname in BLOCKLISTED_DOMAINS) {
306
- return;
307
- }
308
- }
309
-
310
- if (isErrorCollectedByNoibu(pvError)) {
311
- return;
312
- }
313
-
314
- // we register an error event
315
- StoredMetrics.getInstance().addError();
316
- // debounce event
317
- EventDebouncer.getInstance().addEvent(pvError, ERROR_EVENT_TYPE);
198
+ isErrorCollectedByNoibu(pvError).then(isCollected => {
199
+ if (isCollected) {
200
+ return;
201
+ }
202
+ StoredMetrics.getInstance().addError();
203
+ EventDebouncer.getInstance().debounce({
204
+ type: EventType.Error,
205
+ err: pvError,
206
+ });
207
+ });
318
208
  }
319
209
 
320
210
  export { getOnURL, isErrorCollectedByNoibu, saveErrorToPagevisit };
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import uuid from 'react-native-uuid';
3
- import InputManager from '../api/inputManager.js';
3
+ import InputManager from '../api/InputManager.js';
4
4
 
5
5
  // initial state variables
6
6
  const INITIAL_STATE = {
@@ -9,17 +9,14 @@ const INITIAL_STATE = {
9
9
  eventId: null,
10
10
  };
11
11
  /**
12
- * @description A ErrorBoundary component that logs errors to Noibu. Requires React >= 16.
12
+ * @description Target ErrorBoundary component that logs errors to Noibu. Requires React >= 16.
13
13
  * @extends {Component<ErrorBoundaryProps, ErrorBoundaryState>}
14
14
  */
15
15
  class ErrorBoundary extends React.Component {
16
16
  constructor() {
17
17
  super(...arguments);
18
18
  this.state = INITIAL_STATE;
19
- /**
20
- * Callback from fallback to reset the error boundary
21
- * @param {} =>void=(
22
- */
19
+ /** Callback from fallback to reset the error boundary */
23
20
  this.resetErrorBoundary = () => {
24
21
  const { onReset } = this.props;
25
22
  const { error, componentStack, eventId } = this.state;