Skip to content

feat(skills): add int-clarity — Microsoft Clarity Data Export integration#104

Open
mt-alarcon wants to merge 1 commit into
evolution-foundation:mainfrom
mt-alarcon:feat/int-clarity-skill
Open

feat(skills): add int-clarity — Microsoft Clarity Data Export integration#104
mt-alarcon wants to merge 1 commit into
evolution-foundation:mainfrom
mt-alarcon:feat/int-clarity-skill

Conversation

@mt-alarcon

Copy link
Copy Markdown

What

Adds int-clarity, an integration skill for the Microsoft Clarity Data Export API (web analytics / UX friction). Clarity is free and complements GA4/Tag Manager with signals they don't expose: rage/dead/quickback clicks, scroll depth, script errors — and cross-references them with traffic dimensions.

Commands

  • live-insights --project <p> [--days 1|2|3] [--dim1 X --dim2 Y --dim3 Z] [--json] — query the project-live-insights endpoint; prints a readable table or raw JSON.
  • list-projects — list configured projects (names only, never token values).
  • smoke [--project <p>] — standard exit-0 + JSON health-check ({overall, steps[], duration_ms}).
  • --all — sweep every configured project (mind the per-project daily quota).

Configuration

Token is per-project, read from env — never hardcoded, never printed:

  • CLARITY_API_TOKEN — single project, or
  • CLARITY_TOKEN_<PROJECT> — multiple projects (selected via --project).
  • CLARITY_API_BASE — optional override (default https://www.clarity.ms/export-data/api/v1).

Design notes

  • Single-file urllib client following the existing int-stripe pattern (no external deps).
  • HTTP helper always returns dict (passes make lint-http-types).
  • Input validation before calling the API to save quota: numOfDays ∈ {1,2,3}; dimension allowlist (Browser, Device, Country, OS, Source, Medium, Campaign, Channel, URL); max 3 dimensions.
  • Documented API limits: 10 requests/day/project, 1–3 day window (no history), 1000 rows, no pagination, UTC.
  • Robust error handling for 400/401/403/429 (the 429 body may be non-JSON — handled before parsing).
  • Token redaction on every error path — the JWT can never surface in stdout/stderr/exceptions.

Tests

35 unittest cases (no pytest), including adversarial token-leak tests that fail if redaction is removed.

Use cases

  • Campaign attribution via Source/Medium/Campaign dimensions.
  • UX friction per URL (rage/dead/quickback clicks).
  • Bot vs human traffic (totalBotSessionCount alongside totalSessionCount).

…tion

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @mt-alarcon, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant