noibu-react-native 0.2.3 → 0.2.5

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 (71) hide show
  1. package/dist/api/clientConfig.js +20 -27
  2. package/dist/api/helpCode.js +61 -87
  3. package/dist/api/metroplexSocket.js +72 -65
  4. package/dist/api/storedPageVisit.js +150 -208
  5. package/dist/constants.js +3 -7
  6. package/dist/entry/init.js +13 -15
  7. package/dist/monitors/{appNavigationMonitor.js → AppNavigationMonitor.js} +10 -19
  8. package/dist/monitors/BaseMonitor.js +23 -0
  9. package/dist/monitors/ClickMonitor.js +198 -0
  10. package/dist/monitors/ErrorMonitor.js +206 -0
  11. package/dist/monitors/KeyboardInputMonitor.js +60 -0
  12. package/dist/monitors/PageMonitor.js +98 -0
  13. package/dist/monitors/RequestMonitor.js +390 -0
  14. package/dist/monitors/http-tools/GqlErrorValidator.js +259 -0
  15. package/dist/monitors/{httpDataBundler.js → http-tools/HTTPDataBundler.js} +23 -102
  16. package/dist/pageVisit/{eventDebouncer.js → EventDebouncer.js} +36 -47
  17. package/dist/pageVisit/pageVisitEventError.js +3 -3
  18. package/dist/pageVisit/pageVisitEventHTTP.js +5 -4
  19. package/dist/sessionRecorder/nativeSessionRecorderSubscription.js +22 -5
  20. package/dist/sessionRecorder/sessionRecorder.js +5 -2
  21. package/dist/src/api/clientConfig.d.ts +8 -13
  22. package/dist/src/api/clientConfig.test.d.ts +1 -0
  23. package/dist/src/api/helpCode.d.ts +10 -16
  24. package/dist/src/api/metroplexSocket.d.ts +52 -71
  25. package/dist/src/api/storedPageVisit.d.ts +12 -21
  26. package/dist/src/constants.d.ts +1 -0
  27. package/dist/src/monitors/AppNavigationMonitor.d.ts +18 -0
  28. package/dist/src/monitors/BaseMonitor.d.ts +13 -0
  29. package/dist/src/monitors/BaseMonitor.test.d.ts +1 -0
  30. package/dist/src/monitors/ClickMonitor.d.ts +31 -0
  31. package/dist/src/monitors/ErrorMonitor.d.ts +63 -0
  32. package/dist/src/monitors/{keyboardInputMonitor.d.ts → KeyboardInputMonitor.d.ts} +7 -4
  33. package/dist/src/monitors/{pageMonitor.d.ts → PageMonitor.d.ts} +6 -8
  34. package/dist/src/monitors/RequestMonitor.d.ts +94 -0
  35. package/dist/src/monitors/http-tools/GqlErrorValidator.d.ts +59 -0
  36. package/dist/src/monitors/{httpDataBundler.d.ts → http-tools/HTTPDataBundler.d.ts} +13 -28
  37. package/dist/src/monitors/integrations/react-native-navigation-integration.d.ts +3 -2
  38. package/dist/src/pageVisit/{eventDebouncer.d.ts → EventDebouncer.d.ts} +3 -10
  39. package/dist/src/pageVisit/pageVisit.d.ts +1 -1
  40. package/dist/src/pageVisit/pageVisitEventHTTP.d.ts +3 -3
  41. package/dist/src/sessionRecorder/nativeSessionRecorderSubscription.d.ts +15 -0
  42. package/dist/src/storage/rnStorageProvider.d.ts +1 -1
  43. package/dist/src/storage/storage.d.ts +1 -1
  44. package/dist/src/storage/storageProvider.d.ts +2 -2
  45. package/dist/src/utils/function.d.ts +4 -5
  46. package/dist/src/utils/object.d.ts +3 -5
  47. package/dist/src/utils/polyfills.d.ts +1 -4
  48. package/dist/types/Metroplex.types.d.ts +73 -0
  49. package/dist/types/PageVisit.types.d.ts +2 -145
  50. package/dist/types/PageVisitErrors.types.d.ts +114 -0
  51. package/dist/types/PageVisitEvents.types.d.ts +91 -0
  52. package/dist/types/Storage.d.ts +1 -1
  53. package/dist/types/StoredPageVisit.types.d.ts +4 -45
  54. package/dist/utils/function.js +0 -1
  55. package/dist/utils/object.js +1 -0
  56. package/package.json +11 -7
  57. package/dist/monitors/clickMonitor.js +0 -258
  58. package/dist/monitors/errorMonitor.js +0 -202
  59. package/dist/monitors/gqlErrorValidator.js +0 -306
  60. package/dist/monitors/inputMonitor.js +0 -138
  61. package/dist/monitors/keyboardInputMonitor.js +0 -66
  62. package/dist/monitors/pageMonitor.js +0 -122
  63. package/dist/monitors/requestMonitor.js +0 -386
  64. package/dist/src/monitors/appNavigationMonitor.d.ts +0 -22
  65. package/dist/src/monitors/clickMonitor.d.ts +0 -44
  66. package/dist/src/monitors/errorMonitor.d.ts +0 -28
  67. package/dist/src/monitors/gqlErrorValidator.d.ts +0 -82
  68. package/dist/src/monitors/inputMonitor.d.ts +0 -34
  69. package/dist/src/monitors/requestMonitor.d.ts +0 -10
  70. package/dist/types/RRWeb.d.ts +0 -48
  71. package/dist/types/ReactNative.d.ts +0 -4
@@ -1,36 +1,32 @@
1
- import { HTTPDataBundle } from '../../types/PageVisit.types';
2
- import { WrappedXMLHttpRequest } from '../../types/WrappedObjects';
1
+ import { WrappedXMLHttpRequest } from '../../../types/WrappedObjects';
2
+ import { HTTPDataBundle } from '../../../types/PageVisitEvents.types';
3
+ import { Singleton } from '../BaseMonitor';
3
4
  /** Bundles HTTP payloads and headers */
4
- export declare class HTTPDataBundler {
5
+ export declare class HTTPDataBundler extends Singleton {
5
6
  contentTypeReadableRegex: RegExp;
6
7
  hostname: string;
7
8
  initialURLPartsReversed: string[];
8
9
  httpDataCollectionEnabled: boolean;
9
10
  httpDataAllowedRelativeRegex: RegExp | null;
10
11
  httpDataAllowedAbsoluteRegex: RegExp | null;
11
- private static instance;
12
12
  /**
13
13
  * Creates an instance of the ClickMonitor instance
14
14
  */
15
15
  constructor();
16
- /** gets the singleton instance
17
- * @returns {HTTPDataBundler}
18
- * */
19
- static getInstance(): HTTPDataBundler;
20
16
  /**
21
17
  * Builds the HTTP payload allowed regexes for full and relative URLs
22
18
  * @param allowedURLs A list of allowed URLs
23
19
  * @param absolute Use only absolute URLs if true, use only relative URL if false
24
20
  * @returns a regex of allowed URLs
25
21
  */
26
- static buildAllowedRegex(allowedURLs: unknown | unknown[], absolute: boolean): RegExp | null;
22
+ private static buildAllowedRegex;
27
23
  /**
28
24
  * Takes an iterator and returns a map of strings representing headers.
29
- * @param {object} headersIterable any iterable object
30
- * @returns a map of strings (as expected by metroplex) representing HTTP
25
+ * param {object} headersIterable any iterable object
26
+ * returns a map of strings (as expected by metroplex) representing HTTP
31
27
  * request or response headers
32
28
  */
33
- static headersMapFromIterable(headersIterable: any): Map<any, any>;
29
+ static headersMapFromIterable(headersIterable: Iterable<any[]>): Map<any, any>;
34
30
  /**
35
31
  * Takes a string of headers with 'name: value' and returns
36
32
  * a map of strings representing headers.
@@ -45,13 +41,6 @@ export declare class HTTPDataBundler {
45
41
  * @returns a string representation of the response, or null if this fails.
46
42
  */
47
43
  static getResponseStringFromXHR(xhr: WrappedXMLHttpRequest): Promise<any>;
48
- /**
49
- * Takes a URL and returns true if it is determined to be on the same domain as the URL
50
- * the script is running on. Ignores protocol and path, and allows the URL to be a subdomain.
51
- * @param {string} requestURL the URL of a request to compare to the script website's URL
52
- * @param {bool} isHostnameCheck the URL is a domain hostname, could be a super or sub domain
53
- */
54
- isURLSameDomain(requestURL: any, isHostnameCheck?: boolean): boolean;
55
44
  /**
56
45
  * Builds an HTTP Data bundle
57
46
  */
@@ -59,11 +48,8 @@ export declare class HTTPDataBundler {
59
48
  /**
60
49
  * Validates a request based on the URL and method. When enabled, will handle
61
50
  * de-duping the requests
62
- * @param {string} url
63
- * @param {string} method
64
- * @returns boolean indicating whether the validation passed
65
51
  */
66
- isValidRequest(url: any, method: any): boolean;
52
+ isValidRequest(method: unknown): boolean;
67
53
  /**
68
54
  * Checks two things: that the URL is either on the same domain (or an address relative to the
69
55
  * current domain), and also checks that the config http_data_collection flag is enabled.
@@ -73,14 +59,13 @@ export declare class HTTPDataBundler {
73
59
  */
74
60
  shouldContinueForURL(url: any): boolean;
75
61
  /**
76
- * Determins if the URL is absolute or relative
77
- * @param {string} url
78
- * @returns boolean indicating whether the URL passed is either absolute or relative
62
+ * Determines if the URL is absolute or relative
63
+ * returns boolean indicating whether the URL passed is either absolute or relative
79
64
  */
80
- static isAbsoluteURL(url: any): boolean;
65
+ static isAbsoluteURL(url: unknown): boolean;
81
66
  /**
82
67
  * Checks whether HTTP payloads can be collected on this URL
83
- * @returns boolean indicating whether HTTP payloads can be collected on this URL
68
+ * returns boolean indicating whether HTTP payloads can be collected on this URL
84
69
  */
85
70
  shouldCollectPayloadForURL(url: any): boolean;
86
71
  /**
@@ -1,4 +1,5 @@
1
- import { NavigationIntegration } from '../../types/NavigationIntegration';
1
+ import { NavigationIntegration } from '../../../types/NavigationIntegration';
2
+ import { NavigationRoot } from 'react-native-navigation/lib/dist/src/Navigation';
2
3
  /**
3
4
  * react-native-navigation adapter
4
5
  */
@@ -8,7 +9,7 @@ export declare class ReactNativeNavigationIntegration implements NavigationInteg
8
9
  /**
9
10
  * attaches provided listeners to the integration
10
11
  */
11
- register(navigation: any, onNavigation: (breadcrumbs: string[]) => void): void;
12
+ register(navigation: NavigationRoot, onNavigation: (breadcrumbs: string[]) => void): void;
12
13
  /**
13
14
  * Listens to ComponentWillAppear events, keeps track of visited screens and
14
15
  * pops them if the same page is visited to prevent cycles
@@ -1,26 +1,19 @@
1
+ import { Singleton } from '../monitors/BaseMonitor';
1
2
  /**
2
3
  * Singleton class responsible for debouncing all events
3
4
  * that are registered
4
5
  */
5
- export declare class EventDebouncer {
6
+ export declare class EventDebouncer extends Singleton {
6
7
  private readonly eventsToDebounce;
7
- private static instance;
8
8
  /**
9
9
  * Creates an instance of EventDebouncer
10
10
  */
11
11
  constructor();
12
- /**
13
- * gets the instance of EventDebouncer
14
- */
15
- static getInstance(): EventDebouncer;
16
- /** will debounce all events that are of this type by the debounce period
17
- */
18
- registerInputType(type: string, debouncePeriod: number, eventName?: string): void;
19
12
  /**
20
13
  * Creates an event object with the event and the time it was added then pushes
21
14
  * that event object to the queue of events waiting to be debounced.
22
15
  */
23
- addEvent(event: any, type: string, occurredAt?: number): void;
16
+ addEvent(event: any, type: keyof typeof this.eventsToDebounce, occurredAt?: number): void;
24
17
  /**
25
18
  * Adds the events from the object to the page visit and sets up a timer
26
19
  * to send the events if no more are received without the timeout
@@ -17,7 +17,7 @@ export class PageVisit {
17
17
  * @param {} pvEvents
18
18
  * @param {} partCounter
19
19
  */
20
- static makePageVisitFrag(pvEvents: any, partCounter: any): any;
20
+ static makePageVisitFrag(pvEvents: any, partCounter: any): import("../../types/Metroplex.types").PageVisitFrag | import("../../types/Metroplex.types").VideoFrag;
21
21
  partCounter: number;
22
22
  pvMap: {};
23
23
  pvEventLength: number;
@@ -1,17 +1,17 @@
1
- import { HTTPDataBundle, PVEventHTTP } from '../../types/PageVisit.types';
1
+ import { HTTPDataBundle, PVEventHTTPPayload } from '../../types/PageVisitEvents.types';
2
2
  /**
3
3
  * Determines if a response is a failure
4
4
  */
5
5
  export declare function isHttpCodeFailure(code: unknown): boolean;
6
6
  /** Class representing a PageVisitEventHTTP */
7
7
  export declare class PageVisitEventHTTP {
8
- httpEvent: PVEventHTTP;
8
+ httpEvent: PVEventHTTPPayload;
9
9
  httpData: HTTPDataBundle | null;
10
10
  isGqlError: boolean;
11
11
  /**
12
12
  * Creates an instance of the http event for the pv
13
13
  */
14
- constructor(httpEvent: Partial<PVEventHTTP>, httpData: HTTPDataBundle | null, isGqlError?: boolean);
14
+ constructor(httpEvent: Partial<PVEventHTTPPayload>, httpData: HTTPDataBundle | null, isGqlError?: boolean);
15
15
  /** Saves the HTTP event to the pageVisit Queue */
16
16
  saveHTTPEvent(): void;
17
17
  /**
@@ -61,4 +61,19 @@ export declare function setCustomUserId(customUserId: string): void;
61
61
  export declare function setCustomSessionId(customSessionId: string): void;
62
62
  export type RecorderEvent = import('./types').RecorderEvent;
63
63
  export type UnsubscribeFn = import('./types').UnsubscribeFn;
64
+ /**
65
+ * Subscribes to a native event emitted by the Noibu Session Recorder.
66
+ *
67
+ * This function listens for the `noibuRecordingEvent` emitted from the native layer (only on Android)
68
+ * and invokes the provided callback whenever the event occurs. If the platform is not Android,
69
+ * the function will do nothing and return a no-op unsubscribe function.
70
+ *
71
+ * @param {function(RecorderEvent): void} callback - A callback function that will be invoked with
72
+ * the event data whenever the `noibuRecordingEvent` is emitted.
73
+ *
74
+ * @returns {UnsubscribeFn} A function to unsubscribe from the event. On Android, this will remove
75
+ * the event listener. On other platforms, it will be a no-op.
76
+ *
77
+ * @throws {Error} If the Noibu Session Recorder is not initialized before calling this function.
78
+ */
64
79
  export declare function subscribeToNativeEvent(callback: (event: RecorderEvent) => void): UnsubscribeFn;
@@ -13,7 +13,7 @@ export default class RNStorageProvider extends StorageProvider {
13
13
  */
14
14
  static isAvailable(): Promise<{
15
15
  result: boolean;
16
- error: Error | null;
16
+ error: Error;
17
17
  }>;
18
18
  /**
19
19
  * Calculates used scape
@@ -20,7 +20,7 @@ export default class Storage implements IStorage {
20
20
  /** Checks if storage is available */
21
21
  isAvailable(): Promise<boolean>;
22
22
  /** Loads value from storage */
23
- load<R = unknown>(key: string): Promise<R | null>;
23
+ load(key: string): Promise<string | null>;
24
24
  /** Saves value to storage */
25
25
  save(key: string, value: StorageValue): Promise<void>;
26
26
  /**
@@ -9,12 +9,12 @@ export default abstract class StorageProvider {
9
9
  /** Checks if provider is available */
10
10
  static isAvailable<T extends Provider>(resolver: () => T): Promise<{
11
11
  result: boolean;
12
- error: Error | null;
12
+ error: Error;
13
13
  }>;
14
14
  /**
15
15
  * Loads value from storage
16
16
  */
17
- load<R = StorageValue>(key: string): Promise<R | null>;
17
+ load<R = StorageValue>(key: string): Promise<string | R>;
18
18
  /** Saves value to storage */
19
19
  save(key: string, value: StorageValue): Promise<void>;
20
20
  /**
@@ -1,15 +1,14 @@
1
1
  import { RawStackFrame } from './stacktrace-parser';
2
2
  import { REQUIRED_DATA_PROCESSING_URLS } from '../constants';
3
- import { JSErrorOutputMessage } from '../../types/PageVisit.types';
3
+ import { JSErrorOutputMessage } from '../../types/PageVisitErrors.types';
4
4
  /**
5
5
  * returns a string that satisfies a max length
6
6
  * stringToVerify: string that needs to be verified
7
7
  * length :optional, max length that stringToVerify can be
8
8
  */
9
- export declare function getMaxSubstringAllowed(stringToVerify: string, length?: 1024): string;
9
+ export declare function getMaxSubstringAllowed(stringToVerify: string, length?: number): string;
10
10
  /**
11
11
  * Processes the raw stack frames and creates a readable stack in a safe manner
12
- * @param {StackFrame[]} rawFrames
13
12
  */
14
13
  export declare function processFrames(rawFrames: RawStackFrame[]): {
15
14
  file: string;
@@ -28,7 +27,7 @@ export declare function getJSStack(errObj: {
28
27
  /**
29
28
  * Checks if possiblyStacktrace has any stack frames present
30
29
  */
31
- export declare function isStackTrace(_possiblyStacktrace: string): boolean;
30
+ export declare function isStackTrace(_possiblyStacktrace: unknown): _possiblyStacktrace is string;
32
31
  /**
33
32
  * counts the number of bytes
34
33
  */
@@ -80,7 +79,7 @@ export declare function maskTextInput(text: string): string;
80
79
  * It's safer than `instanceof` operator as it handles cases
81
80
  * where type is not actually a type but an object.
82
81
  */
83
- export declare function isInstanceOf(instance: unknown, type: unknown): boolean;
82
+ export declare function isInstanceOf<T>(instance: unknown, type: T): instance is T;
84
83
  /**
85
84
  * To grab the video recorder type based on the device we run the app on.
86
85
  */
@@ -1,5 +1,4 @@
1
1
  /** @module Object */
2
- type Func = (...args: any[]) => any;
3
2
  /**
4
3
  * Replaces an attribute value found in an object with another value
5
4
  * sourceObject: source object whose attribute will get replaced
@@ -10,14 +9,14 @@ type Func = (...args: any[]) => any;
10
9
  * @param {} attributeName
11
10
  * @param {} processingFunction
12
11
  */
13
- export declare const replace: <A extends { [k in K]: Func; }, K extends keyof A>(sourceObject: A, attributeName: K, processingFunction: (arg: A[K]) => A[K]) => void;
12
+ export declare const replace: <A extends { [k in K]: Function; }, K extends keyof A>(sourceObject: A, attributeName: K, processingFunction: (arg: A[K]) => A[K]) => void;
14
13
  /**
15
14
  * unwraps wrapped property, so we can use it without side effects
16
15
  * @param anything
17
16
  */
18
17
  export declare function unwrapNoibuWrapped<T>(anything: {
19
18
  __noibu_original__?: T;
20
- } & T): NonNullable<T>;
19
+ } & T): T;
21
20
  /**
22
21
  * Checks whether the prototype's property is writeable. If it is not,
23
22
  * checks whether the property can be made writeable. If it can, it is
@@ -36,11 +35,10 @@ export declare const propWriteableOrMadeWriteable: <T>(proto: T, property: keyof
36
35
  export declare const iterateObjectRecursively: (instance: Record<any, any>, visit: (i: typeof instance, p: keyof typeof i, v: (typeof i)[typeof p]) => typeof v, limit?: {
37
36
  depth: number;
38
37
  }) => void;
39
- export declare const safeEntries: (obj: unknown | Record<string, string | null> | Headers) => [string, string | null][];
38
+ export declare const safeEntries: (obj: unknown | Record<string, string | null> | Headers) => [string, string][];
40
39
  /**
41
40
  * Replaces the behaviour of Object.fromEntries() as it is not supported on all browsers
42
41
  * @param {Iterable} entries The iterable to parse into an object
43
42
  * @returns An object containing the same key/values as the iterable passed
44
43
  */
45
44
  export declare const safeFromEntries: <T>(entries: unknown) => Record<string, T>;
46
- export {};
@@ -1,7 +1,4 @@
1
1
  /**
2
2
  * In case Promise.all is not available, use this polyfill
3
3
  */
4
- export declare const promiseAll: {
5
- <T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>[]>;
6
- <T extends readonly unknown[] | []>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>;
7
- };
4
+ export declare const promiseAll: any;
@@ -0,0 +1,73 @@
1
+ import { BLOCK_SOCKET_MESSAGE, BROWSER_ID_ATT_NAME, CLOSE_CONNECTION_FORCEFULLY, COLLECT_VER_ATT_NAME, CONN_COUNT_ATT_NAME, CSS_URLS_ATT_NAME, CUSTOM_ID_NAME_TYPE, CUSTOM_ID_VALUE_TYPE, END_AT_ATT_NAME, HELP_CODE_ATT_NAME, HTTP_DATA_METROPLEX_TYPE, IS_LAST_ATT_NAME, LANG_ATT_NAME, LENGTH_ATT_NAME, META_DATA_METROPLEX_TYPE, METROPLEX_SOCKET_INSTANCE_ID_ATT_NAME, OK_SOCKET_MESSAGE, ON_URL_ATT_NAME, PAGE_VISIT_HTTP_DATA_ATT_NAME, PAGE_VISIT_INFORMATION_ATT_NAME, PAGE_VISIT_META_DATA_ATT_NAME, PAGE_VISIT_PART_ATT_NAME, PAGE_VISIT_VID_FRAG_ATT_NAME, PV_EVENTS_ATT_NAME, PV_ID_ATT_NAME, PV_METROPLEX_TYPE, PV_PART_COUNTER_ATT_NAME, PV_SEQ_ATT_NAME, REF_URL_ATT_NAME, SCRIPT_ID_ATT_NAME, SCRIPT_INSTANCE_ID_ATT_NAME, SEQ_NUM_ATT_NAME, SOCKET_INSTANCE_ID_ATT_NAME, STARTED_AT_ATT_NAME, STOP_STORING_PV_SOCKET_MESSAGE, STOP_STORING_VID_SOCKET_MESSAGE, VIDEO_FRAG_ATT_NAME, VIDEO_METROPLEX_TYPE, VIDEO_RECORDER_ATT_NAME, WORK_REQUEST_ATT_NAME } from '../src/constants';
2
+ import { HTTPDataBundle, PVEventMessage } from './PageVisitEvents.types';
3
+ export interface PageVisitInfo {
4
+ [BROWSER_ID_ATT_NAME]: string;
5
+ [PV_ID_ATT_NAME]: string;
6
+ [VIDEO_METROPLEX_TYPE]: number;
7
+ [SCRIPT_ID_ATT_NAME]: string;
8
+ [SCRIPT_INSTANCE_ID_ATT_NAME]: string;
9
+ [METROPLEX_SOCKET_INSTANCE_ID_ATT_NAME]: string;
10
+ [SOCKET_INSTANCE_ID_ATT_NAME]: string;
11
+ [PV_SEQ_ATT_NAME]: number;
12
+ [IS_LAST_ATT_NAME]: boolean;
13
+ [CONN_COUNT_ATT_NAME]: number;
14
+ [ON_URL_ATT_NAME]: string;
15
+ [REF_URL_ATT_NAME]: string;
16
+ [STARTED_AT_ATT_NAME]: string;
17
+ [COLLECT_VER_ATT_NAME]: number;
18
+ [LANG_ATT_NAME]?: string;
19
+ [VIDEO_RECORDER_ATT_NAME]: string;
20
+ }
21
+ export interface OutboundMessageTypeMap {
22
+ [META_DATA_METROPLEX_TYPE]: MetadataMessagePayload;
23
+ [WORK_REQUEST_ATT_NAME]: WorkRequestPayload;
24
+ [PV_METROPLEX_TYPE]: PageVisitPartPayload;
25
+ [HTTP_DATA_METROPLEX_TYPE]: HttpDataPayload;
26
+ [VIDEO_METROPLEX_TYPE]: VideoPartPayload;
27
+ [PAGE_VISIT_INFORMATION_ATT_NAME]: PageVisitInfo;
28
+ }
29
+ export type OutboundMessageType = keyof OutboundMessageTypeMap;
30
+ export type MetroMessagePayloadProps = typeof PAGE_VISIT_PART_ATT_NAME | typeof PAGE_VISIT_VID_FRAG_ATT_NAME | typeof PAGE_VISIT_HTTP_DATA_ATT_NAME | typeof PAGE_VISIT_META_DATA_ATT_NAME;
31
+ export interface MetadataMessagePayload {
32
+ [PAGE_VISIT_META_DATA_ATT_NAME]: {
33
+ [CUSTOM_ID_VALUE_TYPE]: string;
34
+ [CUSTOM_ID_NAME_TYPE]: string;
35
+ };
36
+ }
37
+ export interface WorkRequestPayload {
38
+ [WORK_REQUEST_ATT_NAME]: typeof HELP_CODE_ATT_NAME;
39
+ }
40
+ export interface PageVisitPartPayload {
41
+ [PAGE_VISIT_PART_ATT_NAME]: PageVisitFrag;
42
+ }
43
+ export interface PageVisitFrag {
44
+ [PV_EVENTS_ATT_NAME]: PVEventMessage[];
45
+ [PV_PART_COUNTER_ATT_NAME]: number;
46
+ [END_AT_ATT_NAME]?: string;
47
+ [SEQ_NUM_ATT_NAME]?: number;
48
+ }
49
+ export interface HttpDataPayload {
50
+ [PAGE_VISIT_HTTP_DATA_ATT_NAME]: HTTPDataBundle;
51
+ }
52
+ export interface VideoPartPayload {
53
+ [PAGE_VISIT_VID_FRAG_ATT_NAME]: VideoFrag;
54
+ }
55
+ export interface VideoFrag {
56
+ [VIDEO_FRAG_ATT_NAME]: string;
57
+ [LENGTH_ATT_NAME]: number;
58
+ [PV_SEQ_ATT_NAME]: number;
59
+ [CSS_URLS_ATT_NAME]: string[];
60
+ [END_AT_ATT_NAME]?: string;
61
+ }
62
+ export interface CompletePageVisit {
63
+ [PAGE_VISIT_VID_FRAG_ATT_NAME]: VideoFrag[];
64
+ [PAGE_VISIT_INFORMATION_ATT_NAME]: PageVisitInfo;
65
+ [PAGE_VISIT_PART_ATT_NAME]: PageVisitFrag[];
66
+ }
67
+ export interface SlidingMessage<T extends OutboundMessageType = OutboundMessageType> {
68
+ type: T;
69
+ payload: OutboundMessageTypeMap[T];
70
+ }
71
+ export interface InboundMessageType {
72
+ data?: typeof STOP_STORING_VID_SOCKET_MESSAGE | typeof STOP_STORING_PV_SOCKET_MESSAGE | typeof BLOCK_SOCKET_MESSAGE | typeof CLOSE_CONNECTION_FORCEFULLY | typeof OK_SOCKET_MESSAGE | string;
73
+ }
@@ -1,151 +1,8 @@
1
- import { CLICK_EVENT_TYPE, CSS_CLASS_ATT_NAME, CUSTOM_ERROR_EVENT_TYPE, ERROR_EVENT_ERROR_TYPE, ERROR_EVENT_UNHANDLED_REJECTION_TYPE, ERROR_LOG_EVENT_ERROR_TYPE, ERROR_SOURCE_ATT_NAME, FETCH_EXCEPTION_ERROR_TYPE, GLOBAL_REASSIGN_ERROR_TYPE, GQL_COLUMN_ATT_NAME, GQL_ERROR_ATT_NAME, GQL_ERROR_TYPE, GQL_EXTENSIONS_ATT_NAME, GQL_LINE_ATT_NAME, GQL_LOCATIONS_ATT_NAME, GQL_MESSAGE_ATT_NAME, GQL_PATH_ATT_NAME, GQL_SRC_ATT_NAME, HTMLID_ATT_NAME, HTTP_CODE_ATT_NAME, HTTP_DATA_PAYLOAD_ATT_NAME, HTTP_DATA_REQ_HEADERS_ATT_NAME, HTTP_DATA_RESP_HEADERS_ATT_NAME, HTTP_DATA_RESP_PAYLOAD_ATT_NAME, HTTP_METHOD_ATT_NAME, HTTP_RESP_CODE_ATT_NAME, HTTP_RESP_LENGTH_ATT_NAME, HTTP_RESP_TIME_ATT_NAME, IMAGE_ERROR_TYPE, JS_ERROR_ATT_NAME, JS_STACK_CAUSE_ATT_NAME, JS_STACK_COL_ATT_NAME, JS_STACK_FILE_ATT_NAME, JS_STACK_FRAMES_ATT_NAME, JS_STACK_LINE_ATT_NAME, JS_STACK_MESSAGE_ATT_NAME, JS_STACK_METHOD_ATT_NAME, KEYBOARD_EVENT_TYPE, PAGE_CHECK_ERROR_ATT_NAME, PAGE_CHECK_ERROR_TYPE, PV_SEQ_ATT_NAME, RESOURCE_ERROR_ATT_NAME, RESPONSE_ERROR_TYPE, SOURCE_ATT_NAME, TAGNAME_ATT_NAME, TEXT_ATT_NAME, TYPE_ATT_NAME, URL_ATT_NAME, WRAPPED_EXCEPTION_ERROR_TYPE } from '../src/constants';
2
- export type PVEventHTTP = {
3
- [HTTP_METHOD_ATT_NAME]: string;
4
- [HTTP_RESP_CODE_ATT_NAME]: number;
5
- [URL_ATT_NAME]: string;
6
- [HTTP_RESP_TIME_ATT_NAME]: number;
7
- [HTTP_RESP_LENGTH_ATT_NAME]?: number;
8
- [PV_SEQ_ATT_NAME]?: number;
9
- };
10
- export type HTTPDataBundle = {
11
- [HTTP_DATA_REQ_HEADERS_ATT_NAME]: Record<string, string>;
12
- [HTTP_DATA_PAYLOAD_ATT_NAME]: string;
13
- [HTTP_DATA_RESP_HEADERS_ATT_NAME]: Record<string, string>;
14
- [HTTP_DATA_RESP_PAYLOAD_ATT_NAME]: string;
15
- };
16
- export interface UserInputMonitorPayload {
17
- [SOURCE_ATT_NAME]: string;
18
- [TEXT_ATT_NAME]: string;
19
- [TAGNAME_ATT_NAME]: string;
20
- [HTMLID_ATT_NAME]: string;
21
- [TYPE_ATT_NAME]: string;
22
- [CSS_CLASS_ATT_NAME]: string;
23
- }
24
- export interface ClickMonitorPayload extends UserInputMonitorPayload {
25
- [SOURCE_ATT_NAME]: string;
26
- [TEXT_ATT_NAME]: string;
27
- [TAGNAME_ATT_NAME]: string;
28
- [HTMLID_ATT_NAME]: string;
29
- [TYPE_ATT_NAME]: typeof CLICK_EVENT_TYPE;
30
- [CSS_CLASS_ATT_NAME]: string;
31
- }
32
- export interface KeyboardMonitorPayload extends UserInputMonitorPayload {
33
- [SOURCE_ATT_NAME]: string;
34
- [TEXT_ATT_NAME]: string;
35
- [TAGNAME_ATT_NAME]: string;
36
- [HTMLID_ATT_NAME]: string;
37
- [TYPE_ATT_NAME]: typeof KEYBOARD_EVENT_TYPE;
38
- [CSS_CLASS_ATT_NAME]: string;
39
- }
40
- export type JSErrorOutputMessage = {
41
- [JS_STACK_MESSAGE_ATT_NAME]: string;
42
- [JS_STACK_FRAMES_ATT_NAME]: {
43
- [JS_STACK_FILE_ATT_NAME]: string;
44
- [JS_STACK_LINE_ATT_NAME]: string;
45
- [JS_STACK_METHOD_ATT_NAME]: string;
46
- [JS_STACK_COL_ATT_NAME]?: number;
47
- }[];
48
- [JS_STACK_CAUSE_ATT_NAME]?: UserInputMonitorPayload[];
49
- };
1
+ import { UserStepEventPayload } from './PageVisitEvents.types';
50
2
  /**
51
3
  * Helper class to improve typing in methods that use anonymous classes: Keyboard and Click monitors
52
4
  */
53
5
  export interface UserInputEventMonitor {
54
6
  isValid(event: Event): boolean;
55
- getPayload(event: Event): UserInputMonitorPayload;
56
- }
57
- export declare namespace PVError {
58
- export interface Input {
59
- [ERROR_EVENT_ERROR_TYPE]: EventInput;
60
- [ERROR_EVENT_UNHANDLED_REJECTION_TYPE]: EventInput;
61
- [RESPONSE_ERROR_TYPE]: ResponseInput;
62
- [GQL_ERROR_TYPE]: GqlInput;
63
- [IMAGE_ERROR_TYPE]: ResourceInput;
64
- [PAGE_CHECK_ERROR_TYPE]: PageCheckInput;
65
- [WRAPPED_EXCEPTION_ERROR_TYPE]: EventInput;
66
- [FETCH_EXCEPTION_ERROR_TYPE]: EventInput;
67
- [ERROR_LOG_EVENT_ERROR_TYPE]: JErrorObject;
68
- [CUSTOM_ERROR_EVENT_TYPE]: EventInput;
69
- [GLOBAL_REASSIGN_ERROR_TYPE]: GlobalReassignInput;
70
- }
71
- export interface Output {
72
- [ERROR_EVENT_ERROR_TYPE]: Event;
73
- [ERROR_EVENT_UNHANDLED_REJECTION_TYPE]: Event;
74
- [RESPONSE_ERROR_TYPE]: Http;
75
- [GQL_ERROR_TYPE]: Gql;
76
- [IMAGE_ERROR_TYPE]: Image;
77
- [PAGE_CHECK_ERROR_TYPE]: PageCheck;
78
- [WRAPPED_EXCEPTION_ERROR_TYPE]: Event;
79
- [FETCH_EXCEPTION_ERROR_TYPE]: Event;
80
- [ERROR_LOG_EVENT_ERROR_TYPE]: Log;
81
- [CUSTOM_ERROR_EVENT_TYPE]: Event;
82
- [GLOBAL_REASSIGN_ERROR_TYPE]: Event;
83
- }
84
- export type ResourceInput = {
85
- tag_name: string;
86
- id?: string;
87
- src: string;
88
- detail: string;
89
- };
90
- export type PageCheckInput = {
91
- checkId: string;
92
- version?: string;
93
- triggerId?: string;
94
- assertionId?: string;
95
- log: string[];
96
- };
97
- export type GqlInput = {
98
- [GQL_SRC_ATT_NAME]?: string;
99
- [GQL_MESSAGE_ATT_NAME]: string;
100
- [GQL_LOCATIONS_ATT_NAME]?: {
101
- [GQL_LINE_ATT_NAME]: number;
102
- [GQL_COLUMN_ATT_NAME]: number;
103
- }[];
104
- [GQL_PATH_ATT_NAME]?: string[];
105
- [GQL_EXTENSIONS_ATT_NAME]?: string;
106
- };
107
- export type ResponseInput = Pick<Response, 'status' | 'url'>;
108
- export type JErrWithCause = Partial<{
109
- cause: UserInputMonitorPayload[];
110
- }>;
111
- export type JErrWithStack = Error & JErrWithCause;
112
- export type JErrWithFilename = {
113
- fileName: string;
114
- lineNumber: string;
115
- columnNumber: number;
116
- } & JErrWithCause;
117
- export type JErrorObject = JErrWithFilename | JErrWithStack;
118
- export type EventInput = {
119
- filename?: string;
120
- error: JErrorObject;
121
- };
122
- export type GlobalReassignInput = {
123
- error: Error;
124
- };
125
- interface Base {
126
- [TYPE_ATT_NAME]: string;
127
- [URL_ATT_NAME]: string;
128
- [ERROR_SOURCE_ATT_NAME]?: keyof Input;
129
- }
130
- export interface Http extends Base {
131
- [HTTP_CODE_ATT_NAME]: number;
132
- [PV_SEQ_ATT_NAME]?: number;
133
- }
134
- export interface Event extends Base {
135
- [JS_ERROR_ATT_NAME]: JSErrorOutputMessage;
136
- }
137
- export interface Gql extends Base {
138
- [GQL_ERROR_ATT_NAME]: GqlInput;
139
- [PV_SEQ_ATT_NAME]?: number;
140
- }
141
- export interface Log extends Base {
142
- [JS_ERROR_ATT_NAME]: JSErrorOutputMessage;
143
- }
144
- export interface PageCheck extends Base {
145
- [PAGE_CHECK_ERROR_ATT_NAME]: PageCheckInput;
146
- }
147
- export interface Image extends Base {
148
- [RESOURCE_ERROR_ATT_NAME]: ResourceInput;
149
- }
150
- export {};
7
+ getPayload(event: Event): UserStepEventPayload;
151
8
  }
@@ -0,0 +1,114 @@
1
+ import { CUSTOM_ERROR_EVENT_TYPE, ERROR_EVENT_ERROR_TYPE, ERROR_EVENT_UNHANDLED_REJECTION_TYPE, ERROR_LOG_EVENT_ERROR_TYPE, ERROR_SOURCE_ATT_NAME, FETCH_EXCEPTION_ERROR_TYPE, GLOBAL_REASSIGN_ERROR_TYPE, GQL_COLUMN_ATT_NAME, GQL_ERROR_ATT_NAME, GQL_ERROR_TYPE, GQL_EXTENSIONS_ATT_NAME, GQL_LINE_ATT_NAME, GQL_LOCATIONS_ATT_NAME, GQL_MESSAGE_ATT_NAME, GQL_PATH_ATT_NAME, GQL_SRC_ATT_NAME, HTTP_CODE_ATT_NAME, IMAGE_ERROR_TYPE, JS_ERROR_ATT_NAME, JS_STACK_CAUSE_ATT_NAME, JS_STACK_COL_ATT_NAME, JS_STACK_FILE_ATT_NAME, JS_STACK_FRAMES_ATT_NAME, JS_STACK_LINE_ATT_NAME, JS_STACK_MESSAGE_ATT_NAME, JS_STACK_METHOD_ATT_NAME, PAGE_CHECK_ERROR_ATT_NAME, PAGE_CHECK_ERROR_TYPE, PV_SEQ_ATT_NAME, RESOURCE_ERROR_ATT_NAME, RESPONSE_ERROR_TYPE, TYPE_ATT_NAME, URL_ATT_NAME, WRAPPED_EXCEPTION_ERROR_TYPE, XML_HTTP_REQUEST_ERROR_TYPE } from '../src/constants';
2
+ import { WrappedXMLHttpRequest } from './WrappedObjects';
3
+ import { UserStepEventPayload } from './PageVisitEvents.types';
4
+ export interface Input {
5
+ [XML_HTTP_REQUEST_ERROR_TYPE]: HttpInput;
6
+ [ERROR_EVENT_ERROR_TYPE]: EventInput;
7
+ [ERROR_EVENT_UNHANDLED_REJECTION_TYPE]: EventInput;
8
+ [RESPONSE_ERROR_TYPE]: ResponseInput;
9
+ [GQL_ERROR_TYPE]: GqlInput;
10
+ [IMAGE_ERROR_TYPE]: ResourceInput;
11
+ [PAGE_CHECK_ERROR_TYPE]: PageCheckInput;
12
+ [WRAPPED_EXCEPTION_ERROR_TYPE]: EventInput;
13
+ [FETCH_EXCEPTION_ERROR_TYPE]: EventInput;
14
+ [ERROR_LOG_EVENT_ERROR_TYPE]: JErrorObject;
15
+ [CUSTOM_ERROR_EVENT_TYPE]: EventInput;
16
+ [GLOBAL_REASSIGN_ERROR_TYPE]: GlobalReassignInput;
17
+ }
18
+ export interface Output {
19
+ [XML_HTTP_REQUEST_ERROR_TYPE]: Http;
20
+ [ERROR_EVENT_ERROR_TYPE]: JSError;
21
+ [ERROR_EVENT_UNHANDLED_REJECTION_TYPE]: JSError;
22
+ [RESPONSE_ERROR_TYPE]: Http;
23
+ [GQL_ERROR_TYPE]: Gql;
24
+ [IMAGE_ERROR_TYPE]: Image;
25
+ [PAGE_CHECK_ERROR_TYPE]: PageCheck;
26
+ [WRAPPED_EXCEPTION_ERROR_TYPE]: JSError;
27
+ [FETCH_EXCEPTION_ERROR_TYPE]: JSError;
28
+ [ERROR_LOG_EVENT_ERROR_TYPE]: LogError;
29
+ [CUSTOM_ERROR_EVENT_TYPE]: JSError;
30
+ [GLOBAL_REASSIGN_ERROR_TYPE]: JSError;
31
+ }
32
+ export interface ResourceInput {
33
+ tag_name: string;
34
+ id?: string;
35
+ src: string;
36
+ detail: string;
37
+ }
38
+ export interface PageCheckInput {
39
+ checkId: string;
40
+ version?: string;
41
+ triggerId?: string;
42
+ assertionId?: string;
43
+ log: string[];
44
+ }
45
+ export interface GqlInput {
46
+ [GQL_SRC_ATT_NAME]?: string;
47
+ [GQL_MESSAGE_ATT_NAME]: string;
48
+ [GQL_LOCATIONS_ATT_NAME]?: {
49
+ [GQL_LINE_ATT_NAME]: number;
50
+ [GQL_COLUMN_ATT_NAME]: number;
51
+ }[];
52
+ [GQL_PATH_ATT_NAME]?: string[];
53
+ [GQL_EXTENSIONS_ATT_NAME]?: string;
54
+ }
55
+ export interface HttpInputBase {
56
+ status: XMLHttpRequest['status'] | Response['status'];
57
+ }
58
+ export interface ResponseInput extends Pick<Response, 'url'>, HttpInputBase {
59
+ }
60
+ export interface HttpInput extends Pick<WrappedXMLHttpRequest, 'responseURL'>, HttpInputBase {
61
+ }
62
+ export type JErrWithCause = Partial<{
63
+ cause: UserStepEventPayload[];
64
+ }>;
65
+ export type JErrWithStack = Error & JErrWithCause;
66
+ export interface JErrWithFilename extends JErrWithCause {
67
+ fileName: string;
68
+ lineNumber: string;
69
+ columnNumber: number;
70
+ }
71
+ export type JErrorObject = JErrWithFilename | JErrWithStack;
72
+ export interface EventInput {
73
+ filename?: string;
74
+ error: JErrorObject;
75
+ }
76
+ export interface GlobalReassignInput {
77
+ error: Error;
78
+ }
79
+ interface Base {
80
+ [TYPE_ATT_NAME]: string;
81
+ [URL_ATT_NAME]: string;
82
+ [ERROR_SOURCE_ATT_NAME]?: keyof Input;
83
+ }
84
+ export interface Http extends Base {
85
+ [HTTP_CODE_ATT_NAME]: number;
86
+ [PV_SEQ_ATT_NAME]?: number;
87
+ }
88
+ export interface JSError extends Base {
89
+ [JS_ERROR_ATT_NAME]: JSErrorOutputMessage;
90
+ }
91
+ export interface Gql extends Base {
92
+ [GQL_ERROR_ATT_NAME]: GqlInput;
93
+ [PV_SEQ_ATT_NAME]?: number;
94
+ }
95
+ export interface LogError extends Base {
96
+ [JS_ERROR_ATT_NAME]: JSErrorOutputMessage;
97
+ }
98
+ export interface PageCheck extends Base {
99
+ [PAGE_CHECK_ERROR_ATT_NAME]: PageCheckInput;
100
+ }
101
+ export interface Image extends Base {
102
+ [RESOURCE_ERROR_ATT_NAME]: ResourceInput;
103
+ }
104
+ export interface JSErrorOutputMessage {
105
+ [JS_STACK_MESSAGE_ATT_NAME]: string;
106
+ [JS_STACK_FRAMES_ATT_NAME]: {
107
+ [JS_STACK_FILE_ATT_NAME]: string;
108
+ [JS_STACK_LINE_ATT_NAME]: string;
109
+ [JS_STACK_METHOD_ATT_NAME]: string;
110
+ [JS_STACK_COL_ATT_NAME]?: number;
111
+ }[];
112
+ [JS_STACK_CAUSE_ATT_NAME]?: UserStepEventPayload[];
113
+ }
114
+ export {};