diff --git a/package.json b/package.json index 4406a3cc4..53d62571b 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,7 @@ "@babel/preset-flow": "^7.0.0", "@babel/preset-react": "^7.0.0", "@babel/register": "^7.0.0", + "@exponent/electron-cookies": "^2.0.0", "@hot-loader/react-dom": "16.8", "@lbry/color": "^1.0.2", "@lbry/components": "^2.7.0", diff --git a/src/ui/analytics.js b/src/ui/analytics.js index e4800b450..2dffc0b6c 100644 --- a/src/ui/analytics.js +++ b/src/ui/analytics.js @@ -2,6 +2,9 @@ import { Lbryio } from 'lbryinc'; import ReactGA from 'react-ga'; import { history } from './store'; +// @if TARGET='app' +import ElectronCookies from '@exponent/electron-cookies'; +// @endif type Analytics = { pageView: string => void, @@ -15,7 +18,7 @@ let analyticsEnabled: boolean = true; const analytics: Analytics = { pageView: path => { if (analyticsEnabled) { - ReactGA.pageview(path, IS_WEB ? ['web'] : ['desktop']); + ReactGA.pageview(path); } }, setUser: user => { @@ -78,16 +81,27 @@ const analytics: Analytics = { // Will change once we have separate ids for desktop/web 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, { - gaOptions: { name: IS_WEB ? 'web' : 'desktop' }, testMode: process.env.NODE_ENV !== 'production', - // debug: true, + cookieDomain: 'auto', }); // Manually call the first page view // React Router doesn't include this on `history.listen` 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 // This will include search queries history.listen(location => { diff --git a/yarn.lock b/yarn.lock index e5a0fd298..06015dcc1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -823,6 +823,14 @@ resolved "https://registry.yarnpkg.com/@emotion/memoize/-/memoize-0.7.1.tgz#e93c13942592cf5ef01aa8297444dc192beee52f" 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": version "16.8.6" 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" 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" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" 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" integrity sha1-8FKijacOYYkX7wqKw0wa5aaChrM= -psl@^1.1.24: +psl@^1.1.24, psl@^1.1.28: version "1.1.31" resolved "https://registry.yarnpkg.com/psl/-/psl-1.1.31.tgz#e9aa86d0101b5b105cbe93ac6b784cd547276184" 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" integrity sha1-wNWmOycYgArY4esPpSachN1BhF4= -punycode@^2.1.0: +punycode@^2.1.0, punycode@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" 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" 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: version "2.4.3" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.4.3.tgz#53f36da3f47783b0925afa06ff9f3b165280f781"