Skip to content

Commit

Permalink
feat: add growthbook
Browse files Browse the repository at this point in the history
  • Loading branch information
qin-guan committed Oct 22, 2023
1 parent bede144 commit a69318e
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion components/app/services/page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async function click() {
</f7NavTitleLarge>
</f7Navbar>

<f7List strong inset>
<f7List v-if="$growthbook.isOn('sstaars')" strong inset>
<f7ListItem class="font-semibold">
SSTAA Registration System (SSTAARS)
</f7ListItem>
Expand Down
6 changes: 6 additions & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,11 @@ export default defineNuxtConfig({
firebase: {
projectId: 'sstaa-app' || process.env.FIREBASE_PROJECT_ID,
},

public: {
growthbook: {
clientKey: '' || process.env.GROWTHBOOK_CLIENT_KEY,
},
},
},
})
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"devDependencies": {
"@antfu/eslint-config": "latest",
"@cloudflare/workers-types": "^4.20230914.0",
"@growthbook/growthbook": "^0.29.0",
"@libsql/client": "^0.3.4",
"@nuxt/devtools": "latest",
"@nuxt/ui": "^2.8.1",
Expand Down
20 changes: 20 additions & 0 deletions plugins/growthbook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { GrowthBook } from '@growthbook/growthbook'

export default defineNuxtPlugin(async () => {
const config = useRuntimeConfig()

const growthbook = new GrowthBook({
apiHost: 'https://cdn.growthbook.io',
clientKey: config.public.growthbook.clientKey,
enableDevMode: true,
subscribeToChanges: true,
})

await growthbook.loadFeatures()

return {
provide: {
growthbook,
},
}
})
15 changes: 15 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a69318e

Please # to comment.