diff --git a/plugins/4.analytics.client.ts b/plugins/4.analytics.client.ts index d9eec235..c3f990f9 100644 --- a/plugins/4.analytics.client.ts +++ b/plugins/4.analytics.client.ts @@ -1,12 +1,18 @@ import { useMembershipStatus } from '~~/composables/states' +type WindowWithDataLayer = Window & { + dataLayer: Record[] +} + +declare const window: WindowWithDataLayer +declare const dataLayer: Record[] + export default defineNuxtPlugin(() => { const config = useRuntimeConfig() const membershipStatus = useMembershipStatus() const { $experiments } = useNuxtApp() - window.dataLayer = window.dataLayer || [] - const dataLayer = (window as any).dataLayer + // init gtag function function gtag(...args) { dataLayer.push(args) diff --git a/plugins/5.htlbid.ts b/plugins/5.htlbid.ts index 2e682cc3..50f30218 100644 --- a/plugins/5.htlbid.ts +++ b/plugins/5.htlbid.ts @@ -1,3 +1,18 @@ +interface htlbidType { + cmd: (() => void)[] + layout: (string) => void + setTargeting: (keys: string, targetingParams: string[]) => void + clearTargeting: (string) => void + forceRefresh: () => void +} + +type WindowWithHtlbid = Window & { + htlbid: htlbidType +} + +declare const window: WindowWithHtlbid +declare const htlbid: htlbidType + export default defineNuxtPlugin(() => { const config = useRuntimeConfig() useHead({ @@ -13,7 +28,6 @@ export default defineNuxtPlugin(() => { }) if (!process.server) { window.htlbid = window.htlbid || {} - const htlbid = (window as any).htlbid htlbid.cmd = htlbid.cmd || [] const init = () => {