chore: conditional rendering of umami

This commit is contained in:
Rotimi Best
2026-03-11 10:37:44 +01:00
parent 996f40bddf
commit d19dddd8cd
10 changed files with 33 additions and 25 deletions
-7
View File
@@ -9,13 +9,6 @@
<link rel="icon" type="image/png" href="/favicon.ico" /> <link rel="icon" type="image/png" href="/favicon.ico" />
<link rel="icon" type="image/png" sizes="32x32" href="/logo-32.png" /> <link rel="icon" type="image/png" sizes="32x32" href="/logo-32.png" />
<script
nonce="%sveltekit.nonce%"
defer
src="https://umami.hz.oncws.com/script.js"
data-website-id="80a9544a-4dda-4c91-b62f-b6be7a8a3b5c"
></script>
%sveltekit.head% %sveltekit.head%
</head> </head>
@@ -18,7 +18,7 @@
let { title = $bindable(''), navClass = '', isCoursePage = false }: Props = $props(); let { title = $bindable(''), navClass = '', isCoursePage = false }: Props = $props();
let coursesPath = $derived( let coursesPath = $derived(
$globalStore.isOrgSite ? '/lms/mylearning' : isCoursePage ? `${$currentOrgPath}/courses` : $currentOrgPath $globalStore.isStudent ? '/lms/mylearning' : isCoursePage ? `${$currentOrgPath}/courses` : $currentOrgPath
); );
</script> </script>
@@ -27,13 +27,13 @@
<div class="flex items-center text-white"> <div class="flex items-center text-white">
{#if isCoursePage} {#if isCoursePage}
<li class="hidden md:block"> <li class="hidden md:block">
<IconButton onclick={() => goto(resolve(coursesPath))}> <IconButton onclick={() => goto(resolve(coursesPath, {}))}>
<ArrowLeftIcon size={16} class="custom" /> <ArrowLeftIcon size={16} class="custom" />
</IconButton> </IconButton>
</li> </li>
{/if} {/if}
<a <a
href={resolve(coursesPath)} href={resolve(coursesPath, {})}
title="{$t('navigation.goto')} {isCoursePage ? $t('navigation.courses') : $t('navigation.classroomio_home')}" title="{$t('navigation.goto')} {isCoursePage ? $t('navigation.courses') : $t('navigation.classroomio_home')}"
id="logo" id="logo"
class="line-clamp-1 text-lg" class="line-clamp-1 text-lg"
@@ -116,6 +116,7 @@ class AppInitApi extends BaseApi {
return; return;
} }
// This allows you to be on the landing page of an organization site and not be redirected
if (isOrgSite && window.location.pathname === '/') { if (isOrgSite && window.location.pathname === '/') {
return; return;
} }
@@ -45,7 +45,7 @@
let { path, id, isStudent = false }: Props = $props(); let { path, id, isStudent = false }: Props = $props();
const coursesListPath = $derived($globalStore.isOrgSite ? '/lms/mylearning' : `${$currentOrgPath}/courses`); const coursesListPath = $derived($globalStore.isStudent ? '/lms/mylearning' : `${$currentOrgPath}/courses`);
const contentData = $derived(getCourseContent(courseApi.course)); const contentData = $derived(getCourseContent(courseApi.course));
const sidebar = useSidebar(); const sidebar = useSidebar();
const contentCount = $derived.by(() => { const contentCount = $derived.by(() => {
@@ -6,6 +6,7 @@
import { currentOrg } from '$lib/utils/store/org'; import { currentOrg } from '$lib/utils/store/org';
import { profile } from '$lib/utils/store/user'; import { profile } from '$lib/utils/store/user';
import { coursesApi } from '$features/course/api'; import { coursesApi } from '$features/course/api';
import { resolve } from '$app/paths';
let totalCompleted = $derived( let totalCompleted = $derived(
coursesApi.enrolledCourses.reduce((acc, cur) => { coursesApi.enrolledCourses.reduce((acc, cur) => {
@@ -38,7 +39,7 @@
? $currentOrg.customization.dashboard.bannerText ? $currentOrg.customization.dashboard.bannerText
: $t('dashboard.lms_dashboard_hero')} : $t('dashboard.lms_dashboard_hero')}
</p> </p>
<Button onclick={() => goto('/lms/mylearning')}> <Button onclick={() => goto(resolve('/lms/mylearning', {}))}>
{$t('dashboard.continue_learning')} {$t('dashboard.continue_learning')}
</Button> </Button>
</div> </div>
@@ -29,10 +29,10 @@
function onClick(org: AccountOrg) { function onClick(org: AccountOrg) {
if (org.id === $currentOrg.id) return; if (org.id === $currentOrg.id) return;
localStorage.setItem('classroomio_org_sitename', org.siteName); localStorage.setItem('classroomio_org_sitename', org.siteName!);
currentOrg.set(org); currentOrg.set(org);
setTheme(org.theme); setTheme(org.theme!);
window.location.href = $currentOrgPath; window.location.href = $currentOrgPath;
} }
</script> </script>
@@ -1,7 +1,7 @@
import { PUBLIC_IS_SELFHOSTED } from '$env/static/public'; import { PUBLIC_IS_SELFHOSTED } from '$env/static/public';
import { dev } from '$app/environment';
import { initPosthog } from '$lib/utils/services/posthog'; import { initPosthog } from '$lib/utils/services/posthog';
import { initSentry } from '$lib/utils/services/sentry'; import { initSentry } from '$lib/utils/services/sentry';
import { initUmami } from '$lib/utils/services/umami';
import { licenseApi } from '$features/license/api/license.svelte'; import { licenseApi } from '$features/license/api/license.svelte';
let isInitialized = false; let isInitialized = false;
@@ -11,12 +11,8 @@ export function setupAnalytics() {
isInitialized = true; isInitialized = true;
initSentry(); initSentry();
initPosthog(); initPosthog();
initUmami();
if (dev) {
localStorage.setItem('umami.disabled', '1');
}
} }
/** Checks if this is cloud deployment and initializes analytics */ /** Checks if this is cloud deployment and initializes analytics */
@@ -0,0 +1,16 @@
import { dev } from '$app/environment';
import { licenseApi } from '$features/license/api/license.svelte';
const UMAMI_WEBSITE_ID = '80a9544a-4dda-4c91-b62f-b6be7a8a3b5c';
export const initUmami = (): void => {
if (dev || licenseApi.hasAccess('no-tracking')) return;
const script = document.createElement('script');
script.defer = true;
script.src = 'https://umami.hz.oncws.com/script.js';
script.dataset.websiteId = UMAMI_WEBSITE_ID;
const nonce = document.querySelector('script[nonce]')?.getAttribute('nonce');
if (nonce) script.setAttribute('nonce', nonce);
document.head.appendChild(script);
};
@@ -80,7 +80,7 @@
{#snippet child()} {#snippet child()}
<div class="mb-10 flex flex-wrap items-start"> <div class="mb-10 flex flex-wrap items-start">
<div class="grid w-full grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3"> <div class="grid w-full grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3">
{#each cards as card} {#each cards as card, i (i)}
<ActivityCard activity={card} /> <ActivityCard activity={card} />
{/each} {/each}
</div> </div>
@@ -94,11 +94,11 @@
<div class="h-full space-y-6"> <div class="h-full space-y-6">
{#if !topCourses} {#if !topCourses}
{#each Array(5) as _} {#each Array(5) as _, i (i)}
<Skeleton class="h-10 w-full rounded-md" /> <Skeleton class="h-10 w-full rounded-md" />
{/each} {/each}
{:else} {:else}
{#each topCourses as course} {#each topCourses as course (course.id)}
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<div class="w-4/6 space-y-1"> <div class="w-4/6 space-y-1">
<a class="hover:underline" href={`/courses/${course.id}`}> <a class="hover:underline" href={`/courses/${course.id}`}>
@@ -140,11 +140,11 @@
<div class="h-full space-y-6"> <div class="h-full space-y-6">
{#if !enrollments} {#if !enrollments}
{#each Array(5) as _} {#each Array(5) as _, i (i)}
<Skeleton class="h-10 w-full rounded-md" /> <Skeleton class="h-10 w-full rounded-md" />
{/each} {/each}
{:else} {:else}
{#each enrollments as enrollment} {#each enrollments as enrollment (enrollment.id)}
<div class="flex items-center justify-between gap-2"> <div class="flex items-center justify-between gap-2">
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<Avatar.Root class="h-6 w-6"> <Avatar.Root class="h-6 w-6">
+1
View File
@@ -34,6 +34,7 @@ const defaultScriptSrcDomains = [
'https://cdnjs.cloudflare.com', 'https://cdnjs.cloudflare.com',
'https://*.posthog.com', 'https://*.posthog.com',
'https://*.senja.io', 'https://*.senja.io',
'https://umami.hz.oncws.com',
'https://www.youtube.com', 'https://www.youtube.com',
'https://youtube.com', 'https://youtube.com',
'https://google.com' 'https://google.com'