change appInsightsvNextKey for window. fix grunt file.

This commit is contained in:
Basel Rustum 2018-08-08 15:55:52 -07:00
Родитель ce9ee927cc
Коммит a1be297c47
5 изменённых файлов: 16 добавлений и 13 удалений

Просмотреть файл

@ -19,7 +19,7 @@ try {
// get snippet or initialize to an empty object
// appinsightsvnext should not conflict if page uses existing sdk for a layer of instrumentation
var aiName = "appinsightsvnext";
var aiName = "appInsightsvNext";
if (window[aiName] === undefined) {
// if no snippet is present, initialize default values

Просмотреть файл

@ -48,8 +48,6 @@ export class Initialization {
let extensions = [];
let appInsightsChannel : Sender = new Sender();
extensions.push(appInsightsChannel);
extensions.push(this.appInsights);

Просмотреть файл

@ -42,7 +42,6 @@
return appInsights;
})({
instrumentationKey: "INSTRUMENTATION_KEY",
});
// global instance must be set in this order to mitigate issues in ie8 and lower
@ -50,5 +49,9 @@ window.appInsightsvNext = appInsights;
// if somebody calls the snippet twice, don't report page view again
if (appInsights.queue && appInsights.queue.length === 0) {
appInsights.trackPageView();
var pageViewItem = {
name: document.title ? document.title : "",
uri: document.URL ? document.URL : ""
};
appInsights.trackPageView(pageViewItem);
}

Просмотреть файл

@ -21,13 +21,12 @@ import { TelemetryItemCreator } from "./TelemetryItemCreator";
export class ApplicationInsights implements IAppInsights, ITelemetryPlugin, IAppInsightsInternal {
public static defaultIdentifier = "ApplicationInsightsAnalytics";
public static defaultIdentifier = "ApplicationInsightsAnalytics";
public identifier: string;
priority: number;
public initialize: (config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[]) => void;
public static Version = "0.0.1";
private _core: IAppInsightsCore;
private _globalconfig: IConfiguration;
private _nextPlugin: ITelemetryPlugin;
@ -41,17 +40,20 @@ export class ApplicationInsights implements IAppInsights, ITelemetryPlugin, IApp
private _pageVisitTimeManager: PageVisitTimeManager;
public config: IConfig;
public core: IAppInsightsCore;
public context: TelemetryContext;
public queue: (() => void)[];
public static appInsightsDefaultConfig: IConfiguration;
constructor() {
this.identifier = ApplicationInsights.defaultIdentifier;
this.initialize = this._initialize.bind(this);
this.initialize = this._initialize.bind(this);
}
public processTelemetry(env: ITelemetryItem) {
this._nextPlugin.processTelemetry(env);
if (!CoreUtils.isNullOrUndefined(this._nextPlugin)) {
this._nextPlugin.processTelemetry(env);
}
}
public setNextPlugin(next: ITelemetryPlugin) {
@ -104,7 +106,7 @@ export class ApplicationInsights implements IAppInsights, ITelemetryPlugin, IApp
throw Error("Error initializing");
}
this._core = core;
this.core = core;
this._globalconfig = {
instrumentationKey: config.instrumentationKey,
endpointUrl: config.endpointUrl
@ -158,9 +160,9 @@ export class ApplicationInsights implements IAppInsights, ITelemetryPlugin, IApp
appId: () => this.config.appId
}
this.context = new TelemetryContext(configGetters, this._core);
this.context = new TelemetryContext(configGetters, this.core);
this._pageViewManager = new PageViewManager(this, this.config.overridePageViewDuration, this._core);
this._pageViewManager = new PageViewManager(this, this.config.overridePageViewDuration, this.core);
/*
TODO: renable this trackEvent once we support trackEvent in this package. Created task to track this:

Просмотреть файл

@ -207,6 +207,6 @@ module.exports = function (grunt) {
grunt.registerTask("aitests", ["ts:appinsights", "ts:appinsightstests", "qunit:aitests"]);
grunt.registerTask("aicjs", ["ts:appinsightscjs"]);
grunt.registerTask("aisku", ["ts:aisku", "uglify:aivNext"]);
grunt.registerTask("snippetvnext, ["uglify:snippetvNext"]);
grunt.registerTask("snippetvnext", ["uglify:snippetvNext"]);
grunt.registerTask("test", ["ts:default", "ts:test", "ts:testSchema", "ts:testE2E", "ts:types", "qunit:all"]);
};