diff --git a/src/renderer/index.js b/src/renderer/index.js index 155278bda..d5154b084 100644 --- a/src/renderer/index.js +++ b/src/renderer/index.js @@ -19,8 +19,10 @@ const contextMenu = remote.require("./main.js").contextMenu; const app = require("./app"); // Workaround for https://github.com/electron-userland/electron-webpack/issues/52 -if (process.env.NODE_ENV !== 'development') { - window.staticResourcesPath = require("path").join(remote.app.getAppPath(), "../static").replace(/\\/g, "\\\\"); +if (process.env.NODE_ENV !== "development") { + window.staticResourcesPath = require("path") + .join(remote.app.getAppPath(), "../static") + .replace(/\\/g, "\\\\"); } else { window.staticResourcesPath = ""; } @@ -55,6 +57,16 @@ ipcRenderer.on("window-is-focused", (event, data) => { dock.setBadge(""); }); +(function(history) { + var replaceState = history.replaceState; + history.replaceState = function(_, __, path) { + amplitude + .getInstance() + .logEvent("NAVIGATION", { destination: path ? path.slice(1) : path }); + return replaceState.apply(history, arguments); + }; +})(window.history); + document.addEventListener("click", event => { var target = event.target; while (target && target !== document) { @@ -110,7 +122,7 @@ var init = function() { , - document.getElementById('app') + document.getElementById("app") ); } ); @@ -124,7 +136,7 @@ var init = function() { , - document.getElementById('app') + document.getElementById("app") ); } }; diff --git a/src/renderer/redux/actions/navigation.js b/src/renderer/redux/actions/navigation.js index a4cbca615..b718936aa 100644 --- a/src/renderer/redux/actions/navigation.js +++ b/src/renderer/redux/actions/navigation.js @@ -9,7 +9,6 @@ import { } from "redux/selectors/navigation"; import { doSearch } from "redux/actions/search"; import { toQueryString } from "util/query_params"; -import amplitude from "amplitude-js"; export function doNavigate(path, params = {}, options = {}) { return function(dispatch, getState) { @@ -24,8 +23,6 @@ export function doNavigate(path, params = {}, options = {}) { const scrollY = options.scrollY; - amplitude.getInstance().logEvent("NAVIGATION", { destination: url }); - dispatch({ type: types.HISTORY_NAVIGATE, data: { url, index: options.index, scrollY },