Skip to content

Commit a83fb35

Browse files
committedAug 6, 2024
fix: ensure plugin types are exposed (fixes #31)
1 parent 42e160a commit a83fb35

9 files changed

+800
-320
lines changed
 

‎.nuxtrc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
imports.autoImport=false
2+
typescript.includeWorkspace=true

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"defu": "^6.1.4"
4747
},
4848
"devDependencies": {
49-
"@nuxt/eslint-config": "0.3.0-beta.9",
49+
"@nuxt/eslint-config": "^0.5.0",
5050
"@nuxt/module-builder": "^0.8.1",
5151
"@nuxt/schema": "^3.12.4",
5252
"@types/node": "^20.14.14",

‎playground/app.vue

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script setup lang="ts">
2+
import { navigateTo, useRuntimeConfig, useTrackEvent, useTrackPageview } from '#imports'
3+
24
const { plausible } = useRuntimeConfig().public
35
46
function trackEvent() {

‎pnpm-lock.yaml

+785-310
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/runtime/composables/useTrackEvent.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { useNuxtApp } from '#imports'
21
import type {
32
EventName,
43
EventOptions,
54
Plausible,
65
} from '@barbapapazes/plausible-tracker'
6+
import { useNuxtApp } from '#imports'
77

88
/**
99
* Tracks a custom event
@@ -20,7 +20,6 @@ import type {
2020
*/
2121
export function useTrackEvent(eventName: EventName, options?: EventOptions) {
2222
if (import.meta.client) {
23-
// eslint-disable-next-line no-extra-semi
2423
;(useNuxtApp().$plausible as Plausible)?.trackEvent(eventName, options)
2524
}
2625
}

‎src/runtime/composables/useTrackPageview.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { useNuxtApp } from '#imports'
21
import type { EventOptions, Plausible } from '@barbapapazes/plausible-tracker'
2+
import { useNuxtApp } from '#imports'
33

44
/**
55
* Manually track a page view
@@ -12,7 +12,6 @@ import type { EventOptions, Plausible } from '@barbapapazes/plausible-tracker'
1212
*/
1313
export function useTrackPageview(options?: EventOptions) {
1414
if (import.meta.client) {
15-
// eslint-disable-next-line no-extra-semi
1615
;(useNuxtApp().$plausible as Plausible)?.trackPageview(options)
1716
}
1817
}

‎src/runtime/plugin-auto-outbound-tracking.client.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { defineNuxtPlugin, useNuxtApp, useRuntimeConfig } from '#imports'
1+
import { defineNuxtPlugin } from 'nuxt/app'
22
import type { Plausible } from '@barbapapazes/plausible-tracker'
3-
import type { ModuleOptions } from '../module'
43
import { useAutoOutboundTracking } from '@barbapapazes/plausible-tracker/extensions/auto-outbound-tracking'
4+
import type { ModuleOptions } from '../module'
5+
import { useNuxtApp, useRuntimeConfig } from '#imports'
56

67
export default defineNuxtPlugin({
78
name: 'plausible:auto-outbound-tracking',

‎src/runtime/plugin-auto-pageviews.client.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { defineNuxtPlugin, useNuxtApp, useRuntimeConfig } from '#imports'
1+
import { defineNuxtPlugin } from 'nuxt/app'
22
import type { Plausible } from '@barbapapazes/plausible-tracker'
3-
import type { ModuleOptions } from '../module'
43
import { useAutoPageviews } from '@barbapapazes/plausible-tracker/extensions/auto-pageviews'
4+
import type { ModuleOptions } from '../module'
5+
import { useNuxtApp, useRuntimeConfig } from '#imports'
56

67
export default defineNuxtPlugin({
78
name: 'plausible:auto-pageviews',

‎src/runtime/plugin.client.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { defineNuxtPlugin, useRuntimeConfig } from '#imports'
1+
import { defineNuxtPlugin } from 'nuxt/app'
22
import { createPlausibleTracker } from '@barbapapazes/plausible-tracker'
33
import type { ModuleOptions } from '../module'
4+
import { useRuntimeConfig } from '#imports'
45

56
export default defineNuxtPlugin({
67
name: 'plausible',

0 commit comments

Comments
 (0)
Please sign in to comment.