Fix caching, fix attributes setting
This commit is contained in:
@@ -16,7 +16,7 @@ setPolyfills({
|
||||
return value != null ? JSON.parse(value) : null
|
||||
},
|
||||
setItem: async (key, value) => {
|
||||
CACHE.set(key, JSON.stringify(value))
|
||||
CACHE.set(key, value)
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -180,6 +180,13 @@ export function AnalyticsFeaturesContext({
|
||||
}) {
|
||||
const parentContext = useContext(Context)
|
||||
|
||||
/**
|
||||
* Side-effect: we need to synchronously set this during the
|
||||
* same render cycle. It does not trigger a re-render, it just
|
||||
* sets properties on the singleton GrowthBook instance.
|
||||
*/
|
||||
setAttributes(parentContext.metadata)
|
||||
|
||||
useEffect(() => {
|
||||
feats.setTrackingCallback((experiment, result) => {
|
||||
parentContext.metric('experiment:viewed', {
|
||||
@@ -189,10 +196,6 @@ export function AnalyticsFeaturesContext({
|
||||
})
|
||||
}, [parentContext.metric])
|
||||
|
||||
useEffect(() => {
|
||||
setAttributes(parentContext.metadata)
|
||||
}, [parentContext.metadata])
|
||||
|
||||
const childContext = useMemo<AnalyticsContextType>(() => {
|
||||
return {
|
||||
...parentContext,
|
||||
|
||||
@@ -4,5 +4,8 @@ import {useAnalytics} from '#/analytics'
|
||||
|
||||
export function useIsBskyTeam() {
|
||||
const ax = useAnalytics()
|
||||
return useMemo(() => ax.features.enabled(ax.features.IsBskyTeam), [ax])
|
||||
return useMemo(
|
||||
() => ax.features.enabled(ax.features.IsBskyTeam),
|
||||
[ax.features],
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user