mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-07-22 05:44:16 +00:00
Move group chat analytics event to server
This commit is contained in:
parent
a30c4379a6
commit
d934d9d759
3 changed files with 25 additions and 19 deletions
|
|
@ -23,25 +23,6 @@ export async function postChat (store, payload) {
|
|||
});
|
||||
}
|
||||
|
||||
if (group.privacy === 'public') {
|
||||
Analytics.track({
|
||||
hitType: 'event',
|
||||
eventCategory: 'behavior',
|
||||
eventAction: 'group chat',
|
||||
groupType: group.type,
|
||||
privacy: group.privacy,
|
||||
groupName: group.name,
|
||||
});
|
||||
} else {
|
||||
Analytics.track({
|
||||
hitType: 'event',
|
||||
eventCategory: 'behavior',
|
||||
eventAction: 'group chat',
|
||||
groupType: group.type,
|
||||
privacy: group.privacy,
|
||||
});
|
||||
}
|
||||
|
||||
let response = await axios.post(url, {
|
||||
message: payload.message,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -83,6 +83,8 @@ function getBannedWordsFromText (message) {
|
|||
return getMatchesByWordArray(message, bannedWords);
|
||||
}
|
||||
|
||||
|
||||
const mentionRegex = new RegExp('\\B@[-\\w]+', 'g');
|
||||
/**
|
||||
* @api {post} /api/v3/groups/:groupId/chat Post chat message to a group
|
||||
* @apiName PostChat
|
||||
|
|
@ -185,6 +187,28 @@ api.postChat = {
|
|||
|
||||
await Promise.all(toSave);
|
||||
|
||||
let analyticsObject = {
|
||||
uuid: user._id,
|
||||
hitType: 'event',
|
||||
category: 'behavior',
|
||||
groupType: group.type,
|
||||
privacy: group.privacy,
|
||||
headers: req.headers,
|
||||
};
|
||||
|
||||
const mentions = req.body.message.match(mentionRegex);
|
||||
if (mentions) {
|
||||
analyticsObject.mentionsCount = mentions.length;
|
||||
} else {
|
||||
analyticsObject.mentionsCount = 0;
|
||||
}
|
||||
if (group.privacy === 'public') {
|
||||
analyticsObject.groupName = group.name;
|
||||
}
|
||||
|
||||
console.log(analyticsObject);
|
||||
res.analytics.track('group chat', analyticsObject);
|
||||
|
||||
if (chatUpdated) {
|
||||
res.respond(200, {chat: chatRes.chat});
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -269,6 +269,7 @@ let _sendPurchaseDataToGoogle = (data) => {
|
|||
};
|
||||
|
||||
function track (eventType, data) {
|
||||
console.log(eventType, data);
|
||||
return Promise.all([
|
||||
_sendDataToAmplitude(eventType, data),
|
||||
_sendDataToGoogle(eventType, data),
|
||||
|
|
|
|||
Loading…
Reference in a new issue