Skip to content

Commit 8c03bdc

Browse files
committed
feat: implement auto-trigger for sample data prompt via ?demo URL param
1 parent 4315c60 commit 8c03bdc

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

src/components/InsightsSidebar.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useCallback } from 'react';
1+
import React, { useState, useCallback, useEffect } from 'react';
22
import {
33
ActionMenu,
44
ActionList,
@@ -97,6 +97,25 @@ export function InsightsSidebar({
9797
}
9898
}, [addReport, onboarding]);
9999

100+
// Auto-trigger sample data prompt via ?demo URL param
101+
useEffect(() => {
102+
const params = new URLSearchParams(window.location.search);
103+
if (!params.has('demo')) return;
104+
if (reports.length > 0) return;
105+
106+
// ?demo=auto skips the prompt and loads immediately
107+
if (params.get('demo') === 'auto') {
108+
handleLoadSamples();
109+
} else {
110+
setShowSamplePrompt(true);
111+
}
112+
// Clean the param from URL so refresh doesn't re-trigger
113+
params.delete('demo');
114+
const clean = params.toString();
115+
const url = window.location.pathname + (clean ? `?${clean}` : '');
116+
window.history.replaceState({}, '', url);
117+
}, []); // eslint-disable-line react-hooks/exhaustive-deps
118+
100119
return (
101120
<div className={styles.sidebarContent}>
102121
<div className={styles.sidebarHeader}>

0 commit comments

Comments
 (0)