import * as vscode from "vscode"; import { ReplacementOption } from "@vscode/extension-telemetry"; interface IOptions { /** * @deprecated This field is deprecated and will not have any effect. */ firstParty?: boolean; replacementOptions?: ReplacementOption[]; debug?: boolean; } /** * Initialize TelemetryReporter by parsing attributes from a JSON file. * It reads these attributes: publisher, name, version, aiKey. * @param jsonFilepath absolute path of a JSON file. * @param options debug: if set as true, debug information be printed to console. */ export { ReplacementOption } from "@vscode/extension-telemetry"; export declare function initializeFromJsonFile(jsonFilepath: string, options?: IOptions): Promise; /** * Initialize TelemetryReporter from given attributes. * @param extensionId Identifier of the extension, used as prefix of EventName in telemetry data. * @param version Version of the extension. (Deprecated, will not have any effect) * @param aiKey Key of Application Insights. * @param options debug: if set as true, debug information be printed to console. */ export declare function initialize(extensionId: string, _version: string, aiKey: string | string[], options?: IOptions): void; /** * Mark an Error instance as a user error. */ export declare function setUserError(err: Error): void; /** * Set custom error code or an Error instance. * @param errorCode A custom error code. */ export declare function setErrorCode(err: Error, errorCode: number): void; /** * Instrument callback for a command to auto send OPERATION_START, OPERATION_END, ERROR telemetry. * A unique Id is created and accessible in the callback. * @param operationName For extension activation, use "activation", for VS Code commands, use command name. * @param cb The callback function **with a unique Id passed by its 1st parameter**. * @param thisArg The `this` context used when invoking the handler function. * @returns The instrumented callback. */ export declare function instrumentOperation(operationName: string, cb: (operationId: string, ...args: any[]) => any, thisArg?: any): (...args: any[]) => any; /** * Instrument callback for a command to auto send OPERATION_START, OPERATION_END, ERROR telemetry. * @param operationName For extension activation, use "activation", for VS Code commands, use command name. * @param cb The callback function. * @param thisArg The `this` context used when invoking the handler function. * @returns The instrumented callback. */ export declare function instrumentSimpleOperation(operationName: string, cb: (...args: any[]) => any, thisArg?: any): (...args: any[]) => any; /** * A shortcut to instrument and operation and register it as a VSCode command. * Note that operation Id will no longer be accessible in this approach. * @param command A unique identifier for the command. * @param cb A command handler function. * @param thisArg The `this` context used when invoking the handler function. */ export declare function instrumentOperationAsVsCodeCommand(command: string, cb: (...args: any[]) => any, thisArg?: any): vscode.Disposable; /** * Send OPERATION_START event. * @param operationId Unique id of the operation. * @param operationName Name of the operation. */ export declare function sendOperationStart(operationId: string, operationName: string): void; /** * Send OPERATION_END event. * @param operationId Unique id of the operation. * @param operationName Name of the operation. * @param duration Time elapsed for the operation, in milliseconds. * @param err An optional Error instance if occurs during the operation. */ export declare function sendOperationEnd(operationId: string, operationName: string, duration: number, err?: Error): void; /** * Send an ERROR event. * @param err An Error instance. */ export declare function sendError(err: Error): void; /** * Send an ERROR event during an operation, carrying id and name of the operation. * @param operationId Unique id of the operation. * @param operationName Name of the operation. * @param err An Error instance containing details. */ export declare function sendOperationError(operationId: string, operationName: string, err: Error): void; /** * Send an INFO event during an operation. * @param operationId Unique id of the operation. * @param data Values of string type go to customDimensions, values of number type go to customMeasurements. */ export declare function sendInfo(operationId: string, data: { [key: string]: string | number; }): void; /** * Send an INFO event during an operation. * Note that: operationId will overwrite dimensions['operationId'] if it exists. * @param operationId Unique id of the operation. * @param dimensions The object recorded as customDimensions. * @param measurements The object recorded as customMeasurements. */ export declare function sendInfo(operationId: string, dimensions: { [key: string]: string; }, measurements: { [key: string]: number; }): void; /** * Instrument callback for a procedure (regarded as a step in an operation). * @param operationId A unique identifier for the operation to which the step belongs. * @param stepName Name of the step. * @param cb The callback function with a unique Id passed by its 1st parameter. * @returns The instrumented callback. */ export declare function instrumentOperationStep(operationId: string, stepName: string, cb: (...args: any[]) => any): (...args: any[]) => any; /** * Create a UUID string. */ export declare function createUuid(): string; /** * Dispose the reporter. */ export declare function dispose(): Promise; /** * Add a context property that will be set for all "info" events. * It will be overwritten by the property with the same name, if it's explicitly set in an event. * @param name name of context property * @param value value of context property */ export declare function addContextProperty(name: string, value: string): void; /** * @deprecated This method is deprecated. Use replacementOptions in IOptions instead. * Add a replacement rule that will be applied to all properties. Useful when you want to wipe sensitive data. * * Note: rules will not affect context properties. * * @param pattern RegExp pattern to search * @param replaceString target string to repalce matched parts */ export declare function addReplacementRule(pattern: RegExp, replaceString?: string): void;