Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docusaurus/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ const config = {
searchPagePath: 'search',
},
}),
// Scarf pixel – fires on every page view (SPA-aware)
clientModules: [require.resolve('./src/scarf.js')],

plugins: [
[
'docusaurus-plugin-typedoc',
Expand Down
27 changes: 27 additions & 0 deletions docusaurus/src/scarf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Scarf pixel – SPA-aware tracking for the Docusaurus documentation site.
// This client module fires on the initial page load and on every subsequent
// in-app navigation so that each page view is recorded, even in a SPA where
// the full page is never reloaded.

const PIXEL_ID = '7c25872d-249e-45d8-aa99-0d0e3421c29e';

let lastHref = null;

function sendScarfPing() {
if (typeof window === 'undefined') return;

const currentHref = window.location.href;
if (currentHref === lastHref) return; // dedup: skip if same page
lastHref = currentHref;

const url = `https://static.scarf.sh/a.png?x-pxid=${PIXEL_ID}`;
const img = new Image();
img.referrerPolicy = 'no-referrer-when-downgrade';
img.src = url;
}

// Docusaurus client-module lifecycle hook – called after every route update
// (initial load + every SPA navigation).
export function onRouteDidUpdate() {
sendScarfPing();
}
Loading