Bluesky app fork with some witchin' additions 💫

[Statsig] Add test gates and events (#3659)

* [Statsig] Add test gates and events

* Better types

authored by danabra.mov and committed by

GitHub 09672511 30c2c051

+89 -1
+10
src/lib/statsig/events.ts
··· 113 113 | 'ProfileMenu' 114 114 | 'ProfileHoverCard' 115 115 } 116 + 117 + 'test:all:always': {} 118 + 'test:all:sometimes': {} 119 + 'test:all:boosted_by_gate1': {reason: 'base' | 'gate1'} 120 + 'test:all:boosted_by_gate2': {reason: 'base' | 'gate2'} 121 + 'test:all:boosted_by_both': {reason: 'base' | 'gate1' | 'gate2'} 122 + 'test:gate1:always': {} 123 + 'test:gate1:sometimes': {} 124 + 'test:gate2:always': {} 125 + 'test:gate2:sometimes': {} 116 126 }
+2
src/lib/statsig/gates.ts
··· 6 6 | 'hide_vertical_scroll_indicators' 7 7 | 'show_follow_back_label_v2' 8 8 | 'start_session_with_following_v2' 9 + | 'test_gate_1' 10 + | 'test_gate_2' 9 11 | 'use_new_suggestions_endpoint'
+77 -1
src/view/screens/Profile.tsx
··· 1 - import React, {useMemo} from 'react' 1 + import React, {useEffect, useMemo} from 'react' 2 2 import {StyleSheet} from 'react-native' 3 3 import { 4 4 AppBskyActorDefs, ··· 11 11 import {useFocusEffect} from '@react-navigation/native' 12 12 import {useQueryClient} from '@tanstack/react-query' 13 13 14 + import {logEvent, useGate} from '#/lib/statsig/statsig' 14 15 import {cleanError} from '#/lib/strings/errors' 15 16 import {useProfileShadow} from '#/state/cache/profile-shadow' 16 17 import {useLabelerInfoQuery} from '#/state/queries/labeler' ··· 465 466 accessibilityHint="" 466 467 /> 467 468 )} 469 + <TestGates /> 468 470 </ScreenHider> 469 471 ) 470 472 } ··· 522 524 textAlign: 'center', 523 525 }, 524 526 }) 527 + 528 + const shouldExposeToGate2 = Math.random() < 0.2 529 + 530 + // --- Temporary: we're testing our Statsig setup --- 531 + let TestGates = React.memo(function TestGates() { 532 + const gate = useGate() 533 + 534 + useEffect(() => { 535 + logEvent('test:all:always', {}) 536 + if (Math.random() < 0.2) { 537 + logEvent('test:all:sometimes', {}) 538 + } 539 + if (Math.random() < 0.1) { 540 + logEvent('test:all:boosted_by_gate1', { 541 + reason: 'base', 542 + }) 543 + } 544 + if (Math.random() < 0.1) { 545 + logEvent('test:all:boosted_by_gate2', { 546 + reason: 'base', 547 + }) 548 + } 549 + if (Math.random() < 0.1) { 550 + logEvent('test:all:boosted_by_both', { 551 + reason: 'base', 552 + }) 553 + } 554 + }, []) 555 + 556 + return [ 557 + gate('test_gate_1') ? <TestGate1 /> : null, 558 + shouldExposeToGate2 && gate('test_gate_2') ? <TestGate2 /> : null, 559 + ] 560 + }) 561 + 562 + function TestGate1() { 563 + useEffect(() => { 564 + logEvent('test:gate1:always', {}) 565 + if (Math.random() < 0.2) { 566 + logEvent('test:gate1:sometimes', {}) 567 + } 568 + if (Math.random() < 0.5) { 569 + logEvent('test:all:boosted_by_gate1', { 570 + reason: 'gate1', 571 + }) 572 + } 573 + if (Math.random() < 0.5) { 574 + logEvent('test:all:boosted_by_both', { 575 + reason: 'gate1', 576 + }) 577 + } 578 + }, []) 579 + return null 580 + } 581 + 582 + function TestGate2() { 583 + useEffect(() => { 584 + logEvent('test:gate2:always', {}) 585 + if (Math.random() < 0.2) { 586 + logEvent('test:gate2:sometimes', {}) 587 + } 588 + if (Math.random() < 0.5) { 589 + logEvent('test:all:boosted_by_gate2', { 590 + reason: 'gate2', 591 + }) 592 + } 593 + if (Math.random() < 0.5) { 594 + logEvent('test:all:boosted_by_both', { 595 + reason: 'gate2', 596 + }) 597 + } 598 + }, []) 599 + return null 600 + }