2021-09-20 12:41:54 +03:00
|
|
|
import setupGhostApi from './utils/api';
|
|
|
|
|
|
|
|
function sendEntryViewEvent({analyticsId, api}) {
|
|
|
|
if (analyticsId) {
|
|
|
|
api.analytics.pushEvent({
|
2021-09-21 09:28:57 +03:00
|
|
|
type: 'entry_view',
|
2021-09-20 12:41:54 +03:00
|
|
|
entry_id: analyticsId,
|
2021-09-21 14:57:37 +03:00
|
|
|
entry_url: window.location.href,
|
2021-09-21 09:28:57 +03:00
|
|
|
created_at: new Date()
|
2021-09-20 12:41:54 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function setupAnalytics({siteUrl, analyticsId}) {
|
|
|
|
const GhostApi = setupGhostApi({siteUrl});
|
|
|
|
// Fire page/post view event
|
|
|
|
sendEntryViewEvent({analyticsId, api: GhostApi});
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default setupAnalytics;
|