1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-09-02 22:02:39 +02:00

feat: analytics (#8727)

This commit is contained in:
Arik Chakma
2025-06-02 20:49:22 +06:00
committed by GitHub
parent 67b17ef075
commit 7384d68998
2 changed files with 15 additions and 0 deletions

1
.astro/types.d.ts vendored
View File

@@ -1 +1,2 @@
/// <reference types="astro/client" />
/// <reference path="content.d.ts" />

View File

@@ -1,3 +1,5 @@
import { httpPost } from '../../lib/query-http';
declare global {
interface Window {
gtag: any;
@@ -20,6 +22,18 @@ declare global {
*/
window.fireEvent = (props) => {
const { action, category, label, value, callback } = props;
if (['course', 'ai_tutor'].includes(category)) {
const url = new URL(import.meta.env.PUBLIC_API_URL);
url.pathname = '/_t';
url.searchParams.set('action', action);
url.searchParams.set('category', category);
url.searchParams.set('label', label ?? '');
url.searchParams.set('value', value ?? '');
httpPost(url.toString(), {}).catch(console.error);
}
if (!window.gtag) {
console.warn('Missing GTAG - Analytics disabled');
return;