mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-03 08:25:06 +03:00
Added alpha analytics api setup
refs https://github.com/TryGhost/Team/issues/1062 Member activity is a labs alpha feature which aims at capturing member events for site owner if switched on. The event metadata captures the site page/post where the event originates from, and the post/page id is included as content of new ghost analytics meta tag. This change adds a new alpha API endpoint for pushing events to new ingress endpoint, which Portal's new analytics script can use to push events upstream.
This commit is contained in:
parent
5893a85359
commit
bfa91ee1ea
@ -7,7 +7,7 @@ function setupGhostApi({siteUrl = window.location.origin}) {
|
||||
}
|
||||
}
|
||||
|
||||
function makeRequest({url, method, headers = {}, credentials, body}) {
|
||||
function makeRequest({url, method = 'GET', headers = {}, credentials = undefined, body = undefined}) {
|
||||
const options = {
|
||||
method,
|
||||
headers,
|
||||
@ -18,6 +18,28 @@ function setupGhostApi({siteUrl = window.location.origin}) {
|
||||
}
|
||||
const api = {};
|
||||
|
||||
api.analytics = {
|
||||
pushEvent(event) {
|
||||
const url = endpointFor({type: 'members', resource: 'events'});
|
||||
const body = {
|
||||
events: [event]
|
||||
};
|
||||
return makeRequest({
|
||||
url,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(body)
|
||||
}).then(function (res) {
|
||||
if (!res.ok) {
|
||||
return null;
|
||||
}
|
||||
return res.json();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
api.site = {
|
||||
read() {
|
||||
const url = endpointFor({type: 'members', resource: 'site'});
|
||||
|
Loading…
Reference in New Issue
Block a user