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

feat: update to new audience logic #330

Merged

Conversation

BrandonStalnaker
Copy link
Contributor

@BrandonStalnaker BrandonStalnaker commented Feb 24, 2025

Summary

  • Recover Audience API changes

Testing Plan

  • Tested locally and through unit tests

Reference Issue (For mParticle employees only. Ignore if you are an outside contributor)

@BrandonStalnaker BrandonStalnaker self-assigned this Feb 24, 2025
@BrandonStalnaker BrandonStalnaker changed the title Feat/6150 update to new audience logic Feat: update to new audience logic Feb 25, 2025
@BrandonStalnaker BrandonStalnaker changed the title Feat: update to new audience logic feat: update to new audience logic Feb 25, 2025
@BrandonStalnaker BrandonStalnaker force-pushed the feat/6150-Update-To-New-Audience-Logic branch 2 times, most recently from e05b693 to 1fc7a59 Compare February 25, 2025 20:33
Comment on lines 14 to 16
/**
The mParticle id associated with this user (MPID)
*/
Copy link
Member

Choose a reason for hiding this comment

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

this comment looks outdated. please fix

@@ -550,6 +551,10 @@ - (void)testUploadWithOptOutMessage {
[self waitForExpectationsWithTimeout:DEFAULT_TIMEOUT handler:nil];
}

- (void)testAudiences {
Copy link
Member

Choose a reason for hiding this comment

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

There's a lot of code changes but just this 1 test. At a minimum, i feel lik there shoudl be tests for:

  1. ensuring the url endpoint for audience is created properly
  2. ensuring the feature flag works if True or error messages if False

@@ -89,6 +90,13 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (void)removeUserAttribute:(NSString *)key;

#pragma mark - User Audiences
/**
Retrieves user audiences from mParticle's servers and returns the result as two arrays of MPAudience objects
Copy link
Member

Choose a reason for hiding this comment

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

is reeturns result as two arrays accurate? shouldn't it just be a single array of user audiences? this screenshot of a live example on we which hits the same endpoint returns a single array which contains 2 audiences
image

Comment on lines 209 to 223
if (supportedKits) {
kits = [supportedKits componentsJoinedByString:@","];
}

NSString *environment = [NSString stringWithFormat:@"%d", (int)[MPStateMachine environment]];
[urlRequest setValue:environment forHTTPHeaderField:@"x-mp-env"];

MPIUserDefaults *userDefaults = [MPIUserDefaults standardUserDefaults];
NSString *eTag = userDefaults[kMPHTTPETagHeaderKey];
NSDictionary *config = [userDefaults getConfiguration];
if (eTag && config) {
[urlRequest setValue:eTag forHTTPHeaderField:@"If-None-Match"];
}

NSString *query = [_url.defaultURL query];
signatureMessage = [NSString stringWithFormat:@"%@\n%@\n%@?%@", _httpMethod, date, relativePath, query];
Copy link
Member

Choose a reason for hiding this comment

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

should this be in this PR? i'm unclear as to what is going on here. zoom might be easier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So when I was testing this existing code with the endpoint it wasn't working because of a url with capitalization issues and because the the signature was malformed. There was also several headers being sent in the audience call that weren't necessary. So since this was the only ticket I had for this functionality, I fixed it all in this ticket though some of this is also from the changes in that feature branch.

Copy link
Member

@rmi22186 rmi22186 left a comment

Choose a reason for hiding this comment

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

LGTM.

@BrandonStalnaker BrandonStalnaker changed the base branch from main to development March 6, 2025 19:54
@rmi22186 rmi22186 self-requested a review March 6, 2025 20:11
@BrandonStalnaker BrandonStalnaker force-pushed the feat/6150-Update-To-New-Audience-Logic branch from 88b1c03 to f2d0f30 Compare March 6, 2025 21:21
@BrandonStalnaker BrandonStalnaker merged commit 3b9ad82 into development Mar 6, 2025
12 checks passed
@BrandonStalnaker BrandonStalnaker deleted the feat/6150-Update-To-New-Audience-Logic branch March 6, 2025 22:01
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