Skip to content

Commit

Permalink
fix: Add filtering check to legacy code path (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjenkins authored Jul 15, 2022
1 parent a82b928 commit 0212944
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions mParticle-Apple-SDK/Kits/MPKitContainer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2031,17 +2031,19 @@ - (void)configureKits:(NSArray<NSDictionary *> *)kitConfigurations {
while ((key = [attributeEnumerator nextObject])) {
if (![MParticle.sharedInstance.dataPlanFilter isBlockedUserAttributeKey:key]) {
value = userAttributes[key];

FilteredMParticleUser *filteredUser = [[FilteredMParticleUser alloc] initWithMParticleUser:[[[MParticle sharedInstance] identity] currentUser] kitConfiguration:self.kitConfigurations[kitRegister.code]];
if ([kitInstance respondsToSelector:@selector(onSetUserAttribute:)] && filteredUser != nil) {
[kitInstance onSetUserAttribute:filteredUser];
} else if ([kitInstance respondsToSelector:@selector(setUserAttribute:value:)] && [value isKindOfClass:NSStringClass]) {
[kitInstance setUserAttribute:key value:value];
} else if ([kitInstance respondsToSelector:@selector(setUserAttribute:value:)] && [value isKindOfClass:NSNumberClass]) {
value = [value stringValue];
[kitInstance setUserAttribute:key value:value];
} else if ([kitInstance respondsToSelector:@selector(setUserAttribute:values:)] && [value isKindOfClass:NSArrayClass]) {
[kitInstance setUserAttribute:key values:value];
MPKitFilter *kitFilter = [self filter:kitRegister forUserAttributeKey:key value:value];
if (!kitFilter.shouldFilter) {
FilteredMParticleUser *filteredUser = [[FilteredMParticleUser alloc] initWithMParticleUser:[[[MParticle sharedInstance] identity] currentUser] kitConfiguration:self.kitConfigurations[kitRegister.code]];
if ([kitInstance respondsToSelector:@selector(onSetUserAttribute:)] && filteredUser != nil) {
[kitInstance onSetUserAttribute:filteredUser];
} else if ([kitInstance respondsToSelector:@selector(setUserAttribute:value:)] && [value isKindOfClass:NSStringClass]) {
[kitInstance setUserAttribute:key value:value];
} else if ([kitInstance respondsToSelector:@selector(setUserAttribute:value:)] && [value isKindOfClass:NSNumberClass]) {
value = [value stringValue];
[kitInstance setUserAttribute:key value:value];
} else if ([kitInstance respondsToSelector:@selector(setUserAttribute:values:)] && [value isKindOfClass:NSArrayClass]) {
[kitInstance setUserAttribute:key values:value];
}
}
}
}
Expand Down

0 comments on commit 0212944

Please sign in to comment.