1- import React from 'react' ;
1+ import React , { useEffect } from 'react' ;
22import 'react-loading-skeleton/dist/skeleton.css' ;
33import type { Preview } from '@storybook/react-vite' ;
44
@@ -16,11 +16,35 @@ const GlobalStyles = createGlobalStyle`
1616const preview : Preview = {
1717 // tags: ['autodocs'], // turn on when fix some components stories
1818 decorators : [
19- ( Story ) => (
20- < ThemeProvider theme = { themeConfig } >
21- < Story />
22- </ ThemeProvider >
23- ) ,
19+ ( Story ) => {
20+ useEffect ( ( ) => {
21+ // Google Analytics tracking code
22+ const script = document . createElement ( 'script' ) ;
23+ script . async = true ;
24+ script . src = 'https://www.googletagmanager.com/gtag/js?id=G-H4X1J4017T' ; // Replace with your GA4 Measurement ID
25+ document . head . appendChild ( script ) ;
26+
27+ script . onload = ( ) => {
28+ window . dataLayer = window . dataLayer || [ ] ;
29+ function gtag ( ) {
30+ dataLayer . push ( arguments ) ;
31+ }
32+ gtag ( 'js' , new Date ( ) ) ;
33+ gtag ( 'config' , 'G-H4X1J4017T' ) ; // Replace with your GA4 Measurement ID
34+ } ;
35+
36+ return ( ) => {
37+ // Optional: Clean up the script if needed
38+ document . head . removeChild ( script ) ;
39+ } ;
40+ } , [ ] ) ;
41+
42+ return (
43+ < ThemeProvider theme = { themeConfig } >
44+ < Story />
45+ </ ThemeProvider >
46+ ) ;
47+ } ,
2448 withThemeFromJSXProvider ( {
2549 themes : {
2650 light : themeConfig . light ,
0 commit comments