Web Basic: add flush, export types, fix initialization crash (#709)

* add flush, export types, fix initialization crash

* remove window dependency from DateTimeUtils

* Remove browser field from package.json, export types in main
This commit is contained in:
Mark Wolff 2018-11-08 13:48:27 -08:00 коммит произвёл GitHub
Родитель e89cac6a3e
Коммит c853219183
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
8 изменённых файлов: 38 добавлений и 17 удалений

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

@ -11,5 +11,4 @@
!dist-esm/**
!dist/**
!browser/**
!types/**
!src/**
!src/**

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

@ -1,11 +1,10 @@
{
"name": "@microsoft/applicationinsights-web",
"version": "1.0.0-beta",
"version": "1.0.0-beta.1",
"description": "Microsoft Application Insights Javascript SDK API 1.0 beta",
"main": "dist/applicationinsights-web.min.js",
"main": "dist/applicationinsights-web.js",
"module": "dist-esm/applicationinsights-web.js",
"types": "types/applicationinsights-web.d.ts",
"browser": "browser/ai.1.min.js",
"types": "dist-esm/applicationinsights-web.d.ts",
"sideEffects": false,
"scripts": {
"clean": "rm -rfv browser types dist-esm",
@ -29,10 +28,10 @@
},
"dependencies": {
"@microsoft/applicationinsights-analytics-js": "^1.0.0-beta.3",
"@microsoft/applicationinsights-channel-js": "^1.0.0-beta",
"@microsoft/applicationinsights-common": "^1.0.0-beta.3",
"@microsoft/applicationinsights-channel-js": "^1.0.0-beta.3",
"@microsoft/applicationinsights-common": "^1.0.0-beta.4",
"@microsoft/applicationinsights-core-js": "^1.0.0-beta.2",
"@microsoft/applicationinsights-properties-js": "^1.0.0-beta",
"@microsoft/applicationinsights-dependencies-js": "^1.0.0-beta"
"@microsoft/applicationinsights-dependencies-js": "^1.0.0-beta.1"
}
}

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

@ -347,4 +347,4 @@ export class Initialization implements IApplicationInsights {
return configuration;
}
}
}

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

@ -3,3 +3,11 @@ export {
IApplicationInsights,
Snippet
} from './Initialization';
export { IConfiguration, AppInsightsCore, IAppInsightsCore, LoggingSeverity, _InternalMessageId, ITelemetryItem } from "@microsoft/applicationinsights-core-js";
export { ApplicationInsights as ApplicationAnalytics } from "@microsoft/applicationinsights-analytics-js";
export { Util, IConfig, IDependencyTelemetry, PageViewPerformance, IPageViewPerformanceTelemetry, IPageViewTelemetry, IExceptionTelemetry, IAutoExceptionTelemetry, ITraceTelemetry, IMetricTelemetry, IEventTelemetry, IAppInsights } from "@microsoft/applicationinsights-common";
export { Sender } from "@microsoft/applicationinsights-channel-js";
export { PropertiesPlugin, IPropertiesPlugin } from "@microsoft/applicationinsights-properties-js";
export { AjaxPlugin as DependenciesPlugin, IDependenciesPlugin } from '@microsoft/applicationinsights-dependencies-js';

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

@ -13,7 +13,7 @@
"forceConsistentCasingInFileNames": true,
"declaration": true,
"declarationMap": true,
"declarationDir": "AISKU/types",
"declarationDir": "AISKU/dist-esm",
"outDir": "dist-esm",
"rootDir": "AISKU/src"
},

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

@ -25,6 +25,7 @@ export class ApplicationInsights {
if (CoreUtils.isNullOrUndefined(config) || CoreUtils.isNullOrUndefined(config.instrumentationKey)) {
throw new Error("Invalid input configuration");
}
this.config = config;
this.initialize();
}
@ -58,4 +59,19 @@ export class ApplicationInsights {
public track(item: ITelemetryItem) {
this.core.track(item);
}
}
/**
* Immediately send all batched telemetry
* @param {boolean} [async=true]
* @memberof ApplicationInsights
*/
public flush(async: boolean = true) {
this.core.getTransmissionControls().forEach(controls => {
controls.forEach(plugin => {
async ? (<Sender>plugin).flush() : (<Sender>plugin).triggerSend(async);
});
});
}
}
export { IConfiguration, AppInsightsCore, IAppInsightsCore, LoggingSeverity, _InternalMessageId, CoreUtils, ITelemetryItem };

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

@ -1,10 +1,9 @@
{
"name": "@microsoft/applicationinsights-web-basic",
"version": "1.0.0-beta",
"version": "1.0.0-beta.3",
"description": "Microsoft Application Insights Javascript SDK core and channel",
"main": "dist/applicationinsights-web-basic.min.js",
"main": "dist/applicationinsights-web-basic.js",
"module": "dist-esm/index.js",
"browser": "browser/aib.1.min.js",
"types": "types/index.d.ts",
"sideEffects": false,
"scripts": {
@ -23,7 +22,7 @@
"typescript": "2.5.3"
},
"dependencies": {
"@microsoft/applicationinsights-channel-js": "^1.0.0-beta",
"@microsoft/applicationinsights-channel-js": "^1.0.0-beta.2",
"@microsoft/applicationinsights-core-js": "^1.0.0-beta.2"
}
}

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

@ -688,7 +688,7 @@ export class DateTimeUtils {
/**
* Get the number of milliseconds since 1970/01/01 in local timezone
*/
public static Now = (window.performance && window.performance.now && window.performance.timing) ?
public static Now = (window && window.performance && window.performance.now && window.performance.timing) ?
function () {
return window.performance.now() + window.performance.timing.navigationStart;
}