@logrocket/react-native 0.21.0 → 0.23.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.
|
@@ -4,37 +4,74 @@
|
|
|
4
4
|
|
|
5
5
|
@implementation LogRocketNativeModule
|
|
6
6
|
|
|
7
|
-
RCT_EXPORT_MODULE()
|
|
7
|
+
RCT_EXPORT_MODULE();
|
|
8
|
+
|
|
9
|
+
RCT_EXPORT_METHOD(addLog:(NSString *)level args:(NSArray *)args)
|
|
10
|
+
{
|
|
11
|
+
[LROSDK addLogWithLevel:level args:args];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
RCT_EXPORT_METHOD(captureException:(NSString *)message
|
|
15
|
+
errorType:(NSString *)errorType
|
|
16
|
+
exceptionType:(NSString *)exceptionType
|
|
17
|
+
stackTrace:(NSString *)stackTrace)
|
|
18
|
+
{
|
|
19
|
+
[LROSDK captureExceptionWithErrorMessage:message errorType:errorType exceptionType:exceptionType stackTrace:stackTrace];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
RCT_EXPORT_METHOD(getSessionURL:(RCTResponseSenderBlock)callback)
|
|
23
|
+
{
|
|
24
|
+
void (^completion)(NSString*) = ^(NSString* sessionURL) {
|
|
25
|
+
callback(@[sessionURL]);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
[LROSDK getSessionURL:completion];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
NSMutableDictionary<NSString *, LROResponseBuilder *> *capturedRequests;
|
|
32
|
+
|
|
33
|
+
- (id)init {
|
|
34
|
+
self = [super init];
|
|
35
|
+
|
|
36
|
+
if (self) {
|
|
37
|
+
capturedRequests = [[NSMutableDictionary alloc] init];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return self;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
+ (BOOL)requiresMainQueueSetup {
|
|
44
|
+
return YES;
|
|
45
|
+
}
|
|
8
46
|
|
|
9
47
|
RCT_EXPORT_METHOD(initWithConfig:(NSString *)appID
|
|
10
48
|
config:(NSDictionary *)config
|
|
11
49
|
resolver:(RCTPromiseResolveBlock)resolve
|
|
12
50
|
rejecter:(RCTPromiseRejectBlock)reject)
|
|
13
51
|
{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
LROConfiguration *configuration = [[LROConfiguration alloc] initWithAppID:appID];
|
|
19
|
-
|
|
20
|
-
configuration.serverURL = serverURL;
|
|
21
|
-
configuration.redactionTags = tags;
|
|
22
|
-
configuration.viewScanningEnabled = true;
|
|
23
|
-
configuration.networkCaptureEnabled = false;
|
|
24
|
-
configuration.logCaptureEnabled = false;
|
|
25
|
-
configuration.requestSanitizer = nil;
|
|
26
|
-
configuration.responseSanitizer = nil;
|
|
27
|
-
configuration.registerTouchHandlers = true;
|
|
28
|
-
|
|
29
|
-
BOOL result = [LROSDK initializeWithConfiguration:configuration];
|
|
30
|
-
resolve(@(result));
|
|
31
|
-
}
|
|
52
|
+
@try {
|
|
53
|
+
NSString *serverURL = config[@"serverURL"];
|
|
54
|
+
NSSet<NSString *> *tags = [NSSet setWithArray:config[@"redactionTags"]];
|
|
32
55
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
56
|
+
LROConfiguration *configuration = [[LROConfiguration alloc] initWithAppID:appID];
|
|
57
|
+
|
|
58
|
+
configuration.serverURL = serverURL;
|
|
59
|
+
configuration.redactionTags = tags;
|
|
60
|
+
configuration.viewScanningEnabled = true;
|
|
61
|
+
configuration.networkCaptureEnabled = false;
|
|
62
|
+
configuration.logCaptureEnabled = false;
|
|
63
|
+
configuration.requestSanitizer = nil;
|
|
64
|
+
configuration.responseSanitizer = nil;
|
|
65
|
+
configuration.registerTouchHandlers = true;
|
|
66
|
+
|
|
67
|
+
BOOL result = [LROSDK initializeWithConfiguration:configuration];
|
|
68
|
+
resolve(@(result));
|
|
69
|
+
}
|
|
37
70
|
|
|
71
|
+
@catch (NSException *e) {
|
|
72
|
+
NSLog(@"Failed to start LogRocket SDK");
|
|
73
|
+
resolve(@(false));
|
|
74
|
+
}
|
|
38
75
|
}
|
|
39
76
|
|
|
40
77
|
RCT_EXPORT_METHOD(identifyWithTraits:(NSString *)userID
|
|
@@ -56,29 +93,88 @@ RCT_EXPORT_METHOD(identifyWithTraits:(NSString *)userID
|
|
|
56
93
|
RCT_EXPORT_METHOD(shutdown:(RCTPromiseResolveBlock)resolve
|
|
57
94
|
rejecter:(RCTPromiseRejectBlock)reject)
|
|
58
95
|
{
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
96
|
+
@try {
|
|
97
|
+
[LROSDK shutdown];
|
|
98
|
+
resolve(@(true));
|
|
99
|
+
}
|
|
63
100
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
101
|
+
@catch (NSException *e) {
|
|
102
|
+
NSLog(@"Failed to shutdown LogRocket SDK");
|
|
103
|
+
resolve(@(false));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
RCT_EXPORT_METHOD(track:(NSString *)customEventName eventProperties:(NSDictionary *)eventProperties)
|
|
108
|
+
{
|
|
109
|
+
LROCustomEventBuilder *builder = [[LROCustomEventBuilder alloc] initWithName:customEventName];
|
|
110
|
+
|
|
111
|
+
for (NSString *key in eventProperties) {
|
|
112
|
+
NSDictionary *value = [eventProperties objectForKey:key];
|
|
113
|
+
|
|
114
|
+
if ([value objectForKey:@"doubleVal"]) {
|
|
115
|
+
NSArray *doubleArray = [value objectForKey:@"doubleVal"];
|
|
116
|
+
[builder putDoubleArrayWithKey:key value:doubleArray];
|
|
117
|
+
} else if ([value objectForKey:@"boolVal"]) {
|
|
118
|
+
NSArray *boolArray = [value objectForKey:@"boolVal"];
|
|
119
|
+
[builder putBoolArrayWithKey:key value:boolArray];
|
|
120
|
+
} else if ([value objectForKey:@"stringVal"]) {
|
|
121
|
+
NSArray *stringArray = [value objectForKey:@"stringVal"];
|
|
122
|
+
[builder putStringArrayWithKey:key value:stringArray];
|
|
67
123
|
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
[LROSDK track:builder];
|
|
68
127
|
}
|
|
69
128
|
|
|
70
|
-
|
|
129
|
+
|
|
130
|
+
RCT_EXPORT_METHOD(captureRequest:(NSString *)reqID request:(NSDictionary *)request)
|
|
71
131
|
{
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
};
|
|
132
|
+
LRORequestBuilder *builder = [LROSDK newRequestBuilder];
|
|
133
|
+
builder.url = request[@"url"];
|
|
75
134
|
|
|
76
|
-
[
|
|
135
|
+
if ([request objectForKey:@"body"]) {
|
|
136
|
+
NSDictionary *arson = [request objectForKey:@"body"];
|
|
137
|
+
if (arson && [arson objectForKey:@"arson"]) {
|
|
138
|
+
builder.arsonBody = [arson objectForKey:@"arson"];
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if ([request objectForKey:@"method"]) {
|
|
143
|
+
builder.method = [request objectForKey:@"method"];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if ([request objectForKey:@"headers"]) {
|
|
147
|
+
builder.headers = [request objectForKey:@"headers"];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
capturedRequests[reqID] = [builder capture];
|
|
77
151
|
}
|
|
78
152
|
|
|
79
|
-
RCT_EXPORT_METHOD(
|
|
153
|
+
RCT_EXPORT_METHOD(captureResponse:(NSString *)reqID response:(NSDictionary *)response)
|
|
80
154
|
{
|
|
81
|
-
|
|
155
|
+
LROResponseBuilder *builder = capturedRequests[reqID];
|
|
156
|
+
|
|
157
|
+
if (builder) {
|
|
158
|
+
if ([response objectForKey:@"body"]) {
|
|
159
|
+
NSDictionary *arson = [response objectForKey:@"body"];
|
|
160
|
+
if (arson && [arson objectForKey:@"arson"]) {
|
|
161
|
+
builder.arsonBody = [arson objectForKey:@"arson"];
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if ([response objectForKey:@"statusCode"]) {
|
|
166
|
+
NSNumber *statusCode = (NSNumber *) [response objectForKey:@"statusCode"];
|
|
167
|
+
builder.status = [statusCode longValue];
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if ([response objectForKey:@"headers"]) {
|
|
171
|
+
builder.headers = [response objectForKey:@"headers"];
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
[builder capture];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
[capturedRequests removeObjectForKey:reqID];
|
|
82
178
|
}
|
|
83
179
|
|
|
84
180
|
@end
|