Skip to content

Commit

Permalink
Merge pull request #33 from kissmetrics/edt/domain-swap-prep
Browse files Browse the repository at this point in the history
Update all domain names and endpoints to new (kissmetrics.io)
  • Loading branch information
NathanielWroblewski committed Jun 17, 2020
2 parents 518b612 + cb12f2c commit 4bcc7b2
Show file tree
Hide file tree
Showing 8 changed files with 251 additions and 251 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3
2.4
10 changes: 5 additions & 5 deletions KISSmetrics-iOS-SDK.podspec.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"name": "KISSmetrics-iOS-SDK",
"version": "2.3.1",
"version": "2.4.0",
"summary": "iOS SDK for KISSmetrics",
"homepage": "http://www.kissmetrics.com",
"documentation_url": "http://support.kissmetrics.com/article/show/ios-sdk-v2",
"homepage": "https://www.kissmetrics.io",
"documentation_url": "https://support.kissmetrics.io/reference#ios-v2",
"license": {
"type": "Apache 2.0",
"text": "http://www.apache.org/licenses/LICENSE-2.0.txt"
},
"authors": {
"kissmetrics": "support@kissmetrics.com"
"kissmetrics": "support@kissmetrics.io"
},
"source": {
"git": "https://github.com/kissmetrics/KISSmetrics-iOS-SDK.git",
"tag": "v2.3.1"
"tag": "v2.4.0"
},
"public_header_files": "KISSmetricsAPI/*.h",
"source_files": "KISSmetricsAPI/*.{h,m,c}",
Expand Down
98 changes: 49 additions & 49 deletions KISSmetricsAPI/KMAArchiver.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
static NSString * const kKMADoTrackKey = @"doTrack";
static NSString * const kKMADoSendKey = @"doSend";
static NSString * const kKMABaseUrlKey = @"baseUrl";
static NSString * const kKMABaseUrlDefault = @"https://trk.kissmetrics.com";
static NSString * const kKMABaseUrlDefault = @"https://trk.kissmetrics.io";
static NSString * const kKMAAPIClientType = @"mobile_app";
static NSString * const kKMAAPIUserAgent = @"kissmetrics-ios/2.3.1";
static NSString * const kKMAAPIUserAgent = @"kissmetrics-ios/2.4.0";
static NSString * const kKMAKeychainAppVersionKey = @"KMAAppVersion";

static KMAArchiver *sSharedArchiver = nil;
Expand Down Expand Up @@ -144,27 +144,27 @@ - (id)init
{
if ((self = [super init])) {
KMALog(@"------------------KMAArchiver init");

// Ensure Library URL exists
if (![self kma_directoryExistsAtUrl:[self kma_libraryUrlWithPathComponent:@"KISSmetrics"]]) {
[self kma_createLibraryDirectoryAtURL:[self kma_libraryUrlWithPathComponent:@"KISSmetrics"]];
}

[self kma_defineDefaultUrls];
[self kma_unarchiveSettings];

// Perform any required migrations base on settings values (schemaVersion)
[self kma_migrateFromVersion:[self getSchemaVersion] toVersion:kKMASchemaVersion];

[self kma_unarchiveIdentity];
[self kma_unarchiveSendQueue];
[self kma_unarchiveSavedIdEvents];
[self kma_unarchiveSavedInstallEvents];
[self kma_unarchiveSavedProperties];

[self keychainAppVersion];
}

return self;
}

Expand All @@ -185,7 +185,7 @@ - (BOOL)kma_directoryExistsAtUrl:(NSURL *)dirUrl
{
BOOL isDir;
BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:dirUrl.path isDirectory:&isDir];

if (exists && isDir) {
return YES;
}
Expand All @@ -204,7 +204,7 @@ - (void)kma_createLibraryDirectoryAtURL:(NSURL *)dirUrl
KMALog(@"KISSmetricsAPI_Archiver - !WARNING! - KISSmetrics library directory could not be created");
return;
}

// Prevent iCloud backup
[self kma_addSkipBackupAttributeToItemAtURL:dirUrl];
}
Expand All @@ -214,7 +214,7 @@ - (void)kma_createLibraryDirectoryAtURL:(NSURL *)dirUrl
- (BOOL)kma_addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
assert([[NSFileManager defaultManager] fileExistsAtPath: [URL path]]);

NSError *error = nil;
BOOL success = [URL setResourceValue: [NSNumber numberWithBool: YES]
forKey: NSURLIsExcludedFromBackupKey error: &error];
Expand All @@ -241,21 +241,21 @@ - (void)kma_migrateFromVersion:(NSInteger)fromVersion toVersion:(NSInteger)toVer
@synchronized(self)
{
switch (fromVersion + 1) {

case 2: {
KMALog(@"KISSmetricsAPI_Archiver - migrating from v1 to v2");

// Migrating from v1 to v2:
// The v1 SDK stored the identity archive directly to the NSLibrary dir.
// Version 2 stores all archive files under a KISSmetrics directory in the NSLibrary dir.
// There is no need to migrate the v1 actions archive from the caches directory as it will have been
// removed during the app update which applies the Version 2 SDK.

NSString *oldIdentityPath = [[NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) lastObject]
stringByAppendingPathComponent:@"KISSMetrics.identity"];

if ([[NSFileManager defaultManager] fileExistsAtPath:oldIdentityPath]) {

NSError *moveError;
[[NSFileManager defaultManager] copyItemAtPath:oldIdentityPath
toPath:self.identityUrl.path
Expand Down Expand Up @@ -284,11 +284,11 @@ - (void)archiveInstallUuid:(NSString *)installUuid
if (installUuid == nil ||
installUuid.length == 0 ||
[self.settings objectForKey:kKMAInstallUuidKey]) {

KMALog(@"KISSmetricsAPI_Archiver - !WARNING! - installUuid not valid to save");
return;
}

@synchronized(self)
{
[self.settings setObject:installUuid forKey:kKMAInstallUuidKey];
Expand Down Expand Up @@ -385,7 +385,7 @@ - (void)archiveFirstIdentity:(NSString*)firstIdentity
if (firstIdentity == nil || firstIdentity.length == 0) {
return;
}

@synchronized(self)
{
KMALog(@"archiveFirstIdentity");
Expand Down Expand Up @@ -445,19 +445,19 @@ - (NSUInteger)getQueueCount
- (void)archiveEvent:(NSString *)name withProperties:(NSDictionary *)properties onCondition:(KMARecordCondition)condition
{
KMALog(@"KMAArchiver archiveEvent withProperties onCondition");

if (name == nil || [name length] == 0) {
KMALog(@"KISSmetricsAPI - !WARNING! - Tried to record event with empty or nil name. Ignoring.");
return;
}

switch (condition) {
case KMARecordAlways:
// Nothing else to check, continue with archiving the event.
break;

case KMARecordOncePerIdentity:

@synchronized(self)
{
if ([self.savedIdEvents containsObject:name]) {
Expand All @@ -468,9 +468,9 @@ - (void)archiveEvent:(NSString *)name withProperties:(NSDictionary *)properties
[self kma_archiveSavedIdEvents];
}
}

break;

case KMARecordOncePerInstall:

@synchronized(self)
Expand All @@ -485,12 +485,12 @@ - (void)archiveEvent:(NSString *)name withProperties:(NSDictionary *)properties
}

break;

default:
// Continue with archiving the event.
break;
}

// Intentionally called outside of @synchronized, method is already synchronized
[self kma_archiveEvent:name withProperties:properties];
}
Expand All @@ -500,16 +500,16 @@ - (void)archiveEvent:(NSString *)name withProperties:(NSDictionary *)properties
- (void)archiveProperties:(NSDictionary *)properties
{
KMALog(@"archiveProperties");

if (properties == nil || [properties count] == 0) {
KMALog(@"KISSmetricsAPI - !WARNING! - Tried to set properties with no properties in it..");
return;
}

@synchronized(self)
{
int actualTimeOfEvent = (int)[[NSDate date] timeIntervalSince1970];

NSString *theUrl = [self.queryEncoder createPropertiesQueryWithProperties:properties
identity:self.identity
timestamp:actualTimeOfEvent];
Expand All @@ -522,22 +522,22 @@ - (void)archiveProperties:(NSDictionary *)properties
- (void)archiveIdentity:(NSString *)identity
{
KMALog(@"KMAArchiver archiveIdentity");

if (identity == nil || [identity length] == 0 || identity == self.identity) {
KMALog(@"KISSmetricsAPI - !WARNING! - attempted to use nil, empty or existing identity. Ignoring.");
return;
}

NSString *theUrl = [self.queryEncoder createAliasQueryWithAlias:identity andIdentity:self.identity];

@synchronized(self)
{
self.identity = identity;

if (![NSKeyedArchiver archiveRootObject:self.identity toFile:self.identityUrl.path]) {
KMALog(@"KISSmetricsAPI - !WARNING! - Unable to archive new identity!");
}

// Only add the alias query if the current identity is a generic identity
if ([self hasGenericIdentity]) {
[self archiveHasGenericIdentity:NO];
Expand All @@ -557,15 +557,15 @@ - (void)archiveIdentity:(NSString *)identity
- (void)archiveAlias:(NSString *)alias withIdentity:(NSString *)identity
{
KMALog(@"KMAArchiver archiveAlias");

if (alias == nil || [alias length] == 0 || identity == nil || [identity length] == 0) {
KMALog(@"KISSmetricsAPI - !WARNING! - attempted to use nil or empty identities in alias (%@ and %@). Ignoring.",
alias, identity);
return;
}

NSString *theUrl = [self.queryEncoder createAliasQueryWithAlias:alias andIdentity:identity];

@synchronized(self)
{
[self.sendQueue addObject:theUrl];
Expand All @@ -576,7 +576,7 @@ - (void)archiveAlias:(NSString *)alias withIdentity:(NSString *)identity
- (void)archiveDistinctProperty:(NSString*)name value:(NSObject*)value
{
NSString *valueString;

// Confirm value is of type NSString or NSNumber
if ([value isKindOfClass:[NSString class]]) {
valueString = (NSString*)value;
Expand All @@ -589,7 +589,7 @@ - (void)archiveDistinctProperty:(NSString*)name value:(NSObject*)value
KMALog(@"KISSmetricsAPI - !WARNING! - Property values must be NSString or NSNumber objects!");
return;
}

@synchronized(self)
{
// All property values are archived as NSStrings
Expand All @@ -603,7 +603,7 @@ - (void)archiveDistinctProperty:(NSString*)name value:(NSObject*)value
[self kma_archiveSavedProperties];
}
}

[self archiveProperties:@{name:valueString}];
}

Expand All @@ -623,7 +623,7 @@ - (NSNumber *)getVerificationExpDate
if ([self.settings objectForKey:kKMAVerificationExpDateKey]) {
return [self.settings objectForKey:kKMAVerificationExpDateKey];
}

return @(kKMAVerificationExpDateDefault);
}

Expand All @@ -633,7 +633,7 @@ - (BOOL)hasGenericIdentity
if ([self.settings objectForKey:kKMAHasGenericIdentityKey]) {
return [[self.settings objectForKey:kKMAHasGenericIdentityKey] boolValue];
}

return kKMAHasGenericIdentityDefault;
}

Expand All @@ -643,7 +643,7 @@ - (BOOL)getDoSend
if ([self.settings objectForKey:kKMADoSendKey]) {
return [[self.settings objectForKey:kKMADoSendKey] boolValue];
}

return kKMADoSendDefault;
}

Expand All @@ -653,7 +653,7 @@ - (BOOL)getDoTrack
if ([self.settings objectForKey:kKMADoTrackKey]) {
return [[self.settings objectForKey:kKMADoTrackKey] boolValue];
}

return kKMADoTrackDefault;
}

Expand All @@ -663,7 +663,7 @@ - (NSString *)getBaseUrl
if ([self.settings objectForKey:kKMABaseUrlKey]) {
return (NSString *)[self.settings objectForKey:kKMABaseUrlKey];
}

return (NSString *)kKMABaseUrlDefault;
}

Expand All @@ -674,19 +674,19 @@ - (NSString *)getBaseUrl
- (void)kma_archiveEvent:(NSString *)name withProperties:(NSDictionary *)properties
{
KMALog(@"KMAArchiver archiveEvent withProperties");

@synchronized(self)
{
// We'll store and use the actual time of the record event in case of disconnected operation.
int actualTimeOfEvent = (int)[[NSDate date] timeIntervalSince1970];

NSString *theUrl = [self.queryEncoder createEventQueryWithName:name
properties:properties
identity:self.identity
timestamp:actualTimeOfEvent];
// Queue up call
[self.sendQueue addObject:theUrl];

// Persist the new queue
[self kma_archiveSendQueue];
}
Expand Down Expand Up @@ -721,7 +721,7 @@ - (void)kma_archiveDefaultSettings
kKMABaseUrlKey: kKMABaseUrlDefault,
kKMAVerificationExpDateKey: @(kKMAVerificationExpDateDefault),
kKMAHasGenericIdentityKey: @(kKMAHasGenericIdentityDefault)} mutableCopy];

[self kma_archiveSettings];
}

Expand Down
4 changes: 2 additions & 2 deletions KISSmetricsAPI/KMAVerification.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#import "KMAVerification.h"

static float const kKMAVerificationTimeout = 20.0f;
static NSString * const kKMAVerificationUrl = @"https://et.kissmetrics.com/m/trk";
static NSString * const kKMAVerificationUrl = @"https://et.kissmetrics.io/m/trk";


@implementation KMAVerification {
Expand Down Expand Up @@ -135,7 +135,7 @@ - (void)connectionDidFinishLoading:(NSURLConnection *)connection

if (!jsonParsingError) {
// Parse JSON for expected data
// Expected JSON payload = { "reason": "PRODUCT_SAMPLING", "tracking": false, "tracking_endpoint": "trk.kissmetrics.com"}
// Expected JSON payload = { "reason": "PRODUCT_SAMPLING", "tracking": false, "tracking_endpoint": "trc.kissmetrics.io"}
_success = YES;
_expirationDate = [self kma_unixTimestampFromDateString:_expiresHeaderString];
_doTrack = [[jsonDict objectForKey:@"tracking"] boolValue];
Expand Down
Loading

0 comments on commit 4bcc7b2

Please sign in to comment.