0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Cleaned up old analytics setup in Portal

refs https://github.com/TryGhost/Team/issues/2216

- the analytics tag was an old alpha concept and has been moved away from since so its safe to remove
- the flag that enabled this feature no longer exists so its completely inaccessible
This commit is contained in:
Rishabh 2022-11-11 11:09:01 +05:30 committed by Rishabh Garg
parent 9175b82ab9
commit 9a290b6f77
3 changed files with 0 additions and 55 deletions

View file

@ -1,21 +0,0 @@
import setupGhostApi from './utils/api';
function sendEntryViewEvent({analyticsId, api}) {
if (analyticsId) {
api.analytics.pushEvent({
type: 'entry_view',
entry_id: analyticsId,
entry_url: window.location.href,
created_at: new Date()
});
}
}
function setupAnalytics({siteUrl, analyticsId}) {
const GhostApi = setupGhostApi({siteUrl});
// Fire page/post view event
sendEntryViewEvent({analyticsId, api: GhostApi});
return {};
}
export default setupAnalytics;

View file

@ -2,7 +2,6 @@ import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import setupAnalytics from './analytics';
const ROOT_DIV_ID = 'ghost-portal-root';
@ -34,18 +33,9 @@ function handleTokenUrl() {
}
}
function setupAnalyticsScript({siteUrl}) {
const analyticsTag = document.querySelector('meta[name=ghost-analytics-id]');
const analyticsId = analyticsTag?.content;
if (siteUrl && analyticsTag) {
setupAnalytics({siteUrl, analyticsId});
}
}
function setup({siteUrl}) {
addRootDiv();
handleTokenUrl();
setupAnalyticsScript({siteUrl});
}
function init() {

View file

@ -28,30 +28,6 @@ function setupGhostApi({siteUrl = window.location.origin, apiUrl, apiKey}) {
}
const api = {};
api.analytics = {
async pushEvent(event) {
const url = endpointFor({type: 'members', resource: 'events'});
const identity = await api.member.identity();
event.identity = identity;
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.text();
});
}
};
api.site = {
read() {
const url = endpointFor({type: 'members', resource: 'site'});