@truewatchtech/react-native-mobile 0.4.2 → 0.4.3
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/FTMobileReactNativeSDK.podspec +7 -5
- package/android/build.gradle +10 -3
- package/android/src/main/java/com/ft/sdk/reactnative/FTLogImpl.java +10 -2
- package/android/src/main/java/com/ft/sdk/reactnative/FTMobileImpl.java +45 -10
- package/android/src/main/java/com/ft/sdk/reactnative/FTRUMImpl.java +131 -6
- package/android/src/main/java/com/ft/sdk/reactnative/FTTraceImpl.java +10 -3
- package/android/src/main/java/com/ft/sdk/reactnative/JsLongTaskMonitor.java +281 -0
- package/android/src/main/java/com/ft/sdk/reactnative/ViewTiming.java +17 -0
- package/android/src/main/java/com/ft/sdk/reactnative/VisitorIdConfigMapper.java +50 -0
- package/android/src/main/java/com/ft/sdk/reactnative/utils/ReactNativeUtils.java +5 -12
- package/android/src/newarch/java/com/ft/sdk/reactnative/FTMobileModule.java +14 -5
- package/android/src/newarch/java/com/ft/sdk/reactnative/FTRUMModule.java +44 -1
- package/android/src/newarch/java/com/ft/sdk/reactnative/FTTraceModule.java +14 -0
- package/android/src/oldarch/java/com/ft/sdk/reactnative/FTMobileModule.java +7 -2
- package/android/src/oldarch/java/com/ft/sdk/reactnative/FTRUMModule.java +39 -1
- package/android/src/oldarch/java/com/ft/sdk/reactnative/FTTraceModule.java +12 -0
- package/android/src/rnpost70/java/com/ft/sdk/reactnative/ReactJsThreadExecutor.java +21 -0
- package/android/src/rnpre70/java/com/ft/sdk/reactnative/ReactJsThreadExecutor.java +37 -0
- package/android/src/test/java/com/ft/sdk/reactnative/FTMobileImplTest.java +53 -0
- package/android/src/test/java/com/ft/sdk/reactnative/FTRUMModuleTest.java +117 -0
- package/android/src/test/java/com/ft/sdk/reactnative/JsLongTaskMonitorTest.java +446 -0
- package/android/src/test/java/com/ft/sdk/reactnative/utils/ReactNativeUtilsTest.java +33 -0
- package/ios/FTJSLongTaskMonitor.h +51 -0
- package/ios/FTJSLongTaskMonitor.m +250 -0
- package/ios/FTMobileReactNative.mm +54 -18
- package/ios/FTReactNativeLog.mm +9 -5
- package/ios/FTReactNativeRUM.mm +196 -31
- package/ios/FTReactNativeResource.h +4 -0
- package/ios/FTReactNativeResource.m +64 -0
- package/ios/FTReactNativeTrace.mm +59 -14
- package/ios/FTReactNativeUtils.m +10 -15
- package/ios/FTReactNativeViewTiming.h +18 -0
- package/ios/FTReactNativeWebSocket.h +10 -0
- package/ios/FTReactNativeWebSocket.mm +201 -0
- package/ios/FTWebSocketMetadataStore.h +25 -0
- package/ios/FTWebSocketMetadataStore.m +622 -0
- package/ios/FTWebSocketResourceData.h +20 -0
- package/ios/FTWebSocketResourceData.m +106 -0
- package/lib/commonjs/ft_logger.js +3 -1
- package/lib/commonjs/ft_logger.js.map +1 -1
- package/lib/commonjs/ft_mobile_agent.js +47 -4
- package/lib/commonjs/ft_mobile_agent.js.map +1 -1
- package/lib/commonjs/ft_rum.js +65 -5
- package/lib/commonjs/ft_rum.js.map +1 -1
- package/lib/commonjs/ft_tracing.js +14 -4
- package/lib/commonjs/ft_tracing.js.map +1 -1
- package/lib/commonjs/index.js +21 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/rum/FTBabelInteractionTracking.js +72 -0
- package/lib/commonjs/rum/FTBabelInteractionTracking.js.map +1 -0
- package/lib/commonjs/rum/FTBabelUtils.js +87 -0
- package/lib/commonjs/rum/FTBabelUtils.js.map +1 -0
- package/lib/commonjs/rum/FTRumActionTracking.js +10 -39
- package/lib/commonjs/rum/FTRumActionTracking.js.map +1 -1
- package/lib/commonjs/rum/FTRumActionTrackingContext.js +50 -0
- package/lib/commonjs/rum/FTRumActionTrackingContext.js.map +1 -0
- package/lib/commonjs/rum/FTRumViewTracking.js +147 -0
- package/lib/commonjs/rum/FTRumViewTracking.js.map +1 -0
- package/lib/commonjs/rum/FTRumWebSocketNative.js +73 -0
- package/lib/commonjs/rum/FTRumWebSocketNative.js.map +1 -0
- package/lib/commonjs/rum/FTRumWebSocketTiming.js +73 -0
- package/lib/commonjs/rum/FTRumWebSocketTiming.js.map +1 -0
- package/lib/commonjs/rum/FTRumWebSocketTracking.js +506 -0
- package/lib/commonjs/rum/FTRumWebSocketTracking.js.map +1 -0
- package/lib/commonjs/rum/longTasksUtils.js +25 -0
- package/lib/commonjs/rum/longTasksUtils.js.map +1 -0
- package/lib/commonjs/specs/NativeFTMobileReactNative.js.map +1 -1
- package/lib/commonjs/specs/NativeFTReactNativeRUM.js.map +1 -1
- package/lib/commonjs/specs/NativeFTReactNativeTrace.js.map +1 -1
- package/lib/commonjs/specs/NativeFTReactNativeWebSocket.js +11 -0
- package/lib/commonjs/specs/NativeFTReactNativeWebSocket.js.map +1 -0
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/commonjs/visitorIdConfig.js +37 -0
- package/lib/commonjs/visitorIdConfig.js.map +1 -0
- package/lib/module/ft_logger.js +3 -1
- package/lib/module/ft_logger.js.map +1 -1
- package/lib/module/ft_mobile_agent.js +47 -4
- package/lib/module/ft_mobile_agent.js.map +1 -1
- package/lib/module/ft_rum.js +65 -5
- package/lib/module/ft_rum.js.map +1 -1
- package/lib/module/ft_tracing.js +14 -2
- package/lib/module/ft_tracing.js.map +1 -1
- package/lib/module/index.js +4 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/rum/FTBabelInteractionTracking.js +66 -0
- package/lib/module/rum/FTBabelInteractionTracking.js.map +1 -0
- package/lib/module/rum/FTBabelUtils.js +80 -0
- package/lib/module/rum/FTBabelUtils.js.map +1 -0
- package/lib/module/rum/FTRumActionTracking.js +10 -39
- package/lib/module/rum/FTRumActionTracking.js.map +1 -1
- package/lib/module/rum/FTRumActionTrackingContext.js +43 -0
- package/lib/module/rum/FTRumActionTrackingContext.js.map +1 -0
- package/lib/module/rum/FTRumViewTracking.js +140 -0
- package/lib/module/rum/FTRumViewTracking.js.map +1 -0
- package/lib/module/rum/FTRumWebSocketNative.js +62 -0
- package/lib/module/rum/FTRumWebSocketNative.js.map +1 -0
- package/lib/module/rum/FTRumWebSocketTiming.js +67 -0
- package/lib/module/rum/FTRumWebSocketTiming.js.map +1 -0
- package/lib/module/rum/FTRumWebSocketTracking.js +499 -0
- package/lib/module/rum/FTRumWebSocketTracking.js.map +1 -0
- package/lib/module/rum/longTasksUtils.js +18 -0
- package/lib/module/rum/longTasksUtils.js.map +1 -0
- package/lib/module/specs/NativeFTMobileReactNative.js.map +1 -1
- package/lib/module/specs/NativeFTReactNativeRUM.js.map +1 -1
- package/lib/module/specs/NativeFTReactNativeTrace.js.map +1 -1
- package/lib/module/specs/NativeFTReactNativeWebSocket.js +8 -0
- package/lib/module/specs/NativeFTReactNativeWebSocket.js.map +1 -0
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/module/visitorIdConfig.js +31 -0
- package/lib/module/visitorIdConfig.js.map +1 -0
- package/lib/typescript/ft_logger.d.ts +11 -1
- package/lib/typescript/ft_mobile_agent.d.ts +28 -0
- package/lib/typescript/ft_rum.d.ts +42 -5
- package/lib/typescript/ft_tracing.d.ts +9 -1
- package/lib/typescript/index.d.ts +5 -1
- package/lib/typescript/rum/FTBabelInteractionTracking.d.ts +30 -0
- package/lib/typescript/rum/FTBabelUtils.d.ts +1 -0
- package/lib/typescript/rum/FTRumActionTracking.d.ts +0 -2
- package/lib/typescript/rum/FTRumActionTrackingContext.d.ts +11 -0
- package/lib/typescript/rum/FTRumViewTracking.d.ts +32 -0
- package/lib/typescript/rum/FTRumWebSocketNative.d.ts +22 -0
- package/lib/typescript/rum/FTRumWebSocketTiming.d.ts +7 -0
- package/lib/typescript/rum/FTRumWebSocketTracking.d.ts +54 -0
- package/lib/typescript/rum/longTasksUtils.d.ts +8 -0
- package/lib/typescript/specs/NativeFTMobileReactNative.d.ts +15 -0
- package/lib/typescript/specs/NativeFTReactNativeRUM.d.ts +11 -1
- package/lib/typescript/specs/NativeFTReactNativeTrace.d.ts +12 -0
- package/lib/typescript/specs/NativeFTReactNativeWebSocket.d.ts +13 -0
- package/lib/typescript/version.d.ts +1 -1
- package/lib/typescript/visitorIdConfig.d.ts +11 -0
- package/package.json +6 -4
- package/src/ft_logger.tsx +11 -1
- package/src/ft_mobile_agent.tsx +79 -7
- package/src/ft_rum.tsx +111 -7
- package/src/ft_tracing.tsx +24 -2
- package/src/index.tsx +8 -0
- package/src/rum/FTBabelInteractionTracking.ts +124 -0
- package/src/rum/FTBabelUtils.tsx +99 -0
- package/src/rum/FTRumActionTracking.tsx +14 -43
- package/src/rum/FTRumActionTrackingContext.ts +68 -0
- package/src/rum/FTRumViewTracking.ts +179 -0
- package/src/rum/FTRumWebSocketNative.ts +107 -0
- package/src/rum/FTRumWebSocketTiming.ts +82 -0
- package/src/rum/FTRumWebSocketTracking.ts +722 -0
- package/src/rum/longTasksUtils.ts +17 -0
- package/src/specs/NativeFTMobileReactNative.ts +18 -0
- package/src/specs/NativeFTReactNativeRUM.ts +19 -1
- package/src/specs/NativeFTReactNativeTrace.ts +12 -0
- package/src/specs/NativeFTReactNativeWebSocket.ts +33 -0
- package/src/version.ts +1 -1
- package/src/visitorIdConfig.ts +123 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const MIN_LONG_TASK_THRESHOLD_MS = 100;
|
|
2
|
+
export const MAX_LONG_TASK_THRESHOLD_MS = 5000;
|
|
3
|
+
export const DEFAULT_LONG_TASK_THRESHOLD_MS = 100;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Converts the public JavaScript long task option to the numeric value expected
|
|
7
|
+
* by the native bridge. Enablement is controlled separately.
|
|
8
|
+
*/
|
|
9
|
+
export function normalizeLongTaskThreshold(threshold?: number): number {
|
|
10
|
+
if (!threshold) {
|
|
11
|
+
return DEFAULT_LONG_TASK_THRESHOLD_MS;
|
|
12
|
+
}
|
|
13
|
+
if (threshold < MIN_LONG_TASK_THRESHOLD_MS) {
|
|
14
|
+
return MIN_LONG_TASK_THRESHOLD_MS;
|
|
15
|
+
}
|
|
16
|
+
return Math.min(threshold, MAX_LONG_TASK_THRESHOLD_MS);
|
|
17
|
+
}
|
|
@@ -41,6 +41,7 @@ export interface Spec extends TurboModule {
|
|
|
41
41
|
* @returns a Promise.
|
|
42
42
|
*/
|
|
43
43
|
unbindRUMUserData(): Promise<void>;
|
|
44
|
+
resetVisitorId(): Promise<void>;
|
|
44
45
|
/**
|
|
45
46
|
* Add custom global parameters. Applies to RUM and Log data
|
|
46
47
|
* @param context custom global parameters.
|
|
@@ -79,5 +80,22 @@ export interface Spec extends TurboModule {
|
|
|
79
80
|
* Clear all data that has not yet been uploaded to the server.
|
|
80
81
|
*/
|
|
81
82
|
clearAllData(): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Update remote configuration using the configured minimum update interval.
|
|
85
|
+
*/
|
|
86
|
+
updateRemoteConfig(): Promise<Object>;
|
|
87
|
+
/**
|
|
88
|
+
* Update remote configuration using a custom minimum update interval and
|
|
89
|
+
* optional override rules.
|
|
90
|
+
*/
|
|
91
|
+
updateRemoteConfigWithMiniUpdateInterval(
|
|
92
|
+
interval: number,
|
|
93
|
+
rules?: Array<Object>
|
|
94
|
+
): Promise<Object>;
|
|
95
|
+
/**
|
|
96
|
+
* Required by NativeEventEmitter for remote configuration callbacks.
|
|
97
|
+
*/
|
|
98
|
+
addListener(eventName: string): void;
|
|
99
|
+
removeListeners(count: number): void;
|
|
82
100
|
}
|
|
83
101
|
export default TurboModuleRegistry.get<Spec>('FTMobileReactNative');
|
|
@@ -9,6 +9,10 @@ export interface Spec extends TurboModule {
|
|
|
9
9
|
* @returns a Promise.
|
|
10
10
|
*/
|
|
11
11
|
setConfig(config: Object): Promise<void>;
|
|
12
|
+
/** Internal synchronous snapshot used only by native JS long task reporting. */
|
|
13
|
+
setLongTaskContext(context: Object): boolean;
|
|
14
|
+
/** Stops the internal JavaScript long task monitor before SDK shutdown. */
|
|
15
|
+
stopLongTaskTracking(): Promise<void>;
|
|
12
16
|
/**
|
|
13
17
|
* Start RUM Action.
|
|
14
18
|
* RUM will bind Resource, Error, LongTask events that may be triggered by this Action.
|
|
@@ -39,10 +43,24 @@ export interface Spec extends TurboModule {
|
|
|
39
43
|
/**
|
|
40
44
|
* view load duration.
|
|
41
45
|
* @param viewName view name
|
|
42
|
-
* @param loadTime view load duration
|
|
46
|
+
* @param loadTime monotonic view load duration in nanoseconds
|
|
43
47
|
* @returns a Promise.
|
|
44
48
|
*/
|
|
45
49
|
onCreateView(viewName: string, loadTime: number): Promise<void>;
|
|
50
|
+
/** Replace the current View's loading duration; non-negative safe integer nanoseconds. */
|
|
51
|
+
updateViewLoadingTime(duration: number): Promise<void>;
|
|
52
|
+
/** Framework integration: duration in ns; epoch start in ms, converted natively. */
|
|
53
|
+
onCreateViewWithLoadStart(
|
|
54
|
+
viewName: string,
|
|
55
|
+
loadTime: number,
|
|
56
|
+
loadStartEpochMs: number
|
|
57
|
+
): Promise<void>;
|
|
58
|
+
/** Framework integration: Manual = 0, Automatic = 1. */
|
|
59
|
+
startViewWithTrackingType(
|
|
60
|
+
viewName: string,
|
|
61
|
+
property: Object | undefined,
|
|
62
|
+
trackingType: number
|
|
63
|
+
): Promise<void>;
|
|
46
64
|
/**
|
|
47
65
|
* view start.
|
|
48
66
|
* @param viewName page name
|
|
@@ -22,5 +22,17 @@ export interface Spec extends TurboModule {
|
|
|
22
22
|
* @returns trace request header parameters
|
|
23
23
|
*/
|
|
24
24
|
getTraceHeaderFields(url: string, key?: string): Promise<Object>;
|
|
25
|
+
/**
|
|
26
|
+
* Get trace HTTP request headers synchronously for APIs whose construction
|
|
27
|
+
* cannot wait for a Promise, such as React Native WebSocket.
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
getTraceHeaderFieldsSync(url: string, key: string): Object | null;
|
|
31
|
+
/**
|
|
32
|
+
* Discard iOS Trace correlation when WebSocket observation is abandoned
|
|
33
|
+
* before Resource reporting starts. Android uses native collection.
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
cancelWebSocketTrace(key: string): Promise<void>;
|
|
25
37
|
}
|
|
26
38
|
export default TurboModuleRegistry.get<Spec>('FTReactNativeTrace');
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
2
|
+
import type { TurboModule } from 'react-native';
|
|
3
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
4
|
+
|
|
5
|
+
/** Internal iOS handshake reporting bridge; absent on Android and older binaries. */
|
|
6
|
+
export interface Spec extends TurboModule {
|
|
7
|
+
startCapture(session: string): Promise<void>;
|
|
8
|
+
stopCapture(session: string): Promise<void>;
|
|
9
|
+
clear(): Promise<void>;
|
|
10
|
+
startResource(
|
|
11
|
+
key: string,
|
|
12
|
+
socketID: number,
|
|
13
|
+
url: string,
|
|
14
|
+
session: string,
|
|
15
|
+
sequence: number,
|
|
16
|
+
property: Object
|
|
17
|
+
): Promise<void>;
|
|
18
|
+
stopResource(
|
|
19
|
+
key: string,
|
|
20
|
+
event: string,
|
|
21
|
+
session: string,
|
|
22
|
+
property: Object
|
|
23
|
+
): Promise<void>;
|
|
24
|
+
addResource(
|
|
25
|
+
key: string,
|
|
26
|
+
content: Object,
|
|
27
|
+
metrics: Object,
|
|
28
|
+
session: string
|
|
29
|
+
): Promise<void>;
|
|
30
|
+
releaseResource(key: string, session: string): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default TurboModuleRegistry.get<Spec>('FTReactNativeWebSocket');
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
export const version = '0.4.
|
|
2
|
+
export const version = '0.4.3';
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/** Anonymous Visitor ID header configuration for HTTP(S), excluding WebSockets. */
|
|
2
|
+
export interface FTVisitorIdConfig {
|
|
3
|
+
header: string;
|
|
4
|
+
/** Fixed lifetime in hours; defaults to 24. Access does not renew it. */
|
|
5
|
+
ttlHours?: number;
|
|
6
|
+
/** Complete HTTP(S) prefixes constrained to the same scheme, host and port. */
|
|
7
|
+
urlPrefixes?: string[];
|
|
8
|
+
/** Native regular expressions searched against the complete URL; rules use OR. */
|
|
9
|
+
regularExpressions?: string[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// These restrictions are shared by the target iOS and Android native SDKs.
|
|
13
|
+
const reservedHeaders = new Set([
|
|
14
|
+
'accept-charset',
|
|
15
|
+
'accept-encoding',
|
|
16
|
+
'access-control-request-headers',
|
|
17
|
+
'access-control-request-method',
|
|
18
|
+
'connection',
|
|
19
|
+
'content-length',
|
|
20
|
+
'cookie',
|
|
21
|
+
'cookie2',
|
|
22
|
+
'date',
|
|
23
|
+
'dnt',
|
|
24
|
+
'expect',
|
|
25
|
+
'host',
|
|
26
|
+
'keep-alive',
|
|
27
|
+
'origin',
|
|
28
|
+
'permissions-policy',
|
|
29
|
+
'referer',
|
|
30
|
+
'te',
|
|
31
|
+
'trailer',
|
|
32
|
+
'transfer-encoding',
|
|
33
|
+
'upgrade',
|
|
34
|
+
'via',
|
|
35
|
+
'b3',
|
|
36
|
+
'traceparent',
|
|
37
|
+
'tracestate',
|
|
38
|
+
'uber-trace-id',
|
|
39
|
+
'sw8',
|
|
40
|
+
'x-gc-trace-id',
|
|
41
|
+
'x-gc-span-id',
|
|
42
|
+
'x-rum-resource-id',
|
|
43
|
+
]);
|
|
44
|
+
const reservedFragments = [
|
|
45
|
+
'authorization',
|
|
46
|
+
'authentication',
|
|
47
|
+
'api-key',
|
|
48
|
+
'api_key',
|
|
49
|
+
'apikey',
|
|
50
|
+
'auth-token',
|
|
51
|
+
'auth_token',
|
|
52
|
+
'access-token',
|
|
53
|
+
'access_token',
|
|
54
|
+
'session-token',
|
|
55
|
+
'session_token',
|
|
56
|
+
'refresh-token',
|
|
57
|
+
'refresh_token',
|
|
58
|
+
'id-token',
|
|
59
|
+
'id_token',
|
|
60
|
+
'security-token',
|
|
61
|
+
'security_token',
|
|
62
|
+
'csrf',
|
|
63
|
+
'xsrf',
|
|
64
|
+
'jwt',
|
|
65
|
+
'signature',
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
export function validateVisitorIdConfig(config: FTVisitorIdConfig): void {
|
|
69
|
+
if (!config || typeof config !== 'object' || Array.isArray(config)) {
|
|
70
|
+
throw new Error('visitorIdConfig must be an object');
|
|
71
|
+
}
|
|
72
|
+
const {
|
|
73
|
+
header,
|
|
74
|
+
ttlHours = 24,
|
|
75
|
+
urlPrefixes = [],
|
|
76
|
+
regularExpressions = [],
|
|
77
|
+
} = config;
|
|
78
|
+
if (
|
|
79
|
+
typeof header !== 'string' ||
|
|
80
|
+
/[\r\n]/.test(header) ||
|
|
81
|
+
!/^[!#$%&'*+.^_`|~0-9a-z-]+$/.test(header) ||
|
|
82
|
+
reservedHeaders.has(header) ||
|
|
83
|
+
reservedFragments.some((part) => header.includes(part)) ||
|
|
84
|
+
['proxy-', 'sec-', 'x-datadog-', 'x-b3-'].some((prefix) =>
|
|
85
|
+
header.startsWith(prefix)
|
|
86
|
+
)
|
|
87
|
+
) {
|
|
88
|
+
throw new Error(
|
|
89
|
+
'visitorIdConfig.header must be a lowercase custom HTTP header'
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
// Android stores TTL as a signed long number of milliseconds.
|
|
93
|
+
const milliseconds = ttlHours * 3600000;
|
|
94
|
+
if (
|
|
95
|
+
typeof ttlHours !== 'number' ||
|
|
96
|
+
!Number.isFinite(ttlHours) ||
|
|
97
|
+
milliseconds < 1 ||
|
|
98
|
+
milliseconds >= 2 ** 63
|
|
99
|
+
) {
|
|
100
|
+
throw new Error(
|
|
101
|
+
'visitorIdConfig.ttlHours must represent at least 1 millisecond and fit a signed 64-bit integer'
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
if (
|
|
105
|
+
!Array.isArray(urlPrefixes) ||
|
|
106
|
+
!Array.isArray(regularExpressions) ||
|
|
107
|
+
urlPrefixes.length + regularExpressions.length === 0
|
|
108
|
+
) {
|
|
109
|
+
throw new Error('visitorIdConfig requires at least one URL matching rule');
|
|
110
|
+
}
|
|
111
|
+
if (
|
|
112
|
+
urlPrefixes.some(
|
|
113
|
+
(prefix) =>
|
|
114
|
+
typeof prefix !== 'string' ||
|
|
115
|
+
!/^https?:\/\/[^/?#\s]+(?:[/?#]|$)/i.test(prefix)
|
|
116
|
+
) ||
|
|
117
|
+
regularExpressions.some(
|
|
118
|
+
(pattern) => typeof pattern !== 'string' || pattern.length === 0
|
|
119
|
+
)
|
|
120
|
+
) {
|
|
121
|
+
throw new Error('visitorIdConfig contains an invalid URL matching rule');
|
|
122
|
+
}
|
|
123
|
+
}
|