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:
1
.astro/types.d.ts
vendored
1
.astro/types.d.ts
vendored
@@ -1 +1,2 @@
|
||||
/// <reference types="astro/client" />
|
||||
/// <reference path="content.d.ts" />
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user