-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathsession-pixel.svelte
More file actions
43 lines (37 loc) · 1.06 KB
/
session-pixel.svelte
File metadata and controls
43 lines (37 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<script lang="ts">
import { onMount } from 'svelte';
import { page } from '$app/state';
const TRACKING_PIXEL_BASE_URL =
'https://wpt.tomwheeler.com/cgi-sys/cgiwrap/twheeler/wtp.cgi';
let trackingPixelURL = $state('');
const disableTrackingPixel = $derived(
page.data?.settings?.disableTrackingPixel,
);
const uidKey = 'temporal-user-uuid';
const clusterId = $derived(page.data?.systemInfo?.clusterId);
const srcId = 'temporal-web-ui';
onMount(() => {
if (
!disableTrackingPixel &&
!sessionStorage.getItem('session-pixel-fired')
) {
let uuid = localStorage.getItem(uidKey);
if (!uuid) {
uuid = crypto.randomUUID();
localStorage.setItem(uidKey, uuid);
}
sessionStorage.setItem('session-pixel-fired', 'true');
trackingPixelURL = `${TRACKING_PIXEL_BASE_URL}?srcid=${clusterId}:${uuid}:${srcId}`;
}
});
</script>
{#if trackingPixelURL}
<img
src={trackingPixelURL}
alt=""
aria-hidden="true"
width="1"
height="1"
style="position:absolute;left:-9999px"
/>
{/if}