Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: add support for fathom tracking pixel #281

Merged
merged 1 commit into from
May 9, 2024
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
1 change: 1 addition & 0 deletions clients/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"@sentry/browser": "^7.101.0",
"@sentry/vite-plugin": "^2.14.0",
"@solid-primitives/map": "^0.4.9",
"@solid-primitives/script-loader": "^2.1.2",
"@solidjs/router": "^0.12.0",
"@tanstack/solid-virtual": "^3.0.4",
"clsx": "^2.1.0",
Expand Down
11 changes: 11 additions & 0 deletions clients/web/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions clients/web/src/lib/load-fathom.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { createScriptLoader } from "@solid-primitives/script-loader";

export function loadFathom() {
const fathomUrl = import.meta.env.VITE_FATHOM_URL;
const fathomId = import.meta.env.VITE_FATHOM_ID;
if (fathomUrl && fathomId)
createScriptLoader({ src: fathomUrl, "data-site": fathomId, defer: true });
Copy link
Contributor

Choose a reason for hiding this comment

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

We can only test in production if there is some CSP headers blocking the script. Most ad blockers will block it. too.

}
2 changes: 2 additions & 0 deletions clients/web/src/render-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import "~/css/global.css";
import Entry from "./entry";
import * as Sentry from "@sentry/browser";
import { DEV } from "solid-js";
import { loadFathom } from "./lib/load-fathom";

if (!DEV) {
Sentry.init({
Expand All @@ -11,6 +12,7 @@ if (!DEV) {
integrations: (def) => [...def, Sentry.browserTracingIntegration()],
tracesSampleRate: 0.1,
});
loadFathom();
}

const app = document.getElementById("app");
Expand Down
2 changes: 1 addition & 1 deletion clients/web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"jsx": "preserve",
"jsxImportSource": "solid-js",

"types": ["vitest/globals"]
"types": ["vitest/globals", "vite/client"]
},
"include": ["src", "tests"]
}
Loading