-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1603 from appwrite/nav-experiment
Nav experiment
- Loading branch information
Showing
14 changed files
with
225 additions
and
84 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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 @@ | ||
import { PUBLIC_POSTHOG_API_KEY } from '$env/static/public'; | ||
import { PostHog } from 'posthog-node'; | ||
|
||
export const posthogServerClient = new PostHog(PUBLIC_POSTHOG_API_KEY, { | ||
host: 'https://eu.i.posthog.com', | ||
persistence: 'memory' | ||
}); | ||
|
||
export const experiments = { | ||
'sticky-navigation_ab-test': ['control', 'sticky-nav'] | ||
} as const; | ||
|
||
type Key = keyof typeof experiments; | ||
|
||
export const isFlagEqualTo = <K extends Key>( | ||
variant: (typeof experiments)[K][number], | ||
currentVariant?: string | boolean | ||
) => { | ||
return currentVariant === variant; | ||
}; | ||
|
||
export const getFeatureFlag = async <K extends Key>( | ||
key: Key, | ||
variant: (typeof experiments)[K][number], | ||
distinctId: string | ||
) => { | ||
const flagData = await posthogServerClient.getFeatureFlag(key, distinctId); | ||
|
||
return isFlagEqualTo(variant, flagData); | ||
}; |
Oops, something went wrong.