Move analytics out of redux folder #881
3 changed files with 20 additions and 8 deletions
|
@ -46,6 +46,7 @@ export const Header = props => {
|
||||||
onClick={() => navigate("/subscriptions")}
|
onClick={() => navigate("/subscriptions")}
|
||||||
button="alt button--flat"
|
button="alt button--flat"
|
||||||
icon="icon-at"
|
icon="icon-at"
|
||||||
|
title={__("My Subscriptions")}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="header__item header__item--wunderbar">
|
<div className="header__item header__item--wunderbar">
|
||||||
|
|
|
@ -19,8 +19,10 @@ const contextMenu = remote.require("./main.js").contextMenu;
|
||||||
const app = require("./app");
|
const app = require("./app");
|
||||||
|
|
||||||
// Workaround for https://github.com/electron-userland/electron-webpack/issues/52
|
// Workaround for https://github.com/electron-userland/electron-webpack/issues/52
|
||||||
if (process.env.NODE_ENV !== 'development') {
|
if (process.env.NODE_ENV !== "development") {
|
||||||
window.staticResourcesPath = require("path").join(remote.app.getAppPath(), "../static").replace(/\\/g, "\\\\");
|
window.staticResourcesPath = require("path")
|
||||||
|
.join(remote.app.getAppPath(), "../static")
|
||||||
|
.replace(/\\/g, "\\\\");
|
||||||
} else {
|
} else {
|
||||||
window.staticResourcesPath = "";
|
window.staticResourcesPath = "";
|
||||||
}
|
}
|
||||||
|
@ -55,13 +57,24 @@ ipcRenderer.on("window-is-focused", (event, data) => {
|
||||||
dock.setBadge("");
|
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 => {
|
document.addEventListener("click", event => {
|
||||||
var target = event.target;
|
var target = event.target;
|
||||||
while (target && target !== document) {
|
while (target && target !== document) {
|
||||||
if (target.matches("a") || target.matches("button")) {
|
if (target.matches("a") || target.matches("button")) {
|
||||||
// TODO: Look into using accessiblity labels (this would also make the app more accessible)
|
// TODO: Look into using accessiblity labels (this would also make the app more accessible)
|
||||||
let hrefParts = window.location.href.split("#");
|
let hrefParts = window.location.href.split("#");
|
||||||
let element = target.title || (target.text && target.text.trim());
|
let element =
|
||||||
|
target.title || (target.textContent && target.textContent.trim());
|
||||||
if (element) {
|
if (element) {
|
||||||
amplitude.getInstance().logEvent("CLICK", {
|
amplitude.getInstance().logEvent("CLICK", {
|
||||||
target: element,
|
target: element,
|
||||||
|
@ -72,6 +85,7 @@ document.addEventListener("click", event => {
|
||||||
amplitude.getInstance().logEvent("UNMARKED_CLICK", {
|
amplitude.getInstance().logEvent("UNMARKED_CLICK", {
|
||||||
location:
|
location:
|
||||||
hrefParts.length > 1 ? hrefParts[hrefParts.length - 1] : "/",
|
hrefParts.length > 1 ? hrefParts[hrefParts.length - 1] : "/",
|
||||||
|
source: target.outerHTML,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,7 +124,7 @@ var init = function() {
|
||||||
<SnackBar />
|
<SnackBar />
|
||||||
</div>
|
</div>
|
||||||
</Provider>,
|
</Provider>,
|
||||||
document.getElementById('app')
|
document.getElementById("app")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -124,7 +138,7 @@ var init = function() {
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<SplashScreen onReadyToLaunch={onDaemonReady} />
|
<SplashScreen onReadyToLaunch={onDaemonReady} />
|
||||||
</Provider>,
|
</Provider>,
|
||||||
document.getElementById('app')
|
document.getElementById("app")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,7 +9,6 @@ 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) {
|
||||||
|
@ -24,8 +23,6 @@ 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 },
|
||||||
|
|
Loading…
Reference in a new issue