Skip to content

Instantly share code, notes, and snippets.

@digitalbase
Created April 23, 2020 19:44
Show Gist options
  • Save digitalbase/622afab06110fdd0e0589f3a03142198 to your computer and use it in GitHub Desktop.
Save digitalbase/622afab06110fdd0e0589f3a03142198 to your computer and use it in GitHub Desktop.
// src/utils/event_extraction.util.js
module.exports = (request_body) => {
const referrer = request_body.context.page.referrer;
const href = request_body.context.page.url;
const anonymousId = request_body.anonymousId;
const messageId = request_body.messageId;
const userId = request_body.userId;
const type = request_body.type;
const timestamp = request_body.timestamp;
// Only handle `page` and `track` events
if (type !== 'page' && type !== 'track') {
return false;
}
return {
referrer,
messageId,
href,
anonymousId,
timestamp,
userId
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment