Skip to content

Commit de20689

Browse files
author
Simon
committed
- Handles extra options on trackAction function
1 parent 40854c7 commit de20689

1 file changed

Lines changed: 30 additions & 12 deletions

File tree

ios/MatherAnalytics.m

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,28 +183,46 @@ @implementation MatherAnalytics
183183
accountNumber:accountNumber];
184184

185185
NSMutableDictionary *event = [[NSMutableDictionary alloc] init];
186-
186+
NSMutableDictionary *options = [[NSMutableDictionary alloc] init];
187+
188+
// Handles Event
189+
190+
/*
187191
// no support for type
188-
// NSString* type = [RCTConvert NSString:payload[@"type"]];
189-
// if (type) {
190-
// event[@"type"] = type;
191-
// }
192+
NSString* type = [RCTConvert NSString:payload[@"type"]];
193+
if (type) {
194+
event[@"type"] = type;
195+
}
196+
*/
197+
192198
NSString* category = [RCTConvert NSString:payload[@"category"]];
193199
if (category) {
194-
event[@"category"] = category;
200+
[event setObject:category forKey:@"category"];
195201
}
196202
NSString* action = [RCTConvert NSString:payload[@"action"]];
197203
if (action) {
198-
event[@"action"] = action;
204+
[event setObject:action forKey:@"action"];
199205
}
200206

207+
// Handles Options
208+
NSArray *offers = [RCTConvert NSArray:payload[@"offers"]];
209+
if (offers) {
210+
[options setObject:offers forKey:@"offers"];
211+
}
212+
213+
/*
201214
// no support for custom
202-
// NSDictionary* custom = [RCTConvert NSDictionary:payload[@"custom"]];
203-
// if (custom) {
204-
// impression[@"custom"] = custom;
205-
// }
215+
NSDictionary* custom = [RCTConvert NSDictionary:payload[@"custom"]];
216+
if (custom) {
217+
impression[@"custom"] = custom;
218+
}
219+
*/
206220

207-
[mListener trackEvent:event];
221+
if ([options count] > 0) {
222+
[mListener trackEvent:event options:options];
223+
} else {
224+
[mListener trackEvent:event];
225+
}
208226
}
209227

210228
RCT_EXPORT_METHOD(trackImpression:(nonnull NSString *)accountName

0 commit comments

Comments
 (0)