Skip to content

Commit

Permalink
chore: add stable id override snippets (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-statsig authored Sep 18, 2024
1 parent 612e304 commit d8ec2cb
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
4 changes: 2 additions & 2 deletions samples/react/src/SamplesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ export default function SamplesPage(): ReactNode {

{filteredSnippets.length > 0 && (
<pre>
<code className="language-javascript">
{filteredSnippets[snippetIndex].content}
<code className="language-typescript">
{filteredSnippets[snippetIndex]?.content}
</code>
</pre>
)}
Expand Down
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));
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>

0 comments on commit d8ec2cb

Please sign in to comment.