Files
supabase/apps/studio/lib/configcat.ts
T
Ivan Vasilov b77a1b48be feat: Use Vercel Toolbar for overriding feature flags (#29697)
* initial test.

* Add base path to the rewrites.

* Remove base path from the source rewrite.

* Another try.

* Another try.

* another try.

* Try another magic.

* Add try/catch to the flag processing code.

* Revert some of the unneeded changes.

* Fix the api route for flags.

* Remove vercel/toolbar for local dev.

* Try using a static file for toolbar config.

* Add a well known flags file in the www app.

* Add headers to interpret vercel/flags as json.

* Another try.

* Fix the json formatting.

* Add headers for the vercel/flags route in the www app.

* Change to force studio to deploy.
2024-10-08 11:21:03 +02:00

26 lines
531 B
TypeScript

import type { User } from '@supabase/supabase-js'
import * as configcat from 'configcat-js'
let client: configcat.IConfigCatClient
function getClient() {
if (client) {
return client
}
client = configcat.getClient(
process.env.NEXT_PUBLIC_CONFIGCAT_SDK_KEY ?? '',
configcat.PollingMode.AutoPoll,
{ pollIntervalSeconds: 600 }
)
return client
}
export async function getFlags(user?: User) {
if (user) {
return getClient().getAllValuesAsync(new configcat.User(user?.email ?? ''))
}
return []
}