@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","get"],"sources":["NativeFTMobileReactNative.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-types */\nimport type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\n\nexport interface Spec extends TurboModule {\n /**\n * SDK initialization method.\n * @param config SDK initialization configuration items.\n * @returns a Promise.\n */\n sdkConfig(config: Object): Promise<void>;\n /**\n * Dynamically set the Datakit upload URL after SDK initialization.\n * @param datakitUrl Datakit upload URL.\n * @returns a Promise.\n */\n setDatakitURL(datakitUrl: string): Promise<void>;\n /**\n * Dynamically set the Dataway upload URL and client token after SDK initialization.\n * @param datawayUrl Dataway upload URL.\n * @param clientToken Dataway authentication token.\n * @returns a Promise.\n */\n setDatawayURL(datawayUrl: string, clientToken: string): Promise<void>;\n /**\n * Bind user.\n * @param userId user ID.\n * @param userName user name.\n * @param userEmail user email\n * @param extra additional user information\n * @returns a Promise.\n */\n bindRUMUserData(\n userId: string,\n userName?: string,\n userEmail?: string,\n extra?: Object\n ): Promise<void>;\n /**\n * Unbind user.\n * @returns a Promise.\n */\n unbindRUMUserData(): Promise<void>;\n /**\n * Add custom global parameters. Applies to RUM and Log data\n * @param context custom global parameters.\n * @returns a Promise.\n */\n appendGlobalContext(context: Object): Promise<void>;\n /**\n * Add custom RUM global parameters. Applies to RUM data\n * @param context custom RUM global parameters.\n * @returns a Promise.\n */\n appendRUMGlobalContext(context: Object): Promise<void>;\n /**\n * Add custom RUM and Log global parameters. Applies to Log data\n * @param context custom Log global parameters.\n * @returns a Promise.\n */\n appendLogGlobalContext(context: Object): Promise<void>;\n /**\n * Actively synchronize data. When `FTMobileConfig.autoSync=false` is configured, you need to actively trigger this method to synchronize data.\n * @returns a Promise.\n */\n flushSyncData(): Promise<void>;\n\n /**\n * Synchronize events in iOS Widget Extension, iOS only\n * @param groupIdentifier app groupId\n * @returns {groupIdentifier:string,datas:Array<Object>} can be used to view data collected in Extension.\n */\n trackEventFromExtension(identifier: string): Promise<Object>;\n /**\n * Shut down objects currently running in the SDK\n */\n shutDown(): Promise<void>;\n /**\n * Clear all data that has not yet been uploaded to the server.\n */\n clearAllData(): Promise<void>;\n}\nexport default TurboModuleRegistry.get<Spec>('FTMobileReactNative');\n"],"mappings":";;;;;;AAEA,IAAAA,YAAA,GAAAC,OAAA;AAFA;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","get"],"sources":["NativeFTMobileReactNative.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-types */\nimport type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\n\nexport interface Spec extends TurboModule {\n /**\n * SDK initialization method.\n * @param config SDK initialization configuration items.\n * @returns a Promise.\n */\n sdkConfig(config: Object): Promise<void>;\n /**\n * Dynamically set the Datakit upload URL after SDK initialization.\n * @param datakitUrl Datakit upload URL.\n * @returns a Promise.\n */\n setDatakitURL(datakitUrl: string): Promise<void>;\n /**\n * Dynamically set the Dataway upload URL and client token after SDK initialization.\n * @param datawayUrl Dataway upload URL.\n * @param clientToken Dataway authentication token.\n * @returns a Promise.\n */\n setDatawayURL(datawayUrl: string, clientToken: string): Promise<void>;\n /**\n * Bind user.\n * @param userId user ID.\n * @param userName user name.\n * @param userEmail user email\n * @param extra additional user information\n * @returns a Promise.\n */\n bindRUMUserData(\n userId: string,\n userName?: string,\n userEmail?: string,\n extra?: Object\n ): Promise<void>;\n /**\n * Unbind user.\n * @returns a Promise.\n */\n unbindRUMUserData(): Promise<void>;\n resetVisitorId(): Promise<void>;\n /**\n * Add custom global parameters. Applies to RUM and Log data\n * @param context custom global parameters.\n * @returns a Promise.\n */\n appendGlobalContext(context: Object): Promise<void>;\n /**\n * Add custom RUM global parameters. Applies to RUM data\n * @param context custom RUM global parameters.\n * @returns a Promise.\n */\n appendRUMGlobalContext(context: Object): Promise<void>;\n /**\n * Add custom RUM and Log global parameters. Applies to Log data\n * @param context custom Log global parameters.\n * @returns a Promise.\n */\n appendLogGlobalContext(context: Object): Promise<void>;\n /**\n * Actively synchronize data. When `FTMobileConfig.autoSync=false` is configured, you need to actively trigger this method to synchronize data.\n * @returns a Promise.\n */\n flushSyncData(): Promise<void>;\n\n /**\n * Synchronize events in iOS Widget Extension, iOS only\n * @param groupIdentifier app groupId\n * @returns {groupIdentifier:string,datas:Array<Object>} can be used to view data collected in Extension.\n */\n trackEventFromExtension(identifier: string): Promise<Object>;\n /**\n * Shut down objects currently running in the SDK\n */\n shutDown(): Promise<void>;\n /**\n * Clear all data that has not yet been uploaded to the server.\n */\n clearAllData(): Promise<void>;\n /**\n * Update remote configuration using the configured minimum update interval.\n */\n updateRemoteConfig(): Promise<Object>;\n /**\n * Update remote configuration using a custom minimum update interval and\n * optional override rules.\n */\n updateRemoteConfigWithMiniUpdateInterval(\n interval: number,\n rules?: Array<Object>\n ): Promise<Object>;\n /**\n * Required by NativeEventEmitter for remote configuration callbacks.\n */\n addListener(eventName: string): void;\n removeListeners(count: number): void;\n}\nexport default TurboModuleRegistry.get<Spec>('FTMobileReactNative');\n"],"mappings":";;;;;;AAEA,IAAAA,YAAA,GAAAC,OAAA;AAFA;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAoGeC,gCAAmB,CAACC,GAAG,CAAO,qBAAqB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","get"],"sources":["NativeFTReactNativeRUM.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-types */\nimport type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\n\nexport interface Spec extends TurboModule {\n /**\n * Set RUM tracking conditions and enable RUM collection.\n * @param config rum configuration parameters.\n * @returns a Promise.\n */\n setConfig(config: Object): Promise<void>;\n /**\n * Start RUM Action.\n * RUM will bind Resource, Error, LongTask events that may be triggered by this Action.\n * Avoid adding multiple times within 0.1s, only one Action will be associated with the same View at the same time, and new Actions will be discarded if the previous one has not ended.\n * Adding Action with `addAction` method does not affect each other.\n * @param actionName action name\n * @param actionType action type\n * @param property event context (optional)\n * @returns a Promise.\n */\n startAction(\n actionName: string,\n actionType: string,\n property?: Object\n ): Promise<void>;\n /**\n * Add Action event. This type of data cannot be associated with Error, Resource, LongTask data, and has no discard logic.\n * @param actionName action name\n * @param actionType action type\n * @param property event context (optional)\n * @returns a Promise.\n */\n addAction(\n actionName: string,\n actionType: string,\n property?: Object\n ): Promise<void>;\n /**\n * view load duration.\n * @param viewName view name\n * @param loadTime view load duration\n * @returns a Promise.\n */\n onCreateView(viewName: string, loadTime: number): Promise<void>;\n /**\n * view start.\n * @param viewName page name\n * @param property event context (optional)\n * @returns a Promise.\n */\n startView(viewName: string, property?: Object): Promise<void>;\n /**\n * view end.\n * @param property event context (optional)\n * @returns a Promise.\n */\n stopView(property?: Object): Promise<void>;\n /**\n * Exception capture and log collection.\n * @param stack stack log\n * @param message error message\n * @param property event context (optional)\n * @returns a Promise.\n */\n addError(stack: string, message: string, property?: Object): Promise<void>;\n /**\n * Exception capture and log collection.\n * @param type error type\n * @param stack stack log\n * @param message error message\n * @param property event context (optional)\n * @returns a Promise.\n */\n addErrorWithType(\n type: string,\n stack: string,\n message: string,\n property?: Object\n ): Promise<void>;\n /**\n * Start resource request.\n * @param key unique id\n * @param property event context (optional)\n * @returns a Promise.\n */\n startResource(key: string, property?: Object): Promise<void>;\n /**\n * End resource request.\n * @param key unique id\n * @param property event context (optional)\n * @returns a Promise.\n */\n stopResource(key: string, property?: Object): Promise<void>;\n /**\n * Send resource data metrics.\n * @param key unique id\n * @param resource resource data\n * @param metrics resource performance data\n * @returns a Promise.\n */\n addResource(key: string, resource: Object, metrics?: Object): Promise<void>;\n}\nexport default TurboModuleRegistry.get<Spec>('FTReactNativeRUM');\n"],"mappings":";;;;;;AAEA,IAAAA,YAAA,GAAAC,OAAA;AAFA;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","get"],"sources":["NativeFTReactNativeRUM.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-types */\nimport type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\n\nexport interface Spec extends TurboModule {\n /**\n * Set RUM tracking conditions and enable RUM collection.\n * @param config rum configuration parameters.\n * @returns a Promise.\n */\n setConfig(config: Object): Promise<void>;\n /** Internal synchronous snapshot used only by native JS long task reporting. */\n setLongTaskContext(context: Object): boolean;\n /** Stops the internal JavaScript long task monitor before SDK shutdown. */\n stopLongTaskTracking(): Promise<void>;\n /**\n * Start RUM Action.\n * RUM will bind Resource, Error, LongTask events that may be triggered by this Action.\n * Avoid adding multiple times within 0.1s, only one Action will be associated with the same View at the same time, and new Actions will be discarded if the previous one has not ended.\n * Adding Action with `addAction` method does not affect each other.\n * @param actionName action name\n * @param actionType action type\n * @param property event context (optional)\n * @returns a Promise.\n */\n startAction(\n actionName: string,\n actionType: string,\n property?: Object\n ): Promise<void>;\n /**\n * Add Action event. This type of data cannot be associated with Error, Resource, LongTask data, and has no discard logic.\n * @param actionName action name\n * @param actionType action type\n * @param property event context (optional)\n * @returns a Promise.\n */\n addAction(\n actionName: string,\n actionType: string,\n property?: Object\n ): Promise<void>;\n /**\n * view load duration.\n * @param viewName view name\n * @param loadTime monotonic view load duration in nanoseconds\n * @returns a Promise.\n */\n onCreateView(viewName: string, loadTime: number): Promise<void>;\n /** Replace the current View's loading duration; non-negative safe integer nanoseconds. */\n updateViewLoadingTime(duration: number): Promise<void>;\n /** Framework integration: duration in ns; epoch start in ms, converted natively. */\n onCreateViewWithLoadStart(\n viewName: string,\n loadTime: number,\n loadStartEpochMs: number\n ): Promise<void>;\n /** Framework integration: Manual = 0, Automatic = 1. */\n startViewWithTrackingType(\n viewName: string,\n property: Object | undefined,\n trackingType: number\n ): Promise<void>;\n /**\n * view start.\n * @param viewName page name\n * @param property event context (optional)\n * @returns a Promise.\n */\n startView(viewName: string, property?: Object): Promise<void>;\n /**\n * view end.\n * @param property event context (optional)\n * @returns a Promise.\n */\n stopView(property?: Object): Promise<void>;\n /**\n * Exception capture and log collection.\n * @param stack stack log\n * @param message error message\n * @param property event context (optional)\n * @returns a Promise.\n */\n addError(stack: string, message: string, property?: Object): Promise<void>;\n /**\n * Exception capture and log collection.\n * @param type error type\n * @param stack stack log\n * @param message error message\n * @param property event context (optional)\n * @returns a Promise.\n */\n addErrorWithType(\n type: string,\n stack: string,\n message: string,\n property?: Object\n ): Promise<void>;\n /**\n * Start resource request.\n * @param key unique id\n * @param property event context (optional)\n * @returns a Promise.\n */\n startResource(key: string, property?: Object): Promise<void>;\n /**\n * End resource request.\n * @param key unique id\n * @param property event context (optional)\n * @returns a Promise.\n */\n stopResource(key: string, property?: Object): Promise<void>;\n /**\n * Send resource data metrics.\n * @param key unique id\n * @param resource resource data\n * @param metrics resource performance data\n * @returns a Promise.\n */\n addResource(key: string, resource: Object, metrics?: Object): Promise<void>;\n}\nexport default TurboModuleRegistry.get<Spec>('FTReactNativeRUM');\n"],"mappings":";;;;;;AAEA,IAAAA,YAAA,GAAAC,OAAA;AAFA;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAyHeC,gCAAmB,CAACC,GAAG,CAAO,kBAAkB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","get"],"sources":["NativeFTReactNativeTrace.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-types */\nimport type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\n\nexport interface Spec extends TurboModule {\n /**\n * Configure trace to enable distributed tracing.\n * @param config trace configuration parameters.\n * @returns a Promise.\n */\n setConfig(config: Object): Promise<void>;\n /**\n * Get trace HTTP request header data.\n * @param url request URL\n * @returns trace request header parameters\n * @deprecated use getTraceHeaderFields() replace.\n */\n getTraceHeader(key: string, url: string): Promise<Object>;\n /**\n * Get trace HTTP request header data.\n * @param url request URL\n * @returns trace request header parameters\n */\n getTraceHeaderFields(url: string, key?: string): Promise<Object>;\n}\nexport default TurboModuleRegistry.get<Spec>('FTReactNativeTrace');\n"],"mappings":";;;;;;AAEA,IAAAA,YAAA,GAAAC,OAAA;AAFA;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","get"],"sources":["NativeFTReactNativeTrace.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-types */\nimport type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\n\nexport interface Spec extends TurboModule {\n /**\n * Configure trace to enable distributed tracing.\n * @param config trace configuration parameters.\n * @returns a Promise.\n */\n setConfig(config: Object): Promise<void>;\n /**\n * Get trace HTTP request header data.\n * @param url request URL\n * @returns trace request header parameters\n * @deprecated use getTraceHeaderFields() replace.\n */\n getTraceHeader(key: string, url: string): Promise<Object>;\n /**\n * Get trace HTTP request header data.\n * @param url request URL\n * @returns trace request header parameters\n */\n getTraceHeaderFields(url: string, key?: string): Promise<Object>;\n /**\n * Get trace HTTP request headers synchronously for APIs whose construction\n * cannot wait for a Promise, such as React Native WebSocket.\n * @internal\n */\n getTraceHeaderFieldsSync(url: string, key: string): Object | null;\n /**\n * Discard iOS Trace correlation when WebSocket observation is abandoned\n * before Resource reporting starts. Android uses native collection.\n * @internal\n */\n cancelWebSocketTrace(key: string): Promise<void>;\n}\nexport default TurboModuleRegistry.get<Spec>('FTReactNativeTrace');\n"],"mappings":";;;;;;AAEA,IAAAA,YAAA,GAAAC,OAAA;AAFA;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAqCeC,gCAAmB,CAACC,GAAG,CAAO,oBAAoB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
9
|
+
/** Internal iOS handshake reporting bridge; absent on Android and older binaries. */
|
|
10
|
+
var _default = exports.default = _reactNative.TurboModuleRegistry.get('FTReactNativeWebSocket');
|
|
11
|
+
//# sourceMappingURL=NativeFTReactNativeWebSocket.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","get"],"sources":["NativeFTReactNativeWebSocket.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-types */\nimport type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\n\n/** Internal iOS handshake reporting bridge; absent on Android and older binaries. */\nexport interface Spec extends TurboModule {\n startCapture(session: string): Promise<void>;\n stopCapture(session: string): Promise<void>;\n clear(): Promise<void>;\n startResource(\n key: string,\n socketID: number,\n url: string,\n session: string,\n sequence: number,\n property: Object\n ): Promise<void>;\n stopResource(\n key: string,\n event: string,\n session: string,\n property: Object\n ): Promise<void>;\n addResource(\n key: string,\n content: Object,\n metrics: Object,\n session: string\n ): Promise<void>;\n releaseResource(key: string, session: string): Promise<void>;\n}\n\nexport default TurboModuleRegistry.get<Spec>('FTReactNativeWebSocket');\n"],"mappings":";;;;;;AAEA,IAAAA,YAAA,GAAAC,OAAA;AAFA;AAIA;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GA4BeC,gCAAmB,CAACC,GAAG,CAAO,wBAAwB,CAAC","ignoreList":[]}
|
package/lib/commonjs/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["version","exports"],"sources":["version.ts"],"sourcesContent":["// generated by genversion\nexport const version = '0.4.
|
|
1
|
+
{"version":3,"names":["version","exports"],"sources":["version.ts"],"sourcesContent":["// generated by genversion\nexport const version = '0.4.3';\n"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAAC,OAAA,CAAAD,OAAA,GAAG,OAAO","ignoreList":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.validateVisitorIdConfig = validateVisitorIdConfig;
|
|
7
|
+
/** Anonymous Visitor ID header configuration for HTTP(S), excluding WebSockets. */
|
|
8
|
+
|
|
9
|
+
// These restrictions are shared by the target iOS and Android native SDKs.
|
|
10
|
+
const reservedHeaders = new Set(['accept-charset', 'accept-encoding', 'access-control-request-headers', 'access-control-request-method', 'connection', 'content-length', 'cookie', 'cookie2', 'date', 'dnt', 'expect', 'host', 'keep-alive', 'origin', 'permissions-policy', 'referer', 'te', 'trailer', 'transfer-encoding', 'upgrade', 'via', 'b3', 'traceparent', 'tracestate', 'uber-trace-id', 'sw8', 'x-gc-trace-id', 'x-gc-span-id', 'x-rum-resource-id']);
|
|
11
|
+
const reservedFragments = ['authorization', 'authentication', 'api-key', 'api_key', 'apikey', 'auth-token', 'auth_token', 'access-token', 'access_token', 'session-token', 'session_token', 'refresh-token', 'refresh_token', 'id-token', 'id_token', 'security-token', 'security_token', 'csrf', 'xsrf', 'jwt', 'signature'];
|
|
12
|
+
function validateVisitorIdConfig(config) {
|
|
13
|
+
if (!config || typeof config !== 'object' || Array.isArray(config)) {
|
|
14
|
+
throw new Error('visitorIdConfig must be an object');
|
|
15
|
+
}
|
|
16
|
+
const {
|
|
17
|
+
header,
|
|
18
|
+
ttlHours = 24,
|
|
19
|
+
urlPrefixes = [],
|
|
20
|
+
regularExpressions = []
|
|
21
|
+
} = config;
|
|
22
|
+
if (typeof header !== 'string' || /[\r\n]/.test(header) || !/^[!#$%&'*+.^_`|~0-9a-z-]+$/.test(header) || reservedHeaders.has(header) || reservedFragments.some(part => header.includes(part)) || ['proxy-', 'sec-', 'x-datadog-', 'x-b3-'].some(prefix => header.startsWith(prefix))) {
|
|
23
|
+
throw new Error('visitorIdConfig.header must be a lowercase custom HTTP header');
|
|
24
|
+
}
|
|
25
|
+
// Android stores TTL as a signed long number of milliseconds.
|
|
26
|
+
const milliseconds = ttlHours * 3600000;
|
|
27
|
+
if (typeof ttlHours !== 'number' || !Number.isFinite(ttlHours) || milliseconds < 1 || milliseconds >= 2 ** 63) {
|
|
28
|
+
throw new Error('visitorIdConfig.ttlHours must represent at least 1 millisecond and fit a signed 64-bit integer');
|
|
29
|
+
}
|
|
30
|
+
if (!Array.isArray(urlPrefixes) || !Array.isArray(regularExpressions) || urlPrefixes.length + regularExpressions.length === 0) {
|
|
31
|
+
throw new Error('visitorIdConfig requires at least one URL matching rule');
|
|
32
|
+
}
|
|
33
|
+
if (urlPrefixes.some(prefix => typeof prefix !== 'string' || !/^https?:\/\/[^/?#\s]+(?:[/?#]|$)/i.test(prefix)) || regularExpressions.some(pattern => typeof pattern !== 'string' || pattern.length === 0)) {
|
|
34
|
+
throw new Error('visitorIdConfig contains an invalid URL matching rule');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=visitorIdConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["reservedHeaders","Set","reservedFragments","validateVisitorIdConfig","config","Array","isArray","Error","header","ttlHours","urlPrefixes","regularExpressions","test","has","some","part","includes","prefix","startsWith","milliseconds","Number","isFinite","length","pattern"],"sources":["visitorIdConfig.ts"],"sourcesContent":["/** Anonymous Visitor ID header configuration for HTTP(S), excluding WebSockets. */\nexport interface FTVisitorIdConfig {\n header: string;\n /** Fixed lifetime in hours; defaults to 24. Access does not renew it. */\n ttlHours?: number;\n /** Complete HTTP(S) prefixes constrained to the same scheme, host and port. */\n urlPrefixes?: string[];\n /** Native regular expressions searched against the complete URL; rules use OR. */\n regularExpressions?: string[];\n}\n\n// These restrictions are shared by the target iOS and Android native SDKs.\nconst reservedHeaders = new Set([\n 'accept-charset',\n 'accept-encoding',\n 'access-control-request-headers',\n 'access-control-request-method',\n 'connection',\n 'content-length',\n 'cookie',\n 'cookie2',\n 'date',\n 'dnt',\n 'expect',\n 'host',\n 'keep-alive',\n 'origin',\n 'permissions-policy',\n 'referer',\n 'te',\n 'trailer',\n 'transfer-encoding',\n 'upgrade',\n 'via',\n 'b3',\n 'traceparent',\n 'tracestate',\n 'uber-trace-id',\n 'sw8',\n 'x-gc-trace-id',\n 'x-gc-span-id',\n 'x-rum-resource-id',\n]);\nconst reservedFragments = [\n 'authorization',\n 'authentication',\n 'api-key',\n 'api_key',\n 'apikey',\n 'auth-token',\n 'auth_token',\n 'access-token',\n 'access_token',\n 'session-token',\n 'session_token',\n 'refresh-token',\n 'refresh_token',\n 'id-token',\n 'id_token',\n 'security-token',\n 'security_token',\n 'csrf',\n 'xsrf',\n 'jwt',\n 'signature',\n];\n\nexport function validateVisitorIdConfig(config: FTVisitorIdConfig): void {\n if (!config || typeof config !== 'object' || Array.isArray(config)) {\n throw new Error('visitorIdConfig must be an object');\n }\n const {\n header,\n ttlHours = 24,\n urlPrefixes = [],\n regularExpressions = [],\n } = config;\n if (\n typeof header !== 'string' ||\n /[\\r\\n]/.test(header) ||\n !/^[!#$%&'*+.^_`|~0-9a-z-]+$/.test(header) ||\n reservedHeaders.has(header) ||\n reservedFragments.some((part) => header.includes(part)) ||\n ['proxy-', 'sec-', 'x-datadog-', 'x-b3-'].some((prefix) =>\n header.startsWith(prefix)\n )\n ) {\n throw new Error(\n 'visitorIdConfig.header must be a lowercase custom HTTP header'\n );\n }\n // Android stores TTL as a signed long number of milliseconds.\n const milliseconds = ttlHours * 3600000;\n if (\n typeof ttlHours !== 'number' ||\n !Number.isFinite(ttlHours) ||\n milliseconds < 1 ||\n milliseconds >= 2 ** 63\n ) {\n throw new Error(\n 'visitorIdConfig.ttlHours must represent at least 1 millisecond and fit a signed 64-bit integer'\n );\n }\n if (\n !Array.isArray(urlPrefixes) ||\n !Array.isArray(regularExpressions) ||\n urlPrefixes.length + regularExpressions.length === 0\n ) {\n throw new Error('visitorIdConfig requires at least one URL matching rule');\n }\n if (\n urlPrefixes.some(\n (prefix) =>\n typeof prefix !== 'string' ||\n !/^https?:\\/\\/[^/?#\\s]+(?:[/?#]|$)/i.test(prefix)\n ) ||\n regularExpressions.some(\n (pattern) => typeof pattern !== 'string' || pattern.length === 0\n )\n ) {\n throw new Error('visitorIdConfig contains an invalid URL matching rule');\n }\n}\n"],"mappings":";;;;;;AAAA;;AAWA;AACA,MAA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ACQ,QAAQ,CAACD,IAAI,CAAC,CAAC,IACvD,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,CAAC,CAACD,IAAI,CAAEG,MAAM,IACpDT,MAAM,CAACU,UAAU,CAACD,MAAM,CAC1B,CAAC,EACD;IACA,MAAM,IAAIV,KAAK,CACb,+DACF,CAAC;EACH;EACA;EACA,MAAMY,YAAY,GAAGV,QAAQ,GAAG,OAAO;EACvC,IACE,OAAOA,QAAQ,KAAK,QAAQ,IAC5B,CAACW,MAAM,CAACC,QAAQ,CAACZ,QAAQ,CAAC,IAC1BU,YAAY,GAAG,CAAC,IAChBA,YAAY,IAAI,CAAC,IAAI,EAAE,EACvB;IACA,MAAM,IAAIZ,KAAK,CACb,gGACF,CAAC;EACH;EACA,IACE,CAACF,KAAK,CAACC,OAAO,CAACI,WAAW,CAAC,IAC3B,CAACL,KAAK,CAACC,OAAO,CAACK,kBAAkB,CAAC,IAClCD,WAAW,CAACY,MAAM,GAAGX,kBAAkB,CAACW,MAAM,KAAK,CAAC,EACpD;IACA,MAAM,IAAIf,KAAK,CAAC,yDAAyD,CAAC;EAC5E;EACA,IACEG,WAAW,CAACI,IAAI,CACbG,MAAM,IACL,OAAOA,MAAM,KAAK,QAAQ,IAC1B,CAAC,mCAAmC,CAACL,IAAI,CAACK,MAAM,CACpD,CAAC,IACDN,kBAAkB,CAACG,IAAI,CACpBS,OAAO,IAAK,OAAOA,OAAO,KAAK,QAAQ,IAAIA,OAAO,CAACD,MAAM,KAAK,CACjE,CAAC,EACD;IACA,MAAM,IAAIf,KAAK,CAAC,uDAAuD,CAAC;EAC1E;AACF","ignoreList":[]}
|
package/lib/module/ft_logger.js
CHANGED
|
@@ -23,8 +23,10 @@ export let FTLogCacheDiscard = /*#__PURE__*/function (FTLogCacheDiscard) {
|
|
|
23
23
|
}({});
|
|
24
24
|
/**
|
|
25
25
|
* Configure log output configuration.
|
|
26
|
-
* @param
|
|
26
|
+
* @param logSamplingRate Log sampling percentage in [0, 100], default 100. Supports fractional percentages and takes precedence over sampleRate.
|
|
27
|
+
* @param sampleRate Deprecated log sampling probability in [0, 1], default 1. Used only when logSamplingRate is omitted; multiplied by 100 before passing to Native.
|
|
27
28
|
* @param enableLinkRumData whether to link with RUM
|
|
29
|
+
* @param enableWebViewLog Collect Browser Logs SDK events from WebViews, default false
|
|
28
30
|
* @param enableCustomLog whether to enable custom logs
|
|
29
31
|
* @param discardStrategy log discard strategy
|
|
30
32
|
* @param logLevelFilters log level filter
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["bridgeContextManager","FTLogStatus","FTLogCacheDiscard","FTReactNativeLogWrapper","constructor","_defineProperty","require","default","logConfig","config","logger","logging","content","logStatus","property","mergedProperties","mergeWithLocalPropertiesSync","logWithStatusString","toString","enumLogStatus","FTReactNativeLog"],"sources":["ft_logger.tsx"],"sourcesContent":["import { bridgeContextManager } from './ft_mobile_agent';\n/**\n * Set log level.\n */\nexport enum FTLogStatus {\n info,\n warning,\n error,\n critical,\n ok,\n}\n/**\n * Log discard method.\n */\nexport enum FTLogCacheDiscard {\n discard,\n discardOldest,\n}\n/**\n * Configure log output configuration.\n * @param sampleRate sampling
|
|
1
|
+
{"version":3,"names":["bridgeContextManager","FTLogStatus","FTLogCacheDiscard","FTReactNativeLogWrapper","constructor","_defineProperty","require","default","logConfig","config","logger","logging","content","logStatus","property","mergedProperties","mergeWithLocalPropertiesSync","logWithStatusString","toString","enumLogStatus","FTReactNativeLog"],"sources":["ft_logger.tsx"],"sourcesContent":["import { bridgeContextManager } from './ft_mobile_agent';\n/**\n * Set log level.\n */\nexport enum FTLogStatus {\n info,\n warning,\n error,\n critical,\n ok,\n}\n/**\n * Log discard method.\n */\nexport enum FTLogCacheDiscard {\n discard,\n discardOldest,\n}\n/**\n * Configure log output configuration.\n * @param logSamplingRate Log sampling percentage in [0, 100], default 100. Supports fractional percentages and takes precedence over sampleRate.\n * @param sampleRate Deprecated log sampling probability in [0, 1], default 1. Used only when logSamplingRate is omitted; multiplied by 100 before passing to Native.\n * @param enableLinkRumData whether to link with RUM\n * @param enableWebViewLog Collect Browser Logs SDK events from WebViews, default false\n * @param enableCustomLog whether to enable custom logs\n * @param discardStrategy log discard strategy\n * @param logLevelFilters log level filter\n * @param globalContext custom global parameters\n * @param logCacheLimitCount get maximum log entry count limit [1000,), default 5000\n */\nexport interface FTLogConfig {\n /**\n * Log sampling percentage in [0, 100], default 100.\n * Supports fractional percentages: 12.5 means 12.5%, not 0.125.\n * Takes precedence over sampleRate when both are supplied, including 0.\n */\n logSamplingRate?: number;\n /** @deprecated Use logSamplingRate. Probability in [0, 1], default 1; 0.125 maps to 12.5%. Ignored when logSamplingRate is supplied. */\n sampleRate?: number;\n enableLinkRumData?: boolean;\n enableCustomLog?: boolean;\n enableWebViewLog?: boolean;\n discardStrategy?: FTLogCacheDiscard;\n logLevelFilters?: Array<FTLogStatus>;\n globalContext?: object;\n logCacheLimitCount?: number;\n}\n\ntype FTReactNativeLogType = {\n /**\n *Configure log output configuration to enable log collection.\n */\n logConfig(config: FTLogConfig): Promise<void>;\n /**\n * Output log.\n * @param content log content\n * @param status log status\n * @param property log context (optional)\n */\n logging(\n content: string,\n logStatus: FTLogStatus,\n property?: object\n ): Promise<void>;\n /**\n * Output log.\n * @param content log content\n * @param status log status\n * @param property log context (optional)\n */\n logWithStatusString(\n content: string,\n logStatus: string,\n property?: object\n ): Promise<void>;\n};\n\nclass FTReactNativeLogWrapper {\n /* eslint-disable @typescript-eslint/no-var-requires */\n private logger: FTReactNativeLogType =\n require('./specs/NativeFTReactNativeLog').default;\n /* eslint-enable @typescript-eslint/no-var-requires */\n\n /**\n *Configure log output configuration to enable log collection.\n */\n logConfig(config: FTLogConfig): Promise<void> {\n return this.logger.logConfig(config);\n }\n\n /**\n * Output log.\n * @param content log content\n * @param status log status\n * @param property log context (optional)\n */\n logging(\n content: string,\n logStatus: FTLogStatus | string,\n property?: object\n ): Promise<void> {\n // Automatically merge bridge context properties with local properties\n const mergedProperties =\n bridgeContextManager.mergeWithLocalPropertiesSync(property);\n\n if (typeof logStatus === 'string') {\n return this.logger.logWithStatusString(\n content,\n logStatus.toString(),\n mergedProperties\n );\n }\n let enumLogStatus: FTLogStatus = logStatus as FTLogStatus;\n return this.logger.logging(content, enumLogStatus, mergedProperties);\n }\n}\nexport const FTReactNativeLog: FTReactNativeLogWrapper =\n new FTReactNativeLogWrapper();\n"],"mappings":";;;AAAA,SAASA,oBAAoB,QAAQ,mBAAmB;AACxD;AACA;AACA;AACA,WAAYC,WAAW,0BAAXA,WAAW;EAAXA,WAAW,CAAXA,WAAW;EAAXA,WAAW,CAAXA,WAAW;EAAXA,WAAW,CAAXA,WAAW;EAAXA,WAAW,CAAXA,WAAW;EAAXA,WAAW,CAAXA,WAAW;EAAA,OAAXA,WAAW;AAAA;AAOvB;AACA;AACA;AACA,WAAYC,iBAAiB,0BAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA;AAI7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgDA,MAAMC,uBAAuB,CAAC;EAAAC,YAAA;IAC5B;IAAAC,eAAA,iBAEEC,OAAO,CAAC,gCAAgC,CAAC,CAACC,OAAO;EAAA;EACnD;;EAEA;AACF;AACA;EACEC,SAASA,CAACC,MAAmB,EAAiB;IAC5C,OAAO,IAAI,CAACC,MAAM,CAACF,SAAS,CAACC,MAAM,CAAC;EACtC;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEE,OAAOA,CACLC,OAAe,EACfC,SAA+B,EAC/BC,QAAiB,EACF;IACf;IACA,MAAMC,gBAAgB,GACpBf,oBAAoB,CAACgB,4BAA4B,CAACF,QAAQ,CAAC;IAE7D,IAAI,OAAOD,SAAS,KAAK,QAAQ,EAAE;MACjC,OAAO,IAAI,CAACH,MAAM,CAACO,mBAAmB,CACpCL,OAAO,EACPC,SAAS,CAACK,QAAQ,CAAC,CAAC,EACpBH,gBACF,CAAC;IACH;IACA,IAAII,aAA0B,GAAGN,SAAwB;IACzD,OAAO,IAAI,CAACH,MAAM,CAACC,OAAO,CAACC,OAAO,EAAEO,aAAa,EAAEJ,gBAAgB,CAAC;EACtE;AACF;AACA,OAAO,MAAMK,gBAAyC,GACpD,IAAIjB,uBAAuB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -4,6 +4,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
4
4
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
5
5
|
import { NativeEventEmitter, NativeModules } from 'react-native';
|
|
6
6
|
import { version as sdkVersion } from './version';
|
|
7
|
+
import { FTRumWebSocketTracking } from './rum/FTRumWebSocketTracking';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Bridge context manager for managing shared properties across RUM and Logger modules
|
|
@@ -13,6 +14,7 @@ import { version as sdkVersion } from './version';
|
|
|
13
14
|
class BridgeContextManager {
|
|
14
15
|
constructor() {
|
|
15
16
|
_defineProperty(this, "properties", new Map());
|
|
17
|
+
_defineProperty(this, "longTaskContextEnabled", false);
|
|
16
18
|
// Initialize with SDK version information
|
|
17
19
|
this.initializeSDKInfo();
|
|
18
20
|
}
|
|
@@ -53,10 +55,32 @@ class BridgeContextManager {
|
|
|
53
55
|
Object.entries(properties).forEach(([key, value]) => {
|
|
54
56
|
this.properties.set(key, value);
|
|
55
57
|
});
|
|
58
|
+
if (this.longTaskContextEnabled) {
|
|
59
|
+
this.syncLongTaskContext();
|
|
60
|
+
}
|
|
56
61
|
} catch (error) {
|
|
57
62
|
console.warn('Failed to append bridge context:', error);
|
|
58
63
|
}
|
|
59
64
|
}
|
|
65
|
+
configureLongTaskContext(enabled) {
|
|
66
|
+
this.longTaskContextEnabled = enabled;
|
|
67
|
+
if (enabled) {
|
|
68
|
+
this.syncLongTaskContext();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
syncLongTaskContext() {
|
|
72
|
+
try {
|
|
73
|
+
// Apply the snapshot before JS can block. An async native call may run after
|
|
74
|
+
// the frame that detects the long task and attach stale context to it.
|
|
75
|
+
const rum =
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
77
|
+
require('./specs/NativeFTReactNativeRUM').default;
|
|
78
|
+
rum.setLongTaskContext(this.mergeWithLocalPropertiesSync());
|
|
79
|
+
} catch (error) {
|
|
80
|
+
// Context synchronization must not make a destroyed/older bridge crash the host.
|
|
81
|
+
console.warn('Failed to sync JS long task bridge context:', error);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
60
84
|
|
|
61
85
|
/**
|
|
62
86
|
* Merge bridge context properties with local properties
|
|
@@ -124,6 +148,8 @@ export let FTDBCacheDiscard = /*#__PURE__*/function (FTDBCacheDiscard) {
|
|
|
124
148
|
/**
|
|
125
149
|
* Values that can be modified by remote config override rules.
|
|
126
150
|
* These values will adjust the fetched remote configuration before it is applied.
|
|
151
|
+
* Omitted fields are not changed by this rule. Sampling percentages use [0, 100]
|
|
152
|
+
* and support fractions (12.5 means 12.5%); legacy probabilities use [0, 1].
|
|
127
153
|
*/
|
|
128
154
|
|
|
129
155
|
/**
|
|
@@ -175,6 +201,7 @@ class FTMobileReactNativeWrapper {
|
|
|
175
201
|
constructor() {
|
|
176
202
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
177
203
|
_defineProperty(this, "sdk", require('./specs/NativeFTMobileReactNative').default);
|
|
204
|
+
_defineProperty(this, "rum", require('./specs/NativeFTReactNativeRUM').default);
|
|
178
205
|
/* eslint-enable @typescript-eslint/no-var-requires */
|
|
179
206
|
_defineProperty(this, "emitter", null);
|
|
180
207
|
}
|
|
@@ -191,7 +218,14 @@ class FTMobileReactNativeWrapper {
|
|
|
191
218
|
if (config.serverUrl != null && config.serverUrl.length > 0 && config.datakitUrl == null) {
|
|
192
219
|
config.datakitUrl = config.serverUrl;
|
|
193
220
|
}
|
|
194
|
-
|
|
221
|
+
const nativeConfig = {
|
|
222
|
+
...config
|
|
223
|
+
};
|
|
224
|
+
// Keep undefined equivalent to omission; explicit null overrides legacy hosts.
|
|
225
|
+
if (nativeConfig.allowWebViewHost === undefined) {
|
|
226
|
+
delete nativeConfig.allowWebViewHost;
|
|
227
|
+
}
|
|
228
|
+
return this.sdk.sdkConfig(nativeConfig);
|
|
195
229
|
}
|
|
196
230
|
setDatakitURL(datakitUrl) {
|
|
197
231
|
return this.sdk.setDatakitURL(datakitUrl);
|
|
@@ -202,6 +236,9 @@ class FTMobileReactNativeWrapper {
|
|
|
202
236
|
bindRUMUserData(userId, userName, userEmail, extra) {
|
|
203
237
|
return this.sdk.bindRUMUserData(userId, userName, userEmail, extra);
|
|
204
238
|
}
|
|
239
|
+
resetVisitorId() {
|
|
240
|
+
return this.sdk.resetVisitorId();
|
|
241
|
+
}
|
|
205
242
|
unbindRUMUserData() {
|
|
206
243
|
return this.sdk.unbindRUMUserData();
|
|
207
244
|
}
|
|
@@ -220,14 +257,20 @@ class FTMobileReactNativeWrapper {
|
|
|
220
257
|
flushSyncData() {
|
|
221
258
|
return this.sdk.flushSyncData();
|
|
222
259
|
}
|
|
223
|
-
shutDown() {
|
|
224
|
-
|
|
260
|
+
async shutDown() {
|
|
261
|
+
bridgeContextManager.configureLongTaskContext(false);
|
|
262
|
+
try {
|
|
263
|
+
FTRumWebSocketTracking.shutDown();
|
|
264
|
+
await this.rum.stopLongTaskTracking();
|
|
265
|
+
} finally {
|
|
266
|
+
await this.sdk.shutDown();
|
|
267
|
+
}
|
|
225
268
|
}
|
|
226
269
|
clearAllData() {
|
|
227
270
|
return this.sdk.clearAllData();
|
|
228
271
|
}
|
|
229
272
|
appendBridgeContext(properties) {
|
|
230
|
-
//
|
|
273
|
+
// Store properties in JS and update the native long task snapshot when enabled.
|
|
231
274
|
bridgeContextManager.appendBridgeContext(properties);
|
|
232
275
|
}
|
|
233
276
|
updateRemoteConfig() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeEventEmitter","NativeModules","version","sdkVersion","BridgeContextManager","constructor","_defineProperty","Map","initializeSDKInfo","sdkBridgeInfo","react_native","properties","set","JSON","stringify","getInstance","instance","appendBridgeContext","Object","entries","forEach","key","value","error","console","warn","mergeWithLocalPropertiesSync","localProperties","merged","assign","_BridgeContextManager","bridgeContextManager","EnvType","FTDBCacheDiscard","FTMobileReactNativeWrapper","require","default","getEmitter","_NativeModules$FTMobi","emitter","nativeEventModule","FTMobileReactNative","sdk","sdkConfig","config","serverUrl","length","datakitUrl","setDatakitURL","setDatawayURL","datawayUrl","clientToken","bindRUMUserData","userId","userName","userEmail","extra","unbindRUMUserData","appendGlobalContext","context","appendLogGlobalContext","appendRUMGlobalContext","trackEventFromExtension","identifier","flushSyncData","shutDown","clearAllData","updateRemoteConfig","updateRemoteConfigWithMiniUpdateInterval","interval","rules","addRemoteConfigListener","listener","addListener"],"sources":["ft_mobile_agent.tsx"],"sourcesContent":["import {\n EmitterSubscription,\n NativeEventEmitter,\n NativeModules,\n} from 'react-native';\nimport { version as sdkVersion } from './version';\n\n/**\n * Bridge context manager for managing shared properties across RUM and Logger modules\n * This class provides a centralized way to store and retrieve global properties that will be\n * automatically merged with local properties when making calls to RUM and Logger functions\n */\nclass BridgeContextManager {\n private static instance: BridgeContextManager;\n private properties: Map<string, any> = new Map();\n\n private constructor() {\n // Initialize with SDK version information\n this.initializeSDKInfo();\n }\n\n /**\n * Initialize SDK information properties\n * @private\n */\n private initializeSDKInfo(): void {\n // Create sdk_bridge_info with version information\n const sdkBridgeInfo = {\n react_native: sdkVersion,\n };\n\n // Set the sdk_bridge_info property\n this.properties.set('sdk_bridge_info', JSON.stringify(sdkBridgeInfo));\n }\n\n /**\n * Get singleton instance of BridgeContextManager\n * @returns BridgeContextManager instance\n */\n public static getInstance(): BridgeContextManager {\n if (!BridgeContextManager.instance) {\n BridgeContextManager.instance = new BridgeContextManager();\n }\n return BridgeContextManager.instance;\n }\n\n /**\n * Add bridge context properties that will be automatically merged with local properties\n * @param properties Object containing key-value pairs\n */\n public appendBridgeContext(properties: Record<string, any>): void {\n // Store properties locally in JavaScript\n try {\n // Store properties locally in JavaScript\n Object.entries(properties).forEach(([key, value]) => {\n this.properties.set(key, value);\n });\n } catch (error) {\n console.warn('Failed to append bridge context:', error);\n }\n }\n\n /**\n * Merge bridge context properties with local properties\n * Bridge context properties take precedence over local properties\n * @param localProperties Local properties to merge with bridge context properties\n * @returns Merged properties object\n */\n public mergeWithLocalPropertiesSync(\n localProperties?: object\n ): Record<string, any> {\n try {\n const merged: Record<string, any> = {};\n\n // First add local properties (if any)\n if (localProperties) {\n Object.assign(merged, localProperties);\n }\n\n // Then add bridge context properties (these will override local properties with same keys)\n this.properties.forEach((value, key) => {\n merged[key] = value;\n });\n\n return merged;\n } catch (error) {\n console.warn(\n 'Failed to merge bridge context with local properties:',\n error\n );\n // Return empty object or only local properties on error\n return localProperties ? { ...localProperties } : {};\n }\n }\n}\n\n// Internal bridge context manager - not exported\nexport const bridgeContextManager = BridgeContextManager.getInstance();\n\n/**\n * Environment.\n */\nexport enum EnvType {\n prod,\n gray,\n pre,\n common,\n local,\n}\nexport enum FTDBCacheDiscard {\n discard,\n discardOldest,\n}\n\n/**\n * Remote config override rule matching condition for custom keys. Supports exact match and contains match.\n * For exact match, set the value directly, for example: \"userid\": \"test_user\", which means the rule will be applied when the custom key \"userid\" is exactly \"test_user\".\n * For contains match, set the value as an object with a \"contains\" field, for example: \"userid\": { \"contains\": \"test_user\" }, which means the rule will be applied when the custom key \"userid\" contains the object \"test_user\".\n */\nexport type FTRemoteConfigCustomKeyContainsMatch = {\n contains: string | number | boolean;\n};\n\n/**\n * Matching rules for remote config override\n * Defines matching conditions using customKeys\n */\nexport type FTRemoteConfigOverrideMatch = {\n customKeys?: Record<\n string,\n string | number | boolean | FTRemoteConfigCustomKeyContainsMatch\n >;\n};\n\n/**\n * Values that can be modified by remote config override rules.\n * These values will adjust the fetched remote configuration before it is applied.\n */\nexport type FTRemoteConfigOverrideValues = {\n env?: string;\n serviceName?: string;\n autoSync?: boolean;\n compressIntakeRequests?: boolean;\n syncPageSize?: number;\n syncSleepTime?: number;\n rumSampleRate?: number;\n rumSessionOnErrorSampleRate?: number;\n rumEnableTraceUserAction?: boolean;\n rumEnableTraceUserView?: boolean;\n rumEnableTraceUserResource?: boolean;\n rumEnableResourceHostIP?: boolean;\n rumEnableTrackAppUIBlock?: boolean;\n rumBlockDurationMs?: number;\n rumEnableTrackAppCrash?: boolean;\n rumEnableTrackAppANR?: boolean;\n rumEnableTraceWebView?: boolean;\n rumAllowWebViewHost?: Array<string>;\n traceSampleRate?: number;\n traceEnableAutoTrace?: boolean;\n traceType?: string;\n logSampleRate?: number;\n logLevelFilters?: Array<string>;\n logEnableCustomLog?: boolean;\n logEnableConsoleLog?: boolean;\n};\n\n/**\n * Remote config override rules .\n * Adjust the fetched remote configuration before application.\n */\nexport type FTRemoteConfigOverrideRule = {\n id?: string;\n enabled?: boolean;\n match: FTRemoteConfigOverrideMatch;\n override: FTRemoteConfigOverrideValues;\n};\n/**\n * Final result of the remote config update\n * @param triggerType the type of remote config update trigger, auto or manual\n * @param success whether the remote config update was successful\n * @param platform the platform of the device, ios or android\n * @param timestamp the timestamp when the remote config update was triggered\n * @param rawJson the final remote config update result, in JSON string format\n * @param errorCode the error code if the remote config update failed, may be null if the update was successful\n * @param errorMessage the error message if the remote config update failed, may be null if the update was successful\n * @param appliedOverrideRuleIds the list of override rule IDs applied in this remote config update, may be null if no rules were applied\n */\nexport type FTRemoteConfigResult = {\n triggerType: 'auto' | 'manual';\n success: boolean;\n platform: 'ios' | 'android';\n timestamp: number;\n rawJson?: string;\n errorCode?: string | number;\n errorMessage?: string;\n appliedOverrideRuleIds?: string[];\n};\n/**\n * Configure SDK startup parameters.\n * @param serverUrl data reporting address, deprecated, use [datakitUrl] instead\n * @param datakitUrl datakit access URL address, example: http://10.0.0.1:9529, default port 9529. Choose one between datakit and dataway configuration\n * @param datawayUrl dataway access URL address, example: http://10.0.0.1:9528, default port 9528, note: the device installing the SDK needs to be able to access this address. Note: choose one between datakit and dataway configuration\n * @param clientToken dataway authentication token, needs to be configured together with [datawayUrl]\n * @param debug set whether to allow log printing, default false\n * @param env environment, default prod\n * @param service set the name of the business or service it belongs to, default: `df_rum_ios`, `df_rum_android`\n * @param autoSync whether data is automatically synchronized and uploaded, default: true\n * @param syncPageSize number of synchronized items per request during data synchronization, minimum value 5, default: 10\n * @param syncSleepTime interval time between each request during data synchronization, unit milliseconds, 0 < syncSleepTime < 100\n * @param enableDataIntegerCompatible whether to enable data integer compatibility during data synchronization, enabled by default\n * @param compressIntakeRequests whether to compress synchronized data\n * @param enableDataFilter whether to enable SDK-side local data filters, enabled by default\n * @param dataFilters local blocklist filter rules. Supported categories include `logging` and `rum`. Any data that matches a rule will be discarded.\n * @param globalContext custom global parameters\n * @param groupIdentifiers iOS side sets the AppGroups Identifier array corresponding to the collected Widget Extension\n * @param enableLimitWithDbSize set whether to enable using db to limit data size, after enabling, `FTLogConfig.logCacheLimitCount` and `FTRUMConfig.rumCacheLimitCount` will no longer take effect\n * @param dbCacheLimit db cache limit size, minimum value 30MB, default 100MB, unit byte\n * @param dbDiscardStrategy db data discard strategy\n * @param dataModifier data modifier, modify individual fields {key:value}, after setting, the SDK will replace the original value with the set value according to the key\n * @param lineDataModifier data modifier, modify single data {\"measurement\":measurement,\"data\":{key:value}}, after setting, the SDK will replace the original value with the set value according to the key\n * @param remoteConfiguration Set whether to enable remote dynamic configuration\n * @param remoteConfigMiniUpdateInterval Set remote dynamic configuration minimum update interval, unit seconds, default 12*60*60\n * @param remoteConfigOverrideRules Remote config override rules .Adjust the fetched remote configuration before application.\n */\nexport interface FTMobileConfig {\n /**\n * @deprecated \"serverUrl\" parameter renamed to \"datakitUrl\"\n */\n serverUrl?: string;\n datakitUrl?: string;\n datawayUrl?: string;\n clientToken?: string;\n debug?: boolean;\n envType?: EnvType;\n env?: string;\n service?: string;\n autoSync?: boolean;\n syncPageSize?: number;\n syncSleepTime?: number;\n enableDataIntegerCompatible?: boolean;\n compressIntakeRequests?: boolean;\n enableDataFilter?: boolean;\n dataFilters?: Record<string, Array<string>>;\n globalContext?: object;\n groupIdentifiers?: Array<string>;\n enableLimitWithDbSize?: boolean;\n dbCacheLimit?: number;\n dbDiscardStrategy?: FTDBCacheDiscard;\n dataModifier?: object;\n lineDataModifier?: object;\n remoteConfiguration?: boolean;\n remoteConfigMiniUpdateInterval?: number;\n remoteConfigOverrideRules?: Array<FTRemoteConfigOverrideRule>;\n}\n\ntype FTMobileReactNativeType = {\n /**\n * SDK initialization method.\n * @param config SDK initialization configuration items.\n * @returns a Promise.\n */\n sdkConfig(config: FTMobileConfig): Promise<void>;\n /**\n * Dynamically set the Datakit upload URL after SDK initialization.\n * @param datakitUrl Datakit upload URL.\n * @returns a Promise.\n */\n setDatakitURL(datakitUrl: string): Promise<void>;\n /**\n * Dynamically set the Dataway upload URL and client token after SDK initialization.\n * @param datawayUrl Dataway upload URL.\n * @param clientToken Dataway authentication token.\n * @returns a Promise.\n */\n setDatawayURL(datawayUrl: string, clientToken: string): Promise<void>;\n /**\n * Bind user.\n * @param userId user ID.\n * @param userName user name.\n * @param userEmail user email\n * @param extra additional user information\n * @returns a Promise.\n */\n bindRUMUserData(\n userId: string,\n userName?: string,\n userEmail?: string,\n extra?: object\n ): Promise<void>;\n /**\n * Unbind user.\n * @returns a Promise.\n */\n unbindRUMUserData(): Promise<void>;\n /**\n * Add custom global parameters. Applies to RUM and Log data\n * @param context custom global parameters.\n * @returns a Promise.\n */\n appendGlobalContext(context: object): Promise<void>;\n /**\n * Add custom RUM global parameters. Applies to RUM data\n * @param context custom RUM global parameters.\n * @returns a Promise.\n */\n appendRUMGlobalContext(context: object): Promise<void>;\n /**\n * Add custom RUM and Log global parameters. Applies to Log data\n * @param context custom Log global parameters.\n * @returns a Promise.\n */\n appendLogGlobalContext(context: object): Promise<void>;\n /**\n * Actively synchronize data. When `FTMobileConfig.autoSync=false` is configured, you need to actively trigger this method to synchronize data.\n * @returns a Promise.\n */\n flushSyncData(): Promise<void>;\n\n /**\n * Synchronize events in iOS Widget Extension, iOS only\n * @param groupIdentifier app groupId\n * @returns {groupIdentifier:string,datas:Array<object>} can be used to view data collected in Extension.\n */\n trackEventFromExtension(identifier: string): Promise<object>;\n /**\n * Shut down objects currently running in the SDK\n */\n shutDown(): Promise<void>;\n /**\n * Clear all data that has not yet been uploaded to the server.\n */\n clearAllData(): Promise<void>;\n /**\n * Add bridge context properties that will be automatically merged with local properties\n * @param properties Object containing key-value pairs\n */\n appendBridgeContext(properties: Record<string, any>): void;\n /**\n * Update remote configuration, after enabling remote configuration, you can call this method to update the configuration in real time.\n */\n updateRemoteConfig(): Promise<FTRemoteConfigResult>;\n /**\n * Update remote configuration with minimum update interval, after enabling remote configuration, you can call this method to update the configuration in real time.\n * This method is used to set the minimum update interval for remote configuration updates. If the time since the last update is less than the specified interval, the update will not be performed.\n * @param interval minimum update interval, unit seconds\n * @param rules Remote config override rules .Adjust the fetched remote configuration before application.\n * @returns the result of the remote config update\n */\n updateRemoteConfigWithMiniUpdateInterval(\n interval: number,\n rules?: Array<FTRemoteConfigOverrideRule>\n ): Promise<FTRemoteConfigResult>;\n /**\n * Listen for auto remote configuration updates triggered by the native SDK.\n * Manual updates are returned through the update Promise instead of this event.\n */\n addRemoteConfigListener(\n listener: (result: FTRemoteConfigResult) => void\n ): EmitterSubscription;\n};\n\nclass FTMobileReactNativeWrapper implements FTMobileReactNativeType {\n /* eslint-disable @typescript-eslint/no-var-requires */\n private sdk: FTMobileReactNativeType =\n require('./specs/NativeFTMobileReactNative').default;\n /* eslint-enable @typescript-eslint/no-var-requires */\n\n private emitter: NativeEventEmitter | null = null;\n\n private getEmitter(): NativeEventEmitter {\n if (this.emitter) {\n return this.emitter;\n }\n\n const nativeEventModule = NativeModules.FTMobileReactNative ?? this.sdk;\n this.emitter = new NativeEventEmitter(nativeEventModule as never);\n return this.emitter;\n }\n\n sdkConfig(config: FTMobileConfig): Promise<void> {\n if (\n config.serverUrl != null &&\n config.serverUrl.length > 0 &&\n config.datakitUrl == null\n ) {\n config.datakitUrl = config.serverUrl;\n }\n return this.sdk.sdkConfig(config);\n }\n setDatakitURL(datakitUrl: string): Promise<void> {\n return this.sdk.setDatakitURL(datakitUrl);\n }\n setDatawayURL(datawayUrl: string, clientToken: string): Promise<void> {\n return this.sdk.setDatawayURL(datawayUrl, clientToken);\n }\n bindRUMUserData(\n userId: string,\n userName?: string,\n userEmail?: string,\n extra?: object\n ): Promise<void> {\n return this.sdk.bindRUMUserData(userId, userName, userEmail, extra);\n }\n unbindRUMUserData(): Promise<void> {\n return this.sdk.unbindRUMUserData();\n }\n appendGlobalContext(context: object): Promise<void> {\n return this.sdk.appendGlobalContext(context);\n }\n appendLogGlobalContext(context: object): Promise<void> {\n return this.sdk.appendLogGlobalContext(context);\n }\n appendRUMGlobalContext(context: object): Promise<void> {\n return this.sdk.appendRUMGlobalContext(context);\n }\n trackEventFromExtension(identifier: string): Promise<object> {\n return this.sdk.trackEventFromExtension(identifier);\n }\n flushSyncData(): Promise<void> {\n return this.sdk.flushSyncData();\n }\n shutDown(): Promise<void> {\n return this.sdk.shutDown();\n }\n clearAllData(): Promise<void> {\n return this.sdk.clearAllData();\n }\n appendBridgeContext(properties: Record<string, any>): void {\n // Use bridgeContextManager to store properties in JavaScript and send to native SDK\n bridgeContextManager.appendBridgeContext(properties);\n }\n updateRemoteConfig(): Promise<FTRemoteConfigResult> {\n return this.sdk.updateRemoteConfig();\n }\n updateRemoteConfigWithMiniUpdateInterval(\n interval: number,\n rules?: Array<FTRemoteConfigOverrideRule>\n ): Promise<FTRemoteConfigResult> {\n return this.sdk.updateRemoteConfigWithMiniUpdateInterval(interval, rules);\n }\n addRemoteConfigListener(\n listener: (result: FTRemoteConfigResult) => void\n ): EmitterSubscription {\n return this.getEmitter().addListener('ft_remote_config_callback', listener);\n }\n}\nexport const FTMobileReactNative: FTMobileReactNativeType =\n new FTMobileReactNativeWrapper();\n"],"mappings":";;;;AAAA,SAEEA,kBAAkB,EAClBC,aAAa,QACR,cAAc;AACrB,SAASC,OAAO,IAAIC,UAAU,QAAQ,WAAW;;AAEjD;AACA;AACA;AACA;AACA;AACA,MAAMC,oBAAoB,CAAC;EAIjBC,WAAWA,CAAA,EAAG;IAAAC,eAAA,qBAFiB,IAAIC,GAAG,CAAC,CAAC;IAG9C;IACA,IAAI,CAACC,iBAAiB,CAAC,CAAC;EAC1B;;EAEA;AACF;AACA;AACA;EACUA,iBAAiBA,CAAA,EAAS;IAChC;IACA,MAAMC,aAAa,GAAG;MACpBC,YAAY,EAAEP;IAChB,CAAC;;IAED;IACA,IAAI,CAACQ,UAAU,CAACC,GAAG,CAAC,iBAAiB,EAAEC,IAAI,CAACC,SAAS,CAACL,aAAa,CAAC,CAAC;EACvE;;EAEA;AACF;AACA;AACA;EACE,OAAcM,WAAWA,CAAA,EAAyB;IAChD,IAAI,CAACX,oBAAoB,CAACY,QAAQ,EAAE;MAClCZ,oBAAoB,CAACY,QAAQ,GAAG,IAAIZ,oBAAoB,CAAC,CAAC;IAC5D;IACA,OAAOA,oBAAoB,CAACY,QAAQ;EACtC;;EAEA;AACF;AACA;AACA;EACSC,mBAAmBA,CAACN,UAA+B,EAAQ;IAChE;IACA,IAAI;MACF;MACAO,MAAM,CAACC,OAAO,CAACR,UAAU,CAAC,CAACS,OAAO,CAAC,CAAC,CAACC,GAAG,EAAEC,KAAK,CAAC,KAAK;QACnD,IAAI,CAACX,UAAU,CAACC,GAAG,CAACS,GAAG,EAAEC,KAAK,CAAC;MACjC,CAAC,CAAC;IACJ,CAAC,CAAC,OAAOC,KAAK,EAAE;MACdC,OAAO,CAACC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BAAuBA,CACrBC,QAAgD,EAC3B;IACrB,OAAO,IAAI,CAACnC,UAAU,CAAC,CAAC,CAACoC,WAAW,CAAC,2BAA2B,EAAED,QAAQ,CAAC;EAC7E;AACF;AACA,OAAO,MAAM/B,mBAA4C,GACvD,IAAIP,0BAA0B,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["NativeEventEmitter","NativeModules","version","sdkVersion","FTRumWebSocketTracking","BridgeContextManager","constructor","_defineProperty","Map","initializeSDKInfo","sdkBridgeInfo","react_native","properties","set","JSON","stringify","getInstance","instance","appendBridgeContext","Object","entries","forEach","key","value","longTaskContextEnabled","syncLongTaskContext","error","console","warn","configureLongTaskContext","enabled","rum","require","default","setLongTaskContext","mergeWithLocalPropertiesSync","localProperties","merged","assign","_BridgeContextManager","bridgeContextManager","EnvType","FTDBCacheDiscard","FTMobileReactNativeWrapper","getEmitter","_NativeModules$FTMobi","emitter","nativeEventModule","FTMobileReactNative","sdk","sdkConfig","config","serverUrl","length","datakitUrl","nativeConfig","allowWebViewHost","undefined","setDatakitURL","setDatawayURL","datawayUrl","clientToken","bindRUMUserData","userId","userName","userEmail","extra","resetVisitorId","unbindRUMUserData","appendGlobalContext","context","appendLogGlobalContext","appendRUMGlobalContext","trackEventFromExtension","identifier","flushSyncData","shutDown","stopLongTaskTracking","clearAllData","updateRemoteConfig","updateRemoteConfigWithMiniUpdateInterval","interval","rules","addRemoteConfigListener","listener","addListener"],"sources":["ft_mobile_agent.tsx"],"sourcesContent":["import {\n EmitterSubscription,\n NativeEventEmitter,\n NativeModules,\n} from 'react-native';\nimport type { Spec as NativeFTMobileReactNativeSpec } from './specs/NativeFTMobileReactNative';\nimport type { Spec as NativeFTReactNativeRUMSpec } from './specs/NativeFTReactNativeRUM';\nimport { version as sdkVersion } from './version';\nimport { FTRumWebSocketTracking } from './rum/FTRumWebSocketTracking';\n\n/**\n * Bridge context manager for managing shared properties across RUM and Logger modules\n * This class provides a centralized way to store and retrieve global properties that will be\n * automatically merged with local properties when making calls to RUM and Logger functions\n */\nclass BridgeContextManager {\n private static instance: BridgeContextManager;\n private properties: Map<string, any> = new Map();\n private longTaskContextEnabled = false;\n\n private constructor() {\n // Initialize with SDK version information\n this.initializeSDKInfo();\n }\n\n /**\n * Initialize SDK information properties\n * @private\n */\n private initializeSDKInfo(): void {\n // Create sdk_bridge_info with version information\n const sdkBridgeInfo = {\n react_native: sdkVersion,\n };\n\n // Set the sdk_bridge_info property\n this.properties.set('sdk_bridge_info', JSON.stringify(sdkBridgeInfo));\n }\n\n /**\n * Get singleton instance of BridgeContextManager\n * @returns BridgeContextManager instance\n */\n public static getInstance(): BridgeContextManager {\n if (!BridgeContextManager.instance) {\n BridgeContextManager.instance = new BridgeContextManager();\n }\n return BridgeContextManager.instance;\n }\n\n /**\n * Add bridge context properties that will be automatically merged with local properties\n * @param properties Object containing key-value pairs\n */\n public appendBridgeContext(properties: Record<string, any>): void {\n // Store properties locally in JavaScript\n try {\n // Store properties locally in JavaScript\n Object.entries(properties).forEach(([key, value]) => {\n this.properties.set(key, value);\n });\n if (this.longTaskContextEnabled) {\n this.syncLongTaskContext();\n }\n } catch (error) {\n console.warn('Failed to append bridge context:', error);\n }\n }\n\n public configureLongTaskContext(enabled: boolean): void {\n this.longTaskContextEnabled = enabled;\n if (enabled) {\n this.syncLongTaskContext();\n }\n }\n\n private syncLongTaskContext(): void {\n try {\n // Apply the snapshot before JS can block. An async native call may run after\n // the frame that detects the long task and attach stale context to it.\n const rum: NativeFTReactNativeRUMSpec =\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n require('./specs/NativeFTReactNativeRUM').default;\n rum.setLongTaskContext(this.mergeWithLocalPropertiesSync());\n } catch (error) {\n // Context synchronization must not make a destroyed/older bridge crash the host.\n console.warn('Failed to sync JS long task bridge context:', error);\n }\n }\n\n /**\n * Merge bridge context properties with local properties\n * Bridge context properties take precedence over local properties\n * @param localProperties Local properties to merge with bridge context properties\n * @returns Merged properties object\n */\n public mergeWithLocalPropertiesSync(\n localProperties?: object\n ): Record<string, any> {\n try {\n const merged: Record<string, any> = {};\n\n // First add local properties (if any)\n if (localProperties) {\n Object.assign(merged, localProperties);\n }\n\n // Then add bridge context properties (these will override local properties with same keys)\n this.properties.forEach((value, key) => {\n merged[key] = value;\n });\n\n return merged;\n } catch (error) {\n console.warn(\n 'Failed to merge bridge context with local properties:',\n error\n );\n // Return empty object or only local properties on error\n return localProperties ? { ...localProperties } : {};\n }\n }\n}\n\n// Internal bridge context manager - not exported\nexport const bridgeContextManager = BridgeContextManager.getInstance();\n\n/**\n * Environment.\n */\nexport enum EnvType {\n prod,\n gray,\n pre,\n common,\n local,\n}\nexport enum FTDBCacheDiscard {\n discard,\n discardOldest,\n}\n\n/**\n * Remote config override rule matching condition for custom keys. Supports exact match and contains match.\n * For exact match, set the value directly, for example: \"userid\": \"test_user\", which means the rule will be applied when the custom key \"userid\" is exactly \"test_user\".\n * For contains match, set the value as an object with a \"contains\" field, for example: \"userid\": { \"contains\": \"test_user\" }, which means the rule will be applied when the custom key \"userid\" contains the object \"test_user\".\n */\nexport type FTRemoteConfigCustomKeyContainsMatch = {\n contains: string | number | boolean;\n};\n\n/**\n * Matching rules for remote config override\n * Defines matching conditions using customKeys\n */\nexport type FTRemoteConfigOverrideMatch = {\n customKeys?: Record<\n string,\n string | number | boolean | FTRemoteConfigCustomKeyContainsMatch\n >;\n};\n\n/**\n * Values that can be modified by remote config override rules.\n * These values will adjust the fetched remote configuration before it is applied.\n * Omitted fields are not changed by this rule. Sampling percentages use [0, 100]\n * and support fractions (12.5 means 12.5%); legacy probabilities use [0, 1].\n */\nexport type FTRemoteConfigOverrideValues = {\n env?: string;\n serviceName?: string;\n autoSync?: boolean;\n compressIntakeRequests?: boolean;\n syncPageSize?: number;\n syncSleepTime?: number;\n /** RUM session sampling percentage override in [0, 100]; takes precedence over rumSampleRate, including 0. */\n sessionSamplingRate?: number;\n /** Error session sampling percentage override in [0, 100]; takes precedence over rumSessionOnErrorSampleRate, including 0. */\n sessionOnErrorSamplingRate?: number;\n /** Trace sampling percentage override in [0, 100]; takes precedence over traceSampleRate, including 0. */\n traceSamplingRate?: number;\n /** Log sampling percentage override in [0, 100]; takes precedence over logSampleRate, including 0. */\n logSamplingRate?: number;\n /** Session Replay sampling percentage override in [0, 100]; fractional percentages are supported. */\n sessionReplaySamplingRate?: number;\n /** Error replay sampling percentage override in [0, 100]; fractional percentages are supported. */\n sessionReplayOnErrorSamplingRate?: number;\n /** @deprecated Use sessionSamplingRate. Legacy RUM probability override in [0, 1]; 0.125 maps to 12.5%. */\n rumSampleRate?: number;\n /** @deprecated Use sessionOnErrorSamplingRate. Legacy error session probability override in [0, 1]. */\n rumSessionOnErrorSampleRate?: number;\n rumEnableTraceUserAction?: boolean;\n rumEnableTraceUserView?: boolean;\n rumEnableTraceUserResource?: boolean;\n rumEnableResourceHostIP?: boolean;\n rumEnableTrackAppUIBlock?: boolean;\n rumBlockDurationMs?: number;\n rumEnableTrackAppCrash?: boolean;\n rumEnableTrackAppANR?: boolean;\n rumEnableTraceWebView?: boolean;\n rumAllowWebViewHost?: Array<string>;\n /** @deprecated Use traceSamplingRate. Legacy Trace probability override in [0, 1]. */\n traceSampleRate?: number;\n traceEnableAutoTrace?: boolean;\n traceType?: string;\n /** @deprecated Use logSamplingRate. Legacy log probability override in [0, 1]. */\n logSampleRate?: number;\n logLevelFilters?: Array<string>;\n logEnableCustomLog?: boolean;\n logEnableWebViewLog?: boolean;\n logEnableConsoleLog?: boolean;\n};\n\n/**\n * Remote config override rules .\n * Adjust the fetched remote configuration before application.\n */\nexport type FTRemoteConfigOverrideRule = {\n id?: string;\n enabled?: boolean;\n match: FTRemoteConfigOverrideMatch;\n override: FTRemoteConfigOverrideValues;\n};\n/**\n * Final result of the remote config update\n * @param triggerType the type of remote config update trigger, auto or manual\n * @param success whether the remote config update was successful\n * @param platform the platform of the device, ios or android\n * @param timestamp the timestamp when the remote config update was triggered\n * @param rawJson the final remote config update result, in JSON string format\n * @param errorCode the error code if the remote config update failed, may be null if the update was successful\n * @param errorMessage the error message if the remote config update failed, may be null if the update was successful\n * @param appliedOverrideRuleIds the list of override rule IDs applied in this remote config update, may be null if no rules were applied\n */\nexport type FTRemoteConfigResult = {\n triggerType: 'auto' | 'manual';\n success: boolean;\n platform: 'ios' | 'android';\n timestamp: number;\n rawJson?: string;\n errorCode?: string | number;\n errorMessage?: string;\n appliedOverrideRuleIds?: string[];\n};\n/**\n * Configure SDK startup parameters.\n * @param serverUrl data reporting address, deprecated, use [datakitUrl] instead\n * @param datakitUrl datakit access URL address, example: http://10.0.0.1:9529, default port 9529. Choose one between datakit and dataway configuration\n * @param datawayUrl dataway access URL address, example: http://10.0.0.1:9528, default port 9528, note: the device installing the SDK needs to be able to access this address. Note: choose one between datakit and dataway configuration\n * @param clientToken dataway authentication token, needs to be configured together with [datawayUrl]\n * @param debug set whether to allow log printing, default false\n * @param env environment, default prod\n * @param service set the name of the business or service it belongs to, default: `df_rum_ios`, `df_rum_android`\n * @param autoSync whether data is automatically synchronized and uploaded, default: true\n * @param syncPageSize number of synchronized items per request during data synchronization, minimum value 5, default: 10\n * @param syncSleepTime interval time between each request during data synchronization, unit milliseconds, 0 < syncSleepTime < 100\n * @param enableDataIntegerCompatible whether to enable data integer compatibility during data synchronization, enabled by default\n * @param compressIntakeRequests whether to compress synchronized data\n * @param enableDataFilter whether to enable SDK-side local data filters, enabled by default\n * @param dataFilters local blocklist filter rules. Supported categories include `logging` and `rum`. Any data that matches a rule will be discarded.\n * @param globalContext custom global parameters\n * @param groupIdentifiers iOS side sets the AppGroups Identifier array corresponding to the collected Widget Extension\n * @param enableLimitWithDbSize set whether to enable using db to limit data size, after enabling, `FTLogConfig.logCacheLimitCount` and `FTRUMConfig.rumCacheLimitCount` will no longer take effect\n * @param dbCacheLimit db cache limit size, minimum value 30MB, default 100MB, unit byte\n * @param dbDiscardStrategy db data discard strategy\n * @param dataModifier data modifier, modify individual fields {key:value}, after setting, the SDK will replace the original value with the set value according to the key\n * @param lineDataModifier data modifier, modify single data {\"measurement\":measurement,\"data\":{key:value}}, after setting, the SDK will replace the original value with the set value according to the key\n * @param remoteConfiguration Set whether to enable remote dynamic configuration\n * @param remoteConfigMiniUpdateInterval Set remote dynamic configuration minimum update interval, unit seconds, default 12*60*60\n * @param remoteConfigOverrideRules Remote config override rules .Adjust the fetched remote configuration before application.\n */\nexport interface FTMobileConfig {\n /**\n * @deprecated \"serverUrl\" parameter renamed to \"datakitUrl\"\n */\n serverUrl?: string;\n datakitUrl?: string;\n datawayUrl?: string;\n clientToken?: string;\n debug?: boolean;\n envType?: EnvType;\n env?: string;\n service?: string;\n autoSync?: boolean;\n syncPageSize?: number;\n syncSleepTime?: number;\n enableDataIntegerCompatible?: boolean;\n compressIntakeRequests?: boolean;\n enableDataFilter?: boolean;\n dataFilters?: Record<string, Array<string>>;\n /** Shared WebView host allowlist for RUM and Log. Omitted uses the legacy RUM\n * config; null allows every host; [] disables bridge access. Remote config wins.\n */\n allowWebViewHost?: Array<string> | null;\n globalContext?: object;\n groupIdentifiers?: Array<string>;\n enableLimitWithDbSize?: boolean;\n dbCacheLimit?: number;\n dbDiscardStrategy?: FTDBCacheDiscard;\n dataModifier?: object;\n lineDataModifier?: object;\n remoteConfiguration?: boolean;\n remoteConfigMiniUpdateInterval?: number;\n remoteConfigOverrideRules?: Array<FTRemoteConfigOverrideRule>;\n}\n\ntype FTMobileReactNativeType = {\n /**\n * SDK initialization method.\n * @param config SDK initialization configuration items.\n * @returns a Promise.\n */\n sdkConfig(config: FTMobileConfig): Promise<void>;\n /**\n * Dynamically set the Datakit upload URL after SDK initialization.\n * @param datakitUrl Datakit upload URL.\n * @returns a Promise.\n */\n setDatakitURL(datakitUrl: string): Promise<void>;\n /**\n * Dynamically set the Dataway upload URL and client token after SDK initialization.\n * @param datawayUrl Dataway upload URL.\n * @param clientToken Dataway authentication token.\n * @returns a Promise.\n */\n setDatawayURL(datawayUrl: string, clientToken: string): Promise<void>;\n /**\n * Bind user.\n * @param userId user ID.\n * @param userName user name.\n * @param userEmail user email\n * @param extra additional user information\n * @returns a Promise.\n */\n bindRUMUserData(\n userId: string,\n userName?: string,\n userEmail?: string,\n extra?: object\n ): Promise<void>;\n /**\n * Unbind user.\n * @returns a Promise.\n */\n unbindRUMUserData(): Promise<void>;\n /** Rotate the native anonymous Visitor ID for subsequent requests. */\n resetVisitorId(): Promise<void>;\n /**\n * Add custom global parameters. Applies to RUM and Log data\n * @param context custom global parameters.\n * @returns a Promise.\n */\n appendGlobalContext(context: object): Promise<void>;\n /**\n * Add custom RUM global parameters. Applies to RUM data\n * @param context custom RUM global parameters.\n * @returns a Promise.\n */\n appendRUMGlobalContext(context: object): Promise<void>;\n /**\n * Add custom RUM and Log global parameters. Applies to Log data\n * @param context custom Log global parameters.\n * @returns a Promise.\n */\n appendLogGlobalContext(context: object): Promise<void>;\n /**\n * Actively synchronize data. When `FTMobileConfig.autoSync=false` is configured, you need to actively trigger this method to synchronize data.\n * @returns a Promise.\n */\n flushSyncData(): Promise<void>;\n\n /**\n * Synchronize events in iOS Widget Extension, iOS only\n * @param groupIdentifier app groupId\n * @returns {groupIdentifier:string,datas:Array<object>} can be used to view data collected in Extension.\n */\n trackEventFromExtension(identifier: string): Promise<object>;\n /**\n * Shut down objects currently running in the SDK\n */\n shutDown(): Promise<void>;\n /**\n * Clear all data that has not yet been uploaded to the server.\n */\n clearAllData(): Promise<void>;\n /**\n * Add bridge context properties that will be automatically merged with local properties\n * @param properties Object containing key-value pairs\n */\n appendBridgeContext(properties: Record<string, any>): void;\n /**\n * Update remote configuration, after enabling remote configuration, you can call this method to update the configuration in real time.\n */\n updateRemoteConfig(): Promise<FTRemoteConfigResult>;\n /**\n * Update remote configuration with minimum update interval, after enabling remote configuration, you can call this method to update the configuration in real time.\n * This method is used to set the minimum update interval for remote configuration updates. If the time since the last update is less than the specified interval, the update will not be performed.\n * @param interval minimum update interval, unit seconds\n * @param rules Remote config override rules .Adjust the fetched remote configuration before application.\n * @returns the result of the remote config update\n */\n updateRemoteConfigWithMiniUpdateInterval(\n interval: number,\n rules?: Array<FTRemoteConfigOverrideRule>\n ): Promise<FTRemoteConfigResult>;\n /**\n * Listen for auto remote configuration updates triggered by the native SDK.\n * Manual updates are returned through the update Promise instead of this event.\n */\n addRemoteConfigListener(\n listener: (result: FTRemoteConfigResult) => void\n ): EmitterSubscription;\n};\n\nclass FTMobileReactNativeWrapper implements FTMobileReactNativeType {\n /* eslint-disable @typescript-eslint/no-var-requires */\n private sdk: NativeFTMobileReactNativeSpec =\n require('./specs/NativeFTMobileReactNative').default;\n private rum: NativeFTReactNativeRUMSpec =\n require('./specs/NativeFTReactNativeRUM').default;\n /* eslint-enable @typescript-eslint/no-var-requires */\n\n private emitter: NativeEventEmitter | null = null;\n\n private getEmitter(): NativeEventEmitter {\n if (this.emitter) {\n return this.emitter;\n }\n\n const nativeEventModule = NativeModules.FTMobileReactNative ?? this.sdk;\n this.emitter = new NativeEventEmitter(nativeEventModule as never);\n return this.emitter;\n }\n\n sdkConfig(config: FTMobileConfig): Promise<void> {\n if (\n config.serverUrl != null &&\n config.serverUrl.length > 0 &&\n config.datakitUrl == null\n ) {\n config.datakitUrl = config.serverUrl;\n }\n const nativeConfig = { ...config };\n // Keep undefined equivalent to omission; explicit null overrides legacy hosts.\n if (nativeConfig.allowWebViewHost === undefined) {\n delete nativeConfig.allowWebViewHost;\n }\n return this.sdk.sdkConfig(nativeConfig);\n }\n setDatakitURL(datakitUrl: string): Promise<void> {\n return this.sdk.setDatakitURL(datakitUrl);\n }\n setDatawayURL(datawayUrl: string, clientToken: string): Promise<void> {\n return this.sdk.setDatawayURL(datawayUrl, clientToken);\n }\n bindRUMUserData(\n userId: string,\n userName?: string,\n userEmail?: string,\n extra?: object\n ): Promise<void> {\n return this.sdk.bindRUMUserData(userId, userName, userEmail, extra);\n }\n resetVisitorId(): Promise<void> {\n return this.sdk.resetVisitorId();\n }\n unbindRUMUserData(): Promise<void> {\n return this.sdk.unbindRUMUserData();\n }\n appendGlobalContext(context: object): Promise<void> {\n return this.sdk.appendGlobalContext(context);\n }\n appendLogGlobalContext(context: object): Promise<void> {\n return this.sdk.appendLogGlobalContext(context);\n }\n appendRUMGlobalContext(context: object): Promise<void> {\n return this.sdk.appendRUMGlobalContext(context);\n }\n trackEventFromExtension(identifier: string): Promise<object> {\n return this.sdk.trackEventFromExtension(identifier);\n }\n flushSyncData(): Promise<void> {\n return this.sdk.flushSyncData();\n }\n async shutDown(): Promise<void> {\n bridgeContextManager.configureLongTaskContext(false);\n try {\n FTRumWebSocketTracking.shutDown();\n await this.rum.stopLongTaskTracking();\n } finally {\n await this.sdk.shutDown();\n }\n }\n clearAllData(): Promise<void> {\n return this.sdk.clearAllData();\n }\n appendBridgeContext(properties: Record<string, any>): void {\n // Store properties in JS and update the native long task snapshot when enabled.\n bridgeContextManager.appendBridgeContext(properties);\n }\n updateRemoteConfig(): Promise<FTRemoteConfigResult> {\n return this.sdk.updateRemoteConfig() as Promise<FTRemoteConfigResult>;\n }\n updateRemoteConfigWithMiniUpdateInterval(\n interval: number,\n rules?: Array<FTRemoteConfigOverrideRule>\n ): Promise<FTRemoteConfigResult> {\n return this.sdk.updateRemoteConfigWithMiniUpdateInterval(\n interval,\n rules\n ) as Promise<FTRemoteConfigResult>;\n }\n addRemoteConfigListener(\n listener: (result: FTRemoteConfigResult) => void\n ): EmitterSubscription {\n return this.getEmitter().addListener('ft_remote_config_callback', listener);\n }\n}\nexport const FTMobileReactNative: FTMobileReactNativeType =\n new FTMobileReactNativeWrapper();\n"],"mappings":";;;;AAAA,SAEEA,kBAAkB,EAClBC,aAAa,QACR,cAAc;AAGrB,SAASC,OAAO,IAAIC,UAAU,QAAQ,WAAW;AACjD,SAASC,sBAAsB,QAAQ,8BAA8B;;AAErE;AACA;AACA;AACA;AACA;AACA,MAAMC,oBAAoB,CAAC;EAKjBC,WAAWA,CAAA,EAAG;IAAAC,eAAA,qBAHiB,IAAIC,GAAG,CAAC,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CAACX,wBAAwB,CAAC,KAAK,CAAC;IACpD,IAAI;MACFzB,sBAAsB,CAACwE,QAAQ,CAAC,CAAC;MACjC,MAAM,IAAI,CAAC7C,GAAG,CAAC8C,oBAAoB,CAAC,CAAC;IACvC,CAAC,SAAS;MACR,MAAM,IAAI,CAAC5B,GAAG,CAAC2B,QAAQ,CAAC,CAAC;IAC3B;EACF;EACAE,YAAYA,CAAA,EAAkB;IAC5B,OAAO,IAAI,CAAC7B,GAAG,CAAC6B,YAAY,CAAC,CAAC;EAChC;EACA5D,mBAAmBA,CAACN,UAA+B,EAAQ;IACzD;IACA4B,oBAAoB,CAACtB,mBAAmB,CAACN,UAAU,CAAC;EACtD;EACAmE,kBAAkBA,CAAA,EAAkC;IAClD,OAAO,IAAI,CAAC9B,GAAG,CAAC8B,kBAAkB,CAAC,CAAC;EACtC;EACAC,wCAAwCA,CACtCC,QAAgB,EAChBC,KAAyC,EACV;IAC/B,OAAO,IAAI,CAACjC,GAAG,CAAC+B,wCAAwC,CACtDC,QAAQ,EACRC,KACF,CAAC;EACH;EACAC,uBAAuBA,CACrBC,QAAgD,EAC3B;IACrB,OAAO,IAAI,CAACxC,UAAU,CAAC,CAAC,CAACyC,WAAW,CAAC,2BAA2B,EAAED,QAAQ,CAAC;EAC7E;AACF;AACA,OAAO,MAAMpC,mBAA4C,GACvD,IAAIL,0BAA0B,CAAC,CAAC","ignoreList":[]}
|
package/lib/module/ft_rum.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
2
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
3
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
+
import { validateVisitorIdConfig } from './visitorIdConfig';
|
|
4
5
|
// import { NativeModules } from 'react-native';
|
|
6
|
+
import { Platform } from 'react-native';
|
|
5
7
|
import { FTRumErrorTracking } from './rum/FTRumErrorTracking';
|
|
6
8
|
import { FTRumActionTracking } from './rum/FTRumActionTracking';
|
|
9
|
+
import { FTBabelInteractionTracking } from './rum/FTBabelInteractionTracking';
|
|
10
|
+
import { FTRumWebSocketTracking } from './rum/FTRumWebSocketTracking';
|
|
7
11
|
import { bridgeContextManager } from './ft_mobile_agent';
|
|
12
|
+
import { normalizeLongTaskThreshold } from './rum/longTasksUtils';
|
|
8
13
|
|
|
9
14
|
/**
|
|
10
15
|
* Error monitoring type.
|
|
@@ -66,17 +71,25 @@ export let IOSCrashMonitoringType = /*#__PURE__*/function (IOSCrashMonitoringTyp
|
|
|
66
71
|
* Set RUM tracking conditions.
|
|
67
72
|
* @param androidAppId appId, apply during monitoring
|
|
68
73
|
* @param iOSAppId appId, apply during monitoring
|
|
69
|
-
* @param
|
|
70
|
-
* @param
|
|
74
|
+
* @param sessionSamplingRate RUM session sampling percentage in [0, 100], default 100. Supports fractional percentages and takes precedence over sampleRate.
|
|
75
|
+
* @param sessionOnErrorSamplingRate Sampling percentage in [0, 100] for otherwise unsampled sessions when an error occurs, default 0. Supports fractional percentages and takes precedence over sessionOnErrorSampleRate.
|
|
76
|
+
* @param sampleRate Deprecated RUM session sampling probability in [0, 1], default 1. Used only when sessionSamplingRate is omitted; multiplied by 100 before passing to Native.
|
|
77
|
+
* @param sessionOnErrorSampleRate Deprecated error session sampling probability in [0, 1], default 0. Used only when sessionOnErrorSamplingRate is omitted; multiplied by 100 before passing to Native.
|
|
71
78
|
* @param enableAutoTrackUserAction whether to automatically collect react-native control click events, can set actionName with accessibilityLabel when enabled
|
|
72
79
|
* @param enableTrackError whether to automatically collect react-native Error
|
|
73
80
|
* @param enableTrackNativeCrash whether to collect Native Error
|
|
74
81
|
* @param enableTrackNativeAppANR whether to collect Native ANR
|
|
75
82
|
* @param enableTrackNativeFreeze whether to collect Native Freeze
|
|
76
83
|
* @param nativeFreezeDurationMs set the threshold for collecting Native Freeze, value range [100,), unit ms. iOS default 250ms, Android default 1000ms
|
|
84
|
+
* @param enableLongTask whether to collect React Native JavaScript LongTasks, default false
|
|
85
|
+
* @param longTaskThresholdMs set the threshold for collecting React Native JavaScript LongTasks, unit ms. Defaults to 100 and is clamped to [100, 5000]
|
|
77
86
|
* @param enableNativeUserAction whether to start Native Action tracking, Button click events, recommended to disable for pure react-native apps
|
|
78
87
|
* @param enableNativeUserView whether to start Native View auto tracking, recommended to disable for pure react-native apps
|
|
79
88
|
* @param enableNativeUserResource whether to automatically collect react-native Resource
|
|
89
|
+
* @param enableIOSWebSocketResource whether to collect iOS WebSocket opening handshakes as RUM Resources. Defaults to false.
|
|
90
|
+
* Independent of enableNativeUserResource. Android native WebSocket collection is unaffected.
|
|
91
|
+
* iOS WebSocket Trace header injection requires both this option and enableNativeAutoTrace.
|
|
92
|
+
* When disabled, new iOS WebSocket connections are not instrumented or automatically injected with Trace headers by this SDK.
|
|
80
93
|
* @param enableResourceHostIP whether to collect network request Host IP (only for native http, iOS 13 and above)
|
|
81
94
|
* @param errorMonitorType error monitoring supplement type
|
|
82
95
|
* @param deviceMonitorType page monitoring supplement type
|
|
@@ -85,7 +98,7 @@ export let IOSCrashMonitoringType = /*#__PURE__*/function (IOSCrashMonitoringTyp
|
|
|
85
98
|
* @param rumCacheLimitCount RUM max cache size, default 100_000
|
|
86
99
|
* @param rumDiscardStrategy RUM data discard strategy
|
|
87
100
|
* @param enableTraceWebView Set whether to enable WebView data collection, default true
|
|
88
|
-
* @param allowWebViewHost
|
|
101
|
+
* @param allowWebViewHost Deprecated; use FTMobileConfig.allowWebViewHost for shared WebView host filtering.
|
|
89
102
|
* @param iosCrashMonitoringType iOS crash monitoring type , default is highCompatibility, which does not include Mach exceptions for better compatibility. you must enable system crash monitoring to get crash stack traces and crash information.
|
|
90
103
|
*/
|
|
91
104
|
|
|
@@ -110,20 +123,61 @@ export let IOSCrashMonitoringType = /*#__PURE__*/function (IOSCrashMonitoringTyp
|
|
|
110
123
|
* @param resource_first_byte resource first byte time
|
|
111
124
|
*/
|
|
112
125
|
|
|
126
|
+
function isBabelPluginEnabled() {
|
|
127
|
+
if (typeof globalThis !== 'undefined') {
|
|
128
|
+
return globalThis.__FT_RN_BABEL_PLUGIN_ENABLED__ === true;
|
|
129
|
+
}
|
|
130
|
+
if (typeof global !== 'undefined') {
|
|
131
|
+
return global.__FT_RN_BABEL_PLUGIN_ENABLED__ === true;
|
|
132
|
+
}
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
113
135
|
class FTReactNativeRUMWrapper {
|
|
114
136
|
constructor() {
|
|
137
|
+
_defineProperty(this, "webSocketConfigVersion", 0);
|
|
115
138
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
116
139
|
_defineProperty(this, "rum", require('./specs/NativeFTReactNativeRUM').default);
|
|
117
140
|
}
|
|
118
141
|
setConfig(config) {
|
|
142
|
+
if (config.visitorIdConfig != null) {
|
|
143
|
+
try {
|
|
144
|
+
validateVisitorIdConfig(config.visitorIdConfig);
|
|
145
|
+
} catch (error) {
|
|
146
|
+
return Promise.reject(error);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
bridgeContextManager.configureLongTaskContext(config.enableLongTask === true);
|
|
150
|
+
const webSocketLifecycle = FTRumWebSocketTracking.getLifecycleVersion();
|
|
151
|
+
const webSocketConfigVersion = ++this.webSocketConfigVersion;
|
|
152
|
+
const trackWebSocket = config.enableIOSWebSocketResource === true;
|
|
119
153
|
console.log('FTRUMConfig');
|
|
120
154
|
if (config.enableAutoTrackError) {
|
|
121
155
|
FTRumErrorTracking.startTracking();
|
|
122
156
|
}
|
|
123
|
-
|
|
157
|
+
const babelPluginEnabled = isBabelPluginEnabled();
|
|
158
|
+
FTBabelInteractionTracking.configure({
|
|
159
|
+
trackInteractions: babelPluginEnabled && Boolean(config.enableAutoTrackUserAction),
|
|
160
|
+
actionReporter: (actionName, actionType, property) => this.startAction(actionName, actionType, property)
|
|
161
|
+
});
|
|
162
|
+
if (config.enableAutoTrackUserAction && !babelPluginEnabled) {
|
|
124
163
|
FTRumActionTracking.startTracking();
|
|
164
|
+
} else {
|
|
165
|
+
FTRumActionTracking.stopTracking();
|
|
125
166
|
}
|
|
126
|
-
return this.rum.setConfig(
|
|
167
|
+
return this.rum.setConfig({
|
|
168
|
+
...config,
|
|
169
|
+
enableLongTask: config.enableLongTask === true,
|
|
170
|
+
longTaskThresholdMs: normalizeLongTaskThreshold(config.longTaskThresholdMs)
|
|
171
|
+
}).then(() => {
|
|
172
|
+
if (webSocketLifecycle !== FTRumWebSocketTracking.getLifecycleVersion() || webSocketConfigVersion !== this.webSocketConfigVersion) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (Platform.OS === 'ios' && trackWebSocket) {
|
|
176
|
+
FTRumWebSocketTracking.startTracking(this);
|
|
177
|
+
} else {
|
|
178
|
+
FTRumWebSocketTracking.stopTracking();
|
|
179
|
+
}
|
|
180
|
+
});
|
|
127
181
|
}
|
|
128
182
|
startAction(actionName, actionType, property) {
|
|
129
183
|
// Automatically merge bridge context properties with local properties
|
|
@@ -138,6 +192,12 @@ class FTReactNativeRUMWrapper {
|
|
|
138
192
|
onCreateView(viewName, loadTime) {
|
|
139
193
|
return this.rum.onCreateView(viewName, loadTime);
|
|
140
194
|
}
|
|
195
|
+
updateViewLoadingTime(duration) {
|
|
196
|
+
if (!Number.isSafeInteger(duration) || duration < 0) {
|
|
197
|
+
return Promise.reject(new RangeError('duration must be a non-negative safe integer in nanoseconds'));
|
|
198
|
+
}
|
|
199
|
+
return this.rum.updateViewLoadingTime(duration);
|
|
200
|
+
}
|
|
141
201
|
startView(viewName, property) {
|
|
142
202
|
// Automatically merge bridge context properties with local properties
|
|
143
203
|
const mergedProperties = bridgeContextManager.mergeWithLocalPropertiesSync(property);
|