Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove useless analytics #568

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Run Tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
- run: yarn
- run: yarn test --detectOpenHandles --forceExit
5 changes: 5 additions & 0 deletions __mocks__/plugins.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
'test-plugin': {
fn: () => {}
}
}
13 changes: 3 additions & 10 deletions app/lib/config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { app, ipcRenderer } from 'electron'
import fs from 'fs'
import path from 'path'
import { memoize } from 'cerebro-tools'
import { trackEvent } from './trackEvent'
import loadThemes from './loadThemes'

const remote = process.type === 'browser'
Expand All @@ -14,11 +14,11 @@ const electronApp = remote ? remote.app : app
// set data directory to ./userdata
process.argv.forEach((arg) => {
if (arg.toLowerCase() === '-p' || arg.toLowerCase() === '--portable') {
electronApp.setPath('userData', `${process.cwd()}/userdata`)
electronApp.setPath('userData', path.join(process.cwd(), 'userdata'))
}
})

const CONFIG_FILE = `${electronApp.getPath('userData')}/config.json`
const CONFIG_FILE = path.join(electronApp.getPath('userData'), 'config.json')

const defaultSettings = memoize(() => {
const locale = electronApp.getLocale() || 'en-US'
Expand All @@ -38,7 +38,6 @@ const defaultSettings = memoize(() => {
lastShownDonateDialog: null,
plugins: {},
isMigratedPlugins: false,
trackingEnabled: true,
crashreportingEnabled: true,
openAtLogin: true
}
Expand Down Expand Up @@ -85,12 +84,6 @@ const set = (key, value) => {
}
config[key] = value
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2))
// Track settings changes
trackEvent({
category: 'Settings',
event: `Change ${key}`,
label: value
})

if (ipcRenderer) {
console.log('notify main process', key, value)
Expand Down
36 changes: 0 additions & 36 deletions app/lib/trackEvent.js

This file was deleted.

17 changes: 0 additions & 17 deletions app/main/components/Cerebro/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import escapeStringRegexp from 'escape-string-regexp'

import debounce from 'lodash/debounce'

import { trackEvent } from 'lib/trackEvent'
import getWindowPosition from 'lib/getWindowPosition'
import {
WINDOW_WIDTH,
Expand All @@ -29,19 +28,6 @@ const remote = process.type === 'browser'
? { getCurrentWindow: BrowserWindow.getFocusedWindow }
: require('@electron/remote')

const SHOW_EVENT = {
category: 'Window',
event: 'show'
}

const SELECT_EVENT = {
category: 'Plugins',
event: 'select'
}

const trackShowWindow = () => trackEvent(SHOW_EVENT)
const trackSelectItem = (label) => trackEvent({ ...SELECT_EVENT, label })

/**
* Wrap click or mousedown event to custom `select-item` event,
* that includes only information about clicked keys (alt, shift, ctrl and meta)
Expand Down Expand Up @@ -112,7 +98,6 @@ class Cerebro extends Component {
window.addEventListener('beforeunload', this.cleanup)
this.electronWindow.on('show', this.focusMainInput)
this.electronWindow.on('show', this.updateElectronWindow)
this.electronWindow.on('show', trackShowWindow)
}

componentDidMount() {
Expand Down Expand Up @@ -268,7 +253,6 @@ class Cerebro extends Component {
window.removeEventListener('beforeunload', this.cleanup)
this.electronWindow.removeListener('show', this.focusMainInput)
this.electronWindow.removeListener('show', this.updateElectronWindow)
this.electronWindow.removeListener('show', trackShowWindow)
}

focusMainInput() {
Expand All @@ -290,7 +274,6 @@ class Cerebro extends Component {
*/
selectItem(item, realEvent) {
this.props.actions.reset()
trackSelectItem(item.plugin)
const event = wrapEvent(realEvent)
item.onSelect(event)
if (!event.defaultPrevented) {
Expand Down
13 changes: 3 additions & 10 deletions app/main/createWindow.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { BrowserWindow, globalShortcut, app, screen, shell } from 'electron'
import {
BrowserWindow, globalShortcut, app, screen, shell
} from 'electron'
import debounce from 'lodash/debounce'
import EventEmitter from 'events'
import { trackEvent, screenView } from 'lib/trackEvent'
import config from 'lib/config'
import getWindowPosition from 'lib/getWindowPosition'

Expand Down Expand Up @@ -176,14 +177,6 @@ export default ({ src, isDev }) => {
setTimeout(donateDialog.show, 1000)
}

// Track app start event
trackEvent({
category: 'App Start',
event: config.get('firstStart') ? 'First' : 'Secondary'
})

screenView('Search')

// Save in config information, that application has been started
config.set('firstStart', false)

Expand Down
14 changes: 1 addition & 13 deletions app/main/createWindow/donateDialog.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { dialog, shell } from 'electron'
import config from '../../lib/config'
import { trackEvent } from '../../lib/trackEvent'

const now = () => new Date().getTime()
const twoWeeksAgo = () => now() - 1000 * 3600 * 24 * 7
Expand Down Expand Up @@ -30,15 +29,6 @@ const skipMessages = ["I don't want to see this message again"]
export const show = () => {
config.set('lastShownDonateDialog', now())
const AB = Math.floor(Math.random() * buttons.length)
const track = (event) => {
trackEvent({
event,
category: 'Donate Dialog',
label: AB
})
}

track('show-dialog')

const options = {
type: 'info',
Expand All @@ -53,12 +43,10 @@ export const show = () => {
const callback = (id, checkboxChecked) => {
if (checkboxChecked) {
config.set('skipDonateDialog', true)
track('skip-dialog')
}
if (id === 1) {
track('choose-donate')
donate()
} else { track('cancel') }
}
}

setTimeout(() => {
Expand Down
7 changes: 3 additions & 4 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@
"dependencies": {
"move-file": "2.1.0",
"chokidar": "3.5.3",
"electron-updater": "5.0.1",
"electron-updater": "5.0.5",
"fix-path": "3.0.0",
"rimraf": "3.0.2",
"semver": "7.3.7",
"universal-analytics": "0.5.3"
"semver": "7.3.7"
},
"optionalDependencies": {},
"devDependencies": {}
}
}
6 changes: 0 additions & 6 deletions app/plugins/core/plugins/Preview/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { KeyboardNav, KeyboardNavItem, Preload } from '@cerebroapp/cerebro-ui'
import { trackEvent } from 'lib/trackEvent'
import { client } from 'lib/plugins'
import plugins from 'plugins'
import ReactMarkdown from 'react-markdown'
Expand Down Expand Up @@ -38,11 +37,6 @@ class Preview extends Component {
pluginAction(plugin, runningAction) {
return () => {
this.setState({ runningAction })
trackEvent({
category: 'Plugins',
event: runningAction,
label: plugin
})
client[runningAction](plugin)
}
}
Expand Down
50 changes: 19 additions & 31 deletions app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ braces@~3.0.2:
dependencies:
fill-range "^7.0.1"

[email protected].0:
version "9.0.0"
resolved "https://registry.yarnpkg.com/builder-util-runtime/-/builder-util-runtime-9.0.0.tgz#3a40ba7382712ccdb24471567f91d7c167e00830"
integrity sha512-SkpEtSmTkREDHRJnxKEv43aAYp8sYWY8fxYBhGLBLOBIRXeaIp6Kv3lBgSD7uR8jQtC7CA659sqJrpSV6zNvSA==
[email protected].2:
version "9.0.2"
resolved "https://registry.yarnpkg.com/builder-util-runtime/-/builder-util-runtime-9.0.2.tgz#dc54f8581bbcf1e0428da4483fa46d09524be857"
integrity sha512-xF55W/8mgfT6+sMbX0TeiJkTusA5GMOzckM4rajN4KirFcUIuLTH8oEaTYmM86YwVCZaTwa/7GyFhauXaEICwA==
dependencies:
debug "^4.3.2"
debug "^4.3.4"
sax "^1.2.4"

[email protected]:
Expand Down Expand Up @@ -86,38 +86,32 @@ cross-spawn@^4.0.0:
lru-cache "^4.0.1"
which "^1.2.9"

debug@^4.3.1:
debug@^4.3.1, debug@^4.3.4:
version "4.3.4"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
dependencies:
ms "2.1.2"

debug@^4.3.2:
version "4.3.2"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.2.tgz#f0a49c18ac8779e31d4a0c6029dfb76873c7428b"
integrity sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==
dependencies:
ms "2.1.2"

default-shell@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/default-shell/-/default-shell-1.0.1.tgz#752304bddc6174f49eb29cb988feea0b8813c8bc"
integrity sha512-/Os8tTMPSriNHCsVj3VLjMZblIl1sIg8EXz3qg7C5K+y9calfTA/qzlfPvCQ+LEgLWmtZ9wCnzE1w+S6TPPFyQ==

[email protected].1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/electron-updater/-/electron-updater-5.0.1.tgz#327915f1b2e573daf1ce1d8102bcab93f4880c1a"
integrity sha512-dNnXPCqYmergXy3jgg4UICuD50Orug9GQe/5xfHy+BE2Fy0icB0QE+y6iQWdCDf7yeONxwMBf4HgIkGG5pIaVg==
[email protected].5:
version "5.0.5"
resolved "https://registry.yarnpkg.com/electron-updater/-/electron-updater-5.0.5.tgz#efc025a1777fc0a9c6f9f20ef70037b727e989fb"
integrity sha512-YcKEI9zpU+c0sNXTpjw3UpzP8Pfuuwo70T42oLYm0hHc0dy41ih51oENlhxgooa2+uzzpXhoCOyrpG+w6CB0Pw==
dependencies:
"@types/semver" "^7.3.6"
builder-util-runtime "9.0.0"
builder-util-runtime "9.0.2"
fs-extra "^10.0.0"
js-yaml "^4.1.0"
lazy-val "^1.0.5"
lodash.escaperegexp "^4.1.2"
lodash.isequal "^4.5.0"
semver "^7.3.5"
typed-emitter "^2.1.0"

execa@^0.5.0:
version "0.5.1"
Expand Down Expand Up @@ -389,6 +383,13 @@ [email protected]:
dependencies:
glob "^7.1.3"

rxjs@^7.5.2:
version "7.5.6"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.5.6.tgz#0446577557862afd6903517ce7cae79ecb9662bc"
integrity sha512-dnyv2/YsXhnm461G+R/Pe5bWP41Nm6LBXEYWI6eiFP4fiwx6WRI/CD0zbdVAudd9xwLEF2IDcKXLHit0FYjUzw==
dependencies:
tslib "^2.1.0"

sax@^1.2.4:
version "1.2.4"
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"
Expand Down Expand Up @@ -448,24 +449,11 @@ to-regex-range@^5.0.1:
dependencies:
is-number "^7.0.0"

[email protected]:
version "0.5.3"
resolved "https://registry.yarnpkg.com/universal-analytics/-/universal-analytics-0.5.3.tgz#ff2d9b850062cdd4a8f652448047982a183c8e96"
integrity sha512-HXSMyIcf2XTvwZ6ZZQLfxfViRm/yTGoRgDeTbojtq6rezeyKB0sTBcKH2fhddnteAHRcHiKgr/ACpbgjGOC6RQ==
dependencies:
debug "^4.3.1"
uuid "^8.0.0"

universalify@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717"
integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==

uuid@^8.0.0:
version "8.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==

which@^1.2.9:
version "1.3.1"
resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a"
Expand Down
Loading