Skip to content

Commit f472eca

Browse files
authored
Merge pull request #6117 from ethereum/fix_matomo_3
Fix using matomo api
2 parents 632c72f + c102580 commit f472eca

File tree

7 files changed

+21
-46
lines changed

7 files changed

+21
-46
lines changed

apps/remix-ide-e2e/src/tests/matomo.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ module.exports = {
7676
browser.execute(function () {
7777
localStorage.removeItem('config-v0.8:.remix.config')
7878
localStorage.setItem('showMatomo', 'true')
79-
localStorage.removeItem('matomo-perf-analytics-consent')
79+
localStorage.removeItem('matomo-analytics-consent')
8080
}, [])
8181
.refreshPage()
8282
.perform(done())
@@ -137,7 +137,7 @@ module.exports = {
137137
browser.execute(function () {
138138
const oldTimestamp = new Date()
139139
oldTimestamp.setMonth(oldTimestamp.getMonth() - 7)
140-
localStorage.setItem('matomo-perf-analytics-consent', oldTimestamp.getTime().toString())
140+
localStorage.setItem('matomo-analytics-consent', oldTimestamp.getTime().toString())
141141
}, [])
142142
.refreshPage()
143143
.perform(done())
@@ -149,7 +149,7 @@ module.exports = {
149149
})
150150
.execute(function () {
151151

152-
const timestamp = window.localStorage.getItem('matomo-perf-analytics-consent');
152+
const timestamp = window.localStorage.getItem('matomo-analytics-consent');
153153
if (timestamp) {
154154

155155
const consentDate = new Date(Number(timestamp));
@@ -179,15 +179,15 @@ module.exports = {
179179
browser.execute(function () {
180180
const recentTimestamp = new Date()
181181
recentTimestamp.setMonth(recentTimestamp.getMonth() - 1)
182-
localStorage.setItem('matomo-perf-analytics-consent', recentTimestamp.getTime().toString())
182+
localStorage.setItem('matomo-analytics-consent', recentTimestamp.getTime().toString())
183183
}, [])
184184
.refreshPage()
185185
.perform(done())
186186
})
187187
// check if timestamp is younger than 6 months
188188
.execute(function () {
189189

190-
const timestamp = window.localStorage.getItem('matomo-perf-analytics-consent');
190+
const timestamp = window.localStorage.getItem('matomo-analytics-consent');
191191
if (timestamp) {
192192

193193
const consentDate = new Date(Number(timestamp));
@@ -221,7 +221,7 @@ module.exports = {
221221
browser.execute(function () {
222222
localStorage.removeItem('config-v0.8:.remix.config')
223223
localStorage.setItem('showMatomo', 'true')
224-
localStorage.removeItem('matomo-perf-analytics-consent')
224+
localStorage.removeItem('matomo-analytics-consent')
225225
}, [])
226226
.refreshPage()
227227
.perform(done())
@@ -237,7 +237,7 @@ module.exports = {
237237
.pause(2000)
238238
.execute(function () {
239239

240-
const timestamp = window.localStorage.getItem('matomo-perf-analytics-consent');
240+
const timestamp = window.localStorage.getItem('matomo-analytics-consent');
241241
if (timestamp) {
242242

243243
const consentDate = new Date(Number(timestamp));
@@ -263,7 +263,7 @@ module.exports = {
263263
browser.execute(function () {
264264
const oldTimestamp = new Date()
265265
oldTimestamp.setMonth(oldTimestamp.getMonth() - 7)
266-
localStorage.setItem('matomo-perf-analytics-consent', oldTimestamp.getTime().toString())
266+
localStorage.setItem('matomo-analytics-consent', oldTimestamp.getTime().toString())
267267
}, [])
268268
.refreshPage()
269269
.perform(done())
@@ -281,7 +281,7 @@ module.exports = {
281281
browser.execute(function () {
282282
const recentTimestamp = new Date()
283283
recentTimestamp.setMonth(recentTimestamp.getMonth() - 1)
284-
localStorage.setItem('matomo-perf-analytics-consent', recentTimestamp.getTime().toString())
284+
localStorage.setItem('matomo-analytics-consent', recentTimestamp.getTime().toString())
285285
}, [])
286286
.refreshPage()
287287
.perform(done())
@@ -300,7 +300,7 @@ module.exports = {
300300
localStorage.removeItem('config-v0.8:.remix.config')
301301
const recentTimestamp = new Date()
302302
recentTimestamp.setMonth(recentTimestamp.getMonth() - 1)
303-
localStorage.setItem('matomo-perf-analytics-consent', recentTimestamp.getTime().toString())
303+
localStorage.setItem('matomo-analytics-consent', recentTimestamp.getTime().toString())
304304
}, [])
305305
.refreshPage()
306306
.perform(done())
@@ -315,7 +315,7 @@ module.exports = {
315315
localStorage.removeItem('config-v0.8:.remix.config')
316316
const oldTimestamp = new Date()
317317
oldTimestamp.setMonth(oldTimestamp.getMonth() - 7)
318-
localStorage.setItem('matomo-perf-analytics-consent', oldTimestamp.getTime().toString())
318+
localStorage.setItem('matomo-analytics-consent', oldTimestamp.getTime().toString())
319319
}, [])
320320
.refreshPage()
321321
.perform(done())

apps/remix-ide/src/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ class AppComponent {
226226

227227
const electronTracking = (window as any).electronAPI ? await (window as any).electronAPI.canTrackMatomo() : false
228228

229-
const lastMatomoCheck = window.localStorage.getItem('matomo-perf-analytics-consent')
229+
const lastMatomoCheck = window.localStorage.getItem('matomo-analytics-consent')
230230
const sixMonthsAgo = new Date();
231231
sixMonthsAgo.setMonth(sixMonthsAgo.getMonth() - 6);
232232

apps/remix-ide/src/app/tabs/settings-tab.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,14 @@ export default class SettingsTab extends ViewPlugin {
129129
updateMatomoPerfAnalyticsChoice(isChecked) {
130130
this.config.set('settings/matomo-perf-analytics', isChecked)
131131
// set timestamp to local storage to track when the user has given consent
132-
localStorage.setItem('matomo-perf-analytics-consent', Date.now().toString())
132+
localStorage.setItem('matomo-analytics-consent', Date.now().toString())
133133
this.useMatomoPerfAnalytics = isChecked
134134
if (!isChecked) {
135135
// revoke tracking consent for performance data
136-
_paq.push(['forgetMatomoPerfConsentGiven'])
136+
_paq.push(['disableCookies'])
137137
} else {
138138
// user has given consent to process their performance data
139-
_paq.push(['setMatomoPerfConsentGiven'])
139+
_paq.push(['setCookieConsentGiven'])
140140
}
141141
this.dispatch({
142142
...this

apps/remix-ide/src/assets/js/loader.js

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,8 @@ function trackDomain(domainToTrack) {
1818
_paq.push(['trackPageView']);
1919
_paq.push(['enableLinkTracking']);
2020
_paq.push(['enableHeartBeatTimer']);
21-
const remixConfig = window.localStorage.getItem('config-v0.8:.remix.config');
22-
if (!remixConfig || (remixConfig && !remixConfig.includes('settings/matomo-analytics'))) {
23-
// require user tracking consent before processing data
24-
_paq.push(['requireConsent']);
25-
} else {
26-
try {
27-
const config = JSON.parse(remixConfig);
28-
if (config['settings/matomo-analytics'] === true) {
29-
// user has given consent to process their data
30-
_paq.push(['setConsentGiven']);
31-
} else {
32-
// user has not given consent to process their data
33-
_paq.push(['requireConsent']);
34-
}
35-
} catch (e) {
36-
console.error('Error parsing remix config:', e);
37-
_paq.push(['requireConsent']);
38-
}
39-
}
21+
_paq.push(['setConsentGiven']);
22+
_paq.push(['requireCookieConsent']);
4023
_paq.push(['trackEvent', 'loader', 'load']);
4124
(function () {
4225
var u = "https://ethereumfoundation.matomo.cloud/";

libs/remix-ui/app/src/lib/remix-app/components/modals/managePreferences.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,6 @@ const ManagePreferencesDialog = (props) => {
117117
_paq.push(['setConsentGiven']) // default consent to process their anonymous data
118118
settings.updateMatomoAnalyticsChoice(true) // Always true for matomo Anonymous analytics
119119
settings.updateMatomoPerfAnalyticsChoice(switcherState.current.matPerfSwitch) // Enable/Disable Matomo Performance analytics
120-
if (switcherState.current.matPerfSwitch) {
121-
// user has given consent to process their performance data
122-
_paq.push(['setMatomoPerfConsentGiven'])
123-
} else {
124-
// revoke tracking consent for performance data
125-
_paq.push(['forgetMatomoPerfConsentGiven'])
126-
}
127120
settings.updateCopilotChoice(switcherState.current.remixAISwitch) // Enable/Disable RemixAI copilot
128121
setVisible(false)
129122
props.savePreferencesFn()

libs/remix-ui/app/src/lib/remix-app/components/modals/matomo.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ const MatomoDialog = (props: MatomoDialogProps) => {
6666
}, [visible])
6767

6868
const handleAcceptAllClick = async () => {
69-
_paq.push(['setConsentGiven']) // default consent to process their anonymous data
70-
_paq.push(['setMatomoPerfConsentGiven']) // user has given consent to process their performance data
7169
settings.updateMatomoAnalyticsChoice(true) // Enable Matomo Anonymous analytics
7270
settings.updateMatomoPerfAnalyticsChoice(true) // Enable Matomo Performance analytics
7371
settings.updateCopilotChoice(true) // Enable RemixAI copilot

libs/remix-ui/settings/src/lib/settingsAction.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,15 @@ export const copilotTemperature = (config, checked, dispatch) => {
4141

4242
export const useMatomoPerfAnalytics = (config, checked, dispatch) => {
4343
config.set('settings/matomo-perf-analytics', checked)
44-
localStorage.setItem('matomo-perf-analytics-consent', Date.now().toString())
44+
localStorage.setItem('matomo-analytics-consent', Date.now().toString())
4545
dispatch({ type: 'useMatomoPerfAnalytics', payload: { isChecked: checked, textClass: checked ? textDark : textSecondary } })
4646
if (checked) {
4747
// user has given consent to process their performance data
48-
_paq.push(['setMatomoPerfConsentGiven'])
48+
_paq.push(['setCookieConsentGiven'])
49+
4950
} else {
5051
// revoke tracking consent for performance data
51-
_paq.push(['forgetMatomoPerfConsentGiven'])
52+
_paq.push(['disableCookies'])
5253
}
5354
}
5455

0 commit comments

Comments
 (0)