Skip to content

Commit 7355661

Browse files
committed
feat: basic analytics for tools site
1 parent 4dfa3a4 commit 7355661

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

website/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"deploy": "gh-pages -d dist"
1515
},
1616
"dependencies": {
17+
"@amplitude/analytics-browser": "^2.16.1",
1718
"@ant-design/icons": "^5.6.0",
1819
"@codemirror/language": "^6.10.8",
1920
"@codemirror/legacy-modes": "^6.4.2",

website/src/index.jsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,26 @@ import { createRoot } from "react-dom/client";
44
import { RouterProvider } from "react-router-dom";
55
import { router } from "./routing.jsx";
66
import WorkerProvider from "./workers/WorkerProvider.jsx";
7+
import { init } from '@amplitude/analytics-browser';
8+
import { autocapturePlugin } from '@amplitude/plugin-autocapture-browser';
9+
10+
// Initialize Amplitude with your API key
11+
const AMPLITUDE_API_KEY = import.meta.env.VITE_AMPLITUDE_API_KEY;
12+
13+
if (AMPLITUDE_API_KEY) {
14+
init(AMPLITUDE_API_KEY, {
15+
serverZone: "US",
16+
defaultTracking: {
17+
sessions: true,
18+
pageViews: true,
19+
formInteractions: true,
20+
fileDownloads: true,
21+
},
22+
plugins: [
23+
autocapturePlugin()
24+
]
25+
});
26+
}
727

828
const container = document.getElementById("root");
929
const root = createRoot(container);
@@ -32,4 +52,4 @@ const reportWebVitals = (onPerfEntry) => {
3252
// If you want to start measuring performance in your app, pass a function
3353
// to log results (for example: reportWebVitals(console.log))
3454
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
35-
reportWebVitals();
55+
reportWebVitals();

0 commit comments

Comments
 (0)