TelemetryLoggerMiddleware Class

  • java.lang.Object
    • com.microsoft.bot.builder.TelemetryLoggerMiddleware

Implements

public class TelemetryLoggerMiddleware
implements Middleware

Middleware for logging incoming, outgoing, updated or deleted Activity messages. Uses the BotTelemetryClient interface.

Constructor Summary

Constructor Description
TelemetryLoggerMiddleware(BotTelemetryClient withTelemetryClient, boolean withLogPersonalInformation)

Initializes a new instance of the class.

Method Summary

Modifier and Type Method and Description
protected java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.String>> fillDeleteEventProperties(Activity activity, Map<String,String> additionalProperties)

Fills the event properties for BotMessageDelete.

protected java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.String>> fillReceiveEventProperties(Activity activity, Map<String,String> additionalProperties)

Fills the event properties for the BotMessageReceived.

protected java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.String>> fillSendEventProperties(Activity activity, Map<String,String> additionalProperties)

Fills the event properties for BotMessageSend.

protected java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.String>> fillUpdateEventProperties(Activity activity, Map<String,String> additionalProperties)

Fills the event properties for BotMessageUpdate.

BotTelemetryClient getTelemetryClient()

Gets the currently configured BotTelemetryClient that logs the event.

protected java.util.concurrent.CompletableFuture<java.lang.Void> onDeleteActivity(Activity activity)

Invoked when the bot deletes a message.

protected java.util.concurrent.CompletableFuture<java.lang.Void> onReceiveActivity(Activity activity)

Invoked when a message is received from the user.

protected java.util.concurrent.CompletableFuture<java.lang.Void> onSendActivity(Activity activity)

Invoked when the bot sends a message to the user.

java.util.concurrent.CompletableFuture<java.lang.Void> onTurn(TurnContext context, NextDelegate next)

Logs events based on incoming and outgoing activities using the BotTelemetryClient interface.

protected java.util.concurrent.CompletableFuture<java.lang.Void> onUpdateActivity(Activity activity)

Invoked when the bot updates a message.

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Constructor Details

TelemetryLoggerMiddleware

public TelemetryLoggerMiddleware(BotTelemetryClient withTelemetryClient, boolean withLogPersonalInformation)

Initializes a new instance of the class.

Parameters:

withTelemetryClient - The IBotTelemetryClient implementation used for registering telemetry events.
withLogPersonalInformation - TRUE to include personally identifiable information.

Method Details

fillDeleteEventProperties

protected CompletableFuture> fillDeleteEventProperties(Activity activity, Map additionalProperties)

Fills the event properties for BotMessageDelete. These properties are logged when an activity message is sent by the Bot to the user.

Parameters:

activity - Last activity sent from user.
additionalProperties - Additional properties to add to the event.

Returns:

A dictionary that is sent as "Properties" to BotTelemetryClient#trackEvent method for the BotMessageDelete event.

fillReceiveEventProperties

protected CompletableFuture> fillReceiveEventProperties(Activity activity, Map additionalProperties)

Fills the event properties for the BotMessageReceived. Adheres to the LogPersonalInformation flag to filter Name, Text and Speak properties.

Parameters:

activity - Last activity sent from user.
additionalProperties - Additional properties to add to the event.

Returns:

A dictionary that is sent as "Properties" to BotTelemetryClient#trackEvent method for the BotMessageReceived event.

fillSendEventProperties

protected CompletableFuture> fillSendEventProperties(Activity activity, Map additionalProperties)

Fills the event properties for BotMessageSend. These properties are logged when an activity message is sent by the Bot to the user.

Parameters:

activity - Last activity sent from user.
additionalProperties - Additional properties to add to the event.

Returns:

A dictionary that is sent as "Properties" to BotTelemetryClient#trackEvent method for the BotMessageSend event.

fillUpdateEventProperties

protected CompletableFuture> fillUpdateEventProperties(Activity activity, Map additionalProperties)

Fills the event properties for BotMessageUpdate. These properties are logged when an activity message is sent by the Bot to the user.

Parameters:

activity - Last activity sent from user.
additionalProperties - Additional properties to add to the event.

Returns:

A dictionary that is sent as "Properties" to BotTelemetryClient#trackEvent method for the BotMessageUpdate event.

getTelemetryClient

public BotTelemetryClient getTelemetryClient()

Gets the currently configured BotTelemetryClient that logs the event.

Returns:

The BotTelemetryClient being used to log events.

onDeleteActivity

protected CompletableFuture onDeleteActivity(Activity activity)

Invoked when the bot deletes a message. Performs logging of telemetry data using the BotTelemetryClient#trackEvent method. This event name used is "BotMessageDelete".

Parameters:

activity - Current activity sent from user.

Returns:

A task that represents the work queued to execute.

onReceiveActivity

protected CompletableFuture onReceiveActivity(Activity activity)

Invoked when a message is received from the user. Performs logging of telemetry data using the BotTelemetryClient#trackEvent method. This event name used is "BotMessageReceived".

Parameters:

activity - Current activity sent from user.

Returns:

A task that represents the work queued to execute.

onSendActivity

protected CompletableFuture onSendActivity(Activity activity)

Invoked when the bot sends a message to the user. Performs logging of telemetry data using the BotTelemetryClient#trackEvent method. This event name used is "BotMessageSend".

Parameters:

activity - Current activity sent from user.

Returns:

A task that represents the work queued to execute.

onTurn

public CompletableFuture onTurn(TurnContext context, NextDelegate next)

Logs events based on incoming and outgoing activities using the BotTelemetryClient interface.

Parameters:

context - The context object for this turn.
next - The delegate to call to continue the bot middleware pipeline.

Returns:

A task that represents the work queued to execute.

onUpdateActivity

protected CompletableFuture onUpdateActivity(Activity activity)

Invoked when the bot updates a message. Performs logging of telemetry data using the BotTelemetryClient#trackEvent method. This event name used is "BotMessageUpdate".

Parameters:

activity - Current activity sent from user.

Returns:

A task that represents the work queued to execute.

Applies to