ApplicationInsights-PHP icon indicating copy to clipboard operation
ApplicationInsights-PHP copied to clipboard

PHP: trackEvent() not making it to App Insights

Open cobydodd opened this issue 5 years ago • 1 comments

Hi All, I'm attempting to send an event with some custom data to App Insights and I'm not seeing ANY events appearing there. I have confirmed I'm using the correct Instrumentation Key and have used the same block below to send just an event 'name' for testing, with no luck. Any idea what I could be missing? I'm not seeing any errors and I'm not sure how else to troubleshoot this. Any help is much appreciated! My code block:

public static function uploadJobQueueDataAppInsights($intJobQueueId){

$strEventName = "GccJobQueueUpdate";
$objJobQueue = new JobQueue();
$objJobQueue->id = $intJobQueueId;
$objJobQueueDetails = $objJobQueue->getJobQueueById();
$arrJobQueueDetails = (array)$objJobQueueDetails;

if(isset($arrJobQueueDetails[0])){
   $objTelemetryClient = new Telemetry_Client();
   $objContext = $objTelemetryClient->getContext();
   $objContext->setInstrumentationKey(Utilities::APP_INSIGHTS_INSTRUMENTATION_KEY);
   $objTelemetryClient->trackEvent($strEventName, $arrJobQueueDetails[0]);
   $objTelemetryClient->flush();
   unset($objContext, $objTelemetryClient);
}

}

cobydodd avatar Apr 05 '19 15:04 cobydodd

Try the latest version, trackEvent was finally fixed now it seems

MichelZ avatar Apr 28 '19 05:04 MichelZ