Compare commits
17 commits
Author | SHA1 | Date | |
---|---|---|---|
8615595ad6 | |||
f621c33de9 | |||
787a1fd57f | |||
f52bec681c | |||
1f21177997 | |||
f8fd8d9567 | |||
|
b51f1f256a | ||
|
967997b2e0 | ||
f34a13327e | |||
91b53da7f0 | |||
804e8ea1d8 | |||
7b78980023 | |||
d6b11afd2d | |||
|
45a65edaae | ||
|
3b570b2044 | ||
|
ac81d120e2 | ||
07eb639f04 |
16 changed files with 15520 additions and 7318 deletions
115
README.md
115
README.md
|
@ -6,7 +6,7 @@
|
|||
[![Nuxt][nuxt-src]][nuxt-href]
|
||||
[![Wide Angle][wideangle-src]][wideangle-href]
|
||||
|
||||

|
||||

|
||||
|
||||
# Wide Angle Analytics module for Nuxt
|
||||
|
||||
|
@ -16,15 +16,17 @@ Enable **privacy-friendly** web analytics in your [Nuxt 3.x](https://nuxt.com/)
|
|||
|
||||
# How to get started
|
||||
|
||||
You can enable Wide Angle Analytics in your Nuxt projects in just few steps. No complex configuration needed as our sane defaults give you reliable and privacy centric deployment out of the box.
|
||||
You can enable Wide Angle Analytics in your Nuxt projects in just a few steps. No complex configuration needed, as our sane defaults provide you with a reliable and privacy-centric deployment out of the box.
|
||||
|
||||
1. Go to [Wide Angle](https://wideangle.co) website, create an account. You can create free 14-day trail. No Credit Card is required. [Learn more.](https://wideangle.co/documentation/create-account)
|
||||
2. [Create new Site](https://wideangle.co/documentation/create-and-configure-site) and activate it.
|
||||
3. Install `wideangle-vuejs` plugin in your Vue application.
|
||||
1. Go to the [Wide Angle](https://wideangle.co) website and create an account. You can enjoy a free 14-day trail. No Credit Card is required. [Learn more.](https://wideangle.co/documentation/create-account)
|
||||
2. [Create a new site](https://wideangle.co/documentation/create-and-configure-site) and activate it.
|
||||
3. Install the `wideangle-vuejs` plugin in your Vue application.
|
||||
|
||||
```npm install wideangle-nuxt```
|
||||
```bash
|
||||
npx nuxi@latest module add wideangle
|
||||
```
|
||||
|
||||
4. Enable and configure module.
|
||||
4. Enable and configure the module.
|
||||
|
||||
```javascript
|
||||
export default defineNuxtConfig({
|
||||
|
@ -42,20 +44,21 @@ export default defineNuxtConfig({
|
|||
|
||||
# Configuring Wide Angle Analytics plugin
|
||||
|
||||
The Wide Angle Analytics plugin must be initialized with configuration object as there are required settings without defaults.
|
||||
The Wide Angle Analytics plugin must be initialized with a configuration object as there are required settings without defaults.
|
||||
|
||||
|
||||
option|description|required|default|example
|
||||
------|-----------|--------|-------|-------
|
||||
siteId| The Site ID from Wide Angle Site settings| :white_check_mark: | _none_ | 8D27G3B9ACA01F4241
|
||||
siteId| The Site ID from the Wide Angle Site settings| :white_check_mark: | _none_ | 8D27G3B9ACA01F4241
|
||||
domain| Domain hosting the script, can be found in Wide Angle Analytics Site settings | :x: | stats.wideangle.co | your.domain.com
|
||||
fingerprint | Should script use browser fingerprinting; this might require collecting consent depeing on the applicable laws | :x: | false | true
|
||||
supressDnt | Should script ingore Do Not Track browser setting. If not enabled, not events will be sent if user's browser has DNT enabled | :x: | false | true
|
||||
fingerprint | Should script use browser fingerprinting; this might require collecting consent depending on the applicable laws | :x: | false | true
|
||||
suppressDnt | Should script ingore Do Not Track browser setting. If not enabled, no events will be sent if user's browser has DNT enabled | :x: | false | true
|
||||
includeParams | An array of query parameters that can be passed as part of tracking event. By default only `utm_*` and `ref` parameters are passed in the event | :x: | `[]` | `['sessionId', 'offset']`
|
||||
excludePaths | An array of URL paths that should not trigger default events such as page view, page leave | :x: | `[]` | `['^/wp-admin/.*', ]`
|
||||
ignoreHash | If enabled, change in the URL fragment will not trigger page view event | :x: | false | true
|
||||
ignoreHash | If enabled, a change in the URL fragment will not trigger page view event | :x: | false | true
|
||||
consentMarker | Name of cookie (with or without) which presence is treated as implied consent; when not defined, consent is not determined by cookie | :x: | n/a | `WAA_CONSENT=true`
|
||||
|
||||
You will find more details about these settings in [Wide Angle Analytics documentation](https://wideangle.co/documentation/configure-site).
|
||||
You can find more details about these settings in the [Wide Angle Analytics documentation](https://wideangle.co/documentation/configure-site).
|
||||
|
||||
|
||||
Example:
|
||||
|
@ -70,10 +73,11 @@ export default defineNuxtConfig({
|
|||
siteId: "8D27G3B9ACA01F4241",
|
||||
domain: "your.domain.com",
|
||||
fingerprint: false,
|
||||
supressDnt: true,
|
||||
suppressDnt: true,
|
||||
includeParams: ['q', 'customerId'],
|
||||
excludePaths: ['^/admin.*'],
|
||||
ignoreHash: true
|
||||
ignoreHash: true,
|
||||
consentMarker: `WAA_CONSENT=true`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,12 +87,21 @@ export default defineNuxtConfig({
|
|||
|
||||
# Usage
|
||||
|
||||
The Wide Angle Analytics provides an instance of `waa` which can be then injected to your component.
|
||||
The Wide Angle Analytics provides a composable which can be used in your component.
|
||||
|
||||
```javascript
|
||||
import { useWideAngle } from '#imports'
|
||||
<template>
|
||||
<button @click="sendEvent">Send Event</button>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { useWideAngle } from '#imports';
|
||||
|
||||
const sendEvent = () => {
|
||||
useWideAngle().dispatchEvent('basket-open', {'page': 'catalogue'}, {'item-price': 599.00, 'basket-total': 1299.00});
|
||||
}
|
||||
</script>
|
||||
|
||||
useWideAngle('purchase', {'basket_value': '45.00'})
|
||||
```
|
||||
|
||||
You will find a fully functional example in this [repository](playground/app.vue).
|
||||
|
@ -105,7 +118,7 @@ Wide Angle supports three specialized events:
|
|||
* downloads
|
||||
* custom actions
|
||||
|
||||
Site has to have these event enable in Wide Angle Analytics configuration prior to usage. Otherwise the tracker script will not sent these events. Consult [official documentation](https://wideangle.co/documentation/tracking-custom-actions) regarding how to enable event handling.
|
||||
Site has to have these events enabled in the Wide Angle Analytics configuration prior to usage. Otherwise the tracker script will not send these events. Consult the [official documentation](https://wideangle.co/documentation/tracking-custom-actions) regarding how to enable event handling.
|
||||
|
||||
### Tracking Clicks
|
||||
|
||||
|
@ -119,7 +132,7 @@ Depending on the configured mode, the **Download Event** will fire automatically
|
|||
|
||||
### Tracking Custom Actions
|
||||
|
||||
Custom action are the most flexible and can be triggered directly from Vue components. As such their usage is not limitted due to Shadow DOM.
|
||||
Custom actions are the most flexible and can be triggered directly from Vue components. As such, their usage is not limitted due to the Shadow DOM.
|
||||
|
||||
Example:
|
||||
|
||||
|
@ -129,20 +142,74 @@ Example:
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { useWaaEvent } from '#imports'
|
||||
import { useWideAngle } from '#imports'
|
||||
|
||||
const sendEvent = async () => {
|
||||
const params = {
|
||||
session: 'cjhw92nf9aq',
|
||||
cohort: 'c1233'
|
||||
}
|
||||
useWaaEvent('interest', params);
|
||||
}
|
||||
useWideAngle().dispatchEvent('interest', params);
|
||||
}
|
||||
</script>
|
||||
```
|
||||
|
||||
### Module Assets
|
||||
You can find high-resolution Wide Angle Analytics logo and icon on our [media page](https://wideangle.co/media).
|
||||
You can find a high-resolution Wide Angle Analytics logo and icon on our [media page](https://wideangle.co/media).
|
||||
|
||||
# Recording consent
|
||||
|
||||
The Wide Angle Analytics, thanks to is privacy-first, anonymous approach to web traffic analytics does not requires consent by default.
|
||||
|
||||
However, we do offer multiple tools that support collecting consent should it be required in your use case.
|
||||
|
||||
## Opt-Out by default
|
||||
|
||||
If the visitors browsers has `DoNotTrack` setting enabled in the browser, it will be understood as opt-out and not tracking events will be issued.
|
||||
|
||||
You website can't overwrite this behaviour by specifying `suppressDnt` setting.
|
||||
|
||||
```javascript
|
||||
wideangle: {
|
||||
siteId: "8D27G3B9ACA01F4241",
|
||||
suppressDnt: true
|
||||
}
|
||||
```
|
||||
|
||||
## Opt-In or Opt-Out based on Cookie
|
||||
|
||||
Wide Angle can be configure to handle presence of a cookie, or a cookie with specific value, as an implicit consent. Lack of the cookie will be handled as implicit opt-out.
|
||||
|
||||
Example configuration with cookie marker, expecting cookie name `WAA_CONSENT` with value `true`:
|
||||
|
||||
```javascript
|
||||
wideangle: {
|
||||
siteId: "8D27G3B9ACA01F4241",
|
||||
consentMarker: "WAA_CONSENT=true"
|
||||
}
|
||||
```
|
||||
|
||||
## Programmatic consent
|
||||
|
||||
The Wide Angle serving offers two additional methods, which allow for recording tracking consent:
|
||||
|
||||
- `recordConsent(subjectId: String): void`, and
|
||||
- `revokeConsent()`
|
||||
|
||||
|
||||
Calling above methods on `waa` service will overwrite other consent mechanism (ie. DoNotTrack, and cookie marker).
|
||||
|
||||
Example usage:
|
||||
|
||||
```vue
|
||||
<script setup>
|
||||
|
||||
import { useWideAngle } from '#imports'
|
||||
|
||||
useWideAngle().recordConsent('FHJ44111');
|
||||
|
||||
</script>
|
||||
```
|
||||
|
||||
<!-- Badges -->
|
||||
|
||||
|
|
BIN
assets/full_logo_color_light_transparent.png
Executable file
BIN
assets/full_logo_color_light_transparent.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 173 KiB |
20
eslint.config.mjs
Normal file
20
eslint.config.mjs
Normal file
|
@ -0,0 +1,20 @@
|
|||
// @ts-check
|
||||
import { createConfigForNuxt } from '@nuxt/eslint-config/flat'
|
||||
|
||||
// Run `npx @eslint/config-inspector` to inspect the resolved config interactively
|
||||
export default createConfigForNuxt({
|
||||
features: {
|
||||
// Rules for module authors
|
||||
tooling: true,
|
||||
// Rules for formatting
|
||||
stylistic: true,
|
||||
},
|
||||
dirs: {
|
||||
src: [
|
||||
'./playground',
|
||||
],
|
||||
},
|
||||
})
|
||||
.append(
|
||||
// your custom flat config here...
|
||||
)
|
22447
package-lock.json
generated
22447
package-lock.json
generated
File diff suppressed because it is too large
Load diff
45
package.json
45
package.json
|
@ -1,8 +1,12 @@
|
|||
{
|
||||
"name": "wideangle-nuxt",
|
||||
"version": "1.0.2",
|
||||
"version": "2.0.0",
|
||||
"description": "Wide Angle Analytics module for Nuxt",
|
||||
"repository": "inputobjects/wideangle-nuxt",
|
||||
"homepage": "https://wideangle.co",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://cloud.inputobjects.eu/forge/wideangle/wideangle-nuxt.git"
|
||||
},
|
||||
"author": "Wide Angle Analytics <developers@wideangle.co>",
|
||||
"license": "Apache-2.0",
|
||||
"type": "module",
|
||||
|
@ -13,7 +17,9 @@
|
|||
"vuejs",
|
||||
"plugin",
|
||||
"vuejs plugin",
|
||||
"nuxt module"
|
||||
"nuxt module",
|
||||
"privacy",
|
||||
"privacy web analytics"
|
||||
],
|
||||
"exports": {
|
||||
".": {
|
||||
|
@ -28,28 +34,29 @@
|
|||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"prepack": "nuxt-module-build",
|
||||
"prepack": "nuxt-module-build build",
|
||||
"dev": "nuxi dev playground",
|
||||
"dev:build": "nuxi build playground",
|
||||
"dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
|
||||
"release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
|
||||
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
||||
"release": "npm run prepack && changelogen --release && npm publish",
|
||||
"lint": "eslint .",
|
||||
"test": "vitest run",
|
||||
"test:watch": "vitest watch"
|
||||
"lint:fix": "eslint . --fix"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nuxt/kit": "^3.4.3",
|
||||
"wideangle-vuejs": "1.0.0"
|
||||
"@nuxt/kit": "^3.15.3",
|
||||
"wideangle-vuejs": "2.0.0",
|
||||
"defu": "^6.1.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxt/eslint-config": "^0.1.1",
|
||||
"@nuxt/module-builder": "^0.3.0",
|
||||
"@nuxt/schema": "^3.4.3",
|
||||
"@nuxt/test-utils": "^3.4.3",
|
||||
"@types/node": "^18",
|
||||
"changelogen": "^0.5.3",
|
||||
"eslint": "^8.39.0",
|
||||
"nuxt": "^3.4.3",
|
||||
"vitest": "^0.30.1"
|
||||
"@nuxt/devtools": "latest",
|
||||
"@nuxt/eslint-config": "^0.7.5",
|
||||
"@nuxt/module-builder": "^0.8.4",
|
||||
"@nuxt/schema": "^3.15.3",
|
||||
"@types/node": "latest",
|
||||
"changelogen": "^0.5.7",
|
||||
"eslint": "^9.19.0",
|
||||
"nuxt": "^3.13.2",
|
||||
"typescript": "~5.7.2",
|
||||
"vue-tsc": "^2.2.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
<template>
|
||||
<main>
|
||||
<h1>Nuxt Application</h1>
|
||||
<button @click="trackClick">
|
||||
Track Click
|
||||
</button>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useWaaEvent } from "#imports";
|
||||
|
||||
function trackClick() {
|
||||
useWaaEvent("foo", {"name": "bar"});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
main {
|
||||
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
|
||||
font-size: 2rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-width: 300px;
|
||||
gap: 2rem;
|
||||
align-items: center;
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
button {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
</style>
|
11
playground/components/sample-tracker.vue
Normal file
11
playground/components/sample-tracker.vue
Normal file
|
@ -0,0 +1,11 @@
|
|||
<template>
|
||||
<button @click="sendEvent">Send Event</button>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { useWideAngle } from '#imports';
|
||||
|
||||
const sendEvent = () => {
|
||||
useWideAngle().dispatchEvent('foo', {'param1': 'bar'}, {'value1': 123});
|
||||
}
|
||||
</script>
|
|
@ -1,13 +1,17 @@
|
|||
// https://nuxt.com/docs/api/configuration/nuxt-config
|
||||
export default defineNuxtConfig({
|
||||
modules: ['../src/module'],
|
||||
devtools: { enabled: true },
|
||||
compatibilityDate: "2025-01-28",
|
||||
modules: ['wideangle-nuxt'],
|
||||
// ssr: false,
|
||||
runtimeConfig: {
|
||||
public: {
|
||||
wideangle: {
|
||||
siteId: "8D27G3B9ACA01F4241",
|
||||
domain: "wideangle.local:3000",
|
||||
fingerprint: true,
|
||||
supressDnt: true
|
||||
domain: "events.wideangle.test",
|
||||
fingerprint: false,
|
||||
suppressDnt: true
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"private": true,
|
||||
"name": "wideangle-playground"
|
||||
}
|
7
playground/pages/index.vue
Normal file
7
playground/pages/index.vue
Normal file
|
@ -0,0 +1,7 @@
|
|||
<template>
|
||||
<div>
|
||||
<h1>Wide Angle Analytics Playground</h1>
|
||||
<sample-tracker/>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
import { defineNuxtModule, addPlugin, addImports, createResolver, useLogger } from '@nuxt/kit'
|
||||
import { defineNuxtModule, addPlugin, addImportsDir, createResolver, useLogger } from '@nuxt/kit'
|
||||
import { defu } from 'defu'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
const logger = useLogger('nuxt:wideangle')
|
||||
|
||||
|
@ -8,10 +7,11 @@ export interface ModuleOptions {
|
|||
siteId?: string
|
||||
domain: string
|
||||
fingerprint: boolean
|
||||
supressDnt: boolean
|
||||
suppressDnt: boolean
|
||||
includeParams: string[]
|
||||
excludePaths: string[]
|
||||
ignoreHash: boolean
|
||||
consentMarker?: string
|
||||
}
|
||||
|
||||
export default defineNuxtModule<ModuleOptions>({
|
||||
|
@ -19,39 +19,29 @@ export default defineNuxtModule<ModuleOptions>({
|
|||
name: 'wideangle',
|
||||
configKey: 'wideangle',
|
||||
compatibility: {
|
||||
nuxt: '^3'
|
||||
}
|
||||
nuxt: '>=3',
|
||||
},
|
||||
},
|
||||
defaults: {
|
||||
domain: "stats.wideangle.co",
|
||||
domain: 'stats.wideangle.co',
|
||||
fingerprint: false,
|
||||
supressDnt: false,
|
||||
suppressDnt: false,
|
||||
includeParams: [],
|
||||
excludePaths: [],
|
||||
ignoreHash: false
|
||||
ignoreHash: false,
|
||||
consentMarker: undefined,
|
||||
},
|
||||
setup (options, nuxt) {
|
||||
const runtimeDir = fileURLToPath(new URL('./runtime', import.meta.url))
|
||||
setup(options, nuxt) {
|
||||
const resolver = createResolver(import.meta.url)
|
||||
nuxt.options.build.transpile.push(resolver.resolve('./runtime'))
|
||||
|
||||
nuxt.options.runtimeConfig.public.wideangle = defu(
|
||||
nuxt.options.runtimeConfig.public.wideangle,
|
||||
options,
|
||||
)
|
||||
nuxt.options.runtimeConfig.public.wideangle ||= {},
|
||||
{ ...options })
|
||||
logger.info('Adding Wide Angle Analytics (useWideAngle) import')
|
||||
addImportsDir(resolver.resolve('./runtime/composables'))
|
||||
|
||||
nuxt.options.build.transpile.push(runtimeDir);
|
||||
const resolver = createResolver(import.meta.url);
|
||||
|
||||
logger.info('Adding Wide Angle Analytics runtime plugin');
|
||||
|
||||
addImports({
|
||||
name: "useWaaEvent",
|
||||
as: "useWaaEvent",
|
||||
from: resolver.resolve('./runtime/composables/useWaaEvent')
|
||||
});
|
||||
|
||||
addPlugin({
|
||||
src: resolver.resolve('./runtime/plugin.client')
|
||||
});
|
||||
|
||||
}
|
||||
logger.info('Adding Wide Angle Analytics runtime plugin')
|
||||
addPlugin(resolver.resolve('./runtime/plugin.client'))
|
||||
},
|
||||
})
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
import { useNuxtApp } from '#imports';
|
||||
|
||||
export function useWaaEvent (name: string, params?: Record<string, any>) {
|
||||
const waa = useNuxtApp().$waa
|
||||
if(waa && waa.value) {
|
||||
waa.value.dispatchEvent(name, params);
|
||||
} else {
|
||||
console.debug("[WAA] Wide Angle Analytics is not yest initialized");
|
||||
}
|
||||
}
|
27
src/runtime/composables/useWideAngle.ts
Normal file
27
src/runtime/composables/useWideAngle.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import {useNuxtApp} from '#imports'
|
||||
import type {WideAngleApi} from "~/src/types";
|
||||
|
||||
class NoOpWideAngleAnalyticsApi implements WideAngleApi {
|
||||
dispatchEvent(name: string, params: any, values: any): void {
|
||||
console.debug(`[WideAngleApi#dispatchEvent] Defaulting to NoOp Wide Angle call with name "${name}", params: ${JSON.stringify(params)}, values: ${JSON.stringify(params)}`);
|
||||
}
|
||||
|
||||
recordConsent(subjectsId: string): void {
|
||||
console.debug(`[WideAngleApi#recordConsent] Defaulting to NoOp Wide Angle call with ${subjectsId}`);
|
||||
}
|
||||
|
||||
revokeConsent() {
|
||||
console.debug(`[WideAngleApi#revokeConsent] Defaulting to NoOp Wide Angle call`);
|
||||
}
|
||||
}
|
||||
|
||||
const noOpWideAngleApi = new NoOpWideAngleAnalyticsApi();
|
||||
|
||||
export function useWideAngle() {
|
||||
const { $waa } = useNuxtApp()
|
||||
if ($waa) {
|
||||
return $waa.value;
|
||||
} else {
|
||||
return noOpWideAngleApi;
|
||||
}
|
||||
}
|
|
@ -1,30 +1,36 @@
|
|||
import { defineNuxtPlugin, useRuntimeConfig } from '#imports';
|
||||
import { ref } from 'vue';
|
||||
import { initWideAngle } from 'wideangle-vuejs';
|
||||
import { type Ref, ref} from 'vue'
|
||||
import { initWideAngle } from 'wideangle-vuejs'
|
||||
import { defineNuxtPlugin, type NuxtApp } from '#app'
|
||||
import { useRuntimeConfig } from "#imports";
|
||||
import type { WideAngleApi } from "~/src/types";
|
||||
|
||||
export default defineNuxtPlugin(() => {
|
||||
if(process.server) {
|
||||
console.warn("[WAA] Plugin will not be enabled on server side.");
|
||||
return;
|
||||
export default defineNuxtPlugin(async (_nuxtApp) => {
|
||||
|
||||
if (import.meta.server) {
|
||||
console.warn('[WAA] Plugin will not be enabled on server side.')
|
||||
return
|
||||
}
|
||||
|
||||
const { wideangle: options } = useRuntimeConfig().public
|
||||
console.debug(`[WAA] Initializing Wide Angle Analytics with: ${JSON.stringify(options)}`);
|
||||
if(options.siteId == null) {
|
||||
throw new Error("[WAA] Wide Angle Analytics requires the site ID.");
|
||||
console.debug(`[WAA] Initializing Wide Angle Analytics with: ${JSON.stringify(options)}`)
|
||||
|
||||
if (options.siteId == null) {
|
||||
throw new Error('[WAA] Wide Angle Analytics requires the site ID.')
|
||||
}
|
||||
|
||||
const waa = ref()
|
||||
|
||||
initWideAngle(options)
|
||||
.then(waaInstance => {
|
||||
waa.value = waaInstance;
|
||||
console.debug("[WAA] Wide Angle Analytics instance available");
|
||||
}).catch(e => { console.error("[WAA] Failed to load Wide Angle Plugin", e)});
|
||||
.then((waaInstance) => {
|
||||
waa.value = waaInstance
|
||||
console.debug('[WAA] Wide Angle Analytics instance available')
|
||||
}).catch((e) => {
|
||||
console.error('[WAA] Failed to load Wide Angle Plugin', e)
|
||||
})
|
||||
|
||||
return {
|
||||
provide: {
|
||||
waa
|
||||
}
|
||||
waa: waa as Ref<WideAngleApi>,
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
|
5
src/types.ts
Normal file
5
src/types.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
export interface WideAngleApi {
|
||||
dispatchEvent(name: string, params: any, values: any) : void;
|
||||
recordConsent(subjectsId: string) : void;
|
||||
revokeConsent() : void;
|
||||
}
|
|
@ -1,3 +1,8 @@
|
|||
{
|
||||
"extends": "./playground/.nuxt/tsconfig.json"
|
||||
"extends": "./.nuxt/tsconfig.json",
|
||||
"exclude": [
|
||||
"dist",
|
||||
"node_modules",
|
||||
"playground",
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue