Esempio n. 1
0
        public static void TrackEvent(this IActivityAdapter activity, QueryResult queryResult, InstrumentationSettings settings, TelemetryClient telemetryClient)
        {
            if (activity is null)
            {
                throw new ArgumentNullException(nameof(activity));
            }

            if (queryResult is null)
            {
                throw new ArgumentNullException(nameof(queryResult));
            }

            if (telemetryClient is null)
            {
                throw new ArgumentNullException(nameof(telemetryClient));
            }

            var properties = new Dictionary <string, string>
            {
                { QnAConstants.UserQuery, activity.MessageActivity.Text },
                { QnAConstants.KnowledgeBaseQuestion, queryResult.KnowledgeBaseQuestion },
                { QnAConstants.KnowledgeBaseAnswer, queryResult.KnowledgeBaseAnswer },
                { QnAConstants.Score, queryResult.Score },
            };

            activity.TrackCustomEvent(telemetryClient, settings, EventTypes.QnaEvent, properties);
        }
        public void GIVENAnyActivity_WHENTrackCustomEventIsInvoked_THENEventTelemetryIsBeingSent(
            IActivityAdapter activity,
            InstrumentationSettings settings)
        {
            // Arrange
            // Act
            activity.TrackCustomEvent(this.telemetryClient, settings);

            // Assert
            this.mockTelemetryChannel.Verify(
                tc => tc.Send(It.Is <EventTelemetry>(t =>
                                                     t.Name == EventTypes.CustomEvent)),
                Times.Once);
        }
Esempio n. 3
0
        public static void TrackIntent(this IActivityAdapter activity, IntentResult result, TelemetryClient telemetryClient, InstrumentationSettings settings)
        {
            if (result is null)
            {
                throw new ArgumentNullException(nameof(result));
            }

            if (telemetryClient is null)
            {
                throw new ArgumentNullException(nameof(telemetryClient));
            }

            var properties = new Dictionary <string, string>
            {
                { IntentConstants.Intent, result.Intent },
                { IntentConstants.Score, result.Score },
                { IntentConstants.Entities, result.Entities },
            };

            activity.TrackCustomEvent(telemetryClient, settings, EventTypes.Intent, properties);
        }
Esempio n. 4
0
        public static async Task TrackMessageSentiment(this IActivityAdapter activity, TelemetryClient telemetryClient, InstrumentationSettings settings, ISentimentClient sentimentClient)
        {
            if (telemetryClient is null)
            {
                throw new ArgumentNullException(nameof(telemetryClient));
            }

            if (sentimentClient is null)
            {
                throw new ArgumentNullException(nameof(sentimentClient));
            }

            var score = await sentimentClient.GetSentiment(activity)
                        .ConfigureAwait(false);

            var properties = new Dictionary <string, string>
            {
                { SentimentConstants.Score, score.Value.ToString(CultureInfo.InvariantCulture) },
            };

            activity.TrackCustomEvent(telemetryClient, settings, EventTypes.MessageSentiment, properties);
        }
        GIVENAnyActivityAnyEventNameAndAnyProperty_WHENTrackCustomEventIsInvoked_THENEventTelemetryIsBeingSent(
            IActivityAdapter activity,
            string eventName,
            string propertyKey,
            string propertyValue,
            InstrumentationSettings settings)
        {
            // Arrange
            var properties = new Dictionary <string, string> {
                { propertyKey, propertyValue }
            };

            // Act
            activity.TrackCustomEvent(this.telemetryClient, settings, eventName, properties);

            // Assert
            this.mockTelemetryChannel.Verify(
                tc => tc.Send(It.Is <EventTelemetry>(t =>
                                                     t.Name == eventName &&
                                                     t.Properties[propertyKey] == propertyValue)),
                Times.Once);
        }