@truewatchtech/react-native-mobile 0.3.15 → 0.4.1

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 (113) hide show
  1. package/FTMobileReactNativeSDK.podspec +32 -2
  2. package/android/build.gradle +10 -4
  3. package/android/src/main/java/com/ft/sdk/reactnative/FTMobileImpl.java +434 -5
  4. package/android/src/main/java/com/ft/sdk/reactnative/FTRUMImpl.java +12 -0
  5. package/android/src/main/java/com/ft/sdk/reactnative/FTTraceImpl.java +1 -1
  6. package/android/src/newarch/java/com/ft/sdk/reactnative/FTLogModule.java +7 -14
  7. package/android/src/newarch/java/com/ft/sdk/reactnative/FTMobileModule.java +46 -12
  8. package/android/src/newarch/java/com/ft/sdk/reactnative/FTRUMModule.java +12 -13
  9. package/android/src/newarch/java/com/ft/sdk/reactnative/FTTraceModule.java +6 -8
  10. package/android/src/oldarch/java/com/ft/sdk/reactnative/FTMobileModule.java +34 -2
  11. package/android/src/rnpost74/java/com/ft/sdk/reactnative/FTMobilePackage.java +14 -4
  12. package/android/src/rnpre74/java/com/ft/sdk/reactnative/FTMobilePackage.java +0 -2
  13. package/ios/FTMobileReactNative.h +9 -5
  14. package/ios/FTMobileReactNative.mm +619 -0
  15. package/ios/FTReactNativeLog.h +8 -3
  16. package/ios/FTReactNativeLog.mm +79 -0
  17. package/ios/FTReactNativeRUM.h +8 -4
  18. package/ios/{FTReactNativeRUM.m → FTReactNativeRUM.mm} +143 -84
  19. package/ios/FTReactNativeTrace.h +7 -3
  20. package/ios/FTReactNativeTrace.mm +74 -0
  21. package/ios/FtMobileAgent.xcodeproj/project.pbxproj +22 -0
  22. package/lib/commonjs/ft_logger.js +14 -13
  23. package/lib/commonjs/ft_logger.js.map +1 -1
  24. package/lib/commonjs/ft_mobile_agent.js +153 -6
  25. package/lib/commonjs/ft_mobile_agent.js.map +1 -1
  26. package/lib/commonjs/ft_rum.js +55 -21
  27. package/lib/commonjs/ft_rum.js.map +1 -1
  28. package/lib/commonjs/ft_tracing.js +29 -10
  29. package/lib/commonjs/ft_tracing.js.map +1 -1
  30. package/lib/commonjs/index.js +30 -0
  31. package/lib/commonjs/index.js.map +1 -1
  32. package/lib/commonjs/rum/FTRumActionTracking.js +10 -4
  33. package/lib/commonjs/rum/FTRumActionTracking.js.map +1 -1
  34. package/lib/commonjs/rum/FTRumErrorTracking.js +4 -4
  35. package/lib/commonjs/rum/FTRumErrorTracking.js.map +1 -1
  36. package/lib/commonjs/specs/NativeFTMobileReactNative.js +10 -0
  37. package/lib/commonjs/specs/NativeFTMobileReactNative.js.map +1 -0
  38. package/lib/commonjs/specs/NativeFTReactNativeLog.js +10 -0
  39. package/lib/commonjs/specs/NativeFTReactNativeLog.js.map +1 -0
  40. package/lib/commonjs/specs/NativeFTReactNativeRUM.js +10 -0
  41. package/lib/commonjs/specs/NativeFTReactNativeRUM.js.map +1 -0
  42. package/lib/commonjs/specs/NativeFTReactNativeTrace.js +10 -0
  43. package/lib/commonjs/specs/NativeFTReactNativeTrace.js.map +1 -0
  44. package/lib/commonjs/version.js +1 -1
  45. package/lib/commonjs/version.js.map +1 -1
  46. package/lib/module/ft_logger.js +14 -12
  47. package/lib/module/ft_logger.js.map +1 -1
  48. package/lib/module/ft_mobile_agent.js +159 -5
  49. package/lib/module/ft_mobile_agent.js.map +1 -1
  50. package/lib/module/ft_rum.js +54 -16
  51. package/lib/module/ft_rum.js.map +1 -1
  52. package/lib/module/ft_tracing.js +29 -9
  53. package/lib/module/ft_tracing.js.map +1 -1
  54. package/lib/module/index.js +3 -3
  55. package/lib/module/index.js.map +1 -1
  56. package/lib/module/rum/FTRumActionTracking.js +10 -4
  57. package/lib/module/rum/FTRumActionTracking.js.map +1 -1
  58. package/lib/module/rum/FTRumErrorTracking.js +4 -4
  59. package/lib/module/rum/FTRumErrorTracking.js.map +1 -1
  60. package/lib/module/specs/NativeFTMobileReactNative.js +5 -0
  61. package/lib/module/specs/NativeFTMobileReactNative.js.map +1 -0
  62. package/lib/module/specs/NativeFTReactNativeLog.js +5 -0
  63. package/lib/module/specs/NativeFTReactNativeLog.js.map +1 -0
  64. package/lib/module/specs/NativeFTReactNativeRUM.js +5 -0
  65. package/lib/module/specs/NativeFTReactNativeRUM.js.map +1 -0
  66. package/lib/module/specs/NativeFTReactNativeTrace.js +5 -0
  67. package/lib/module/specs/NativeFTReactNativeTrace.js.map +1 -0
  68. package/lib/module/version.js +1 -1
  69. package/lib/module/version.js.map +1 -1
  70. package/lib/typescript/ft_logger.d.ts +6 -6
  71. package/lib/typescript/ft_mobile_agent.d.ts +165 -14
  72. package/lib/typescript/ft_rum.d.ts +32 -8
  73. package/lib/typescript/ft_tracing.d.ts +6 -6
  74. package/lib/typescript/index.d.ts +3 -3
  75. package/lib/typescript/specs/NativeFTMobileReactNative.d.ts +75 -0
  76. package/lib/typescript/specs/NativeFTReactNativeLog.d.ts +23 -0
  77. package/lib/typescript/specs/NativeFTReactNativeRUM.d.ts +89 -0
  78. package/lib/typescript/specs/NativeFTReactNativeTrace.d.ts +24 -0
  79. package/lib/typescript/version.d.ts +1 -1
  80. package/package.json +29 -96
  81. package/scripts/replace-react-require.js +37 -38
  82. package/src/ft_logger.tsx +71 -40
  83. package/src/ft_mobile_agent.tsx +374 -92
  84. package/src/ft_rum.tsx +227 -123
  85. package/src/ft_tracing.tsx +58 -38
  86. package/src/index.tsx +58 -16
  87. package/src/rum/FTRumActionTracking.tsx +212 -204
  88. package/src/rum/FTRumErrorTracking.tsx +70 -71
  89. package/src/specs/NativeFTMobileReactNative.ts +83 -0
  90. package/src/specs/NativeFTReactNativeLog.ts +29 -0
  91. package/src/specs/NativeFTReactNativeRUM.ts +104 -0
  92. package/src/specs/NativeFTReactNativeTrace.ts +26 -0
  93. package/src/version.ts +1 -1
  94. package/LICENSE +0 -201
  95. package/android/.project +0 -17
  96. package/android/.settings/org.eclipse.buildship.core.prefs +0 -13
  97. package/android/gradlew +0 -185
  98. package/android/local.properties +0 -8
  99. package/android/src/main/java/com/ft/sdk/InnerClassProxy.java +0 -8
  100. package/ios/.idea/.name +0 -1
  101. package/ios/.idea/ios.iml +0 -2
  102. package/ios/.idea/modules.xml +0 -8
  103. package/ios/.idea/vcs.xml +0 -6
  104. package/ios/.idea/xcode.xml +0 -4
  105. package/ios/FTMobileReactNative.m +0 -183
  106. package/ios/FTReactNativeLog.m +0 -60
  107. package/ios/FTReactNativeTrace.m +0 -58
  108. package/ios/FtMobileAgent.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -4
  109. package/ios/FtMobileAgent.xcodeproj/project.xcworkspace/xcuserdata/Brandon.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  110. package/ios/FtMobileAgent.xcodeproj/project.xcworkspace/xcuserdata/Brandon.xcuserdatad/xcschemes/xcschememanagement.plist +0 -5
  111. package/ios/FtMobileAgent.xcodeproj/xcuserdata/Brandon.xcuserdatad/xcschemes/FtMobileAgent.xcscheme +0 -56
  112. package/ios/FtMobileAgent.xcodeproj/xcuserdata/Brandon.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
  113. package/ios/RCTVersion.h +0 -8
@@ -35,13 +35,13 @@ type FTReactNativeTraceType = {
35
35
  * @returns trace request header parameters
36
36
  * @deprecated use getTraceHeaderFields() replace.
37
37
  */
38
- getTraceHeader(key: String, url: String): Promise<object>;
38
+ getTraceHeader(key: string, url: string): Promise<object>;
39
39
  /**
40
- * Get trace HTTP request header data.
41
- * @param url request URL
42
- * @returns trace request header parameters
43
- */
44
- getTraceHeaderFields(url: String, key?: String): Promise<object>;
40
+ * Get trace HTTP request header data.
41
+ * @param url request URL
42
+ * @returns trace request header parameters
43
+ */
44
+ getTraceHeaderFields(url: string, key?: string): Promise<object>;
45
45
  };
46
46
  export declare const FTReactNativeTrace: FTReactNativeTraceType;
47
47
  export {};
@@ -1,7 +1,7 @@
1
- import { FTMobileConfig, FTMobileReactNative, EnvType, FTDBCacheDiscard } from './ft_mobile_agent';
1
+ import { FTMobileConfig, FTMobileReactNative, EnvType, FTDBCacheDiscard, FTRemoteConfigResult, FTRemoteConfigOverrideRule, FTRemoteConfigOverrideMatch, FTRemoteConfigOverrideValues } from './ft_mobile_agent';
2
2
  import { FTLogConfig, FTReactNativeLog, FTLogStatus, FTLogCacheDiscard } from './ft_logger';
3
- import { FTRUMConfig, FTRUMResource, FTReactNativeRUM, ErrorMonitorType, DeviceMetricsMonitorType, DetectFrequency, FTRUMResourceMetrics, FTRUMCacheDiscard } from './ft_rum';
3
+ import { FTRUMConfig, FTRUMResource, FTReactNativeRUM, ErrorMonitorType, DeviceMetricsMonitorType, DetectFrequency, FTRUMResourceMetrics, FTRUMCacheDiscard, IOSCrashMonitoringType } from './ft_rum';
4
4
  import { FTTraceConfig, FTReactNativeTrace, TraceType } from './ft_tracing';
5
5
  import { FTRumActionTracking } from './rum/FTRumActionTracking';
6
6
  import { FTRumErrorTracking } from './rum/FTRumErrorTracking';
7
- export { FTMobileReactNative, FTMobileConfig, EnvType, FTDBCacheDiscard, FTLogConfig, FTReactNativeLog, FTLogStatus, FTLogCacheDiscard, FTRUMConfig, FTReactNativeRUM, FTRUMResource, ErrorMonitorType, DeviceMetricsMonitorType, DetectFrequency, FTRUMResourceMetrics, FTRUMCacheDiscard, FTTraceConfig, FTReactNativeTrace, TraceType, FTRumActionTracking, FTRumErrorTracking };
7
+ 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, };
@@ -0,0 +1,75 @@
1
+ import type { TurboModule } from 'react-native';
2
+ export interface Spec extends TurboModule {
3
+ /**
4
+ * SDK initialization method.
5
+ * @param config SDK initialization configuration items.
6
+ * @returns a Promise.
7
+ */
8
+ sdkConfig(config: Object): Promise<void>;
9
+ /**
10
+ * Dynamically set the Datakit upload URL after SDK initialization.
11
+ * @param datakitUrl Datakit upload URL.
12
+ * @returns a Promise.
13
+ */
14
+ setDatakitURL(datakitUrl: string): Promise<void>;
15
+ /**
16
+ * Dynamically set the Dataway upload URL and client token after SDK initialization.
17
+ * @param datawayUrl Dataway upload URL.
18
+ * @param clientToken Dataway authentication token.
19
+ * @returns a Promise.
20
+ */
21
+ setDatawayURL(datawayUrl: string, clientToken: string): Promise<void>;
22
+ /**
23
+ * Bind user.
24
+ * @param userId user ID.
25
+ * @param userName user name.
26
+ * @param userEmail user email
27
+ * @param extra additional user information
28
+ * @returns a Promise.
29
+ */
30
+ bindRUMUserData(userId: string, userName?: string, userEmail?: string, extra?: Object): Promise<void>;
31
+ /**
32
+ * Unbind user.
33
+ * @returns a Promise.
34
+ */
35
+ unbindRUMUserData(): Promise<void>;
36
+ /**
37
+ * Add custom global parameters. Applies to RUM and Log data
38
+ * @param context custom global parameters.
39
+ * @returns a Promise.
40
+ */
41
+ appendGlobalContext(context: Object): Promise<void>;
42
+ /**
43
+ * Add custom RUM global parameters. Applies to RUM data
44
+ * @param context custom RUM global parameters.
45
+ * @returns a Promise.
46
+ */
47
+ appendRUMGlobalContext(context: Object): Promise<void>;
48
+ /**
49
+ * Add custom RUM and Log global parameters. Applies to Log data
50
+ * @param context custom Log global parameters.
51
+ * @returns a Promise.
52
+ */
53
+ appendLogGlobalContext(context: Object): Promise<void>;
54
+ /**
55
+ * Actively synchronize data. When `FTMobileConfig.autoSync=false` is configured, you need to actively trigger this method to synchronize data.
56
+ * @returns a Promise.
57
+ */
58
+ flushSyncData(): Promise<void>;
59
+ /**
60
+ * Synchronize events in iOS Widget Extension, iOS only
61
+ * @param groupIdentifier app groupId
62
+ * @returns {groupIdentifier:string,datas:Array<Object>} can be used to view data collected in Extension.
63
+ */
64
+ trackEventFromExtension(identifier: string): Promise<Object>;
65
+ /**
66
+ * Shut down objects currently running in the SDK
67
+ */
68
+ shutDown(): Promise<void>;
69
+ /**
70
+ * Clear all data that has not yet been uploaded to the server.
71
+ */
72
+ clearAllData(): Promise<void>;
73
+ }
74
+ declare const _default: Spec | null;
75
+ export default _default;
@@ -0,0 +1,23 @@
1
+ import type { TurboModule } from 'react-native';
2
+ export interface Spec extends TurboModule {
3
+ /**
4
+ *Configure log output configuration to enable log collection.
5
+ */
6
+ logConfig(config: Object): Promise<void>;
7
+ /**
8
+ * Output log.
9
+ * @param content log content
10
+ * @param status log status
11
+ * @param property log context (optional)
12
+ */
13
+ logging(content: string, logStatus: number, property?: Object): Promise<void>;
14
+ /**
15
+ * Output log.
16
+ * @param content log content
17
+ * @param status log status
18
+ * @param property log context (optional)
19
+ */
20
+ logWithStatusString(content: string, logStatus: string, property?: Object): Promise<void>;
21
+ }
22
+ declare const _default: Spec | null;
23
+ export default _default;
@@ -0,0 +1,89 @@
1
+ import type { TurboModule } from 'react-native';
2
+ export interface Spec extends TurboModule {
3
+ /**
4
+ * Set RUM tracking conditions and enable RUM collection.
5
+ * @param config rum configuration parameters.
6
+ * @returns a Promise.
7
+ */
8
+ setConfig(config: Object): Promise<void>;
9
+ /**
10
+ * Start RUM Action.
11
+ * RUM will bind Resource, Error, LongTask events that may be triggered by this Action.
12
+ * 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.
13
+ * Adding Action with `addAction` method does not affect each other.
14
+ * @param actionName action name
15
+ * @param actionType action type
16
+ * @param property event context (optional)
17
+ * @returns a Promise.
18
+ */
19
+ startAction(actionName: string, actionType: string, property?: Object): Promise<void>;
20
+ /**
21
+ * Add Action event. This type of data cannot be associated with Error, Resource, LongTask data, and has no discard logic.
22
+ * @param actionName action name
23
+ * @param actionType action type
24
+ * @param property event context (optional)
25
+ * @returns a Promise.
26
+ */
27
+ addAction(actionName: string, actionType: string, property?: Object): Promise<void>;
28
+ /**
29
+ * view load duration.
30
+ * @param viewName view name
31
+ * @param loadTime view load duration
32
+ * @returns a Promise.
33
+ */
34
+ onCreateView(viewName: string, loadTime: number): Promise<void>;
35
+ /**
36
+ * view start.
37
+ * @param viewName page name
38
+ * @param property event context (optional)
39
+ * @returns a Promise.
40
+ */
41
+ startView(viewName: string, property?: Object): Promise<void>;
42
+ /**
43
+ * view end.
44
+ * @param property event context (optional)
45
+ * @returns a Promise.
46
+ */
47
+ stopView(property?: Object): Promise<void>;
48
+ /**
49
+ * Exception capture and log collection.
50
+ * @param stack stack log
51
+ * @param message error message
52
+ * @param property event context (optional)
53
+ * @returns a Promise.
54
+ */
55
+ addError(stack: string, message: string, property?: Object): Promise<void>;
56
+ /**
57
+ * Exception capture and log collection.
58
+ * @param type error type
59
+ * @param stack stack log
60
+ * @param message error message
61
+ * @param property event context (optional)
62
+ * @returns a Promise.
63
+ */
64
+ addErrorWithType(type: string, stack: string, message: string, property?: Object): Promise<void>;
65
+ /**
66
+ * Start resource request.
67
+ * @param key unique id
68
+ * @param property event context (optional)
69
+ * @returns a Promise.
70
+ */
71
+ startResource(key: string, property?: Object): Promise<void>;
72
+ /**
73
+ * End resource request.
74
+ * @param key unique id
75
+ * @param property event context (optional)
76
+ * @returns a Promise.
77
+ */
78
+ stopResource(key: string, property?: Object): Promise<void>;
79
+ /**
80
+ * Send resource data metrics.
81
+ * @param key unique id
82
+ * @param resource resource data
83
+ * @param metrics resource performance data
84
+ * @returns a Promise.
85
+ */
86
+ addResource(key: string, resource: Object, metrics?: Object): Promise<void>;
87
+ }
88
+ declare const _default: Spec | null;
89
+ export default _default;
@@ -0,0 +1,24 @@
1
+ import type { TurboModule } from 'react-native';
2
+ export interface Spec extends TurboModule {
3
+ /**
4
+ * Configure trace to enable distributed tracing.
5
+ * @param config trace configuration parameters.
6
+ * @returns a Promise.
7
+ */
8
+ setConfig(config: Object): Promise<void>;
9
+ /**
10
+ * Get trace HTTP request header data.
11
+ * @param url request URL
12
+ * @returns trace request header parameters
13
+ * @deprecated use getTraceHeaderFields() replace.
14
+ */
15
+ getTraceHeader(key: string, url: string): Promise<Object>;
16
+ /**
17
+ * Get trace HTTP request header data.
18
+ * @param url request URL
19
+ * @returns trace request header parameters
20
+ */
21
+ getTraceHeaderFields(url: string, key?: string): Promise<Object>;
22
+ }
23
+ declare const _default: Spec | null;
24
+ export default _default;
@@ -1 +1 @@
1
- export declare const version = "0.3.15";
1
+ export declare const version = "0.4.1";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@truewatchtech/react-native-mobile",
3
- "version": "0.3.15",
4
- "description": "Base on TrueWatch Android iOS React Native SDK",
3
+ "version": "0.4.1",
4
+ "description": "Base on TrueWatchTech Android iOS React Native SDK",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
7
7
  "types": "lib/typescript/index.d.ts",
@@ -16,23 +16,25 @@
16
16
  "cpp",
17
17
  "FTMobileReactNativeSDK.podspec",
18
18
  "!lib/typescript/example",
19
+ "!android/.project",
19
20
  "!android/build",
20
21
  "!android/.gradle",
21
22
  "!android/.idea",
23
+ "!android/.settings",
22
24
  "!ios/build",
25
+ "!ios/**/xcuserdata",
26
+ "!ios/**/*.xcuserstate",
23
27
  "!**/__tests__",
24
28
  "!**/__fixtures__",
25
29
  "!**/__mocks__"
26
30
  ],
27
31
  "scripts": {
28
- "test": "jest",
29
- "typescript": "tsc --noEmit",
30
- "lint": "eslint \"**/*.{js,ts,tsx}\"",
31
- "prepare": "genversion --es6 --semi src/version.ts && bob build",
32
- "release": "release-it",
33
- "example": "yarn --cwd example",
34
- "pods": "cd example && pod-install --quiet",
35
- "bootstrap": "yarn example && yarn && yarn pods",
32
+ "test": "yarn run -T jest",
33
+ "typescript": "yarn run -T tsc --noEmit",
34
+ "lint": "yarn run -T eslint \"**/*.{js,ts,tsx}\"",
35
+ "prepare": "yarn run -T genversion --es6 --semi src/version.ts && yarn run -T bob build",
36
+ "prepack": "yarn run -T check-version && yarn prepare",
37
+ "release": "yarn run -T release-it",
36
38
  "postinstall": "node scripts/replace-react-require.js"
37
39
  },
38
40
  "keywords": [
@@ -43,38 +45,19 @@
43
45
  ],
44
46
  "repository": {
45
47
  "type": "git",
46
- "url": "git+https://github.com/TrueWatchTech/datakit-react-native.git"
48
+ "url": "git+https://github.com/GuanceCloud/datakit-react-native.git"
47
49
  },
48
50
  "author": "Brandon <brandonfaustine@gmail.com> (https://github.com/Br4ndonZhang)",
49
51
  "license": "Apache-2.0",
50
52
  "bugs": {
51
- "url": "https://github.com/TrueWatchTech/datakit-react-native.git/issues"
53
+ "url": "https://github.com/GuanceCloud/datakit-react-native.git/issues"
52
54
  },
53
- "homepage": "https://github.com/TrueWatchTech/datakit-react-native.git#readme",
55
+ "homepage": "https://github.com/GuanceCloud/datakit-react-native.git#readme",
54
56
  "publishConfig": {
55
57
  "registry": "https://registry.npmjs.org/"
56
58
  },
57
- "devDependencies": {
58
- "@commitlint/config-conventional": "^11.0.0",
59
- "@react-native-community/eslint-config": "^2.0.0",
60
- "@release-it/conventional-changelog": "^2.0.0",
61
- "@types/jest": "^26.0.0",
62
- "@types/react": "^16.9.19",
63
- "@types/react-native": "0.62.13",
64
- "commitlint": "^11.0.0",
65
- "eslint": "^7.2.0",
66
- "eslint-config-prettier": "^7.0.0",
67
- "eslint-plugin-prettier": "^3.1.3",
68
- "genversion": "3.0.2",
69
- "husky": "^4.2.5",
70
- "jest": "^26.0.1",
71
- "pod-install": "^0.1.0",
72
- "prettier": "^2.0.5",
73
- "react": "18.1.0",
74
- "react-native": "0.70.0",
75
- "react-native-builder-bob": "^0.17.1",
76
- "release-it": "^14.2.2",
77
- "typescript": "^4.1.3"
59
+ "engines": {
60
+ "node": ">=18"
78
61
  },
79
62
  "peerDependencies": {
80
63
  "react": ">=16.13.1",
@@ -83,67 +66,9 @@
83
66
  "jest": {
84
67
  "preset": "react-native",
85
68
  "modulePathIgnorePatterns": [
86
- "<rootDir>/example/node_modules",
87
69
  "<rootDir>/lib/"
88
70
  ]
89
71
  },
90
- "husky": {
91
- "hooks": {
92
- "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
93
- "pre-commit": "yarn lint && yarn typescript"
94
- }
95
- },
96
- "commitlint": {
97
- "extends": [
98
- "@commitlint/config-conventional"
99
- ]
100
- },
101
- "release-it": {
102
- "git": {
103
- "commitMessage": "chore: release ${version}",
104
- "tagName": "v${version}"
105
- },
106
- "npm": {
107
- "publish": true
108
- },
109
- "github": {
110
- "release": true
111
- },
112
- "plugins": {
113
- "@release-it/conventional-changelog": {
114
- "preset": "angular"
115
- }
116
- }
117
- },
118
- "eslintConfig": {
119
- "root": true,
120
- "extends": [
121
- "@react-native-community",
122
- "prettier"
123
- ],
124
- "rules": {
125
- "prettier/prettier": [
126
- "error", {
127
- "quoteProps": "consistent",
128
- "singleQuote": true,
129
- "tabWidth": 2,
130
- "trailingComma": "es5",
131
- "useTabs": false
132
- }
133
- ]
134
- }
135
- },
136
- "eslintIgnore": [
137
- "node_modules/",
138
- "lib/"
139
- ],
140
- "prettier": {
141
- "quoteProps": "consistent",
142
- "singleQuote": true,
143
- "tabWidth": 2,
144
- "trailingComma": "es5",
145
- "useTabs": false
146
- },
147
72
  "react-native-builder-bob": {
148
73
  "source": "src",
149
74
  "output": "lib",
@@ -151,17 +76,25 @@
151
76
  "commonjs",
152
77
  "module",
153
78
  [
154
- "typescript", {
155
- "project": "tsconfig.build.json"
79
+ "typescript",
80
+ {
81
+ "tsc": "../../node_modules/.bin/tsc"
156
82
  }
157
83
  ]
158
84
  ]
159
85
  },
86
+ "codegenConfig": {
87
+ "name": "FTSdkReactNative",
88
+ "type": "all",
89
+ "jsSrcsDir": "./src/specs",
90
+ "android": {
91
+ "javaPackageName": "com.ft.sdk.reactnative"
92
+ }
93
+ },
160
94
  "dependencies": {
161
95
  "@babel/runtime": "^7.16.5"
162
96
  },
163
97
  "directories": {
164
- "example": "example",
165
98
  "lib": "lib"
166
99
  }
167
- }
100
+ }
@@ -2,51 +2,50 @@
2
2
 
3
3
  // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
4
4
  const { readFileSync, writeFileSync } = require('fs');
5
- const GET_JSX_RUNTIME_RELATIVE_PATH =
6
- 'rum/FTRumActionTracking';
5
+ const GET_JSX_RUNTIME_RELATIVE_PATH = 'rum/FTRumActionTracking';
7
6
 
8
7
  const isJsxExportedInReactVersion = (major, minor) => {
9
- if (Number(major) > 16) {
10
- return true;
11
- }
12
- if (Number(major) === 16 && Number(minor) > 13) {
13
- return true;
14
- }
15
- return false;
8
+ if (Number(major) > 16) {
9
+ return true;
10
+ }
11
+ if (Number(major) === 16 && Number(minor) > 13) {
12
+ return true;
13
+ }
14
+ return false;
16
15
  };
17
16
  const replaceReactJsxRequire = () => {
18
- process.stdout.write('[FTLog] replacing react/jsx-runtime by react\n');
19
- const actionFilePath = `${__dirname}/..`;
20
- const locations = [
21
- { directory: `${actionFilePath}/src`, extension: 'tsx' },
22
- { directory: `${actionFilePath}/lib/commonjs`, extension: 'js' },
23
- { directory: `${actionFilePath}/lib/commonjs`, extension: 'js.map' },
24
- { directory: `${actionFilePath}/lib/module`, extension: 'js' },
25
- { directory: `${actionFilePath}/lib/module`, extension: 'js.map' }
26
- ];
17
+ process.stdout.write('[FTLog] replacing react/jsx-runtime by react\n');
18
+ const actionFilePath = `${__dirname}/..`;
19
+ const locations = [
20
+ { directory: `${actionFilePath}/src`, extension: 'tsx' },
21
+ { directory: `${actionFilePath}/lib/commonjs`, extension: 'js' },
22
+ { directory: `${actionFilePath}/lib/commonjs`, extension: 'js.map' },
23
+ { directory: `${actionFilePath}/lib/module`, extension: 'js' },
24
+ { directory: `${actionFilePath}/lib/module`, extension: 'js.map' },
25
+ ];
27
26
 
28
- locations.forEach(location => {
29
- const fileLocation = `${location.directory}/${GET_JSX_RUNTIME_RELATIVE_PATH}.${location.extension}`;
30
- const file = readFileSync(fileLocation).toString();
31
- writeFileSync(
32
- fileLocation,
33
- file.replace("require('react/jsx-runtime')", "require('react')")
34
- );
35
- });
27
+ locations.forEach((location) => {
28
+ const fileLocation = `${location.directory}/${GET_JSX_RUNTIME_RELATIVE_PATH}.${location.extension}`;
29
+ const file = readFileSync(fileLocation).toString();
30
+ writeFileSync(
31
+ fileLocation,
32
+ file.replace("require('react/jsx-runtime')", "require('react')")
33
+ );
34
+ });
36
35
  };
37
36
 
38
37
  try {
39
- // Get React version
40
- // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
41
- const [major, minor] = require('react/package.json').version.split('.');
42
- process.stdout.write(`[FTLog] found react version ${major}${minor}\n`);
38
+ // Get React version
39
+ // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
40
+ const [major, minor] = require('react/package.json').version.split('.');
41
+ process.stdout.write(`[FTLog] found react version ${major}${minor}\n`);
43
42
 
44
- if (!isJsxExportedInReactVersion(major, minor)) {
45
- replaceReactJsxRequire();
46
- }
47
- process.stdout.write('[FTLog] postinstall replace-react-require end\n');
43
+ if (!isJsxExportedInReactVersion(major, minor)) {
44
+ replaceReactJsxRequire();
45
+ }
46
+ process.stdout.write('[FTLog] postinstall replace-react-require end\n');
48
47
  } catch (error) {
49
- process.stderr.write(
50
- `[FTLog] Error running replace-react-require: ${error}\n`
51
- );
52
- }
48
+ process.stderr.write(
49
+ `[FTLog] Error running replace-react-require: ${error}\n`
50
+ );
51
+ }
package/src/ft_logger.tsx CHANGED
@@ -1,14 +1,21 @@
1
- import { NativeModules } from 'react-native';
1
+ import { bridgeContextManager } from './ft_mobile_agent';
2
2
  /**
3
3
  * Set log level.
4
4
  */
5
- export enum FTLogStatus {
6
- info, warning, error, critical, ok,
7
- };
5
+ export enum FTLogStatus {
6
+ info,
7
+ warning,
8
+ error,
9
+ critical,
10
+ ok,
11
+ }
8
12
  /**
9
13
  * Log discard method.
10
14
  */
11
- export enum FTLogCacheDiscard { discard, discardOldest };
15
+ export enum FTLogCacheDiscard {
16
+ discard,
17
+ discardOldest,
18
+ }
12
19
  /**
13
20
  * Configure log output configuration.
14
21
  * @param sampleRate sampling rate
@@ -19,59 +26,83 @@ import { NativeModules } from 'react-native';
19
26
  * @param globalContext custom global parameters
20
27
  * @param logCacheLimitCount get maximum log entry count limit [1000,), default 5000
21
28
  */
22
- export interface FTLogConfig{
23
- sampleRate?: number,
24
- enableLinkRumData?: boolean,
25
- enableCustomLog?: boolean,
26
- discardStrategy?: FTLogCacheDiscard,
27
- logLevelFilters?: Array<FTLogStatus>,
28
- globalContext?:object,
29
- logCacheLimitCount?: number
30
- };
29
+ export interface FTLogConfig {
30
+ sampleRate?: number;
31
+ enableLinkRumData?: boolean;
32
+ enableCustomLog?: boolean;
33
+ discardStrategy?: FTLogCacheDiscard;
34
+ logLevelFilters?: Array<FTLogStatus>;
35
+ globalContext?: object;
36
+ logCacheLimitCount?: number;
37
+ }
31
38
 
32
- type FTReactNativeLogType = {
39
+ type FTReactNativeLogType = {
33
40
  /**
34
41
  *Configure log output configuration to enable log collection.
35
42
  */
36
- logConfig(config: FTLogConfig): Promise<void>;
43
+ logConfig(config: FTLogConfig): Promise<void>;
37
44
  /**
38
45
  * Output log.
39
46
  * @param content log content
40
47
  * @param status log status
41
48
  * @param property log context (optional)
42
49
  */
43
- logging(content:String,logStatus:FTLogStatus,property?:object): Promise<void>;
44
- /**
45
- * Output log.
46
- * @param content log content
47
- * @param status log status
48
- * @param property log context (optional)
49
- */
50
- logWithStatusString(content:String,logStatus:String,property?:object): Promise<void>;
51
- };
50
+ logging(
51
+ content: string,
52
+ logStatus: FTLogStatus,
53
+ property?: object
54
+ ): Promise<void>;
55
+ /**
56
+ * Output log.
57
+ * @param content log content
58
+ * @param status log status
59
+ * @param property log context (optional)
60
+ */
61
+ logWithStatusString(
62
+ content: string,
63
+ logStatus: string,
64
+ property?: object
65
+ ): Promise<void>;
66
+ };
52
67
 
53
- class FTReactNativeLogWrapper {
54
- private logger: FTReactNativeLogType = NativeModules.FTReactNativeLog;
68
+ class FTReactNativeLogWrapper {
69
+ /* eslint-disable @typescript-eslint/no-var-requires */
70
+ private logger: FTReactNativeLogType =
71
+ require('./specs/NativeFTReactNativeLog').default;
72
+ /* eslint-enable @typescript-eslint/no-var-requires */
55
73
 
56
74
  /**
57
75
  *Configure log output configuration to enable log collection.
58
76
  */
59
- logConfig(config:FTLogConfig): Promise<void>{
60
- return this.logger.logConfig(config);
61
- }
77
+ logConfig(config: FTLogConfig): Promise<void> {
78
+ return this.logger.logConfig(config);
79
+ }
62
80
 
63
- /**
81
+ /**
64
82
  * Output log.
65
83
  * @param content log content
66
84
  * @param status log status
67
85
  * @param property log context (optional)
68
86
  */
69
- logging(content:String,logStatus:FTLogStatus|String,property?:object): Promise<void>{
70
- if((typeof logStatus)==='string'){
71
- return this.logger.logWithStatusString(content,logStatus.toString(),property)
72
- }
73
- let enumLogStatus: FTLogStatus = logStatus as FTLogStatus;
74
- return this.logger.logging(content,enumLogStatus,property);
75
- }
76
- }
77
- export const FTReactNativeLog: FTReactNativeLogWrapper = new FTReactNativeLogWrapper();
87
+ logging(
88
+ content: string,
89
+ logStatus: FTLogStatus | string,
90
+ property?: object
91
+ ): Promise<void> {
92
+ // Automatically merge bridge context properties with local properties
93
+ const mergedProperties =
94
+ bridgeContextManager.mergeWithLocalPropertiesSync(property);
95
+
96
+ if (typeof logStatus === 'string') {
97
+ return this.logger.logWithStatusString(
98
+ content,
99
+ logStatus.toString(),
100
+ mergedProperties
101
+ );
102
+ }
103
+ let enumLogStatus: FTLogStatus = logStatus as FTLogStatus;
104
+ return this.logger.logging(content, enumLogStatus, mergedProperties);
105
+ }
106
+ }
107
+ export const FTReactNativeLog: FTReactNativeLogWrapper =
108
+ new FTReactNativeLogWrapper();