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 { ListLayout } from "@/components/AwesomeArcadeList/listLayout" ;
2+
13export namespace AnalyticEvents {
24 export function sendAwesomeClick ( type : "extension" | "tool" , repo : string ) {
35 window . gtag ( "event" , "click_awesome" , {
@@ -36,7 +38,12 @@ export namespace AnalyticEvents {
3638 theme : "light" | "dark" | "auto light" | "auto dark" ,
3739 ) {
3840 // https://ithoughthecamewithyou.com/post/user-scoped-custom-dimensions-in-google-analytics-4-using-gtag
39- // console.log(`Setting user preferred theme to ${theme}`);
41+ console . log ( `Setting user preferred theme to ${ theme } ` ) ;
4042 window . gtag ( "set" , "user_properties" , { theme : theme } ) ;
4143 }
44+
45+ export function setUserPreferredLayout ( layout : ListLayout ) {
46+ console . log ( `Setting user preferred layout to ${ layout } ` ) ;
47+ window . gtag ( "set" , "user_properties" , { layout : layout } ) ;
48+ }
4249}
Original file line number Diff line number Diff line change 11import React from "react" ;
2+ import { AnalyticEvents } from "@/components/Analytics/specific" ;
23
34const ListLayouts = [ "masonry" , "grid" , "github" ] as const ;
45export type ListLayout = ( typeof ListLayouts ) [ number ] ;
@@ -28,12 +29,10 @@ export default function NavbarDropdownListLayoutPicker({
2829 const [ layout , setLayout ] = React . useState < ListLayout > ( "masonry" ) ;
2930
3031 React . useEffect ( ( ) => {
31- const l = window . localStorage . getItem ( "listLayout" ) ;
32- if ( l ) {
33- setLayout ( l as ListLayout ) ;
34- } else {
35- setLayout ( "masonry" ) ;
36- }
32+ const l = ( window . localStorage . getItem ( "listLayout" ) ??
33+ "masonry" ) as ListLayout ;
34+ setLayout ( l ) ;
35+ AnalyticEvents . setUserPreferredLayout ( l ) ;
3736 // eslint-disable-next-line react-hooks/exhaustive-deps
3837 } , [ ] ) ;
3938
You can’t perform that action at this time.
0 commit comments