Skip to content
Merged
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions src/lib/helpers/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,14 @@ export function trackSourcesClick(learningUnitId: string) {
learning_unit_id: learningUnitId,
});
}

/**
* Tracks when the profile is clicked.
*/
export function trackProfileClick() {
if (!browser) {
return;
}

window.gtag('event', 'profile_click');
}
7 changes: 7 additions & 0 deletions src/routes/(protected)/(core)/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<script lang="ts">
import { BookHeart, Home } from '@lucide/svelte';
import type { MouseEventHandler } from 'svelte/elements';

import { page } from '$app/state';
import { trackProfileClick } from '$lib/helpers/analytics.js';
import { HOME_PATH, IsWithinViewport } from '$lib/helpers/index.js';

const { data, children } = $props();
Expand All @@ -12,6 +14,10 @@
const isMyLearningPage = $derived(page.url.pathname === '/learning');

const isWithinViewport = new IsWithinViewport(() => target);

const handleProfileClick: MouseEventHandler<HTMLAnchorElement> = () => {
trackProfileClick();
};
</script>

<header class="fixed inset-x-0 z-50 bg-white/90 backdrop-blur-sm">
Expand All @@ -34,6 +40,7 @@
href="/profile"
aria-label="Profile"
class="h-10 w-10 cursor-pointer overflow-hidden rounded-full"
onclick={handleProfileClick}
>
<img src={data.avatar} alt="profile" />
</a>
Expand Down
3 changes: 2 additions & 1 deletion src/routes/(protected)/unit/[id]/quiz/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { Button, LinkButton } from '$lib/components/Button/index.js';
import { Modal } from '$lib/components/Modal/index.js';
import {
HOME_PATH,
IsWithinViewport,
noop,
trackQuizAttempt,
Expand Down Expand Up @@ -303,7 +304,7 @@
</LinkButton>

<a
href="/"
href={HOME_PATH}
class="inline-flex w-full cursor-pointer items-center justify-center rounded-full px-3.75 py-2.75 font-medium hover:bg-slate-100 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-slate-950 focus-visible:outline-dashed"
>
Back to home
Expand Down