Compare commits

...

1 Commits

Author SHA1 Message Date
Arik Chakma
c1c83b1d13 feat: analytics 2025-05-30 22:19:56 +06:00
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;