diff --git a/apps/remix-ide/src/app.ts b/apps/remix-ide/src/app.ts index 6f524ae840e..184c044f1a7 100644 --- a/apps/remix-ide/src/app.ts +++ b/apps/remix-ide/src/app.ts @@ -71,7 +71,7 @@ import { HardhatHandleDesktop } from './app/plugins/electron/hardhatPlugin' import { circomPlugin } from './app/plugins/electron/circomElectronPlugin' import { GitHubAuthHandler } from './app/plugins/electron/gitHubAuthHandler' import { GitPlugin } from './app/plugins/git' -import { Matomo } from './app/plugins/matomo' +import type { Matomo } from './app/plugins/matomo' import { DesktopClient } from './app/plugins/desktop-client' import { DesktopHost } from './app/plugins/electron/desktopHostPlugin' import { WalletConnect } from './app/plugins/walletconnect' @@ -160,7 +160,9 @@ class AppComponent { settings: SettingsTab params: any desktopClientMode: boolean - constructor() { + matomo: Matomo + constructor(matomo: Matomo) { + this.matomo = matomo const PlatFormAPi = new platformApi() Registry.getInstance().put({ api: PlatFormAPi, @@ -307,9 +309,6 @@ class AppComponent { //---- git const git = new GitPlugin() - //---- matomo - const matomo = new Matomo() - //---------------- Solidity UML Generator ------------------------- const solidityumlgen = new SolidityUmlGen(appManager) @@ -454,7 +453,7 @@ class AppComponent { templates, git, pluginStateLogger, - matomo, + this.matomo, templateSelection, scriptRunnerUI, remixAI, diff --git a/apps/remix-ide/src/app/components/preload.tsx b/apps/remix-ide/src/app/components/preload.tsx index 16f2d08cd8b..64660aefafe 100644 --- a/apps/remix-ide/src/app/components/preload.tsx +++ b/apps/remix-ide/src/app/components/preload.tsx @@ -8,7 +8,12 @@ import { localStorageFS } from '../files/filesystems/localStorage' import { fileSystemUtility, migrationTestData } from '../files/filesystems/fileSystemUtility' import './styles/preload.css' import isElectron from 'is-electron' +import { Matomo } from '../plugins/matomo' + const _paq = (window._paq = window._paq || []) +const matomo = new Matomo(_paq) + +window._paq = matomo // _paq.push(['trackEvent', 'App', 'Preload', 'start']) @@ -34,13 +39,13 @@ export const Preload = (props: any) => { function loadAppComponent() { import('../../app') .then((AppComponent) => { - const appComponent = new AppComponent.default() + const appComponent = new AppComponent.default(matomo) appComponent.run().then(() => { props.root.render() }) }) .catch((err) => { - _paq.push(['trackEvent', 'App', 'PreloadError', err && err.message]) + window._paq.push(['trackEvent', 'App', 'PreloadError', err && err.message]) console.error('Error loading Remix:', err) setError(true) }) @@ -57,7 +62,7 @@ export const Preload = (props: any) => { setShowDownloader(false) const fsUtility = new fileSystemUtility() const migrationResult = await fsUtility.migrate(localStorageFileSystem.current, remixIndexedDB.current) - _paq.push(['trackEvent', 'Migrate', 'result', migrationResult ? 'success' : 'fail']) + window._paq.push(['trackEvent', 'Migrate', 'result', migrationResult ? 'success' : 'fail']) await setFileSystems() } @@ -68,10 +73,10 @@ export const Preload = (props: any) => { ]) if (fsLoaded) { console.log(fsLoaded.name + ' activated') - _paq.push(['trackEvent', 'Storage', 'activate', fsLoaded.name]) + window._paq.push(['trackEvent', 'Storage', 'activate', fsLoaded.name]) loadAppComponent() } else { - _paq.push(['trackEvent', 'Storage', 'error', 'no supported storage']) + window._paq.push(['trackEvent', 'Storage', 'error', 'no supported storage']) setSupported(false) } } @@ -89,8 +94,8 @@ export const Preload = (props: any) => { return } async function loadStorage() { - ;(await remixFileSystems.current.addFileSystem(remixIndexedDB.current)) || _paq.push(['trackEvent', 'Storage', 'error', 'indexedDB not supported']) - ;(await remixFileSystems.current.addFileSystem(localStorageFileSystem.current)) || _paq.push(['trackEvent', 'Storage', 'error', 'localstorage not supported']) + ;(await remixFileSystems.current.addFileSystem(remixIndexedDB.current)) || window._paq.push(['trackEvent', 'Storage', 'error', 'indexedDB not supported']) + ;(await remixFileSystems.current.addFileSystem(localStorageFileSystem.current)) || window._paq.push(['trackEvent', 'Storage', 'error', 'localstorage not supported']) await testmigration() remixIndexedDB.current.loaded && (await remixIndexedDB.current.checkWorkspaces()) localStorageFileSystem.current.loaded && (await localStorageFileSystem.current.checkWorkspaces()) diff --git a/apps/remix-ide/src/app/plugins/matomo.ts b/apps/remix-ide/src/app/plugins/matomo.ts index 40c61e718e7..21827dfec74 100644 --- a/apps/remix-ide/src/app/plugins/matomo.ts +++ b/apps/remix-ide/src/app/plugins/matomo.ts @@ -1,8 +1,6 @@ 'use strict' import { Plugin } from '@remixproject/engine' -const _paq = window._paq = window._paq || [] - const profile = { name: 'matomo', description: 'send analytics to Matomo', @@ -14,13 +12,19 @@ const profile = { const allowedPlugins = ['LearnEth', 'etherscan', 'vyper', 'circuit-compiler', 'doc-gen', 'doc-viewer', 'solhint', 'walletconnect', 'scriptRunner', 'scriptRunnerBridge', 'dgit', 'contract-verification', 'noir-compiler'] export class Matomo extends Plugin { + _paq: { push: (data: string[]) => void } - constructor() { + constructor(_paq: { push: (data: string[]) => void }) { super(profile) + this._paq = _paq } async track(data: string[]) { - if (!allowedPlugins.includes(this.currentRequest.from)) return - _paq.push(data) + this._paq.push(data) + } + + push(data: string[]) { + console.log('data coming through matomo plugin:', ...data) + this._paq.push(data) } } \ No newline at end of file diff --git a/apps/remix-ide/src/assets/js/loader.js b/apps/remix-ide/src/assets/js/loader.js index 3d591f4ad4a..010f13ab64d 100644 --- a/apps/remix-ide/src/assets/js/loader.js +++ b/apps/remix-ide/src/assets/js/loader.js @@ -8,7 +8,7 @@ const domainsOnPrem = { 'alpha.remix.live': 1, 'beta.remix.live': 2, 'remix.ethereum.org': 3, - 'localhost': 4 // remix desktop + 'localhost': isElectron() ? 4 : 1, // remix desktop } let cloudDomainToTrack = domains[window.location.hostname]