@@ -36,6 +36,7 @@ export default class SettingsTab extends ViewPlugin {
36
36
}
37
37
element : HTMLDivElement
38
38
public useMatomoAnalytics : any
39
+ public useMatomoPerfAnalytics : any
39
40
public useCopilot : any
40
41
dispatch : React . Dispatch < any > = ( ) => { }
41
42
constructor ( config , editor ) {
@@ -52,6 +53,7 @@ export default class SettingsTab extends ViewPlugin {
52
53
this . element = document . createElement ( 'div' )
53
54
this . element . setAttribute ( 'id' , 'settingsTab' )
54
55
this . useMatomoAnalytics = null
56
+ this . useMatomoPerfAnalytics = null
55
57
this . useCopilot = this . get ( 'settings/copilot/suggest/activate' )
56
58
}
57
59
@@ -123,4 +125,21 @@ export default class SettingsTab extends ViewPlugin {
123
125
...this
124
126
} )
125
127
}
128
+
129
+ updateMatomoPerfAnalyticsChoice ( isChecked ) {
130
+ this . config . set ( 'settings/matomo-perf-analytics' , isChecked )
131
+ // set timestamp to local storage to track when the user has given consent
132
+ localStorage . setItem ( 'matomo-perf-analytics-consent' , Date . now ( ) . toString ( ) )
133
+ this . useMatomoPerfAnalytics = isChecked
134
+ if ( ! isChecked ) {
135
+ // revoke tracking consent , need to be updated
136
+ _paq . push ( [ 'forgetConsentGiven' ] ) ;
137
+ } else {
138
+ // user has given consent to process their data, need to be updated
139
+ _paq . push ( [ 'setConsentGiven' ] ) ;
140
+ }
141
+ this . dispatch ( {
142
+ ...this
143
+ } )
144
+ }
126
145
}
0 commit comments