@vskstudio/takt-astro 0.2.1 → 0.3.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/Badge.astro +14 -0
- package/Embed.astro +16 -0
- package/README.md +26 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -0
- package/package.json +8 -4
package/Badge.astro
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { badgeUrl, type BadgeVariant, type BadgeGlyph, type WidgetLang } from '@vskstudio/takt-core'
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
domain: string
|
|
6
|
+
variant?: BadgeVariant
|
|
7
|
+
glyph?: BadgeGlyph
|
|
8
|
+
lang?: WidgetLang
|
|
9
|
+
host?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const { domain, variant, glyph, lang, host, ...rest } = Astro.props
|
|
13
|
+
---
|
|
14
|
+
<img src={badgeUrl(domain, { variant, glyph, lang, host })} alt="takt" loading="lazy" decoding="async" {...rest} />
|
package/Embed.astro
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { embedUrl, type EmbedTheme, type WidgetLang } from '@vskstudio/takt-core'
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
domain: string
|
|
6
|
+
theme?: EmbedTheme
|
|
7
|
+
lang?: WidgetLang
|
|
8
|
+
host?: string
|
|
9
|
+
width?: number | string
|
|
10
|
+
height?: number | string
|
|
11
|
+
title?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const { domain, theme, lang, host, width = 404, height = 264, title = 'takt', ...rest } = Astro.props
|
|
15
|
+
---
|
|
16
|
+
<iframe src={embedUrl(domain, { theme, lang, host })} title={title} width={width} height={height} loading="lazy" style="border:0" {...rest}></iframe>
|
package/README.md
CHANGED
|
@@ -65,6 +65,32 @@ import { track } from '@vskstudio/takt-astro'
|
|
|
65
65
|
track('Signup', { revenue: { amount: '9.00', currency: 'USD' } })
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
+
## Widgets
|
|
69
|
+
|
|
70
|
+
Thin wrappers around Takt's server-rendered badge SVG and embed iframe.
|
|
71
|
+
|
|
72
|
+
```astro
|
|
73
|
+
---
|
|
74
|
+
import Badge from '@vskstudio/takt-astro/Badge.astro'
|
|
75
|
+
import Embed from '@vskstudio/takt-astro/Embed.astro'
|
|
76
|
+
---
|
|
77
|
+
<Badge domain="example.com" variant="d" />
|
|
78
|
+
<Embed domain="example.com" theme="dark" />
|
|
79
|
+
```
|
|
80
|
+
|
|
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.
|
|
82
|
+
|
|
83
|
+
## Public stats
|
|
84
|
+
|
|
85
|
+
`createStats` (re-exported from core) reads public analytics:
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
import { createStats } from '@vskstudio/takt-astro'
|
|
89
|
+
|
|
90
|
+
const stats = createStats({ domain: 'example.com' })
|
|
91
|
+
const summary = await stats.summary({ period: '7d' })
|
|
92
|
+
```
|
|
93
|
+
|
|
68
94
|
## License
|
|
69
95
|
|
|
70
96
|
MIT
|
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 { InitOptions, TrackOptions, 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, 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
|
package/dist/index.js
CHANGED
|
@@ -50,9 +50,14 @@ function takt(options = {}) {
|
|
|
50
50
|
|
|
51
51
|
// src/index.ts
|
|
52
52
|
import { track, pageview, optOut, optIn } from "@vskstudio/takt-core";
|
|
53
|
+
import { createStats, PublicApiError, badgeUrl, embedUrl } from "@vskstudio/takt-core";
|
|
53
54
|
export {
|
|
55
|
+
PublicApiError,
|
|
56
|
+
badgeUrl,
|
|
54
57
|
buildRuntime,
|
|
58
|
+
createStats,
|
|
55
59
|
takt as default,
|
|
60
|
+
embedUrl,
|
|
56
61
|
optIn,
|
|
57
62
|
optOut,
|
|
58
63
|
pageview,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vskstudio/takt-astro",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Astro integration for Takt privacy-friendly analytics",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "VSK Studio",
|
|
@@ -32,24 +32,28 @@
|
|
|
32
32
|
"default": "./dist/index.js"
|
|
33
33
|
},
|
|
34
34
|
"./Takt.astro": "./Takt.astro",
|
|
35
|
+
"./Badge.astro": "./Badge.astro",
|
|
36
|
+
"./Embed.astro": "./Embed.astro",
|
|
35
37
|
"./package.json": "./package.json"
|
|
36
38
|
},
|
|
37
39
|
"files": [
|
|
38
40
|
"dist",
|
|
39
|
-
"Takt.astro"
|
|
41
|
+
"Takt.astro",
|
|
42
|
+
"Badge.astro",
|
|
43
|
+
"Embed.astro"
|
|
40
44
|
],
|
|
41
45
|
"engines": {
|
|
42
46
|
"node": ">=18"
|
|
43
47
|
},
|
|
44
48
|
"peerDependencies": {
|
|
45
|
-
"@vskstudio/takt-core": ">=0.
|
|
49
|
+
"@vskstudio/takt-core": ">=0.3.0",
|
|
46
50
|
"astro": ">=4"
|
|
47
51
|
},
|
|
48
52
|
"devDependencies": {
|
|
49
53
|
"@changesets/cli": "^2.31.0",
|
|
50
54
|
"@playwright/test": "^1.50.0",
|
|
51
55
|
"@size-limit/preset-small-lib": "^11.1.6",
|
|
52
|
-
"@vskstudio/takt-core": "^0.
|
|
56
|
+
"@vskstudio/takt-core": "^0.3.0",
|
|
53
57
|
"astro": "^5.0.0",
|
|
54
58
|
"eslint": "^9.0.0",
|
|
55
59
|
"size-limit": "^11.1.6",
|