Skip to content

Commit c78bb6d

Browse files
committed
Correctly pick up boolean
1 parent 25fbcaf commit c78bb6d

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

Analytics/Integrations/Kahuna/SEGKahunaIntegration.m

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ @implementation SEGKahunaIntegration
4545

4646
+ (void)load {
4747
[SEGAnalytics registerIntegration:self withIdentifier:@"Kahuna"];
48-
48+
4949
// When this class loads we will register for the 'UIApplicationDidFinishLaunchingNotification' notification.
5050
// To receive the notification we will use the SEGKahunaPushMonitor singleton instance.
5151
[[NSNotificationCenter defaultCenter] addObserver:[SEGKahunaPushMonitor sharedInstance]
@@ -60,7 +60,7 @@ - (id)init {
6060
self.name = @"Kahuna";
6161
self.valid = NO;
6262
self.initialized = NO;
63-
63+
6464
_kahunaCredentialsKeys = [NSSet setWithObjects: KAHUNA_CREDENTIAL_USERNAME,
6565
KAHUNA_CREDENTIAL_EMAIL,
6666
KAHUNA_CREDENTIAL_FACEBOOK,
@@ -85,11 +85,11 @@ - (void)start {
8585
[KahunaAnalytics handleNotification:[SEGKahunaPushMonitor sharedInstance].pushInfo withApplicationState:[SEGKahunaPushMonitor sharedInstance].applicationState];
8686
[SEGKahunaPushMonitor sharedInstance].pushInfo = nil;
8787
}
88-
88+
8989
[SEGKahunaPushMonitor sharedInstance].kahunaInitialized = TRUE;
9090
}
9191
}
92-
92+
9393
[super start];
9494
}
9595

@@ -106,12 +106,12 @@ - (void)identify:(NSString *)userId traits:(NSDictionary *)traits options:(NSDic
106106
if (KAHUNA_NOT_STRING_NULL_EMPTY (userId)) {
107107
[KahunaAnalytics setUserCredentialsWithKey:KAHUNA_CREDENTIAL_USER_ID andValue:userId];
108108
}
109-
109+
110110
// We will go through each of the above keys, and try to see if the traits has that key. If it does, then we will add the key:value as a credential.
111111
// All other traits is being tracked as an attribute.
112112
for (NSString *eachKey in traits) {
113113
if (!KAHUNA_NOT_STRING_NULL_EMPTY (eachKey)) continue;
114-
114+
115115
NSString *eachValue = [traits objectForKey:eachKey];
116116
if (KAHUNA_NOT_STRING_NULL_EMPTY (eachValue)) {
117117
// Check if this is a Kahuna credential key.
@@ -136,7 +136,7 @@ - (void)identify:(NSString *)userId traits:(NSDictionary *)traits options:(NSDic
136136
}
137137
}
138138
}
139-
139+
140140
// Track the attributes if we have any items in it.
141141
if (attributes.count > 0) {
142142
[KahunaAnalytics setUserAttributes:attributes];
@@ -155,30 +155,30 @@ - (void)track:(NSString *)event properties:(NSDictionary *)properties options:(N
155155
} else if ([value isKindOfClass:[NSNumber class]]) {
156156
quantity = value;
157157
}
158-
158+
159159
break;
160160
}
161161
}
162-
162+
163163
// Get the count and value from quantity and revenue.
164164
long value = (long) ([revenue doubleValue] * 100);
165165
long count = [quantity longValue];
166-
166+
167167
if (count + value > 0) {
168168
[KahunaAnalytics trackEvent:event withCount:count andValue:value];
169169
} else {
170170
[KahunaAnalytics trackEvent:event];
171171
}
172-
172+
173173
NSMutableDictionary *attributes = [[NSMutableDictionary alloc] init];
174174
NSMutableDictionary *lowerCaseKeyProperties = [[NSMutableDictionary alloc] init];
175-
175+
176176
// Lower case all the keys and copy over the properties into a new dictionary.
177177
for (NSString *eachKey in properties) {
178178
if (!KAHUNA_NOT_STRING_NULL_EMPTY (eachKey)) continue;
179179
[lowerCaseKeyProperties setValue:properties[eachKey] forKey:[eachKey lowercaseString]];
180180
}
181-
181+
182182
if ([event caseInsensitiveCompare:KAHUNA_VIEWED_PRODUCT_CATEGORY] == NSOrderedSame) {
183183
[self addViewedProductCategoryElements:&attributes fromProperties:lowerCaseKeyProperties];
184184
} else if ([event caseInsensitiveCompare:KAHUNA_VIEWED_PRODUCT] == NSOrderedSame) {
@@ -188,7 +188,7 @@ - (void)track:(NSString *)event properties:(NSDictionary *)properties options:(N
188188
} else if ([event caseInsensitiveCompare:KAHUNA_COMPLETED_ORDER] == NSOrderedSame) {
189189
[self addCompletedOrderElements:&attributes fromProperties:lowerCaseKeyProperties];
190190
}
191-
191+
192192
// If we have collected any attributes, then we will call the setUserAttributes API
193193
if (attributes.count > 0) {
194194
[KahunaAnalytics setUserAttributes:attributes];
@@ -207,7 +207,7 @@ - (void) addViewedProductCategoryElements:(NSMutableDictionary*__autoreleasing*)
207207
if (aryOfCategoriesViewed.count > 50) {
208208
[aryOfCategoriesViewed removeObjectAtIndex:0]; // Remove the first object.
209209
}
210-
210+
211211
[aryOfCategoriesViewed addObject:value];
212212
[(*attributes) setValue:[aryOfCategoriesViewed componentsJoinedByString:@","] forKey:KAHUNA_CATEGORIES_VIEWED];
213213
}
@@ -226,7 +226,7 @@ - (void) addViewedProductElements:(NSMutableDictionary*__autoreleasing*) attribu
226226
if (KAHUNA_NOT_STRING_NULL_EMPTY(kname)) {
227227
[(*attributes) setValue:kname forKey:KAHUNA_LAST_PRODUCT_VIEWED_NAME];
228228
}
229-
229+
230230
[self addViewedProductCategoryElements:attributes fromProperties:properties];
231231
}
232232

@@ -235,12 +235,12 @@ - (void) addAddedProductElements:(NSMutableDictionary*__autoreleasing*) attribut
235235
if (KAHUNA_NOT_STRING_NULL_EMPTY(kname)) {
236236
[(*attributes) setValue:kname forKey:KAHUNA_LAST_PRODUCT_ADDED_TO_CART_NAME];
237237
}
238-
238+
239239
id category = properties [KAHUNA_CATEGORY];
240240
if (!KAHUNA_NOT_STRING_NULL_EMPTY(category)) {
241241
category = KAHUNA_NONE;
242242
}
243-
243+
244244
[(*attributes) setValue:category forKey:KAHUNA_LAST_PRODUCT_ADDED_TO_CART_CATEGORY];
245245
}
246246

@@ -254,7 +254,7 @@ - (void) addCompletedOrderElements:(NSMutableDictionary*__autoreleasing*) attrib
254254
}
255255

256256
- (void)screen:(NSString *)screenTitle properties:(NSDictionary *)properties options:(NSDictionary *)options {
257-
BOOL trackAllPages = [[self.settings objectForKey:@"trackAllPages"] boolValue];
257+
BOOL trackAllPages = [(NSNumber *)[self.settings objectForKey:@"trackAllPages"] boolValue];
258258
if (trackAllPages && KAHUNA_NOT_STRING_NULL_EMPTY (screenTitle)) {
259259
// Track the screen view as an event.
260260
[self track:SEGEventNameForScreenTitle(screenTitle) properties:properties options:options];
@@ -291,7 +291,7 @@ - (void) didFinishLaunching:(NSNotification*) notificationPayload {
291291
[SEGKahunaPushMonitor sharedInstance].pushInfo = remoteNotification;
292292
[SEGKahunaPushMonitor sharedInstance].applicationState = UIApplicationStateInactive;
293293
}
294-
294+
295295
// We will also swizzle the app delegate methods now. We need this so that we can intercept the registration for device token
296296
// and a push being received when the app is in foreground or background.
297297
[self swizzleAppDelegateMethods];
@@ -312,11 +312,11 @@ - (void) swizzleAppDelegateMethods
312312
{
313313
Method methodSegmentWrapper = class_getInstanceMethod([self class], selector);
314314
const char *methodTypeEncoding = method_getTypeEncoding(methodSegmentWrapper);
315-
315+
316316
IMP implementationSegmentWrapper = class_getMethodImplementation([self class], selector);
317317
class_addMethod ([[UIApplication sharedApplication].delegate class], selector, implementationSegmentWrapper, methodTypeEncoding);
318318
}
319-
319+
320320
// ####### didReceiveRemoteNotification #######
321321
selector = @selector(application:didReceiveRemoteNotification:);
322322
if ([[UIApplication sharedApplication].delegate respondsToSelector:selector])
@@ -327,18 +327,18 @@ - (void) swizzleAppDelegateMethods
327327
{
328328
Method methodSegmentWrapper = class_getInstanceMethod([self class], selector);
329329
const char *methodTypeEncoding = method_getTypeEncoding(methodSegmentWrapper);
330-
330+
331331
IMP implementationSegmentWrapper = class_getMethodImplementation([self class], selector);
332332
class_addMethod ([[UIApplication sharedApplication].delegate class], selector, implementationSegmentWrapper, methodTypeEncoding);
333333
}
334-
334+
335335
// ####### didReceiveRemoteNotification:fetchCompletionHandler #######
336336
selector = @selector(application:didReceiveRemoteNotification:fetchCompletionHandler:);
337337
if ([[UIApplication sharedApplication].delegate respondsToSelector:selector])
338338
{
339339
selOriginalApplicationDidReceiveRemoteNotificationWithFetchCompletionHandler = (void (*)(id, SEL, id, id, void (^)(UIBackgroundFetchResult result))) [[[UIApplication sharedApplication].delegate class] instanceMethodForSelector:selector];
340340
}
341-
341+
342342
// ####### handleActionWithIdentifier:forRemoteNotification:completionHandler #######
343343
selector = @selector(application:handleActionWithIdentifier:forRemoteNotification:completionHandler:);
344344
if ([[UIApplication sharedApplication].delegate respondsToSelector:selector])
@@ -349,38 +349,38 @@ - (void) swizzleAppDelegateMethods
349349
{
350350
Method methodSegmentWrapper = class_getInstanceMethod([self class], selector);
351351
const char *methodTypeEncoding = method_getTypeEncoding(methodSegmentWrapper);
352-
352+
353353
IMP implementationSegmentWrapper = class_getMethodImplementation([self class], selector);
354354
addedMethodHandleActionWithIdentifierWithFetchCompletionHandler = class_addMethod ([[UIApplication sharedApplication].delegate class], selector, implementationSegmentWrapper, methodTypeEncoding);
355355
}
356-
356+
357357
// Swizzle the methods only if we got the original Application selector. Otherwise no point doing the swizzling.
358358
Method methodSegmentWrapper = nil;
359359
Method methodHostApp = nil;
360-
360+
361361
// Swizzling didFailToRegisterForRemoteNotificationsWithError
362362
if (selOriginalApplicationDidFailToRegisterForRemoteNotificationsWithError)
363363
{
364364
methodSegmentWrapper = class_getInstanceMethod ([self class], @selector(application:didFailToRegisterForRemoteNotificationsWithError:));
365365
methodHostApp = class_getInstanceMethod ([[UIApplication sharedApplication].delegate class], @selector(application:didFailToRegisterForRemoteNotificationsWithError:));
366366
method_exchangeImplementations (methodSegmentWrapper, methodHostApp);
367367
}
368-
368+
369369
// Swizzling didReceiveRemoteNotification
370370
if(selOriginalApplicationDidReceiveRemoteNotification)
371371
{
372372
methodSegmentWrapper = class_getInstanceMethod ([self class], @selector(application:didReceiveRemoteNotification:));
373373
methodHostApp = class_getInstanceMethod ([[UIApplication sharedApplication].delegate class], @selector(application:didReceiveRemoteNotification:));
374374
method_exchangeImplementations (methodSegmentWrapper, methodHostApp);
375375
}
376-
376+
377377
if (selOriginalApplicationDidReceiveRemoteNotificationWithFetchCompletionHandler)
378378
{
379379
methodSegmentWrapper = class_getInstanceMethod ([self class], @selector(application:didReceiveRemoteNotification:fetchCompletionHandler:));
380380
methodHostApp = class_getInstanceMethod ([[UIApplication sharedApplication].delegate class], @selector(application:didReceiveRemoteNotification:fetchCompletionHandler:));
381381
method_exchangeImplementations (methodSegmentWrapper, methodHostApp);
382382
}
383-
383+
384384
selector = @selector(application:handleActionWithIdentifier:forRemoteNotification:completionHandler:);
385385
if (selOriginalApplicationHandleActionWithIdentifierWithFetchCompletionHandler)
386386
{
@@ -400,7 +400,7 @@ - (void) application:(UIApplication *)application didFailToRegisterForRemoteNoti
400400
if ([SEGKahunaPushMonitor sharedInstance].kahunaInitialized) {
401401
[KahunaAnalytics handleNotificationRegistrationFailure:error];
402402
}
403-
403+
404404
if (selOriginalApplicationDidFailToRegisterForRemoteNotificationsWithError)
405405
{
406406
selOriginalApplicationDidFailToRegisterForRemoteNotificationsWithError ([UIApplication sharedApplication].delegate,

0 commit comments

Comments
 (0)