File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -932,6 +932,16 @@ test.describe('site pages', () => {
932932 }
933933 } ) ;
934934
935+ test ( '?stats=off opts the browser out of Umami, and ?stats=on puts it back' , async ( { page } ) => {
936+ const flag = ( ) => page . evaluate ( ( ) => localStorage . getItem ( 'umami.disabled' ) ) ;
937+ await open ( page , { path : '/docs/?stats=off#stats' } ) ;
938+ await page . waitForURL ( / \/ d o c s \/ # s t a t s $ / ) ;
939+ expect ( await flag ( ) , 'off sets the key Umami checks before every send, and drops the param' ) . toBe ( '1' ) ;
940+ await open ( page , { path : '/?stats=on' } ) ;
941+ await page . waitForURL ( url => url . search === '' ) ;
942+ expect ( await flag ( ) , 'on clears it again' ) . toBeNull ( ) ;
943+ } ) ;
944+
935945 test ( 'the wordmark reports the load in the state color on light, and keeps its dot in ink on dark' , async ( {
936946 page,
937947 } ) => {
Original file line number Diff line number Diff line change @@ -1926,7 +1926,9 @@ <h3 id="contributing">Contributing</h3>
19261926 < h3 id ="stats "> Stats</ h3 >
19271927 < p >
19281928 The site counts visits with < a href ="https://umami.is/ "> Umami</ a > , plus which tell you pick, which install tab
1929- you open, and which palette you try. There are no cookies, and nothing in the totals identifies you.
1929+ you open, and which palette you try. There are no cookies, and nothing in the totals identifies you. To leave
1930+ yourself out, open < a href ="?stats=off#stats "> < code > ?stats=off</ code > </ a > once in each browser.
1931+ < a href ="?stats=on#stats "> < code > ?stats=on</ code > </ a > puts you back.
19301932 </ p >
19311933 </ section >
19321934 < section
Original file line number Diff line number Diff line change @@ -2,3 +2,14 @@ const PAGE = { '/': 'landing', '/docs/': 'docs' };
22
33export const track = ( name , data ) =>
44 window . umami ?. track ( name , { ...data , page : PAGE [ location . pathname ] ?? location . pathname } ) ;
5+
6+ const url = new URL ( location ) ;
7+ const stats = url . searchParams . get ( 'stats' ) ;
8+ if ( stats === 'off' || stats === 'on' ) {
9+ /* Umami's own opt-out: it checks this key before every send. */
10+ try {
11+ stats === 'off' ? localStorage . setItem ( 'umami.disabled' , '1' ) : localStorage . removeItem ( 'umami.disabled' ) ;
12+ } catch { }
13+ url . searchParams . delete ( 'stats' ) ;
14+ history . replaceState ( null , '' , url ) ;
15+ }
You can’t perform that action at this time.
0 commit comments