@@ -24,7 +24,7 @@ public static void TrackEvent(this TelemetryClient telemetryClient, string event
2424 properties = new Dictionary < string , string > ( ) ;
2525 }
2626
27- AddTargetingProperties ( properties , targetingContext ) ;
27+ properties [ "TargetingId" ] = targetingContext . UserId ;
2828
2929 telemetryClient . TrackEvent ( eventName , properties , metrics ) ;
3030 }
@@ -41,56 +41,17 @@ public static void TrackEvent(this TelemetryClient telemetryClient, EventTelemet
4141 telemetry = new EventTelemetry ( ) ;
4242 }
4343
44- AddTargetingProperties ( telemetry . Properties , targetingContext ) ;
44+ telemetry . Properties [ "TargetingId" ] = targetingContext . UserId ;
4545
4646 telemetryClient . TrackEvent ( telemetry ) ;
4747 }
4848
49- /// <summary>
50- /// Extension method to track a metric with <see cref="TargetingContext"/>.
51- /// </summary>
52- public static void TrackMetric ( this TelemetryClient telemetryClient , string name , double value , TargetingContext targetingContext , IDictionary < string , string > properties = null )
53- {
54- ValidateTargetingContext ( targetingContext ) ;
55-
56- if ( properties == null )
57- {
58- properties = new Dictionary < string , string > ( ) ;
59- }
60-
61- AddTargetingProperties ( properties , targetingContext ) ;
62-
63- telemetryClient . TrackMetric ( name , value , properties ) ;
64- }
65-
66- /// <summary>
67- /// Extension method to track a <see cref="MetricTelemetry"/> with <see cref="TargetingContext"/>.
68- /// </summary>
69- public static void TrackMetric ( this TelemetryClient telemetryClient , MetricTelemetry telemetry , TargetingContext targetingContext )
70- {
71- ValidateTargetingContext ( targetingContext ) ;
72-
73- if ( telemetry == null )
74- {
75- telemetry = new MetricTelemetry ( ) ;
76- }
77-
78- AddTargetingProperties ( telemetry . Properties , targetingContext ) ;
79-
80- telemetryClient . TrackMetric ( telemetry ) ;
81- }
82-
8349 private static void ValidateTargetingContext ( TargetingContext targetingContext )
8450 {
8551 if ( targetingContext == null )
8652 {
8753 throw new ArgumentNullException ( nameof ( targetingContext ) ) ;
8854 }
8955 }
90-
91- private static void AddTargetingProperties ( IDictionary < string , string > properties , TargetingContext targetingContext )
92- {
93- properties [ "TargetingId" ] = targetingContext . UserId ;
94- }
9556 }
9657}
0 commit comments