Skip to content

Commit

Permalink
fix: pass module options to Nuxt runtime public config
Browse files Browse the repository at this point in the history
  • Loading branch information
mitjans committed Mar 21, 2024
1 parent feeda4d commit 433e013
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 18 deletions.
21 changes: 3 additions & 18 deletions playground/app.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
<template>
<PostHogFeatureFlag v-slot="{ payload }" name="test" match="variant">
<div>This content is under a feature flag</div>
<div
v-posthog-capture="{
name: 'event',
properties: {
color: 'red',
},
}"
>
This is the feature flag payload: {{ payload }}
</div>
</PostHogFeatureFlag>
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
</template>

<script setup lang="ts">
const runtimeConfig = useRuntimeConfig();
runtimeConfig.public.posthogApiKey;
</script>
8 changes: 8 additions & 0 deletions playground/layouts/default.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<template>
<div>
<NuxtLink to="/">/index</NuxtLink>
<NuxtLink to="/about">/about</NuxtLink>

<slot />
</div>
</template>
3 changes: 3 additions & 0 deletions playground/pages/about.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<div>About</div>
</template>
20 changes: 20 additions & 0 deletions playground/pages/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<template>
<PostHogFeatureFlag v-slot="{ payload }" name="ab" match="var2">
<div>This content is under a feature flag</div>
<div
v-posthog-capture="{
name: 'event',
properties: {
color: 'red',
},
}"
>
This is the feature flag payload: {{ payload }}
</div>
</PostHogFeatureFlag>
</template>

<script setup lang="ts">
const runtimeConfig = useRuntimeConfig();
runtimeConfig.public.posthogApiKey;
</script>
2 changes: 2 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ export default defineNuxtModule<ModuleOptions>({
{
publicKey: options.publicKey,
host: options.host,
capturePageViews: options.capturePageViews,
clientOptions: options.clientOptions,
},
);

Expand Down

0 comments on commit 433e013

Please sign in to comment.