File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -892,7 +892,25 @@ class Particle {
892892 }
893893
894894 auth = this . _getActiveAuthToken ( auth ) ;
895- return new EventStream ( `${ this . baseUrl } ${ uri } ` , auth ) . connect ( ) ;
895+ const headers = this . _getDefaultHttpHeadersForContext ( ) ;
896+ return new EventStream ( `${ this . baseUrl } ${ uri } ` , auth , { headers } ) . connect ( ) ;
897+ }
898+
899+ /**
900+ * A reimplementation of Agent's _addToolContext() and _addProjectContext() methods
901+ * that can be used by getEventStream() which doesn't use Agent for http interactions
902+ * @private
903+ * @returns {Object } key/value http headers
904+ */
905+ _getDefaultHttpHeadersForContext ( ) {
906+ const returnThis = { } ;
907+ if ( this . context && this . context . tool ) {
908+ returnThis [ 'X-Particle-Tool' ] = `${ this . context . tool . name } @${ this . context . tool . version } ` ;
909+ }
910+ if ( this . context && this . context . project ) {
911+ returnThis [ 'X-Particle-Project' ] = `${ this . context . project . name } @${ this . context . project . version } ` ;
912+ }
913+ return returnThis ;
896914 }
897915
898916 /**
You can’t perform that action at this time.
0 commit comments