Changed navigation analytic location
This commit is contained in:
parent
ca16c1d375
commit
c4cccac632
2 changed files with 4 additions and 8 deletions
|
@ -9,6 +9,7 @@ import {
|
||||||
} from "redux/selectors/navigation";
|
} from "redux/selectors/navigation";
|
||||||
import { doSearch } from "redux/actions/search";
|
import { doSearch } from "redux/actions/search";
|
||||||
import { toQueryString } from "util/query_params";
|
import { toQueryString } from "util/query_params";
|
||||||
|
import amplitude from "amplitude-js";
|
||||||
|
|
||||||
export function doNavigate(path, params = {}, options = {}) {
|
export function doNavigate(path, params = {}, options = {}) {
|
||||||
return function(dispatch, getState) {
|
return function(dispatch, getState) {
|
||||||
|
@ -23,6 +24,8 @@ export function doNavigate(path, params = {}, options = {}) {
|
||||||
|
|
||||||
const scrollY = options.scrollY;
|
const scrollY = options.scrollY;
|
||||||
|
|
||||||
|
amplitude.getInstance().logEvent("NAVIGATION", { destination: url });
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: types.HISTORY_NAVIGATE,
|
type: types.HISTORY_NAVIGATE,
|
||||||
data: { url, index: options.index, scrollY },
|
data: { url, index: options.index, scrollY },
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import * as types from "constants/action_types";
|
import * as types from "constants/action_types";
|
||||||
import { parseQueryParams } from "util/query_params";
|
import { parseQueryParams } from "util/query_params";
|
||||||
import amplitude from "amplitude-js";
|
|
||||||
|
|
||||||
const currentPath = () => {
|
const currentPath = () => {
|
||||||
const hash = document.location.hash;
|
const hash = document.location.hash;
|
||||||
|
@ -71,13 +70,7 @@ reducers[types.WINDOW_SCROLLED] = (state, action) => {
|
||||||
export default function reducer(state = defaultState, action) {
|
export default function reducer(state = defaultState, action) {
|
||||||
const handler = reducers[action.type];
|
const handler = reducers[action.type];
|
||||||
if (handler) {
|
if (handler) {
|
||||||
let nextState = handler(state, action);
|
return handler(state, action);
|
||||||
if (nextState.currentPath !== state.currentPath) {
|
|
||||||
amplitude
|
|
||||||
.getInstance()
|
|
||||||
.logEvent("NAVIGATION", { destination: nextState.currentPath });
|
|
||||||
}
|
|
||||||
return nextState;
|
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue