@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.
Files changed (95) hide show
  1. package/FTMobileReactNativeSDK.podspec +1 -1
  2. package/README.md +0 -34
  3. package/android/build.gradle +2 -2
  4. package/android/src/main/java/com/ft/sdk/reactnative/FTLogImpl.java +10 -2
  5. package/android/src/main/java/com/ft/sdk/reactnative/FTMobileImpl.java +45 -3
  6. package/android/src/main/java/com/ft/sdk/reactnative/FTRUMImpl.java +51 -9
  7. package/android/src/main/java/com/ft/sdk/reactnative/FTTraceImpl.java +5 -2
  8. package/android/src/main/java/com/ft/sdk/reactnative/ViewTiming.java +17 -0
  9. package/android/src/main/java/com/ft/sdk/reactnative/VisitorIdConfigMapper.java +50 -0
  10. package/android/src/newarch/java/com/ft/sdk/reactnative/FTMobileModule.java +5 -0
  11. package/android/src/newarch/java/com/ft/sdk/reactnative/FTRUMModule.java +18 -0
  12. package/android/src/oldarch/java/com/ft/sdk/reactnative/FTMobileModule.java +5 -0
  13. package/android/src/oldarch/java/com/ft/sdk/reactnative/FTRUMModule.java +15 -0
  14. package/android/src/test/java/com/ft/sdk/reactnative/FTMobileImplTest.java +53 -0
  15. package/ios/FTMobileReactNative.mm +37 -2
  16. package/ios/FTReactNativeLog.mm +7 -2
  17. package/ios/FTReactNativeRUM.mm +94 -4
  18. package/ios/FTReactNativeResource.m +6 -0
  19. package/ios/FTReactNativeTrace.mm +4 -2
  20. package/ios/FTReactNativeViewTiming.h +18 -0
  21. package/ios/FTWebSocketResourceData.h +4 -0
  22. package/ios/FTWebSocketResourceData.m +31 -0
  23. package/lib/commonjs/ft_logger.js +3 -1
  24. package/lib/commonjs/ft_logger.js.map +1 -1
  25. package/lib/commonjs/ft_mobile_agent.js +13 -1
  26. package/lib/commonjs/ft_mobile_agent.js.map +1 -1
  27. package/lib/commonjs/ft_rum.js +19 -3
  28. package/lib/commonjs/ft_rum.js.map +1 -1
  29. package/lib/commonjs/ft_tracing.js +2 -1
  30. package/lib/commonjs/ft_tracing.js.map +1 -1
  31. package/lib/commonjs/index.js +7 -0
  32. package/lib/commonjs/index.js.map +1 -1
  33. package/lib/commonjs/rum/FTRumViewTracking.js +147 -0
  34. package/lib/commonjs/rum/FTRumViewTracking.js.map +1 -0
  35. package/lib/commonjs/rum/FTRumWebSocketNative.js.map +1 -1
  36. package/lib/commonjs/rum/FTRumWebSocketTiming.js +19 -1
  37. package/lib/commonjs/rum/FTRumWebSocketTiming.js.map +1 -1
  38. package/lib/commonjs/rum/FTRumWebSocketTracking.js +7 -11
  39. package/lib/commonjs/rum/FTRumWebSocketTracking.js.map +1 -1
  40. package/lib/commonjs/specs/NativeFTMobileReactNative.js.map +1 -1
  41. package/lib/commonjs/specs/NativeFTReactNativeRUM.js.map +1 -1
  42. package/lib/commonjs/version.js +1 -1
  43. package/lib/commonjs/version.js.map +1 -1
  44. package/lib/commonjs/visitorIdConfig.js +37 -0
  45. package/lib/commonjs/visitorIdConfig.js.map +1 -0
  46. package/lib/module/ft_logger.js +3 -1
  47. package/lib/module/ft_logger.js.map +1 -1
  48. package/lib/module/ft_mobile_agent.js +13 -1
  49. package/lib/module/ft_mobile_agent.js.map +1 -1
  50. package/lib/module/ft_rum.js +19 -3
  51. package/lib/module/ft_rum.js.map +1 -1
  52. package/lib/module/ft_tracing.js +2 -1
  53. package/lib/module/ft_tracing.js.map +1 -1
  54. package/lib/module/index.js +1 -0
  55. package/lib/module/index.js.map +1 -1
  56. package/lib/module/rum/FTRumViewTracking.js +140 -0
  57. package/lib/module/rum/FTRumViewTracking.js.map +1 -0
  58. package/lib/module/rum/FTRumWebSocketNative.js.map +1 -1
  59. package/lib/module/rum/FTRumWebSocketTiming.js +19 -1
  60. package/lib/module/rum/FTRumWebSocketTiming.js.map +1 -1
  61. package/lib/module/rum/FTRumWebSocketTracking.js +7 -11
  62. package/lib/module/rum/FTRumWebSocketTracking.js.map +1 -1
  63. package/lib/module/specs/NativeFTMobileReactNative.js.map +1 -1
  64. package/lib/module/specs/NativeFTReactNativeRUM.js.map +1 -1
  65. package/lib/module/version.js +1 -1
  66. package/lib/module/version.js.map +1 -1
  67. package/lib/module/visitorIdConfig.js +31 -0
  68. package/lib/module/visitorIdConfig.js.map +1 -0
  69. package/lib/typescript/ft_logger.d.ts +11 -1
  70. package/lib/typescript/ft_mobile_agent.d.ts +25 -0
  71. package/lib/typescript/ft_rum.d.ts +33 -5
  72. package/lib/typescript/ft_tracing.d.ts +9 -1
  73. package/lib/typescript/index.d.ts +2 -0
  74. package/lib/typescript/rum/FTRumViewTracking.d.ts +32 -0
  75. package/lib/typescript/rum/FTRumWebSocketNative.d.ts +2 -3
  76. package/lib/typescript/rum/FTRumWebSocketTiming.d.ts +6 -1
  77. package/lib/typescript/rum/FTRumWebSocketTracking.d.ts +2 -4
  78. package/lib/typescript/specs/NativeFTMobileReactNative.d.ts +1 -0
  79. package/lib/typescript/specs/NativeFTReactNativeRUM.d.ts +7 -1
  80. package/lib/typescript/version.d.ts +1 -1
  81. package/lib/typescript/visitorIdConfig.d.ts +11 -0
  82. package/package.json +4 -3
  83. package/src/ft_logger.tsx +11 -1
  84. package/src/ft_mobile_agent.tsx +34 -1
  85. package/src/ft_rum.tsx +50 -5
  86. package/src/ft_tracing.tsx +9 -1
  87. package/src/index.tsx +4 -0
  88. package/src/rum/FTRumViewTracking.ts +179 -0
  89. package/src/rum/FTRumWebSocketNative.ts +2 -1
  90. package/src/rum/FTRumWebSocketTiming.ts +34 -2
  91. package/src/rum/FTRumWebSocketTracking.ts +9 -14
  92. package/src/specs/NativeFTMobileReactNative.ts +1 -0
  93. package/src/specs/NativeFTReactNativeRUM.ts +15 -1
  94. package/src/version.ts +1 -1
  95. package/src/visitorIdConfig.ts +123 -0
@@ -43,10 +43,24 @@ export interface Spec extends TurboModule {
43
43
  /**
44
44
  * view load duration.
45
45
  * @param viewName view name
46
- * @param loadTime view load duration
46
+ * @param loadTime monotonic view load duration in nanoseconds
47
47
  * @returns a Promise.
48
48
  */
49
49
  onCreateView(viewName: string, loadTime: number): Promise<void>;
50
+ /** Replace the current View's loading duration; non-negative safe integer nanoseconds. */
51
+ updateViewLoadingTime(duration: number): Promise<void>;
52
+ /** Framework integration: duration in ns; epoch start in ms, converted natively. */
53
+ onCreateViewWithLoadStart(
54
+ viewName: string,
55
+ loadTime: number,
56
+ loadStartEpochMs: number
57
+ ): Promise<void>;
58
+ /** Framework integration: Manual = 0, Automatic = 1. */
59
+ startViewWithTrackingType(
60
+ viewName: string,
61
+ property: Object | undefined,
62
+ trackingType: number
63
+ ): Promise<void>;
50
64
  /**
51
65
  * view start.
52
66
  * @param viewName page name
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // generated by genversion
2
- export const version = '0.4.3-alpha.2';
2
+ export const version = '0.4.3';
@@ -0,0 +1,123 @@
1
+ /** Anonymous Visitor ID header configuration for HTTP(S), excluding WebSockets. */
2
+ export interface FTVisitorIdConfig {
3
+ header: string;
4
+ /** Fixed lifetime in hours; defaults to 24. Access does not renew it. */
5
+ ttlHours?: number;
6
+ /** Complete HTTP(S) prefixes constrained to the same scheme, host and port. */
7
+ urlPrefixes?: string[];
8
+ /** Native regular expressions searched against the complete URL; rules use OR. */
9
+ regularExpressions?: string[];
10
+ }
11
+
12
+ // These restrictions are shared by the target iOS and Android native SDKs.
13
+ const reservedHeaders = new Set([
14
+ 'accept-charset',
15
+ 'accept-encoding',
16
+ 'access-control-request-headers',
17
+ 'access-control-request-method',
18
+ 'connection',
19
+ 'content-length',
20
+ 'cookie',
21
+ 'cookie2',
22
+ 'date',
23
+ 'dnt',
24
+ 'expect',
25
+ 'host',
26
+ 'keep-alive',
27
+ 'origin',
28
+ 'permissions-policy',
29
+ 'referer',
30
+ 'te',
31
+ 'trailer',
32
+ 'transfer-encoding',
33
+ 'upgrade',
34
+ 'via',
35
+ 'b3',
36
+ 'traceparent',
37
+ 'tracestate',
38
+ 'uber-trace-id',
39
+ 'sw8',
40
+ 'x-gc-trace-id',
41
+ 'x-gc-span-id',
42
+ 'x-rum-resource-id',
43
+ ]);
44
+ const reservedFragments = [
45
+ 'authorization',
46
+ 'authentication',
47
+ 'api-key',
48
+ 'api_key',
49
+ 'apikey',
50
+ 'auth-token',
51
+ 'auth_token',
52
+ 'access-token',
53
+ 'access_token',
54
+ 'session-token',
55
+ 'session_token',
56
+ 'refresh-token',
57
+ 'refresh_token',
58
+ 'id-token',
59
+ 'id_token',
60
+ 'security-token',
61
+ 'security_token',
62
+ 'csrf',
63
+ 'xsrf',
64
+ 'jwt',
65
+ 'signature',
66
+ ];
67
+
68
+ export function validateVisitorIdConfig(config: FTVisitorIdConfig): void {
69
+ if (!config || typeof config !== 'object' || Array.isArray(config)) {
70
+ throw new Error('visitorIdConfig must be an object');
71
+ }
72
+ const {
73
+ header,
74
+ ttlHours = 24,
75
+ urlPrefixes = [],
76
+ regularExpressions = [],
77
+ } = config;
78
+ if (
79
+ typeof header !== 'string' ||
80
+ /[\r\n]/.test(header) ||
81
+ !/^[!#$%&'*+.^_`|~0-9a-z-]+$/.test(header) ||
82
+ reservedHeaders.has(header) ||
83
+ reservedFragments.some((part) => header.includes(part)) ||
84
+ ['proxy-', 'sec-', 'x-datadog-', 'x-b3-'].some((prefix) =>
85
+ header.startsWith(prefix)
86
+ )
87
+ ) {
88
+ throw new Error(
89
+ 'visitorIdConfig.header must be a lowercase custom HTTP header'
90
+ );
91
+ }
92
+ // Android stores TTL as a signed long number of milliseconds.
93
+ const milliseconds = ttlHours * 3600000;
94
+ if (
95
+ typeof ttlHours !== 'number' ||
96
+ !Number.isFinite(ttlHours) ||
97
+ milliseconds < 1 ||
98
+ milliseconds >= 2 ** 63
99
+ ) {
100
+ throw new Error(
101
+ 'visitorIdConfig.ttlHours must represent at least 1 millisecond and fit a signed 64-bit integer'
102
+ );
103
+ }
104
+ if (
105
+ !Array.isArray(urlPrefixes) ||
106
+ !Array.isArray(regularExpressions) ||
107
+ urlPrefixes.length + regularExpressions.length === 0
108
+ ) {
109
+ throw new Error('visitorIdConfig requires at least one URL matching rule');
110
+ }
111
+ if (
112
+ urlPrefixes.some(
113
+ (prefix) =>
114
+ typeof prefix !== 'string' ||
115
+ !/^https?:\/\/[^/?#\s]+(?:[/?#]|$)/i.test(prefix)
116
+ ) ||
117
+ regularExpressions.some(
118
+ (pattern) => typeof pattern !== 'string' || pattern.length === 0
119
+ )
120
+ ) {
121
+ throw new Error('visitorIdConfig contains an invalid URL matching rule');
122
+ }
123
+ }