Skip to content

Commit 042074e

Browse files
authored
chore: Do not inline context in click/pageview events. (#120)
Chore as this has not been released.
1 parent 85c227c commit 042074e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/EventProcessor.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const ContextFilter = require('./ContextFilter');
44
const errors = require('./errors');
55
const messages = require('./messages');
66
const utils = require('./utils');
7+
const { getContextKeys } = require('./context');
78

89
function EventProcessor(
910
platform,
@@ -47,8 +48,14 @@ function EventProcessor(
4748
function makeOutputEvent(e) {
4849
const ret = utils.extend({}, e);
4950

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

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

67+
function getContextKeysFromEvent(event) {
68+
return getContextKeys(event.context, logger);
69+
}
70+
6071
function addToOutbox(event) {
6172
if (queue.length < eventCapacity) {
6273
queue.push(event);

0 commit comments

Comments
 (0)