@vskstudio/takt-astro 0.6.2 → 0.7.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/README.md +25 -4
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ Astro integration for [Takt](https://github.com/vskstudio/takt-core), privacy-fr
|
|
|
11
11
|
pnpm add @vskstudio/takt-astro @vskstudio/takt-core
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
Both are peer dependencies: `astro` (`>=4`) and `@vskstudio/takt-core` (`>=0.
|
|
14
|
+
Both are peer dependencies: `astro` (`>=4`) and `@vskstudio/takt-core` (`>=0.9.0`).
|
|
15
15
|
|
|
16
16
|
## Usage
|
|
17
17
|
|
|
@@ -62,8 +62,9 @@ Both the integration and the component accept the same options, with one excepti
|
|
|
62
62
|
| `trackQuery` | `boolean` | `false` | Keep the full query string and hash instead of stripping them. Wins over `queryParams`. |
|
|
63
63
|
| `queryParams` | `string[]` | – | Allowlist of query params to keep, applied only when `trackQuery` is off. |
|
|
64
64
|
| `exclude` | `string[]` | – | Path prefixes never tracked, e.g. `['/app', '/account']` (segment-bounded, checked at send time). |
|
|
65
|
-
| `scrubUrl` | `(url: string) => string` | – | **Integration only.** Rewrite each URL before it is sent (e.g. strip a fragment or PII
|
|
65
|
+
| `scrubUrl` | `(url: string) => string` | – | **Integration only.** Rewrite each URL before it is sent (page, referrer, and the `url` prop of outbound-link and file-download events), e.g. to strip a fragment or PII. See the note below. |
|
|
66
66
|
| `tagged` | `boolean` | `false` | Auto-track clicks on `[data-takt-event]` elements; `data-takt-prop-*` attributes become event props. |
|
|
67
|
+
| `debug` | `boolean` | `false` | Log each payload to the browser console before sending. |
|
|
67
68
|
|
|
68
69
|
> **`scrubUrl` note.** Unlike the other options, `scrubUrl` is a **function**, so it
|
|
69
70
|
> is supported **only via the integration**, not the `<Takt />` component. The
|
|
@@ -82,7 +83,7 @@ Astro's client router runs several history operations per navigation (scroll-res
|
|
|
82
83
|
|
|
83
84
|
## Custom events
|
|
84
85
|
|
|
85
|
-
`track`, `pageview`, `optOut` and `
|
|
86
|
+
`track`, `pageview`, `optOut`, `optIn` and `isOptedOut` are re-exported from core for convenience. `track` and `pageview` act on core's default instance, which only exists in the browser once the injected runtime has booted, so call them from a client-side `<script>`, not from `.astro` frontmatter (where they are silent no-ops):
|
|
86
87
|
|
|
87
88
|
```astro
|
|
88
89
|
<button id="signup">Sign up</button>
|
|
@@ -94,6 +95,26 @@ Astro's client router runs several history operations per navigation (scroll-res
|
|
|
94
95
|
</script>
|
|
95
96
|
```
|
|
96
97
|
|
|
98
|
+
## Consent
|
|
99
|
+
|
|
100
|
+
`optOut`, `optIn` and `isOptedOut` do not wait for the runtime to boot: they read and write the stored choice directly. A consent banner can therefore run before the injected runtime, and the instance it boots later honours the choice. Call them from a client-side `<script>`, since the choice lives in the browser.
|
|
101
|
+
|
|
102
|
+
```astro
|
|
103
|
+
<button id="analytics-toggle"></button>
|
|
104
|
+
<script>
|
|
105
|
+
import { isOptedOut, optIn, optOut } from '@vskstudio/takt-astro'
|
|
106
|
+
const button = document.getElementById('analytics-toggle')
|
|
107
|
+
const render = () => {
|
|
108
|
+
if (button) button.textContent = isOptedOut() ? 'Enable analytics' : 'Disable analytics'
|
|
109
|
+
}
|
|
110
|
+
button?.addEventListener('click', () => {
|
|
111
|
+
isOptedOut() ? optIn() : optOut()
|
|
112
|
+
render()
|
|
113
|
+
})
|
|
114
|
+
render()
|
|
115
|
+
</script>
|
|
116
|
+
```
|
|
117
|
+
|
|
97
118
|
## Widgets
|
|
98
119
|
|
|
99
120
|
Thin wrappers around Takt's server-rendered badge SVG and embed iframe.
|
|
@@ -137,7 +158,7 @@ From `@vskstudio/takt-astro`:
|
|
|
137
158
|
|
|
138
159
|
- `default` / `takt` — the integration factory (same function under both names)
|
|
139
160
|
- `resolveOptions`, `assertNoScrubUrl`, `buildRuntime` — the internals the `.astro` components build on, exported so you can drive the runtime yourself
|
|
140
|
-
- Re-exported from core: `track`, `pageview`, `optOut`, `optIn`, `createStats`, `PublicApiError`, `badgeUrl`, `embedUrl`
|
|
161
|
+
- Re-exported from core: `track`, `pageview`, `optOut`, `optIn`, `isOptedOut`, `createStats`, `PublicApiError`, `badgeUrl`, `embedUrl`
|
|
141
162
|
- Types: `TaktOptions`, plus `InitOptions`, `TrackOptions`, `BadgeOptions`, `EmbedOptions`, `BadgeVariant`, `BadgeGlyph`, `EmbedTheme`, `WidgetLang`, `StatsClient`, `StatsClientOptions`, `StatsParams`, `StatsPeriod`, `StatsDimension`, `StatsMetrics`, `StatsSummary`, `StatsPoint`, `StatsTimeseries`, `StatsBreakdownRow`, `StatsBreakdown`, `StatsRealtime` re-exported from core
|
|
142
163
|
|
|
143
164
|
Component subpaths: `@vskstudio/takt-astro/Takt.astro`, `/Badge.astro`, `/Embed.astro`.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AstroIntegration } from 'astro';
|
|
2
2
|
import { InitOptions } from '@vskstudio/takt-core';
|
|
3
|
-
export { BadgeGlyph, BadgeOptions, BadgeVariant, EmbedOptions, EmbedTheme, InitOptions, PublicApiError, StatsBreakdown, StatsBreakdownRow, StatsClient, StatsClientOptions, StatsDimension, StatsMetrics, StatsParams, StatsPeriod, StatsPoint, StatsRealtime, StatsSummary, StatsTimeseries, TrackOptions, WidgetLang, badgeUrl, createStats, embedUrl, optIn, optOut, pageview, track } from '@vskstudio/takt-core';
|
|
3
|
+
export { BadgeGlyph, BadgeOptions, BadgeVariant, EmbedOptions, EmbedTheme, InitOptions, PublicApiError, StatsBreakdown, StatsBreakdownRow, StatsClient, StatsClientOptions, StatsDimension, StatsMetrics, StatsParams, StatsPeriod, StatsPoint, StatsRealtime, StatsSummary, StatsTimeseries, TrackOptions, WidgetLang, badgeUrl, createStats, embedUrl, isOptedOut, optIn, optOut, pageview, track } from '@vskstudio/takt-core';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Options for the Takt integration and `<Takt />` component. Mirrors core's
|
|
@@ -54,6 +54,7 @@ interface TaktOptions {
|
|
|
54
54
|
scrubUrl?: (url: string) => string;
|
|
55
55
|
/** Auto-track elements marked with `data-takt-event`. */
|
|
56
56
|
tagged?: boolean;
|
|
57
|
+
debug?: boolean;
|
|
57
58
|
}
|
|
58
59
|
/**
|
|
59
60
|
* Guard the `<Takt />` component path against `scrubUrl`. The component
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,8 @@ function resolveOptions(options = {}) {
|
|
|
22
22
|
trackQuery: options.trackQuery,
|
|
23
23
|
queryParams: options.queryParams,
|
|
24
24
|
exclude: options.exclude,
|
|
25
|
-
tagged: options.tagged
|
|
25
|
+
tagged: options.tagged,
|
|
26
|
+
debug: options.debug
|
|
26
27
|
};
|
|
27
28
|
}
|
|
28
29
|
|
|
@@ -65,7 +66,7 @@ function takt(options = {}) {
|
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
// src/index.ts
|
|
68
|
-
import { track, pageview, optOut, optIn } from "@vskstudio/takt-core";
|
|
69
|
+
import { track, pageview, optOut, optIn, isOptedOut } from "@vskstudio/takt-core";
|
|
69
70
|
import { createStats, PublicApiError, badgeUrl, embedUrl } from "@vskstudio/takt-core";
|
|
70
71
|
export {
|
|
71
72
|
PublicApiError,
|
|
@@ -75,6 +76,7 @@ export {
|
|
|
75
76
|
createStats,
|
|
76
77
|
takt as default,
|
|
77
78
|
embedUrl,
|
|
79
|
+
isOptedOut,
|
|
78
80
|
optIn,
|
|
79
81
|
optOut,
|
|
80
82
|
pageview,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vskstudio/takt-astro",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Astro integration for Takt privacy-friendly analytics",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "VSK Studio",
|
|
@@ -56,14 +56,14 @@
|
|
|
56
56
|
"release": "pnpm build && changeset publish"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@vskstudio/takt-core": ">=0.
|
|
59
|
+
"@vskstudio/takt-core": ">=0.9.0",
|
|
60
60
|
"astro": ">=4"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@changesets/cli": "^2.31.0",
|
|
64
64
|
"@playwright/test": "^1.50.0",
|
|
65
65
|
"@size-limit/preset-small-lib": "^11.1.6",
|
|
66
|
-
"@vskstudio/takt-core": "^0.
|
|
66
|
+
"@vskstudio/takt-core": "^0.9.0",
|
|
67
67
|
"astro": "^5.0.0",
|
|
68
68
|
"eslint": "^9.0.0",
|
|
69
69
|
"size-limit": "^11.1.6",
|