-
Notifications
You must be signed in to change notification settings - Fork 0
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
Additional params to experiment hooks methods. Enable hooks in getAssignment
#8
Conversation
d4c2ae7
to
7adbe91
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 looks good! 🎉
expect(td.explain(mockHooks.onPreAssignment).callCount).toEqual(1); | ||
expect(td.explain(mockHooks.onPreAssignment).calls[0].args[0]).toEqual('subject-identifer'); | ||
expect(td.explain(mockHooks.onPreAssignment).calls[0].args[0]).toEqual(experimentName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
src/client/eppo-client.ts
Outdated
assignment = this.getAssignment(subjectKey, experimentKey, subjectAttributes); | ||
// check for overridden assignment via hook | ||
const overriddenAssignment = assignmentHooks?.onPreAssignment(experimentKey, subjectKey); | ||
if (overriddenAssignment != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor but we can strict inequality check here (!==
)
…signment` (#8) * additional params to experiment hooks methods. enable hooks in getAssignment * only check assignment override after enabled check * ensure logging callback is invoked when overriding via hook * create internal method to avoid multiple calls to log assignment/post assignment callback * add undefined check
…signment` (#8) * additional params to experiment hooks methods. enable hooks in getAssignment * only check assignment override after enabled check * ensure logging callback is invoked when overriding via hook * create internal method to avoid multiple calls to log assignment/post assignment callback * add undefined check
…signment` (#8) * additional params to experiment hooks methods. enable hooks in getAssignment * only check assignment override after enabled check * ensure logging callback is invoked when overriding via hook * create internal method to avoid multiple calls to log assignment/post assignment callback * add undefined check
Description
IAssignmentHooks
async
in order to potentially perform I/O during a hook invocation. We also got feedback that this isn't necessary/desired, so added the hooks as an optional param to the synchronousgetAssignment
method, and removed thegetAssignmentWithHooks
method.onPreAssignment
after the enabled check so overrides only take place if the flag is enabled