@@ -4,6 +4,7 @@ const ContextFilter = require('./ContextFilter');
4
4
const errors = require ( './errors' ) ;
5
5
const messages = require ( './messages' ) ;
6
6
const utils = require ( './utils' ) ;
7
+ const { getContextKeys } = require ( './context' ) ;
7
8
8
9
function EventProcessor (
9
10
platform ,
@@ -47,8 +48,14 @@ function EventProcessor(
47
48
function makeOutputEvent ( e ) {
48
49
const ret = utils . extend ( { } , e ) ;
49
50
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
+ }
52
59
53
60
if ( e . kind === 'feature' ) {
54
61
delete ret [ 'trackEvents' ] ;
@@ -57,6 +64,10 @@ function EventProcessor(
57
64
return ret ;
58
65
}
59
66
67
+ function getContextKeysFromEvent ( event ) {
68
+ return getContextKeys ( event . context , logger ) ;
69
+ }
70
+
60
71
function addToOutbox ( event ) {
61
72
if ( queue . length < eventCapacity ) {
62
73
queue . push ( event ) ;
0 commit comments