mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
Use types module instead of custom typings for applicationinsights
This commit is contained in:
parent
8fd2f09c29
commit
434662c6cb
|
@ -61,6 +61,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"7zip": "0.0.6",
|
||||
"@types/applicationinsights": "0.20.0",
|
||||
"@types/chokidar": "2.1.3",
|
||||
"@types/cookie": "^0.3.3",
|
||||
"@types/graceful-fs": "4.1.2",
|
||||
|
|
218
src/typings/applicationInsights.d.ts
vendored
218
src/typings/applicationInsights.d.ts
vendored
|
@ -1,218 +0,0 @@
|
|||
/**
|
||||
* The singleton meta class for the default client of the client. This class is used to setup/start and configure
|
||||
* the auto-collection behavior of the application insights module.
|
||||
*/
|
||||
declare module ApplicationInsights {
|
||||
|
||||
/**
|
||||
* The default client, initialized when setup was called. To initialize a different client
|
||||
* with its own configuration, use `new TelemetryClient(instrumentationKey?)`.
|
||||
*/
|
||||
var defaultClient: TelemetryClient;
|
||||
/**
|
||||
* Initializes the default client. Should be called after setting
|
||||
* configuration options.
|
||||
*
|
||||
* @param instrumentationKey the instrumentation key to use. Optional, if
|
||||
* this is not specified, the value will be read from the environment
|
||||
* variable APPINSIGHTS_INSTRUMENTATIONKEY.
|
||||
* @returns {Configuration} the configuration class to initialize
|
||||
* and start the SDK.
|
||||
*/
|
||||
function setup(instrumentationKey?: string): typeof Configuration;
|
||||
/**
|
||||
* Starts automatic collection of telemetry. Prior to calling start no
|
||||
* telemetry will be *automatically* collected, though manual collection
|
||||
* is enabled.
|
||||
* @returns {ApplicationInsights} this class
|
||||
*/
|
||||
function start(): typeof Configuration;
|
||||
/**
|
||||
* The active configuration for global SDK behaviors, such as autocollection.
|
||||
*/
|
||||
class Configuration {
|
||||
static start: typeof start;
|
||||
/**
|
||||
* Sets the state of console and logger tracking (enabled by default for third-party loggers only)
|
||||
* @param value if true logger activity will be sent to Application Insights
|
||||
* @param collectConsoleLog if true, logger autocollection will include console.log calls (default false)
|
||||
* @returns {Configuration} this class
|
||||
*/
|
||||
static setAutoCollectConsole(value: boolean, collectConsoleLog?: boolean): typeof Configuration;
|
||||
/**
|
||||
* Sets the state of exception tracking (enabled by default)
|
||||
* @param value if true uncaught exceptions will be sent to Application Insights
|
||||
* @returns {Configuration} this class
|
||||
*/
|
||||
static setAutoCollectExceptions(value: boolean): typeof Configuration;
|
||||
/**
|
||||
* Sets the state of performance tracking (enabled by default)
|
||||
* @param value if true performance counters will be collected every second and sent to Application Insights
|
||||
* @returns {Configuration} this class
|
||||
*/
|
||||
static setAutoCollectPerformance(value: boolean): typeof Configuration;
|
||||
/**
|
||||
* Sets the state of request tracking (enabled by default)
|
||||
* @param value if true requests will be sent to Application Insights
|
||||
* @returns {Configuration} this class
|
||||
*/
|
||||
static setAutoCollectRequests(value: boolean): typeof Configuration;
|
||||
/**
|
||||
* Sets the state of dependency tracking (enabled by default)
|
||||
* @param value if true dependencies will be sent to Application Insights
|
||||
* @returns {Configuration} this class
|
||||
*/
|
||||
static setAutoCollectDependencies(value: boolean): typeof Configuration;
|
||||
/**
|
||||
* Sets the state of automatic dependency correlation (enabled by default)
|
||||
* @param value if true dependencies will be correlated with requests
|
||||
* @returns {Configuration} this class
|
||||
*/
|
||||
static setAutoDependencyCorrelation(value: boolean): typeof Configuration;
|
||||
/**
|
||||
* Enable or disable disk-backed retry caching to cache events when client is offline (enabled by default)
|
||||
* Note that this method only applies to the default client. Disk-backed retry caching is disabled by default for additional clients.
|
||||
* For enable for additional clients, use client.channel.setUseDiskRetryCaching(true).
|
||||
* These cached events are stored in your system or user's temporary directory and access restricted to your user when possible.
|
||||
* @param value if true events that occured while client is offline will be cached on disk
|
||||
* @param resendInterval The wait interval for resending cached events.
|
||||
* @param maxBytesOnDisk The maximum size (in bytes) that the created temporary directory for cache events can grow to, before caching is disabled.
|
||||
* @returns {Configuration} this class
|
||||
*/
|
||||
static setUseDiskRetryCaching(value: boolean, resendInterval?: number, maxBytesOnDisk?: number): typeof Configuration;
|
||||
/**
|
||||
* Enables debug and warning logging for AppInsights itself.
|
||||
* @param enableDebugLogging if true, enables debug logging
|
||||
* @param enableWarningLogging if true, enables warning logging
|
||||
* @returns {Configuration} this class
|
||||
*/
|
||||
static setInternalLogging(enableDebugLogging?: boolean, enableWarningLogging?: boolean): typeof Configuration;
|
||||
}
|
||||
/**
|
||||
* Disposes the default client and all the auto collectors so they can be reinitialized with different configuration
|
||||
*/
|
||||
function dispose(): void;
|
||||
|
||||
interface ITelemetryClient {
|
||||
config: Config;
|
||||
channel: Channel;
|
||||
/**
|
||||
* Log a user action or other occurrence.
|
||||
* @param telemetry Object encapsulating tracking options
|
||||
*/
|
||||
trackEvent(telemetry: EventTelemetry): void;
|
||||
/**
|
||||
* Immediately send all queued telemetry.
|
||||
* @param options Flush options, including indicator whether app is crashing and callback
|
||||
*/
|
||||
flush(options?: FlushOptions): void;
|
||||
|
||||
}
|
||||
|
||||
class TelemetryClient implements ITelemetryClient {
|
||||
config: Config;
|
||||
channel: Channel;
|
||||
/**
|
||||
* Constructs a new client of the client
|
||||
* @param iKey the instrumentation key to use (read from environment variable if not specified)
|
||||
*/
|
||||
constructor(iKey?: string);
|
||||
/**
|
||||
* Log a user action or other occurrence.
|
||||
* @param telemetry Object encapsulating tracking options
|
||||
*/
|
||||
trackEvent(telemetry: EventTelemetry): void;
|
||||
/**
|
||||
* Immediately send all queued telemetry.
|
||||
* @param options Flush options, including indicator whether app is crashing and callback
|
||||
*/
|
||||
flush(options?: FlushOptions): void;
|
||||
|
||||
}
|
||||
|
||||
class Config {
|
||||
static ENV_azurePrefix: string;
|
||||
static ENV_iKey: string;
|
||||
static legacy_ENV_iKey: string;
|
||||
static ENV_profileQueryEndpoint: string;
|
||||
static ENV_http_proxy: string;
|
||||
static ENV_https_proxy: string;
|
||||
/** An identifier for your Application Insights resource */
|
||||
instrumentationKey: string;
|
||||
/** The id for cross-component correlation. READ ONLY. */
|
||||
correlationId: string;
|
||||
/** The ingestion endpoint to send telemetry payloads to */
|
||||
endpointUrl: string;
|
||||
/** The maximum number of telemetry items to include in a payload to the ingestion endpoint (Default 250) */
|
||||
maxBatchSize: number;
|
||||
/** The maximum amount of time to wait for a payload to reach maxBatchSize (Default 15000) */
|
||||
maxBatchIntervalMs: number;
|
||||
/** A flag indicating if telemetry transmission is disabled (Default false) */
|
||||
disableAppInsights: boolean;
|
||||
/** The percentage of telemetry items tracked that should be transmitted (Default 100) */
|
||||
samplingPercentage: number;
|
||||
/** The time to wait before retrying to retrieve the id for cross-component correlation (Default 30000) */
|
||||
correlationIdRetryIntervalMs: number;
|
||||
/** A list of domains to exclude from cross-component header injection */
|
||||
correlationHeaderExcludedDomains: string[];
|
||||
/** A proxy server for SDK HTTP traffic (Optional, Default pulled from `http_proxy` environment variable) */
|
||||
proxyHttpUrl: string;
|
||||
/** A proxy server for SDK HTTPS traffic (Optional, Default pulled from `https_proxy` environment variable) */
|
||||
proxyHttpsUrl: string;
|
||||
}
|
||||
|
||||
interface Channel {
|
||||
/**
|
||||
* Enable or disable disk-backed retry caching to cache events when client is offline (enabled by default)
|
||||
* These cached events are stored in your system or user's temporary directory and access restricted to your user when possible.
|
||||
* @param value if true events that occured while client is offline will be cached on disk
|
||||
* @param resendInterval The wait interval for resending cached events.
|
||||
* @param maxBytesOnDisk The maximum size (in bytes) that the created temporary directory for cache events can grow to, before caching is disabled.
|
||||
* @returns {Configuration} this class
|
||||
*/
|
||||
setUseDiskRetryCaching(value: boolean, resendInterval?: number, maxBytesOnDisk?: number): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Telemetry about the custom event of interest, such application workflow event, business logic event (purchase) and anything that
|
||||
* you would like to track and aggregate by count. Event can contain measurements such as purchase amount associated with purchase event
|
||||
*/
|
||||
interface EventTelemetry {
|
||||
/**
|
||||
* Name of the event
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Metrics associated with this event, displayed in Metrics Explorer on the portal.
|
||||
*/
|
||||
measurements?: {
|
||||
[key: string]: number;
|
||||
};
|
||||
/**
|
||||
* Additional data used to filter events and metrics in the portal. Defaults to empty.
|
||||
*/
|
||||
properties?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Encapsulates options passed into client.flush() function
|
||||
*/
|
||||
interface FlushOptions {
|
||||
/**
|
||||
* Flag indicating whether application is crashing. When this flag is set to true
|
||||
* and storing data locally is enabled, Node.JS SDK will attempt to store data on disk
|
||||
*/
|
||||
isAppCrashing?: boolean;
|
||||
/**
|
||||
* Callback that will be invoked with the response from server, in case of isAppCrashing set to true,
|
||||
* with immediate notification that data was stored
|
||||
*/
|
||||
callback?: (v: string) => void;
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'applicationinsights' {
|
||||
export = ApplicationInsights;
|
||||
}
|
|
@ -42,7 +42,7 @@ export class AppInsightsAppender implements ITelemetryAppender {
|
|||
constructor(
|
||||
private _eventPrefix: string,
|
||||
private _defaultData: { [key: string]: any } | null,
|
||||
aiKeyOrClientFactory: string | (() => appInsights.ITelemetryClient), // allow factory function for testing
|
||||
aiKeyOrClientFactory: string | (() => appInsights.TelemetryClient), // allow factory function for testing
|
||||
@ILogService private _logService?: ILogService
|
||||
) {
|
||||
if (!this._defaultData) {
|
||||
|
|
|
@ -5,15 +5,19 @@
|
|||
import * as assert from 'assert';
|
||||
import { AppInsightsAppender } from 'vs/platform/telemetry/node/appInsightsAppender';
|
||||
import { ILogService, AbstractLogService, LogLevel, DEFAULT_LOG_LEVEL } from 'vs/platform/log/common/log';
|
||||
import { ITelemetryClient, EventTelemetry } from 'applicationinsights';
|
||||
import { TelemetryClient, Contracts } from 'applicationinsights';
|
||||
|
||||
class AppInsightsMock implements ITelemetryClient {
|
||||
class AppInsightsMock extends TelemetryClient {
|
||||
public config: any;
|
||||
public channel: any;
|
||||
public events: EventTelemetry[] = [];
|
||||
public events: Contracts.EventTelemetry[] = [];
|
||||
public IsTrackingPageView: boolean = false;
|
||||
public exceptions: any[] = [];
|
||||
|
||||
constructor() {
|
||||
super('testKey');
|
||||
}
|
||||
|
||||
public trackEvent(event: any) {
|
||||
this.events.push(event);
|
||||
}
|
||||
|
|
71
yarn.lock
71
yarn.lock
|
@ -95,6 +95,13 @@
|
|||
lodash "^4.17.11"
|
||||
to-fast-properties "^2.0.0"
|
||||
|
||||
"@types/applicationinsights@0.20.0":
|
||||
version "0.20.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/applicationinsights/-/applicationinsights-0.20.0.tgz#fa7b36dc954f635fa9037cad27c378446b1048fb"
|
||||
integrity sha512-dQ3Hb58ERe5YNKFVyvU9BrEvpgKeb6Ht9HkCyBvsOZxhx6yKSwF3e+xml3PJQ3JiVOvf6gM/PmE3MdWDl1L6aA==
|
||||
dependencies:
|
||||
applicationinsights "*"
|
||||
|
||||
"@types/chokidar@2.1.3":
|
||||
version "2.1.3"
|
||||
resolved "https://registry.yarnpkg.com/@types/chokidar/-/chokidar-2.1.3.tgz#123ab795dba6d89be04bf076e6aecaf8620db674"
|
||||
|
@ -579,6 +586,16 @@ append-buffer@^1.0.2:
|
|||
dependencies:
|
||||
buffer-equal "^1.0.0"
|
||||
|
||||
applicationinsights@*:
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/applicationinsights/-/applicationinsights-1.5.0.tgz#074df9e525dcfd592822e7b80723b9284d2716fd"
|
||||
integrity sha512-D+JyPrDx9RWVNIwukoe03ANKNdyVe/ejExbR7xMvZTm09553TzXenW2oPZmfN9jeguKSDugzIWdbILMPNSRRlg==
|
||||
dependencies:
|
||||
cls-hooked "^4.2.2"
|
||||
continuation-local-storage "^3.2.1"
|
||||
diagnostic-channel "0.2.0"
|
||||
diagnostic-channel-publishers "^0.3.3"
|
||||
|
||||
applicationinsights@1.0.8:
|
||||
version "1.0.8"
|
||||
resolved "https://registry.yarnpkg.com/applicationinsights/-/applicationinsights-1.0.8.tgz#db6e3d983cf9f9405fe1ee5ba30ac6e1914537b5"
|
||||
|
@ -813,11 +830,26 @@ async-each@^1.0.0, async-each@^1.0.1:
|
|||
resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d"
|
||||
integrity sha1-GdOGodntxufByF04iu28xW0zYC0=
|
||||
|
||||
async-hook-jl@^1.7.6:
|
||||
version "1.7.6"
|
||||
resolved "https://registry.yarnpkg.com/async-hook-jl/-/async-hook-jl-1.7.6.tgz#4fd25c2f864dbaf279c610d73bf97b1b28595e68"
|
||||
integrity sha512-gFaHkFfSxTjvoxDMYqDuGHlcRyUuamF8s+ZTtJdDzqjws4mCt7v0vuV79/E2Wr2/riMQgtG4/yUtXWs1gZ7JMg==
|
||||
dependencies:
|
||||
stack-chain "^1.3.7"
|
||||
|
||||
async-limiter@~1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.0.tgz#78faed8c3d074ab81f22b4e985d79e8738f720f8"
|
||||
integrity sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==
|
||||
|
||||
async-listener@^0.6.0:
|
||||
version "0.6.10"
|
||||
resolved "https://registry.yarnpkg.com/async-listener/-/async-listener-0.6.10.tgz#a7c97abe570ba602d782273c0de60a51e3e17cbc"
|
||||
integrity sha512-gpuo6xOyF4D5DE5WvyqZdPA3NGhiT6Qf07l7DCB0wwDEsLvDIbCr6j9S5aj5Ch96dLace5tXVzWBZkxU/c5ohw==
|
||||
dependencies:
|
||||
semver "^5.3.0"
|
||||
shimmer "^1.1.0"
|
||||
|
||||
async-settle@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/async-settle/-/async-settle-1.0.0.tgz#1d0a914bb02575bec8a8f3a74e5080f72b2c0c6b"
|
||||
|
@ -1570,6 +1602,15 @@ cloneable-readable@^1.0.0:
|
|||
process-nextick-args "^1.0.6"
|
||||
through2 "^2.0.1"
|
||||
|
||||
cls-hooked@^4.2.2:
|
||||
version "4.2.2"
|
||||
resolved "https://registry.yarnpkg.com/cls-hooked/-/cls-hooked-4.2.2.tgz#ad2e9a4092680cdaffeb2d3551da0e225eae1908"
|
||||
integrity sha512-J4Xj5f5wq/4jAvcdgoGsL3G103BtWpZrMo8NEinRltN+xpTZdI+M38pyQqhuFU/P792xkMFvnKSf+Lm81U1bxw==
|
||||
dependencies:
|
||||
async-hook-jl "^1.7.6"
|
||||
emitter-listener "^1.0.1"
|
||||
semver "^5.4.1"
|
||||
|
||||
co@^4.6.0:
|
||||
version "4.6.0"
|
||||
resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184"
|
||||
|
@ -1789,6 +1830,14 @@ content-type@~1.0.4:
|
|||
resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b"
|
||||
integrity sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==
|
||||
|
||||
continuation-local-storage@^3.2.1:
|
||||
version "3.2.1"
|
||||
resolved "https://registry.yarnpkg.com/continuation-local-storage/-/continuation-local-storage-3.2.1.tgz#11f613f74e914fe9b34c92ad2d28fe6ae1db7ffb"
|
||||
integrity sha512-jx44cconVqkCEEyLSKWwkvUXwO561jXMa3LPjTPsm5QR22PA0/mhe33FT4Xb5y74JDvt/Cq+5lm8S8rskLv9ZA==
|
||||
dependencies:
|
||||
async-listener "^0.6.0"
|
||||
emitter-listener "^1.1.1"
|
||||
|
||||
convert-source-map@^1.1.1:
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.5.0.tgz#9acd70851c6d5dfdd93d9282e5edf94a03ff46b5"
|
||||
|
@ -2260,6 +2309,11 @@ diagnostic-channel-publishers@0.2.1:
|
|||
resolved "https://registry.yarnpkg.com/diagnostic-channel-publishers/-/diagnostic-channel-publishers-0.2.1.tgz#8e2d607a8b6d79fe880b548bc58cc6beb288c4f3"
|
||||
integrity sha1-ji1geottef6IC1SLxYzGvrKIxPM=
|
||||
|
||||
diagnostic-channel-publishers@^0.3.3:
|
||||
version "0.3.3"
|
||||
resolved "https://registry.yarnpkg.com/diagnostic-channel-publishers/-/diagnostic-channel-publishers-0.3.3.tgz#376b7798f4fa90f37eb4f94d2caca611b0e9c330"
|
||||
integrity sha512-qIocRYU5TrGUkBlDDxaziAK1+squ8Yf2Ls4HldL3xxb/jzmWO2Enux7CvevNKYmF2kDXZ9HiRqwjPsjk8L+i2Q==
|
||||
|
||||
diagnostic-channel@0.2.0:
|
||||
version "0.2.0"
|
||||
resolved "https://registry.yarnpkg.com/diagnostic-channel/-/diagnostic-channel-0.2.0.tgz#cc99af9612c23fb1fff13612c72f2cbfaa8d5a17"
|
||||
|
@ -2434,6 +2488,13 @@ elliptic@^6.0.0:
|
|||
minimalistic-assert "^1.0.0"
|
||||
minimalistic-crypto-utils "^1.0.0"
|
||||
|
||||
emitter-listener@^1.0.1, emitter-listener@^1.1.1:
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/emitter-listener/-/emitter-listener-1.1.2.tgz#56b140e8f6992375b3d7cb2cab1cc7432d9632e8"
|
||||
integrity sha512-Bt1sBAGFHY9DKY+4/2cV6izcKJUf5T7/gkdmkxzX/qv9CcGH8xSwVRW5mtX03SWJtRTWSOpzCuWN9rBFYZepZQ==
|
||||
dependencies:
|
||||
shimmer "^1.2.0"
|
||||
|
||||
emoji-regex@^7.0.1:
|
||||
version "7.0.3"
|
||||
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156"
|
||||
|
@ -7623,6 +7684,11 @@ shebang-regex@^1.0.0:
|
|||
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3"
|
||||
integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=
|
||||
|
||||
shimmer@^1.1.0, shimmer@^1.2.0:
|
||||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/shimmer/-/shimmer-1.2.1.tgz#610859f7de327b587efebf501fb43117f9aff337"
|
||||
integrity sha512-sQTKC1Re/rM6XyFM6fIAGHRPVGvyXfgzIDvzoq608vM+jeyVD0Tu1E6Np0Kc2zAIFWIj963V2800iF/9LPieQw==
|
||||
|
||||
sigmund@^1.0.1, sigmund@~1.0.0:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/sigmund/-/sigmund-1.0.1.tgz#3ff21f198cad2175f9f3b781853fd94d0d19b590"
|
||||
|
@ -7860,6 +7926,11 @@ ssri@^5.2.4:
|
|||
dependencies:
|
||||
safe-buffer "^5.1.1"
|
||||
|
||||
stack-chain@^1.3.7:
|
||||
version "1.3.7"
|
||||
resolved "https://registry.yarnpkg.com/stack-chain/-/stack-chain-1.3.7.tgz#d192c9ff4ea6a22c94c4dd459171e3f00cea1285"
|
||||
integrity sha1-0ZLJ/06moiyUxN1FkXHj8AzqEoU=
|
||||
|
||||
stack-trace@0.0.10:
|
||||
version "0.0.10"
|
||||
resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.10.tgz#547c70b347e8d32b4e108ea1a2a159e5fdde19c0"
|
||||
|
|
Loading…
Reference in a new issue