@@ -51,8 +51,8 @@ protected function onError(HitAbstract $hit): void
5151 protected function sendHit (HitAbstract $ hit ): void
5252 {
5353 $ header = [
54- FlagshipConstant::HEADER_CONTENT_TYPE => FlagshipConstant::HEADER_APPLICATION_JSON ,
55- ];
54+ FlagshipConstant::HEADER_CONTENT_TYPE => FlagshipConstant::HEADER_APPLICATION_JSON ,
55+ ];
5656
5757 $ requestBody = $ hit ->toApiKeys ();
5858 $ now = $ this ->getNow ();
@@ -68,8 +68,8 @@ protected function sendHit(HitAbstract $hit): void
6868 FlagshipConstant::TRACKING_MANAGER ,
6969 FlagshipConstant::HIT_SENT_SUCCESS ,
7070 [
71- FlagshipConstant::SEND_HIT ,
72- $ this ->getLogFormat (null , $ url , $ requestBody , $ header , $ this ->getNow () - $ now ),
71+ FlagshipConstant::SEND_HIT ,
72+ $ this ->getLogFormat (null , $ url , $ requestBody , $ header , $ this ->getNow () - $ now ),
7373 ]
7474 );
7575 } catch (Exception $ exception ) {
@@ -79,12 +79,23 @@ protected function sendHit(HitAbstract $hit): void
7979 FlagshipConstant::TRACKING_MANAGER ,
8080 FlagshipConstant::UNEXPECTED_ERROR_OCCURRED ,
8181 [
82- FlagshipConstant::SEND_HIT ,
83- $ this ->getLogFormat ($ exception ->getMessage (), $ url , $ requestBody , $ header , $ this ->getNow () - $ now ),
82+ FlagshipConstant::SEND_HIT ,
83+ $ this ->getLogFormat ($ exception ->getMessage (), $ url , $ requestBody , $ header , $ this ->getNow () - $ now ),
8484 ]
8585 );
8686 $ troubleshooting = new Troubleshooting ();
87- $ troubleshooting ->setLabel (TroubleshootingLabel::SEND_HIT_ROUTE_ERROR )->setLogLevel (LogLevel::ERROR )->setVisitorId ($ this ->flagshipInstanceId )->setFlagshipInstanceId ($ this ->flagshipInstanceId )->setTraffic (100 )->setConfig ($ this ->config )->setHttpRequestBody ($ requestBody )->setHttpRequestHeaders ($ header )->setHttpRequestMethod ("POST " )->setHttpRequestUrl ($ url )->setHttpResponseBody ($ exception ->getMessage ())->setHttpResponseTime ($ this ->getNow () - $ now );
87+ $ troubleshooting ->setLabel (TroubleshootingLabel::SEND_HIT_ROUTE_ERROR )
88+ ->setLogLevel (LogLevel::ERROR )
89+ ->setFlagshipInstanceId ($ this ->flagshipInstanceId )
90+ ->setHttpRequestBody ($ requestBody )
91+ ->setHttpRequestHeaders ($ header )
92+ ->setHttpRequestMethod ("POST " )
93+ ->setHttpRequestUrl ($ url )
94+ ->setHttpResponseBody ($ exception ->getMessage ())
95+ ->setHttpResponseTime ($ this ->getNow () - $ now )
96+ ->setTraffic (100 )->setConfig ($ this ->config )
97+ ->setVisitorId ($ this ->flagshipInstanceId )
98+ ;
8899 $ this ->addTroubleshootingHit ($ troubleshooting );
89100 $ this ->sendTroubleshootingQueue ();
90101 }
@@ -117,8 +128,8 @@ public function activateFlag(Activate $hit): void
117128 FlagshipConstant::TRACKING_MANAGER ,
118129 FlagshipConstant::HIT_SENT_SUCCESS ,
119130 [
120- FlagshipConstant::SEND_ACTIVATE ,
121- $ this ->getLogFormat (null , $ url , $ requestBody , $ headers , $ this ->getNow () - $ now ),
131+ FlagshipConstant::SEND_ACTIVATE ,
132+ $ this ->getLogFormat (null , $ url , $ requestBody , $ headers , $ this ->getNow () - $ now ),
122133 ]
123134 );
124135 } catch (Exception $ exception ) {
@@ -128,22 +139,29 @@ public function activateFlag(Activate $hit): void
128139 FlagshipConstant::TRACKING_MANAGER ,
129140 FlagshipConstant::UNEXPECTED_ERROR_OCCURRED ,
130141 [
131- FlagshipConstant::SEND_ACTIVATE ,
132- $ this ->getLogFormat ($ exception ->getMessage (), $ url , $ requestBody , $ headers , $ this ->getNow () - $ now ),
142+ FlagshipConstant::SEND_ACTIVATE ,
143+ $ this ->getLogFormat ($ exception ->getMessage (), $ url , $ requestBody , $ headers , $ this ->getNow () - $ now ),
133144 ]
134145 );
135146
136147 $ troubleshooting = new Troubleshooting ();
137- $ troubleshooting ->setLabel (TroubleshootingLabel::SEND_ACTIVATE_HIT_ROUTE_ERROR )->setLogLevel (LogLevel::ERROR )->setVisitorId ($ this ->flagshipInstanceId )->setFlagshipInstanceId ($ this ->flagshipInstanceId )->setTraffic (100 )->setConfig ($ this ->config )->setHttpRequestBody ($ requestBody )->setHttpRequestHeaders ($ headers )->setHttpRequestMethod ("POST " )->setHttpRequestUrl ($ url )->setHttpResponseBody ($ exception ->getMessage ())->setHttpResponseTime ($ this ->getNow () - $ now );
148+ $ troubleshooting ->setLabel (TroubleshootingLabel::SEND_ACTIVATE_HIT_ROUTE_ERROR )
149+ ->setFlagshipInstanceId ($ this ->flagshipInstanceId )
150+ ->setHttpRequestBody ($ requestBody )
151+ ->setHttpRequestHeaders ($ headers )
152+ ->setHttpRequestMethod ("POST " )
153+ ->setHttpRequestUrl ($ url )
154+ ->setHttpResponseBody ($ exception ->getMessage ())
155+ ->setHttpResponseTime ($ this ->getNow () - $ now )
156+ ->setLogLevel (LogLevel::ERROR )
157+ ->setTraffic (100 )->setConfig ($ this ->config )
158+ ->setVisitorId ($ this ->flagshipInstanceId );
138159 $ this ->addTroubleshootingHit ($ troubleshooting );
139160 $ this ->sendTroubleshootingQueue ();
140161 }
141162 }
142163
143- /**
144- * @param string $visitorId
145- * @return void
146- */
164+
147165 protected function notConsent (string $ visitorId ): void
148166 {
149167 $ keysToFlush = $ this ->commonNotConsent ($ visitorId );
@@ -157,7 +175,10 @@ protected function notConsent(string $visitorId): void
157175
158176 public function addTroubleshootingHit (Troubleshooting $ hit ): void
159177 {
160- $ this ->sendTroubleshooting ($ hit );
178+ if (!$ this ->isTroubleshootingActivated ()) {
179+ return ;
180+ }
181+ $ this ->sendTroubleshooting ($ hit );
161182 }
162183
163184 public function addUsageHit (UsageHit $ hit ): void
0 commit comments