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: statsig integration PoC #747

Merged

Conversation

yogurtandjam
Copy link
Contributor

@yogurtandjam yogurtandjam commented Jun 28, 2024

Blocked by dydxprotocol/v4-abacus#489. Will fail CI checks until that PR is merged in and abacus version is bumped

Merges into #739

Builds on @moo-onthelawn's PR by adding a concept of a non-hook based statsig gate request.

It's necessary to do this because we have some abacus initialization we do that requires us to fetch statsig configs within a useEffect hook in order for us to make sure we start up abacus only once (with the correct statsig configs).

Some specifics this PR does:

  • creates functions to pull in all statsig flags specified in the v4-web repo.
  • refactors the analytics to pull all statsig configs and once and throw them in. this way devs dont need to update .analytics manually every time they add a flag. this uses the previously mentioned functions
  • adds a statsig disable flag to allow tests that hit statsig paths to pass.
  • this pr also creates a types folder that will allow us to separate constant values from types. which will help us prevent cyclic dependencies

Copy link

vercel bot commented Jun 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
v4-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 1, 2024 9:00pm
v4-testnet ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 1, 2024 9:00pm

@yogurtandjam yogurtandjam force-pushed the jerms/462-setup-statsig branch from 543ed7f to 07c3061 Compare June 28, 2024 20:20
@yogurtandjam yogurtandjam changed the title [wip] test statsig via abacus usage feat: statsig integration PoC Jun 30, 2024
@yogurtandjam yogurtandjam changed the base branch from main to mulan/ote-462-abacus-set-up-statsig June 30, 2024 19:39
@yogurtandjam yogurtandjam changed the base branch from mulan/ote-462-abacus-set-up-statsig to main June 30, 2024 19:39
@yogurtandjam yogurtandjam changed the base branch from main to mulan/ote-462-abacus-set-up-statsig June 30, 2024 19:39
@yogurtandjam yogurtandjam force-pushed the jerms/462-setup-statsig branch from a059223 to 3062120 Compare June 30, 2024 19:42
@yogurtandjam yogurtandjam force-pushed the jerms/462-setup-statsig branch from 3062120 to 58d5217 Compare June 30, 2024 19:44
@yogurtandjam yogurtandjam force-pushed the jerms/462-setup-statsig branch from 58d5217 to d389f5d Compare June 30, 2024 19:49
test friendly

cleanup

remove top level await

use promises instead of top level await

fix

add temp hack to silence build error

awlways render, otherwise app breaks if no statsig client

lint

setup statsig depending on abacus

comments

abstract analytics identifying
, use new statsigconfig name
src/types/statsig.ts Show resolved Hide resolved
import { StatsigClient } from '@statsig/js-client';

const fetchIp = async () => {
const resp = await fetch('https://api.ipify.org?format=json');
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 move this into useEndpointsConfig? I think it's more secure to do this, also unsure if deployers want to use something diff here

Copy link
Contributor Author

@yogurtandjam yogurtandjam Jul 1, 2024

Choose a reason for hiding this comment

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

hmm we can... 🤔 but api.ipify.org is a public url so i don't think there's a security concern about exposing this

can update it if you feel strong tho, nw

Copy link
Contributor Author

@yogurtandjam yogurtandjam Jul 1, 2024

Choose a reason for hiding this comment

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

actually i like this idea a lot - deployers can stand up their own proxy servers this way which i think is totally worth doing if they feel like it - although not sure if we can use hooks in this lib since we're using it in a hook. investigatin 👀

Copy link
Contributor

Choose a reason for hiding this comment

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

chatted offline; deploying without ip. sounds like we're synced about using the config for the url when we do log ip tho 🫡

src/lib/statsig.ts Outdated Show resolved Hide resolved
return statsigClient;
};

export const statsigClientPromise = initStatsig();
Copy link
Contributor

Choose a reason for hiding this comment

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

unsure if we need this const; can we just export initStatsig() instead?

src/hooks/useStatsig.tsx Show resolved Hide resolved
src/lib/statsig.ts Outdated Show resolved Hide resolved
src/constants/abacus.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@moo-onthelawn moo-onthelawn left a comment

Choose a reason for hiding this comment

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

🚗

@yogurtandjam yogurtandjam merged commit ffa2f97 into mulan/ote-462-abacus-set-up-statsig Jul 1, 2024
6 checks passed
@yogurtandjam yogurtandjam deleted the jerms/462-setup-statsig branch July 1, 2024 21:05
yogurtandjam added a commit that referenced this pull request Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants