2026-04-12 08:58:41 +01:00
|
|
|
<script lang="ts">
|
|
|
|
|
import { PageRestricted } from '$features/ui';
|
|
|
|
|
import { currentOrg } from '$lib/utils/store/org';
|
2026-05-18 03:47:22 +01:00
|
|
|
import { onMount } from 'svelte';
|
|
|
|
|
import { afterNavigate } from '$app/navigation';
|
|
|
|
|
import { env } from '$env/dynamic/public';
|
|
|
|
|
import { analytics } from '@cio/analytics/client';
|
|
|
|
|
import type { Snippet } from 'svelte';
|
|
|
|
|
import type { AccountOrg } from '$features/app/types';
|
2026-04-12 08:58:41 +01:00
|
|
|
|
|
|
|
|
interface Props {
|
2026-05-18 03:47:22 +01:00
|
|
|
children?: Snippet;
|
2026-04-12 08:58:41 +01:00
|
|
|
data: {
|
|
|
|
|
isOrgSite: boolean;
|
2026-05-18 03:47:22 +01:00
|
|
|
org: AccountOrg | null;
|
2026-04-12 08:58:41 +01:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let { children, data }: Props = $props();
|
2026-05-18 03:47:22 +01:00
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
|
if (!env.PUBLIC_SERVER_URL) return;
|
|
|
|
|
|
|
|
|
|
analytics.init({
|
|
|
|
|
endpoint: `${env.PUBLIC_SERVER_URL.replace(/\/$/, '')}/dash/track`,
|
|
|
|
|
orgId: data.org?.id ?? undefined
|
|
|
|
|
});
|
|
|
|
|
analytics.pageView({ kind: 'landing' });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
afterNavigate(({ to }) => {
|
|
|
|
|
if (!to) return;
|
|
|
|
|
|
|
|
|
|
const isCoursePage = /\/course\//.test(to.url.pathname);
|
|
|
|
|
analytics.pageView({
|
|
|
|
|
kind: isCoursePage ? 'course' : 'landing',
|
|
|
|
|
path: to.url.pathname
|
|
|
|
|
});
|
|
|
|
|
});
|
2026-04-12 08:58:41 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
{#if data.org?.isRestricted || $currentOrg.isRestricted}
|
|
|
|
|
<PageRestricted />
|
|
|
|
|
{:else}
|
|
|
|
|
{@render children?.()}
|
|
|
|
|
{/if}
|