Skip to content
Merged
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
37 changes: 37 additions & 0 deletions .vitepress/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ import { wagmiAdapter } from '@/utils/wagmiConfig';
import ChainSelector from '@/components/ChainSelector.vue';
import './style.css';

declare global {
interface Window {
dataLayer: any[];
axeptioSettings: {
clientId: string;
cookiesVersion: string;
};
}
}

export default {
extends: DefaultTheme,
Layout,
Expand All @@ -33,5 +43,32 @@ export default {
googleAnalytics({
id: 'GTM-P7KSD4T',
});

if (typeof window !== 'undefined') {
// Ensure dataLayer exists
window.dataLayer = window.dataLayer || [];

// Define a map of event types and their corresponding actions
const eventMap = {
connectWallet: 'hw_connectWallet',
protectData: 'hw_protectData',
grantAccess: 'hw_grantAccess',
claimVoucher: 'hw_claimVoucher',
};

// Add a global click listener
document.addEventListener('click', (event) => {
if (event.target instanceof Element) {
// Iterate through eventMap to check which event matches
Object.keys(eventMap).forEach((key) => {
if ((event.target as Element).matches(`[data-track="${key}"]`)) {
window.dataLayer.push({
event: eventMap[key],
});
}
});
}
});
}
},
} satisfies Theme;