Skip to content

Commit

Permalink
Added more actions for GA
Browse files Browse the repository at this point in the history
* plugin install/uninstall
* show window
* select result
  • Loading branch information
KELiON committed Dec 8, 2016
1 parent c7efbd9 commit 2e5a71a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions main/actions/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export function updateTerm(term) {
let result = Array.isArray(payload) ? payload : [payload]
result = result.map(x => ({
...x,
plugin,
// Scope result ids with plugin name and use title if id is empty
id: `${plugin}-${x.id || x.title}`
}))
Expand Down
18 changes: 18 additions & 0 deletions main/containers/Search/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,27 @@ import escapeStringRegexp from 'escape-string-regexp'

import { debounce, bind } from 'lodash-decorators'

import trackEvent from 'lib/trackEvent'

import {
INPUT_HEIGHT,
RESULT_HEIGHT,
MIN_VISIBLE_RESULTS,
} from '../../constants/ui'

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 @@ -94,6 +109,7 @@ class Search extends Component {
window.addEventListener('beforeunload', this.cleanup)
this.electronWindow.on('hide', this.props.actions.reset)
this.electronWindow.on('show', this.focusMainInput)
this.electronWindow.on('show', trackShowWindow)
}
componentDidMount() {
this.focusMainInput()
Expand Down Expand Up @@ -219,6 +235,7 @@ class Search extends Component {
window.removeEventListener('beforeunload', this.cleanup)
this.electronWindow.removeListener('hide', this.props.actions.reset)
this.electronWindow.removeListener('show', this.focusMainInput)
this.electronWindow.removeListener('show', trackShowWindow)
}

@bind()
Expand All @@ -242,6 +259,7 @@ class Search extends Component {
@bind()
selectItem(item, realEvent) {
this.props.actions.reset()
trackSelectItem(item.plugin)
const event = wrapEvent(realEvent)
item.onSelect(event)
if (!event.defaultPrevented) {
Expand Down
6 changes: 6 additions & 0 deletions main/plugins/core/plugins/Preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ActionButton from './ActionButton.js'
import getReadme from '../getReadme'
import ReactMarkdown from 'react-markdown'
import styles from './styles.css'
import trackEvent from 'lib/trackEvent'
import { client } from 'lib/plugins'

const isRelative = (src) => !src.match(/^(https?:|data:)/)
Expand Down Expand Up @@ -44,6 +45,11 @@ export default class Preview extends Component {
}

pluginAction(plugin, action) {
trackEvent({
category: 'Plugins',
event: action,
label: plugin
})
return () => client[action](plugin)
}

Expand Down

0 comments on commit 2e5a71a

Please sign in to comment.