@@ -13,7 +13,8 @@ export type SignalsSettingsConfig = Pick<
1313 | 'functionHost'
1414 | 'flushAt'
1515 | 'flushInterval'
16- | 'enableSignalsDebug'
16+ | 'disableSignalsRedaction'
17+ | 'enableSignalsIngestion'
1718 | 'networkSignalsAllowList'
1819 | 'networkSignalsDisallowList'
1920 | 'networkSignalsAllowSameDomain'
@@ -43,7 +44,10 @@ export class SignalGlobalSettings {
4344 )
4445 }
4546
46- this . signalsDebug = new SignalsDebugSettings ( settings . enableSignalsDebug )
47+ this . signalsDebug = new SignalsDebugSettings (
48+ settings . disableSignalsRedaction ,
49+ settings . enableSignalsIngestion
50+ )
4751
4852 this . signalBuffer = {
4953 signalStorage : settings . signalStorage ,
@@ -53,9 +57,10 @@ export class SignalGlobalSettings {
5357 apiHost : settings . apiHost ,
5458 flushAt : settings . flushAt ,
5559 flushInterval : settings . flushInterval ,
56- shouldDisableSignalRedaction : this . signalsDebug . getSignalsDebug ,
60+ shouldDisableSignalsRedaction :
61+ this . signalsDebug . getDisableSignalsRedaction ,
5762 shouldIngestSignals : ( ) => {
58- if ( this . signalsDebug . getSignalsDebug ( ) ) {
63+ if ( this . signalsDebug . getEnableSignalsIngestion ( ) ) {
5964 return true
6065 }
6166 if ( ! this . sampleSuccess ) {
@@ -106,10 +111,14 @@ export class SignalGlobalSettings {
106111}
107112
108113class SignalsDebugSettings {
109- private static key = 'segment_signals_debug'
110- constructor ( initialValue ?: boolean ) {
111- if ( typeof initialValue === 'boolean' ) {
112- this . setSignalsDebug ( initialValue )
114+ private static redactionKey = 'segment_signals_debug_redaction_disabled'
115+ private static ingestionKey = 'segment_signals_debug_ingestion_enabled'
116+ constructor ( disableRedaction ?: boolean , enableIngestion ?: boolean ) {
117+ if ( typeof disableRedaction === 'boolean' ) {
118+ this . setDebugKey ( SignalsDebugSettings . redactionKey , disableRedaction )
119+ }
120+ if ( typeof enableIngestion === 'boolean' ) {
121+ this . setDebugKey ( SignalsDebugSettings . ingestionKey , enableIngestion )
113122 }
114123
115124 // setting ?segment_signals_debug=true will disable redaction, enable ingestion, and set keys in local storage
@@ -118,30 +127,46 @@ class SignalsDebugSettings {
118127 const debugModeInQs = parseDebugModeQueryString ( )
119128 logger . debug ( 'debugMode is set to true via query string' )
120129 if ( typeof debugModeInQs === 'boolean' ) {
121- this . setSignalsDebug ( debugModeInQs )
130+ this . setDebugKey ( SignalsDebugSettings . redactionKey , debugModeInQs )
131+ this . setDebugKey ( SignalsDebugSettings . ingestionKey , debugModeInQs )
122132 }
123133 }
124134
125- setSignalsDebug ( shouldDisable : boolean ) {
135+ setDebugKey ( key : string , enable : boolean ) {
126136 try {
127- if ( shouldDisable ) {
128- window . sessionStorage . setItem ( SignalsDebugSettings . key , 'true' )
137+ if ( enable ) {
138+ window . sessionStorage . setItem ( key , 'true' )
129139 } else {
130- logger . debug ( 'Removing debug key from storage' )
131- window . sessionStorage . removeItem ( SignalsDebugSettings . key )
140+ logger . debug ( `Removing debug key ${ key } from storage` )
141+ window . sessionStorage . removeItem ( key )
142+ }
143+ } catch ( e ) {
144+ logger . debug ( 'Storage error' , e )
145+ }
146+ }
147+
148+ getDisableSignalsRedaction ( ) {
149+ try {
150+ const isEnabled = Boolean (
151+ window . sessionStorage . getItem ( SignalsDebugSettings . redactionKey )
152+ )
153+ if ( isEnabled ) {
154+ logger . debug ( `${ SignalsDebugSettings . redactionKey } =true (app. storage)` )
155+ return true
132156 }
133157 } catch ( e ) {
134158 logger . debug ( 'Storage error' , e )
135159 }
160+ return false
136161 }
137162
138- getSignalsDebug ( ) {
163+ getEnableSignalsIngestion ( ) {
139164 try {
140- const isDisabled = Boolean (
141- window . sessionStorage . getItem ( SignalsDebugSettings . key )
165+ const isEnabled = Boolean (
166+ window . sessionStorage . getItem ( SignalsDebugSettings . ingestionKey )
142167 )
143- if ( isDisabled ) {
144- logger . debug ( `${ SignalsDebugSettings . key } =true (app. storage)` )
168+ if ( isEnabled ) {
169+ logger . debug ( `${ SignalsDebugSettings . ingestionKey } =true (app. storage)` )
145170 return true
146171 }
147172 } catch ( e ) {
0 commit comments