-
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: client event snippet and docs
- Loading branch information
1 parent
576b75e
commit 106eb5e
Showing
3 changed files
with
51 additions
and
8 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
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
27 changes: 27 additions & 0 deletions
27
samples/react/src/samples/precomputed-client/sample-precomp-client-event.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,27 @@ | ||
/* eslint-disable no-console */ | ||
|
||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
// <snippet> | ||
import type { StatsigClientEventData } from '@statsig/client-core'; | ||
|
||
// </snippet> | ||
import { myStatsigClient } from './sample-precomp-instance'; | ||
|
||
// prettier-ignore | ||
export default async function Sample(): Promise<void> { | ||
// <snippet> | ||
const onClientEvent = (data: StatsigClientEventData) => { | ||
console.log("Statsig Logs", data); | ||
}; | ||
|
||
// subscribe to an individual StatsigClientEvent | ||
myStatsigClient.on('logs_flushed', onClientEvent); | ||
|
||
// or, subscribe to all StatsigClientEvents | ||
myStatsigClient.on('*', onClientEvent); | ||
|
||
// then later, unsubscribe from the events | ||
myStatsigClient.off('logs_flushed', onClientEvent); | ||
myStatsigClient.off('*', onClientEvent); | ||
// </snippet> | ||
} |