@@ -248,6 +248,13 @@ const isSyncMode = (value: unknown): value is SyncMode => {
248
248
return syncModeTypes . find ( ( validValue ) => value === validValue ) !== undefined
249
249
}
250
250
251
+ const INTERNAL_HIDDEN_FIELDS = [ '__segment_internal_sync_mode' , '__segment_internal_matching_key' ]
252
+ const removeInternalHiddenFields = ( mapping : JSONLikeObject ) : JSONLikeObject => {
253
+ return Object . keys ( mapping ) . reduce ( ( acc , key ) => {
254
+ return INTERNAL_HIDDEN_FIELDS . includes ( key ) ? acc : { ...acc , [ key ] : mapping [ key ] }
255
+ } , { } )
256
+ }
257
+
251
258
/**
252
259
* Action is the beginning step for all partner actions. Entrypoints always start with the
253
260
* MapAndValidateInput step.
@@ -334,6 +341,8 @@ export class Action<Settings, Payload extends JSONLikeObject, AudienceSettings =
334
341
results . push ( { output : 'Payload validated' } )
335
342
}
336
343
344
+ payload = removeInternalHiddenFields ( payload ) as Payload
345
+
337
346
let hookOutputs = { }
338
347
if ( this . definition . hooks ) {
339
348
for ( const hookType in this . definition . hooks ) {
@@ -402,10 +411,11 @@ export class Action<Settings, Payload extends JSONLikeObject, AudienceSettings =
402
411
403
412
for ( let i = 0 ; i < payloads . length ; i ++ ) {
404
413
// Remove empty values (`null`, `undefined`, `''`) when not explicitly accepted
405
- const payload = removeEmptyValues ( payloads [ i ] , schema ) as Payload
414
+ let payload = removeEmptyValues ( payloads [ i ] , schema ) as Payload
406
415
// Validate payload schema
407
416
try {
408
417
validateSchema ( payload , schema , validationOptions )
418
+ payload = removeInternalHiddenFields ( payload ) as Payload
409
419
} catch ( e ) {
410
420
// Validation failed with an exception, record the filtered out event
411
421
multiStatusResponse [ i ] = {
0 commit comments