File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import React , { useState , useCallback } from 'react' ;
1+ import React , { useState , useCallback , useEffect } from 'react' ;
22import {
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 } >
You can’t perform that action at this time.
0 commit comments