Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kyled/waterfall cancel telemetry #1639

Merged
merged 4 commits into from
Jan 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libraries/botbuilder-dialogs/src/waterfallDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export class WaterfallDialog<O extends object = {}> extends Dialog<O> {
'InstanceId': instanceId,
}});
} else if (reason === DialogReason.cancelCalled) {
var index = instance.state[state.stepIndex];
var index = state.stepIndex;
var stepName = this.waterfallStepName(index);
this.telemetryClient.trackEvent({name: 'WaterfallCancel', properties: {
'DialogId': this.id,
Expand Down
24 changes: 22 additions & 2 deletions libraries/botbuilder-dialogs/tests/waterfallDialog.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { ActivityTypes, ConversationState, MemoryStorage, TestAdapter } = require('botbuilder-core');
const { Dialog, DialogSet, WaterfallDialog, DialogTurnStatus } = require('../');
const { Dialog, DialogReason, DialogSet, DialogTurnStatus, WaterfallDialog } = require('../');

const assert = require('assert');

Expand Down Expand Up @@ -29,7 +29,6 @@ class MyWaterfall extends WaterfallDialog {
}
}


describe('WaterfallDialog', function () {
this.timeout(5000);

Expand Down Expand Up @@ -614,4 +613,25 @@ describe('WaterfallDialog', function () {
.assertReply('done.')
.startTest();
});

it('should record the correct step name when cancelled.', async function() {
const id = 'waterfall';
const index = 1;
const dialog = new MyWaterfall(id);
var trackEventCalled;
dialog.telemetryClient = {
trackEvent(telemetry) {
assert(telemetry.properties.StepName == dialog.steps[index].name, `telemetry contains incorrect step name: "${telemetry.properties.StepName}"`);
trackEventCalled = true;
}
};
await dialog.endDialog({}, {
id,
state: {
stepIndex: index,
values: { instanceId: '(guid)' }
}
}, DialogReason.cancelCalled);
assert(trackEventCalled, 'trackEvent was never called.');
});
});