feat: add basic webui
This commit is contained in:
20
packages/feature-flags/lib/create-flag.ts
Normal file
20
packages/feature-flags/lib/create-flag.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { analytics } from '@konobangu/analytics/server';
|
||||
import { getSessionFromHeaders } from '@konobangu/auth/server';
|
||||
import { unstable_flag as flag } from '@vercel/flags/next';
|
||||
|
||||
export const createFlag = (key: string) =>
|
||||
flag({
|
||||
key,
|
||||
defaultValue: false,
|
||||
async decide() {
|
||||
const { userId } = await getSessionFromHeaders();
|
||||
|
||||
if (!userId) {
|
||||
return this.defaultValue as boolean;
|
||||
}
|
||||
|
||||
const isEnabled = await analytics.isFeatureEnabled(key, userId);
|
||||
|
||||
return isEnabled ?? (this.defaultValue as boolean);
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user