Skip to content

Commit 97ec213

Browse files
committed
Use _paq
1 parent 3c10d9a commit 97ec213

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

apps/remix-ide/src/app.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ import { HardhatHandleDesktop } from './app/plugins/electron/hardhatPlugin'
7171
import { circomPlugin } from './app/plugins/electron/circomElectronPlugin'
7272
import { GitHubAuthHandler } from './app/plugins/electron/gitHubAuthHandler'
7373
import { GitPlugin } from './app/plugins/git'
74-
import { Matomo } from './app/plugins/matomo'
74+
import type { Matomo } from './app/plugins/matomo'
7575
import { DesktopClient } from './app/plugins/desktop-client'
7676
import { DesktopHost } from './app/plugins/electron/desktopHostPlugin'
7777
import { WalletConnect } from './app/plugins/walletconnect'
@@ -112,6 +112,8 @@ import TabProxy from './app/panels/tab-proxy.js'
112112
import { Plugin } from '@remixproject/engine'
113113
import BottomBarPanel from './app/components/bottom-bar-panel'
114114

115+
const _paq = (window._paq = window._paq || [])
116+
115117
export class platformApi {
116118
get name() {
117119
return isElectron() ? appPlatformTypes.desktop : appPlatformTypes.web
@@ -217,7 +219,7 @@ class AppComponent {
217219
this.workspace = pluginLoader.get()
218220
if (pluginLoader.current === 'queryParams') {
219221
this.workspace.map((workspace) => {
220-
this.matomo.push(['trackEvent', 'App', 'queryParams-activated', workspace])
222+
_paq.push(['trackEvent', 'App', 'queryParams-activated', workspace])
221223
})
222224
}
223225
this.engine = new RemixEngine()
@@ -246,7 +248,7 @@ class AppComponent {
246248
this.showMatomo = contextShouldShowMatomo && (!this.matomoConfAlreadySet || shouldRenewConsent)
247249

248250
if (this.showMatomo && shouldRenewConsent) {
249-
this.matomo.push(['trackEvent', 'Matomo', 'refreshMatomoPermissions']);
251+
_paq.push(['trackEvent', 'Matomo', 'refreshMatomoPermissions']);
250252
}
251253

252254
this.walkthroughService = new WalkthroughService(appManager)
@@ -682,7 +684,7 @@ class AppComponent {
682684
if (callDetails.length > 1) {
683685
this.appManager.call('notification', 'toast', `initiating ${callDetails[0]} and calling "${callDetails[1]}" ...`)
684686
// @todo(remove the timeout when activatePlugin is on 0.3.0)
685-
this.matomo.push(['trackEvent', 'App', 'queryParams-calls', this.params.call])
687+
_paq.push(['trackEvent', 'App', 'queryParams-calls', this.params.call])
686688
//@ts-ignore
687689
await this.appManager.call(...callDetails).catch(console.error)
688690
}
@@ -693,7 +695,7 @@ class AppComponent {
693695

694696
// call all functions in the list, one after the other
695697
for (const call of calls) {
696-
this.matomo.push(['trackEvent', 'App', 'queryParams-calls', call])
698+
_paq.push(['trackEvent', 'App', 'queryParams-calls', call])
697699
const callDetails = call.split('//')
698700
if (callDetails.length > 1) {
699701
this.appManager.call('notification', 'toast', `initiating ${callDetails[0]} and calling "${callDetails[1]}" ...`)

apps/remix-ide/src/app/components/preload.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const Preload = (props: any) => {
4545
})
4646
})
4747
.catch((err) => {
48-
matomo.push(['trackEvent', 'App', 'PreloadError', err && err.message])
48+
window._paq.push(['trackEvent', 'App', 'PreloadError', err && err.message])
4949
console.error('Error loading Remix:', err)
5050
setError(true)
5151
})
@@ -62,7 +62,7 @@ export const Preload = (props: any) => {
6262
setShowDownloader(false)
6363
const fsUtility = new fileSystemUtility()
6464
const migrationResult = await fsUtility.migrate(localStorageFileSystem.current, remixIndexedDB.current)
65-
_paq.push(['trackEvent', 'Migrate', 'result', migrationResult ? 'success' : 'fail'])
65+
window._paq.push(['trackEvent', 'Migrate', 'result', migrationResult ? 'success' : 'fail'])
6666
await setFileSystems()
6767
}
6868

@@ -73,10 +73,10 @@ export const Preload = (props: any) => {
7373
])
7474
if (fsLoaded) {
7575
console.log(fsLoaded.name + ' activated')
76-
matomo.push(['trackEvent', 'Storage', 'activate', fsLoaded.name])
76+
window._paq.push(['trackEvent', 'Storage', 'activate', fsLoaded.name])
7777
loadAppComponent()
7878
} else {
79-
matomo.push(['trackEvent', 'Storage', 'error', 'no supported storage'])
79+
window._paq.push(['trackEvent', 'Storage', 'error', 'no supported storage'])
8080
setSupported(false)
8181
}
8282
}
@@ -94,8 +94,8 @@ export const Preload = (props: any) => {
9494
return
9595
}
9696
async function loadStorage() {
97-
;(await remixFileSystems.current.addFileSystem(remixIndexedDB.current)) || matomo.push(['trackEvent', 'Storage', 'error', 'indexedDB not supported'])
98-
;(await remixFileSystems.current.addFileSystem(localStorageFileSystem.current)) || matomo.push(['trackEvent', 'Storage', 'error', 'localstorage not supported'])
97+
;(await remixFileSystems.current.addFileSystem(remixIndexedDB.current)) || window._paq.push(['trackEvent', 'Storage', 'error', 'indexedDB not supported'])
98+
;(await remixFileSystems.current.addFileSystem(localStorageFileSystem.current)) || window._paq.push(['trackEvent', 'Storage', 'error', 'localstorage not supported'])
9999
await testmigration()
100100
remixIndexedDB.current.loaded && (await remixIndexedDB.current.checkWorkspaces())
101101
localStorageFileSystem.current.loaded && (await localStorageFileSystem.current.checkWorkspaces())

apps/remix-ide/src/app/plugins/matomo.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export class Matomo extends Plugin {
2020
}
2121

2222
async track(data: string[]) {
23-
if (!allowedPlugins.includes(this.currentRequest.from)) return
2423
this._paq.push(data)
2524
}
2625

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const domainsOnPrem = {
88
'alpha.remix.live': 1,
99
'beta.remix.live': 2,
1010
'remix.ethereum.org': 3,
11-
'localhost': 4 // remix desktop
11+
'localhost': isElectron() ? 4 : 1, // remix desktop
1212
}
1313

1414
let cloudDomainToTrack = domains[window.location.hostname]

0 commit comments

Comments
 (0)