File tree Expand file tree Collapse file tree 1 file changed +32
-14
lines changed
packages/common/src/utils/analytics Expand file tree Collapse file tree 1 file changed +32
-14
lines changed Original file line number Diff line number Diff line change @@ -67,20 +67,38 @@ export const WHITELISTED_VSCODE_EVENTS = [
6767 'code-runner.run' ,
6868] ;
6969
70- export const DO_NOT_TRACK_ENABLED =
71- typeof window !== 'undefined' &&
72- Boolean (
73- // @ts -ignore
74- global . doNotTrack === '1' ||
75- // @ts -ignore
76- global . navigator . doNotTrack === '1' ||
77- // @ts -ignore
78- global . navigator . msDoNotTrack === '1' ||
79- ( typeof localStorage !== 'undefined' &&
80- localStorage . getItem ( 'DO_NOT_TRACK_ENABLED' ) ) ||
81- process . env . NODE_ENV === 'development' ||
82- process . env . STAGING
83- ) ;
70+ const isDoNotTrackEnabled = ( ) => {
71+ try {
72+ if ( typeof window !== 'undefined' ) {
73+ let localStorageValue = true ;
74+ try {
75+ localStorageValue =
76+ typeof localStorage !== 'undefined' &&
77+ localStorage . getItem ( 'DO_NOT_TRACK_ENABLED' ) === 'true' ;
78+ } catch ( e ) {
79+ /* ignore */
80+ }
81+
82+ return Boolean (
83+ // @ts -ignore
84+ global . doNotTrack === '1' ||
85+ // @ts -ignore
86+ global . navigator . doNotTrack === '1' ||
87+ // @ts -ignore
88+ global . navigator . msDoNotTrack === '1' ||
89+ localStorageValue ||
90+ process . env . NODE_ENV === 'development' ||
91+ process . env . STAGING
92+ ) ;
93+ }
94+
95+ return true ;
96+ } catch ( e ) {
97+ return false ;
98+ }
99+ } ;
100+
101+ export const DO_NOT_TRACK_ENABLED = isDoNotTrackEnabled ( ) ;
84102
85103export const isAllowedEvent = ( eventName , secondArg ) => {
86104 try {
You can’t perform that action at this time.
0 commit comments