@truewatchtech/react-native-mobile 0.4.3-alpha.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 +1 -1
- package/README.md +0 -34
- package/android/build.gradle +2 -2
- 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 -3
- package/android/src/main/java/com/ft/sdk/reactnative/FTRUMImpl.java +51 -9
- package/android/src/main/java/com/ft/sdk/reactnative/FTTraceImpl.java +5 -2
- 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/newarch/java/com/ft/sdk/reactnative/FTMobileModule.java +5 -0
- package/android/src/newarch/java/com/ft/sdk/reactnative/FTRUMModule.java +18 -0
- package/android/src/oldarch/java/com/ft/sdk/reactnative/FTMobileModule.java +5 -0
- package/android/src/oldarch/java/com/ft/sdk/reactnative/FTRUMModule.java +15 -0
- package/android/src/test/java/com/ft/sdk/reactnative/FTMobileImplTest.java +53 -0
- package/ios/FTMobileReactNative.mm +37 -2
- package/ios/FTReactNativeLog.mm +7 -2
- package/ios/FTReactNativeRUM.mm +94 -4
- package/ios/FTReactNativeResource.m +6 -0
- package/ios/FTReactNativeTrace.mm +4 -2
- package/ios/FTReactNativeViewTiming.h +18 -0
- package/ios/FTWebSocketResourceData.h +4 -0
- package/ios/FTWebSocketResourceData.m +31 -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 +13 -1
- package/lib/commonjs/ft_mobile_agent.js.map +1 -1
- package/lib/commonjs/ft_rum.js +19 -3
- package/lib/commonjs/ft_rum.js.map +1 -1
- package/lib/commonjs/ft_tracing.js +2 -1
- package/lib/commonjs/ft_tracing.js.map +1 -1
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/rum/FTRumViewTracking.js +147 -0
- package/lib/commonjs/rum/FTRumViewTracking.js.map +1 -0
- package/lib/commonjs/rum/FTRumWebSocketNative.js.map +1 -1
- package/lib/commonjs/rum/FTRumWebSocketTiming.js +19 -1
- package/lib/commonjs/rum/FTRumWebSocketTiming.js.map +1 -1
- package/lib/commonjs/rum/FTRumWebSocketTracking.js +7 -11
- package/lib/commonjs/rum/FTRumWebSocketTracking.js.map +1 -1
- package/lib/commonjs/specs/NativeFTMobileReactNative.js.map +1 -1
- package/lib/commonjs/specs/NativeFTReactNativeRUM.js.map +1 -1
- 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 +13 -1
- package/lib/module/ft_mobile_agent.js.map +1 -1
- package/lib/module/ft_rum.js +19 -3
- package/lib/module/ft_rum.js.map +1 -1
- package/lib/module/ft_tracing.js +2 -1
- package/lib/module/ft_tracing.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/rum/FTRumViewTracking.js +140 -0
- package/lib/module/rum/FTRumViewTracking.js.map +1 -0
- package/lib/module/rum/FTRumWebSocketNative.js.map +1 -1
- package/lib/module/rum/FTRumWebSocketTiming.js +19 -1
- package/lib/module/rum/FTRumWebSocketTiming.js.map +1 -1
- package/lib/module/rum/FTRumWebSocketTracking.js +7 -11
- package/lib/module/rum/FTRumWebSocketTracking.js.map +1 -1
- package/lib/module/specs/NativeFTMobileReactNative.js.map +1 -1
- package/lib/module/specs/NativeFTReactNativeRUM.js.map +1 -1
- 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 +25 -0
- package/lib/typescript/ft_rum.d.ts +33 -5
- package/lib/typescript/ft_tracing.d.ts +9 -1
- package/lib/typescript/index.d.ts +2 -0
- package/lib/typescript/rum/FTRumViewTracking.d.ts +32 -0
- package/lib/typescript/rum/FTRumWebSocketNative.d.ts +2 -3
- package/lib/typescript/rum/FTRumWebSocketTiming.d.ts +6 -1
- package/lib/typescript/rum/FTRumWebSocketTracking.d.ts +2 -4
- package/lib/typescript/specs/NativeFTMobileReactNative.d.ts +1 -0
- package/lib/typescript/specs/NativeFTReactNativeRUM.d.ts +7 -1
- package/lib/typescript/version.d.ts +1 -1
- package/lib/typescript/visitorIdConfig.d.ts +11 -0
- package/package.json +4 -3
- package/src/ft_logger.tsx +11 -1
- package/src/ft_mobile_agent.tsx +34 -1
- package/src/ft_rum.tsx +50 -5
- package/src/ft_tracing.tsx +9 -1
- package/src/index.tsx +4 -0
- package/src/rum/FTRumViewTracking.ts +179 -0
- package/src/rum/FTRumWebSocketNative.ts +2 -1
- package/src/rum/FTRumWebSocketTiming.ts +34 -2
- package/src/rum/FTRumWebSocketTracking.ts +9 -14
- package/src/specs/NativeFTMobileReactNative.ts +1 -0
- package/src/specs/NativeFTReactNativeRUM.ts +15 -1
- package/src/version.ts +1 -1
- package/src/visitorIdConfig.ts +123 -0
package/lib/module/ft_rum.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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';
|
|
5
6
|
import { Platform } from 'react-native';
|
|
6
7
|
import { FTRumErrorTracking } from './rum/FTRumErrorTracking';
|
|
@@ -70,8 +71,10 @@ export let IOSCrashMonitoringType = /*#__PURE__*/function (IOSCrashMonitoringTyp
|
|
|
70
71
|
* Set RUM tracking conditions.
|
|
71
72
|
* @param androidAppId appId, apply during monitoring
|
|
72
73
|
* @param iOSAppId appId, apply during monitoring
|
|
73
|
-
* @param
|
|
74
|
-
* @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.
|
|
75
78
|
* @param enableAutoTrackUserAction whether to automatically collect react-native control click events, can set actionName with accessibilityLabel when enabled
|
|
76
79
|
* @param enableTrackError whether to automatically collect react-native Error
|
|
77
80
|
* @param enableTrackNativeCrash whether to collect Native Error
|
|
@@ -95,7 +98,7 @@ export let IOSCrashMonitoringType = /*#__PURE__*/function (IOSCrashMonitoringTyp
|
|
|
95
98
|
* @param rumCacheLimitCount RUM max cache size, default 100_000
|
|
96
99
|
* @param rumDiscardStrategy RUM data discard strategy
|
|
97
100
|
* @param enableTraceWebView Set whether to enable WebView data collection, default true
|
|
98
|
-
* @param allowWebViewHost
|
|
101
|
+
* @param allowWebViewHost Deprecated; use FTMobileConfig.allowWebViewHost for shared WebView host filtering.
|
|
99
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.
|
|
100
103
|
*/
|
|
101
104
|
|
|
@@ -136,6 +139,13 @@ class FTReactNativeRUMWrapper {
|
|
|
136
139
|
_defineProperty(this, "rum", require('./specs/NativeFTReactNativeRUM').default);
|
|
137
140
|
}
|
|
138
141
|
setConfig(config) {
|
|
142
|
+
if (config.visitorIdConfig != null) {
|
|
143
|
+
try {
|
|
144
|
+
validateVisitorIdConfig(config.visitorIdConfig);
|
|
145
|
+
} catch (error) {
|
|
146
|
+
return Promise.reject(error);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
139
149
|
bridgeContextManager.configureLongTaskContext(config.enableLongTask === true);
|
|
140
150
|
const webSocketLifecycle = FTRumWebSocketTracking.getLifecycleVersion();
|
|
141
151
|
const webSocketConfigVersion = ++this.webSocketConfigVersion;
|
|
@@ -182,6 +192,12 @@ class FTReactNativeRUMWrapper {
|
|
|
182
192
|
onCreateView(viewName, loadTime) {
|
|
183
193
|
return this.rum.onCreateView(viewName, loadTime);
|
|
184
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
|
+
}
|
|
185
201
|
startView(viewName, property) {
|
|
186
202
|
// Automatically merge bridge context properties with local properties
|
|
187
203
|
const mergedProperties = bridgeContextManager.mergeWithLocalPropertiesSync(property);
|
package/lib/module/ft_rum.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","FTRumErrorTracking","FTRumActionTracking","FTBabelInteractionTracking","FTRumWebSocketTracking","bridgeContextManager","normalizeLongTaskThreshold","ErrorMonitorType","DeviceMetricsMonitorType","DetectFrequency","FTRUMCacheDiscard","IOSCrashMonitoringType","isBabelPluginEnabled","globalThis","__FT_RN_BABEL_PLUGIN_ENABLED__","global","FTReactNativeRUMWrapper","constructor","_defineProperty","require","default","setConfig","config","configureLongTaskContext","enableLongTask","webSocketLifecycle","getLifecycleVersion","webSocketConfigVersion","trackWebSocket","enableIOSWebSocketResource","console","log","enableAutoTrackError","startTracking","babelPluginEnabled","configure","trackInteractions","Boolean","enableAutoTrackUserAction","actionReporter","actionName","actionType","property","startAction","stopTracking","rum","longTaskThresholdMs","then","OS","mergedProperties","mergeWithLocalPropertiesSync","addAction","onCreateView","viewName","loadTime","startView","stopView","addError","stack","message","addErrorWithType","type","startResource","key","stopResource","addResource","resource","metrics","FTReactNativeRUM"],"sources":["ft_rum.tsx"],"sourcesContent":["// import { NativeModules } from 'react-native';\nimport { Platform } from 'react-native';\nimport { FTRumErrorTracking } from './rum/FTRumErrorTracking';\nimport { FTRumActionTracking } from './rum/FTRumActionTracking';\nimport { FTBabelInteractionTracking } from './rum/FTBabelInteractionTracking';\nimport { FTRumWebSocketTracking } from './rum/FTRumWebSocketTracking';\nimport { bridgeContextManager } from './ft_mobile_agent';\nimport { normalizeLongTaskThreshold } from './rum/longTasksUtils';\n\n/**\n * Error monitoring type.\n */\n/* eslint-disable no-bitwise */\nexport enum ErrorMonitorType {\n all = 0xffffffff,\n battery = 1 << 1,\n memory = 1 << 2,\n cpu = 1 << 3,\n}\n/**\n * Page monitoring supplement type\n */\nexport enum DeviceMetricsMonitorType {\n all = 0xffffffff,\n battery = 1 << 1,\n memory = 1 << 2,\n cpu = 1 << 3,\n fps = 1 << 4,\n}\n/**\n * Device information monitoring cycle.\n */\nexport enum DetectFrequency {\n normal,\n frequent,\n rare,\n}\n\nexport enum FTRUMCacheDiscard {\n discard,\n discardOldest,\n}\n\nexport enum IOSCrashMonitoringType {\n /** Monitor Mach kernel exceptions. */\n machException = 0x01,\n\n /** Monitor fatal signals. */\n signal = 0x02,\n\n /** Monitor uncaught C++ exceptions. */\n cppException = 0x04,\n\n /** Monitor uncaught Objective-C NSExceptions. */\n nsException = 0x08,\n\n /** Track and inject system information. */\n system = 0x40,\n\n /** Track and inject application state information. */\n applicationState = 0x80,\n\n /** All crash monitor types. */\n all = machException |\n signal |\n cppException |\n nsException |\n applicationState |\n system,\n\n /** High compatibility crash monitor types (excludes Mach exceptions). */\n highCompatibility = all & ~machException,\n}\n/* eslint-enable no-bitwise */\n/**\n * Set RUM tracking conditions.\n * @param androidAppId appId, apply during monitoring\n * @param iOSAppId appId, apply during monitoring\n * @param sampleRate sampling rate\n * @param sessionOnErrorSampleRate error session sampling rate. For sessions not sampled, if ERROR is hit, collect data 1 minute before the error occurs\n * @param enableAutoTrackUserAction whether to automatically collect react-native control click events, can set actionName with accessibilityLabel when enabled\n * @param enableTrackError whether to automatically collect react-native Error\n * @param enableTrackNativeCrash whether to collect Native Error\n * @param enableTrackNativeAppANR whether to collect Native ANR\n * @param enableTrackNativeFreeze whether to collect Native Freeze\n * @param nativeFreezeDurationMs set the threshold for collecting Native Freeze, value range [100,), unit ms. iOS default 250ms, Android default 1000ms\n * @param enableLongTask whether to collect React Native JavaScript LongTasks, default false\n * @param longTaskThresholdMs set the threshold for collecting React Native JavaScript LongTasks, unit ms. Defaults to 100 and is clamped to [100, 5000]\n * @param enableNativeUserAction whether to start Native Action tracking, Button click events, recommended to disable for pure react-native apps\n * @param enableNativeUserView whether to start Native View auto tracking, recommended to disable for pure react-native apps\n * @param enableNativeUserResource whether to automatically collect react-native Resource\n * @param enableIOSWebSocketResource whether to collect iOS WebSocket opening handshakes as RUM Resources. Defaults to false.\n * Independent of enableNativeUserResource. Android native WebSocket collection is unaffected.\n * iOS WebSocket Trace header injection requires both this option and enableNativeAutoTrace.\n * When disabled, new iOS WebSocket connections are not instrumented or automatically injected with Trace headers by this SDK.\n * @param enableResourceHostIP whether to collect network request Host IP (only for native http, iOS 13 and above)\n * @param errorMonitorType error monitoring supplement type\n * @param deviceMonitorType page monitoring supplement type\n * @param detectFrequency monitoring frequency\n * @param globalContext custom global parameters\n * @param rumCacheLimitCount RUM max cache size, default 100_000\n * @param rumDiscardStrategy RUM data discard strategy\n * @param enableTraceWebView Set whether to enable WebView data collection, default true\n * @param allowWebViewHost Set specific hosts or domains allowed to collect WebView data, nil means collect all\n * @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.\n */\nexport interface FTRUMConfig {\n androidAppId: string;\n iOSAppId: string;\n sampleRate?: number;\n sessionOnErrorSampleRate?: number;\n enableAutoTrackUserAction?: boolean;\n enableAutoTrackError?: boolean;\n enableTrackNativeCrash?: boolean;\n enableTrackNativeAppANR?: boolean;\n enableTrackNativeFreeze?: boolean;\n nativeFreezeDurationMs?: number;\n enableLongTask?: boolean;\n longTaskThresholdMs?: number;\n enableNativeUserAction?: boolean;\n enableNativeUserView?: boolean;\n enableNativeUserResource?: boolean;\n enableIOSWebSocketResource?: boolean;\n enableResourceHostIP?: boolean;\n errorMonitorType?: ErrorMonitorType;\n deviceMonitorType?: DeviceMetricsMonitorType;\n detectFrequency?: DetectFrequency;\n globalContext?: object;\n rumCacheLimitCount?: number;\n rumDiscardStrategy?: FTRUMCacheDiscard;\n enableTraceWebView?: boolean;\n allowWebViewHost?: Array<string>;\n iosCrashMonitoringType?: IOSCrashMonitoringType;\n}\n/**\n * RUM Resource data.\n * @param url request URL\n * @param httpMethod request method\n * @param requestHeader request header parameters\n * @param responseHeader response header parameters\n * @param responseBody response content\n * @param resourceStatus response status code\n */\nexport interface FTRUMResource {\n url: string;\n httpMethod: string;\n requestHeader: object;\n responseHeader?: object;\n responseBody?: string;\n resourceStatus?: number;\n}\n/**\n * RUM Resource performance metrics.\n * @param duration resource load time\n * @param resource_dns resource DNS resolution time\n * @param resource_tcp resource TCP connection time\n * @param resource_ssl resource SSL connection time\n * @param resource_ttfb resource request response time\n * @param resource_trans resource content transfer time\n * @param resource_first_byte resource first byte time\n */\nexport interface FTRUMResourceMetrics {\n duration?: number;\n resource_dns?: number;\n resource_tcp?: number;\n resource_ssl?: number;\n resource_ttfb?: number;\n resource_trans?: number;\n resource_first_byte?: number;\n}\ntype FTReactNativeRUMType = {\n /**\n * Set RUM tracking conditions and enable RUM collection.\n * @param config rum configuration parameters.\n * @returns a Promise.\n */\n setConfig(config: FTRUMConfig): 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(\n key: string,\n resource: FTRUMResource,\n metrics?: FTRUMResourceMetrics\n ): Promise<void>;\n};\n\nfunction isBabelPluginEnabled(): boolean {\n if (typeof globalThis !== 'undefined') {\n return globalThis.__FT_RN_BABEL_PLUGIN_ENABLED__ === true;\n }\n if (typeof global !== 'undefined') {\n return global.__FT_RN_BABEL_PLUGIN_ENABLED__ === true;\n }\n return false;\n}\n\nclass FTReactNativeRUMWrapper implements FTReactNativeRUMType {\n private webSocketConfigVersion = 0;\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n private rum: FTReactNativeRUMType = require('./specs/NativeFTReactNativeRUM')\n .default;\n\n setConfig(config: FTRUMConfig): Promise<void> {\n bridgeContextManager.configureLongTaskContext(\n config.enableLongTask === true\n );\n const webSocketLifecycle = FTRumWebSocketTracking.getLifecycleVersion();\n const webSocketConfigVersion = ++this.webSocketConfigVersion;\n const trackWebSocket = config.enableIOSWebSocketResource === true;\n console.log('FTRUMConfig');\n if (config.enableAutoTrackError) {\n FTRumErrorTracking.startTracking();\n }\n const babelPluginEnabled = isBabelPluginEnabled();\n FTBabelInteractionTracking.configure({\n trackInteractions:\n babelPluginEnabled && Boolean(config.enableAutoTrackUserAction),\n actionReporter: (actionName, actionType, property) =>\n this.startAction(actionName, actionType, property),\n });\n if (config.enableAutoTrackUserAction && !babelPluginEnabled) {\n FTRumActionTracking.startTracking();\n } else {\n FTRumActionTracking.stopTracking();\n }\n return this.rum\n .setConfig({\n ...config,\n enableLongTask: config.enableLongTask === true,\n longTaskThresholdMs: normalizeLongTaskThreshold(\n config.longTaskThresholdMs\n ),\n })\n .then(() => {\n if (\n webSocketLifecycle !== FTRumWebSocketTracking.getLifecycleVersion() ||\n webSocketConfigVersion !== this.webSocketConfigVersion\n ) {\n return;\n }\n if (Platform.OS === 'ios' && trackWebSocket) {\n FTRumWebSocketTracking.startTracking(this);\n } else {\n FTRumWebSocketTracking.stopTracking();\n }\n });\n }\n startAction(\n actionName: string,\n actionType: string,\n property?: object\n ): Promise<void> {\n // Automatically merge bridge context properties with local properties\n const mergedProperties =\n bridgeContextManager.mergeWithLocalPropertiesSync(property);\n return this.rum.startAction(actionName, actionType, mergedProperties);\n }\n addAction(\n actionName: string,\n actionType: string,\n property?: object\n ): Promise<void> {\n // Automatically merge bridge context properties with local properties\n const mergedProperties =\n bridgeContextManager.mergeWithLocalPropertiesSync(property);\n return this.rum.addAction(actionName, actionType, mergedProperties);\n }\n onCreateView(viewName: string, loadTime: number): Promise<void> {\n return this.rum.onCreateView(viewName, loadTime);\n }\n startView(viewName: string, property?: object): Promise<void> {\n // Automatically merge bridge context properties with local properties\n const mergedProperties =\n bridgeContextManager.mergeWithLocalPropertiesSync(property);\n return this.rum.startView(viewName, mergedProperties);\n }\n stopView(property?: object): Promise<void> {\n // Automatically merge bridge context properties with local properties\n const mergedProperties =\n bridgeContextManager.mergeWithLocalPropertiesSync(property);\n return this.rum.stopView(mergedProperties);\n }\n addError(stack: string, message: string, property?: object): Promise<void> {\n // Automatically merge bridge context properties with local properties\n const mergedProperties =\n bridgeContextManager.mergeWithLocalPropertiesSync(property);\n return this.rum.addError(stack, message, mergedProperties);\n }\n addErrorWithType(\n type: string,\n stack: string,\n message: string,\n property?: object\n ): Promise<void> {\n // Automatically merge bridge context properties with local properties\n const mergedProperties =\n bridgeContextManager.mergeWithLocalPropertiesSync(property);\n return this.rum.addErrorWithType(type, stack, message, mergedProperties);\n }\n startResource(key: string, property?: object): Promise<void> {\n // Automatically merge bridge context properties with local properties\n const mergedProperties =\n bridgeContextManager.mergeWithLocalPropertiesSync(property);\n return this.rum.startResource(key, mergedProperties);\n }\n stopResource(key: string, property?: object): Promise<void> {\n // Automatically merge bridge context properties with local properties\n const mergedProperties =\n bridgeContextManager.mergeWithLocalPropertiesSync(property);\n return this.rum.stopResource(key, mergedProperties);\n }\n addResource(\n key: string,\n resource: FTRUMResource,\n metrics: FTRUMResourceMetrics = {}\n ): Promise<void> {\n return this.rum.addResource(key, resource, metrics);\n }\n}\n\nexport const FTReactNativeRUM: FTReactNativeRUMType =\n new FTReactNativeRUMWrapper();\n"],"mappings":";;;AAAA;AACA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SAASC,kBAAkB,QAAQ,0BAA0B;AAC7D,SAASC,mBAAmB,QAAQ,2BAA2B;AAC/D,SAASC,0BAA0B,QAAQ,kCAAkC;AAC7E,SAASC,sBAAsB,QAAQ,8BAA8B;AACrE,SAASC,oBAAoB,QAAQ,mBAAmB;AACxD,SAASC,0BAA0B,QAAQ,sBAAsB;;AAEjE;AACA;AACA;AACA;AACA,WAAYC,gBAAgB,0BAAhBA,gBAAgB;EAAhBA,gBAAgB,CAAhBA,gBAAgB;EAAhBA,gBAAgB,CAAhBA,gBAAgB;EAAhBA,gBAAgB,CAAhBA,gBAAgB;EAAhBA,gBAAgB,CAAhBA,gBAAgB;EAAA,OAAhBA,gBAAgB;AAAA;AAM5B;AACA;AACA;AACA,WAAYC,wBAAwB,0BAAxBA,wBAAwB;EAAxBA,wBAAwB,CAAxBA,wBAAwB;EAAxBA,wBAAwB,CAAxBA,wBAAwB;EAAxBA,wBAAwB,CAAxBA,wBAAwB;EAAxBA,wBAAwB,CAAxBA,wBAAwB;EAAxBA,wBAAwB,CAAxBA,wBAAwB;EAAA,OAAxBA,wBAAwB;AAAA;AAOpC;AACA;AACA;AACA,WAAYC,eAAe,0BAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA;AAM3B,WAAYC,iBAAiB,0BAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB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AC7D,OAAO,IAAI,CAACG,GAAG,CAACY,QAAQ,CAACC,KAAK,EAAEC,OAAO,EAAEV,gBAAgB,CAAC;EAC5D;EACAW,gBAAgBA,CACdC,IAAY,EACZH,KAAa,EACbC,OAAe,EACfjB,QAAiB,EACF;IACf;IACA,MAAMO,gBAAgB,GACpB5C,oBAAoB,CAAC6C,4BAA4B,CAACR,QAAQ,CAAC;IAC7D,OAAO,IAAI,CAACG,GAAG,CAACe,gBAAgB,CAACC,IAAI,EAAEH,KAAK,EAAEC,OAAO,EAAEV,gBAAgB,CAAC;EAC1E;EACAa,aAAaA,CAACC,GAAW,EAAErB,QAAiB,EAAiB;IAC3D;IACA,MAAMO,gBAAgB,GACpB5C,oBAAoB,CAAC6C,4BAA4B,CAACR,QAAQ,CAAC;IAC7D,OAAO,IAAI,CAACG,GAAG,CAACiB,aAAa,CAACC,GAAG,EAAEd,gBAAgB,CAAC;EACtD;EACAe,YAAYA,CAACD,GAAW,EAAErB,QAAiB,EAAiB;IAC1D;IACA,MAAMO,gBAAgB,GACpB5C,oBAAoB,CAAC6C,4BAA4B,CAACR,QAAQ,CAAC;IAC7D,OAAO,IAAI,CAACG,GAAG,CAACmB,YAAY,CAACD,GAAG,EAAEd,gBAAgB,CAAC;EACrD;EACAgB,WAAWA,CACTF,GAAW,EACXG,QAAuB,EACvBC,OAA6B,GAAG,CAAC,CAAC,EACnB;IACf,OAAO,IAAI,CAACtB,GAAG,CAACoB,WAAW,CAACF,GAAG,EAAEG,QAAQ,EAAEC,OAAO,CAAC;EACrD;AACF;AAEA,OAAO,MAAMC,gBAAsC,GACjD,IAAIpD,uBAAuB,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["validateVisitorIdConfig","Platform","FTRumErrorTracking","FTRumActionTracking","FTBabelInteractionTracking","FTRumWebSocketTracking","bridgeContextManager","normalizeLongTaskThreshold","ErrorMonitorType","DeviceMetricsMonitorType","DetectFrequency","FTRUMCacheDiscard","IOSCrashMonitoringType","isBabelPluginEnabled","globalThis","__FT_RN_BABEL_PLUGIN_ENABLED__","global","FTReactNativeRUMWrapper","constructor","_defineProperty","require","default","setConfig","config","visitorIdConfig","error","Promise","reject","configureLongTaskContext","enableLongTask","webSocketLifecycle","getLifecycleVersion","webSocketConfigVersion","trackWebSocket","enableIOSWebSocketResource","console","log","enableAutoTrackError","startTracking","babelPluginEnabled","configure","trackInteractions","Boolean","enableAutoTrackUserAction","actionReporter","actionName","actionType","property","startAction","stopTracking","rum","longTaskThresholdMs","then","OS","mergedProperties","mergeWithLocalPropertiesSync","addAction","onCreateView","viewName","loadTime","updateViewLoadingTime","duration","Number","isSafeInteger","RangeError","startView","stopView","addError","stack","message","addErrorWithType","type","startResource","key","stopResource","addResource","resource","metrics","FTReactNativeRUM"],"sources":["ft_rum.tsx"],"sourcesContent":["import { FTVisitorIdConfig, validateVisitorIdConfig } from './visitorIdConfig';\n// import { NativeModules } from 'react-native';\nimport { Platform } from 'react-native';\nimport { FTRumErrorTracking } from './rum/FTRumErrorTracking';\nimport { FTRumActionTracking } from './rum/FTRumActionTracking';\nimport { FTBabelInteractionTracking } from './rum/FTBabelInteractionTracking';\nimport { FTRumWebSocketTracking } from './rum/FTRumWebSocketTracking';\nimport { bridgeContextManager } from './ft_mobile_agent';\nimport { normalizeLongTaskThreshold } from './rum/longTasksUtils';\n\n/**\n * Error monitoring type.\n */\n/* eslint-disable no-bitwise */\nexport enum ErrorMonitorType {\n all = 0xffffffff,\n battery = 1 << 1,\n memory = 1 << 2,\n cpu = 1 << 3,\n}\n/**\n * Page monitoring supplement type\n */\nexport enum DeviceMetricsMonitorType {\n all = 0xffffffff,\n battery = 1 << 1,\n memory = 1 << 2,\n cpu = 1 << 3,\n fps = 1 << 4,\n}\n/**\n * Device information monitoring cycle.\n */\nexport enum DetectFrequency {\n normal,\n frequent,\n rare,\n}\n\nexport enum FTRUMCacheDiscard {\n discard,\n discardOldest,\n}\n\nexport enum IOSCrashMonitoringType {\n /** Monitor Mach kernel exceptions. */\n machException = 0x01,\n\n /** Monitor fatal signals. */\n signal = 0x02,\n\n /** Monitor uncaught C++ exceptions. */\n cppException = 0x04,\n\n /** Monitor uncaught Objective-C NSExceptions. */\n nsException = 0x08,\n\n /** Track and inject system information. */\n system = 0x40,\n\n /** Track and inject application state information. */\n applicationState = 0x80,\n\n /** All crash monitor types. */\n all = machException |\n signal |\n cppException |\n nsException |\n applicationState |\n system,\n\n /** High compatibility crash monitor types (excludes Mach exceptions). */\n highCompatibility = all & ~machException,\n}\n/* eslint-enable no-bitwise */\n/**\n * Set RUM tracking conditions.\n * @param androidAppId appId, apply during monitoring\n * @param iOSAppId appId, apply during monitoring\n * @param sessionSamplingRate RUM session sampling percentage in [0, 100], default 100. Supports fractional percentages and takes precedence over sampleRate.\n * @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.\n * @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.\n * @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.\n * @param enableAutoTrackUserAction whether to automatically collect react-native control click events, can set actionName with accessibilityLabel when enabled\n * @param enableTrackError whether to automatically collect react-native Error\n * @param enableTrackNativeCrash whether to collect Native Error\n * @param enableTrackNativeAppANR whether to collect Native ANR\n * @param enableTrackNativeFreeze whether to collect Native Freeze\n * @param nativeFreezeDurationMs set the threshold for collecting Native Freeze, value range [100,), unit ms. iOS default 250ms, Android default 1000ms\n * @param enableLongTask whether to collect React Native JavaScript LongTasks, default false\n * @param longTaskThresholdMs set the threshold for collecting React Native JavaScript LongTasks, unit ms. Defaults to 100 and is clamped to [100, 5000]\n * @param enableNativeUserAction whether to start Native Action tracking, Button click events, recommended to disable for pure react-native apps\n * @param enableNativeUserView whether to start Native View auto tracking, recommended to disable for pure react-native apps\n * @param enableNativeUserResource whether to automatically collect react-native Resource\n * @param enableIOSWebSocketResource whether to collect iOS WebSocket opening handshakes as RUM Resources. Defaults to false.\n * Independent of enableNativeUserResource. Android native WebSocket collection is unaffected.\n * iOS WebSocket Trace header injection requires both this option and enableNativeAutoTrace.\n * When disabled, new iOS WebSocket connections are not instrumented or automatically injected with Trace headers by this SDK.\n * @param enableResourceHostIP whether to collect network request Host IP (only for native http, iOS 13 and above)\n * @param errorMonitorType error monitoring supplement type\n * @param deviceMonitorType page monitoring supplement type\n * @param detectFrequency monitoring frequency\n * @param globalContext custom global parameters\n * @param rumCacheLimitCount RUM max cache size, default 100_000\n * @param rumDiscardStrategy RUM data discard strategy\n * @param enableTraceWebView Set whether to enable WebView data collection, default true\n * @param allowWebViewHost Deprecated; use FTMobileConfig.allowWebViewHost for shared WebView host filtering.\n * @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.\n */\nexport interface FTRUMConfig {\n /** Valid config enables Visitor ID; omitted/null disables it. */\n visitorIdConfig?: FTVisitorIdConfig | null;\n androidAppId: string;\n iOSAppId: string;\n /**\n * RUM session 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 * Setting 0 disables regular session sampling; error session sampling is separate.\n */\n sessionSamplingRate?: number;\n /** @deprecated Use sessionSamplingRate. Probability in [0, 1], default 1; 0.125 maps to 12.5%. Ignored when sessionSamplingRate is supplied. */\n sampleRate?: number;\n /**\n * Sampling percentage for otherwise unsampled RUM sessions when an error occurs.\n * Range [0, 100], default 0; fractional percentages are supported.\n * Takes precedence over sessionOnErrorSampleRate when both are supplied, including 0.\n */\n sessionOnErrorSamplingRate?: number;\n /** @deprecated Use sessionOnErrorSamplingRate. Probability in [0, 1], default 0; multiplied by 100. Ignored when sessionOnErrorSamplingRate is supplied. */\n sessionOnErrorSampleRate?: number;\n enableAutoTrackUserAction?: boolean;\n enableAutoTrackError?: boolean;\n enableTrackNativeCrash?: boolean;\n enableTrackNativeAppANR?: boolean;\n enableTrackNativeFreeze?: boolean;\n nativeFreezeDurationMs?: number;\n enableLongTask?: boolean;\n longTaskThresholdMs?: number;\n enableNativeUserAction?: boolean;\n enableNativeUserView?: boolean;\n enableNativeUserResource?: boolean;\n enableIOSWebSocketResource?: boolean;\n enableResourceHostIP?: boolean;\n errorMonitorType?: ErrorMonitorType;\n deviceMonitorType?: DeviceMetricsMonitorType;\n detectFrequency?: DetectFrequency;\n globalContext?: object;\n rumCacheLimitCount?: number;\n rumDiscardStrategy?: FTRUMCacheDiscard;\n enableTraceWebView?: boolean;\n /** @deprecated Configure the shared host allowlist in FTMobileConfig.allowWebViewHost. */\n allowWebViewHost?: Array<string> | null;\n iosCrashMonitoringType?: IOSCrashMonitoringType;\n}\n/**\n * RUM Resource data.\n * @param url request URL\n * @param httpMethod request method\n * @param requestHeader request header parameters\n * @param responseHeader response header parameters\n * @param responseBody response content\n * @param resourceStatus response status code\n */\nexport interface FTRUMResource {\n url: string;\n httpMethod: string;\n requestHeader: object;\n responseHeader?: object;\n responseBody?: string;\n resourceStatus?: number;\n}\n/**\n * RUM Resource performance metrics.\n * @param duration resource load time\n * @param resource_dns resource DNS resolution time\n * @param resource_tcp resource TCP connection time\n * @param resource_ssl resource SSL connection time\n * @param resource_ttfb resource request response time\n * @param resource_trans resource content transfer time\n * @param resource_first_byte resource first byte time\n */\nexport interface FTRUMResourceMetrics {\n duration?: number;\n resource_dns?: number;\n resource_tcp?: number;\n resource_ssl?: number;\n resource_ttfb?: number;\n resource_trans?: number;\n resource_first_byte?: number;\n}\ntype FTReactNativeRUMType = {\n /**\n * Set RUM tracking conditions and enable RUM collection.\n * @param config rum configuration parameters.\n * @returns a Promise.\n */\n setConfig(config: FTRUMConfig): 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 /**\n * Replace the current active View's loading duration, between startView and stopView.\n * @param duration monotonic elapsed time in nanoseconds; a non-negative safe integer.\n * Zero clears loading time. Late calls can update a newer View; no View ID is supplied.\n * @returns a Promise for the native call, not for data upload.\n */\n updateViewLoadingTime(duration: 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(\n key: string,\n resource: FTRUMResource,\n metrics?: FTRUMResourceMetrics\n ): Promise<void>;\n};\n\nfunction isBabelPluginEnabled(): boolean {\n if (typeof globalThis !== 'undefined') {\n return globalThis.__FT_RN_BABEL_PLUGIN_ENABLED__ === true;\n }\n if (typeof global !== 'undefined') {\n return global.__FT_RN_BABEL_PLUGIN_ENABLED__ === true;\n }\n return false;\n}\n\nclass FTReactNativeRUMWrapper implements FTReactNativeRUMType {\n private webSocketConfigVersion = 0;\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n private rum: FTReactNativeRUMType = require('./specs/NativeFTReactNativeRUM')\n .default;\n\n setConfig(config: FTRUMConfig): Promise<void> {\n if (config.visitorIdConfig != null) {\n try {\n validateVisitorIdConfig(config.visitorIdConfig);\n } catch (error) {\n return Promise.reject(error);\n }\n }\n bridgeContextManager.configureLongTaskContext(\n config.enableLongTask === true\n );\n const webSocketLifecycle = FTRumWebSocketTracking.getLifecycleVersion();\n const webSocketConfigVersion = ++this.webSocketConfigVersion;\n const trackWebSocket = config.enableIOSWebSocketResource === true;\n console.log('FTRUMConfig');\n if (config.enableAutoTrackError) {\n FTRumErrorTracking.startTracking();\n }\n const babelPluginEnabled = isBabelPluginEnabled();\n FTBabelInteractionTracking.configure({\n trackInteractions:\n babelPluginEnabled && Boolean(config.enableAutoTrackUserAction),\n actionReporter: (actionName, actionType, property) =>\n this.startAction(actionName, actionType, property),\n });\n if (config.enableAutoTrackUserAction && !babelPluginEnabled) {\n FTRumActionTracking.startTracking();\n } else {\n FTRumActionTracking.stopTracking();\n }\n return this.rum\n .setConfig({\n ...config,\n enableLongTask: config.enableLongTask === true,\n longTaskThresholdMs: normalizeLongTaskThreshold(\n config.longTaskThresholdMs\n ),\n })\n .then(() => {\n if (\n webSocketLifecycle !== FTRumWebSocketTracking.getLifecycleVersion() ||\n webSocketConfigVersion !== this.webSocketConfigVersion\n ) {\n return;\n }\n if (Platform.OS === 'ios' && trackWebSocket) {\n FTRumWebSocketTracking.startTracking(this);\n } else {\n FTRumWebSocketTracking.stopTracking();\n }\n });\n }\n startAction(\n actionName: string,\n actionType: string,\n property?: object\n ): Promise<void> {\n // Automatically merge bridge context properties with local properties\n const mergedProperties =\n bridgeContextManager.mergeWithLocalPropertiesSync(property);\n return this.rum.startAction(actionName, actionType, mergedProperties);\n }\n addAction(\n actionName: string,\n actionType: string,\n property?: object\n ): Promise<void> {\n // Automatically merge bridge context properties with local properties\n const mergedProperties =\n bridgeContextManager.mergeWithLocalPropertiesSync(property);\n return this.rum.addAction(actionName, actionType, mergedProperties);\n }\n onCreateView(viewName: string, loadTime: number): Promise<void> {\n return this.rum.onCreateView(viewName, loadTime);\n }\n updateViewLoadingTime(duration: number): Promise<void> {\n if (!Number.isSafeInteger(duration) || duration < 0) {\n return Promise.reject(\n new RangeError(\n 'duration must be a non-negative safe integer in nanoseconds'\n )\n );\n }\n return this.rum.updateViewLoadingTime(duration);\n }\n startView(viewName: string, property?: object): Promise<void> {\n // Automatically merge bridge context properties with local properties\n const mergedProperties =\n bridgeContextManager.mergeWithLocalPropertiesSync(property);\n return this.rum.startView(viewName, mergedProperties);\n }\n stopView(property?: object): Promise<void> {\n // Automatically merge bridge context properties with local properties\n const mergedProperties =\n bridgeContextManager.mergeWithLocalPropertiesSync(property);\n return this.rum.stopView(mergedProperties);\n }\n addError(stack: string, message: string, property?: object): Promise<void> {\n // Automatically merge bridge context properties with local properties\n const mergedProperties =\n bridgeContextManager.mergeWithLocalPropertiesSync(property);\n return this.rum.addError(stack, message, mergedProperties);\n }\n addErrorWithType(\n type: string,\n stack: string,\n message: string,\n property?: object\n ): Promise<void> {\n // Automatically merge bridge context properties with local properties\n const mergedProperties =\n bridgeContextManager.mergeWithLocalPropertiesSync(property);\n return this.rum.addErrorWithType(type, stack, message, mergedProperties);\n }\n startResource(key: string, property?: object): Promise<void> {\n // Automatically merge bridge context properties with local properties\n const mergedProperties =\n bridgeContextManager.mergeWithLocalPropertiesSync(property);\n return this.rum.startResource(key, mergedProperties);\n }\n stopResource(key: string, property?: object): Promise<void> {\n // Automatically merge bridge context properties with local properties\n const mergedProperties =\n bridgeContextManager.mergeWithLocalPropertiesSync(property);\n return this.rum.stopResource(key, mergedProperties);\n }\n addResource(\n key: string,\n resource: FTRUMResource,\n metrics: FTRUMResourceMetrics = {}\n ): Promise<void> {\n return this.rum.addResource(key, resource, metrics);\n }\n}\n\nexport const FTReactNativeRUM: FTReactNativeRUMType =\n new FTReactNativeRUMWrapper();\n"],"mappings":";;;AAAA,SAA4BA,uBAAuB,QAAQ,mBAAmB;AAC9E;AACA,SAASC,QAAQ,QAAQ,cAAc;AACvC,SAASC,kBAAkB,QAAQ,0BAA0B;AAC7D,SAASC,mBAAmB,QAAQ,2BAA2B;AAC/D,SAASC,0BAA0B,QAAQ,kCAAkC;AAC7E,SAASC,sBAAsB,QAAQ,8BAA8B;AACrE,SAASC,oBAAoB,QAAQ,mBAAmB;AACxD,SAASC,0BAA0B,QAAQ,sBAAsB;;AAEjE;AACA;AACA;AACA;AACA,WAAYC,gBAAgB,0BAAhBA,gBAAgB;EAAhBA,gBAAgB,CAAhBA,gBAAgB;EAAhBA,gBAAgB,CAAhBA,gBAAgB;EAAhBA,gBAAgB,CAAhBA,gBAAgB;EAAhBA,gBAAgB,CAAhBA,gBAAgB;EAAA,OAAhBA,gBAAgB;AAAA;AAM5B;AACA;AACA;AACA,WAAYC,wBAAwB,0BAAxBA,wBAAwB;EAAxBA,wBAAwB,CAAxBA,wBAAwB;EAAxBA,wBAAwB,CAAxBA,wBAAwB;EAAxBA,wBAAwB,CAAxBA,wBAAwB;EAAxBA,wBAAwB,CAAxBA,wBAAwB;EAAxBA,wBAAwB,CAAxBA,wBAAwB;EAAA,OAAxBA,wBAAwB;AAAA;AAOpC;AACA;AACA;AACA,WAAYC,eAAe,0BAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAfA,eAAe,CAAfA,eAAe;EAAfA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;IAC1D;IACA,MAAMO,gBAAgB,GACpBhD,oBAAoB,CAACiD,4BAA4B,CAACR,QAAQ,CAAC;IAC7D,OAAO,IAAI,CAACG,GAAG,CAACwB,YAAY,CAACD,GAAG,EAAEnB,gBAAgB,CAAC;EACrD;EACAqB,WAAWA,CACTF,GAAW,EACXG,QAAuB,EACvBC,OAA6B,GAAG,CAAC,CAAC,EACnB;IACf,OAAO,IAAI,CAAC3B,GAAG,CAACyB,WAAW,CAACF,GAAG,EAAEG,QAAQ,EAAEC,OAAO,CAAC;EACrD;AACF;AAEA,OAAO,MAAMC,gBAAsC,GACjD,IAAI7D,uBAAuB,CAAC,CAAC","ignoreList":[]}
|
package/lib/module/ft_tracing.js
CHANGED
|
@@ -39,7 +39,8 @@ export let TraceType = /*#__PURE__*/function (TraceType) {
|
|
|
39
39
|
}({});
|
|
40
40
|
/**
|
|
41
41
|
* Configure trace.
|
|
42
|
-
* @param
|
|
42
|
+
* @param traceSamplingRate Trace sampling percentage in [0, 100], default 100. Supports fractional percentages and takes precedence over sampleRate.
|
|
43
|
+
* @param sampleRate Deprecated Trace sampling probability in [0, 1], default 1. Used only when traceSamplingRate is omitted; multiplied by 100 before passing to Native.
|
|
43
44
|
* @param traceType trace type
|
|
44
45
|
* @param enableLinkRUMData whether to link with RUM data
|
|
45
46
|
* @param enableNativeAutoTrace whether to enable automatic tracing
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FTRumWebSocketTracking","TraceType","FTReactNativeTraceWrapper","constructor","_defineProperty","require","default","setConfig","config","webSocketLifecycle","getLifecycleVersion","webSocketConfigVersion","traceWebSocket","enableNativeAutoTrace","trace","then","setNativeAutoTraceEnabled","getTraceHeader","key","url","getTraceHeaderFields","FTReactNativeTrace"],"sources":["ft_tracing.tsx"],"sourcesContent":["// import { NativeModules } from 'react-native';\n//FTReactNativeTrace\n\nimport { FTRumWebSocketTracking } from './rum/FTRumWebSocketTracking';\n\n/**\n * Trace types for use.\n */\nexport enum TraceType {\n //\n // datadog trace\n //\n // x-datadog-trace-id\n // x-datadog-parent-id\n // x-datadog-sampling-priority\n // x-datadog-origin\n //\n ddTrace,\n //\n // zipkin multi header\n //\n // X-B3-TraceId\n // X-B3-SpanId\n // X-B3-Sampled\n //\n zipkinMulti,\n /// zipkin single header,b3\n zipkinSingle,\n // w3c, traceparent\n traceparent,\n // skywalking 8.0+, sw-8\n skywalking,\n // jaeger, header uber-trace-id\n jaeger,\n}\n/**\n * Configure trace.\n * @param sampleRate sampling
|
|
1
|
+
{"version":3,"names":["FTRumWebSocketTracking","TraceType","FTReactNativeTraceWrapper","constructor","_defineProperty","require","default","setConfig","config","webSocketLifecycle","getLifecycleVersion","webSocketConfigVersion","traceWebSocket","enableNativeAutoTrace","trace","then","setNativeAutoTraceEnabled","getTraceHeader","key","url","getTraceHeaderFields","FTReactNativeTrace"],"sources":["ft_tracing.tsx"],"sourcesContent":["// import { NativeModules } from 'react-native';\n//FTReactNativeTrace\n\nimport { FTRumWebSocketTracking } from './rum/FTRumWebSocketTracking';\n\n/**\n * Trace types for use.\n */\nexport enum TraceType {\n //\n // datadog trace\n //\n // x-datadog-trace-id\n // x-datadog-parent-id\n // x-datadog-sampling-priority\n // x-datadog-origin\n //\n ddTrace,\n //\n // zipkin multi header\n //\n // X-B3-TraceId\n // X-B3-SpanId\n // X-B3-Sampled\n //\n zipkinMulti,\n /// zipkin single header,b3\n zipkinSingle,\n // w3c, traceparent\n traceparent,\n // skywalking 8.0+, sw-8\n skywalking,\n // jaeger, header uber-trace-id\n jaeger,\n}\n/**\n * Configure trace.\n * @param traceSamplingRate Trace sampling percentage in [0, 100], default 100. Supports fractional percentages and takes precedence over sampleRate.\n * @param sampleRate Deprecated Trace sampling probability in [0, 1], default 1. Used only when traceSamplingRate is omitted; multiplied by 100 before passing to Native.\n * @param traceType trace type\n * @param enableLinkRUMData whether to link with RUM data\n * @param enableNativeAutoTrace whether to enable automatic tracing\n */\nexport interface FTTraceConfig {\n /**\n * Trace 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 traceSamplingRate?: number;\n /** @deprecated Use traceSamplingRate. Probability in [0, 1], default 1; 0.125 maps to 12.5%. Ignored when traceSamplingRate is supplied. */\n sampleRate?: number;\n traceType?: TraceType;\n enableLinkRUMData?: boolean;\n enableNativeAutoTrace?: boolean;\n}\n\ntype FTReactNativeTraceType = {\n /**\n * Configure trace to enable distributed tracing.\n * @param config trace configuration parameters.\n * @returns a Promise.\n */\n setConfig(config: FTTraceConfig): 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\nclass FTReactNativeTraceWrapper implements FTReactNativeTraceType {\n private webSocketConfigVersion = 0;\n /* eslint-disable @typescript-eslint/no-var-requires */\n private trace: FTReactNativeTraceType =\n require('./specs/NativeFTReactNativeTrace').default;\n /* eslint-enable @typescript-eslint/no-var-requires */\n\n setConfig(config: FTTraceConfig): Promise<void> {\n const webSocketLifecycle = FTRumWebSocketTracking.getLifecycleVersion();\n const webSocketConfigVersion = ++this.webSocketConfigVersion;\n const traceWebSocket = config.enableNativeAutoTrace === true;\n return this.trace.setConfig(config).then(() => {\n if (\n webSocketLifecycle !== FTRumWebSocketTracking.getLifecycleVersion() ||\n webSocketConfigVersion !== this.webSocketConfigVersion\n ) {\n return;\n }\n FTRumWebSocketTracking.setNativeAutoTraceEnabled(traceWebSocket);\n });\n }\n /**\n * Get trace HTTP request header data.\n * @param key unique id\n * @param url request URL\n * @returns a Promise.\n */\n getTraceHeader(key: string, url: string): Promise<object> {\n return this.trace.getTraceHeaderFields(url, key);\n }\n /**\n * Get trace HTTP request header data.\n * @param url request URL\n * @param key unique id\n * @returns a Promise.\n */\n getTraceHeaderFields(url: string, key?: string): Promise<object> {\n return this.trace.getTraceHeaderFields(url, key);\n }\n}\nexport const FTReactNativeTrace: FTReactNativeTraceType =\n new FTReactNativeTraceWrapper();\n"],"mappings":";;;AAAA;AACA;;AAEA,SAASA,sBAAsB,QAAQ,8BAA8B;;AAErE;AACA;AACA;AACA,WAAYC,SAAS,0BAATA,SAAS;EACnB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EARUA,SAAS,CAATA,SAAS;EAUnB;EACA;EACA;EACA;EACA;EACA;EACA;EAhBUA,SAAS,CAATA,SAAS;EAkBnB;EAlBUA,SAAS,CAATA,SAAS;EAoBnB;EApBUA,SAAS,CAATA,SAAS;EAsBnB;EAtBUA,SAAS,CAATA,SAAS;EAwBnB;EAxBUA,SAAS,CAATA,SAAS;EAAA,OAATA,SAAS;AAAA;AA2BrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqCA,MAAMC,yBAAyB,CAAmC;EAAAC,YAAA;IAAAC,eAAA,iCAC/B,CAAC;IAClC;IAAAA,eAAA,gBAEEC,OAAO,CAAC,kCAAkC,CAAC,CAACC,OAAO;EAAA;EACrD;;EAEAC,SAASA,CAACC,MAAqB,EAAiB;IAC9C,MAAMC,kBAAkB,GAAGT,sBAAsB,CAACU,mBAAmB,CAAC,CAAC;IACvE,MAAMC,sBAAsB,GAAG,EAAE,IAAI,CAACA,sBAAsB;IAC5D,MAAMC,cAAc,GAAGJ,MAAM,CAACK,qBAAqB,KAAK,IAAI;IAC5D,OAAO,IAAI,CAACC,KAAK,CAACP,SAAS,CAACC,MAAM,CAAC,CAACO,IAAI,CAAC,MAAM;MAC7C,IACEN,kBAAkB,KAAKT,sBAAsB,CAACU,mBAAmB,CAAC,CAAC,IACnEC,sBAAsB,KAAK,IAAI,CAACA,sBAAsB,EACtD;QACA;MACF;MACAX,sBAAsB,CAACgB,yBAAyB,CAACJ,cAAc,CAAC;IAClE,CAAC,CAAC;EACJ;EACA;AACF;AACA;AACA;AACA;AACA;EACEK,cAAcA,CAACC,GAAW,EAAEC,GAAW,EAAmB;IACxD,OAAO,IAAI,CAACL,KAAK,CAACM,oBAAoB,CAACD,GAAG,EAAED,GAAG,CAAC;EAClD;EACA;AACF;AACA;AACA;AACA;AACA;EACEE,oBAAoBA,CAACD,GAAW,EAAED,GAAY,EAAmB;IAC/D,OAAO,IAAI,CAACJ,KAAK,CAACM,oBAAoB,CAACD,GAAG,EAAED,GAAG,CAAC;EAClD;AACF;AACA,OAAO,MAAMG,kBAA0C,GACrD,IAAInB,yBAAyB,CAAC,CAAC","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -7,4 +7,5 @@ import { FTRumErrorTracking } from './rum/FTRumErrorTracking';
|
|
|
7
7
|
import { FTBabelInteractionTracking } from './rum/FTBabelInteractionTracking';
|
|
8
8
|
import { __ftExtractText } from './rum/FTBabelUtils';
|
|
9
9
|
export { FTMobileReactNative, FTMobileConfig, EnvType, FTDBCacheDiscard, FTRemoteConfigResult, FTRemoteConfigOverrideRule, FTRemoteConfigOverrideMatch, FTRemoteConfigOverrideValues, FTLogConfig, FTReactNativeLog, FTLogStatus, FTLogCacheDiscard, FTRUMConfig, FTReactNativeRUM, FTRUMResource, ErrorMonitorType, DeviceMetricsMonitorType, DetectFrequency, FTRUMResourceMetrics, FTRUMCacheDiscard, IOSCrashMonitoringType, FTTraceConfig, FTReactNativeTrace, TraceType, FTRumActionTracking, FTRumErrorTracking, FTBabelInteractionTracking, __ftExtractText };
|
|
10
|
+
export { FTRumViewTracking } from './rum/FTRumViewTracking';
|
|
10
11
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FTMobileConfig","FTMobileReactNative","EnvType","FTDBCacheDiscard","FTRemoteConfigResult","FTRemoteConfigOverrideRule","FTRemoteConfigOverrideMatch","FTRemoteConfigOverrideValues","FTLogConfig","FTReactNativeLog","FTLogStatus","FTLogCacheDiscard","FTRUMConfig","FTRUMResource","FTReactNativeRUM","ErrorMonitorType","DeviceMetricsMonitorType","DetectFrequency","FTRUMResourceMetrics","FTRUMCacheDiscard","IOSCrashMonitoringType","FTTraceConfig","FTReactNativeTrace","TraceType","FTRumActionTracking","FTRumErrorTracking","FTBabelInteractionTracking","__ftExtractText"],"sources":["index.tsx"],"sourcesContent":["import {\n FTMobileConfig,\n FTMobileReactNative,\n EnvType,\n FTDBCacheDiscard,\n FTRemoteConfigResult,\n FTRemoteConfigOverrideRule,\n FTRemoteConfigOverrideMatch,\n FTRemoteConfigOverrideValues,\n} from './ft_mobile_agent';\nimport {\n FTLogConfig,\n FTReactNativeLog,\n FTLogStatus,\n FTLogCacheDiscard,\n} from './ft_logger';\nimport {\n FTRUMConfig,\n FTRUMResource,\n FTReactNativeRUM,\n ErrorMonitorType,\n DeviceMetricsMonitorType,\n DetectFrequency,\n FTRUMResourceMetrics,\n FTRUMCacheDiscard,\n IOSCrashMonitoringType,\n} from './ft_rum';\nimport { FTTraceConfig, FTReactNativeTrace, TraceType } from './ft_tracing';\nimport { FTRumActionTracking } from './rum/FTRumActionTracking';\nimport { FTRumErrorTracking } from './rum/FTRumErrorTracking';\nimport { FTBabelInteractionTracking } from './rum/FTBabelInteractionTracking';\nimport { __ftExtractText } from './rum/FTBabelUtils';\n\nexport {\n FTMobileReactNative,\n FTMobileConfig,\n EnvType,\n FTDBCacheDiscard,\n FTRemoteConfigResult,\n FTRemoteConfigOverrideRule,\n FTRemoteConfigOverrideMatch,\n FTRemoteConfigOverrideValues,\n FTLogConfig,\n FTReactNativeLog,\n FTLogStatus,\n FTLogCacheDiscard,\n FTRUMConfig,\n FTReactNativeRUM,\n FTRUMResource,\n ErrorMonitorType,\n DeviceMetricsMonitorType,\n DetectFrequency,\n FTRUMResourceMetrics,\n FTRUMCacheDiscard,\n IOSCrashMonitoringType,\n FTTraceConfig,\n FTReactNativeTrace,\n TraceType,\n FTRumActionTracking,\n FTRumErrorTracking,\n FTBabelInteractionTracking,\n __ftExtractText,\n};\n"],"mappings":"AAAA,SACEA,cAAc,EACdC,mBAAmB,EACnBC,OAAO,EACPC,gBAAgB,EAChBC,oBAAoB,EACpBC,0BAA0B,EAC1BC,2BAA2B,EAC3BC,4BAA4B,QACvB,mBAAmB;AAC1B,SACEC,WAAW,EACXC,gBAAgB,EAChBC,WAAW,EACXC,iBAAiB,QACZ,aAAa;AACpB,SACEC,WAAW,EACXC,aAAa,EACbC,gBAAgB,EAChBC,gBAAgB,EAChBC,wBAAwB,EACxBC,eAAe,EACfC,oBAAoB,EACpBC,iBAAiB,EACjBC,sBAAsB,QACjB,UAAU;AACjB,SAASC,aAAa,EAAEC,kBAAkB,EAAEC,SAAS,QAAQ,cAAc;AAC3E,SAASC,mBAAmB,QAAQ,2BAA2B;AAC/D,SAASC,kBAAkB,QAAQ,0BAA0B;AAC7D,SAASC,0BAA0B,QAAQ,kCAAkC;AAC7E,SAASC,eAAe,QAAQ,oBAAoB;AAEpD,SACE1B,mBAAmB,EACnBD,cAAc,EACdE,OAAO,EACPC,gBAAgB,EAChBC,oBAAoB,EACpBC,0BAA0B,EAC1BC,2BAA2B,EAC3BC,4BAA4B,EAC5BC,WAAW,EACXC,gBAAgB,EAChBC,WAAW,EACXC,iBAAiB,EACjBC,WAAW,EACXE,gBAAgB,EAChBD,aAAa,EACbE,gBAAgB,EAChBC,wBAAwB,EACxBC,eAAe,EACfC,oBAAoB,EACpBC,iBAAiB,EACjBC,sBAAsB,EACtBC,aAAa,EACbC,kBAAkB,EAClBC,SAAS,EACTC,mBAAmB,EACnBC,kBAAkB,EAClBC,0BAA0B,EAC1BC,eAAe","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["FTMobileConfig","FTMobileReactNative","EnvType","FTDBCacheDiscard","FTRemoteConfigResult","FTRemoteConfigOverrideRule","FTRemoteConfigOverrideMatch","FTRemoteConfigOverrideValues","FTLogConfig","FTReactNativeLog","FTLogStatus","FTLogCacheDiscard","FTRUMConfig","FTRUMResource","FTReactNativeRUM","ErrorMonitorType","DeviceMetricsMonitorType","DetectFrequency","FTRUMResourceMetrics","FTRUMCacheDiscard","IOSCrashMonitoringType","FTTraceConfig","FTReactNativeTrace","TraceType","FTRumActionTracking","FTRumErrorTracking","FTBabelInteractionTracking","__ftExtractText","FTRumViewTracking"],"sources":["index.tsx"],"sourcesContent":["import {\n FTMobileConfig,\n FTMobileReactNative,\n EnvType,\n FTDBCacheDiscard,\n FTRemoteConfigResult,\n FTRemoteConfigOverrideRule,\n FTRemoteConfigOverrideMatch,\n FTRemoteConfigOverrideValues,\n} from './ft_mobile_agent';\nimport {\n FTLogConfig,\n FTReactNativeLog,\n FTLogStatus,\n FTLogCacheDiscard,\n} from './ft_logger';\nimport {\n FTRUMConfig,\n FTRUMResource,\n FTReactNativeRUM,\n ErrorMonitorType,\n DeviceMetricsMonitorType,\n DetectFrequency,\n FTRUMResourceMetrics,\n FTRUMCacheDiscard,\n IOSCrashMonitoringType,\n} from './ft_rum';\nimport { FTTraceConfig, FTReactNativeTrace, TraceType } from './ft_tracing';\nimport { FTRumActionTracking } from './rum/FTRumActionTracking';\nimport { FTRumErrorTracking } from './rum/FTRumErrorTracking';\nimport { FTBabelInteractionTracking } from './rum/FTBabelInteractionTracking';\nimport { __ftExtractText } from './rum/FTBabelUtils';\n\nexport {\n FTMobileReactNative,\n FTMobileConfig,\n EnvType,\n FTDBCacheDiscard,\n FTRemoteConfigResult,\n FTRemoteConfigOverrideRule,\n FTRemoteConfigOverrideMatch,\n FTRemoteConfigOverrideValues,\n FTLogConfig,\n FTReactNativeLog,\n FTLogStatus,\n FTLogCacheDiscard,\n FTRUMConfig,\n FTReactNativeRUM,\n FTRUMResource,\n ErrorMonitorType,\n DeviceMetricsMonitorType,\n DetectFrequency,\n FTRUMResourceMetrics,\n FTRUMCacheDiscard,\n IOSCrashMonitoringType,\n FTTraceConfig,\n FTReactNativeTrace,\n TraceType,\n FTRumActionTracking,\n FTRumErrorTracking,\n FTBabelInteractionTracking,\n __ftExtractText,\n};\n\nexport type { FTVisitorIdConfig } from './visitorIdConfig';\n\nexport { FTRumViewTracking } from './rum/FTRumViewTracking';\n"],"mappings":"AAAA,SACEA,cAAc,EACdC,mBAAmB,EACnBC,OAAO,EACPC,gBAAgB,EAChBC,oBAAoB,EACpBC,0BAA0B,EAC1BC,2BAA2B,EAC3BC,4BAA4B,QACvB,mBAAmB;AAC1B,SACEC,WAAW,EACXC,gBAAgB,EAChBC,WAAW,EACXC,iBAAiB,QACZ,aAAa;AACpB,SACEC,WAAW,EACXC,aAAa,EACbC,gBAAgB,EAChBC,gBAAgB,EAChBC,wBAAwB,EACxBC,eAAe,EACfC,oBAAoB,EACpBC,iBAAiB,EACjBC,sBAAsB,QACjB,UAAU;AACjB,SAASC,aAAa,EAAEC,kBAAkB,EAAEC,SAAS,QAAQ,cAAc;AAC3E,SAASC,mBAAmB,QAAQ,2BAA2B;AAC/D,SAASC,kBAAkB,QAAQ,0BAA0B;AAC7D,SAASC,0BAA0B,QAAQ,kCAAkC;AAC7E,SAASC,eAAe,QAAQ,oBAAoB;AAEpD,SACE1B,mBAAmB,EACnBD,cAAc,EACdE,OAAO,EACPC,gBAAgB,EAChBC,oBAAoB,EACpBC,0BAA0B,EAC1BC,2BAA2B,EAC3BC,4BAA4B,EAC5BC,WAAW,EACXC,gBAAgB,EAChBC,WAAW,EACXC,iBAAiB,EACjBC,WAAW,EACXE,gBAAgB,EAChBD,aAAa,EACbE,gBAAgB,EAChBC,wBAAwB,EACxBC,eAAe,EACfC,oBAAoB,EACpBC,iBAAiB,EACjBC,sBAAsB,EACtBC,aAAa,EACbC,kBAAkB,EAClBC,SAAS,EACTC,mBAAmB,EACnBC,kBAAkB,EAClBC,0BAA0B,EAC1BC,eAAe;AAKjB,SAASC,iBAAiB,QAAQ,yBAAyB","ignoreList":[]}
|
|
@@ -0,0 +1,140 @@
|
|
|
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
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
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 { AppState } from 'react-native';
|
|
5
|
+
import { FTReactNativeRUM } from '../ft_rum';
|
|
6
|
+
import { bridgeContextManager } from '../ft_mobile_agent';
|
|
7
|
+
const MAX_PENDING_LOAD_MS = 15 * 60 * 1000;
|
|
8
|
+
|
|
9
|
+
/** Shared lifecycle coordinator for navigation adapters. Use one per navigator. */
|
|
10
|
+
export class FTRumViewTracking {
|
|
11
|
+
constructor(onBackground) {
|
|
12
|
+
this.onBackground = onBackground;
|
|
13
|
+
_defineProperty(this, "current", void 0);
|
|
14
|
+
_defineProperty(this, "active", void 0);
|
|
15
|
+
_defineProperty(this, "generation", 0);
|
|
16
|
+
_defineProperty(this, "lifecycle", 0);
|
|
17
|
+
_defineProperty(this, "state", null);
|
|
18
|
+
_defineProperty(this, "subscription", void 0);
|
|
19
|
+
_defineProperty(this, "loading", new Map());
|
|
20
|
+
_defineProperty(this, "onAppState", state => {
|
|
21
|
+
if (state === this.state) return;
|
|
22
|
+
this.state = state;
|
|
23
|
+
if (state === 'background') {
|
|
24
|
+
var _this$onBackground;
|
|
25
|
+
// Native closes Automatic Views at its own history boundary. No JS stop.
|
|
26
|
+
this.active = undefined;
|
|
27
|
+
this.loading.clear();
|
|
28
|
+
(_this$onBackground = this.onBackground) === null || _this$onBackground === void 0 || _this$onBackground.call(this);
|
|
29
|
+
} else if (state === 'active' && this.current) {
|
|
30
|
+
this.show(this.current);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
start() {
|
|
35
|
+
if (this.subscription) return;
|
|
36
|
+
this.state = AppState.currentState;
|
|
37
|
+
const lifecycle = ++this.lifecycle;
|
|
38
|
+
const listener = state => {
|
|
39
|
+
if (lifecycle === this.lifecycle) this.onAppState(state);
|
|
40
|
+
};
|
|
41
|
+
const subscription = AppState.addEventListener('change', listener);
|
|
42
|
+
// RN < 0.65 uses removeEventListener instead of returning a subscription.
|
|
43
|
+
const legacyAppState = AppState;
|
|
44
|
+
this.subscription = subscription || {
|
|
45
|
+
remove: () => {
|
|
46
|
+
var _legacyAppState$remov;
|
|
47
|
+
return (_legacyAppState$remov = legacyAppState.removeEventListener) === null || _legacyAppState$remov === void 0 ? void 0 : _legacyAppState$remov.call(legacyAppState, 'change', listener);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Capture both clocks at the loading boundary, before any async work. */
|
|
53
|
+
beginLoad(key) {
|
|
54
|
+
this.start();
|
|
55
|
+
this.pruneLoading();
|
|
56
|
+
if (this.state === 'background' || this.loading.has(key)) return;
|
|
57
|
+
if (typeof performance === 'undefined' || typeof performance.now !== 'function') return;
|
|
58
|
+
// Only the latest transition can supply loading for this navigator.
|
|
59
|
+
this.loading.clear();
|
|
60
|
+
this.loading.set(key, {
|
|
61
|
+
monotonicMs: performance.now(),
|
|
62
|
+
epochMs: Date.now()
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Remember a transitioning route so foreground recovery uses the current page. */
|
|
67
|
+
setCurrent(route) {
|
|
68
|
+
this.start();
|
|
69
|
+
this.current = {
|
|
70
|
+
key: route.key,
|
|
71
|
+
name: route.name
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
show(route, loadingKey = route.key) {
|
|
75
|
+
var _this$active;
|
|
76
|
+
this.setCurrent(route);
|
|
77
|
+
this.pruneLoading();
|
|
78
|
+
const loading = this.loading.get(loadingKey);
|
|
79
|
+
this.loading.clear();
|
|
80
|
+
if (this.state !== 'active') return undefined;
|
|
81
|
+
if (((_this$active = this.active) === null || _this$active === void 0 ? void 0 : _this$active.key) === route.key) return this.active.generation;
|
|
82
|
+
this.active = {
|
|
83
|
+
key: route.key,
|
|
84
|
+
generation: ++this.generation
|
|
85
|
+
};
|
|
86
|
+
if (loading) {
|
|
87
|
+
const durationNs = Math.floor((performance.now() - loading.monotonicMs) * 1000000);
|
|
88
|
+
if (Number.isFinite(durationNs) && durationNs > 0) {
|
|
89
|
+
this.report(this.nativeRUM.onCreateViewWithLoadStart(route.name, durationNs, Number.isFinite(loading.epochMs) ? loading.epochMs : 0));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// Enqueue these calls together. Waiting for a Promise here could start a stale
|
|
93
|
+
// page after background/route changes; native consumes loading before start.
|
|
94
|
+
this.report(this.nativeRUM.startViewWithTrackingType(route.name, bridgeContextManager.mergeWithLocalPropertiesSync(), 1 // Automatic is an internal framework bridge detail.
|
|
95
|
+
));
|
|
96
|
+
return this.active.generation;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Apply a completed interval only to the appearance that started it. */
|
|
100
|
+
updateLoadingTime(key, generation, durationNs) {
|
|
101
|
+
if (this.state !== 'active' || !this.active || this.active.key !== key || this.active.generation !== generation || !Number.isSafeInteger(durationNs) || durationNs <= 0) return;
|
|
102
|
+
// Enqueue immediately; never let a Promise continuation update another View.
|
|
103
|
+
this.report(FTReactNativeRUM.updateViewLoadingTime(durationNs));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Only the appearance that owns the active generation may close it. */
|
|
107
|
+
hide(key, generation) {
|
|
108
|
+
if (this.state !== 'active') return;
|
|
109
|
+
if (!this.active || this.active.key !== key || this.active.generation !== generation) return;
|
|
110
|
+
this.active = undefined;
|
|
111
|
+
this.current = undefined;
|
|
112
|
+
this.report(FTReactNativeRUM.stopView());
|
|
113
|
+
}
|
|
114
|
+
stop() {
|
|
115
|
+
var _this$subscription;
|
|
116
|
+
++this.lifecycle;
|
|
117
|
+
(_this$subscription = this.subscription) === null || _this$subscription === void 0 || _this$subscription.remove();
|
|
118
|
+
this.subscription = undefined;
|
|
119
|
+
if (this.active && this.state === 'active') this.report(FTReactNativeRUM.stopView());
|
|
120
|
+
this.active = undefined;
|
|
121
|
+
this.current = undefined;
|
|
122
|
+
this.loading.clear();
|
|
123
|
+
// Never reuse generation values: callbacks from a previous subscription can arrive late.
|
|
124
|
+
}
|
|
125
|
+
pruneLoading() {
|
|
126
|
+
const now = typeof performance !== 'undefined' && typeof performance.now === 'function' ? performance.now() : NaN;
|
|
127
|
+
for (const [key, load] of this.loading) {
|
|
128
|
+
const age = now - load.monotonicMs;
|
|
129
|
+
if (!Number.isFinite(age) || age < 0 || age >= MAX_PENDING_LOAD_MS) this.loading.delete(key);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
get nativeRUM() {
|
|
133
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
134
|
+
return require('../specs/NativeFTReactNativeRUM').default;
|
|
135
|
+
}
|
|
136
|
+
report(result) {
|
|
137
|
+
result.catch(error => console.warn('[TrueWatch] Automatic View tracking failed', error));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=FTRumViewTracking.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["AppState","FTReactNativeRUM","bridgeContextManager","MAX_PENDING_LOAD_MS","FTRumViewTracking","constructor","onBackground","_defineProperty","Map","state","_this$onBackground","active","undefined","loading","clear","call","current","show","start","subscription","currentState","lifecycle","listener","onAppState","addEventListener","legacyAppState","remove","_legacyAppState$remov","removeEventListener","beginLoad","key","pruneLoading","has","performance","now","set","monotonicMs","epochMs","Date","setCurrent","route","name","loadingKey","_this$active","get","generation","durationNs","Math","floor","Number","isFinite","report","nativeRUM","onCreateViewWithLoadStart","startViewWithTrackingType","mergeWithLocalPropertiesSync","updateLoadingTime","isSafeInteger","updateViewLoadingTime","hide","stopView","stop","_this$subscription","NaN","load","age","delete","require","default","result","catch","error","console","warn"],"sources":["FTRumViewTracking.ts"],"sourcesContent":["import { AppState } from 'react-native';\nimport type { AppStateStatus } from 'react-native';\nimport { FTReactNativeRUM } from '../ft_rum';\nimport { bridgeContextManager } from '../ft_mobile_agent';\nimport type { Spec as NativeRUMSpec } from '../specs/NativeFTReactNativeRUM';\n\ntype Route = { key: string; name: string };\ntype Loading = { monotonicMs: number; epochMs: number };\nconst MAX_PENDING_LOAD_MS = 15 * 60 * 1000;\n\n/** Shared lifecycle coordinator for navigation adapters. Use one per navigator. */\nexport class FTRumViewTracking {\n private current?: Route;\n private active?: { key: string; generation: number };\n private generation = 0;\n private lifecycle = 0;\n private state: AppStateStatus | null = null;\n private subscription?: { remove(): void };\n private loading = new Map<string, Loading>();\n\n constructor(private readonly onBackground?: () => void) {}\n\n start(): void {\n if (this.subscription) return;\n this.state = AppState.currentState;\n const lifecycle = ++this.lifecycle;\n const listener = (state: AppStateStatus): void => {\n if (lifecycle === this.lifecycle) this.onAppState(state);\n };\n const subscription = AppState.addEventListener('change', listener);\n // RN < 0.65 uses removeEventListener instead of returning a subscription.\n const legacyAppState = AppState as typeof AppState & {\n removeEventListener?: (type: string, callback: typeof listener) => void;\n };\n this.subscription = subscription || {\n remove: () => legacyAppState.removeEventListener?.('change', listener),\n };\n }\n\n /** Capture both clocks at the loading boundary, before any async work. */\n beginLoad(key: string): void {\n this.start();\n this.pruneLoading();\n if (this.state === 'background' || this.loading.has(key)) return;\n if (\n typeof performance === 'undefined' ||\n typeof performance.now !== 'function'\n )\n return;\n // Only the latest transition can supply loading for this navigator.\n this.loading.clear();\n this.loading.set(key, {\n monotonicMs: performance.now(),\n epochMs: Date.now(),\n });\n }\n\n /** Remember a transitioning route so foreground recovery uses the current page. */\n setCurrent(route: Route): void {\n this.start();\n this.current = { key: route.key, name: route.name };\n }\n\n show(route: Route, loadingKey: string = route.key): number | undefined {\n this.setCurrent(route);\n this.pruneLoading();\n const loading = this.loading.get(loadingKey);\n this.loading.clear();\n if (this.state !== 'active') return undefined;\n if (this.active?.key === route.key) return this.active.generation;\n this.active = { key: route.key, generation: ++this.generation };\n if (loading) {\n const durationNs = Math.floor(\n (performance.now() - loading.monotonicMs) * 1000000\n );\n if (Number.isFinite(durationNs) && durationNs > 0) {\n this.report(\n this.nativeRUM.onCreateViewWithLoadStart(\n route.name,\n durationNs,\n Number.isFinite(loading.epochMs) ? loading.epochMs : 0\n )\n );\n }\n }\n // Enqueue these calls together. Waiting for a Promise here could start a stale\n // page after background/route changes; native consumes loading before start.\n this.report(\n this.nativeRUM.startViewWithTrackingType(\n route.name,\n bridgeContextManager.mergeWithLocalPropertiesSync(),\n 1 // Automatic is an internal framework bridge detail.\n )\n );\n return this.active.generation;\n }\n\n /** Apply a completed interval only to the appearance that started it. */\n updateLoadingTime(\n key: string,\n generation: number | undefined,\n durationNs: number\n ): void {\n if (\n this.state !== 'active' ||\n !this.active ||\n this.active.key !== key ||\n this.active.generation !== generation ||\n !Number.isSafeInteger(durationNs) ||\n durationNs <= 0\n )\n return;\n // Enqueue immediately; never let a Promise continuation update another View.\n this.report(FTReactNativeRUM.updateViewLoadingTime(durationNs));\n }\n\n /** Only the appearance that owns the active generation may close it. */\n hide(key: string, generation: number | undefined): void {\n if (this.state !== 'active') return;\n if (\n !this.active ||\n this.active.key !== key ||\n this.active.generation !== generation\n )\n return;\n this.active = undefined;\n this.current = undefined;\n this.report(FTReactNativeRUM.stopView());\n }\n\n stop(): void {\n ++this.lifecycle;\n this.subscription?.remove();\n this.subscription = undefined;\n if (this.active && this.state === 'active')\n this.report(FTReactNativeRUM.stopView());\n this.active = undefined;\n this.current = undefined;\n this.loading.clear();\n // Never reuse generation values: callbacks from a previous subscription can arrive late.\n }\n\n private onAppState = (state: AppStateStatus): void => {\n if (state === this.state) return;\n this.state = state;\n if (state === 'background') {\n // Native closes Automatic Views at its own history boundary. No JS stop.\n this.active = undefined;\n this.loading.clear();\n this.onBackground?.();\n } else if (state === 'active' && this.current) {\n this.show(this.current);\n }\n };\n\n private pruneLoading(): void {\n const now =\n typeof performance !== 'undefined' &&\n typeof performance.now === 'function'\n ? performance.now()\n : NaN;\n for (const [key, load] of this.loading) {\n const age = now - load.monotonicMs;\n if (!Number.isFinite(age) || age < 0 || age >= MAX_PENDING_LOAD_MS)\n this.loading.delete(key);\n }\n }\n\n private get nativeRUM(): NativeRUMSpec {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n return require('../specs/NativeFTReactNativeRUM').default;\n }\n\n private report(result: Promise<void>): void {\n result.catch((error) =>\n console.warn('[TrueWatch] Automatic View tracking failed', error)\n );\n }\n}\n"],"mappings":";;;AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,SAASC,gBAAgB,QAAQ,WAAW;AAC5C,SAASC,oBAAoB,QAAQ,oBAAoB;AAKzD,MAAMC,mBAAmB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;;AAE1C;AACA,OAAO,MAAMC,iBAAiB,CAAC;EAS7BC,WAAWA,CAAkBC,YAAyB,EAAE;IAAA,KAA3BA,YAAyB,GAAzBA,YAAyB;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA,qBANjC,CAAC;IAAAA,eAAA,oBACF,CAAC;IAAAA,eAAA,gBACkB,IAAI;IAAAA,eAAA;IAAAA,eAAA,kBAEzB,IAAIC,GAAG,CAAkB,CAAC;IAAAD,eAAA,qBA4HtBE,KAAqB,IAAW;MACpD,IAAIA,KAAK,KAAK,IAAI,CAACA,KAAK,EAAE;MAC1B,IAAI,CAACA,KAAK,GAAGA,KAAK;MAClB,IAAIA,KAAK,KAAK,YAAY,EAAE;QAAA,IAAAC,kBAAA;QAC1B;QACA,IAAI,CAACC,MAAM,GAAGC,SAAS;QACvB,IAAI,CAACC,OAAO,CAACC,KAAK,CAAC,CAAC;QACpB,CAAAJ,kBAAA,OAAI,CAACJ,YAAY,cAAAI,kBAAA,eAAj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,IACjBC,OAAO,CAACC,IAAI,CAAC,4CAA4C,EAAEF,KAAK,CAClE,CAAC;EACH;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeWebSocket","bridgeContextManager","ignoreBridgeFailure","call","Promise","resolve","catch","NativeWebSocketSession","constructor","session","_defineProperty","startCapture","startResource","key","socketID","url","property","mergeWithLocalPropertiesSync","sequence","stopResource","event","addResource","content","metrics","release","releaseResource","stop","stopped","stopCapture","startNativeWebSocketSession","createKey","clear","undefined","clearNativeWebSocketSessions","webSocketNativeID","socket","id","_socketId","Number","isSafeInteger"],"sources":["FTRumWebSocketNative.ts"],"sourcesContent":["import NativeWebSocket from '../specs/NativeFTReactNativeWebSocket';\nimport { bridgeContextManager } from '../ft_mobile_agent';\n\nexport interface NativeWebSocketResource {\n url: string;\n httpMethod: string;\n requestHeader: Record<string, unknown>;\n webSocketEvent: string;\n errorMessage?: string;\n}\n\nfunction ignoreBridgeFailure(call: () => unknown): void {\n try {\n void Promise.resolve(call()).catch(() => {});\n } catch {\n /* Setup/cleanup replies must not interrupt JS capture. */\n }\n}\n\nexport class NativeWebSocketSession {\n private stopped = false;\n private sequence = 0;\n\n constructor(private readonly session: string) {\n // Enqueue setup before start/stop/add on the same native module queue.\n // Its reply never gates JS capture or selects a different reporting route.\n ignoreBridgeFailure(() => NativeWebSocket!.startCapture(session));\n }\n\n startResource(\n key: string,\n socketID: number | undefined,\n url: string\n ): Promise<void> {\n const property = bridgeContextManager.mergeWithLocalPropertiesSync();\n return NativeWebSocket!.startResource(\n key,\n socketID ?? -1,\n url,\n this.session,\n ++this.sequence,\n property\n );\n }\n\n stopResource(key: string, event: string): Promise<void> {\n const property = bridgeContextManager.mergeWithLocalPropertiesSync();\n return NativeWebSocket!.stopResource(key, event, this.session, property);\n }\n\n addResource(\n key: string,\n content: NativeWebSocketResource,\n metrics:
|
|
1
|
+
{"version":3,"names":["NativeWebSocket","bridgeContextManager","ignoreBridgeFailure","call","Promise","resolve","catch","NativeWebSocketSession","constructor","session","_defineProperty","startCapture","startResource","key","socketID","url","property","mergeWithLocalPropertiesSync","sequence","stopResource","event","addResource","content","metrics","release","releaseResource","stop","stopped","stopCapture","startNativeWebSocketSession","createKey","clear","undefined","clearNativeWebSocketSessions","webSocketNativeID","socket","id","_socketId","Number","isSafeInteger"],"sources":["FTRumWebSocketNative.ts"],"sourcesContent":["import NativeWebSocket from '../specs/NativeFTReactNativeWebSocket';\nimport { bridgeContextManager } from '../ft_mobile_agent';\nimport type { WebSocketTimingMetrics } from './FTRumWebSocketTiming';\n\nexport interface NativeWebSocketResource {\n url: string;\n httpMethod: string;\n requestHeader: Record<string, unknown>;\n webSocketEvent: string;\n errorMessage?: string;\n}\n\nfunction ignoreBridgeFailure(call: () => unknown): void {\n try {\n void Promise.resolve(call()).catch(() => {});\n } catch {\n /* Setup/cleanup replies must not interrupt JS capture. */\n }\n}\n\nexport class NativeWebSocketSession {\n private stopped = false;\n private sequence = 0;\n\n constructor(private readonly session: string) {\n // Enqueue setup before start/stop/add on the same native module queue.\n // Its reply never gates JS capture or selects a different reporting route.\n ignoreBridgeFailure(() => NativeWebSocket!.startCapture(session));\n }\n\n startResource(\n key: string,\n socketID: number | undefined,\n url: string\n ): Promise<void> {\n const property = bridgeContextManager.mergeWithLocalPropertiesSync();\n return NativeWebSocket!.startResource(\n key,\n socketID ?? -1,\n url,\n this.session,\n ++this.sequence,\n property\n );\n }\n\n stopResource(key: string, event: string): Promise<void> {\n const property = bridgeContextManager.mergeWithLocalPropertiesSync();\n return NativeWebSocket!.stopResource(key, event, this.session, property);\n }\n\n addResource(\n key: string,\n content: NativeWebSocketResource,\n metrics: Partial<WebSocketTimingMetrics>\n ): Promise<void> {\n return NativeWebSocket!.addResource(key, content, metrics, this.session);\n }\n\n release(key: string): void {\n ignoreBridgeFailure(() =>\n NativeWebSocket?.releaseResource(key, this.session)\n );\n }\n\n stop(): void {\n if (this.stopped) return;\n this.stopped = true;\n // Existing handshakes still finish through their originally selected route.\n ignoreBridgeFailure(() => NativeWebSocket?.stopCapture(this.session));\n }\n}\n\nexport function startNativeWebSocketSession(\n createKey: () => string\n): NativeWebSocketSession | undefined {\n try {\n if (\n typeof NativeWebSocket?.startCapture === 'function' &&\n typeof NativeWebSocket.stopCapture === 'function' &&\n typeof NativeWebSocket.clear === 'function' &&\n typeof NativeWebSocket.startResource === 'function' &&\n typeof NativeWebSocket.stopResource === 'function' &&\n typeof NativeWebSocket.addResource === 'function' &&\n typeof NativeWebSocket.releaseResource === 'function'\n )\n return new NativeWebSocketSession(createKey());\n } catch {\n /* Old native binaries keep the JS fallback. */\n }\n return undefined;\n}\n\nexport function clearNativeWebSocketSessions(): void {\n ignoreBridgeFailure(() => NativeWebSocket?.clear());\n}\n\nexport function webSocketNativeID(socket: unknown): number | undefined {\n try {\n const id = (socket as { _socketId?: unknown })?._socketId;\n return typeof id === 'number' && Number.isSafeInteger(id) && id >= 0\n ? id\n : undefined;\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;;AAAA,OAAOA,eAAe,MAAM,uCAAuC;AACnE,SAASC,oBAAoB,QAAQ,oBAAoB;AAWzD,SAASC,mBAAmBA,CAACC,IAAmB,EAAQ;EACtD,IAAI;IACF,KAAKC,OAAO,CAACC,OAAO,CAACF,IAAI,CAAC,CAAC,CAAC,CAACG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;EAC9C,CAAC,CAAC,MAAM;IACN;EAAA;AAEJ;AAEA,OAAO,MAAMC,sBAAsB,CAAC;EAIlCC,WAAWA,CAAkBC,OAAe,EAAE;IAAA,KAAjBA,OAAe,GAAfA,OAAe;IAAAC,eAAA,kBAH1B,KAAK;IAAAA,eAAA,mBACJ,CAAC;IAGlB;IACA;IACAR,mBAAmB,CAAC,MAAMF,eAAe,CAAEW,YAAY,CAACF,OAAO,CAAC,CAAC;EACnE;EAEAG,aAAaA,CACXC,GAAW,EACXC,QAA4B,EAC5BC,GAAW,EACI;IACf,MAAMC,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e,CAAC+B,KAAK,KAAK,UAAU,IAC3C,OAAO/B,eAAe,CAACY,aAAa,KAAK,UAAU,IACnD,OAAOZ,eAAe,CAACmB,YAAY,KAAK,UAAU,IAClD,OAAOnB,eAAe,CAACqB,WAAW,KAAK,UAAU,IACjD,OAAOrB,eAAe,CAACyB,eAAe,KAAK,UAAU,EAErD,OAAO,IAAIlB,sBAAsB,CAACuB,SAAS,CAAC,CAAC,CAAC;EAClD,CAAC,CAAC,MAAM;IACN;EAAA;EAEF,OAAOE,SAAS;AAClB;AAEA,OAAO,SAASC,4BAA4BA,CAAA,EAAS;EACnD/B,mBAAmB,CAAC,MAAMF,eAAe,aAAfA,eAAe,uBAAfA,eAAe,CAAE+B,KAAK,CAAC,CAAC,CAAC;AACrD;AAEA,OAAO,SAASG,iBAAiBA,CAACC,MAAe,EAAsB;EACrE,IAAI;IACF,MAAMC,EAAE,GAAID,MAAM,aAANA,MAAM,uBAANA,MAAM,CAA8BE,SAAS;IACzD,OAAO,OAAOD,EAAE,KAAK,QAAQ,IAAIE,MAAM,CAACC,aAAa,CAACH,EAAE,CAAC,IAAIA,EAAE,IAAI,CAAC,GAChEA,EAAE,GACFJ,SAAS;EACf,CAAC,CAAC,MAAM;IACN,OAAOA,SAAS;EAClB;AACF","ignoreList":[]}
|
|
@@ -35,9 +35,27 @@ export function startWebSocketTiming() {
|
|
|
35
35
|
}
|
|
36
36
|
// Resource metrics use nanoseconds. Do not send an invalid bridge number.
|
|
37
37
|
const durationNs = Math.round(durationMs * 1e6);
|
|
38
|
-
|
|
38
|
+
if (!Number.isSafeInteger(durationNs)) return undefined;
|
|
39
|
+
const metrics = {
|
|
40
|
+
duration: durationNs
|
|
41
|
+
};
|
|
42
|
+
if (wallStart !== undefined && Number.isSafeInteger(wallStart) && wallStart > 0) {
|
|
43
|
+
// Add the monotonic elapsed interval to the start epoch, not Date.now()
|
|
44
|
+
// at completion. Split milliseconds/remainder to avoid epoch-ns doubles.
|
|
45
|
+
const endMs = wallStart + Math.floor(durationNs / 1e6);
|
|
46
|
+
const start = `${wallStart}000000`;
|
|
47
|
+
const end = `${endMs}${String(durationNs % 1e6).padStart(6, '0')}`;
|
|
48
|
+
if (Number.isSafeInteger(endMs) && fitsInt64(start) && fitsInt64(end)) {
|
|
49
|
+
metrics.fetchStartNsTimeInterval = start;
|
|
50
|
+
metrics.fetchEndNsTimeInterval = end;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return metrics;
|
|
39
54
|
};
|
|
40
55
|
}
|
|
56
|
+
function fitsInt64(value) {
|
|
57
|
+
return value.length < 19 || value.length === 19 && value <= '9223372036854775807';
|
|
58
|
+
}
|
|
41
59
|
function readWallTime() {
|
|
42
60
|
try {
|
|
43
61
|
const time = Date.now();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["startWebSocketTiming","wallStart","readWallTime","monotonicNow","monotonicStart","clock","globalThis","performance","now","durationMs","Number","isFinite","elapsed","undefined","wallEnd","durationNs","Math","round","isSafeInteger","time","Date"],"sources":["FTRumWebSocketTiming.ts"],"sourcesContent":["/** Measures only the JS-observed opening handshake; bridge delays are excluded. */\nexport function startWebSocketTiming(): ()
|
|
1
|
+
{"version":3,"names":["startWebSocketTiming","wallStart","readWallTime","monotonicNow","monotonicStart","clock","globalThis","performance","now","durationMs","Number","isFinite","elapsed","undefined","wallEnd","durationNs","Math","round","isSafeInteger","metrics","duration","endMs","floor","start","end","String","padStart","fitsInt64","fetchStartNsTimeInterval","fetchEndNsTimeInterval","value","length","time","Date"],"sources":["FTRumWebSocketTiming.ts"],"sourcesContent":["export interface WebSocketTimingMetrics {\n duration: number;\n // Decimal int64 nanoseconds: epoch nanoseconds exceed JS number precision.\n fetchStartNsTimeInterval?: string;\n fetchEndNsTimeInterval?: string;\n}\n\n/** Measures only the JS-observed opening handshake; bridge delays are excluded. */\nexport function startWebSocketTiming(): () =>\n | WebSocketTimingMetrics\n | undefined {\n const wallStart = readWallTime();\n let monotonicNow: (() => number) | undefined;\n let monotonicStart: number | undefined;\n try {\n const clock = globalThis.performance;\n if (typeof clock?.now === 'function') {\n monotonicNow = () => clock.now();\n monotonicStart = monotonicNow();\n }\n } catch {\n // Older runtimes and other instrumentation may not provide this clock.\n }\n\n return () => {\n let durationMs: number | undefined;\n try {\n if (monotonicNow && Number.isFinite(monotonicStart)) {\n const elapsed = monotonicNow() - (monotonicStart as number);\n if (Number.isFinite(elapsed) && elapsed >= 0) {\n durationMs = elapsed;\n }\n }\n } catch {\n // Fall back to wall time if the monotonic clock becomes unavailable.\n }\n if (durationMs === undefined && wallStart !== undefined) {\n const wallEnd = readWallTime();\n if (wallEnd !== undefined && wallEnd >= wallStart) {\n durationMs = wallEnd - wallStart;\n }\n }\n if (durationMs === undefined) {\n return undefined;\n }\n // Resource metrics use nanoseconds. Do not send an invalid bridge number.\n const durationNs = Math.round(durationMs * 1e6);\n if (!Number.isSafeInteger(durationNs)) return undefined;\n const metrics: WebSocketTimingMetrics = { duration: durationNs };\n if (\n wallStart !== undefined &&\n Number.isSafeInteger(wallStart) &&\n wallStart > 0\n ) {\n // Add the monotonic elapsed interval to the start epoch, not Date.now()\n // at completion. Split milliseconds/remainder to avoid epoch-ns doubles.\n const endMs = wallStart + Math.floor(durationNs / 1e6);\n const start = `${wallStart}000000`;\n const end = `${endMs}${String(durationNs % 1e6).padStart(6, '0')}`;\n if (Number.isSafeInteger(endMs) && fitsInt64(start) && fitsInt64(end)) {\n metrics.fetchStartNsTimeInterval = start;\n metrics.fetchEndNsTimeInterval = end;\n }\n }\n return metrics;\n };\n}\n\nfunction fitsInt64(value: string): boolean {\n return (\n value.length < 19 || (value.length === 19 && value <= '9223372036854775807')\n );\n}\n\nfunction readWallTime(): number | undefined {\n try {\n const time = Date.now();\n return Number.isFinite(time) ? time : undefined;\n } catch {\n return undefined;\n }\n}\n"],"mappings":"AAOA;AACA,OAAO,SAASA,oBAAoBA,CAAA,EAEtB;EACZ,MAAMC,SAAS,GAAGC,YAAY,CAAC,CA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AAS,CAAC,IAC/BA,SAAS,GAAG,CAAC,EACb;MACA;MACA;MACA,MAAMoB,KAAK,GAAGpB,SAAS,GAAGe,IAAI,CAACM,KAAK,CAACP,UAAU,GAAG,GAAG,CAAC;MACtD,MAAMQ,KAAK,GAAG,GAAGtB,SAAS,QAAQ;MAClC,MAAMuB,GAAG,GAAG,GAAGH,KAAK,GAAGI,MAAM,CAACV,UAAU,GAAG,GAAG,CAAC,CAACW,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE;MAClE,IAAIhB,MAAM,CAACQ,aAAa,CAACG,KAAK,CAAC,IAAIM,SAAS,CAACJ,KAAK,CAAC,IAAII,SAAS,CAACH,GAAG,CAAC,EAAE;QACrEL,OAAO,CAACS,wBAAwB,GAAGL,KAAK;QACxCJ,OAAO,CAACU,sBAAsB,GAAGL,GAAG;MACtC;IACF;IACA,OAAOL,OAAO;EAChB,CAAC;AACH;AAEA,SAASQ,SAASA,CAACG,KAAa,EAAW;EACzC,OACEA,KAAK,CAACC,MAAM,GAAG,EAAE,IAAKD,KAAK,CAACC,MAAM,KAAK,EAAE,IAAID,KAAK,IAAI,qBAAsB;AAEhF;AAEA,SAAS5B,YAAYA,CAAA,EAAuB;EAC1C,IAAI;IACF,MAAM8B,IAAI,GAAGC,IAAI,CAACzB,GAAG,CAAC,CAAC;IACvB,OAAOE,MAAM,CAACC,QAAQ,CAACqB,IAAI,CAAC,GAAGA,IAAI,GAAGnB,SAAS;EACjD,CAAC,CAAC,MAAM;IACN,OAAOA,SAAS;EAClB;AACF","ignoreList":[]}
|
|
@@ -201,7 +201,7 @@ export class FTRumWebSocketTracking {
|
|
|
201
201
|
return;
|
|
202
202
|
}
|
|
203
203
|
completed = true;
|
|
204
|
-
const
|
|
204
|
+
const timing = stopTiming();
|
|
205
205
|
// Freeze the observed boundary before inspecting or parsing error data.
|
|
206
206
|
const error = getError === null || getError === void 0 ? void 0 : getError();
|
|
207
207
|
if (cancelled || lifecycleVersion !== FTRumWebSocketTracking.lifecycleVersion) {
|
|
@@ -230,10 +230,10 @@ export class FTRumWebSocketTracking {
|
|
|
230
230
|
httpMethod: 'GET',
|
|
231
231
|
requestHeader: requestHeaders,
|
|
232
232
|
webSocketEvent: event
|
|
233
|
-
},
|
|
233
|
+
}, timing, error, errorReady);
|
|
234
234
|
return;
|
|
235
235
|
}
|
|
236
|
-
void FTRumWebSocketTracking.completeResource(resourceReporter, lifecycleVersion, resourceKey, started, url, requestHeaders, resourceStatus, state,
|
|
236
|
+
void FTRumWebSocketTracking.completeResource(resourceReporter, lifecycleVersion, resourceKey, started, url, requestHeaders, resourceStatus, state, timing, error, errorReady);
|
|
237
237
|
};
|
|
238
238
|
const onOpen = () => complete(0, 'success', undefined, 'open');
|
|
239
239
|
const onError = event => {
|
|
@@ -407,7 +407,7 @@ export class FTRumWebSocketTracking {
|
|
|
407
407
|
return Promise.reject(error);
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
|
-
static async completeResource(resourceReporter, lifecycleVersion, resourceKey, startPromise, url, requestHeader, resourceStatus, webSocketHandshakeState,
|
|
410
|
+
static async completeResource(resourceReporter, lifecycleVersion, resourceKey, startPromise, url, requestHeader, resourceStatus, webSocketHandshakeState, timing, error, errorReady) {
|
|
411
411
|
const isCurrentLifecycle = () => lifecycleVersion === FTRumWebSocketTracking.lifecycleVersion;
|
|
412
412
|
try {
|
|
413
413
|
if (!(await startPromise) || !isCurrentLifecycle()) {
|
|
@@ -440,10 +440,8 @@ export class FTRumWebSocketTracking {
|
|
|
440
440
|
webSocketHandshakeState
|
|
441
441
|
};
|
|
442
442
|
if (error !== null && error !== void 0 && error.message) resource.errorMessage = error.message;
|
|
443
|
-
const metrics = {};
|
|
444
|
-
if (duration !== undefined) metrics.duration = duration;
|
|
445
443
|
if (isCurrentLifecycle()) {
|
|
446
|
-
await resourceReporter.addResource(resourceKey, resource,
|
|
444
|
+
await resourceReporter.addResource(resourceKey, resource, timing);
|
|
447
445
|
}
|
|
448
446
|
} catch {
|
|
449
447
|
if (isCurrentLifecycle()) {
|
|
@@ -451,7 +449,7 @@ export class FTRumWebSocketTracking {
|
|
|
451
449
|
}
|
|
452
450
|
}
|
|
453
451
|
}
|
|
454
|
-
static async completeNativeResource(session, lifecycleVersion, key, started, content,
|
|
452
|
+
static async completeNativeResource(session, lifecycleVersion, key, started, content, timing, error, errorReady) {
|
|
455
453
|
// Attach rejection handling immediately, including when start never settles.
|
|
456
454
|
let stopped;
|
|
457
455
|
try {
|
|
@@ -469,9 +467,7 @@ export class FTRumWebSocketTracking {
|
|
|
469
467
|
await session.addResource(key, error !== null && error !== void 0 && error.message ? {
|
|
470
468
|
...content,
|
|
471
469
|
errorMessage: error.message
|
|
472
|
-
} : content,
|
|
473
|
-
duration
|
|
474
|
-
});
|
|
470
|
+
} : content, timing !== null && timing !== void 0 ? timing : {});
|
|
475
471
|
} catch {
|
|
476
472
|
session.release(key);
|
|
477
473
|
if (lifecycleVersion === FTRumWebSocketTracking.lifecycleVersion) FTRumWebSocketTracking.warnOnce('Unable to report WebSocket resource.');
|