-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add stable id override snippets (#320)
- Loading branch information
1 parent
612e304
commit d8ec2cb
Showing
3 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
samples/react/src/samples/precomputed-client/sample-precomp-stable-id-overrride.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* eslint-disable no-console */ | ||
// <snippet> | ||
import { StatsigClient, StatsigUser } from '@statsig/js-client'; | ||
|
||
// </snippet> | ||
import { STATSIG_CLIENT_KEY as YOUR_CLIENT_KEY } from '../../Contants'; | ||
|
||
// <snippet> | ||
const user: StatsigUser = { | ||
customIDs: { | ||
stableID: 'my-custom-stable-id', // <- Your Stable ID (Must have key "stableID") | ||
}, | ||
}; | ||
|
||
// Pass in your user object with a stableID | ||
const myStatsigClient = new StatsigClient(YOUR_CLIENT_KEY, user); | ||
// </snippet> | ||
|
||
myStatsigClient.initializeAsync().catch((err) => console.error(err)); |
30 changes: 30 additions & 0 deletions
30
samples/react/src/samples/react-precomp/sample-react-stable-id-override.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* eslint-disable no-console */ | ||
|
||
/* eslint-disable @typescript-eslint/no-inferrable-types */ | ||
// <snippet> | ||
import { StatsigProvider } from '@statsig/react-bindings'; | ||
|
||
// </snippet> | ||
import { STATSIG_CLIENT_KEY as YOUR_CLIENT_KEY } from '../../Contants'; | ||
|
||
// prettier-ignore | ||
export default async function Sample(): Promise<void> { | ||
console.log(App); | ||
} | ||
|
||
// <snippet> | ||
function App() { | ||
return ( | ||
<StatsigProvider | ||
sdkKey={YOUR_CLIENT_KEY} | ||
user={{ | ||
customIDs: { | ||
stableID: 'my-custom-stable-id', // <- Your Stable ID (Must have key "stableID") | ||
}, | ||
}} | ||
> | ||
<div>Hello World</div> | ||
</StatsigProvider> | ||
); | ||
} | ||
// </snippet> |