@picked/svelte 0.0.62-next.9 → 0.0.63-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,153 @@
1
+ <script lang="ts">
2
+ /** @file Devtools screen for the resolved Picked client configuration and reactive lifecycle state. */
3
+ import { getPicked } from '../../../../hooks'
4
+ import { Badge, Card, CodeBlock, DataTable, EmptyState, Stack, Text } from '../../ui'
5
+
6
+ const client = getPicked()
7
+ const lifecycleStageStore = client.lifecycleStageStore
8
+ const readyStore = client.readyStore
9
+ const preconditionPassedStore = client.preconditionPassedStore
10
+ const conditionPassedStore = client.conditionPassedStore
11
+
12
+ const searchParamEntries = Object.entries(client.searchParams ?? {}).map(([key, value]) => ({
13
+ key,
14
+ value: Array.isArray(value) ? value.join(', ') : String(value ?? ''),
15
+ }))
16
+
17
+ const staticRows = [
18
+ { label: 'Project ID', value: client.projectId },
19
+ { label: 'API URL', value: client.apiUrl },
20
+ { label: 'Dashboard URL', value: client.dashboardUrl },
21
+ { label: 'Documentation URL', value: client.documentationSiteUrl },
22
+ { label: 'Data source', value: client.dataSource === null ? '—' : JSON.stringify(client.dataSource) },
23
+ ]
24
+
25
+ const configColumns = [
26
+ { key: 'label', header: 'Property' },
27
+ { key: 'value', header: 'Value' },
28
+ ]
29
+
30
+ const searchParamColumns = [
31
+ { key: 'key', header: 'Key' },
32
+ { key: 'value', header: 'Value' },
33
+ ]
34
+
35
+ /**
36
+ * Maps a lifecycle stage to a Badge status colour.
37
+ *
38
+ * @param {'idle' | 'starting' | 'ready' | 'failed'} stage - The current lifecycle stage.
39
+ * @returns {'default' | 'info' | 'success' | 'error'} The Badge status variant.
40
+ * @example
41
+ * ```typescript
42
+ * stageStatus('ready') // 'success'
43
+ * ```
44
+ */
45
+ function stageStatus(
46
+ stage: 'idle' | 'starting' | 'ready' | 'failed',
47
+ ): 'default' | 'info' | 'success' | 'error' {
48
+ if (stage === 'ready') return 'success'
49
+ if (stage === 'starting') return 'info'
50
+ if (stage === 'failed') return 'error'
51
+ return 'default'
52
+ }
53
+
54
+ /**
55
+ * Maps a tri-state boolean gate result to a Badge status colour.
56
+ *
57
+ * @param {boolean | undefined} value - The gate value: true (passed), false (blocked), or undefined (unevaluated).
58
+ * @returns {'default' | 'success' | 'error'} The Badge status variant.
59
+ * @example
60
+ * ```typescript
61
+ * gateStatus(undefined) // 'default'
62
+ * gateStatus(true) // 'success'
63
+ * ```
64
+ */
65
+ function gateStatus(value: boolean | undefined): 'default' | 'success' | 'error' {
66
+ if (value === true) return 'success'
67
+ if (value === false) return 'error'
68
+ return 'default'
69
+ }
70
+
71
+ /**
72
+ * Renders a tri-state boolean gate as a short label.
73
+ *
74
+ * @param {boolean | undefined} value - The gate value.
75
+ * @returns {string} The label text.
76
+ * @example
77
+ * ```typescript
78
+ * gateLabel(undefined) // 'pending'
79
+ * ```
80
+ */
81
+ function gateLabel(value: boolean | undefined): string {
82
+ if (value === true) return 'passed'
83
+ if (value === false) return 'blocked'
84
+ return 'pending'
85
+ }
86
+ </script>
87
+
88
+ <Stack direction="vertical" gap="medium" padding="medium">
89
+ <Text size="caption" color="subdued">
90
+ The resolved configuration and live lifecycle state for this Picked client instance.
91
+ </Text>
92
+
93
+ <Card sectioned>
94
+ {#snippet header()}
95
+ <Text size="caption" weight="semibold" color="subdued">CONFIGURATION</Text>
96
+ {/snippet}
97
+ <DataTable columns={configColumns} rows={staticRows}>
98
+ {#snippet row(item)}
99
+ <tr>
100
+ <td><Text size="small" weight="medium">{item.label}</Text></td>
101
+ <td><CodeBlock code={item.value} inline /></td>
102
+ </tr>
103
+ {/snippet}
104
+ </DataTable>
105
+ </Card>
106
+
107
+ <Card sectioned>
108
+ {#snippet header()}
109
+ <Text size="caption" weight="semibold" color="subdued">LIFECYCLE</Text>
110
+ {/snippet}
111
+ <Stack direction="vertical" gap="small" padding="medium">
112
+ <Stack direction="horizontal" gap="small">
113
+ <Text size="small" weight="medium">Stage:</Text>
114
+ <Badge status={stageStatus($lifecycleStageStore)} size="small">{$lifecycleStageStore}</Badge>
115
+ </Stack>
116
+ <Stack direction="horizontal" gap="small">
117
+ <Text size="small" weight="medium">Ready:</Text>
118
+ <Badge status={$readyStore ? 'success' : 'default'} size="small">{$readyStore ? 'true' : 'false'}</Badge>
119
+ </Stack>
120
+ <Stack direction="horizontal" gap="small">
121
+ <Text size="small" weight="medium">Precondition:</Text>
122
+ <Badge status={gateStatus($preconditionPassedStore)} size="small">
123
+ {gateLabel($preconditionPassedStore)}
124
+ </Badge>
125
+ </Stack>
126
+ <Stack direction="horizontal" gap="small">
127
+ <Text size="small" weight="medium">Condition:</Text>
128
+ <Badge status={gateStatus($conditionPassedStore)} size="small">
129
+ {gateLabel($conditionPassedStore)}
130
+ </Badge>
131
+ </Stack>
132
+ </Stack>
133
+ </Card>
134
+
135
+ <Card sectioned>
136
+ {#snippet header()}
137
+ <Text size="caption" weight="semibold" color="subdued">
138
+ PICKED SEARCH PARAMS ({searchParamEntries.length})
139
+ </Text>
140
+ {/snippet}
141
+ <DataTable columns={searchParamColumns} rows={searchParamEntries}>
142
+ {#snippet row(entry)}
143
+ <tr>
144
+ <td><CodeBlock code={entry.key} inline /></td>
145
+ <td><CodeBlock code={entry.value} inline /></td>
146
+ </tr>
147
+ {/snippet}
148
+ {#snippet empty()}
149
+ <EmptyState message="No picked-* search params on the current URL" />
150
+ {/snippet}
151
+ </DataTable>
152
+ </Card>
153
+ </Stack>
@@ -0,0 +1,89 @@
1
+ <script lang="ts">
2
+ /** @file Devtools screen listing CMS content records registered with the client. */
3
+ import type { Content } from '@picked/client'
4
+ import { getPicked } from '../../../../hooks'
5
+ import { Badge, Card, CodeBlock, DataTable, EmptyState, ExpandableRow, Stack, Text } from '../../ui'
6
+
7
+ const client = getPicked()
8
+ const contentsStore = client.contents.listStore
9
+
10
+ let expandedId: string | null = null
11
+
12
+ const columns = [
13
+ { key: 'id', header: 'ID' },
14
+ { key: 'keys', header: 'Top-level keys' },
15
+ ]
16
+
17
+ /**
18
+ * Returns the top-level keys of a content record's `data` object, used to give a quick
19
+ * shape preview in the row summary without expanding.
20
+ *
21
+ * @param {Content} content - The content record.
22
+ * @returns {string[]} The data object's top-level keys.
23
+ * @example
24
+ * ```typescript
25
+ * dataKeys({ id: 'c1', data: { headline: 'hi' } }) // ['headline']
26
+ * ```
27
+ */
28
+ function dataKeys(content: Content): string[] {
29
+ return Object.keys(content.data ?? {})
30
+ }
31
+
32
+ /**
33
+ * Pretty-prints the content record's `data` object for use inside a multi-line CodeBlock.
34
+ *
35
+ * @param {Content} content - The content record.
36
+ * @returns {string} A two-space-indented JSON representation of `data`.
37
+ * @example
38
+ * ```typescript
39
+ * formatData({ id: 'c1', data: { a: 1 } }) // '{\n "a": 1\n}'
40
+ * ```
41
+ */
42
+ function formatData(content: Content): string {
43
+ return JSON.stringify(content.data, null, 2)
44
+ }
45
+ </script>
46
+
47
+ <Stack direction="vertical" gap="medium" padding="medium">
48
+ <Text size="caption" color="subdued">
49
+ Content records registered with the client by the active content loader.
50
+ </Text>
51
+
52
+ <Card sectioned>
53
+ <DataTable {columns} rows={$contentsStore}>
54
+ {#snippet row(content)}
55
+ {@const expanded = expandedId === content.id}
56
+ {@const keys = dataKeys(content)}
57
+ <ExpandableRow
58
+ {expanded}
59
+ onToggle={() => { expandedId = expanded ? null : content.id }}
60
+ colspan={columns.length}
61
+ >
62
+ {#snippet summary()}
63
+ <td><CodeBlock code={content.id} inline /></td>
64
+ <td>
65
+ {#if keys.length > 0}
66
+ <Stack direction="horizontal" gap="small" wrap={true}>
67
+ {#each keys as key (key)}
68
+ <Badge status="default" size="small">{key}</Badge>
69
+ {/each}
70
+ </Stack>
71
+ {:else}
72
+ <Text size="small" color="subdued">—</Text>
73
+ {/if}
74
+ </td>
75
+ {/snippet}
76
+ {#snippet details()}
77
+ <Stack direction="vertical" gap="small">
78
+ <Text size="caption" weight="semibold" color="subdued">DATA</Text>
79
+ <CodeBlock code={formatData(content)} />
80
+ </Stack>
81
+ {/snippet}
82
+ </ExpandableRow>
83
+ {/snippet}
84
+ {#snippet empty()}
85
+ <EmptyState message="No content registered" />
86
+ {/snippet}
87
+ </DataTable>
88
+ </Card>
89
+ </Stack>
@@ -0,0 +1,276 @@
1
+ <script lang="ts">
2
+ /** @file Expandable row presenting a single registered field's schema in the devtools fields screen. */
3
+ import type { Field } from '@picked/client'
4
+ import { Badge, CodeBlock, ExpandableRow, Stack, Text } from '../../ui'
5
+
6
+ export let field: Field
7
+ export let columnCount: number
8
+
9
+ let expanded = false
10
+
11
+ $: optionsList = Array.isArray(field.options) ? field.options : []
12
+ $: hasOptions = optionsList.length > 0
13
+ $: hasCondition = field.condition !== undefined && field.condition !== null
14
+ $: hasValidation = field.validation !== undefined && field.validation !== null
15
+ $: hasDefault = field.defaultValue !== undefined
16
+ $: doNotTrack = Boolean(field.policies?.doNotTrackValue)
17
+ $: doNotStore = Boolean(field.policies?.doNotStoreValue)
18
+ $: hasDetails =
19
+ hasCondition ||
20
+ hasValidation ||
21
+ hasOptions ||
22
+ Boolean(field.description) ||
23
+ Boolean(field.helpText) ||
24
+ Boolean(field.placeholder) ||
25
+ Boolean(field.label && field.label !== field.name) ||
26
+ Boolean(field.id)
27
+
28
+ /**
29
+ * Returns a Badge status colour for a given field type so each type renders consistently.
30
+ *
31
+ * @param {Field['type']} type - The field's primitive type.
32
+ * @returns {'default' | 'success' | 'warning' | 'info'} The Badge status variant to apply.
33
+ * @example
34
+ * ```typescript
35
+ * typeStatus('number') // 'success'
36
+ * ```
37
+ */
38
+ function typeStatus(type: Field['type']): 'default' | 'success' | 'warning' | 'info' {
39
+ if (type === 'text') return 'info'
40
+ if (type === 'number') return 'success'
41
+ if (type === 'boolean') return 'warning'
42
+ return 'default'
43
+ }
44
+
45
+ /**
46
+ * Renders an arbitrary value as a short, single-line preview for use in compact table cells.
47
+ * Strings are returned unquoted, primitives are stringified, and objects/arrays are JSON-encoded
48
+ * and truncated.
49
+ *
50
+ * @param {unknown} value - The value to preview.
51
+ * @param {number} [maxLength] - Maximum character length before the preview is truncated.
52
+ * @returns {string} The short preview string, or `'—'` when the value is null/undefined.
53
+ * @example
54
+ * ```typescript
55
+ * previewValue({ foo: 'bar' }) // '{"foo":"bar"}'
56
+ * previewValue(null) // '—'
57
+ * ```
58
+ */
59
+ function previewValue(value: unknown, maxLength = 48): string {
60
+ if (value === null || value === undefined) return '—'
61
+
62
+ let str: string
63
+ if (typeof value === 'string') {
64
+ str = value
65
+ } else if (typeof value === 'object') {
66
+ str = JSON.stringify(value)
67
+ } else {
68
+ str = String(value)
69
+ }
70
+
71
+ if (str.length > maxLength) return `${str.slice(0, maxLength - 1)}…`
72
+ return str
73
+ }
74
+
75
+ /**
76
+ * Pretty-prints a JSON-serializable value for use inside a multi-line CodeBlock.
77
+ *
78
+ * @param {unknown} value - The value to format.
79
+ * @returns {string} A two-space-indented JSON representation.
80
+ * @example
81
+ * ```typescript
82
+ * formatJson({ a: 1 }) // '{\n "a": 1\n}'
83
+ * ```
84
+ */
85
+ function formatJson(value: unknown): string {
86
+ return JSON.stringify(value, null, 2)
87
+ }
88
+
89
+ /**
90
+ * Renders a `FieldOption.value` (which may be any JSON-serializable shape across field types)
91
+ * as a short, copyable code string.
92
+ *
93
+ * @param {unknown} value - The option's underlying value.
94
+ * @returns {string} The string to display inside an inline CodeBlock.
95
+ * @example
96
+ * ```typescript
97
+ * formatOptionValue('us') // 'us'
98
+ * formatOptionValue({ id: 1 }) // '{"id":1}'
99
+ * ```
100
+ */
101
+ function formatOptionValue(value: unknown): string {
102
+ if (typeof value === 'string') return value
103
+ return JSON.stringify(value)
104
+ }
105
+ </script>
106
+
107
+ <ExpandableRow
108
+ {expanded}
109
+ onToggle={() => { if (hasDetails) expanded = !expanded }}
110
+ colspan={columnCount}
111
+ >
112
+ {#snippet summary()}
113
+ <td><CodeBlock code={field.key} inline /></td>
114
+ <td>
115
+ <Stack direction="vertical" gap="none">
116
+ <Text size="small" weight="medium">{field.name}</Text>
117
+ {#if field.label && field.label !== field.name}
118
+ <Text size="caption" color="subdued">{field.label}</Text>
119
+ {/if}
120
+ </Stack>
121
+ </td>
122
+ <td><Badge status={typeStatus(field.type)} size="small">{field.type}</Badge></td>
123
+ <td>
124
+ <Stack direction="horizontal" gap="small">
125
+ {#if field.multiple}
126
+ <Badge status="default" size="small">multiple</Badge>
127
+ {/if}
128
+ {#if field.required}
129
+ <Badge status="warning" size="small">required</Badge>
130
+ {/if}
131
+ {#if doNotTrack}
132
+ <Badge status="error" size="small">no-track</Badge>
133
+ {/if}
134
+ {#if doNotStore}
135
+ <Badge status="error" size="small">no-store</Badge>
136
+ {/if}
137
+ </Stack>
138
+ </td>
139
+ <td>
140
+ {#if hasDefault}
141
+ <CodeBlock code={previewValue(field.defaultValue)} inline />
142
+ {:else}
143
+ <Text size="small" color="subdued">—</Text>
144
+ {/if}
145
+ </td>
146
+ <td>
147
+ {#if hasOptions}
148
+ <Badge status="info" size="small">{optionsList.length}</Badge>
149
+ {:else}
150
+ <Text size="small" color="subdued">—</Text>
151
+ {/if}
152
+ </td>
153
+ <td>
154
+ <Stack direction="horizontal" gap="small">
155
+ {#if hasCondition}
156
+ <Badge status="info" size="small">condition</Badge>
157
+ {/if}
158
+ {#if hasValidation}
159
+ <Badge status="info" size="small">validation</Badge>
160
+ {/if}
161
+ {#if !hasCondition && !hasValidation}
162
+ <Text size="small" color="subdued">—</Text>
163
+ {/if}
164
+ </Stack>
165
+ </td>
166
+ {/snippet}
167
+
168
+ {#snippet details()}
169
+ <Stack direction="vertical" gap="medium">
170
+ <Stack direction="vertical" gap="small">
171
+ <Text size="caption" weight="semibold" color="subdued">IDENTITY</Text>
172
+ <Stack direction="horizontal" gap="medium">
173
+ <Text size="small"><strong>id:</strong></Text>
174
+ <CodeBlock code={field.id} inline />
175
+ </Stack>
176
+ </Stack>
177
+
178
+ {#if field.description || field.helpText || field.placeholder}
179
+ <Stack direction="vertical" gap="small">
180
+ <Text size="caption" weight="semibold" color="subdued">COPY</Text>
181
+ {#if field.description}
182
+ <Text size="small"><strong>description:</strong> {field.description}</Text>
183
+ {/if}
184
+ {#if field.helpText}
185
+ <Text size="small"><strong>help text:</strong> {field.helpText}</Text>
186
+ {/if}
187
+ {#if field.placeholder}
188
+ <Text size="small"><strong>placeholder:</strong> {field.placeholder}</Text>
189
+ {/if}
190
+ </Stack>
191
+ {/if}
192
+
193
+ {#if hasDefault}
194
+ <Stack direction="vertical" gap="small">
195
+ <Text size="caption" weight="semibold" color="subdued">DEFAULT VALUE</Text>
196
+ <CodeBlock code={formatJson(field.defaultValue)} />
197
+ </Stack>
198
+ {/if}
199
+
200
+ {#if hasOptions}
201
+ <Stack direction="vertical" gap="small">
202
+ <Text size="caption" weight="semibold" color="subdued">OPTIONS ({optionsList.length})</Text>
203
+ <table class="options-table">
204
+ <thead>
205
+ <tr>
206
+ <th>Label</th>
207
+ <th>Value</th>
208
+ <th>ID</th>
209
+ <th>Description</th>
210
+ </tr>
211
+ </thead>
212
+ <tbody>
213
+ {#each optionsList as option (option.id)}
214
+ <tr>
215
+ <td>{option.label}</td>
216
+ <td><CodeBlock code={formatOptionValue(option.value)} inline /></td>
217
+ <td><CodeBlock code={option.id} inline /></td>
218
+ <td>
219
+ {#if option.description}
220
+ {option.description}
221
+ {:else}
222
+ <Text size="small" color="subdued">—</Text>
223
+ {/if}
224
+ </td>
225
+ </tr>
226
+ {/each}
227
+ </tbody>
228
+ </table>
229
+ </Stack>
230
+ {/if}
231
+
232
+ {#if hasCondition}
233
+ <Stack direction="vertical" gap="small">
234
+ <Text size="caption" weight="semibold" color="subdued">CONDITION</Text>
235
+ <CodeBlock code={formatJson(field.condition)} />
236
+ </Stack>
237
+ {/if}
238
+
239
+ {#if hasValidation}
240
+ <Stack direction="vertical" gap="small">
241
+ <Text size="caption" weight="semibold" color="subdued">VALIDATION</Text>
242
+ <CodeBlock code={formatJson(field.validation)} />
243
+ </Stack>
244
+ {/if}
245
+ </Stack>
246
+ {/snippet}
247
+ </ExpandableRow>
248
+
249
+ <style>
250
+ .options-table {
251
+ width: 100%;
252
+ border-collapse: collapse;
253
+ background-color: var(--color-white);
254
+ border: 1px solid var(--color-gray-200);
255
+ border-radius: var(--radius-md);
256
+ overflow: hidden;
257
+ }
258
+
259
+ .options-table th,
260
+ .options-table td {
261
+ padding: var(--space-1-5) var(--space-2);
262
+ text-align: left;
263
+ font-size: var(--text-xs);
264
+ border-bottom: 1px solid var(--color-gray-200);
265
+ }
266
+
267
+ .options-table tr:last-child td {
268
+ border-bottom: 0;
269
+ }
270
+
271
+ .options-table th {
272
+ font-weight: var(--font-medium);
273
+ color: var(--color-gray-700);
274
+ background-color: var(--color-gray-50);
275
+ }
276
+ </style>
@@ -0,0 +1,12 @@
1
+ <script lang="ts">
2
+ /** @file Devtools screen that lists every field registered with the SDK. */
3
+ import { getPicked } from '../../../../hooks'
4
+ import FieldsTable from './FieldsTable.svelte'
5
+
6
+ const client = getPicked()
7
+ const fieldsStore = client.fields.listStore
8
+ </script>
9
+
10
+ <div>
11
+ <FieldsTable fields={$fieldsStore} />
12
+ </div>
@@ -0,0 +1,78 @@
1
+ <script lang="ts">
2
+ /** @file Table of registered fields with type filtering for the devtools fields screen. */
3
+ import type { Field } from '@picked/client'
4
+ import { Card, DataTable, EmptyState, RadioGroup, Stack } from '../../ui'
5
+ import FieldTableRow from './FieldTableRow.svelte'
6
+
7
+ export let fields: Field[] = []
8
+
9
+ type TypeFilter = 'all' | Field['type']
10
+
11
+ let filter: TypeFilter = 'all'
12
+
13
+ $: counts = {
14
+ all: fields.length,
15
+ text: fields.filter((f) => f.type === 'text').length,
16
+ number: fields.filter((f) => f.type === 'number').length,
17
+ boolean: fields.filter((f) => f.type === 'boolean').length,
18
+ object: fields.filter((f) => f.type === 'object').length,
19
+ }
20
+
21
+ $: visibleFields = filter === 'all' ? fields : fields.filter((f) => f.type === filter)
22
+
23
+ const columns = [
24
+ { key: 'key', header: 'Key' },
25
+ { key: 'name', header: 'Name' },
26
+ { key: 'type', header: 'Type' },
27
+ { key: 'flags', header: 'Flags' },
28
+ { key: 'default', header: 'Default' },
29
+ { key: 'options', header: 'Options' },
30
+ { key: 'rules', header: 'Rules' },
31
+ ]
32
+
33
+ $: filterOptions = [
34
+ { value: 'all', label: `All (${counts.all})` },
35
+ { value: 'text', label: `Text (${counts.text})` },
36
+ { value: 'number', label: `Number (${counts.number})` },
37
+ { value: 'boolean', label: `Boolean (${counts.boolean})` },
38
+ { value: 'object', label: `Object (${counts.object})` },
39
+ ]
40
+
41
+ /**
42
+ * Updates the active type filter when the user picks a different radio option.
43
+ *
44
+ * @param {string} value - The chosen filter value, expected to be `'all'` or a `Field['type']`.
45
+ * @example
46
+ * ```typescript
47
+ * handleFilterChange('number') // narrows the table to number fields
48
+ * ```
49
+ */
50
+ function handleFilterChange(value: string): void {
51
+ if (value === 'all' || value === 'text' || value === 'number' || value === 'boolean' || value === 'object') {
52
+ filter = value
53
+ }
54
+ }
55
+ </script>
56
+
57
+ <Stack padding="medium">
58
+ <Card sectioned>
59
+ <Stack direction="horizontal" gap="small" align="space-between" justify="center" padding="medium">
60
+ <RadioGroup
61
+ label="Filter by type"
62
+ name="field-type-filter"
63
+ options={filterOptions}
64
+ value={filter}
65
+ onchange={handleFilterChange}
66
+ orientation="horizontal"
67
+ />
68
+ </Stack>
69
+ <DataTable {columns} rows={visibleFields}>
70
+ {#snippet row(field)}
71
+ <FieldTableRow {field} columnCount={columns.length} />
72
+ {/snippet}
73
+ {#snippet empty()}
74
+ <EmptyState message="No fields registered" />
75
+ {/snippet}
76
+ </DataTable>
77
+ </Card>
78
+ </Stack>
@@ -0,0 +1,66 @@
1
+ <script lang="ts">
2
+ /** @file Devtools screen for the current visitor session — id, isUser flag, and identifiers map. */
3
+ import { getPicked } from '../../../../hooks'
4
+ import { Badge, Card, CodeBlock, DataTable, EmptyState, Stack, Text } from '../../ui'
5
+
6
+ const client = getPicked()
7
+ const sessionStore = client.session.store
8
+
9
+ $: identifierEntries = Object.entries($sessionStore.identifiers ?? {})
10
+
11
+ const overviewColumns = [
12
+ { key: 'label', header: 'Property' },
13
+ { key: 'value', header: 'Value' },
14
+ ]
15
+
16
+ const identifierColumns = [
17
+ { key: 'key', header: 'Key' },
18
+ { key: 'value', header: 'Value' },
19
+ ]
20
+ </script>
21
+
22
+ <Stack direction="vertical" gap="medium" padding="medium">
23
+ <Text size="caption" color="subdued">
24
+ The current visitor session as tracked by the SDK. Persisted to localStorage when available.
25
+ </Text>
26
+
27
+ <Card sectioned>
28
+ <DataTable columns={overviewColumns} rows={[{ label: 'Session ID', value: $sessionStore.id }]}>
29
+ {#snippet row(item)}
30
+ <tr>
31
+ <td><Text size="small" weight="medium">{item.label}</Text></td>
32
+ <td><CodeBlock code={item.value} inline /></td>
33
+ </tr>
34
+ {/snippet}
35
+ </DataTable>
36
+ <Stack direction="horizontal" gap="small" padding="medium">
37
+ <Text size="small" weight="medium">Identified as user:</Text>
38
+ {#if $sessionStore.isUser === true}
39
+ <Badge status="success" size="small">true</Badge>
40
+ {:else if $sessionStore.isUser === false}
41
+ <Badge status="default" size="small">false</Badge>
42
+ {:else}
43
+ <Badge status="default" size="small">unset</Badge>
44
+ {/if}
45
+ </Stack>
46
+ </Card>
47
+
48
+ <Card sectioned>
49
+ {#snippet header()}
50
+ <Text size="caption" weight="semibold" color="subdued">
51
+ IDENTIFIERS ({identifierEntries.length})
52
+ </Text>
53
+ {/snippet}
54
+ <DataTable columns={identifierColumns} rows={identifierEntries}>
55
+ {#snippet row(entry)}
56
+ <tr>
57
+ <td><CodeBlock code={entry[0]} inline /></td>
58
+ <td><CodeBlock code={entry[1]} inline /></td>
59
+ </tr>
60
+ {/snippet}
61
+ {#snippet empty()}
62
+ <EmptyState message="No identifiers set" />
63
+ {/snippet}
64
+ </DataTable>
65
+ </Card>
66
+ </Stack>