Fixes zone.js monkey patching by application-insights

This commit is contained in:
Eric Amodio
2017-06-07 12:42:33 -04:00
parent 5298511bb9
commit f16c3857e5
4 changed files with 33 additions and 27 deletions

View File

@@ -16,9 +16,9 @@ interface AutoCollectConsole {
}
interface AutoCollectExceptions {
constructor(client:Client): AutoCollectExceptions;
constructor(client: Client): AutoCollectExceptions;
isInitialized(): boolean;
enable(isEnabled:boolean): void;
enable(isEnabled: boolean): void;
}
interface AutoCollectPerformance {
@@ -348,7 +348,7 @@ interface Client {
* @param max the max sample for this set
* @param stdDev the standard deviation of the set
*/
trackMetric(name: string, value: number, count?:number, min?: number, max?: number, stdDev?: number, properties?: {
trackMetric(name: string, value: number, count?: number, min?: number, max?: number, stdDev?: number, properties?: {
[key: string]: string;
}): void;
@@ -374,7 +374,8 @@ interface Client {
* @param error An error that was returned for this request if it was unsuccessful. Defaults to null.
*/
trackRequestSync(request: any /*http.IncomingMessage */, response: any /*http.ServerResponse */, ellapsedMilliseconds?: number, properties?: {
[key: string]: string;}, error?: any) : void;
[key: string]: string;
}, error?: any): void;
/**
* Log information about a dependency of your app. Typically used to track the time database calls or outgoing http requests take from your server.
@@ -503,6 +504,11 @@ interface ApplicationInsights {
*
*/
setOfflineMode(value: boolean, resentIntervall?: number): ApplicationInsights;
/**
*
*/
setAutoDependencyCorrelation(value: boolean): ApplicationInsights;
}
declare module "applicationinsights" {

View File

@@ -13,15 +13,21 @@ export class Telemetry extends Disposable {
}
static setContext(context?: { [key: string]: string }) {
_reporter && _reporter.setContext(context);
if (_reporter === undefined) return;
_reporter.setContext(context);
}
static trackEvent(name: string, properties?: { [key: string]: string }, measurements?: { [key: string]: number; }) {
_reporter && _reporter.trackEvent(name, properties, measurements);
if (_reporter === undefined) return;
_reporter.trackEvent(name, properties, measurements);
}
static trackException(ex: Error) {
_reporter && _reporter.trackException(ex);
if (_reporter === undefined) return;
_reporter.trackException(ex);
}
}
@@ -44,11 +50,12 @@ export class TelemetryReporter {
}
else {
this._client = this.appInsights.setup(key)
.setAutoCollectConsole(false)
.setAutoCollectDependencies(false)
.setAutoCollectExceptions(false)
.setAutoCollectPerformance(false)
.setAutoCollectRequests(false)
.setAutoCollectPerformance(false)
.setAutoCollectExceptions(false)
.setAutoCollectDependencies(false)
.setAutoCollectConsole(false)
.setAutoDependencyCorrelation(false)
.setOfflineMode(true)
.start()
.client;