Skip to content

Commit 92eb61d

Browse files
authored
Merge pull request #4 from webmaxru/webmaxru-stunning-adventure
Add cookieless-insights skill for privacy-friendly RUM
2 parents 837261c + 3d84204 commit 92eb61d

4 files changed

Lines changed: 128 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Sample prompt — request instrumentation
2+
3+
Paste this to your AI coding agent (Copilot CLI, Claude Code, Cursor, …) from the root of the
4+
static site you want to instrument. Edit the **‹bracketed›** parts.
5+
6+
---
7+
8+
> Instrument this static site with **cookieless Azure Application Insights** using the
9+
> **`@webmaxru/cookieless-insights`** package — **no cookie/GDPR banner**, **Azure free tier only**.
10+
>
11+
> - If a resource group for this project already exists, reuse it; otherwise create one
12+
> (region ‹westeurope›). Provision workspace-based Application Insights with 30-day retention
13+
> and a 0.16 GB/day ingestion cap.
14+
> - Install the package and initialize it once at the app entry with the connection string from a
15+
> build-time env var. Wire a **page view** plus **all key interactions** (buttons, toggles,
16+
> presets, add/remove, and outbound links); **debounce** sliders/typing. Keep a one-line
17+
> **kill switch** (`enabled`).
18+
> - The connection string is a public client key: inject it at **build time** via a CI **variable**
19+
> (not a secret), and update the deploy workflow’s build step.
20+
> - Deploy the Azure Portal **engagement dashboard** and add the **report** command.
21+
> - Then build, run tests, commit, and **redeploy**. Keep everything in sync and show me the
22+
> engagement report once data arrives.
23+
>
24+
> Use the **beacon** transport by default. Validate every Azure/billing claim against official
25+
> Microsoft docs.
26+
27+
---
28+
29+
Prefer the agent to follow the full playbook? Install the skill first (see the repo README:
30+
**Use with an AI agent**), then simply ask: *“Instrument this static site with cookieless-insights.”*
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
name: cookieless-insights
3+
description: Instrument any static website (SPA) with cookieless Azure Application Insights Real User Monitoring — no cookie/GDPR banner, free tier only — using the @webmaxru/cookieless-insights package + CLI. Covers Azure setup, code wiring (incl. build step), a Portal dashboard, and a terminal engagement report. WHEN making a static site/SPA observable, "add analytics without a cookie banner", cookieless RUM, privacy-friendly analytics, Application Insights for a frontend/GitHub Pages/Static Web Apps/Netlify/S3, page views + engagement + geo + key events.
4+
version: 1.0.1
5+
author: webmaxru
6+
license: MIT
7+
---
8+
9+
# Instrument a static site with cookieless Azure Application Insights
10+
11+
> **Sample request prompt:** see [`PROMPT.md`](./PROMPT.md) for a ready-to-paste prompt. Once
12+
> this skill is installed, "Instrument this static site with cookieless-insights" is enough.
13+
14+
15+
Use the **`@webmaxru/cookieless-insights`** package + CLI to give any static front end
16+
privacy-friendly Real User Monitoring that needs **no cookie/GDPR banner** and stays on
17+
Azure's **free tier**. Work autonomously; state assumptions instead of asking.
18+
19+
## Why this approach (validated against Microsoft Learn)
20+
- A static site is **browser-only** — the Azure Monitor **OpenTelemetry Distro is
21+
server-side only** (ASP.NET Core/Java/Node.js/Python). Browser telemetry uses the
22+
**Application Insights JavaScript SDK** path (RUM). `@webmaxru/cookieless-insights`
23+
wraps this: a tiny dependency-free **beacon** by default (~1–2 KB gzipped) or an optional
24+
SDK adapter.
25+
- **Cookieless** = no cookies, no local/session storage, no persistent id → no consent
26+
banner. The beacon is cookieless by construction; the SDK adapter sets
27+
`disableCookiesUsage` + `enableSessionStorageBuffer:false`.
28+
- **Free tier** = workspace-based Application Insights, 30-day retention, and a **0.16 GB/day**
29+
ingestion cap (Microsoft's documented "160 MB/day stays under the 5 GB/month free grant").
30+
31+
## Steps
32+
33+
1. **Discover** the project: framework, build tool, hosting, deploy workflow, and the single
34+
**state/store choke point** (Zustand/Redux/Pinia/signals) or top-level event handlers to
35+
wire events into. Enumerate key events (page view, meaningful controls — debounce
36+
sliders/typing —, presets, add/remove, outbound clicks, "opened via shared link").
37+
38+
2. **Provision Azure** (reuse a project resource group if it exists, else create one):
39+
```
40+
npx cookieless-insights setup --name <project> --location <region> --run
41+
```
42+
Capture the printed **connection string** (a public client key).
43+
44+
3. **Install + wire** (framework-agnostic):
45+
```
46+
npm i @webmaxru/cookieless-insights
47+
```
48+
```ts
49+
import { init, trackEvent, trackChangeDebounced } from '@webmaxru/cookieless-insights';
50+
init({ connectionString: import.meta.env.VITE_APPINSIGHTS_CONNECTION_STRING });
51+
// wire trackEvent(...) at the store choke point + trackChangeDebounced for sliders/typing.
52+
```
53+
For the heavier official SDK instead of the beacon:
54+
`import { initAppInsights } from '@webmaxru/cookieless-insights/appinsights'` (install the
55+
`@microsoft/applicationinsights-web` peer dep).
56+
**Kill switch:** `init({ ..., enabled: false })` disables all telemetry.
57+
58+
4. **Build step / deploy:** the connection string is a **public client key** — provide it at
59+
build time. Locally via `.env` (`VITE_APPINSIGHTS_CONNECTION_STRING=...`); in CI as a repo
60+
**variable** passed to the build step (never a secret, never committed as source). Verify
61+
the build succeeds and the site initializes analytics.
62+
63+
5. **Dashboard + report:**
64+
```
65+
npx cookieless-insights dashboard --app-insights-id <appInsightsResourceId>
66+
npx cookieless-insights report --resource-group <rg> --app-insights <name> --days 30 --open
67+
```
68+
`report` prints engagement (page views, sessions, per-visit dwell, key events, top pages,
69+
geo, browser/OS) and `--open` launches the Portal dashboard. A `scripts/report.ps1`
70+
PowerShell equivalent is scaffolded by `cookieless-insights init`.
71+
72+
6. **Ship:** ensure build + tests pass, commit, and push to the deploy branch. After a real
73+
visit, `report` shows data within ~1–3 minutes.
74+
75+
## Definition of done
76+
- [ ] Cookieless (no cookies/storage, no persistent id) — no banner needed.
77+
- [ ] Free tier: workspace-based, 30-day retention, 0.16 GB/day cap.
78+
- [ ] Key events wired at the choke point; page view + engagement time collected.
79+
- [ ] Connection string injected at build time (repo variable in CI); kill switch documented.
80+
- [ ] Portal dashboard deployed; `report` prints real data and `--open` works.
81+
- [ ] Built, committed, pushed → deployed.

apm.lock.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,19 @@ dependencies:
8181
.agents/skills/agent-package-manager/references/manifest-and-lockfile.md: sha256:751ba3102a04626d96cdfd0400308704e344fc7d30f9817aefc1308e0be986c8
8282
.agents/skills/agent-package-manager/references/troubleshooting.md: sha256:f57abc15c6c6bca5cf6f3fee02690aa68f2859fa4c58e5c8241c4e33b35e8f5f
8383
content_hash: sha256:6338d1772fe1fedfca979da05d61c8e74d33b1dccde1ae13a66e0308eaa9b788
84+
- repo_url: webmaxru/cookieless-insights
85+
name: cookieless-insights
86+
host: github.com
87+
resolved_commit: 3f8fac1b5b7fbd73dca741bf1772826e2f5d631e
88+
version: unknown
89+
virtual_path: skills/cookieless-insights
90+
is_virtual: true
91+
package_type: claude_skill
92+
deployed_files:
93+
- .agents/skills/cookieless-insights
94+
- .agents/skills/cookieless-insights/PROMPT.md
95+
- .agents/skills/cookieless-insights/SKILL.md
96+
deployed_file_hashes:
97+
.agents/skills/cookieless-insights/PROMPT.md: sha256:fc632d29a3e0719dd0f9d66a26b85cc57a689f4defbe768daf975d0cbef34dc4
98+
.agents/skills/cookieless-insights/SKILL.md: sha256:7da717521ac9828241497b4e9de7d4318c7ea71abfb669965f624f929d93c8cb
99+
content_hash: sha256:9b71019f70cc67769711ded1e1367f8e787aebb34a5e09610dbcca4eb5499b85

apm.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ dependencies:
88
- anthropics/skills/skills/frontend-design
99
- webmaxru/ai-native-dev/prompts/seo-and-agent-readiness.prompt.md#main
1010
- rysweet/amplihack-rs/amplifier-bundle/skills/storytelling-synthesizer#b123c107c7ab2e3d436926747c135e78a90545b6
11+
- webmaxru/cookieless-insights/skills/cookieless-insights
1112
mcp: []
1213
includes: auto
1314
scripts: {}

0 commit comments

Comments
 (0)