@vskstudio/takt-astro 0.3.1 → 0.4.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/Embed.astro CHANGED
@@ -13,4 +13,4 @@ type Props = {
13
13
 
14
14
  const { domain, theme, lang, host, width = 404, height = 264, title = 'takt', ...rest } = Astro.props
15
15
  ---
16
- <iframe title={title} referrerpolicy="strict-origin-when-cross-origin" {...rest} width={width} height={height} loading="lazy" style="border:0" src={embedUrl(domain, { theme, lang, host })}></iframe>
16
+ <iframe title={title} {...rest} width={width} height={height} loading="lazy" style="border:0" src={embedUrl(domain, { theme, lang, host })} referrerpolicy="strict-origin-when-cross-origin" sandbox="allow-scripts allow-same-origin"></iframe>
package/README.md CHANGED
@@ -45,6 +45,7 @@ Both the integration and the component accept the same options:
45
45
  | --- | --- | --- | --- |
46
46
  | `domain` | `string` | `location.hostname` | Site identifier sent with every event. |
47
47
  | `endpoint` | `string` | `/api/event` | Ingestion endpoint. |
48
+ | `scriptOrigin` | `string` | – | First-party origin to derive the endpoint from (`{origin}/api/event`) — your Takt domain or a custom domain to dodge ad-blockers (endpoint wins over it). |
48
49
  | `outbound` | `boolean` | `false` | Auto-track outbound link clicks. |
49
50
  | `files` | `boolean` | `false` | Auto-track file downloads. |
50
51
  | `spa` | `boolean` | `true` | Track client-side navigations. |
@@ -78,7 +79,7 @@ import Embed from '@vskstudio/takt-astro/Embed.astro'
78
79
  <Embed domain="example.com" theme="dark" />
79
80
  ```
80
81
 
81
- `Badge` renders an `<img>` (props: `domain`, `variant`, `glyph`, `lang`, `host`); `Embed` renders an `<iframe>` (props: `domain`, `theme`, `lang`, `host`, `width`, `height`, `title`). Extra attributes pass through to the underlying element, but the built `src` is locked and cannot be overridden. The optional `host` must be an absolute `http(s)` URL — core validates it and throws on anything else (e.g. a `javascript:` URL).
82
+ `Badge` renders an `<img>` (props: `domain`, `variant`, `glyph`, `lang`, `host`). Its `alt` defaults to `"takt"` and can be overridden. `Embed` renders an `<iframe>` (props: `domain`, `theme`, `lang`, `host`, `width`, `height`, `title`); the iframe is sandboxed (`allow-scripts allow-same-origin`) and ships a fixed `referrerpolicy="strict-origin-when-cross-origin"` — both are locked and cannot be weakened by a consumer. Extra attributes pass through to the underlying element, but the built `src` is locked and cannot be overridden. The optional `host` must be an absolute `http(s)` URL — core validates it and throws on anything else (e.g. a `javascript:` URL), and reduces it to its origin (dropping path/query). An empty `host` resolves same-origin.
82
83
 
83
84
  ## Public stats
84
85
 
package/dist/index.d.ts CHANGED
@@ -11,6 +11,11 @@ interface TaktOptions {
11
11
  domain?: string;
12
12
  /** Ingestion endpoint. Defaults to `/api/event`. */
13
13
  endpoint?: string;
14
+ /**
15
+ * First-party origin to derive the endpoint from (`{origin}/api/event`) — your
16
+ * Takt domain or a custom domain to dodge ad-blockers. `endpoint` wins over it.
17
+ */
18
+ scriptOrigin?: string;
14
19
  /** Auto-track outbound link clicks. */
15
20
  outbound?: boolean;
16
21
  /** Auto-track file downloads. */
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ function resolveOptions(options = {}) {
3
3
  return {
4
4
  domain: options.domain,
5
5
  endpoint: options.endpoint,
6
+ scriptOrigin: options.scriptOrigin,
6
7
  outbound: options.outbound ?? false,
7
8
  files: options.files ?? false,
8
9
  respectDnt: options.respectDnt ?? true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vskstudio/takt-astro",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Astro integration for Takt privacy-friendly analytics",
5
5
  "license": "MIT",
6
6
  "author": "VSK Studio",
@@ -45,15 +45,25 @@
45
45
  "engines": {
46
46
  "node": ">=18"
47
47
  },
48
+ "scripts": {
49
+ "build": "tsup",
50
+ "typecheck": "tsc --noEmit",
51
+ "lint": "eslint .",
52
+ "test": "vitest run",
53
+ "e2e": "playwright test",
54
+ "size": "size-limit",
55
+ "prepublishOnly": "pnpm build",
56
+ "release": "pnpm build && changeset publish"
57
+ },
48
58
  "peerDependencies": {
49
- "@vskstudio/takt-core": ">=0.3.0",
59
+ "@vskstudio/takt-core": ">=0.4.0",
50
60
  "astro": ">=4"
51
61
  },
52
62
  "devDependencies": {
53
63
  "@changesets/cli": "^2.31.0",
54
64
  "@playwright/test": "^1.50.0",
55
65
  "@size-limit/preset-small-lib": "^11.1.6",
56
- "@vskstudio/takt-core": "^0.3.0",
66
+ "@vskstudio/takt-core": "^0.4.0",
57
67
  "astro": "^5.0.0",
58
68
  "eslint": "^9.0.0",
59
69
  "size-limit": "^11.1.6",
@@ -62,13 +72,5 @@
62
72
  "typescript-eslint": "^8.0.0",
63
73
  "vitest": "^2.1.0"
64
74
  },
65
- "scripts": {
66
- "build": "tsup",
67
- "typecheck": "tsc --noEmit",
68
- "lint": "eslint .",
69
- "test": "vitest run",
70
- "e2e": "playwright test",
71
- "size": "size-limit",
72
- "release": "pnpm build && changeset publish"
73
- }
74
- }
75
+ "packageManager": "pnpm@9.0.0"
76
+ }