From 27f21b9274fee6f80da6f25b3b73d4491e4f9925 Mon Sep 17 00:00:00 2001 From: Abhishek Pandey <64667840+1abhishekpandey@users.noreply.github.com> Date: Tue, 19 Mar 2024 13:12:14 +0530 Subject: [PATCH 1/3] feat: add support for global customContext option (#485) * chore: remove lingering reference to deleted RudderConfig file * fix: logic to merge the externalId in identify call * chore: refactor code * feat: add global option support for customContext * feat: when reset is called then clear the globalOptions customContext field * chore: create a mutable copy of customContexts while merging * Revert "chore: refactor code" This reverts commit 4773a05b59ed38cc688ad2b51d5dafef29955850. * Revert "fix: logic to merge the externalId in identify call" This reverts commit 9e22dbb4c4fb310f55833f04d924aead88788617. * Revert "chore: remove lingering reference to deleted RudderConfig file" This reverts commit fd8bf6b899c75b067d6a5837f2427b13b16549d3. --- Sources/Classes/RSEventRepository.m | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Sources/Classes/RSEventRepository.m b/Sources/Classes/RSEventRepository.m index 27dfa287..296d0fd9 100644 --- a/Sources/Classes/RSEventRepository.m +++ b/Sources/Classes/RSEventRepository.m @@ -268,6 +268,19 @@ - (void)applyIntegrations:(RSMessage *)message withDefaultOption:(RSOption *)def [mutableIntegrations setObject:@YES forKey:@"All"]; message.integrations = mutableIntegrations; } + + // Merge local customContext (message.customContexts) with global customContext (defaultOption.customContexts) giving preference to local one. + if (defaultOption) { + NSMutableDictionary*>* mergedCustomContextValues = [NSMutableDictionary dictionaryWithDictionary:[message.customContexts mutableCopy]]; + + for (NSString* key in defaultOption.customContexts) { + if (!mergedCustomContextValues[key]) { + mergedCustomContextValues[key] = [defaultOption.customContexts[key] mutableCopy]; + } + } + + message.customContexts = mergedCustomContextValues; + } } - (RSMessage *)applyConsents:(RSMessage *)message { @@ -287,6 +300,11 @@ - (void)applySession:(RSMessage *)message withUserSession:(RSUserSession *)_user } -(void) reset { + if (self->defaultOptions != nil && self->defaultOptions.customContexts != nil) { + // Since the reset operation is intended to reset user-level fields, we clear the globalOptions->customContext field. + // The globalOptions->integrations field is a workspace-level setting and should not be cleared. + [self->defaultOptions.customContexts removeAllObjects]; + } if([self->userSession getSessionId] != nil) { [RSLogger logDebug: @"EventRepository: reset: Refreshing the session as the reset is triggered"]; [self->userSession refreshSession]; From 2075910109d17c41da1d2800936aaa8d0ae03b97 Mon Sep 17 00:00:00 2001 From: Desu Sai Venkat <48179357+desusai7@users.noreply.github.com> Date: Tue, 19 Mar 2024 13:45:23 +0530 Subject: [PATCH 2/3] feat: added support for setting advertisingId before sdk init and also persisting it (#481) * feat: added support for setting advertisingId before initialization and also added support for persisting advertisingId * fix: checking if IDFA is valid before saving to defaults --- .../project.pbxproj | 5 + .../Base.lproj/Main.storyboard | 41 ++++- .../RudderSampleAppObjC/_AppDelegate.h | 3 + .../RudderSampleAppObjC/_AppDelegate.m | 17 +- .../RudderSampleAppObjC/_ViewController.m | 10 ++ Podfile.lock | 4 +- Rudder.xcodeproj/project.pbxproj | 162 +++++++++--------- Sources/Classes/Headers/Public/RSClient.h | 2 + Sources/Classes/Headers/Public/RSContext.h | 1 + Sources/Classes/Headers/Public/RSDeviceInfo.h | 2 +- .../Headers/Public/RSPreferenceManager.h | 4 + Sources/Classes/Headers/Public/RSUtils.h | 1 + Sources/Classes/RSClient.m | 25 +++ Sources/Classes/RSContext.m | 21 ++- Sources/Classes/RSDeviceInfo.m | 4 + Sources/Classes/RSPreferenceManager.m | 13 ++ Sources/Classes/RSUtils.m | 4 + 17 files changed, 218 insertions(+), 101 deletions(-) diff --git a/Examples/RudderSampleAppObjC/RudderSampleAppObjC.xcodeproj/project.pbxproj b/Examples/RudderSampleAppObjC/RudderSampleAppObjC.xcodeproj/project.pbxproj index 2d3d6a0d..8db2684a 100644 --- a/Examples/RudderSampleAppObjC/RudderSampleAppObjC.xcodeproj/project.pbxproj +++ b/Examples/RudderSampleAppObjC/RudderSampleAppObjC.xcodeproj/project.pbxproj @@ -24,6 +24,7 @@ ED761A062727E28800B086F4 /* CustomFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = ED7619FC2727E28800B086F4 /* CustomFactory.m */; }; ED761A072727E28800B086F4 /* _AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = ED7619FD2727E28800B086F4 /* _AppDelegate.m */; }; ED8738CE2AB363A80076D24A /* EncryptedDatabaseProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = ED8738CC2AB363A80076D24A /* EncryptedDatabaseProvider.m */; }; + F6A9BB0A2B9F30CA0076FE23 /* RudderConfig.plist in Resources */ = {isa = PBXBuildFile; fileRef = F6A9BB092B9F30CA0076FE23 /* RudderConfig.plist */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -56,6 +57,8 @@ ED7619FD2727E28800B086F4 /* _AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = _AppDelegate.m; sourceTree = ""; }; ED8738CA2AB363A80076D24A /* EncryptedDatabaseProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EncryptedDatabaseProvider.h; sourceTree = ""; }; ED8738CC2AB363A80076D24A /* EncryptedDatabaseProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EncryptedDatabaseProvider.m; sourceTree = ""; }; + F6A9BB092B9F30CA0076FE23 /* RudderConfig.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = RudderConfig.plist; sourceTree = ""; }; + F928F8A942558010CC7088BF /* Pods-RudderSampleAppObjC.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RudderSampleAppObjC.debug.xcconfig"; path = "Target Support Files/Pods-RudderSampleAppObjC/Pods-RudderSampleAppObjC.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -119,6 +122,7 @@ ED0CA6D92A7D049E00899C1C /* RudderConfig */ = { isa = PBXGroup; children = ( + F6A9BB092B9F30CA0076FE23 /* RudderConfig.plist */, ED0CA6DB2A7D049E00899C1C /* SampleRudderConfig.plist */, ED0CA6DC2A7D049E00899C1C /* RudderConfig.swift */, ); @@ -214,6 +218,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + F6A9BB0A2B9F30CA0076FE23 /* RudderConfig.plist in Resources */, ED761A012727E28800B086F4 /* LaunchScreen.storyboard in Resources */, ED0CA6DE2A7D049E00899C1C /* SampleRudderConfig.plist in Resources */, ED761A052727E28800B086F4 /* Images.xcassets in Resources */, diff --git a/Examples/RudderSampleAppObjC/RudderSampleAppObjC/Base.lproj/Main.storyboard b/Examples/RudderSampleAppObjC/RudderSampleAppObjC/Base.lproj/Main.storyboard index 0aab5c64..09e0a816 100644 --- a/Examples/RudderSampleAppObjC/RudderSampleAppObjC/Base.lproj/Main.storyboard +++ b/Examples/RudderSampleAppObjC/RudderSampleAppObjC/Base.lproj/Main.storyboard @@ -1,9 +1,9 @@ - + - + @@ -20,7 +20,7 @@ + + +