From bff8bb37ee6526801be147f35c882e9c4307a018 Mon Sep 17 00:00:00 2001 From: pkbullock <8781041+pkbullock@users.noreply.github.com> Date: Sun, 15 Nov 2026 08:19:00 +0000 Subject: [PATCH 1/2] Initial plan From ef6aecd06c30927cd0428062fed5055ad7318f07 Mon Sep 17 00:00:00 2001 From: pkbullock <8781041+pkbullock@users.noreply.github.com> Date: Sun, 15 Nov 2026 08:21:25 +0000 Subject: [PATCH 2/2] Add Microsoft Clarity tracking to site pages Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- site/src/layouts/Layout.astro | 12 ++++++++++++ site/tests/gallery.spec.ts | 12 +++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/site/src/layouts/Layout.astro b/site/src/layouts/Layout.astro index 5c776a007..21602bca0 100644 --- a/site/src/layouts/Layout.astro +++ b/site/src/layouts/Layout.astro @@ -48,6 +48,18 @@ const structuredData = { "@context": "https://schema.org", "@type": "WebSite", n console.warn("Theme storage is unavailable; using light mode for this visit.", error); } + diff --git a/site/tests/gallery.spec.ts b/site/tests/gallery.spec.ts index 9ecda91bd..8b8677696 100644 --- a/site/tests/gallery.spec.ts +++ b/site/tests/gallery.spec.ts @@ -147,7 +147,9 @@ test("retains old sample, guide, filter, and report links without redirect track test("keeps local previews free of production analytics and maps every page tracker correctly", async ({ page }) => { const requests: string[] = []; - page.on("request", (request) => { if (request.url().includes("m365-visitor-stats")) requests.push(request.url()); }); + page.on("request", (request) => { + if (request.url().includes("m365-visitor-stats") || request.url().includes("clarity.ms")) requests.push(request.url()); + }); const paths = [ ["./", "script-samples"], ["contributors/", "script-samples/contributors"], @@ -171,10 +173,15 @@ test("activates exactly one production tracker without counting filter or theme if (!baseURL) throw new Error("Browser tests require the local production server."); const origin = new URL(baseURL).origin; const tracked: string[] = []; + const clarity: string[] = []; await page.route("https://m365-visitor-stats.azurewebsites.net/**", async (route) => { tracked.push(route.request().url()); await route.fulfill({ contentType: "image/gif", headers: { "Cache-Control": "no-store" }, body: Buffer.from("R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=", "base64") }); }); + await page.route("https://www.clarity.ms/tag/**", async (route) => { + clarity.push(route.request().url()); + await route.fulfill({ contentType: "application/javascript", body: "window.__clarityTestLoaded = true;" }); + }); await page.route("https://pnp.github.io/script-samples/**", async (route) => { const url = new URL(route.request().url()); const response = await request.get(`${origin}${url.pathname}${url.search}`); @@ -188,6 +195,9 @@ test("activates exactly one production tracker without counting filter or theme await page.goto("https://pnp.github.io/script-samples/"); await expect.poll(() => tracked.length).toBe(1); expect(tracked[0]).toBe("https://m365-visitor-stats.azurewebsites.net/script-samples"); + await expect.poll(() => clarity.length).toBe(1); + expect(clarity[0]).toBe("https://www.clarity.ms/tag/8j6pedl344"); + await expect.poll(() => page.evaluate(() => (window as Window & { __clarityTestLoaded?: boolean }).__clarityTestLoaded)).toBe(true); await page.locator('[data-product="graph"]').click(); await page.locator("#sample-search").fill("permissions"); await page.locator("#theme-toggle").click();