Skip to content

Commit

Permalink
Move TelemetryClient property to DialogContainer (#2463)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrestorff authored Jul 1, 2020
1 parent 3f05656 commit c4488ce
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
9 changes: 1 addition & 8 deletions libraries/botbuilder-dialogs-adaptive/src/adaptiveDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
* Licensed under the MIT License.
*/
import {
TurnContext, BotTelemetryClient, NullTelemetryClient, ActivityTypes,
Activity, RecognizerResult, getTopScoringIntent
} from 'botbuilder-core';
TurnContext, ActivityTypes, Activity, RecognizerResult, getTopScoringIntent } from 'botbuilder-core';
import { Dialog, DialogInstance, DialogReason, DialogTurnResult, DialogTurnStatus, DialogEvent, DialogContext, DialogContainer, DialogDependencies, TurnPath, DialogPath, DialogState } from 'botbuilder-dialogs';
import { OnCondition } from './conditions';
import { Recognizer } from './recognizers';
Expand Down Expand Up @@ -90,11 +88,6 @@ export class AdaptiveDialog<O extends object = {}> extends DialogContainer<O> {
return this.dialogSchema ? this.dialogSchema.schema : undefined;
}

public set telemetryClient(client: BotTelemetryClient) {
super.telemetryClient = client ? client : new NullTelemetryClient();
this.dialogs.telemetryClient = client;
}

protected ensureDependenciesInstalled(): void {
if (this.installedDependencies) {
return;
Expand Down
18 changes: 1 addition & 17 deletions libraries/botbuilder-dialogs/src/componentDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
import { BotTelemetryClient, NullTelemetryClient, telemetryTrackDialogView, TurnContext } from 'botbuilder-core';
import { telemetryTrackDialogView, TurnContext } from 'botbuilder-core';
import { Dialog, DialogInstance, DialogReason, DialogTurnResult, DialogTurnStatus } from './dialog';
import { DialogContext } from './dialogContext';
import { DialogContainer } from './dialogContainer';
Expand Down Expand Up @@ -250,20 +250,4 @@ export class ComponentDialog<O extends object = {}> extends DialogContainer<O> {

return innerDC
}

/**
* Set the telemetry client, and also apply it to all child dialogs.
* Future dialogs added to the component will also inherit this client.
*/
public set telemetryClient(client: BotTelemetryClient) {
this._telemetryClient = client ? client : new NullTelemetryClient();
this.dialogs.telemetryClient = client;
}

/**
* Get the current telemetry client.
*/
public get telemetryClient(): BotTelemetryClient {
return this._telemetryClient;
}
}
17 changes: 17 additions & 0 deletions libraries/botbuilder-dialogs/src/dialogContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
import { BotTelemetryClient, NullTelemetryClient } from 'botbuilder-core';
import { Dialog } from './dialog';
import { DialogSet } from './dialogSet';
import { DialogContext } from './dialogContext';
Expand Down Expand Up @@ -66,4 +67,20 @@ export abstract class DialogContainer<O extends object = {}> extends Dialog<O> {
await dc.emitEvent(DialogEvents.versionChanged, this.id, true, false);
}
}

/**
* Set the telemetry client, and also apply it to all child dialogs.
* Future dialogs added to the component will also inherit this client.
*/
public set telemetryClient(client: BotTelemetryClient) {
this._telemetryClient = client ? client : new NullTelemetryClient();
this.dialogs.telemetryClient = client;
}

/**
* Get the current telemetry client.
*/
public get telemetryClient(): BotTelemetryClient {
return this._telemetryClient;
}
}

0 comments on commit c4488ce

Please sign in to comment.