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

Feature/user attributes #347

Merged
merged 28 commits into from
Jul 12, 2024
Merged

Feature/user attributes #347

merged 28 commits into from
Jul 12, 2024

Conversation

kushCT
Copy link
Contributor

@kushCT kushCT commented Jul 8, 2024

  • Change persistence logic to use accountID and deviceID
  • Persistence migration to new UserInfo cache including accountID and deviceID
  • Refactor Event adapter and Trigger Adapter to start using profile attribute names
  • Added support for User Attribute triggering for Profile Increment and Profile Decrement API

Added Unit Test cases for

  • CTUserInfoMigrator
  • EvaluateOnUserAttributeChange
  • getUserAttributeChangeProperties

kushCT and others added 22 commits May 29, 2024 23:28
…ute_names' into Adding_unit_test_cases

* SDK_3824_Refactor_adapter_to_start_using_profile_attribute_names:
  Moved the getUserAttribute and updating profile fields to LocalDataStoreFile
  Refractored some files for code cleaning
  Added support for Profile type Events to be included for server side inapps
  Code Cleaning and refactoring
…tart_using_profile_attribute_names

SDK-3824 Refactor adapter to start using profile attribute names
@kushCT kushCT requested review from nzagorchev, akashvercetti and nishant-clevertap and removed request for nzagorchev and akashvercetti July 8, 2024 11:03
Copy link
Contributor

@nzagorchev nzagorchev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extend CTBatchSentDelegate
- (void)onBatchSent:(NSArray *)batchWithHeader withSuccess:(BOOL)success; to also provide the queue type. Based on the queue type, remove the successfully sent headers from the respective collections. If the queue type is Event, use the current code, if it is Profile, remove from the profile collections.

@@ -298,7 +330,7 @@ - (void)updateTTL:(NSMutableDictionary *)inApp {
- (BatchHeaderKeyPathValues)onBatchHeaderCreationForQueue:(CTQueueType)queueType {
// Evaluation is done for events only at the moment,
// send the evaluated and suppressed ids in that queue header
if (queueType != CTQueueTypeEvents) {
if (queueType != CTQueueTypeEvents && queueType != CTQueueTypeProfile) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create separate collections for the profile server-side in-app ids and the profile suppressed client-side in-apps.

Add to the header the ones based on the queue type.

… batch sent header for incorporating user profile changes
@akashvercetti akashvercetti requested a review from nzagorchev July 11, 2024 04:22
if (newValue == oldValue) {
continue;
}
[eligibleInApps addObjectsFromArray:[self evaluate:event withInApps:self.inAppStore.clientSideInApps]];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The evaluation needs to be outside the if event.profileAttrName so non-profile events are also evaluated

NSMutableArray<NSDictionary *> *eligibleInApps = [NSMutableArray array];
for (CTEventAdapter *event in events) {
[eligibleInApps addObjectsFromArray:[self evaluate:event withInApps:self.inAppStore.serverSideInApps]];
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format code

[self removeSentEvaluatedServerSideInAppIds:header];
[self removeSentSuppressedClientSideInApps:header];
}
else if (queueType == CTQueueTypeEvents) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check should be else if (queueType == CTQueueTypeProfile) {

@@ -215,6 +279,25 @@ - (void)removeSentSuppressedClientSideInApps:(NSDictionary *)header {
}
}

- (void)removeSentEvaluatedServerSideInAppIdsForProfile:(NSDictionary *)header {
NSArray *inapps_eval = header[CLTAP_INAPP_SS_EVAL_STORAGE_KEY_PROFILE];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The header key is the same for profile and event queues, it should be CLTAP_INAPP_SS_EVAL_META_KEY.

}

- (void)removeSentSuppressedClientSideInAppsForProfile:(NSDictionary *)header {
NSArray *suppresed_inapps = header[CLTAP_INAPP_SUPPRESSED_STORAGE_KEY_PROFILE];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The header key is the same for profile and event queues, it should be CLTAP_INAPP_SUPPRESSED_META_KEY.

if (queueType == CTQueueTypeProfile) {

if ([self.evaluatedServerSideInAppIdsForProfile count] > 0) {
header[CLTAP_INAPP_SS_EVAL_STORAGE_KEY_PROFILE] = self.evaluatedServerSideInAppIdsForProfile;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The header meta key should be CLTAP_INAPP_SS_EVAL_META_KEY.

header[CLTAP_INAPP_SS_EVAL_STORAGE_KEY_PROFILE] = self.evaluatedServerSideInAppIdsForProfile;
}
if ([self.suppressedClientSideInAppsForProfile count] > 0) {
header[CLTAP_INAPP_SUPPRESSED_STORAGE_KEY_PROFILE] = self.suppressedClientSideInAppsForProfile;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The header meta key should be CLTAP_INAPP_SUPPRESSED_META_KEY.

[super setUp];
CleverTapInstanceConfig *config = [[CleverTapInstanceConfig alloc] initWithAccountId:@"testAccount" accountToken:@"testToken" accountRegion:@"testRegion"];
CTDeviceInfo *deviceInfo = [[CTDeviceInfo alloc] initWithConfig:config andCleverTapID:@"testDeviceInfo"];
CTDispatchQueueManager *queueManager =[[CTDispatchQueueManager alloc]initWithConfig:config];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format code

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test does not compile.
Method calls to [self.evaluationManager onBatchSent:batchWithHeaderAll withSuccess:YES]; need to be changed to [self.evaluationManager onBatchSent:batchWithHeaderAll withSuccess:YES withQueueType:queueType]; based on the queue type.



[self.evaluationManager evaluateOnUserAttributeChange:profile];
XCTAssertEqualObjects((@[@1]), self.evaluationManager.evaluatedServerSideInAppIds);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should check against evaluatedServerSideInAppIdsForProfile.

@nzagorchev nzagorchev merged commit 4378abe into develop Jul 12, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants