File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -112,17 +112,7 @@ class RequestQueue {
112112 }
113113 }
114114
115- // Build security token header (mirrors Node SDK pattern)
116- const headers = { } ;
117- if ( this . options . securityToken && typeof this . options . securityToken === 'string' ) {
118- headers [ 'x-cnstrc-token' ] = this . options . securityToken ;
119- }
120- if ( this . options . userIp && typeof this . options . userIp === 'string' ) {
121- headers [ 'X-Forwarded-For' ] = this . options . userIp ;
122- }
123- if ( this . options . userAgent && typeof this . options . userAgent === 'string' ) {
124- headers [ 'User-Agent' ] = this . options . userAgent ;
125- }
115+ const headers = this . buildHeaders ( ) ;
126116
127117 if ( nextInQueue . method === 'GET' ) {
128118 request = fetch ( nextInQueue . url , { headers, signal } ) ;
@@ -199,6 +189,21 @@ class RequestQueue {
199189 }
200190 }
201191
192+ // Build request headers from options
193+ buildHeaders ( ) {
194+ const headers = { } ;
195+ if ( this . options . securityToken && typeof this . options . securityToken === 'string' ) {
196+ headers [ 'x-cnstrc-token' ] = this . options . securityToken ;
197+ }
198+ if ( this . options . userIp && typeof this . options . userIp === 'string' ) {
199+ headers [ 'X-Forwarded-For' ] = this . options . userIp ;
200+ }
201+ if ( this . options . userAgent && typeof this . options . userAgent === 'string' ) {
202+ headers [ 'User-Agent' ] = this . options . userAgent ;
203+ }
204+ return headers ;
205+ }
206+
202207 // Read from queue and send requests to server
203208 send ( ) {
204209 if ( this . sendTrackingEvents ) {
You can’t perform that action at this time.
0 commit comments