@@ -4,6 +4,7 @@ const ContextFilter = require('./ContextFilter');
44const errors = require ( './errors' ) ;
55const messages = require ( './messages' ) ;
66const utils = require ( './utils' ) ;
7+ const { getContextKeys } = require ( './context' ) ;
78
89function 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