@microsoft/windows-admin-center-sdk
Version:
Microsoft - Windows Admin Center Shell
193 lines (192 loc) • 9.75 kB
TypeScript
import { Observable } from 'rxjs';
import { AppContext } from '../data/app-context';
import { PowerShellCommand } from '../data/powershell';
import { RpcNotification } from '../rpc/notification/rpc-notification-model';
import { IContentUpdateOverrideValues, IPageActionOverrideValues, IPageViewOverrideValues, LighthousePerformanceMetrics, PowershellDetails, SmePerformanceData, TelemetryEventStates } from './sme-web-telemetry-models';
export declare class SmeWebTelemetry {
/**
* The source name to use when logging about this service.
*/
private static get logSourceName();
/**
* Gets the name of current shell or module.
*/
private static get nameOfModule();
private static get backlogHasSpace();
private static eventBacklog;
private static telemetryHandler;
private static testMode;
private static rpcInitAlready;
private static metaTags;
private static powershellIdMap;
private static isProd;
static get isProduction(): boolean;
private static windowsAdminCenterTenantToken;
/**
* Map of module versions used in this instance of web telemetry - memoize values here.
*/
private static moduleVersions;
/**
* Get the list of module versions for use in telemetry where the event is sent via RPC to shell
* from the actual module the event is called in.
* @returns list of module mappings to versions
*/
private static getModuleVersion;
/**
* Send any manual events that were triggered prior to telemetry initializing.
*/
private static sendBacklogEvents;
/**
* Helper to combine setting metaTags, initialize handler, and
* send any telemetry events that occurred prior to initialization
*/
private static configureAndInitTelemetry;
/**
* Helper function to set metaTags in DOM
*/
private static setMetaInDom;
/**
* Update Meta-tags and/or initialize telemetry, depending on whether rpc message came before or after app-context init.
* @param newMetaTags Primarily contains WAC-Session-Id & extension-version, received from RPC message
*/
static updateFromRpcInit(newMetaTags: {
[tag: string]: string;
}): void;
/**
* Load 1DS if does not already exist.
* @param appContext App context currently being used
*/
static init(appContext: AppContext): Observable<boolean>;
/**
* Set config and initialize telemetry library handler
*/
private static initTelemetryHandler;
/**
* Send a Page-Action event through Web Telemetry.
* @param element Element action is being executed on
* @param overrideValues Various values to override within default Web Telemetry page action fields, see Web Telemetry documentation.
* @param properties Extra properties in an index signature. These are placed under the data field in partC data.
*/
static traceAction(element: Element, overrideValues?: IPageActionOverrideValues, properties?: {
[name: string]: any;
}): void;
/**
* Send a Page-View event through Web Telemetry.
* @param overrideValues Various values to override within default Web Telemetry page view fields, see Web Telemetry documentation.
* @param properties Extra properties in an index signature. These are placed under the data field in partC data.
*/
static tracePageView(overrideValues: IPageViewOverrideValues, properties?: {
[name: string]: any;
}): void;
/**
* Send a Content-Update event through Web Telemetry.
* @param overrideValues Various values to override within default Web Telemetry content update fields, see Web Telemetry documentation
* @param properties Extra properties in an index signature. These are placed under the data field in partC data.
*/
static traceContentUpdate(overrideValues: IContentUpdateOverrideValues, properties?: {
[name: string]: any;
}): void;
/**
* Add standard fields onto performance data
* @param data SmePerformanceData to be sent
*/
private static fillStandardPerformanceData;
/**
* Send a content update event. This content update contains an updated sme-specific timings structure with relevant
* performance data under the data field. The original timings data is also contained under the navigation field.
* The structure of the event is such:
* data : { ...,
* "timings": {
* "extension": [extension-name],
* "entryPointName": [entryPointName],
* "url": [url-endpoint],
* "moduleOpened" : [isModuleOpened],
* "sme": {
* [sme-mark] : [mark-timestamps],
* ...
* },
* "resources": {
* [resource-endpoint] : [resource-load-complete-timestamps],
* ...
* },
* "navigation": {
* [performance-navigation-event]: [navigation-event-timestamps]
* }
* }, ...
* }
* Certain fields are set within this class instead of outside modules since they will always be the same.
* @param dataPayload performance data to be sent through telemetry.
* @param contentOverrides any content overriding behavior wanted in the performance event
*/
static tracePerformanceData(dataPayload: SmePerformanceData, contentOverrides?: any): void;
/**
* Send a content update event - this event will contain timings for lighthouse calculation in the backend
* This can potentially be sent a couple times with overlapping data for one page load event, depending
* on when the TTI is calculated. In this scenario, it will be handled on the backend.
* @param dataPayload Lighthouse data
* @param contentOverrides any content overriding behavior wanted in the performance event
*/
static traceLighthouseData(dataPayload: LighthousePerformanceMetrics, contentOverrides?: any, properties?: {
[name: string]: any;
}): void;
/**
* See tracePerformanceData comments, only difference is moduleOpened is true and the contentOverrides
* @param dataPayload performance data to be sent through telemetry.
*/
static traceModuleOpenPerformance(dataPayload: SmePerformanceData): void;
/**
* Helper to create event boilerplate for notification
* @param clientNotification Client notification to send event for
*/
static traceClientNotification(clientNotification: RpcNotification): void;
/**
* Helper function to assign a command to an id in a multi-step workitem process
* @param id The ID of the powershell session to assign
* @param command The command to assign to the session ID
*/
static addPowershellId(id: string, command: PowerShellCommand): void;
/**
* Helper function to assign a command to an id in a multi-step workitem process
* @param id The ID of the powershell session to assign
* @param command The command to assign to the session ID
*/
static removePowershellId(id: string): void;
/**
* Helper to create event boilerplate for powershell event. In the case where command is not available,
* use an ID (usually ps session ID, which may correlate with work item id)
* @param command Powershell Command
* @param state State of powershell event (start/end/etc)
* @param details Optional details object - see interface for more detail.
*/
static tracePowershellEvent(command: PowerShellCommand, state: TelemetryEventStates, details?: PowershellDetails): void;
/**
* Helper to create event boilerplate for powershell batch event. Batch doesn't deal with work items, so
* we can ignore the ID and sourceName handling that the above function handles.
* @param commands Powershell Commands List in properties stringified form. PS Batch events places PS command into a
* '{properties: PSCommand }' string structure.
* @param state State of powershell event (start/end/etc)
* @param details Optional details object contains various optional fields in powershell event.
* @returns
*/
static tracePowershellBatchEvent(commands: string[], state: TelemetryEventStates, details?: PowershellDetails): void;
/**
* Helper to redactGenericModel function
* Determines whether field should be redacted according to fields provided for redacting and exceptions
* @param key The field in question
* @param keywordsToRedact List of string inclusions to redact - if the field contains any part of this, it will be redacted
* @param exceptions Set of exceptions to the above - if the field matches an exception, it will not be redacted
* @returns True if field should be redacted, false otherwise
*/
private static fieldShouldBeRedacted;
/**
* Telemetry utility function to redact a model object. This function will traverse the model in BFS fashion and redact any fields
* that contain any string in the keywordsToRedact array, unless the field is an exception (in the exceptions array).
* This function will not affect keys in StringMaps or Maps - if names exist there, they should be handled separately.
*
* @param model Model to redact
* @param keywordsToRedact List of string inclusions to redact
* @param fieldExceptions List of exceptions to the above
* @returns Redacted model
*/
static redactGenericModel(model: any, keywordsToRedact: string[], fieldExceptions: string[]): any;
}