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 #577

Merged
merged 1 commit into from
Aug 30, 2022
Merged
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
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
3 changes: 1 addition & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
"electron-updater": "5.0.1",
"fix-path": "3.0.0",
"rimraf": "3.0.2",
"semver": "7.3.7",
"universal-analytics": "0.5.3"
"semver": "7.3.7"
},
"optionalDependencies": {},
"devDependencies": {}
Expand Down
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
20 changes: 0 additions & 20 deletions app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,6 @@ cross-spawn@^4.0.0:
lru-cache "^4.0.1"
which "^1.2.9"

debug@^4.3.1:
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"
Expand Down Expand Up @@ -448,24 +441,11 @@ to-regex-range@^5.0.1:
dependencies:
is-number "^7.0.0"

universal-analytics@0.5.3:
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
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@
"cerebro-tools": "0.1.8",
"escape-string-regexp": "5.0.0",
"lodash": "4.17.21",
"node-machine-id": "1.1.12",
"normalize.css": "8.0.1",
"prop-types": "15.8.1",
"react": "15.7.0",
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7451,11 +7451,6 @@ node-libs-browser@^2.2.1:
util "^0.11.0"
vm-browserify "^1.0.1"

node-machine-id@1.1.12:
version "1.1.12"
resolved "https://registry.yarnpkg.com/node-machine-id/-/node-machine-id-1.1.12.tgz#37904eee1e59b320bb9c5d6c0a59f3b469cb6267"
integrity sha512-QNABxbrPa3qEIfrE6GOJ7BYIuignnJw7iQ2YPbc3Nla1HzRJjXzZOiikfF8m7eAMfichLt3M4VgLOetqgDmgGQ==

node-releases@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.1.tgz#3d1d395f204f1f2f29a54358b9fb678765ad2fc5"
Expand Down