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

[Statsig] Add test gates and events #3659

Merged
merged 2 commits into from
Apr 23, 2024
Merged

[Statsig] Add test gates and events #3659

merged 2 commits into from
Apr 23, 2024

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Apr 23, 2024

This adds some test-only gates and events so we can see if Metric Lifts work as we expect.

See inline comments.

Copy link

render bot commented Apr 23, 2024

const gate = useGate()

useEffect(() => {
logEvent('test:all:always', {})
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Always fires. Baseline.

useEffect(() => {
logEvent('test:all:always', {})
if (Math.random() < 0.2) {
logEvent('test:all:sometimes', {})
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also baseline, but fires less often.

if (Math.random() < 0.1) {
logEvent('test:all:boosted_by_gate1', {
reason: 'base',
})
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This one doesn't fire as much... unless you're in gate 1 (see below).

}, [])

return [
gate('test_gate_1') ? <TestGate1 /> : null,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Expose everyone to this GK.


return [
gate('test_gate_1') ? <TestGate1 /> : null,
shouldExposeToGate2 && gate('test_gate_2') ? <TestGate2 /> : null,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Expose a smaller % to this gate (note separate sessions increase the probability of exposure because Math.random for shouldExposeToGate2 is at module level)

if (Math.random() < 0.5) {
logEvent('test:all:boosted_by_gate1', {
reason: 'gate1',
})
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes sure we hit more of these under the first gate.

return null
}

function TestGate2() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same but for the other gate.

})
}
if (Math.random() < 0.5) {
logEvent('test:all:boosted_by_both', {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Both gates boost this one, but neither does it better.

Copy link

Old size New size Diff
6.45 MB 6.45 MB 1006 B (0.01%)

@gaearon gaearon merged commit 0967251 into main Apr 23, 2024
6 checks passed
@gaearon gaearon deleted the statsig-test-gates branch April 23, 2024 03:47
estrattonbailey added a commit that referenced this pull request Apr 23, 2024
* origin/main: (47 commits)
  Add option to remove quoted post in composer (#3670)
  Add border radius to GIF loading state (#3669)
  use mp4 over webm (#3666)
  Release 1.79 (#3661)
  Update Japanese translation (#3656)
  [Statsig] Add test gates and events (#3659)
  Quick fix to ensure disable 2fa dialog adjusts to keyboard (#3658)
  Email auth factor (#3602)
  GIF Viewer (#3605)
  Ungate profile scroll fix (#3655)
  rm country param (#3653)
  [GIFs] Remove consent flow (#3652)
  [GIFs] Replace GIPHY with Tenor (#3651)
  properly close the switch account dialog (#3558)
  [GIFs] Reset scroll on query change (#3642)
  Update French translations (#3644)
  [GIFs] Add error boundary to GIF picker (#3643)
  Revert "Add layout transitions to the composer photo gallery on iOS (#3609)" (#3649)
  Update Finnish translations  (#3630)
  Update Japanese translations (#3632)
  ...
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