-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
WIP Add Tracking #119
WIP Add Tracking #119
Changes from 11 commits
8d22cfc
b7a0073
26a4f69
a8a659c
4e8c972
91854b1
fb7b8c8
7a1f6eb
1395fec
5c9d2ea
ef86261
b524783
8b69583
487e119
2b6752e
6f6cf30
c058336
676a476
dfead5f
c91136f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// Copyright (c) 2018 Uber Technologies, Inc. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
// This file sends actions on the demo app to Google analytics | ||
|
||
import {ActionTypes} from 'kepler.gl/actions'; | ||
import {LOCATION_CHANGE} from 'react-router-redux'; | ||
|
||
const getPayload = ({payload}) => payload; | ||
|
||
const withStoreInformation = getTracking => (payload, store) => { | ||
const trackingFromPayload = getTracking(payload, store); | ||
try { | ||
const { | ||
demo: { | ||
keplerGl: { | ||
map: { | ||
visState: {datasets = {}, filters = [], layers = []} | ||
} | ||
} | ||
} | ||
} = store.getState(); | ||
const trackingFromStore = { | ||
datasetsCount: Object.keys(datasets).length, | ||
layersCount: layers.length, | ||
filtersCount: filters.length | ||
}; | ||
return { | ||
...trackingFromStore, | ||
...trackingFromPayload | ||
}; | ||
} catch (err) { | ||
/* eslint-disable */ | ||
console.warn(err); | ||
/* eslint-enable */ | ||
return trackingFromPayload; | ||
} | ||
}; | ||
|
||
const trackingInformation = { | ||
[ActionTypes.LOAD_FILES]: ({files}) => | ||
files.map(({size, type}) => ({size, type})), | ||
[ActionTypes.LAYER_HOVER]: ({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't want to track LAYER_HOVER, it gets called all the time There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All actions are currently tracked - should I specifically exclude this one? |
||
payload: { | ||
info: {lngLat} | ||
} | ||
}) => lngLat, | ||
[ActionTypes.LAYER_CONFIG_CHANGE]: ({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LAYER_TYPE_CHANGE |
||
payload: { | ||
oldLayer: {type}, | ||
newConfig | ||
} | ||
}) => ({ | ||
type, | ||
newConfig | ||
}), | ||
[ActionTypes.MAP_STYLE_CHANGE]: getPayload, | ||
[ActionTypes.TOGGLE_MODAL]: getPayload, | ||
[ActionTypes.TOGGLE_SIDE_PANEL]: getPayload, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need to track this |
||
[ActionTypes.UPDATE_MAP]: withStoreInformation(getPayload), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is map viewport change, don't track |
||
[ActionTypes.SET_FILTER]: withStoreInformation(getPayload), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. assume this is where we track the type of filter being used. payload would be not wrapped. and it would sed {idx, prop, value}
|
||
[ActionTypes.INTERACTION_CONFIG_CHANGE]: ({config}) => config, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we want to track whether tooltip or brushing is enabled, we should just track that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed |
||
[LOCATION_CHANGE]: x => x | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to track how many layers and filters we can do
|
||
}; | ||
|
||
const analyticsMiddleware = store => next => action => { | ||
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
Sorry, something went wrong. |
||
// eslint-disable-next-line no-undef | ||
if (window && window.ga) { | ||
// eslint-disable-next-line no-undef | ||
window.ga( | ||
'demo_app', | ||
action.type, | ||
trackingInformation[action.type] | ||
? JSON.stringify( | ||
trackingInformation[action.type](action.payload, store) | ||
) | ||
: undefined | ||
); | ||
} | ||
return next(action); | ||
}; | ||
|
||
export default analyticsMiddleware; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,12 +19,14 @@ | |
// THE SOFTWARE. | ||
|
||
import React, {Component} from 'react'; | ||
import {connect} from 'react-redux'; | ||
import styled from 'styled-components'; | ||
import PropTypes from 'prop-types'; | ||
import {Tooltip} from 'components/common/styled-components'; | ||
import KeplerGlLogo from 'components/common/logo'; | ||
import {CodeAlt, Save, Files, Share, Picture} from 'components/common/icons'; | ||
import PanelDropdown from 'components/side-panel/panel-dropdown'; | ||
import {ACTION_PREFIX} from 'constants/default-settings.js'; | ||
|
||
const StyledPanelHeader = styled.div.attrs({ | ||
className: 'side-side-panel__header' | ||
|
@@ -204,7 +206,7 @@ const defaultActionItems = [ | |
]; | ||
|
||
function PanelHeaderFactory() { | ||
return class PanelHeader extends Component { | ||
class PanelHeader extends Component { | ||
static propTypes = { | ||
logoComponent: PropTypes.oneOfType([PropTypes.element, PropTypes.func]), | ||
actionItems: PropTypes.arrayOf(PropTypes.any) | ||
|
@@ -221,10 +223,12 @@ function PanelHeaderFactory() { | |
|
||
showDropdown = id => { | ||
this.setState({dropdown: id}); | ||
this.props.trackingActionShowExportDropdown(); | ||
}; | ||
|
||
hideDropdown = () => { | ||
this.setState({dropdown: null}); | ||
this.props.trackingActionHideExportDropdown(); | ||
}; | ||
|
||
render() { | ||
|
@@ -273,6 +277,14 @@ function PanelHeaderFactory() { | |
); | ||
} | ||
} | ||
return connect(undefined, { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you are adding tracking to |
||
trackingActionShowExportDropdown: () => ({ | ||
type: `${ACTION_PREFIX}TRACKING_ACTION_SHOW_EXPORT_DROPDOWN` | ||
}), | ||
trackingActionHideExportDropdown: () => ({ | ||
type: `${ACTION_PREFIX}TRACKING_ACTION_HIDE_EXPORT_DROPDOWN` | ||
}) | ||
})(PanelHeader); | ||
} | ||
|
||
export default PanelHeaderFactory; |
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
Sorry, something went wrong.