From 2289172f6813dec341c816139c68fda863650e74 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Fri, 5 Jul 2024 08:23:50 +0200 Subject: [PATCH] add matomo plugin --- apps/remix-ide/src/app.js | 10 +++++++-- apps/remix-ide/src/app/plugins/matomo.ts | 26 ++++++++++++++++++++++++ apps/remix-ide/src/remixAppManager.js | 3 ++- 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 apps/remix-ide/src/app/plugins/matomo.ts diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index b59568e70b..3e0eacdeb0 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -56,6 +56,7 @@ import { xtermPlugin } from './app/plugins/electron/xtermPlugin' import { ripgrepPlugin } from './app/plugins/electron/ripgrepPlugin' import { compilerLoaderPlugin, compilerLoaderPluginDesktop } from './app/plugins/electron/compilerLoaderPlugin' import { GitPlugin } from './app/plugins/git' +import { Matomo } from './app/plugins/matomo' import {SolCoder} from './app/plugins/solcoderAI' @@ -223,6 +224,9 @@ class AppComponent { //---- git const git = new GitPlugin() + //---- matomo + const matomo = new Matomo() + //---------------- Solidity UML Generator ------------------------- const solidityumlgen = new SolidityUmlGen(appManager) @@ -357,7 +361,8 @@ class AppComponent { templates, solcoder, git, - pluginStateLogger + pluginStateLogger, + matomo ]) //---- fs plugin @@ -476,7 +481,8 @@ class AppComponent { 'network', 'web3Provider', 'offsetToLineColumnConverter', - 'pluginStateLogger' + 'pluginStateLogger', + 'matomo' ]) await this.appManager.activatePlugin(['mainPanel', 'menuicons', 'tabs']) await this.appManager.activatePlugin(['statusBar']) diff --git a/apps/remix-ide/src/app/plugins/matomo.ts b/apps/remix-ide/src/app/plugins/matomo.ts new file mode 100644 index 0000000000..9495d1ddd7 --- /dev/null +++ b/apps/remix-ide/src/app/plugins/matomo.ts @@ -0,0 +1,26 @@ +'use strict' +import { Plugin } from '@remixproject/engine' + +const _paq = window._paq = window._paq || [] + +const profile = { + name: 'matomo', + description: 'send analytics to Matomo', + methods: ['track'], + events: [''], + version: '1.0.0' +} + +const allowedPlugins = ['LearnEth', 'etherscan', 'vyper', 'circuit-compiler', 'doc-gen', 'doc-viewer', 'solhint', 'walletconnect', 'scriptRunner'] + +export class Matomo extends Plugin { + + constructor() { + super(profile) + } + + async track(data: string[]) { + if (!allowedPlugins.includes(this.currentRequest.from)) return + _paq.push(data) + } +} \ No newline at end of file diff --git a/apps/remix-ide/src/remixAppManager.js b/apps/remix-ide/src/remixAppManager.js index d430d678d7..20b69d984f 100644 --- a/apps/remix-ide/src/remixAppManager.js +++ b/apps/remix-ide/src/remixAppManager.js @@ -81,7 +81,8 @@ let requiredModules = [ // services + layout views + system views 'dgit', 'pinnedPanel', 'pluginStateLogger', - 'remixGuide' + 'remixGuide', + 'matomo' ]