File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
apps/dashboard/app/(main)/websites/[id]/_components/tabs Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -130,10 +130,27 @@ export function WebsiteTrackingSetupTab({ websiteId }: WebsiteDataTabProps) {
130130 } ;
131131
132132 const utils = trpc . useUtils ( ) ;
133+ const { refetch : refetchTrackingSetup } = trpc . websites . isTrackingSetup . useQuery (
134+ { websiteId } ,
135+ { enabled : ! ! websiteId }
136+ ) ;
133137
134- const handleRefresh = ( ) => {
135- utils . websites . isTrackingSetup . invalidate ( { websiteId } ) ;
138+ const handleRefresh = async ( ) => {
136139 toast . success ( 'Checking tracking status...' ) ;
140+
141+ try {
142+ await utils . websites . isTrackingSetup . invalidate ( { websiteId } ) ;
143+ const result = await refetchTrackingSetup ( ) ;
144+
145+ if ( result . data ?. tracking_setup ) {
146+ toast . success ( 'Tracking setup correctly! Data is being collected.' ) ;
147+ } else {
148+ toast . error ( 'Tracking not found. Please verify the script installation.' ) ;
149+ }
150+ } catch ( error ) {
151+ console . error ( 'Failed to check tracking status:' , error ) ;
152+ toast . error ( 'Failed to check tracking status. Please try again.' ) ;
153+ }
137154 } ;
138155
139156 return (
You can’t perform that action at this time.
0 commit comments