Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call track async #18

Merged
merged 3 commits into from Jul 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-format
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -31,3 +31,4 @@ Carthage
# `pod install` in .travis.yml
#
Pods/
.clang-format
10 changes: 5 additions & 5 deletions Example/Podfile.lock
@@ -1,10 +1,10 @@
PODS:
- Analytics (3.6.0)
- Analytics (3.6.1)
- Expecta (1.0.5)
- OCHamcrest (6.1.1)
- OCMockito (4.1.0):
- OCHamcrest (~> 6.0)
- Segment-Taplytics (1.1.0):
- Segment-Taplytics (1.1.1):
- Analytics (~> 3.0)
- Taplytics (~> 2.15.5)
- Specta (1.0.6)
Expand All @@ -21,14 +21,14 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
Analytics: 15be3e651d22cc811f44df65698538236676437b
Analytics: 32f2d1e0e5499c493450192726b0b42d43606b82
Expecta: e1c022fcd33910b6be89c291d2775b3fe27a89fe
OCHamcrest: 363e1bf738c3e8a94abe7c2c415f70d671adde38
OCMockito: bceefcd365252bcdf8b59c1b2bd23890805fc0d8
Segment-Taplytics: 9ac62b08938eb7545e1dec4413a2715e533b4997
Segment-Taplytics: d28bfc562b08450eb4fa1eb7a868cbc716e3da05
Specta: f506f3a8361de16bc0dcf3b17b75e269072ba465
Taplytics: ff5a5fb99967b1b3a3348b7d3a3d3fa39c1cff2d

PODFILE CHECKSUM: 628429fdb506eb32767cc4ec540d911f0f52ca03

COCOAPODS: 1.2.0
COCOAPODS: 1.2.1
4 changes: 2 additions & 2 deletions Example/Segment-Taplytics.xcodeproj/project.pbxproj
Expand Up @@ -350,7 +350,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
EEF0D1A269A243F35F74BE70 /* [CP] Check Pods Manifest.lock */ = {
Expand All @@ -365,7 +365,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
F9600015AA49289B9E97C4BE /* [CP] Embed Pods Frameworks */ = {
Expand Down
40 changes: 36 additions & 4 deletions Segment-Taplytics/Classes/SEGTaplyticsIntegration.m
Expand Up @@ -81,8 +81,7 @@ + (NSDictionary *)map:(NSDictionary *)dictionary withAttributes:(NSArray *)attri

return [mapped copy];
}

- (void)identify:(SEGIdentifyPayload *)payload
- (void)callIdentify:(SEGIdentifyPayload *)payload
{
NSArray *taplyticsAttributes = @[ @"user_id", @"name", @"firstName", @"lastName", @"email", @"age", @"gender", @"avatarUrl" ];

Expand All @@ -94,6 +93,18 @@ - (void)identify:(SEGIdentifyPayload *)payload
SEGLog(@"[[Taplytics sharedInstance] setUserAttributes:%@]", mappedTraits);
}


- (void)identify:(SEGIdentifyPayload *)payload
{
if ([NSThread isMainThread]) {
[self callIdentify:payload];
} else {
dispatch_async(dispatch_get_main_queue(), ^{
[self callIdentify:payload];
});
}
}

+ (NSNumber *)extractValue:(NSDictionary *)dictionary withKey:(NSString *)valueKey
{
id valueProperty = nil;
Expand Down Expand Up @@ -140,7 +151,7 @@ + (NSNumber *)extractRevenue:(NSDictionary *)dictionary withKey:(NSString *)reve
return nil;
}

- (void)track:(SEGTrackPayload *)payload
- (void)callTrack:(SEGTrackPayload *)payload
{
NSMutableDictionary *mutablePayload = [NSMutableDictionary dictionaryWithDictionary:payload.properties];

Expand All @@ -166,12 +177,33 @@ - (void)track:(SEGTrackPayload *)payload
SEGLog(@"[[Taplytics sharedInstance] logEvent:%@ value:nil metaData:%@]", payload.event, payload.properties);
}

- (void)reset
- (void)track:(SEGTrackPayload *)payload
{
if ([NSThread isMainThread]) {
[self callTrack:payload];
} else {
dispatch_async(dispatch_get_main_queue(), ^{
[self callTrack:payload];
});
}
}
- (void)callReset
{
SEGLog(@"Taplytics resetUser");
[self.taplyticsClass resetUser:nil];
}

- (void)reset
{
if ([NSThread isMainThread]) {
[self callReset];
} else {
dispatch_async(dispatch_get_main_queue(), ^{
[self callReset];
});
}
}

- (NSString *)apiKey
{
return self.settings[@"apiKey"];
Expand Down
6 changes: 4 additions & 2 deletions Segment-Taplytics/Classes/SEGTaplyticsIntegrationFactory.m
Expand Up @@ -9,12 +9,14 @@
#import "SEGTaplyticsIntegrationFactory.h"
#import "SEGTaplyticsIntegration.h"

@interface SEGTaplyticsIntegrationFactory()

@interface SEGTaplyticsIntegrationFactory ()

@property (nonatomic, assign) BOOL skipInit;

@end


@implementation SEGTaplyticsIntegrationFactory

+ (instancetype)instance
Expand Down Expand Up @@ -50,7 +52,7 @@ - (instancetype)initWithSkipInitialization:(BOOL)skipInit
if (self.skipInit) {
return [[SEGTaplyticsIntegration alloc] initWithSettingsAndSkipTaplyticsIntialization:settings];
}

return [[SEGTaplyticsIntegration alloc] initWithSettings:settings];
}

Expand Down