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

fix: Add filtering check to legacy code path #155

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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