add tracker

pull/4837/head
filip mertens 6 months ago
parent 53507972ad
commit 45dcad1367
  1. 3
      apps/remixdesktop/package.json
  2. 5
      apps/remixdesktop/src/main.ts
  3. 3
      apps/remixdesktop/src/plugins/appUpdater.ts
  4. 41
      apps/remixdesktop/src/plugins/fsPlugin.ts
  5. 33
      apps/remixdesktop/src/utils/matamo.ts
  6. 5
      apps/remixdesktop/yarn.lock

@ -1,6 +1,6 @@
{
"name": "remixdesktop",
"version": "1.0.2-insiders",
"version": "1.0.4-insiders",
"main": "build/main.js",
"license": "MIT",
"type": "commonjs",
@ -64,6 +64,7 @@
"electron-updater": "^6.1.8",
"express": "^4.19.2",
"isomorphic-git": "^1.24.2",
"matomo-tracker": "^2.2.4",
"node-pty": "^0.10.1",
"semver": "^7.5.4"
},

@ -31,6 +31,7 @@ if (
// get system home dir
const homeDir = app.getPath('userData')
const windowSet = new Set<BrowserWindow>([]);
export const createWindow = async (dir?: string): Promise<void> => {
// Create the browser window.
@ -53,6 +54,7 @@ export const createWindow = async (dir?: string): Promise<void> => {
(process.env.NODE_ENV === 'production' || isPackaged) && !isE2ELocal ? `file://${__dirname}/remix-ide/index.html` + params :
'http://localhost:8080' + params)
trackEvent('Instance', 'create_window', '', 1);
if (dir) {
mainWindow.setTitle(dir)
@ -74,6 +76,8 @@ export const createWindow = async (dir?: string): Promise<void> => {
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', async () => {
trackEvent('App', 'Launch', app.getVersion(), 1);
trackEvent('App', 'OS', process.platform, 1);
require('./engine')
});
@ -120,6 +124,7 @@ import TerminalMenu from './menus/terminal';
import HelpMenu from './menus/help';
import { execCommand } from './menus/commands';
import main from './menus/main';
import { trackEvent } from './utils/matamo';
const commandKeys: Record<string, string> = {

@ -3,6 +3,7 @@ import { Profile } from "@remixproject/plugin-utils"
import { autoUpdater } from "electron-updater"
import { app } from 'electron';
import { isE2E } from "../main";
import { trackEvent } from "../utils/matamo";
const profile = {
displayName: 'appUpdater',
@ -117,6 +118,8 @@ class AppUpdaterPluginClient extends ElectronBasePluginClient {
type: 'log',
value: 'Remix Desktop version: ' + autoUpdater.currentVersion,
})
trackEvent('App', 'CheckForUpdate', 'Remix Desktop version: ' + autoUpdater.currentVersion, 1);
autoUpdater.checkForUpdates()
}
}

@ -9,7 +9,10 @@ import path from 'path'
import {customAction} from '@remixproject/plugin-api'
import { PluginEventDataBatcher } from '../utils/pluginEventDataBatcher'
type recentFolder = {
timestamp: number,
path: string
}
const profile: Profile = {
displayName: 'fs',
@ -312,11 +315,37 @@ class FSPluginClient extends ElectronBasePluginClient {
}
}
async convertRecentFolders(): Promise<void> {
const config = await this.call('electronconfig' as any, 'readConfig')
if(config.recentFolders) {
const remaps = config.recentFolders.map((f: any) => {
// if type is string
if(typeof f ==='string') {
return {
path: f,
timestamp: new Date().getTime(),
}
}else{
return f
}
})
config.recentFolders = remaps
await writeConfig(config)
}
}
async updateRecentFolders(path: string): Promise<void> {
await this.convertRecentFolders()
const config = await this.call('electronconfig' as any, 'readConfig')
config.recentFolders = config.recentFolders || []
config.recentFolders = config.recentFolders.filter((p: string) => p !== path)
config.recentFolders.push(path)
const timestamp = new Date().getTime()
config.recentFolders.push({
path,
timestamp,
})
writeConfig(config)
}
@ -336,16 +365,18 @@ class FSPluginClient extends ElectronBasePluginClient {
}
async getRecentFolders(): Promise<string[]> {
await this.convertRecentFolders()
const config = await this.call('electronconfig' as any, 'readConfig')
let folders: string[] = config.recentFolders || []
folders = folders.map((f: string) => convertPathToPosix(f))
let folders: string[] = []
folders = (config.recentFolders || []).map((f: recentFolder) => convertPathToPosix(f.path)).sort((a: recentFolder, b: recentFolder) => a.timestamp - b.timestamp).slice(-15).reverse()
return folders
}
async removeRecentFolder(path: string): Promise<void> {
await this.convertRecentFolders()
const config = await this.call('electronconfig' as any, 'readConfig')
config.recentFolders = config.recentFolders || []
config.recentFolders = config.recentFolders.filter((p: string) => p !== path)
config.recentFolders = config.recentFolders.filter((p: recentFolder) => p.path !== path)
writeConfig(config)
}

@ -0,0 +1,33 @@
import { isE2ELocal } from "../main";
import { isPackaged } from "../main";
var MatomoTracker = require('matomo-tracker');
// Function to send events to Matomo
export function trackEvent(category: string, action: string, name: string, value: string | number): void {
var matomo = new MatomoTracker(35, 'http://ethereumfoundation.matomo.cloud/matomo.php');
matomo.on('error', function(err: any) {
console.log('error tracking request: ', err);
});
console.log('Tracking event:', category, action, name, value);
if((process.env.NODE_ENV === 'production' || isPackaged) && !isE2ELocal){
}
matomo.track({
e_c: category,
e_a: action,
e_n: name,
e_v: value,
url: 'https://github.com/remix-project-org/remix-desktop'
// You can add other parameters if needed
}, (error: any) => {
if (error) {
console.error('Error tracking event:', error);
} else {
console.log('Event tracked successfully');
}
});
}

@ -3971,6 +3971,11 @@ matcher@^3.0.0:
dependencies:
escape-string-regexp "^4.0.0"
matomo-tracker@^2.2.4:
version "2.2.4"
resolved "https://registry.yarnpkg.com/matomo-tracker/-/matomo-tracker-2.2.4.tgz#ee397d915d7b2e7964996ca28a0a03f4f0692453"
integrity sha512-7fDy4wRhDQ1dnSxVqmnVqmmos9ACKag0fCBtBD3/Qeoqks7MFqXcO35nfS6S8xU/IXNf7534q/4Gx8fuWKYW6A==
md5.js@^1.3.4:
version "1.3.5"
resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f"

Loading…
Cancel
Save