Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/EventProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const ContextFilter = require('./ContextFilter');
const errors = require('./errors');
const messages = require('./messages');
const utils = require('./utils');
const { getContextKeys } = require('./context');

function EventProcessor(
platform,
Expand Down Expand Up @@ -47,8 +48,14 @@ function EventProcessor(
function makeOutputEvent(e) {
const ret = utils.extend({}, e);

// This method is used for identify, feature, and custom events, which always have an inline context.
ret.context = contextFilter.filter(e.context);
// Identify, feature, and custom events should all include the full context.
// Debug events do as well, but are not handled by this code path.
if (e.kind === 'identify' || e.kind === 'feature' || e.kind === 'custom') {
ret.context = contextFilter.filter(e.context);
} else {
ret.contextKeys = getContextKeysFromEvent(e);
delete ret['context'];
}

if (e.kind === 'feature') {
delete ret['trackEvents'];
Expand All @@ -57,6 +64,10 @@ function EventProcessor(
return ret;
}

function getContextKeysFromEvent(event) {
return getContextKeys(event.context, logger);
}

function addToOutbox(event) {
if (queue.length < eventCapacity) {
queue.push(event);
Expand Down