Skip to content

Commit

Permalink
Merge pull request #4306 from ethereum/matn
Browse files Browse the repository at this point in the history
matomo config
  • Loading branch information
yann300 authored Dec 6, 2023
2 parents f7d8f4d + 111f5e3 commit 073cbf8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
15 changes: 15 additions & 0 deletions apps/remix-ide/src/app/tabs/settings-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import * as packageJson from '../../../../../package.json'
import {RemixUiSettings} from '@remix-ui/settings' //eslint-disable-line
import Registry from '../state/registry'
import {PluginViewWrapper} from '@remix-ui/helper'
declare global {
interface Window {
_paq: any
}
}
const _paq = (window._paq = window._paq || [])

const profile = {
name: 'settings',
Expand Down Expand Up @@ -85,6 +91,15 @@ module.exports = class SettingsTab extends ViewPlugin {
updateMatomoAnalyticsChoice(isChecked) {
this.config.set('settings/matomo-analytics', isChecked)
this.useMatomoAnalytics = isChecked
if (!isChecked) {
_paq.push(['optUserOut'])
// revoke tracking consent
_paq.push(['forgetConsentGiven']);
} else {
_paq.push(['forgetUserOptOut'])
// user has given consent to process their data
_paq.push(['setConsentGiven']);
}
this.dispatch({
...this
})
Expand Down
14 changes: 10 additions & 4 deletions apps/remix-ide/src/assets/js/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,20 @@ if (domains[window.location.hostname]) {
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(["setExcludedQueryParams", ["code","gist"]]);
_paq.push(["setExcludedReferrers", ["etherscan.io"]]);
_paq.push(['disableCookies']);
_paq.push(['enableJSErrorTracking']);
// require user tracking consent before processing data
_paq.push(['requireConsent']);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
_paq.push(['enableHeartBeatTimer']);
if (!window.localStorage.getItem('config-v0.8:.remix.config') ||
(window.localStorage.getItem('config-v0.8:.remix.config') && !window.localStorage.getItem('config-v0.8:.remix.config').includes('settings/matomo-analytics'))) {
_paq.push(['optUserOut'])

} else {
_paq.push(['forgetUserOptOut'])
// user has given consent to process their data
_paq.push(['setConsentGiven'])
}
(function () {
var u = "https://ethereumfoundation.matomo.cloud/";
Expand All @@ -38,17 +44,17 @@ if (domains[window.location.hostname]) {
function isElectron() {
// Renderer process
if (typeof window !== 'undefined' && typeof window.process === 'object' && window.process.type === 'renderer') {
return true
return true
}

// Main process
if (typeof process !== 'undefined' && typeof process.versions === 'object' && !!process.versions.electron) {
return true
return true
}

// Detect the user agent when the `nodeIntegration` option is set to false
if (typeof navigator === 'object' && typeof navigator.userAgent === 'string' && navigator.userAgent.indexOf('Electron') >= 0) {
return true
return true
}

return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,15 @@ const MatomoDialog = (props) => {
const declineModal = async () => {
settings.updateMatomoAnalyticsChoice(false)
_paq.push(['optUserOut'])
// revoke tracking consent
_paq.push(['forgetConsentGiven']);
setVisible(false)
}

const handleModalOkClick = async () => {
_paq.push(['forgetUserOptOut'])
// user has given consent to process their data
_paq.push(['setConsentGiven']);
settings.updateMatomoAnalyticsChoice(true)
setVisible(false)
}
Expand Down

0 comments on commit 073cbf8

Please sign in to comment.