@@ -122,7 +122,7 @@ public void TrackSimulationEnded(Guid simulationId, string simulationType)
122122 /// <param name="eventName">The event name (SimulationStarted/SimulationEnded).</param>
123123 /// <param name="simulationId">The simulation ID.</param>
124124 /// <param name="simulationType">The simulation type.</param>
125- /// <param name="waitForTransmission">If true, blocks until transmission completes (use for CPU-intensive simulations).</param>
125+ /// <param name="waitForTransmission">If true, waits briefly to allow transmission (use for CPU-intensive simulations).</param>
126126 internal void TrackSimulationEvent ( string eventName , Guid simulationId , string simulationType , bool waitForTransmission = false )
127127 {
128128 _logger . LogWarning (
@@ -133,7 +133,7 @@ internal void TrackSimulationEvent(string eventName, Guid simulationId, string s
133133 {
134134 if ( _telemetryClient == null )
135135 {
136- _logger . LogWarning ( "⚠️ TelemetryClient not available (App Insights not configured) , skipping event tracking" ) ;
136+ _logger . LogWarning ( "⚠️ TelemetryClient not available, skipping event tracking" ) ;
137137 return ;
138138 }
139139
@@ -146,16 +146,15 @@ internal void TrackSimulationEvent(string eventName, Guid simulationId, string s
146146 _telemetryClient . TrackEvent ( eventName , properties ) ;
147147 _logger . LogWarning ( "📊 TrackEvent called for {EventName}" , eventName ) ;
148148
149- // Flush to ensure event is sent
150- _telemetryClient . Flush ( ) ;
151- _logger . LogWarning ( "📊 Flush called for {EventName}" , eventName ) ;
149+ // Note: Don't call Flush() - SDK v3 has a bug where it throws NullReferenceException
150+ // The SDK will batch and send telemetry automatically
152151
153- // For CPU-intensive operations, wait to ensure transmission completes
152+ // For CPU-intensive operations, wait briefly to allow the SDK to send
154153 // before background threads saturate all cores
155154 if ( waitForTransmission )
156155 {
157156 _logger . LogWarning ( "📊 Waiting 1s for telemetry transmission..." ) ;
158- Thread . Sleep ( 1000 ) ; // Give network I/O time to complete
157+ Thread . Sleep ( 1000 ) ;
159158 }
160159
161160 _logger . LogWarning ( "📊 Successfully tracked event {EventName}" , eventName ) ;
0 commit comments