File tree Expand file tree Collapse file tree 4 files changed +24
-8
lines changed
packages/signals/signals/src/core Expand file tree Collapse file tree 4 files changed +24
-8
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @segment/analytics-signals ' : patch
3+ ---
4+
5+ Redact formData
Original file line number Diff line number Diff line change @@ -79,11 +79,11 @@ describe(redactSignalData, () => {
7979 it ( 'should redact the value in the "target" property if the type is "interaction"' , ( ) => {
8080 const signal = factories . createInteractionSignal ( {
8181 eventType : 'change' ,
82- target : { value : 'secret' } ,
82+ target : { value : 'secret' , formData : { password : '123' } } ,
8383 } )
8484 const expected = factories . createInteractionSignal ( {
8585 eventType : 'change' ,
86- target : { value : 'XXX' } ,
86+ target : { value : 'XXX' , formData : { password : 'XXX' } } ,
8787 } )
8888 expect ( redactSignalData ( signal ) ) . toEqual ( expected )
8989 } )
Original file line number Diff line number Diff line change @@ -3,8 +3,15 @@ import { Signal } from '@segment/analytics-signals-runtime'
33export const redactSignalData = ( signalArg : Signal ) : Signal => {
44 const signal = structuredClone ( signalArg )
55 if ( signal . type === 'interaction' ) {
6- if ( 'target' in signal . data && 'value' in signal . data . target ) {
7- signal . data . target . value = redactJsonValues ( signal . data . target . value )
6+ if ( 'target' in signal . data ) {
7+ if ( 'value' in signal . data . target ) {
8+ signal . data . target . value = redactJsonValues ( signal . data . target . value )
9+ }
10+ if ( 'formData' in signal . data . target ) {
11+ signal . data . target . formData = redactJsonValues (
12+ signal . data . target . formData
13+ )
14+ }
815 }
916 } else if ( signal . type === 'network' ) {
1017 signal . data = redactJsonValues ( signal . data , 2 )
Original file line number Diff line number Diff line change @@ -56,12 +56,12 @@ interface ParsedElementBase {
5656 id : string
5757 labels ?: Label [ ]
5858 label ?: Label
59- name : string
59+ name ? : string
6060 nodeName : string
6161 tagName : string
6262 title : string
63- type : string
64- value : string
63+ type ? : string
64+ value ? : string
6565 textContent ?: string
6666 innerText ?: string
6767}
@@ -88,6 +88,8 @@ interface ParsedMediaElement extends ParsedElementBase {
8888
8989interface ParsedHTMLFormElement extends ParsedElementBase {
9090 formData : Record < string , string >
91+ innerText : never
92+ textContent : never
9193}
9294
9395type AnyParsedElement =
@@ -99,7 +101,7 @@ type AnyParsedElement =
99101
100102const parseElement = ( el : HTMLElement ) : AnyParsedElement => {
101103 const labels = parseLabels ( ( el as HTMLInputElement ) . labels )
102- const base = {
104+ const base : ParsedElementBase = {
103105 // adding a bunch of fields that are not on _all_ elements, but are on enough that it's useful to have them here.
104106 attributes : parseNodeMap ( el . attributes ) ,
105107 classList : [ ...el . classList ] ,
@@ -147,6 +149,8 @@ const parseElement = (el: HTMLElement): AnyParsedElement => {
147149 } else if ( el instanceof HTMLFormElement ) {
148150 return {
149151 ...base ,
152+ innerText : undefined ,
153+ textContent : undefined ,
150154 formData : parseFormData ( new FormData ( el ) ) ,
151155 }
152156 }
You can’t perform that action at this time.
0 commit comments