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

add analytics #266

Merged
merged 1 commit into from
Nov 24, 2023
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
9 changes: 9 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
<link rel="stylesheet" href="/assets/reset.css" />
<link rel="stylesheet" href="/assets/open-props.1.4.min.css" />
<link rel="stylesheet" href="/styles.css" />
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-5YQYLX790M"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'G-5YQYLX790M');
</script>
</head>

<body>
Expand Down
10 changes: 9 additions & 1 deletion src/common/types/declarations/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,12 @@ declare global {
var THREE: typeof import("three");
var postprocessing: typeof import("postprocessing");
// ... other globals
}
}

declare interface Gtag {
(command: 'config', targetId: string, config?: object): void;
(command: 'set', config: object): void;
(command: 'event', action: string, eventParams?: object): void;
}

declare const gtag: Gtag;
3 changes: 3 additions & 0 deletions src/core/titan-reactor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ globalEvents.on("queue-files", async ({ files: _files }) => {
console.warn("no files to load")
return;
};

// google analytics - send file name only
gtag("event", "queue-files", { "files" : files.map((f) => f.name).join(",") });

//todo map stuff here
if (files[0].name.endsWith(".scx") || files[0].name.endsWith(".scm")) {
Expand Down