@datadog/mobile-react-native 1.7.1 → 1.8.0-rc0

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 (131) hide show
  1. package/DatadogSDKReactNative.podspec +14 -1
  2. package/android/build.gradle +20 -7
  3. package/android/src/main/kotlin/com/datadog/reactnative/{DdLogs.kt → DdLogsImplementation.kt} +3 -17
  4. package/android/src/main/kotlin/com/datadog/reactnative/{DdRum.kt → DdRumImplementation.kt} +2 -18
  5. package/android/src/main/kotlin/com/datadog/reactnative/{DdSdk.kt → DdSdkImplementation.kt} +3 -14
  6. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkReactNativePackage.kt +34 -17
  7. package/android/src/main/kotlin/com/datadog/reactnative/{DdTrace.kt → DdTraceImplementation.kt} +6 -11
  8. package/android/src/newarch/kotlin/com/datadog/reactnative/DdLogs.kt +148 -0
  9. package/android/src/newarch/kotlin/com/datadog/reactnative/DdRum.kt +199 -0
  10. package/android/src/newarch/kotlin/com/datadog/reactnative/DdSdk.kt +90 -0
  11. package/android/src/newarch/kotlin/com/datadog/reactnative/DdTrace.kt +46 -0
  12. package/android/src/oldarch/kotlin/com/datadog/reactnative/DdLogs.kt +163 -0
  13. package/android/src/oldarch/kotlin/com/datadog/reactnative/DdRum.kt +200 -0
  14. package/android/src/oldarch/kotlin/com/datadog/reactnative/DdSdk.kt +91 -0
  15. package/android/src/oldarch/kotlin/com/datadog/reactnative/DdTrace.kt +47 -0
  16. package/android/src/test/kotlin/com/datadog/reactnative/DdLogsTest.kt +3 -13
  17. package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +2 -6
  18. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +33 -33
  19. package/android/src/test/kotlin/com/datadog/reactnative/DdTraceTest.kt +2 -6
  20. package/ios/Sources/{DdSdkReactNative-Bridging-Header.h → DatadogSDKReactNative.h} +2 -1
  21. package/ios/Sources/DdLogs.h +24 -0
  22. package/ios/Sources/DdLogs.mm +149 -0
  23. package/ios/Sources/{DdLogs.swift → DdLogsImplementation.swift} +20 -29
  24. package/ios/Sources/DdRum.h +24 -0
  25. package/ios/Sources/DdRum.mm +188 -0
  26. package/ios/Sources/{DdRum.swift → DdRumImplementation.swift} +28 -35
  27. package/ios/Sources/DdSdk.h +24 -0
  28. package/ios/Sources/DdSdk.mm +119 -0
  29. package/ios/Sources/{DdSdk.swift → DdSdkImplementation.swift} +20 -25
  30. package/ios/Sources/DdTrace.h +24 -0
  31. package/ios/Sources/DdTrace.mm +66 -0
  32. package/ios/Sources/{DdTrace.swift → DdTraceImplementation.swift} +10 -17
  33. package/ios/Sources/QueueHolder.swift +8 -0
  34. package/jest/mock.js +3 -1
  35. package/lib/commonjs/DdSdkReactNative.js +32 -49
  36. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  37. package/lib/commonjs/DdSdkReactNativeConfiguration.js +18 -0
  38. package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
  39. package/lib/commonjs/logs/DdLogs.js +33 -40
  40. package/lib/commonjs/logs/DdLogs.js.map +1 -1
  41. package/lib/commonjs/nativeModulesTypes.js +13 -0
  42. package/lib/commonjs/nativeModulesTypes.js.map +1 -1
  43. package/lib/commonjs/rum/DdRum.js +104 -106
  44. package/lib/commonjs/rum/DdRum.js.map +1 -1
  45. package/lib/commonjs/rum/eventMappers/errorEventMapper.js.map +1 -1
  46. package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +11 -1
  47. package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
  48. package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +6 -2
  49. package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
  50. package/lib/commonjs/sdk/DdSdk.js +3 -3
  51. package/lib/commonjs/sdk/DdSdk.js.map +1 -1
  52. package/lib/commonjs/specs/NativeDdLogs.js +20 -0
  53. package/lib/commonjs/specs/NativeDdLogs.js.map +1 -0
  54. package/lib/commonjs/specs/NativeDdRum.js +20 -0
  55. package/lib/commonjs/specs/NativeDdRum.js.map +1 -0
  56. package/lib/commonjs/specs/NativeDdSdk.js +20 -0
  57. package/lib/commonjs/specs/NativeDdSdk.js.map +1 -0
  58. package/lib/commonjs/specs/NativeDdTrace.js +20 -0
  59. package/lib/commonjs/specs/NativeDdTrace.js.map +1 -0
  60. package/lib/commonjs/trace/DdTrace.js +10 -12
  61. package/lib/commonjs/trace/DdTrace.js.map +1 -1
  62. package/lib/commonjs/version.js +1 -1
  63. package/lib/commonjs/version.js.map +1 -1
  64. package/lib/module/DdSdkReactNative.js +27 -44
  65. package/lib/module/DdSdkReactNative.js.map +1 -1
  66. package/lib/module/DdSdkReactNativeConfiguration.js +18 -0
  67. package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
  68. package/lib/module/logs/DdLogs.js +33 -39
  69. package/lib/module/logs/DdLogs.js.map +1 -1
  70. package/lib/module/nativeModulesTypes.js +13 -0
  71. package/lib/module/nativeModulesTypes.js.map +1 -1
  72. package/lib/module/rum/DdRum.js +100 -101
  73. package/lib/module/rum/DdRum.js.map +1 -1
  74. package/lib/module/rum/eventMappers/errorEventMapper.js.map +1 -1
  75. package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +11 -1
  76. package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
  77. package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +6 -2
  78. package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
  79. package/lib/module/sdk/DdSdk.js +3 -2
  80. package/lib/module/sdk/DdSdk.js.map +1 -1
  81. package/lib/module/specs/NativeDdLogs.js +14 -0
  82. package/lib/module/specs/NativeDdLogs.js.map +1 -0
  83. package/lib/module/specs/NativeDdRum.js +14 -0
  84. package/lib/module/specs/NativeDdRum.js.map +1 -0
  85. package/lib/module/specs/NativeDdSdk.js +14 -0
  86. package/lib/module/specs/NativeDdSdk.js.map +1 -0
  87. package/lib/module/specs/NativeDdTrace.js +14 -0
  88. package/lib/module/specs/NativeDdTrace.js.map +1 -0
  89. package/lib/module/trace/DdTrace.js +10 -11
  90. package/lib/module/trace/DdTrace.js.map +1 -1
  91. package/lib/module/version.js +1 -1
  92. package/lib/module/version.js.map +1 -1
  93. package/lib/typescript/DdSdkReactNative.d.ts +4 -4
  94. package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +14 -0
  95. package/lib/typescript/logs/DdLogs.d.ts +4 -4
  96. package/lib/typescript/nativeModulesTypes.d.ts +28 -168
  97. package/lib/typescript/rum/DdRum.d.ts +12 -12
  98. package/lib/typescript/rum/eventMappers/errorEventMapper.d.ts +4 -4
  99. package/lib/typescript/rum/instrumentation/interactionTracking/DdEventsInterceptor.d.ts +4 -0
  100. package/lib/typescript/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts +3 -1
  101. package/lib/typescript/specs/NativeDdLogs.d.ts +69 -0
  102. package/lib/typescript/specs/NativeDdRum.d.ts +92 -0
  103. package/lib/typescript/specs/NativeDdSdk.d.ts +46 -0
  104. package/lib/typescript/specs/NativeDdTrace.d.ts +23 -0
  105. package/lib/typescript/version.d.ts +1 -1
  106. package/package.json +10 -2
  107. package/src/DdSdkReactNative.tsx +12 -10
  108. package/src/DdSdkReactNativeConfiguration.tsx +22 -0
  109. package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +3 -1
  110. package/src/__tests__/longTasksUtils.test.ts +5 -0
  111. package/src/__tests__/mock.test.ts +89 -0
  112. package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +54 -0
  113. package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +118 -68
  114. package/src/logs/DdLogs.ts +11 -11
  115. package/src/logs/__tests__/DdLogs.test.ts +1 -1
  116. package/src/nativeModulesTypes.ts +49 -254
  117. package/src/rum/DdRum.ts +36 -32
  118. package/src/rum/eventMappers/errorEventMapper.ts +4 -4
  119. package/src/rum/instrumentation/interactionTracking/DdEventsInterceptor.tsx +15 -0
  120. package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +6 -2
  121. package/src/sdk/DdSdk.ts +2 -3
  122. package/src/specs/NativeDdLogs.ts +110 -0
  123. package/src/specs/NativeDdRum.ts +151 -0
  124. package/src/specs/NativeDdSdk.ts +62 -0
  125. package/src/specs/NativeDdTrace.ts +42 -0
  126. package/src/trace/DdTrace.ts +9 -9
  127. package/src/version.ts +1 -1
  128. package/ios/Sources/DdLogs.m +0 -62
  129. package/ios/Sources/DdRum.m +0 -82
  130. package/ios/Sources/DdSdk.m +0 -41
  131. package/ios/Sources/DdTrace.m +0 -23
@@ -33,17 +33,8 @@ internal protocol NativeLogger {
33
33
  func error(_ message: String, errorKind: String?, errorMessage: String?, stackTrace: String?, attributes: [String: Encodable]?)
34
34
  }
35
35
 
36
- @objc(DdLogs)
37
- class RNDdLogs: NSObject {
38
-
39
- @objc(requiresMainQueueSetup)
40
- static func requiresMainQueueSetup() -> Bool {
41
- return false
42
- }
43
-
44
- @objc(methodQueue)
45
- let methodQueue: DispatchQueue = sharedQueue
46
-
36
+ @objc
37
+ public class DdLogsImplementation: NSObject {
47
38
  private lazy var logger: NativeLogger = loggerProvider()
48
39
  private let loggerProvider: () -> NativeLogger
49
40
  private let isSDKInitialized: () -> Bool
@@ -53,16 +44,16 @@ class RNDdLogs: NSObject {
53
44
  self.isSDKInitialized = isSDKInitialized
54
45
  }
55
46
 
56
-
57
- override public convenience init() {
47
+ @objc
48
+ public override convenience init() {
58
49
  let builder = Logger.builder
59
50
  .sendNetworkInfo(true)
60
51
  .printLogsToConsole(true)
61
52
  self.init({ builder.build() }, { Datadog.isInitialized })
62
53
  }
63
54
 
64
- @objc(debug:withContext:withResolver:withRejecter:)
65
- func debug(message: String, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
55
+ @objc
56
+ public func debug(message: String, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
66
57
  if (!self.isSDKInitialized()) {
67
58
  reject(nil, Errors.logSentBeforeSDKInit, nil)
68
59
  return
@@ -72,8 +63,8 @@ class RNDdLogs: NSObject {
72
63
  resolve(nil)
73
64
  }
74
65
 
75
- @objc(info:withContext:withResolver:withRejecter:)
76
- func info(message: String, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
66
+ @objc
67
+ public func info(message: String, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
77
68
  if (!self.isSDKInitialized()) {
78
69
  reject(nil, Errors.logSentBeforeSDKInit, nil)
79
70
  return
@@ -83,8 +74,8 @@ class RNDdLogs: NSObject {
83
74
  resolve(nil)
84
75
  }
85
76
 
86
- @objc(warn:withContext:withResolver:withRejecter:)
87
- func warn(message: String, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
77
+ @objc
78
+ public func warn(message: String, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
88
79
  if (!self.isSDKInitialized()) {
89
80
  reject(nil, Errors.logSentBeforeSDKInit, nil)
90
81
  return
@@ -94,8 +85,8 @@ class RNDdLogs: NSObject {
94
85
  resolve(nil)
95
86
  }
96
87
 
97
- @objc(error:withContext:withResolver:withRejecter:)
98
- func error(message: String, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
88
+ @objc
89
+ public func error(message: String, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
99
90
  if (!self.isSDKInitialized()) {
100
91
  reject(nil, Errors.logSentBeforeSDKInit, nil)
101
92
  return
@@ -105,8 +96,8 @@ class RNDdLogs: NSObject {
105
96
  resolve(nil)
106
97
  }
107
98
 
108
- @objc(debugWithError:withErrorKind:withErrorMessage:withStacktrace:withContext:withResolver:withRejecter:)
109
- func debugWithError(message: String, errorKind: String?, errorMessage: String?, stacktrace: String?, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
99
+ @objc
100
+ public func debugWithError(message: String, errorKind: String?, errorMessage: String?, stacktrace: String?, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
110
101
  if (!self.isSDKInitialized()) {
111
102
  reject(nil, Errors.logSentBeforeSDKInit, nil)
112
103
  return
@@ -116,8 +107,8 @@ class RNDdLogs: NSObject {
116
107
  resolve(nil)
117
108
  }
118
109
 
119
- @objc(infoWithError:withErrorKind:withErrorMessage:withStacktrace:withContext:withResolver:withRejecter:)
120
- func infoWithError(message: String, errorKind: String?, errorMessage: String?, stacktrace: String?, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
110
+ @objc
111
+ public func infoWithError(message: String, errorKind: String?, errorMessage: String?, stacktrace: String?, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
121
112
  if (!self.isSDKInitialized()) {
122
113
  reject(nil, Errors.logSentBeforeSDKInit, nil)
123
114
  return
@@ -127,8 +118,8 @@ class RNDdLogs: NSObject {
127
118
  resolve(nil)
128
119
  }
129
120
 
130
- @objc(warnWithError:withErrorKind:withErrorMessage:withStacktrace:withContext:withResolver:withRejecter:)
131
- func warnWithError(message: String, errorKind: String?, errorMessage: String?, stacktrace: String?, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
121
+ @objc
122
+ public func warnWithError(message: String, errorKind: String?, errorMessage: String?, stacktrace: String?, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
132
123
  if (!self.isSDKInitialized()) {
133
124
  reject(nil, Errors.logSentBeforeSDKInit, nil)
134
125
  return
@@ -138,8 +129,8 @@ class RNDdLogs: NSObject {
138
129
  resolve(nil)
139
130
  }
140
131
 
141
- @objc(errorWithError:withErrorKind:withErrorMessage:withStacktrace:withContext:withResolver:withRejecter:)
142
- func errorWithError(message: String, errorKind: String?, errorMessage: String?, stacktrace: String?, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
132
+ @objc
133
+ public func errorWithError(message: String, errorKind: String?, errorMessage: String?, stacktrace: String?, context: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
143
134
  if (!self.isSDKInitialized()) {
144
135
  reject(nil, Errors.logSentBeforeSDKInit, nil)
145
136
  return
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+
7
+ #import <Foundation/Foundation.h>
8
+ @class DdRumImplementation;
9
+
10
+ #ifdef RCT_NEW_ARCH_ENABLED
11
+
12
+ #import <DdSdkReactNative/DdSdkReactNative.h>
13
+ @interface DdRum: NSObject <NativeDdRumSpec>
14
+
15
+ #else
16
+
17
+ #import <React/RCTBridgeModule.h>
18
+ @interface DdRum : NSObject <RCTBridgeModule>
19
+
20
+ #endif
21
+
22
+ @property (nonatomic, strong) DdRumImplementation* ddRumImplementation;
23
+
24
+ @end
@@ -0,0 +1,188 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+ // Import this first to prevent require cycles
7
+ #import <DatadogSDKReactNative-Swift.h>
8
+ #import "DdRum.h"
9
+
10
+
11
+ @implementation DdRum
12
+
13
+ RCT_EXPORT_MODULE()
14
+
15
+ RCT_REMAP_METHOD(startView, withKey:(NSString*)key
16
+ withName:(NSString*)name
17
+ withContext:(NSDictionary*)context
18
+ withTimestampms:(double)timestampMs
19
+ withResolver:(RCTPromiseResolveBlock)resolve
20
+ withRejecter:(RCTPromiseRejectBlock)reject)
21
+ {
22
+ [self startView:key name:name context:context timestampMs:timestampMs resolve:resolve reject:reject];
23
+ }
24
+
25
+ RCT_REMAP_METHOD(stopView, withKey:(NSString*)key
26
+ withContext:(NSDictionary*)context
27
+ withTimestampms:(double)timestampMs
28
+ withResolver:(RCTPromiseResolveBlock)resolve
29
+ withRejecter:(RCTPromiseRejectBlock)reject)
30
+ {
31
+ [self stopView:key context:context timestampMs:timestampMs resolve:resolve reject:reject];
32
+ }
33
+
34
+ RCT_REMAP_METHOD(startAction, startWithType:(NSString*)type
35
+ withName:(NSString*)name
36
+ withContext:(NSDictionary*)context
37
+ withTimestampms:(double)timestampMs
38
+ withResolver:(RCTPromiseResolveBlock)resolve
39
+ withRejecter:(RCTPromiseRejectBlock)reject)
40
+ {
41
+ [self startAction:type name:name context:context timestampMs:timestampMs resolve:resolve reject:reject];
42
+ }
43
+
44
+ RCT_REMAP_METHOD(stopAction, stopWithType:(NSString*)type
45
+ withName:(NSString*)name
46
+ withContext:(NSDictionary*)context
47
+ withTimestampms:(double)timestampMs
48
+ withResolver:(RCTPromiseResolveBlock)resolve
49
+ withRejecter:(RCTPromiseRejectBlock)reject)
50
+ {
51
+ [self stopAction:type name:name context:context timestampMs:timestampMs resolve:resolve reject:reject];
52
+ }
53
+
54
+ RCT_REMAP_METHOD(addAction, addWithType:(NSString*)type
55
+ withName:(NSString*)name
56
+ withContext:(NSDictionary*)context
57
+ withTimestampms:(double)timestampMs
58
+ withResolver:(RCTPromiseResolveBlock)resolve
59
+ withRejecter:(RCTPromiseRejectBlock)reject)
60
+ {
61
+ [self addAction:type name:name context:context timestampMs:timestampMs resolve:resolve reject:reject];
62
+ }
63
+
64
+ RCT_REMAP_METHOD(startResource, withKey:(NSString*)key
65
+ withMethod:(NSString*)method
66
+ withUrl:(NSString*)url
67
+ withContext:(NSDictionary*)context
68
+ withTimestampms:(double)timestampMs
69
+ withResolver:(RCTPromiseResolveBlock)resolve
70
+ withRejecter:(RCTPromiseRejectBlock)reject)
71
+ {
72
+ [self startResource:key method:method url:url context:context timestampMs:timestampMs resolve:resolve reject:reject];
73
+ }
74
+
75
+ RCT_REMAP_METHOD(stopResource, withKey:(NSString*)key
76
+ withStatuscode:(double)statusCode
77
+ withKind:(NSString*)kind
78
+ withSize:(double)size
79
+ withContext:(NSDictionary*)context
80
+ withTimestampms:(double)timestampMs
81
+ withResolver:(RCTPromiseResolveBlock)resolve
82
+ withRejecter:(RCTPromiseRejectBlock)reject)
83
+ {
84
+ [self stopResource:key statusCode:statusCode kind:kind size:size context:context timestampMs:timestampMs resolve:resolve reject:reject];
85
+ }
86
+
87
+ RCT_REMAP_METHOD(addError, withMessage:(NSString*)message
88
+ withSource:(NSString*)source
89
+ withStacktrace:(NSString*)stacktrace
90
+ withContext:(NSDictionary*)context
91
+ withTimestampms:(double)timestampMs
92
+ withResolver:(RCTPromiseResolveBlock)resolve
93
+ withRejecter:(RCTPromiseRejectBlock)reject)
94
+ {
95
+ [self addError:message source:source stacktrace:stacktrace context:context timestampMs:timestampMs resolve:resolve reject:reject];
96
+ }
97
+
98
+ RCT_REMAP_METHOD(addTiming, withName:(NSString*)name
99
+ withResolver:(RCTPromiseResolveBlock)resolve
100
+ withRejecter:(RCTPromiseRejectBlock)reject)
101
+ {
102
+ [self addTiming:name resolve:resolve reject:reject];
103
+ }
104
+
105
+ RCT_REMAP_METHOD(stopSession, withResolve:(RCTPromiseResolveBlock)resolve
106
+ withRejecter:(RCTPromiseRejectBlock)reject)
107
+ {
108
+ [self stopSession:resolve reject:reject];
109
+ }
110
+
111
+ RCT_REMAP_METHOD(addFeatureFlagEvaluation, withName:(NSString*)name
112
+ withValue:(NSDictionary*)value
113
+ withResolver:(RCTPromiseResolveBlock)resolve
114
+ withRejecter:(RCTPromiseRejectBlock)reject)
115
+ {
116
+ [self addFeatureFlagEvaluation:name value:value resolve:resolve reject:reject];
117
+ }
118
+
119
+ // Thanks to this guard, we won't compile this code when we build for the old architecture.
120
+ #ifdef RCT_NEW_ARCH_ENABLED
121
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
122
+ (const facebook::react::ObjCTurboModule::InitParams &)params
123
+ {
124
+ return std::make_shared<facebook::react::NativeDdRumSpecJSI>(params);
125
+ }
126
+ #endif
127
+
128
+ - (DdRumImplementation*)ddRumImplementation
129
+ {
130
+ if (_ddRumImplementation == nil) {
131
+ _ddRumImplementation = [[DdRumImplementation alloc] init];
132
+ }
133
+ return _ddRumImplementation;
134
+ }
135
+
136
+ + (BOOL)requiresMainQueueSetup {
137
+ return NO;
138
+ }
139
+
140
+ - (dispatch_queue_t)methodQueue {
141
+ return [RNQueue getSharedQueue];
142
+ }
143
+
144
+ - (void)addAction:(NSString *)type name:(NSString *)name context:(NSDictionary *)context timestampMs:(double)timestampMs resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
145
+ [self.ddRumImplementation addActionWithType:type name:name context:context timestampMs:timestampMs resolve:resolve reject:reject];
146
+ }
147
+
148
+ - (void)addError:(NSString *)message source:(NSString *)source stacktrace:(NSString *)stacktrace context:(NSDictionary *)context timestampMs:(double)timestampMs resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
149
+ [self.ddRumImplementation addErrorWithMessage:message source:source stacktrace:stacktrace context:context timestampMs:timestampMs resolve:resolve reject:reject];
150
+ }
151
+
152
+ - (void)addFeatureFlagEvaluation:(NSString *)name value:(NSDictionary *)value resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
153
+ [self.ddRumImplementation addFeatureFlagEvaluationWithName:name value:value resolve:resolve reject:reject];
154
+ }
155
+
156
+ - (void)addTiming:(NSString *)name resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
157
+ [self.ddRumImplementation addTimingWithName:name resolve:resolve reject:reject];
158
+ }
159
+
160
+ - (void)startAction:(NSString *)type name:(NSString *)name context:(NSDictionary *)context timestampMs:(double)timestampMs resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
161
+ [self.ddRumImplementation startActionWithType:type name:name context:context timestampMs:timestampMs resolve:resolve reject:reject];
162
+ }
163
+
164
+ - (void)startResource:(NSString *)key method:(NSString *)method url:(NSString *)url context:(NSDictionary *)context timestampMs:(double)timestampMs resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
165
+ [self.ddRumImplementation startResourceWithKey:key method:method url:url context:context timestampMs:timestampMs resolve:resolve reject:reject];
166
+ }
167
+
168
+ - (void)startView:(NSString *)key name:(NSString *)name context:(NSDictionary *)context timestampMs:(double)timestampMs resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
169
+ [self.ddRumImplementation startViewWithKey:key name:name context:context timestampMs:timestampMs resolve:resolve reject:reject];
170
+ }
171
+
172
+ - (void)stopAction:(NSString *)type name:(NSString *)name context:(NSDictionary *)context timestampMs:(double)timestampMs resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
173
+ [self.ddRumImplementation stopActionWithType:type name:name context:context timestampMs:timestampMs resolve:resolve reject:reject];
174
+ }
175
+
176
+ - (void)stopResource:(NSString *)key statusCode:(double)statusCode kind:(NSString *)kind size:(double)size context:(NSDictionary *)context timestampMs:(double)timestampMs resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
177
+ [self.ddRumImplementation stopResourceWithKey:key statusCode:statusCode kind:kind size:size context:context timestampMs:timestampMs resolve:resolve reject:reject];
178
+ }
179
+
180
+ - (void)stopSession:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
181
+ [self.ddRumImplementation stopSessionWithResolve:resolve reject:reject];
182
+ }
183
+
184
+ - (void)stopView:(NSString *)key context:(NSDictionary *)context timestampMs:(double)timestampMs resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
185
+ [self.ddRumImplementation stopViewWithKey:key context:context timestampMs:timestampMs resolve:resolve reject:reject];
186
+ }
187
+
188
+ @end
@@ -86,8 +86,8 @@ private extension RUMMethod {
86
86
  }
87
87
  }
88
88
 
89
- @objc(DdRum)
90
- class RNDdRum: NSObject {
89
+ @objc
90
+ public class DdRumImplementation: NSObject {
91
91
  internal static let timestampKey = "_dd.timestamp"
92
92
  internal static let resourceTimingsKey = "_dd.resource_timings"
93
93
 
@@ -110,56 +110,49 @@ class RNDdRum: NSObject {
110
110
  self.rumProvider = rumProvider
111
111
  }
112
112
 
113
- override convenience init() {
113
+ @objc
114
+ public override convenience init() {
114
115
  self.init { Global.rum }
115
116
  }
116
117
 
117
- @objc(requiresMainQueueSetup)
118
- static func requiresMainQueueSetup() -> Bool {
119
- return false
120
- }
121
-
122
- @objc(methodQueue)
123
- let methodQueue: DispatchQueue = sharedQueue
124
-
125
- @objc(startView:withName:withContext:withTimestampms:withResolver:withRejecter:)
126
- func startView(key: String, name: String, context: NSDictionary, timestampMs: Int64, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
118
+ @objc
119
+ public func startView(key: String, name: String, context: NSDictionary, timestampMs: Double, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
127
120
  nativeRUM.startView(key: key, name: name, attributes: attributes(from: context, with: timestampMs))
128
121
  resolve(nil)
129
122
  }
130
123
 
131
- @objc(stopView:withContext:withTimestampms:withResolver:withRejecter:)
132
- func stopView(key: String, context: NSDictionary, timestampMs: Int64, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
124
+ @objc
125
+ public func stopView(key: String, context: NSDictionary, timestampMs: Double, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
133
126
  nativeRUM.stopView(key: key, attributes: attributes(from: context, with: timestampMs))
134
127
  resolve(nil)
135
128
  }
136
129
 
137
- @objc(startAction:withName:withContext:withTimestampms:withResolver:withRejecter:)
138
- func startAction(type: String, name: String, context: NSDictionary, timestampMs: Int64, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
130
+ @objc
131
+ public func startAction(type: String, name: String, context: NSDictionary, timestampMs: Double, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
139
132
  nativeRUM.startUserAction(type: RUMUserActionType(from: type), name: name, attributes: attributes(from: context, with: timestampMs))
140
133
  resolve(nil)
141
134
  }
142
135
 
143
- @objc(stopAction:withName:withContext:withTimestampms:withResolver:withRejecter:)
144
- func stopAction(type: String, name: String, context: NSDictionary, timestampMs: Int64, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
136
+ @objc
137
+ public func stopAction(type: String, name: String, context: NSDictionary, timestampMs: Double, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
145
138
  nativeRUM.stopUserAction(type: RUMUserActionType(from: type), name: name, attributes: attributes(from: context, with: timestampMs))
146
139
  resolve(nil)
147
140
  }
148
141
 
149
- @objc(addAction:withName:withContext:withTimestampms:withResolver:withRejecter:)
150
- func addAction(type: String, name: String, context: NSDictionary, timestampMs: Int64, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
142
+ @objc
143
+ public func addAction(type: String, name: String, context: NSDictionary, timestampMs: Double, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
151
144
  nativeRUM.addUserAction(type: RUMUserActionType(from: type), name: name, attributes: attributes(from: context, with: timestampMs))
152
145
  resolve(nil)
153
146
  }
154
147
 
155
- @objc(startResource:withMethod:withUrl:withContext:withTimestampms:withResolver:withRejecter:)
156
- func startResource(key: String, method: String, url: String, context: NSDictionary, timestampMs: Int64, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
148
+ @objc
149
+ public func startResource(key: String, method: String, url: String, context: NSDictionary, timestampMs: Double, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
157
150
  nativeRUM.startResourceLoading(resourceKey: key, httpMethod: RUMMethod(from: method), urlString: url, attributes: attributes(from: context, with: timestampMs))
158
151
  resolve(nil)
159
152
  }
160
153
 
161
- @objc(stopResource:withStatuscode:withKind:withSize:withContext:withTimestampms:withResolver:withRejecter:)
162
- func stopResource(key: String, statusCode: Int64, kind: String, size: Int64, context: NSDictionary, timestampMs: Int64, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
154
+ @objc
155
+ public func stopResource(key: String, statusCode: Int64, kind: String, size: Double, context: NSDictionary, timestampMs: Double, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
163
156
  let mutableContext = NSMutableDictionary(dictionary: context)
164
157
  if let resourceTimings = mutableContext.object(forKey: Self.resourceTimingsKey) as? [String: Any] {
165
158
  mutableContext.removeObject(forKey: Self.resourceTimingsKey)
@@ -171,32 +164,32 @@ class RNDdRum: NSObject {
171
164
  resourceKey: key,
172
165
  statusCode: Int(statusCode),
173
166
  kind: RUMResourceType(from: kind),
174
- size: size == Self.missingResourceSize ? nil : size,
167
+ size: Int64(size) == Self.missingResourceSize ? nil : Int64(size),
175
168
  attributes: attributes(from: mutableContext, with: timestampMs)
176
169
  )
177
170
  resolve(nil)
178
171
  }
179
172
 
180
- @objc(addError:withSource:withStacktrace:withContext:withTimestampms:withResolver:withRejecter:)
181
- func addError(message: String, source: String, stacktrace: String, context: NSDictionary, timestampMs: Int64, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
173
+ @objc
174
+ public func addError(message: String, source: String, stacktrace: String, context: NSDictionary, timestampMs: Double, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
182
175
  nativeRUM.addError(message: message, type: nil, source: RUMErrorSource(from: source), stack: stacktrace, attributes: attributes(from: context, with: timestampMs), file: nil, line: nil)
183
176
  resolve(nil)
184
177
  }
185
178
 
186
- @objc(addTiming:withResolver:withRejecter:)
187
- func addTiming(name: String, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
179
+ @objc
180
+ public func addTiming(name: String, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
188
181
  nativeRUM.addTiming(name: name)
189
182
  resolve(nil)
190
183
  }
191
184
 
192
- @objc(stopSession:withRejecter:)
193
- func stopSession(resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
185
+ @objc
186
+ public func stopSession(resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
194
187
  nativeRUM.stopSession()
195
188
  resolve(nil)
196
189
  }
197
190
 
198
- @objc(addFeatureFlagEvaluation:withValue:withResolver:withRejecter:)
199
- func addFeatureFlagEvaluation(name: String, value: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
191
+ @objc
192
+ public func addFeatureFlagEvaluation(name: String, value: NSDictionary, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) -> Void {
200
193
  let valueAsEncodable = castAttributesToSwift(value)
201
194
  if let value = valueAsEncodable["value"] {
202
195
  nativeRUM.addFeatureFlagEvaluation(name: name, value: value)
@@ -206,7 +199,7 @@ class RNDdRum: NSObject {
206
199
 
207
200
  // MARK: - Private methods
208
201
 
209
- private func attributes(from context: NSDictionary, with timestampMs: Int64) -> [String: Encodable] {
202
+ private func attributes(from context: NSDictionary, with timestampMs: Double) -> [String: Encodable] {
210
203
  var context = context as? [String: Any] ?? [:]
211
204
  context[Self.timestampKey] = timestampMs
212
205
  return castAttributesToSwift(context)
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+
7
+ #import <Foundation/Foundation.h>
8
+ @class DdSdkImplementation;
9
+
10
+ #ifdef RCT_NEW_ARCH_ENABLED
11
+
12
+ #import <DdSdkReactNative/DdSdkReactNative.h>
13
+ @interface DdSdk: NSObject <NativeDdSdkSpec>
14
+
15
+ #else
16
+
17
+ #import <React/RCTBridgeModule.h>
18
+ @interface DdSdk : NSObject <RCTBridgeModule>
19
+
20
+ #endif
21
+
22
+ @property (nonatomic, strong) DdSdkImplementation* ddSdkImplementation;
23
+
24
+ @end
@@ -0,0 +1,119 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+ // Import this first to prevent require cycles
7
+ #import <DatadogSDKReactNative-Swift.h>
8
+ #import "DdSdk.h"
9
+
10
+ @implementation DdSdk
11
+
12
+ RCT_EXPORT_MODULE()
13
+
14
+ RCT_REMAP_METHOD(initialize, withConfiguration:(NSDictionary*)configuration
15
+ withResolver:(RCTPromiseResolveBlock)resolve
16
+ withRejecter:(RCTPromiseRejectBlock)reject)
17
+ {
18
+ [self initialize:configuration resolve:resolve reject:reject];
19
+ }
20
+
21
+ RCT_REMAP_METHOD(setAttributes, withAttributes:(NSDictionary*)attributes
22
+ withResolver:(RCTPromiseResolveBlock)resolve
23
+ withRejecter:(RCTPromiseRejectBlock)reject)
24
+ {
25
+ [self setAttributes:attributes resolve:resolve reject:reject];
26
+ }
27
+
28
+ RCT_REMAP_METHOD(setUser, withUser:(NSDictionary*)user
29
+ withResolver:(RCTPromiseResolveBlock)resolve
30
+ withRejecter:(RCTPromiseRejectBlock)reject)
31
+ {
32
+ [self setUser:user resolve:resolve reject:reject];
33
+ }
34
+
35
+ RCT_REMAP_METHOD(setTrackingConsent, withTrackingConsent:(NSString*)trackingConsent
36
+ withResolver:(RCTPromiseResolveBlock)resolve
37
+ withRejecter:(RCTPromiseRejectBlock)reject)
38
+ {
39
+ [self setTrackingConsent:trackingConsent resolve:resolve reject:reject];
40
+ }
41
+
42
+ RCT_REMAP_METHOD(telemetryDebug, withMessage:(NSString*)message
43
+ withResolver:(RCTPromiseResolveBlock)resolve
44
+ withRejecter:(RCTPromiseRejectBlock)reject)
45
+ {
46
+ [self telemetryDebug:message resolve:resolve reject:reject];
47
+ }
48
+
49
+ RCT_REMAP_METHOD(telemetryError, withMessage:(NSString*)message
50
+ withStack:(NSString*)stack
51
+ withKind:(NSString*)kind
52
+ withResolver:(RCTPromiseResolveBlock)resolve
53
+ withRejecter:(RCTPromiseRejectBlock)reject)
54
+ {
55
+ [self telemetryError:message stack:stack kind:kind resolve:resolve reject:reject];
56
+ }
57
+
58
+ RCT_REMAP_METHOD(consumeWebviewEvent, withWebviewMessage:(NSString*)message
59
+ withResolver:(RCTPromiseResolveBlock)resolve
60
+ withRejecter:(RCTPromiseRejectBlock)reject)
61
+ {
62
+ [self consumeWebviewEvent:message resolve:resolve reject:reject];
63
+ }
64
+
65
+ // Thanks to this guard, we won't compile this code when we build for the old architecture.
66
+ #ifdef RCT_NEW_ARCH_ENABLED
67
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
68
+ (const facebook::react::ObjCTurboModule::InitParams &)params
69
+ {
70
+ return std::make_shared<facebook::react::NativeDdSdkSpecJSI>(params);
71
+ }
72
+ #endif
73
+
74
+
75
+ - (DdSdkImplementation*)ddSdkImplementation
76
+ {
77
+ if (_ddSdkImplementation == nil) {
78
+ _ddSdkImplementation = [[DdSdkImplementation alloc] init];
79
+ }
80
+ return _ddSdkImplementation;
81
+ }
82
+
83
+ + (BOOL)requiresMainQueueSetup {
84
+ return NO;
85
+ }
86
+
87
+ - (dispatch_queue_t)methodQueue {
88
+ return [RNQueue getSharedQueue];
89
+ }
90
+
91
+ - (void)consumeWebviewEvent:(NSString *)message resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
92
+ [self.ddSdkImplementation consumeWebviewEventWithMessage:message resolve:resolve reject:reject];
93
+ }
94
+
95
+ - (void)initialize:(NSDictionary *)configuration resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
96
+ [self.ddSdkImplementation initializeWithConfiguration:configuration resolve:resolve reject:reject];
97
+ }
98
+
99
+ - (void)setAttributes:(NSDictionary *)attributes resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
100
+ [self.ddSdkImplementation setAttributesWithAttributes:attributes resolve:resolve reject:reject];
101
+ }
102
+
103
+ - (void)setTrackingConsent:(NSString *)trackingConsent resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
104
+ [self.ddSdkImplementation setTrackingConsentWithTrackingConsent:trackingConsent resolve:resolve reject:reject];
105
+ }
106
+
107
+ - (void)setUser:(NSDictionary *)user resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
108
+ [self.ddSdkImplementation setUserWithUser:user resolve:resolve reject:reject];
109
+ }
110
+
111
+ - (void)telemetryDebug:(NSString *)message resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
112
+ [self.ddSdkImplementation telemetryDebugWithMessage:message resolve:resolve reject:reject];
113
+ }
114
+
115
+ - (void)telemetryError:(NSString *)message stack:(NSString *)stack kind:(NSString *)kind resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
116
+ [self.ddSdkImplementation telemetryErrorWithMessage:message stack:stack kind:kind resolve:resolve reject:reject];
117
+ }
118
+
119
+ @end