fix: analytics
This commit is contained in:
parent
53a9396ad3
commit
82c19f3aac
1 changed files with 13 additions and 3 deletions
|
@ -26,7 +26,10 @@ const analytics: Analytics = {
|
||||||
// }
|
// }
|
||||||
},
|
},
|
||||||
toggle: (enabled: boolean): void => {
|
toggle: (enabled: boolean): void => {
|
||||||
|
// Always collect analytics on lbry.tv
|
||||||
|
// @if TARGET='app'
|
||||||
analyticsEnabled = enabled;
|
analyticsEnabled = enabled;
|
||||||
|
// @endif
|
||||||
},
|
},
|
||||||
apiLogView: (uri, outpoint, claimId, timeToStart, onSuccessCb) => {
|
apiLogView: (uri, outpoint, claimId, timeToStart, onSuccessCb) => {
|
||||||
if (analyticsEnabled) {
|
if (analyticsEnabled) {
|
||||||
|
@ -78,6 +81,7 @@ const UA_ID = IS_WEB ? 'UA-60403362-12' : 'UA-60403362-12';
|
||||||
ReactGA.initialize(UA_ID, {
|
ReactGA.initialize(UA_ID, {
|
||||||
gaOptions: { name: IS_WEB ? 'web' : 'desktop' },
|
gaOptions: { name: IS_WEB ? 'web' : 'desktop' },
|
||||||
testMode: process.env.NODE_ENV !== 'production',
|
testMode: process.env.NODE_ENV !== 'production',
|
||||||
|
// debug: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Manually call the first page view
|
// Manually call the first page view
|
||||||
|
@ -87,9 +91,15 @@ analytics.pageView(window.location.pathname + window.location.search);
|
||||||
// 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 => {
|
||||||
const { pathname, search } = location;
|
const {
|
||||||
const page = `${pathname}${search}`;
|
pathname,
|
||||||
analytics.pageView(page);
|
// search
|
||||||
|
} = location;
|
||||||
|
|
||||||
|
// TODO: include search query somehow but not in the page name
|
||||||
|
// Google analytics separates those into different pages
|
||||||
|
// const page = `${pathname}${search}`;
|
||||||
|
analytics.pageView(pathname);
|
||||||
});
|
});
|
||||||
|
|
||||||
export default analytics;
|
export default analytics;
|
||||||
|
|
Loading…
Reference in a new issue