-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathDdRum.mm
More file actions
317 lines (267 loc) · 14.9 KB
/
Copy pathDdRum.mm
File metadata and controls
317 lines (267 loc) · 14.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2016-Present Datadog, Inc.
*/
// Import this first to prevent require cycles
#if __has_include("DatadogSDKReactNative-Swift.h")
#import <DatadogSDKReactNative-Swift.h>
#else
#import <DatadogSDKReactNative/DatadogSDKReactNative-Swift.h>
#endif
#import "DdRum.h"
@implementation DdRum
@synthesize bridge = _bridge;
RCT_EXPORT_MODULE()
RCT_REMAP_METHOD(startView, withKey:(NSString*)key
withName:(NSString*)name
withContext:(NSDictionary*)context
withTimestampms:(double)timestampMs
withResolver:(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
{
[self startView:key name:name context:context timestampMs:timestampMs resolve:resolve reject:reject];
}
RCT_REMAP_METHOD(stopView, withKey:(NSString*)key
withContext:(NSDictionary*)context
withTimestampms:(double)timestampMs
withResolver:(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
{
[self stopView:key context:context timestampMs:timestampMs resolve:resolve reject:reject];
}
RCT_REMAP_METHOD(startAction, startWithType:(NSString*)type
withName:(NSString*)name
withContext:(NSDictionary*)context
withTimestampms:(double)timestampMs
withResolver:(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
{
[self startAction:type name:name context:context timestampMs:timestampMs resolve:resolve reject:reject];
}
RCT_REMAP_METHOD(stopAction, stopWithType:(NSString*)type
withName:(NSString*)name
withContext:(NSDictionary*)context
withTimestampms:(double)timestampMs
withResolver:(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
{
[self stopAction:type name:name context:context timestampMs:timestampMs resolve:resolve reject:reject];
}
RCT_REMAP_METHOD(addAction, addWithType:(NSString*)type
withName:(NSString*)name
withTouch:(nullable NSDictionary*)touch
withContext:(NSDictionary*)context
withTimestampms:(double)timestampMs
withResolver:(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
{
[self addAction:type name:name touch:touch context:context timestampMs:timestampMs resolve:resolve reject:reject];
}
RCT_REMAP_METHOD(startResource, withKey:(NSString*)key
withMethod:(NSString*)method
withUrl:(NSString*)url
withContext:(NSDictionary*)context
withTimestampms:(double)timestampMs
withResolver:(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
{
[self startResource:key method:method url:url context:context timestampMs:timestampMs resolve:resolve reject:reject];
}
RCT_REMAP_METHOD(stopResource, withKey:(NSString*)key
withStatuscode:(double)statusCode
withKind:(NSString*)kind
withSize:(double)size
withContext:(NSDictionary*)context
withTimestampms:(double)timestampMs
withResolver:(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
{
[self stopResource:key statusCode:statusCode kind:kind size:size context:context timestampMs:timestampMs resolve:resolve reject:reject];
}
RCT_REMAP_METHOD(addError, withMessage:(NSString*)message
withSource:(NSString*)source
withStacktrace:(NSString*)stacktrace
withContext:(NSDictionary*)context
withTimestampms:(double)timestampMs
withFingerprint:(NSString*)fingerprint
withResolver:(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
{
[self addError:message source:source stacktrace:stacktrace context:context timestampMs:timestampMs fingerprint: fingerprint resolve:resolve reject:reject];
}
RCT_REMAP_METHOD(addTiming, withName:(NSString*)name
withResolver:(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
{
[self addTiming:name resolve:resolve reject:reject];
}
RCT_EXPORT_METHOD(addViewAttribute:(NSString*) key
withValue:(NSDictionary*) value
withResolver:(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
{
[self addViewAttribute:key value:value resolve:resolve reject:reject];
}
RCT_EXPORT_METHOD(removeViewAttribute:(NSString*) key
withResolver:(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
{
[self removeViewAttribute:key resolve:resolve reject:reject];
}
RCT_EXPORT_METHOD(addViewAttributes:(NSDictionary*) attributes
withResolver:(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
{
[self addViewAttributes:attributes resolve:resolve reject:reject];
}
RCT_EXPORT_METHOD(removeViewAttributes:(NSArray *)keys
withResolver:(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
{
[self removeViewAttributes:keys resolve:resolve reject:reject];
}
RCT_REMAP_METHOD(addViewLoadingTime, withOverwrite:(BOOL)overwrite
withResolver:(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
{
[self addViewLoadingTime:overwrite resolve:resolve reject:reject];
}
RCT_EXPORT_METHOD(reportAppFullyDisplayed:
(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
{
[self reportAppFullyDisplayed: resolve reject:reject];
}
RCT_EXPORT_METHOD(stopSession:
(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
{
[self stopSession:resolve reject:reject];
}
RCT_REMAP_METHOD(addFeatureFlagEvaluation, withName:(NSString*)name
withValue:(NSDictionary*)value
withResolver:(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
{
[self addFeatureFlagEvaluation:name value:value resolve:resolve reject:reject];
}
RCT_REMAP_METHOD(getCurrentSessionId,
withResolver:(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
{
[self getCurrentSessionId:resolve reject:reject];
}
RCT_REMAP_METHOD(startFeatureOperation,
startWithName:(NSString*)name
withOperationKey:(NSString*)operationKey
withAttributes:(NSDictionary*)attributes
withResolver:(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
{
[self startFeatureOperation:name operationKey:operationKey attributes:attributes resolve:resolve reject:reject];
}
RCT_REMAP_METHOD(succeedFeatureOperation,
succeedWithName:(NSString*)name
withOperationKey:(NSString*)operationKey
withAttributes:(NSDictionary*)attributes
withResolver:(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
{
[self succeedFeatureOperation:name operationKey:operationKey attributes:attributes resolve:resolve reject:reject];
}
RCT_REMAP_METHOD(failFeatureOperation,
failWithName:(NSString*)name
withOperationKey:(NSString*)operationKey
withReason:(NSString*)reason
withAttributes:(NSDictionary*)attributes
withResolver:(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
{
[self failFeatureOperation:name operationKey:operationKey reason:reason attributes:attributes resolve:resolve reject:reject];
}
// Thanks to this guard, we won't compile this code when we build for the old architecture.
#ifdef RCT_NEW_ARCH_ENABLED
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
(const facebook::react::ObjCTurboModule::InitParams &)params
{
return std::make_shared<facebook::react::NativeDdRumSpecJSI>(params);
}
#endif
- (DdRumImplementation*)ddRumImplementation
{
if (_ddRumImplementation == nil) {
_ddRumImplementation = [[DdRumImplementation alloc] initWithBridge:_bridge];
}
return _ddRumImplementation;
}
+ (BOOL)requiresMainQueueSetup {
return NO;
}
- (dispatch_queue_t)methodQueue {
return [RNQueue getSharedQueue];
}
- (void)addAction:(NSString *)type name:(NSString *)name touch:(nullable NSDictionary *)touch context:(NSDictionary *)context timestampMs:(double)timestampMs resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[self.ddRumImplementation addActionWithType:type name:name touch:touch context:context timestampMs:timestampMs resolve:resolve reject:reject];
}
- (void)addError:(NSString *)message source:(NSString *)source stacktrace:(NSString *)stacktrace context:(NSDictionary *)context timestampMs:(double)timestampMs fingerprint:(NSString *)fingerprint resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[self.ddRumImplementation addErrorWithMessage:message source:source stacktrace:stacktrace context:context timestampMs:timestampMs fingerprint:fingerprint resolve:resolve reject:reject];
}
- (void)addFeatureFlagEvaluation:(NSString *)name value:(NSDictionary *)value resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[self.ddRumImplementation addFeatureFlagEvaluationWithName:name value:value resolve:resolve reject:reject];
}
- (void)getCurrentSessionId:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[self.ddRumImplementation getCurrentSessionId:resolve reject:reject];
}
- (void)addTiming:(NSString *)name resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[self.ddRumImplementation addTimingWithName:name resolve:resolve reject:reject];
}
- (void)addViewAttribute:(NSString *)key value:(NSDictionary *)value resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[self.ddRumImplementation addViewAttributeWithKey:key value:value resolve:resolve reject:reject];
}
- (void)removeViewAttribute:(NSString *)key resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[self.ddRumImplementation removeViewAttributeWithKey:key resolve:resolve reject:reject];
}
- (void)addViewAttributes:(NSDictionary *)attributes resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[self.ddRumImplementation addViewAttributesWithAttributes:attributes resolve:resolve reject:reject];
}
- (void)removeViewAttributes:(NSArray *)keys resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[self.ddRumImplementation removeViewAttributesWithKeys:keys resolve:resolve reject:reject];
}
- (void)addViewLoadingTime:(BOOL)overwrite resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {\
[self.ddRumImplementation addViewLoadingTimeWithOverwrite:overwrite resolve:resolve reject:reject];
}
- (void)reportAppFullyDisplayed:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[self.ddRumImplementation reportAppFullyDisplayedWithResolve:resolve reject: reject];
}
- (void)startAction:(NSString *)type name:(NSString *)name context:(NSDictionary *)context timestampMs:(double)timestampMs resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[self.ddRumImplementation startActionWithType:type name:name context:context timestampMs:timestampMs resolve:resolve reject:reject];
}
- (void)startResource:(NSString *)key method:(NSString *)method url:(NSString *)url context:(NSDictionary *)context timestampMs:(double)timestampMs resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[self.ddRumImplementation startResourceWithKey:key method:method url:url context:context timestampMs:timestampMs resolve:resolve reject:reject];
}
- (void)startView:(NSString *)key name:(NSString *)name context:(NSDictionary *)context timestampMs:(double)timestampMs resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[self.ddRumImplementation startViewWithKey:key name:name context:context timestampMs:timestampMs resolve:resolve reject:reject];
}
- (void)stopAction:(NSString *)type name:(NSString *)name context:(NSDictionary *)context timestampMs:(double)timestampMs resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[self.ddRumImplementation stopActionWithType:type name:name context:context timestampMs:timestampMs resolve:resolve reject:reject];
}
- (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 {
[self.ddRumImplementation stopResourceWithKey:key statusCode:statusCode kind:kind size:size context:context timestampMs:timestampMs resolve:resolve reject:reject];
}
- (void)stopSession:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[self.ddRumImplementation stopSessionWithResolve:resolve reject:reject];
}
- (void)stopView:(NSString *)key context:(NSDictionary *)context timestampMs:(double)timestampMs resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[self.ddRumImplementation stopViewWithKey:key context:context timestampMs:timestampMs resolve:resolve reject:reject];
}
- (void) startFeatureOperation:(NSString *)name operationKey:(NSString *)operationKey attributes:(NSDictionary *)attributes resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[self.ddRumImplementation startFeatureOperationWithName:name operationKey:operationKey attributes:attributes resolve:resolve reject:reject];
}
- (void) succeedFeatureOperation:(NSString *)name operationKey:(NSString *)operationKey attributes:(NSDictionary *)attributes resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[self.ddRumImplementation succeedFeatureOperationWithName:name operationKey:operationKey attributes:attributes resolve:resolve reject:reject];
}
- (void) failFeatureOperation:(NSString *)name operationKey:(NSString *)operationKey reason:(NSString *)reason attributes:(NSDictionary *)attributes resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
[self.ddRumImplementation failFeatureOperationWithName:name operationKey:operationKey reason:reason attributes:attributes resolve:resolve reject:reject];
}
@end