Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Dialog / PageView telemetry (#2145)
* Update app insights package version * Add PageView logging * move TelemetryView helper to botTelemetryClient.ts * remove telemetry Extensions class, harden helper method, add tests Co-authored-by: Steven Gum <14935595+stevengum@users.noreply.github.com>
- Loading branch information
1 parent
c3f7e33
commit b64b61d
Showing
7 changed files
with
101 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
libraries/botbuilder-core/tests/botTelemetryClient.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const { ok, strictEqual } = require('assert'); | ||
const { Severity, telemetryTrackDialogView } = require('../'); | ||
|
||
describe('BotTelemetryClient', function() { | ||
this.timeout(3000); | ||
|
||
describe('"telemetryTrackDialogView" helper', () => { | ||
it('should call client.trackPageView if it exists', () => { | ||
const testClient = { | ||
trackPageView({ name, properties, metrics }) { | ||
ok(name); | ||
ok(properties); | ||
ok(metrics); | ||
} | ||
}; | ||
const testProps = { description: 'value' }; | ||
const testMetrics = { duration: 1 }; | ||
telemetryTrackDialogView(testClient, 'dialogName', testProps, testMetrics); | ||
}); | ||
|
||
it('should call client.trackTrace if trackPageView is not supported', () => { | ||
const testClient = { | ||
trackTrace({ message, severityLevel }) { | ||
ok(message); | ||
strictEqual(severityLevel, Severity.Information); | ||
} | ||
}; | ||
telemetryTrackDialogView(testClient, 'dialogName'); | ||
}); | ||
|
||
it('should throw TypeError if trackTrace and trackPageView do not exist', () => { | ||
try { | ||
telemetryTrackDialogView(undefined, 'dialogName'); | ||
} catch (err) { | ||
strictEqual(err.message, '"telemetryClient" parameter does not have methods trackPageView() or trackTrace()'); | ||
} | ||
|
||
try { | ||
telemetryTrackDialogView({}, 'dialogName'); | ||
} catch (err) { | ||
strictEqual(err.message, '"telemetryClient" parameter does not have methods trackPageView() or trackTrace()'); | ||
} | ||
|
||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters