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(decide): Added useDecide hook #100

Merged
merged 4 commits into from
Feb 17, 2021
Merged

Conversation

zashraf1985
Copy link
Contributor

@zashraf1985 zashraf1985 commented Feb 11, 2021

Summary

Added a hook which used decide api and returns OptimizelyDecision object. It also supports auto updating just like other existing hooks

Test Plan

  • Manually tested thoroughly
  • Added new unit tests

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.

I had a couple of questions to clarify. See my comments.

src/hooks.ts Outdated
@@ -35,6 +35,8 @@ type HookOptions = {
timeout?: number;
};

type decideHooksOptions = HookOptions & { decideOptions?: OptimizelyDecideOption[] };
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't it be uppercase to be consistent? "DecideHooksOptions"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch

src/hooks.ts Outdated
() => ({
decision: optimizely.decide(flagKey, options.decideOptions, overrides.overrideUserId, overrideAttrs)
}),
[optimizely, flagKey, overrides.overrideUserId, overrideAttrs]
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we need dependency on "options.decideOptions"?
If "IGNORE_USER_PROFILE" is added to the option, it'll generate different decision.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, it makes sense. i fixed it.

@zashraf1985 zashraf1985 requested a review from jaeopt February 16, 2021 19:53
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

@zashraf1985 zashraf1985 merged commit d5b25a9 into master Feb 17, 2021
@zashraf1985 zashraf1985 deleted the zeeshan/decide-hook-new branch February 17, 2021 19:46
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.

3 participants