feat: trackBannerClick

Purposefully not enabling the outbound link tracking,
as it would track links people have embedded in diagrams
which will then be available in public analytics.
This commit is contained in:
Sidharth Vinod
2023-12-06 11:27:16 +05:30
parent 7ff3594df7
commit f2fde65536
2 changed files with 15 additions and 3 deletions
+13 -2
View File
@@ -1,6 +1,6 @@
<script context="module" lang="ts">
import { version } from 'mermaid/package.json';
import { analytics } from '$lib/util/stats';
import { analytics, logEvent } from '$lib/util/stats';
void analytics?.track('version', {
mermaidVersion: version
});
@@ -49,12 +49,23 @@
];
let activePromotion = getActivePromotion();
const trackBannerClick = () => {
if (!analytics || !activePromotion) {
return;
}
logEvent('bannerClick', {
promotion: activePromotion.id
});
};
</script>
{#if activePromotion}
<div
class="z-10 w-full top-bar bg-gradient-to-r from-[#bd34fe] to-[#ff3670] flex items-center text-center justify-center p-1 text-white">
<svelte:component this={activePromotion.component} />
<div class="flex flex-grow" on:click={trackBannerClick} on:keypress={trackBannerClick}>
<svelte:component this={activePromotion.component} />
</div>
<button
title="Dismiss banner"
on:click={() => {
+2 -1
View File
@@ -99,7 +99,8 @@ const delaysPerEvent = {
renderDiagram: defaultDelay,
history: defaultDelay,
migration: defaultDelay,
themeChange: defaultDelay
themeChange: defaultDelay,
bannerClick: defaultDelay
};
export type AnalyticsEvent = keyof typeof delaysPerEvent;
const timeouts: Map<string, number> = new Map<string, number>();