fix: analytics on desktop
This commit is contained in:
parent
3ae2c19656
commit
e1cfe6c58f
3 changed files with 44 additions and 6 deletions
|
@ -59,6 +59,7 @@
|
||||||
"@babel/preset-flow": "^7.0.0",
|
"@babel/preset-flow": "^7.0.0",
|
||||||
"@babel/preset-react": "^7.0.0",
|
"@babel/preset-react": "^7.0.0",
|
||||||
"@babel/register": "^7.0.0",
|
"@babel/register": "^7.0.0",
|
||||||
|
"@exponent/electron-cookies": "^2.0.0",
|
||||||
"@hot-loader/react-dom": "16.8",
|
"@hot-loader/react-dom": "16.8",
|
||||||
"@lbry/color": "^1.0.2",
|
"@lbry/color": "^1.0.2",
|
||||||
"@lbry/components": "^2.7.0",
|
"@lbry/components": "^2.7.0",
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
import { Lbryio } from 'lbryinc';
|
import { Lbryio } from 'lbryinc';
|
||||||
import ReactGA from 'react-ga';
|
import ReactGA from 'react-ga';
|
||||||
import { history } from './store';
|
import { history } from './store';
|
||||||
|
// @if TARGET='app'
|
||||||
|
import ElectronCookies from '@exponent/electron-cookies';
|
||||||
|
// @endif
|
||||||
|
|
||||||
type Analytics = {
|
type Analytics = {
|
||||||
pageView: string => void,
|
pageView: string => void,
|
||||||
|
@ -15,7 +18,7 @@ let analyticsEnabled: boolean = true;
|
||||||
const analytics: Analytics = {
|
const analytics: Analytics = {
|
||||||
pageView: path => {
|
pageView: path => {
|
||||||
if (analyticsEnabled) {
|
if (analyticsEnabled) {
|
||||||
ReactGA.pageview(path, IS_WEB ? ['web'] : ['desktop']);
|
ReactGA.pageview(path);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setUser: user => {
|
setUser: user => {
|
||||||
|
@ -78,16 +81,27 @@ const analytics: Analytics = {
|
||||||
// Will change once we have separate ids for desktop/web
|
// Will change once we have separate ids for desktop/web
|
||||||
const UA_ID = IS_WEB ? 'UA-60403362-12' : 'UA-60403362-13';
|
const UA_ID = IS_WEB ? 'UA-60403362-12' : 'UA-60403362-13';
|
||||||
|
|
||||||
|
// @if TARGET='app'
|
||||||
|
ElectronCookies.enable({
|
||||||
|
origin: 'https://lbry.tv',
|
||||||
|
});
|
||||||
|
// @endif
|
||||||
|
|
||||||
ReactGA.initialize(UA_ID, {
|
ReactGA.initialize(UA_ID, {
|
||||||
gaOptions: { name: IS_WEB ? 'web' : 'desktop' },
|
|
||||||
testMode: process.env.NODE_ENV !== 'production',
|
testMode: process.env.NODE_ENV !== 'production',
|
||||||
// debug: true,
|
cookieDomain: 'auto',
|
||||||
});
|
});
|
||||||
|
|
||||||
// Manually call the first page view
|
// Manually call the first page view
|
||||||
// React Router doesn't include this on `history.listen`
|
// React Router doesn't include this on `history.listen`
|
||||||
analytics.pageView(window.location.pathname + window.location.search);
|
analytics.pageView(window.location.pathname + window.location.search);
|
||||||
|
|
||||||
|
// @if TARGET='app'
|
||||||
|
ReactGA.set({ checkProtocolTask: null });
|
||||||
|
ReactGA.set({ location: 'https://lbry.tv' });
|
||||||
|
analytics.pageView(window.location.pathname.split('.html')[1] + window.location.search || '/');
|
||||||
|
// @endif;
|
||||||
|
|
||||||
// Listen for url changes and report
|
// Listen for url changes and report
|
||||||
// This will include search queries
|
// This will include search queries
|
||||||
history.listen(location => {
|
history.listen(location => {
|
||||||
|
|
29
yarn.lock
29
yarn.lock
|
@ -823,6 +823,14 @@
|
||||||
resolved "https://registry.yarnpkg.com/@emotion/memoize/-/memoize-0.7.1.tgz#e93c13942592cf5ef01aa8297444dc192beee52f"
|
resolved "https://registry.yarnpkg.com/@emotion/memoize/-/memoize-0.7.1.tgz#e93c13942592cf5ef01aa8297444dc192beee52f"
|
||||||
integrity sha512-Qv4LTqO11jepd5Qmlp3M1YEjBumoTHcHFdgPTQ+sFlIL5myi/7xu/POwP7IRu6odBdmLXdtIs1D6TuW6kbwbbg==
|
integrity sha512-Qv4LTqO11jepd5Qmlp3M1YEjBumoTHcHFdgPTQ+sFlIL5myi/7xu/POwP7IRu6odBdmLXdtIs1D6TuW6kbwbbg==
|
||||||
|
|
||||||
|
"@exponent/electron-cookies@^2.0.0":
|
||||||
|
version "2.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/@exponent/electron-cookies/-/electron-cookies-2.0.0.tgz#4cf8dcf851454036cc524c40e9e482fc4e23f2d9"
|
||||||
|
integrity sha1-TPjc+FFFQDbMUkxA6eSC/E4j8tk=
|
||||||
|
dependencies:
|
||||||
|
tough-cookie "^2.2.2"
|
||||||
|
tough-cookie-web-storage-store "^1.0.0"
|
||||||
|
|
||||||
"@hot-loader/react-dom@16.8":
|
"@hot-loader/react-dom@16.8":
|
||||||
version "16.8.6"
|
version "16.8.6"
|
||||||
resolved "https://registry.yarnpkg.com/@hot-loader/react-dom/-/react-dom-16.8.6.tgz#7923ba27db1563a7cc48d4e0b2879a140df461ea"
|
resolved "https://registry.yarnpkg.com/@hot-loader/react-dom/-/react-dom-16.8.6.tgz#7923ba27db1563a7cc48d4e0b2879a140df461ea"
|
||||||
|
@ -6769,7 +6777,7 @@ lodash.unset@^4.5.2:
|
||||||
resolved "https://registry.yarnpkg.com/lodash.unset/-/lodash.unset-4.5.2.tgz#370d1d3e85b72a7e1b0cdf2d272121306f23e4ed"
|
resolved "https://registry.yarnpkg.com/lodash.unset/-/lodash.unset-4.5.2.tgz#370d1d3e85b72a7e1b0cdf2d272121306f23e4ed"
|
||||||
integrity sha1-Nw0dPoW3Kn4bDN8tJyEhMG8j5O0=
|
integrity sha1-Nw0dPoW3Kn4bDN8tJyEhMG8j5O0=
|
||||||
|
|
||||||
lodash@^4.0.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.0, lodash@^4.2.1, lodash@~4.17.10:
|
lodash@^4.0.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.6.1, lodash@~4.17.10:
|
||||||
version "4.17.11"
|
version "4.17.11"
|
||||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
|
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
|
||||||
integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==
|
integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==
|
||||||
|
@ -9062,7 +9070,7 @@ pseudomap@^1.0.2:
|
||||||
resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3"
|
resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3"
|
||||||
integrity sha1-8FKijacOYYkX7wqKw0wa5aaChrM=
|
integrity sha1-8FKijacOYYkX7wqKw0wa5aaChrM=
|
||||||
|
|
||||||
psl@^1.1.24:
|
psl@^1.1.24, psl@^1.1.28:
|
||||||
version "1.1.31"
|
version "1.1.31"
|
||||||
resolved "https://registry.yarnpkg.com/psl/-/psl-1.1.31.tgz#e9aa86d0101b5b105cbe93ac6b784cd547276184"
|
resolved "https://registry.yarnpkg.com/psl/-/psl-1.1.31.tgz#e9aa86d0101b5b105cbe93ac6b784cd547276184"
|
||||||
integrity sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw==
|
integrity sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw==
|
||||||
|
@ -9122,7 +9130,7 @@ punycode@^1.2.4, punycode@^1.4.1:
|
||||||
resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e"
|
resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e"
|
||||||
integrity sha1-wNWmOycYgArY4esPpSachN1BhF4=
|
integrity sha1-wNWmOycYgArY4esPpSachN1BhF4=
|
||||||
|
|
||||||
punycode@^2.1.0:
|
punycode@^2.1.0, punycode@^2.1.1:
|
||||||
version "2.1.1"
|
version "2.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
|
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
|
||||||
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==
|
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==
|
||||||
|
@ -11067,6 +11075,21 @@ toposort@^1.0.0:
|
||||||
resolved "https://registry.yarnpkg.com/toposort/-/toposort-1.0.7.tgz#2e68442d9f64ec720b8cc89e6443ac6caa950029"
|
resolved "https://registry.yarnpkg.com/toposort/-/toposort-1.0.7.tgz#2e68442d9f64ec720b8cc89e6443ac6caa950029"
|
||||||
integrity sha1-LmhELZ9k7HILjMieZEOsbKqVACk=
|
integrity sha1-LmhELZ9k7HILjMieZEOsbKqVACk=
|
||||||
|
|
||||||
|
tough-cookie-web-storage-store@^1.0.0:
|
||||||
|
version "1.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/tough-cookie-web-storage-store/-/tough-cookie-web-storage-store-1.0.0.tgz#8021fce24290bf0b6151e491d7312343451d390d"
|
||||||
|
integrity sha1-gCH84kKQvwthUeSR1zEjQ0UdOQ0=
|
||||||
|
dependencies:
|
||||||
|
lodash "^4.6.1"
|
||||||
|
|
||||||
|
tough-cookie@^2.2.2:
|
||||||
|
version "2.5.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2"
|
||||||
|
integrity sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==
|
||||||
|
dependencies:
|
||||||
|
psl "^1.1.28"
|
||||||
|
punycode "^2.1.1"
|
||||||
|
|
||||||
tough-cookie@~2.4.3:
|
tough-cookie@~2.4.3:
|
||||||
version "2.4.3"
|
version "2.4.3"
|
||||||
resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.4.3.tgz#53f36da3f47783b0925afa06ff9f3b165280f781"
|
resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.4.3.tgz#53f36da3f47783b0925afa06ff9f3b165280f781"
|
||||||
|
|
Loading…
Reference in a new issue