119 lines
No EOL
4.3 KiB
JavaScript
119 lines
No EOL
4.3 KiB
JavaScript
"use strict";
|
|
/**
|
|
* @module botbuilder
|
|
*/
|
|
/**
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License.
|
|
*/
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.telemetryTrackDialogView = exports.NullTelemetryClient = exports.BotTelemetryClientKey = exports.Severity = void 0;
|
|
/**
|
|
* Defines the level of severity for the event.
|
|
*/
|
|
var Severity;
|
|
(function (Severity) {
|
|
Severity[Severity["Verbose"] = 0] = "Verbose";
|
|
Severity[Severity["Information"] = 1] = "Information";
|
|
Severity[Severity["Warning"] = 2] = "Warning";
|
|
Severity[Severity["Error"] = 3] = "Error";
|
|
Severity[Severity["Critical"] = 4] = "Critical";
|
|
})(Severity = exports.Severity || (exports.Severity = {}));
|
|
/**
|
|
* Key used to store and fetch a [BotTelemetryClient](xref:botbuilder-core.BotTelemetryClient) from [TurnContext.turnState](xref:botbuilder-core.TurnContextStateCollection)
|
|
*/
|
|
exports.BotTelemetryClientKey = 'BotTelemetryClient';
|
|
/**
|
|
* A null bot telemetry client that implements [BotTelemetryClient](xref:botbuilder-core.BotTelemetryClient).
|
|
*/
|
|
class NullTelemetryClient {
|
|
/**
|
|
* Creates a new instance of the [NullTelemetryClient](xref:botbuilder-core.NullTelemetryClient) class.
|
|
*
|
|
* @param _settings Optional. Settings for the telemetry client.
|
|
*/
|
|
constructor(_settings) {
|
|
// noop
|
|
}
|
|
/**
|
|
* Logs an Application Insights page view.
|
|
*
|
|
* @param _telemetry An object implementing [TelemetryPageView](xref:botbuilder-core.TelemetryPageView).
|
|
*/
|
|
trackPageView(_telemetry) {
|
|
// noop
|
|
}
|
|
/**
|
|
* Sends information about an external dependency (outgoing call) in the application.
|
|
*
|
|
* @param _telemetry An object implementing [TelemetryDependency](xref:botbuilder-core.TelemetryDependency).
|
|
*/
|
|
trackDependency(_telemetry) {
|
|
// noop
|
|
}
|
|
/**
|
|
* Logs custom events with extensible named fields.
|
|
*
|
|
* @param _telemetry An object implementing [TelemetryEvent](xref:botbuilder-core.TelemetryEvent).
|
|
*/
|
|
trackEvent(_telemetry) {
|
|
// noop
|
|
}
|
|
/**
|
|
* Logs a system exception.
|
|
*
|
|
* @param _telemetry An object implementing [TelemetryException](xref:botbuilder-core.TelemetryException).
|
|
*/
|
|
trackException(_telemetry) {
|
|
// noop
|
|
}
|
|
/**
|
|
* Sends a trace message.
|
|
*
|
|
* @param _telemetry An object implementing [TelemetryTrace](xref:botbuilder-core.TelemetryTrace).
|
|
*/
|
|
trackTrace(_telemetry) {
|
|
// noop
|
|
}
|
|
/**
|
|
* Flushes the in-memory buffer and any metrics being pre-aggregated.
|
|
*/
|
|
flush() {
|
|
// noop
|
|
}
|
|
}
|
|
exports.NullTelemetryClient = NullTelemetryClient;
|
|
/**
|
|
* Logs a DialogView using the [trackPageView](xref:botbuilder-core.BotTelemetryClient.trackPageView) method on the [BotTelemetryClient](xref:botbuilder-core.BotTelemetryClient) if [BotPageViewTelemetryClient](xref:botbuilder-core.BotPageViewTelemetryClient) has been implemented.
|
|
* Alternatively logs the information out via TrackTrace.
|
|
*
|
|
* @param telemetryClient TelemetryClient that implements [BotTelemetryClient](xref:botbuilder-core.BotTelemetryClient).
|
|
* @param dialogName Name of the dialog to log the entry / start for.
|
|
* @param properties Named string values you can use to search and classify events.
|
|
* @param metrics Measurements associated with this event.
|
|
*/
|
|
function telemetryTrackDialogView(telemetryClient, dialogName, properties, metrics) {
|
|
if (!clientSupportsTrackDialogView(telemetryClient)) {
|
|
throw new TypeError('"telemetryClient" parameter does not have methods trackPageView() or trackTrace()');
|
|
}
|
|
if (instanceOfBotPageViewTelemetryClient(telemetryClient)) {
|
|
telemetryClient.trackPageView({ name: dialogName, properties: properties, metrics: metrics });
|
|
}
|
|
else {
|
|
telemetryClient.trackTrace({ message: 'Dialog View: ' + dialogName, severityLevel: Severity.Information });
|
|
}
|
|
}
|
|
exports.telemetryTrackDialogView = telemetryTrackDialogView;
|
|
function instanceOfBotPageViewTelemetryClient(object) {
|
|
return 'trackPageView' in object;
|
|
}
|
|
function clientSupportsTrackDialogView(client) {
|
|
if (!client) {
|
|
return false;
|
|
}
|
|
if (typeof client.trackPageView !== 'function' && typeof client.trackTrace !== 'function') {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
//# sourceMappingURL=botTelemetryClient.js.map
|