From 5cd3c151de8ad3984552de201166554a9b1eef8e Mon Sep 17 00:00:00 2001 From: Nikola Zagorchev Date: Wed, 7 Aug 2024 16:11:38 +0300 Subject: [PATCH 1/8] Fix tests build (#365) --- .../InApps/CustomTemplates/CTCustomTemplatesManager+Tests.h | 1 + .../InApps/CustomTemplates/CTCustomTemplatesManagerTest.m | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/CleverTapSDKTests/InApps/CustomTemplates/CTCustomTemplatesManager+Tests.h b/CleverTapSDKTests/InApps/CustomTemplates/CTCustomTemplatesManager+Tests.h index deddada4..8e47eaad 100644 --- a/CleverTapSDKTests/InApps/CustomTemplates/CTCustomTemplatesManager+Tests.h +++ b/CleverTapSDKTests/InApps/CustomTemplates/CTCustomTemplatesManager+Tests.h @@ -9,6 +9,7 @@ #ifndef CTCustomTemplatesManager_Tests_h #define CTCustomTemplatesManager_Tests_h #import "CTCustomTemplatesManager.h" +#import "CTCustomTemplatesManager-Internal.h" @interface CTCustomTemplatesManager (Tests) diff --git a/CleverTapSDKTests/InApps/CustomTemplates/CTCustomTemplatesManagerTest.m b/CleverTapSDKTests/InApps/CustomTemplates/CTCustomTemplatesManagerTest.m index 7d72a627..f2c79acd 100644 --- a/CleverTapSDKTests/InApps/CustomTemplates/CTCustomTemplatesManagerTest.m +++ b/CleverTapSDKTests/InApps/CustomTemplates/CTCustomTemplatesManagerTest.m @@ -8,7 +8,6 @@ #import #import -#import "CTCustomTemplatesManager-Internal.h" #import "CTCustomTemplatesManager+Tests.h" #import "CTInAppTemplateBuilder.h" #import "CTAppFunctionBuilder.h" From f99dcc08fc63c1e3994eace8acdb52327b1f1287 Mon Sep 17 00:00:00 2001 From: kushCT Date: Tue, 20 Aug 2024 20:45:27 +0530 Subject: [PATCH 2/8] Added hotfix for `User` prefix getting appended to system variables --- CleverTapSDK/CTConstants.h | 20 +++++++------- CleverTapSDK/CTLocalDataStore.m | 2 +- CleverTapSDK/CTUserInfoMigrator.h | 3 ++- CleverTapSDK/CTUserInfoMigrator.m | 45 +++++++++++++++++++++++++++++-- 4 files changed, 56 insertions(+), 14 deletions(-) diff --git a/CleverTapSDK/CTConstants.h b/CleverTapSDK/CTConstants.h index a3820ec0..14218361 100644 --- a/CleverTapSDK/CTConstants.h +++ b/CleverTapSDK/CTConstants.h @@ -250,16 +250,16 @@ extern NSString *CLTAP_PROFILE_IDENTITY_KEY; #define CLTAP_SYS_CC @"sysCountryCode" #define CLTAP_SYS_TZ @"sysTZ" -#define CLTAP_USER_NAME @"userName" -#define CLTAP_USER_EMAIL @"userEmail" -#define CLTAP_USER_EDUCATION @"userEducation" -#define CLTAP_USER_MARRIED @"userMarried" -#define CLTAP_USER_DOB @"userDOB" -#define CLTAP_USER_BIRTHDAY @"userBirthday" -#define CLTAP_USER_EMPLOYED @"userEmployed" -#define CLTAP_USER_GENDER @"userGender" -#define CLTAP_USER_PHONE @"userPhone" -#define CLTAP_USER_AGE @"userAge" +#define CLTAP_USER_NAME @"Name" +#define CLTAP_USER_EMAIL @"Email" +#define CLTAP_USER_EDUCATION @"Education" +#define CLTAP_USER_MARRIED @"Married" +#define CLTAP_USER_DOB @"DOB" +#define CLTAP_USER_BIRTHDAY @"Birthday" +#define CLTAP_USER_EMPLOYED @"Employed" +#define CLTAP_USER_GENDER @"Gender" +#define CLTAP_USER_PHONE @"Phone" +#define CLTAP_USER_AGE @"Age" #define CLTAP_OPTOUT @"ct_optout" diff --git a/CleverTapSDK/CTLocalDataStore.m b/CleverTapSDK/CTLocalDataStore.m index ffc2d16f..4d7c09d6 100644 --- a/CleverTapSDK/CTLocalDataStore.m +++ b/CleverTapSDK/CTLocalDataStore.m @@ -52,7 +52,7 @@ - (instancetype)initWithConfig:(CleverTapInstanceConfig *)config profileValues:( [self runOnBackgroundQueue:^{ @synchronized (self->localProfileForSession) { // migrate to new persisted ct-accid-guid-userprofile - [CTUserInfoMigrator migrateUserInfoFileForAccountID:self->_config.accountId deviceID:self->_deviceInfo.deviceId]; + [CTUserInfoMigrator migrateUserInfoFileForAccountID:self->_config.accountId deviceID:self->_deviceInfo.deviceId config:self->_config]; self->localProfileForSession = [self _inflateLocalProfile]; for (NSString* key in [profileValues allKeys]) { diff --git a/CleverTapSDK/CTUserInfoMigrator.h b/CleverTapSDK/CTUserInfoMigrator.h index 5285a96a..d50a2756 100644 --- a/CleverTapSDK/CTUserInfoMigrator.h +++ b/CleverTapSDK/CTUserInfoMigrator.h @@ -6,9 +6,10 @@ // #import +#import "CleverTapInstanceConfig.h" @interface CTUserInfoMigrator : NSObject -+ (void)migrateUserInfoFileForAccountID:(NSString *)acc_id deviceID:(NSString *)device_id; ++ (void)migrateUserInfoFileForAccountID:(NSString *)acc_id deviceID:(NSString *)device_id config:(CleverTapInstanceConfig *) config; @end diff --git a/CleverTapSDK/CTUserInfoMigrator.m b/CleverTapSDK/CTUserInfoMigrator.m index cbc48cdc..c89e38d6 100644 --- a/CleverTapSDK/CTUserInfoMigrator.m +++ b/CleverTapSDK/CTUserInfoMigrator.m @@ -1,9 +1,10 @@ #import "CTUserInfoMigrator.h" #import "CTConstants.h" +#import "CTPreferences.h" @implementation CTUserInfoMigrator -+ (void)migrateUserInfoFileForAccountID:(NSString *)acc_id deviceID:(NSString *)device_id { ++ (void)migrateUserInfoFileForAccountID:(NSString *)acc_id deviceID:(NSString *)device_id config:(CleverTapInstanceConfig *) config { NSFileManager *fileManager = [NSFileManager defaultManager]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); NSString *libraryPath = [paths objectAtIndex:0]; @@ -11,16 +12,56 @@ + (void)migrateUserInfoFileForAccountID:(NSString *)acc_id deviceID:(NSString *) NSString *userProfileWithAccountIDPath = [libraryPath stringByAppendingPathComponent:userProfileWithAccountID]; NSString *userProfileWithAccountIDAndDeviceID = [NSString stringWithFormat:@"clevertap-%@-%@-userprofile.plist", acc_id, device_id]; NSString *userProfileWithAccountIDAndDeviceIDPath = [libraryPath stringByAppendingPathComponent:userProfileWithAccountIDAndDeviceID]; - NSError *error = nil; + + // migration from 5.x and 6.x if ([fileManager fileExistsAtPath:userProfileWithAccountIDPath]) { + // unarchive, remove user prefix, copy to new deviceid path + NSSet *allowedClasses = [NSSet setWithObjects:[NSArray class], [NSString class], [NSDictionary class], [NSNumber class], nil]; + NSMutableDictionary *userProfile = [CTPreferences unarchiveFromFile:userProfileWithAccountID ofTypes:allowedClasses removeFile:NO]; + // remove prefixes from only the system fields + [self removeUserPrefixInDictionary:userProfile]; + // store this new clean file at userProfileWithAccountIDAndDeviceIDPath + [CTPreferences archiveObject:userProfile forFileName:userProfileWithAccountID config:config]; [fileManager copyItemAtPath:userProfileWithAccountIDPath toPath:userProfileWithAccountIDAndDeviceIDPath error:&error]; CleverTapLogStaticInternal(@"[CTUserInfo]: Local file copied successfully to %@", userProfileWithAccountIDAndDeviceIDPath); [fileManager removeItemAtPath:userProfileWithAccountIDPath error:&error]; return; + } + + // migration from 7.0.0 + else if ([fileManager fileExistsAtPath:userProfileWithAccountIDAndDeviceIDPath]) { + // unarchive the file at this path + NSSet *allowedClasses = [NSSet setWithObjects:[NSArray class], [NSString class], [NSDictionary class], [NSNumber class], nil]; + NSMutableDictionary *userProfile = [CTPreferences unarchiveFromFile:userProfileWithAccountIDAndDeviceID ofTypes:allowedClasses removeFile:NO]; + // remove prefixes from only the system fields + [self removeUserPrefixInDictionary:userProfile]; + // update the new file at userProfileWithAccountIDAndDeviceIDPath + [CTPreferences archiveObject:userProfile forFileName:userProfileWithAccountIDAndDeviceID config:config]; + return; } else { CleverTapLogStaticInternal(@"[CTUserInfo]: Failed to copy local file: %@", error.localizedDescription); } } ++ (void)removeUserPrefixInDictionary:(NSMutableDictionary *)dictionary { + // List of known profile fields + NSArray *knownProfileFields = @[ + @"userName", @"userEmail", @"userEducation", @"userMarried", + @"userDOB", @"userBirthday", @"userEmployed", @"userGender", + @"userPhone", @"userAge" + ]; + + // Iterate through the original dictionary's keys + for (NSString *key in [dictionary allKeys]) { + if ([knownProfileFields containsObject:key] && [key hasPrefix:@"user"]) { + NSString *newKey = [key substringFromIndex:[@"user" length]]; + + // Update the dictionary with the new key + id value = dictionary[key]; + [dictionary removeObjectForKey:key]; + [dictionary setObject:value forKey:newKey]; + } + } +} @end From ec40666a43647df566d7f86d938872d4a2749ca3 Mon Sep 17 00:00:00 2001 From: kushCT Date: Wed, 21 Aug 2024 00:45:16 +0530 Subject: [PATCH 3/8] Update the PII key names for encrytion of data --- CleverTapSDK/CTConstants.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CleverTapSDK/CTConstants.h b/CleverTapSDK/CTConstants.h index 14218361..a67c2c93 100644 --- a/CleverTapSDK/CTConstants.h +++ b/CleverTapSDK/CTConstants.h @@ -283,4 +283,4 @@ extern NSString *CLTAP_PROFILE_IDENTITY_KEY; #pragma mark Constants for Encryption #define CLTAP_ENCRYPTION_LEVEL @"CleverTapEncryptionLevel" #define CLTAP_ENCRYPTION_IV @"__CL3>3Rt#P__1V_" -#define CLTAP_ENCRYPTION_PII_DATA (@[@"Identity", @"userEmail", @"userPhone", @"userName"]); +#define CLTAP_ENCRYPTION_PII_DATA (@[@"Identity", @"Email", @"Phone", @"Name"]); From 27c435dc740656f75d7e5f18c16db4ab10ea9f82 Mon Sep 17 00:00:00 2001 From: Akash Malhotra Date: Wed, 21 Aug 2024 10:55:54 +0530 Subject: [PATCH 4/8] fixed an unarchiving bug while getting local profile --- CleverTapSDK/CTLocalDataStore.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CleverTapSDK/CTLocalDataStore.m b/CleverTapSDK/CTLocalDataStore.m index 4d7c09d6..cc0318d2 100644 --- a/CleverTapSDK/CTLocalDataStore.m +++ b/CleverTapSDK/CTLocalDataStore.m @@ -707,7 +707,7 @@ - (NSString *)profileFileName { } - (NSMutableDictionary *)_inflateLocalProfile { - NSSet *allowedClasses = [NSSet setWithObjects:[NSString class], [NSMutableDictionary class], nil]; + NSSet *allowedClasses = [NSSet setWithObjects:[NSArray class], [NSString class], [NSDictionary class], [NSNumber class], nil]; NSMutableDictionary *_profile = (NSMutableDictionary *)[CTPreferences unarchiveFromFile:[self profileFileName] ofTypes:allowedClasses removeFile:NO]; if (!_profile) { _profile = [NSMutableDictionary dictionary]; From 40ff84d437c187cc8085a8cc6fd4f56380a4f052 Mon Sep 17 00:00:00 2001 From: kushCT Date: Wed, 21 Aug 2024 17:35:17 +0530 Subject: [PATCH 5/8] Added support for Multi-Value User Profile Properties --- CleverTapSDK/CTLocalDataStore.m | 8 ++++++-- CleverTapSDK/CTProfileBuilder.h | 2 ++ CleverTapSDK/CTUserInfoMigrator.h | 2 +- CleverTapSDK/CTUserInfoMigrator.m | 5 +++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CleverTapSDK/CTLocalDataStore.m b/CleverTapSDK/CTLocalDataStore.m index cc0318d2..523621e3 100644 --- a/CleverTapSDK/CTLocalDataStore.m +++ b/CleverTapSDK/CTLocalDataStore.m @@ -52,8 +52,7 @@ - (instancetype)initWithConfig:(CleverTapInstanceConfig *)config profileValues:( [self runOnBackgroundQueue:^{ @synchronized (self->localProfileForSession) { // migrate to new persisted ct-accid-guid-userprofile - [CTUserInfoMigrator migrateUserInfoFileForAccountID:self->_config.accountId deviceID:self->_deviceInfo.deviceId config:self->_config]; - + [CTUserInfoMigrator migrateUserInfoFileForDeviceID:self->_deviceInfo.deviceId config:self->_config]; self->localProfileForSession = [self _inflateLocalProfile]; for (NSString* key in [profileValues allKeys]) { [self setProfileFieldWithKey:key andValue:profileValues[key]]; @@ -548,6 +547,11 @@ - (id)getProfileFieldForKey:(NSString *)key { newValue = nil; [self removeProfileFieldForKey:key]; } + else if ([commandIdentifier isEqualToString:kCLTAP_COMMAND_SET] || + [commandIdentifier isEqualToString:kCLTAP_COMMAND_ADD] || + [commandIdentifier isEqualToString:kCLTAP_COMMAND_REMOVE]) { + newValue = [CTProfileBuilder _constructLocalMultiValueWithOriginalValues:value forKey:key usingCommand:commandIdentifier localDataStore:self]; + } } else if ([newValue isKindOfClass:[NSString class]]) { // Remove the date prefix before evaluation and persisting NSString *newValueStr = (NSString *)newValue; diff --git a/CleverTapSDK/CTProfileBuilder.h b/CleverTapSDK/CTProfileBuilder.h index b3e93be5..308939df 100644 --- a/CleverTapSDK/CTProfileBuilder.h +++ b/CleverTapSDK/CTProfileBuilder.h @@ -25,4 +25,6 @@ + (NSNumber *_Nullable)_getUpdatedValue:(NSNumber *_Nonnull)value forKey:(NSString *_Nonnull)key withCommand:(NSString *_Nonnull)command cachedValue:(id _Nullable)cachedValue; ++ (NSArray *_Nullable) _constructLocalMultiValueWithOriginalValues:(NSArray * _Nonnull)values forKey:(NSString * _Nonnull)key usingCommand:(NSString * _Nonnull)command localDataStore:(CTLocalDataStore* _Nonnull)dataStore; + @end diff --git a/CleverTapSDK/CTUserInfoMigrator.h b/CleverTapSDK/CTUserInfoMigrator.h index d50a2756..4483b7f3 100644 --- a/CleverTapSDK/CTUserInfoMigrator.h +++ b/CleverTapSDK/CTUserInfoMigrator.h @@ -10,6 +10,6 @@ @interface CTUserInfoMigrator : NSObject -+ (void)migrateUserInfoFileForAccountID:(NSString *)acc_id deviceID:(NSString *)device_id config:(CleverTapInstanceConfig *) config; ++ (void)migrateUserInfoFileForDeviceID:(NSString *)device_id config:(CleverTapInstanceConfig *) config; @end diff --git a/CleverTapSDK/CTUserInfoMigrator.m b/CleverTapSDK/CTUserInfoMigrator.m index c89e38d6..8f0e8bd9 100644 --- a/CleverTapSDK/CTUserInfoMigrator.m +++ b/CleverTapSDK/CTUserInfoMigrator.m @@ -4,7 +4,8 @@ @implementation CTUserInfoMigrator -+ (void)migrateUserInfoFileForAccountID:(NSString *)acc_id deviceID:(NSString *)device_id config:(CleverTapInstanceConfig *) config { ++ (void)migrateUserInfoFileForDeviceID:(NSString *)device_id config:(CleverTapInstanceConfig *) config { + NSString *acc_id = config.accountId; NSFileManager *fileManager = [NSFileManager defaultManager]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); NSString *libraryPath = [paths objectAtIndex:0]; @@ -54,7 +55,7 @@ + (void)removeUserPrefixInDictionary:(NSMutableDictionary *)dictionary { // Iterate through the original dictionary's keys for (NSString *key in [dictionary allKeys]) { - if ([knownProfileFields containsObject:key] && [key hasPrefix:@"user"]) { + if ([knownProfileFields containsObject:key]) { NSString *newKey = [key substringFromIndex:[@"user" length]]; // Update the dictionary with the new key From 608c5699ff24fad238cc2b7715cb90e0b4e3c458 Mon Sep 17 00:00:00 2001 From: kushCT Date: Wed, 21 Aug 2024 18:10:11 +0530 Subject: [PATCH 6/8] Removed redundant constants for system fields with "User" prefix and removed FB and GPID support --- CleverTapSDK/CTConstants.h | 19 ------------------- CleverTapSDK/CTKnownProfileFields.h | 2 -- CleverTapSDK/CTKnownProfileFields.m | 26 -------------------------- CleverTapSDK/CTLocalDataStore.m | 16 +++++++--------- CleverTapSDK/CTProfileBuilder.m | 2 +- CleverTapSDK/CleverTap.h | 10 +++++----- 6 files changed, 13 insertions(+), 62 deletions(-) diff --git a/CleverTapSDK/CTConstants.h b/CleverTapSDK/CTConstants.h index a67c2c93..f5563c25 100644 --- a/CleverTapSDK/CTConstants.h +++ b/CleverTapSDK/CTConstants.h @@ -226,25 +226,6 @@ extern NSString *CLTAP_PROFILE_IDENTITY_KEY; #define CLTAP_INAPP_HTML_SPLIT @"\"##Vars##\"" #define CLTAP_INAPP_IMAGE_INTERSTITIAL_HTML_NAME @"image_interstitial" -#pragma mark Constants for persisting Facebook data -#define CLTAP_FB_NAME @"fbName" -#define CLTAP_FB_ID @"fbId" -#define CLTAP_FB_EMAIL @"fbEmail" -#define CLTAP_FB_GENDER @"fbGender" -#define CLTAP_FB_EDUCATION @"fbEducation" -#define CLTAP_FB_EMPLOYED @"fbEmployed" -#define CLTAP_FB_DOB @"fbDOB" -#define CLTAP_FB_MARRIED @"fbMarried" - -#pragma mark Constants for persisting G+ data -#define CLTAP_GP_NAME @"gpName" -#define CLTAP_GP_ID @"gpId" -#define CLTAP_GP_EMAIL @"gpEmail" -#define CLTAP_GP_GENDER @"gpGender" -#define CLTAP_GP_EMPLOYED @"gpEmployed" -#define CLTAP_GP_DOB @"gpDOB" -#define CLTAP_GP_MARRIED @"gpMarried" - #pragma mark Constants for persisting system data #define CLTAP_SYS_CARRIER @"sysCarrier" #define CLTAP_SYS_CC @"sysCountryCode" diff --git a/CleverTapSDK/CTKnownProfileFields.h b/CleverTapSDK/CTKnownProfileFields.h index f188ae48..a85e730e 100644 --- a/CleverTapSDK/CTKnownProfileFields.h +++ b/CleverTapSDK/CTKnownProfileFields.h @@ -7,8 +7,6 @@ typedef enum { @interface CTKnownProfileFields : NSObject -+ (NSString *)getStorageValueForField:(KnownField)field; - + (KnownField)getKnownFieldIfPossibleForKey:(NSString *)key; @end diff --git a/CleverTapSDK/CTKnownProfileFields.m b/CleverTapSDK/CTKnownProfileFields.m index c201f7f9..a9d7fca2 100644 --- a/CleverTapSDK/CTKnownProfileFields.m +++ b/CleverTapSDK/CTKnownProfileFields.m @@ -4,32 +4,6 @@ @implementation CTKnownProfileFields { } -+ (NSString *)getStorageValueForField:(KnownField)field { - switch (field) { - case Name: - return CLTAP_USER_NAME; - case Email: - return CLTAP_USER_EMAIL; - case Education: - return CLTAP_USER_EDUCATION; - case Married: - return CLTAP_USER_MARRIED; - case DOB: - return CLTAP_USER_DOB; - case Birthday: - return CLTAP_USER_BIRTHDAY; - case Employed: - return CLTAP_USER_EMPLOYED; - case Gender: - return CLTAP_USER_GENDER; - case Phone: - return CLTAP_USER_PHONE; - case Age: - return CLTAP_USER_AGE; - default: - return nil; - } -} + (KnownField)getKnownFieldIfPossibleForKey:(NSString *)key { if ([key isEqualToString:@"Name"]) diff --git a/CleverTapSDK/CTLocalDataStore.m b/CleverTapSDK/CTLocalDataStore.m index 523621e3..e77e3482 100644 --- a/CleverTapSDK/CTLocalDataStore.m +++ b/CleverTapSDK/CTLocalDataStore.m @@ -908,18 +908,16 @@ - (void)addPropertyFromStoreIfExists:(NSString *)profileKey - (NSDictionary*)generateBaseProfile { NSMutableDictionary *profile = [NSMutableDictionary new]; - [self addPropertyFromStoreIfExists:@"Name" profile:profile storageKeys:@[CLTAP_USER_NAME, CLTAP_FB_NAME, CLTAP_GP_NAME]]; - [self addPropertyFromStoreIfExists:@"Gender" profile:profile storageKeys:@[CLTAP_USER_GENDER, CLTAP_FB_GENDER, CLTAP_GP_GENDER]]; - [self addPropertyFromStoreIfExists:@"Education" profile:profile storageKeys:@[CLTAP_USER_EDUCATION, CLTAP_FB_EDUCATION]]; - [self addPropertyFromStoreIfExists:@"Employed" profile:profile storageKeys:@[CLTAP_USER_EMPLOYED, CLTAP_FB_EMPLOYED, CLTAP_GP_EMPLOYED]]; - [self addPropertyFromStoreIfExists:@"Married" profile:profile storageKeys:@[CLTAP_USER_MARRIED, CLTAP_FB_MARRIED, CLTAP_GP_MARRIED]]; - [self addPropertyFromStoreIfExists:@"DOB" profile:profile storageKeys:@[CLTAP_USER_DOB, CLTAP_FB_DOB, CLTAP_GP_DOB]]; + [self addPropertyFromStoreIfExists:@"Name" profile:profile storageKeys:@[CLTAP_USER_NAME]]; + [self addPropertyFromStoreIfExists:@"Gender" profile:profile storageKeys:@[CLTAP_USER_GENDER]]; + [self addPropertyFromStoreIfExists:@"Education" profile:profile storageKeys:@[CLTAP_USER_EDUCATION]]; + [self addPropertyFromStoreIfExists:@"Employed" profile:profile storageKeys:@[CLTAP_USER_EMPLOYED]]; + [self addPropertyFromStoreIfExists:@"Married" profile:profile storageKeys:@[CLTAP_USER_MARRIED]]; + [self addPropertyFromStoreIfExists:@"DOB" profile:profile storageKeys:@[CLTAP_USER_DOB]]; [self addPropertyFromStoreIfExists:@"Birthday" profile:profile storageKeys:@[CLTAP_USER_BIRTHDAY]]; - [self addPropertyFromStoreIfExists:@"FBID" profile:profile storageKeys:@[CLTAP_FB_ID]]; - [self addPropertyFromStoreIfExists:@"GPID" profile:profile storageKeys:@[CLTAP_GP_ID]]; [self addPropertyFromStoreIfExists:@"Phone" profile:profile storageKeys:@[CLTAP_USER_PHONE]]; [self addPropertyFromStoreIfExists:@"Age" profile:profile storageKeys:@[CLTAP_USER_AGE]]; - [self addPropertyFromStoreIfExists:@"Email" profile:profile storageKeys:@[CLTAP_USER_EMAIL, CLTAP_FB_EMAIL]]; + [self addPropertyFromStoreIfExists:@"Email" profile:profile storageKeys:@[CLTAP_USER_EMAIL]]; [self addPropertyFromStoreIfExists:@"tz" profile:profile storageKeys:@[CLTAP_SYS_TZ]]; [self addPropertyFromStoreIfExists:@"Carrier" profile:profile storageKeys:@[CLTAP_SYS_CARRIER]]; [self addPropertyFromStoreIfExists:@"cc" profile:profile storageKeys:@[CLTAP_SYS_CC]]; diff --git a/CleverTapSDK/CTProfileBuilder.m b/CleverTapSDK/CTProfileBuilder.m index e827a1c6..cda86e77 100644 --- a/CleverTapSDK/CTProfileBuilder.m +++ b/CleverTapSDK/CTProfileBuilder.m @@ -70,7 +70,7 @@ + (void)build:(NSDictionary *)profile completionHandler:(void(^ _Nonnull )(NSDic // if a reserved key add to systemFields else add to customFields KnownField kf = [CTKnownProfileFields getKnownFieldIfPossibleForKey:key]; if (kf != UNKNOWN) { - systemFields[[CTKnownProfileFields getStorageValueForField:kf]] = value; + systemFields[key] = value; } else { customFields[key] = value; } diff --git a/CleverTapSDK/CleverTap.h b/CleverTapSDK/CleverTap.h index 44070c58..c920566d 100644 --- a/CleverTapSDK/CleverTap.h +++ b/CleverTapSDK/CleverTap.h @@ -373,16 +373,16 @@ extern NSString * _Nonnull const CleverTapGeofencesDidUpdateNotification; @method @abstract - Creates a separate and distinct user profile identified by one or more of Identity, Email, FBID or GPID values, + Creates a separate and distinct user profile identified by one or more of Identity or Email values, and populated with the key-values included in the properties dictionary. @discussion If your app is used by multiple users, you can use this method to assign them each a unique profile to track them separately. - If instead you wish to assign multiple Identity, Email, FBID and/or GPID values to the same user profile, + If instead you wish to assign multiple Identity and/or Email values to the same user profile, use profilePush rather than this method. - If none of Identity, Email, FBID or GPID is included in the properties dictionary, + If none of Identity or Email is included in the properties dictionary, all properties values will be associated with the current user profile. When initially installed on this device, your app is assigned an "anonymous" profile. @@ -412,10 +412,10 @@ extern NSString * _Nonnull const CleverTapGeofencesDidUpdateNotification; @discussion If your app is used by multiple users, you can use this method to assign them each a unique profile to track them separately. - If instead you wish to assign multiple Identity, Email, FBID and/or GPID values to the same user profile, + If instead you wish to assign multiple Identity and/or Email values to the same user profile, use profilePush rather than this method. - If none of Identity, Email, FBID or GPID is included in the properties dictionary, + If none of Identity or Email is included in the properties dictionary, all properties values will be associated with the current user profile. When initially installed on this device, your app is assigned an "anonymous" profile. From d6f774fb8a054c4624a2d4e57fb8748b3afc7563 Mon Sep 17 00:00:00 2001 From: kushCT Date: Thu, 22 Aug 2024 03:59:34 +0530 Subject: [PATCH 7/8] Fixed the test case file for user profile migration with new method signature --- CleverTapSDKTests/CTUserInfoMigratorTest.m | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CleverTapSDKTests/CTUserInfoMigratorTest.m b/CleverTapSDKTests/CTUserInfoMigratorTest.m index 31e0a5cd..847a1622 100644 --- a/CleverTapSDKTests/CTUserInfoMigratorTest.m +++ b/CleverTapSDKTests/CTUserInfoMigratorTest.m @@ -9,11 +9,13 @@ #import #import "CTUserInfoMigrator.h" #import "XCTestCase+XCTestCase_Tests.h" +#import "CleverTapInstanceConfig.h" @interface CTUserInfoMigratorTest : XCTestCase @property (nonatomic, strong) NSFileManager *fileManager; @property (nonatomic, strong) NSString *libraryPath; +@property (nonatomic, strong) CleverTapInstanceConfig *config; @end @@ -27,6 +29,7 @@ - (void)setUp { // Get the path to the Library directory NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); self.libraryPath = [paths objectAtIndex:0]; + self.config = [[CleverTapInstanceConfig alloc] initWithAccountId:@"testAccID" accountToken:@"testToken" accountRegion:@"testRegion"]; } - (void)tearDown { @@ -52,7 +55,7 @@ - (void)testMigrateUserInfoFileForAccountID_WhenOldFileExists_ShouldCopyToNewLoc [self.fileManager createFileAtPath:oldFilePath contents:[@"old content" dataUsingEncoding:NSUTF8StringEncoding] attributes:nil]; // Call the method to migrate the user info file - [CTUserInfoMigrator migrateUserInfoFileForAccountID:acc_id deviceID:device_id]; + [CTUserInfoMigrator migrateUserInfoFileForDeviceID:device_id config:self.config]; // Check that the old file has been copied to the new location NSString *newFileName = [NSString stringWithFormat:@"clevertap-%@-%@-userprofile.plist", acc_id, device_id]; @@ -77,7 +80,7 @@ - (void)testMigrateUserInfoFileForAccountID_WhenNewFileExists_ShouldNotCopyAndDe [self.fileManager createFileAtPath:newFilePath contents:[@"new content" dataUsingEncoding:NSUTF8StringEncoding] attributes:nil]; // Call the method to migrate the user info file - [CTUserInfoMigrator migrateUserInfoFileForAccountID:acc_id deviceID:device_id]; + [CTUserInfoMigrator migrateUserInfoFileForDeviceID:device_id config:self.config]; // Check that the new file still exists XCTAssertTrue([self.fileManager fileExistsAtPath:newFilePath], @"New plist file should exist"); @@ -96,7 +99,7 @@ - (void)testMigrateUserInfoFileForAccountID_WhenOldFileDoesNotExist_ShouldNotCre [self.fileManager removeItemAtPath:oldFilePath error:nil]; // Call the method to migrate the user info file - [CTUserInfoMigrator migrateUserInfoFileForAccountID:acc_id deviceID:device_id]; + [CTUserInfoMigrator migrateUserInfoFileForDeviceID:device_id config:self.config]; // Check that the new file does not exist NSString *newFileName = [NSString stringWithFormat:@"clevertap-%@-%@-userprofile.plist", acc_id, device_id]; From 17e226e321f760c894feb7fc770533b6e30d2908 Mon Sep 17 00:00:00 2001 From: kushCT Date: Thu, 22 Aug 2024 14:02:28 +0530 Subject: [PATCH 8/8] Updated Changelog and version --- CHANGELOG.md | 5 +++++ CleverTapSDK/CleverTapBuildInfo.h | 2 +- sdk-version.txt | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e75f575..e3d96eb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Change Log All notable changes to this project will be documented in this file. +### [Version 7.0.1](https://github.com/CleverTap/clevertap-ios-sdk/releases/tag/7.0.1) (August 22, 2024) + +#### Fixed +- Fixes a bug where some user properties were being sent with an incorrect prefix + ### [Version 7.0.0](https://github.com/CleverTap/clevertap-ios-sdk/releases/tag/7.0.0) (August 07, 2024) #### Added diff --git a/CleverTapSDK/CleverTapBuildInfo.h b/CleverTapSDK/CleverTapBuildInfo.h index 88724c9b..ff6f62bb 100644 --- a/CleverTapSDK/CleverTapBuildInfo.h +++ b/CleverTapSDK/CleverTapBuildInfo.h @@ -1 +1 @@ -#define WR_SDK_REVISION @"70000" +#define WR_SDK_REVISION @"70001" diff --git a/sdk-version.txt b/sdk-version.txt index 41225218..73a86b19 100644 --- a/sdk-version.txt +++ b/sdk-version.txt @@ -1 +1 @@ -7.0.0 \ No newline at end of file +7.0.1 \ No newline at end of file