From 5dff014c25e7b7c90fc7b89f227eedfd6060c1c9 Mon Sep 17 00:00:00 2001 From: Rishabh Date: Tue, 21 Sep 2021 11:58:57 +0530 Subject: [PATCH] Attached member identity to analytic events refs https://github.com/TryGhost/Team/issues/1062 - adds member identity to view events to attach member metadata on event --- ghost/portal/src/analytics.js | 7 +++---- ghost/portal/src/utils/api.js | 4 +++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ghost/portal/src/analytics.js b/ghost/portal/src/analytics.js index db921b37dc..7529085ccf 100644 --- a/ghost/portal/src/analytics.js +++ b/ghost/portal/src/analytics.js @@ -3,11 +3,10 @@ import setupGhostApi from './utils/api'; function sendEntryViewEvent({analyticsId, api}) { if (analyticsId) { api.analytics.pushEvent({ - event_name: 'entry_view', - member_id: '', - member_status: '', + type: 'entry_view', entry_id: analyticsId, - source_url: window.location.href + source_url: window.location.href, + created_at: new Date() }); } } diff --git a/ghost/portal/src/utils/api.js b/ghost/portal/src/utils/api.js index e27fc8f8e5..4f225ed176 100644 --- a/ghost/portal/src/utils/api.js +++ b/ghost/portal/src/utils/api.js @@ -19,8 +19,10 @@ function setupGhostApi({siteUrl = window.location.origin}) { const api = {}; api.analytics = { - pushEvent(event) { + async pushEvent(event) { const url = endpointFor({type: 'members', resource: 'events'}); + const identity = await api.member.identity(); + event.identity = identity; const body = { events: [event] };