@deltabreen/analytics-vue 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DeltaBreen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,34 @@
1
- # Temporary Holding Version
1
+ # @deltabreen/analytics-vue
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Analytics by DeltaBreen for Vue 3 and Nuxt. It loads the same per-site script as the `<script>` tag, so pageviews
4
+ (route changes included), heatmaps, errors, Web Vitals, experiments, recordings and surveys all work the same. On a
5
+ server it does nothing.
6
+
7
+ ```bash
8
+ npm install @deltabreen/analytics-vue
9
+ ```
10
+
11
+ ```js
12
+ // main.ts
13
+ import { createApp } from 'vue';
14
+ import { createAnalytics } from '@deltabreen/analytics-vue';
15
+
16
+ createApp(App).use(createAnalytics({ siteKey: 'ans_YOUR_KEY' })).mount('#app');
17
+ ```
18
+
19
+ ```js
20
+ // <script setup>
21
+ import { useVariant, useFlag, track } from '@deltabreen/analytics-vue';
22
+ const variant = useVariant('hero-copy'); // a read-only ref: 'b', or null for the original
23
+ const beta = useFlag('beta'); // the key may be a ref or a getter
24
+ ```
25
+
26
+ Nuxt: `plugins/analytics.client.ts` with
27
+ `export default defineNuxtPlugin((nuxt) => { nuxt.vueApp.use(createAnalytics({ siteKey: 'ans_YOUR_KEY' })) })`.
28
+
29
+ `createAnalytics` takes `origin: '/stats'` to load and send through your own domain (see the proxy docs) and
30
+ `consent: 'tcf'` to follow a consent banner on the IAB's framework. `track`, `identify`, `consent`, `variant`, `flag`
31
+ and `ready` come with it, from `@deltabreen/analytics`. Both composables start at the original and change once the
32
+ component is mounted and the tracker has loaded, so a server render and hydration agree.
33
+
34
+ Docs: https://analytics.deltabreen.eu/docs/install
package/index.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import type { MaybeRefOrGetter, Plugin, Ref } from 'vue';
2
+ import type { InitOptions } from '@deltabreen/analytics';
3
+ export * from '@deltabreen/analytics';
4
+ /** A plugin that loads the tracker as the app starts: app.use(createAnalytics({ siteKey })). */
5
+ export function createAnalytics(options: InitOptions): Plugin;
6
+ /** The variant this person sees, or null for the original until mounted and the tracker has loaded. */
7
+ export function useVariant(key: MaybeRefOrGetter<string>): Readonly<Ref<string | null>>;
8
+ /** Whether a feature flag is on for this person, false until mounted and the tracker has loaded. */
9
+ export function useFlag(key: MaybeRefOrGetter<string>): Readonly<Ref<boolean>>;
package/index.js ADDED
@@ -0,0 +1,40 @@
1
+ // Vue helpers: app.use(createAnalytics({ siteKey: 'ans_…' })) once, and composables for variants and flags. Both start
2
+ // at the original (null / false) and update once mounted and once the tracker has loaded, so a server render and
3
+ // hydration agree. Navigations between pages are counted by the tracker itself.
4
+ import { getCurrentInstance, getCurrentScope, onMounted, onScopeDispose, readonly, ref, toValue, watch } from 'vue';
5
+ import { flag, init, ready, variant } from '@deltabreen/analytics';
6
+
7
+ export * from '@deltabreen/analytics';
8
+
9
+ /** A plugin that loads the tracker as the app starts (nothing on a server). */
10
+ export function createAnalytics(options) {
11
+ return {
12
+ install() {
13
+ init(options);
14
+ },
15
+ };
16
+ }
17
+
18
+ function useTracker(read, initial, key) {
19
+ const value = ref(initial);
20
+ let live = true;
21
+ let started = false;
22
+ const update = () => {
23
+ if (live) value.value = read(toValue(key));
24
+ };
25
+ const start = () => {
26
+ started = true;
27
+ update();
28
+ ready().then(update);
29
+ };
30
+ if (getCurrentInstance()) onMounted(start);
31
+ else start();
32
+ watch(() => toValue(key), () => {
33
+ if (started) update();
34
+ });
35
+ if (getCurrentScope()) onScopeDispose(() => (live = false));
36
+ return readonly(value);
37
+ }
38
+
39
+ export const useVariant = (key) => useTracker(variant, null, key);
40
+ export const useFlag = (key) => useTracker(flag, false, key);
package/package.json CHANGED
@@ -1,6 +1,44 @@
1
1
  {
2
2
  "name": "@deltabreen/analytics-vue",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Analytics by DeltaBreen for Vue and Nuxt: a plugin and composables for experiment variants and feature flags.",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./index.d.ts",
9
+ "default": "./index.js"
10
+ },
11
+ "./package.json": "./package.json"
12
+ },
13
+ "files": [
14
+ "index.js",
15
+ "index.d.ts",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
19
+ "sideEffects": false,
20
+ "dependencies": {
21
+ "@deltabreen/analytics": "^0.2.0"
22
+ },
23
+ "peerDependencies": {
24
+ "vue": ">=3.3"
25
+ },
26
+ "engines": {
27
+ "node": ">=18"
28
+ },
29
+ "license": "MIT",
30
+ "scripts": {
31
+ "test": "node --test test/*.test.mjs"
32
+ },
33
+ "keywords": [
34
+ "analytics",
35
+ "cookieless",
36
+ "heatmaps",
37
+ "ab-testing",
38
+ "feature-flags",
39
+ "deltabreen",
40
+ "vue",
41
+ "nuxt"
42
+ ],
43
+ "homepage": "https://analytics.deltabreen.eu/docs/install"
44
+ }