@grainql/analytics-web/react. Every block uses Analytics Web. For GrainQL Tag in React, with
heatmaps and no provider, read React.
The provider
Wrap the app inGrainProvider one time, at the root. Pass config and the provider creates
the client. defaultConfigurations holds the value of each configuration key until the first
fetch completes. Every value is a string.
enableAutoPageView). Read
GrainProvider.
Track an event
useTrack returns a stable function. It does not change between renders, so it is safe in
an effect dependency list and as a prop.
A feature flag
useConfig returns the cached value at once and refreshes in the background. The value is a
string, so compare it with 'true'.
An A/B variant
Read the variant withuseConfig, show the content for that variant, and put the variant in
every event of the test. A filter on the variant property then separates the two groups.
Identify on login
useGrainAnalytics returns the client. Call identify when a user logs in and logout when
the user logs out. logout returns the client to an anonymous ID.
useAuth is your own hook. Read Identify users and
User properties.
The complete app
GrainProvider sits outside AuthProvider, so AuthSync can read both contexts. React Router
navigates through the History API, so each route change is a page view.