mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-23 19:02:29 +03:00
Updated ingress event handler to use new analytics ingress package
refs https://github.com/TryGhost/Team/issues/1064 - updates handling of member events to use new analytics ingress package which is responsible to ensure storage of event
This commit is contained in:
parent
07d65c4741
commit
317caacc0e
@ -14,13 +14,12 @@ class EventsController {
|
||||
const {events} = req.body;
|
||||
for (const event of events) {
|
||||
if (event.type === 'entry_view') {
|
||||
const {entryId, entryUrl, memberId, memberStatus, createdAt} = event;
|
||||
const entryEvent = new MemberEntryViewEvent({
|
||||
entryId,
|
||||
entryUrl,
|
||||
memberId,
|
||||
memberStatus
|
||||
}, createdAt);
|
||||
entryId: event.entry_id,
|
||||
entryUrl: event.entry_url,
|
||||
memberId: req.member ? req.member.id : null,
|
||||
memberStatus: req.member ? req.member.status : null
|
||||
}, event.created_at);
|
||||
DomainEvents.dispatch(entryEvent);
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ const common = require('./common');
|
||||
|
||||
const StripeAPIService = require('@tryghost/stripe-service');
|
||||
const MemberAnalyticsService = require('@tryghost/member-analytics-service');
|
||||
const MembersAnalyticsIngress = require('@tryghost/members-analytics-ingress');
|
||||
|
||||
const StripeWebhookService = require('./services/stripe-webhook');
|
||||
const TokenService = require('./services/token');
|
||||
@ -353,7 +354,7 @@ module.exports = function MembersAPI({
|
||||
),
|
||||
createEvents: Router().use(
|
||||
body.json(),
|
||||
(req, res) => routerController.createEvents(req, res)
|
||||
(req, res) => MembersAnalyticsIngress.createEvents(req, res)
|
||||
),
|
||||
updateSubscription: Router({mergeParams: true}).use(
|
||||
body.json(),
|
||||
|
@ -2,6 +2,7 @@ const common = require('../../lib/common');
|
||||
const _ = require('lodash');
|
||||
const errors = require('@tryghost/ignition-errors');
|
||||
const DomainEvents = require('@tryghost/domain-events');
|
||||
const MembersAnalyticsIngress = require('@tryghost/members-analytics-ingress');
|
||||
const {MemberEntryViewEvent} = require('@tryghost/member-events');
|
||||
|
||||
/**
|
||||
@ -220,30 +221,6 @@ module.exports = class RouterController {
|
||||
}
|
||||
}
|
||||
|
||||
async createEvents(req, res) {
|
||||
try {
|
||||
const {events} = req.body;
|
||||
for (const event of events) {
|
||||
if (event.type === 'entry_view') {
|
||||
const entryEvent = new MemberEntryViewEvent({
|
||||
entryId: event.entry_id,
|
||||
entryUrl: event.entry_url,
|
||||
memberId: req.member ? req.member.id : null,
|
||||
memberStatus: req.member ? req.member.status : null
|
||||
}, event.created_at);
|
||||
DomainEvents.dispatch(entryEvent);
|
||||
}
|
||||
}
|
||||
res.writeHead(201);
|
||||
return res.end('Created.');
|
||||
} catch (err) {
|
||||
const statusCode = (err && err.statusCode) || 500;
|
||||
common.logging.error(err);
|
||||
res.writeHead(statusCode);
|
||||
return res.end('Internal Server Error.');
|
||||
}
|
||||
}
|
||||
|
||||
async sendMagicLink(req, res) {
|
||||
const {email, emailType, oldEmail, requestSrc} = req.body;
|
||||
let forceEmailType = false;
|
||||
|
@ -33,6 +33,7 @@
|
||||
"@tryghost/magic-link": "^1.0.12",
|
||||
"@tryghost/member-analytics-service": "^0.1.0",
|
||||
"@tryghost/member-events": "^0.2.0",
|
||||
"@tryghost/members-analytics-ingress": "^0.1.0",
|
||||
"@tryghost/stripe-service": "^0.1.0",
|
||||
"@tryghost/tpl": "^0.1.2",
|
||||
"@types/jsonwebtoken": "^8.5.1",
|
||||
|
Loading…
Reference in New Issue
Block a user