Update pageviewinternal with option to override part a context

This commit is contained in:
Piyali Jana 2018-08-01 18:22:50 -07:00
Родитель c6442b4f2e
Коммит 94b465bb3e
8 изменённых файлов: 34 добавлений и 22 удалений

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

@ -36,4 +36,9 @@ export interface IPageViewTelemetry {
* property bag to contain an extension to domain properties - extension to Part B
*/
pageTags?: { [key: string]: any };
}
export interface IPageViewTelemetryInternal extends IPageViewTelemetry {
id?: string;
}

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

@ -13,7 +13,7 @@ import { IPlugin, IConfiguration, IAppInsightsCore, ITelemetryPlugin, CoreUtils,
import { TelemetryContext } from "./TelemetryContext";
import { PageVisitTimeManager } from "./Telemetry/PageVisitTimeManager";
import { IAppInsights } from "../JavascriptSDK.Interfaces/IAppInsights";
import { IPageViewTelemetry } from "../JavascriptSDK.Interfaces/IPageViewTelemetry";
import { IPageViewTelemetry, IPageViewTelemetryInternal } from "../JavascriptSDK.Interfaces/IPageViewTelemetry";
import { ITelemetryConfig } from "../JavaScriptSDK.Interfaces/ITelemetryConfig";
import { TelemetryItemCreator } from "./TelemetryItemCreator";
@ -21,16 +21,15 @@ import { TelemetryItemCreator } from "./TelemetryItemCreator";
export class ApplicationInsights implements IAppInsights, ITelemetryPlugin, IAppInsightsInternal {
public static defaultIdentifier = "ApplicationInsightsAnalytics";
public processTelemetry: (env: ITelemetryItem) => void;
public static defaultIdentifier = "ApplicationInsightsAnalytics";
public identifier: string;
public setNextPlugin: (next: ITelemetryPlugin) => void;
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;
// Counts number of trackAjax invokations.
// By default we only monitor X ajax call per view to avoid too much load.
@ -48,7 +47,15 @@ export class ApplicationInsights implements IAppInsights, ITelemetryPlugin, IApp
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);
}
public setNextPlugin(next: ITelemetryPlugin) {
this._nextPlugin = next;
}
/**
@ -72,8 +79,8 @@ export class ApplicationInsights implements IAppInsights, ITelemetryPlugin, IApp
}
}
public sendPageViewInternal(pageView: IPageViewTelemetry, properties?: { [key: string]: any }) {
let telemetryItem = TelemetryItemCreator.createItem(pageView, PageView.dataType, PageView.envelopeType, properties);
public sendPageViewInternal(pageView: IPageViewTelemetryInternal, properties?: { [key: string]: any }, systemProperties?: { [key: string]: any }) {
let telemetryItem = TelemetryItemCreator.createItem(pageView, PageView.dataType, PageView.envelopeType, properties, systemProperties);
this.context.track(telemetryItem);

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

@ -4,13 +4,13 @@
_InternalMessageId, Util, IChannelControlsAI
} from 'applicationinsights-common';
import { IAppInsightsCore, CoreUtils } from 'applicationinsights-core-js';
import { IPageViewTelemetry } from "../../JavascriptSDK.Interfaces/IPageViewTelemetry";
import { IPageViewTelemetry, IPageViewTelemetryInternal } from "../../JavascriptSDK.Interfaces/IPageViewTelemetry";
/**
* Internal interface to pass appInsights object to subcomponents without coupling
*/
export interface IAppInsightsInternal {
sendPageViewInternal(pageViewItem: IPageViewTelemetry, properties?: Object);
sendPageViewInternal(pageViewItem: IPageViewTelemetryInternal, properties?: Object);
sendPageViewPerformanceInternal(pageViewPerformance: PageViewPerformance);
}

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

@ -1,32 +1,32 @@
import { PageView, IEnvelope, Util, DataSanitizer } from "applicationinsights-common";
import { ITelemetryItem, CoreUtils } from "applicationinsights-core-js";
import { IPageViewTelemetry } from "../JavaScriptSDK.Interfaces/IPageViewTelemetry";
import { IPageViewTelemetryInternal } from "../JavaScriptSDK.Interfaces/IPageViewTelemetry";
export interface ITelemetryItemCreator {
create(pageView: IPageViewTelemetry, baseType: string, envelopeName: string, customProperties?: { [key: string]: any }): ITelemetryItem
create(pageView: IPageViewTelemetryInternal, baseType: string, envelopeName: string, customProperties?: { [key: string]: any }): ITelemetryItem
}
export class TelemetryItemCreator implements ITelemetryItemCreator {
private static creator = new TelemetryItemCreator();
public static createItem(pageView: IPageViewTelemetry, baseType: string, envelopeName: string, customProperties?: { [key: string]: any }): ITelemetryItem {
public static createItem(pageView: IPageViewTelemetryInternal, baseType: string, envelopeName: string, customProperties?: { [key: string]: any }, systemProperties?: { [key: string]: any }): ITelemetryItem {
if (CoreUtils.isNullOrUndefined(pageView) ||
CoreUtils.isNullOrUndefined(baseType) ||
CoreUtils.isNullOrUndefined(envelopeName)) {
throw Error("pageView doesn't contain all required fields");
};
return TelemetryItemCreator.creator.create(pageView, baseType, envelopeName, customProperties);
return TelemetryItemCreator.creator.create(pageView, baseType, envelopeName, customProperties, systemProperties);
}
create(pageView: IPageViewTelemetry, baseType: string, envelopeName: string, customProperties?: { [key: string]: any }): ITelemetryItem {
create(pageView: IPageViewTelemetryInternal, baseType: string, envelopeName: string, customProperties?: { [key: string]: any }, systemProperties?: { [key: string]: any }): ITelemetryItem {
envelopeName = DataSanitizer.sanitizeString(envelopeName) || Util.NotSpecified;
if (baseType === PageView.dataType) {
let item: ITelemetryItem = {
name: envelopeName,
timestamp: new Date(),
instrumentationKey: "", // this will be set in TelemetryContext
ctx: {},
ctx: systemProperties ? systemProperties : {},
tags: [],
data: {
},

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

@ -1,6 +1,6 @@
{
"name": "applicationinsights-analytics-js",
"version": "0.0.67",
"version": "0.0.71",
"description": "Microsoft Application Insights Javascript SDK apis",
"main": "bundle/applicationinsights-analytics-js.js",
"types": "bundle/applicationinsights-analytics-js.d.ts",

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

@ -1,2 +1,2 @@
export { ApplicationInsights } from "./JavaScriptSDK/ApplicationInsights";
export { IPageViewTelemetry } from "./JavaScriptSDK.Interfaces/IPageViewTelemetry";
export { IPageViewTelemetry, IPageViewTelemetryInternal } from "./JavaScriptSDK.Interfaces/IPageViewTelemetry";

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

@ -1,6 +1,6 @@
{
"name": "applicationinsights-analytics-js",
"version": "0.0.70",
"version": "0.0.74",
"description": "Microsoft Application Insights Javascript SDK APIs for commonjs",
"main": "bundle/applicationinsights-analytics-js.js",
"types": "bundle/applicationinsights-analytics-js.d.ts",

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

@ -1,7 +1,7 @@
{
"name": "applicationinsights-analytics-js",
"version": "0.0.70",
"description": "Microsoft Application Insights Javascript SDK APIs for commonjs",
"version": "0.0.71",
"description": "Microsoft Application Insights Javascript SDK apis",
"main": "bundle/applicationinsights-analytics-js.js",
"types": "bundle/applicationinsights-analytics-js.d.ts",
"devDependencies": {
@ -11,7 +11,7 @@
"registry": "https://mseng.pkgs.visualstudio.com/_packaging/ApplicationInsights-Team/npm/registry"
},
"dependencies": {
"applicationinsights-common": "0.0.66",
"applicationinsights-core-js": "0.0.58"
"applicationinsights-common": "0.0.65",
"applicationinsights-core-js": "0.0.59"
}
}