Track redux actions

This commit is contained in:
Thomas Nordquist
2019-01-13 17:13:22 +01:00
parent 490678d7b4
commit d2bb098772
2 changed files with 19 additions and 0 deletions

View File

@@ -2,6 +2,8 @@ import * as q from '../../../backend/src/Model'
import { Action, Reducer } from 'redux' import { Action, Reducer } from 'redux'
import { trackEvent } from '../tracking'
export enum ActionTypes { export enum ActionTypes {
setAutoExpandLimit = 'SET_AUTO_EXPAND_LIMIT', setAutoExpandLimit = 'SET_AUTO_EXPAND_LIMIT',
toggleSettingsVisibility = 'TOGGLE_SETTINGS_VISIBILITY', toggleSettingsVisibility = 'TOGGLE_SETTINGS_VISIBILITY',
@@ -48,6 +50,7 @@ const reducer: Reducer<AppState | undefined, CustomAction> = (state, action) =>
if (!state) { if (!state) {
throw Error('No initial state') throw Error('No initial state')
} }
trackEvent(action.type)
switch (action.type) { switch (action.type) {
case ActionTypes.setAutoExpandLimit: case ActionTypes.setAutoExpandLimit:

View File

@@ -1,5 +1,21 @@
let userId = window.localStorage.getItem('userId')
const sha1 = require('sha1')
if (!userId) {
userId = sha1(sha1(Math.random()) + sha1(performance.now()) + sha1(Date.now())).slice(0, 8) as string
window.localStorage.setItem('userId', userId)
}
const Nucleus = require('electron-nucleus')('5c3b3e0443b7cc00eec3782b', { const Nucleus = require('electron-nucleus')('5c3b3e0443b7cc00eec3782b', {
userId,
disableInDev: true, disableInDev: true,
}) })
export default Nucleus export default Nucleus
export function trackEvent(name: string) {
if (name.match(/^@@redux/)) {
return
}
Nucleus.track(name)
}