mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-09-18 09:29:24 +00:00
Add sthe scarf pixel
This commit is contained in:
parent
67d456cb86
commit
89635b576c
33
frontend/src/components/ScarfPixel.tsx
Normal file
33
frontend/src/components/ScarfPixel.tsx
Normal file
@ -0,0 +1,33 @@
|
||||
import { useLocation } from "react-router-dom";
|
||||
import { useEffect, useRef } from "react";
|
||||
|
||||
export function ScarfPixel() {
|
||||
const location = useLocation();
|
||||
const lastUrlSent = useRef<string | null>(null); // helps with React 18 StrictMode in dev
|
||||
|
||||
useEffect(() => {
|
||||
// Force reload of the tracking pixel on route change
|
||||
const url = 'https://static.scarf.sh/a.png?x-pxid=3c1d68de-8945-4e9f-873f-65320b6fabf7'
|
||||
+ '&path=' + encodeURIComponent(location.pathname)
|
||||
+ '&t=' + Date.now(); // cache-buster
|
||||
|
||||
|
||||
// + '&machineType=' + machineType
|
||||
// + '&appVersion=' + appVersion
|
||||
// + '&licenseType=' + license
|
||||
// + '&loginEnabled=' + loginEnabled;
|
||||
console.log("ScarfPixel: reload " + location.pathname );
|
||||
|
||||
if (lastUrlSent.current !== url) {
|
||||
lastUrlSent.current = url;
|
||||
const img = new Image();
|
||||
img.referrerPolicy = "no-referrer-when-downgrade"; // optional
|
||||
img.src = url;
|
||||
|
||||
console.log("ScarfPixel: Fire to... " + location.pathname , url);
|
||||
}
|
||||
}, [location.pathname]);
|
||||
|
||||
return null; // Nothing visible in UI
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import { BrowserRouter } from 'react-router-dom';
|
||||
import App from './App';
|
||||
import './i18n'; // Initialize i18next
|
||||
import { PostHogProvider } from 'posthog-js/react';
|
||||
import { ScarfPixel } from './components/ScarfPixel';
|
||||
|
||||
// Compute initial color scheme
|
||||
function getInitialScheme(): 'light' | 'dark' {
|
||||
@ -38,10 +39,10 @@ root.render(
|
||||
debug: import.meta.env.MODE === 'development',
|
||||
}}
|
||||
>
|
||||
<BrowserRouter>
|
||||
<App />
|
||||
</BrowserRouter>
|
||||
<BrowserRouter>
|
||||
<ScarfPixel />
|
||||
<App />
|
||||
</BrowserRouter>
|
||||
</PostHogProvider>
|
||||
</React.StrictMode>
|
||||
);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user