Skip to content

feat: Implement createUserContext for decide API #632

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

Merged
merged 3 commits into from
Dec 8, 2020

Conversation

yavorona
Copy link
Contributor

@yavorona yavorona commented Dec 4, 2020

Summary

  • Implemented createUserContext in optimizely client
  • Created OptimizelyUserContext class and implement setAttribute method
  • Cleaned up existing unit tests
  • Included decideConfig for future decide API testing

Test

  • Manual testing + unit tests

Issues

@yavorona yavorona requested a review from a team as a code owner December 4, 2020 21:33
@yavorona yavorona requested review from jaeopt and mjc1283 December 4, 2020 21:46
@coveralls
Copy link

coveralls commented Dec 4, 2020

Coverage Status

Coverage increased (+0.02%) to 96.732% when pulling e4f595c on pnguen/decide-api-optimizely-user-context into dfc1b7f on master.

Copy link
Contributor

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

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

UserContext looks good.
A couple of changes suggested.

}

getAttributes(): UserAttributes {
return this.attributes;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we return a copy of attributes?
The attributes can be changed by setAttribute while decide using it.

}) {
this.optimizely = optimizely;
this.userId = userId;
this.attributes = attributes ?? {};
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we keep a copy of the given attributes here, so that any changes in the caller attributes after creating userContext are not reflected.

});
});
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have one more test validating that changing caller attributes after createUserContext is not reflected in the create userContext?

Copy link
Contributor

@mjc1283 mjc1283 left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -189,6 +189,7 @@ export const DECISION_NOTIFICATION_TYPES = {
FEATURE_TEST: 'feature-test',
FEATURE_VARIABLE: 'feature-variable',
ALL_FEATURE_VARIABLES: 'all-feature-variables',
FLAG: 'flag',
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be added now, or a later PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the next pr. Will remove it from here. Thanks!

@yavorona yavorona force-pushed the pnguen/decide-api-optimizely-user-context branch from 5114c19 to d83c3ec Compare December 5, 2020 04:29
@yavorona yavorona force-pushed the pnguen/decide-api-optimizely-user-context branch from d83c3ec to e4f595c Compare December 5, 2020 04:31
@yavorona yavorona removed their assignment Dec 5, 2020
Copy link
Contributor

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

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

LGTM

@yavorona yavorona merged commit d658697 into master Dec 8, 2020
@yavorona yavorona deleted the pnguen/decide-api-optimizely-user-context branch December 8, 2020 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants