@microsoft/applicationinsights-core-js 2.8.4-nightly.2205-09 → 2.8.4-nightly.2205-10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/applicationinsights-core-js.integrity.json +9 -9
- package/browser/applicationinsights-core-js.js +2008 -1811
- package/browser/applicationinsights-core-js.js.map +1 -1
- package/browser/applicationinsights-core-js.min.js +2 -2
- package/browser/applicationinsights-core-js.min.js.map +1 -1
- package/dist/applicationinsights-core-js.api.json +1302 -199
- package/dist/applicationinsights-core-js.api.md +54 -0
- package/dist/applicationinsights-core-js.d.ts +174 -1
- package/dist/applicationinsights-core-js.js +2008 -1811
- package/dist/applicationinsights-core-js.js.map +1 -1
- package/dist/applicationinsights-core-js.min.js +2 -2
- package/dist/applicationinsights-core-js.min.js.map +1 -1
- package/dist/applicationinsights-core-js.rollup.d.ts +174 -1
- package/dist-esm/JavaScriptSDK/AppInsightsCore.js +1 -1
- package/dist-esm/JavaScriptSDK/BaseCore.js +15 -2
- package/dist-esm/JavaScriptSDK/BaseCore.js.map +1 -1
- package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +1 -1
- package/dist-esm/JavaScriptSDK/ChannelController.js +1 -1
- package/dist-esm/JavaScriptSDK/Constants.js +1 -1
- package/dist-esm/JavaScriptSDK/CookieMgr.js +1 -1
- package/dist-esm/JavaScriptSDK/CoreUtils.js +1 -1
- package/dist-esm/JavaScriptSDK/DataCacheHelper.js +2 -2
- package/dist-esm/JavaScriptSDK/DataCacheHelper.js.map +1 -1
- package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +1 -1
- package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +1 -1
- package/dist-esm/JavaScriptSDK/EnvUtils.js +40 -1
- package/dist-esm/JavaScriptSDK/EnvUtils.js.map +1 -1
- package/dist-esm/JavaScriptSDK/EventHelpers.js +1 -1
- package/dist-esm/JavaScriptSDK/HelperFuncs.js +1 -1
- package/dist-esm/JavaScriptSDK/InstrumentHooks.js +1 -1
- package/dist-esm/JavaScriptSDK/InternalConstants.js +1 -1
- package/dist-esm/JavaScriptSDK/NotificationManager.js +1 -1
- package/dist-esm/JavaScriptSDK/PerfManager.js +1 -1
- package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +1 -1
- package/dist-esm/JavaScriptSDK/RandomHelper.js +1 -1
- package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +54 -6
- package/dist-esm/JavaScriptSDK/TelemetryHelpers.js.map +1 -1
- package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js +1 -1
- package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js +1 -1
- package/dist-esm/JavaScriptSDK/W3cTraceParent.js +172 -0
- package/dist-esm/JavaScriptSDK/W3cTraceParent.js.map +1 -0
- package/dist-esm/JavaScriptSDK.Enums/EnumHelperFuncs.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IDbgExtension.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IDistributedTraceContext.js +8 -0
- package/dist-esm/JavaScriptSDK.Interfaces/IDistributedTraceContext.js.map +1 -0
- package/dist-esm/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITraceParent.js +8 -0
- package/dist-esm/JavaScriptSDK.Interfaces/ITraceParent.js.map +1 -0
- package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js +1 -1
- package/dist-esm/applicationinsights-core-js.js +3 -2
- package/dist-esm/applicationinsights-core-js.js.map +1 -1
- package/package.json +1 -1
- package/src/JavaScriptSDK/BaseCore.ts +32 -1
- package/src/JavaScriptSDK/DataCacheHelper.ts +1 -1
- package/src/JavaScriptSDK/EnvUtils.ts +45 -0
- package/src/JavaScriptSDK/TelemetryHelpers.ts +57 -5
- package/src/JavaScriptSDK/W3cTraceParent.ts +196 -0
- package/src/JavaScriptSDK.Interfaces/IAppInsightsCore.ts +12 -0
- package/src/JavaScriptSDK.Interfaces/IDistributedTraceContext.ts +54 -0
- package/src/JavaScriptSDK.Interfaces/ITraceParent.ts +38 -0
- package/types/JavaScriptSDK/BaseCore.d.ts +10 -0
- package/types/JavaScriptSDK/EnvUtils.d.ts +10 -0
- package/types/JavaScriptSDK/TelemetryHelpers.d.ts +7 -0
- package/types/JavaScriptSDK/W3cTraceParent.d.ts +59 -0
- package/types/JavaScriptSDK.Interfaces/IAppInsightsCore.d.ts +10 -0
- package/types/JavaScriptSDK.Interfaces/IDistributedTraceContext.d.ts +43 -0
- package/types/JavaScriptSDK.Interfaces/ITraceParent.d.ts +32 -0
- package/types/applicationinsights-core-js.d.ts +4 -1
- package/types/tsdoc-metadata.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ITraceParent.js.map","sources":["ITraceParent.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nexport {};\r\n//# sourceMappingURL=ITraceParent.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - Core, 2.8.4-nightly.2205-
|
|
2
|
+
* Application Insights JavaScript SDK - Core, 2.8.4-nightly.2205-10
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
export { MinChannelPriorty } from "./JavaScriptSDK.Interfaces/IChannelControls";
|
|
@@ -12,7 +12,7 @@ export { CoreUtils, EventHelper, Undefined, newGuid, perfNow, generateW3CId, dis
|
|
|
12
12
|
export { isTypeof, isUndefined, isNullOrUndefined, hasOwnProperty, isObject, isFunction, normalizeJsName, objForEachKey, strEndsWith, strStartsWith, isDate, isArray, isError, isString, isNumber, isBoolean, toISOString, arrForEach, arrIndexOf, arrMap, arrReduce, strTrim, objKeys, objDefineAccessors, dateNow, getExceptionName, throwError, strContains, isSymbol, setValue, getSetValue, isNotTruthy, isTruthy, proxyAssign, proxyFunctions, proxyFunctionAs, createClassFromInterface, optimizeObject, isNotUndefined, isNotNullOrUndefined, objFreeze, objSeal, objExtend, objToString, deepFreeze } from "./JavaScriptSDK/HelperFuncs";
|
|
13
13
|
export { createEnumStyle, createEnumMap, createValueMap } from "./JavaScriptSDK.Enums/EnumHelperFuncs";
|
|
14
14
|
export { attachEvent, detachEvent, addEventHandler, addEventListeners, addPageUnloadEventListener, addPageHideEventListener, addPageShowEventListener, removeEventHandler, removeEventListeners, removePageUnloadEventListener, removePageHideEventListener, removePageShowEventListener, eventOn, eventOff, mergeEvtNamespace, __getRegisteredEvents } from "./JavaScriptSDK/EventHelpers";
|
|
15
|
-
export { getGlobalInst, hasWindow, getWindow, hasDocument, getDocument, getCrypto, getMsCrypto, hasNavigator, getNavigator, hasHistory, getHistory, getLocation, getPerformance, hasJSON, getJSON, isReactNative, getConsole, dumpObj, isIE, getIEVersion, isSafari, setEnableEnvMocks, isBeaconsSupported, isFetchSupported, useXDomainRequest, isXhrSupported } from "./JavaScriptSDK/EnvUtils";
|
|
15
|
+
export { getGlobalInst, hasWindow, getWindow, hasDocument, getDocument, getCrypto, getMsCrypto, hasNavigator, getNavigator, hasHistory, getHistory, getLocation, getPerformance, hasJSON, getJSON, isReactNative, getConsole, dumpObj, isIE, getIEVersion, isSafari, setEnableEnvMocks, isBeaconsSupported, isFetchSupported, useXDomainRequest, isXhrSupported, findMetaTag, findNamedServerTiming } from "./JavaScriptSDK/EnvUtils";
|
|
16
16
|
export { getGlobal, objCreateFn as objCreate, strShimPrototype as strPrototype, strShimFunction as strFunction, strShimUndefined as strUndefined, strShimObject as strObject } from "@microsoft/applicationinsights-shims";
|
|
17
17
|
export { NotificationManager } from "./JavaScriptSDK/NotificationManager";
|
|
18
18
|
export { PerfEvent, PerfManager, doPerf, getGblPerfMgr, setGblPerfMgr } from "./JavaScriptSDK/PerfManager";
|
|
@@ -27,4 +27,5 @@ export { createCookieMgr, safeGetCookieMgr, uaDisallowsSameSiteNone, areCookiesS
|
|
|
27
27
|
export { getDebugListener, getDebugExt } from "./JavaScriptSDK/DbgExtensionUtils";
|
|
28
28
|
export { createUniqueNamespace } from "./JavaScriptSDK/DataCacheHelper";
|
|
29
29
|
export { createUnloadHandlerContainer } from "./JavaScriptSDK/UnloadHandlerContainer";
|
|
30
|
+
export { createTraceParent, parseTraceParent, isValidTraceId, isValidSpanId, isValidTraceParent, isSampledFlag, formatTraceParent, findW3cTraceParent } from "./JavaScriptSDK/W3cTraceParent";
|
|
30
31
|
//# sourceMappingURL=applicationinsights-core-js.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applicationinsights-core-js.js.map","sources":["applicationinsights-core-js.js"],"sourcesContent":["export { MinChannelPriorty } from \"./JavaScriptSDK.Interfaces/IChannelControls\";\r\nexport { EventsDiscardedReason } from \"./JavaScriptSDK.Enums/EventsDiscardedReason\";\r\nexport { AppInsightsCore } from \"./JavaScriptSDK/AppInsightsCore\";\r\nexport { BaseCore } from \"./JavaScriptSDK/BaseCore\";\r\nexport { BaseTelemetryPlugin } from \"./JavaScriptSDK/BaseTelemetryPlugin\";\r\nexport { randomValue, random32, mwcRandomSeed, mwcRandom32, newId } from \"./JavaScriptSDK/RandomHelper\";\r\nexport { CoreUtils, EventHelper, Undefined, newGuid, perfNow, generateW3CId, disableCookies, canUseCookies, getCookie, setCookie, deleteCookie, _legacyCookieMgr } from \"./JavaScriptSDK/CoreUtils\";\r\nexport { isTypeof, isUndefined, isNullOrUndefined, hasOwnProperty, isObject, isFunction, normalizeJsName, objForEachKey, strEndsWith, strStartsWith, isDate, isArray, isError, isString, isNumber, isBoolean, toISOString, arrForEach, arrIndexOf, arrMap, arrReduce, strTrim, objKeys, objDefineAccessors, dateNow, getExceptionName, throwError, strContains, isSymbol, setValue, getSetValue, isNotTruthy, isTruthy, proxyAssign, proxyFunctions, proxyFunctionAs, createClassFromInterface, optimizeObject, isNotUndefined, isNotNullOrUndefined, objFreeze, objSeal, objExtend, objToString, deepFreeze } from \"./JavaScriptSDK/HelperFuncs\";\r\nexport { createEnumStyle, createEnumMap, createValueMap } from \"./JavaScriptSDK.Enums/EnumHelperFuncs\";\r\nexport { attachEvent, detachEvent, addEventHandler, addEventListeners, addPageUnloadEventListener, addPageHideEventListener, addPageShowEventListener, removeEventHandler, removeEventListeners, removePageUnloadEventListener, removePageHideEventListener, removePageShowEventListener, eventOn, eventOff, mergeEvtNamespace, __getRegisteredEvents } from \"./JavaScriptSDK/EventHelpers\";\r\nexport { getGlobalInst, hasWindow, getWindow, hasDocument, getDocument, getCrypto, getMsCrypto, hasNavigator, getNavigator, hasHistory, getHistory, getLocation, getPerformance, hasJSON, getJSON, isReactNative, getConsole, dumpObj, isIE, getIEVersion, isSafari, setEnableEnvMocks, isBeaconsSupported, isFetchSupported, useXDomainRequest, isXhrSupported } from \"./JavaScriptSDK/EnvUtils\";\r\nexport { getGlobal, objCreateFn as objCreate, strShimPrototype as strPrototype, strShimFunction as strFunction, strShimUndefined as strUndefined, strShimObject as strObject } from \"@microsoft/applicationinsights-shims\";\r\nexport { NotificationManager } from \"./JavaScriptSDK/NotificationManager\";\r\nexport { PerfEvent, PerfManager, doPerf, getGblPerfMgr, setGblPerfMgr } from \"./JavaScriptSDK/PerfManager\";\r\nexport { safeGetLogger, DiagnosticLogger, _InternalLogMessage, _throwInternal, _warnToConsole, _logInternalMessage } from \"./JavaScriptSDK/DiagnosticLogger\";\r\nexport { ProcessTelemetryContext, createProcessTelemetryContext\r\n// Explicitly NOT exporting createProcessTelemetryUnloadContext() and createProcessTelemetryUpdateContext() as these should only be created internally\r\n } from \"./JavaScriptSDK/ProcessTelemetryContext\";\r\nexport { initializePlugins, sortPlugins, unloadComponents } from \"./JavaScriptSDK/TelemetryHelpers\";\r\nexport { _InternalMessageId, LoggingSeverity } from \"./JavaScriptSDK.Enums/LoggingEnums\";\r\nexport { InstrumentProto, InstrumentProtos, InstrumentFunc, InstrumentFuncs, InstrumentEvent } from \"./JavaScriptSDK/InstrumentHooks\";\r\nexport { createCookieMgr, safeGetCookieMgr, uaDisallowsSameSiteNone, areCookiesSupported } from \"./JavaScriptSDK/CookieMgr\";\r\nexport { getDebugListener, getDebugExt } from \"./JavaScriptSDK/DbgExtensionUtils\";\r\nexport { createUniqueNamespace } from \"./JavaScriptSDK/DataCacheHelper\";\r\nexport { createUnloadHandlerContainer } from \"./JavaScriptSDK/UnloadHandlerContainer\";\r\n//# sourceMappingURL=applicationinsights-core-js.js.map"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
|
1
|
+
{"version":3,"file":"applicationinsights-core-js.js.map","sources":["applicationinsights-core-js.js"],"sourcesContent":["export { MinChannelPriorty } from \"./JavaScriptSDK.Interfaces/IChannelControls\";\r\nexport { EventsDiscardedReason } from \"./JavaScriptSDK.Enums/EventsDiscardedReason\";\r\nexport { AppInsightsCore } from \"./JavaScriptSDK/AppInsightsCore\";\r\nexport { BaseCore } from \"./JavaScriptSDK/BaseCore\";\r\nexport { BaseTelemetryPlugin } from \"./JavaScriptSDK/BaseTelemetryPlugin\";\r\nexport { randomValue, random32, mwcRandomSeed, mwcRandom32, newId } from \"./JavaScriptSDK/RandomHelper\";\r\nexport { CoreUtils, EventHelper, Undefined, newGuid, perfNow, generateW3CId, disableCookies, canUseCookies, getCookie, setCookie, deleteCookie, _legacyCookieMgr } from \"./JavaScriptSDK/CoreUtils\";\r\nexport { isTypeof, isUndefined, isNullOrUndefined, hasOwnProperty, isObject, isFunction, normalizeJsName, objForEachKey, strEndsWith, strStartsWith, isDate, isArray, isError, isString, isNumber, isBoolean, toISOString, arrForEach, arrIndexOf, arrMap, arrReduce, strTrim, objKeys, objDefineAccessors, dateNow, getExceptionName, throwError, strContains, isSymbol, setValue, getSetValue, isNotTruthy, isTruthy, proxyAssign, proxyFunctions, proxyFunctionAs, createClassFromInterface, optimizeObject, isNotUndefined, isNotNullOrUndefined, objFreeze, objSeal, objExtend, objToString, deepFreeze } from \"./JavaScriptSDK/HelperFuncs\";\r\nexport { createEnumStyle, createEnumMap, createValueMap } from \"./JavaScriptSDK.Enums/EnumHelperFuncs\";\r\nexport { attachEvent, detachEvent, addEventHandler, addEventListeners, addPageUnloadEventListener, addPageHideEventListener, addPageShowEventListener, removeEventHandler, removeEventListeners, removePageUnloadEventListener, removePageHideEventListener, removePageShowEventListener, eventOn, eventOff, mergeEvtNamespace, __getRegisteredEvents } from \"./JavaScriptSDK/EventHelpers\";\r\nexport { getGlobalInst, hasWindow, getWindow, hasDocument, getDocument, getCrypto, getMsCrypto, hasNavigator, getNavigator, hasHistory, getHistory, getLocation, getPerformance, hasJSON, getJSON, isReactNative, getConsole, dumpObj, isIE, getIEVersion, isSafari, setEnableEnvMocks, isBeaconsSupported, isFetchSupported, useXDomainRequest, isXhrSupported, findMetaTag, findNamedServerTiming } from \"./JavaScriptSDK/EnvUtils\";\r\nexport { getGlobal, objCreateFn as objCreate, strShimPrototype as strPrototype, strShimFunction as strFunction, strShimUndefined as strUndefined, strShimObject as strObject } from \"@microsoft/applicationinsights-shims\";\r\nexport { NotificationManager } from \"./JavaScriptSDK/NotificationManager\";\r\nexport { PerfEvent, PerfManager, doPerf, getGblPerfMgr, setGblPerfMgr } from \"./JavaScriptSDK/PerfManager\";\r\nexport { safeGetLogger, DiagnosticLogger, _InternalLogMessage, _throwInternal, _warnToConsole, _logInternalMessage } from \"./JavaScriptSDK/DiagnosticLogger\";\r\nexport { ProcessTelemetryContext, createProcessTelemetryContext\r\n// Explicitly NOT exporting createProcessTelemetryUnloadContext() and createProcessTelemetryUpdateContext() as these should only be created internally\r\n } from \"./JavaScriptSDK/ProcessTelemetryContext\";\r\nexport { initializePlugins, sortPlugins, unloadComponents } from \"./JavaScriptSDK/TelemetryHelpers\";\r\nexport { _InternalMessageId, LoggingSeverity } from \"./JavaScriptSDK.Enums/LoggingEnums\";\r\nexport { InstrumentProto, InstrumentProtos, InstrumentFunc, InstrumentFuncs, InstrumentEvent } from \"./JavaScriptSDK/InstrumentHooks\";\r\nexport { createCookieMgr, safeGetCookieMgr, uaDisallowsSameSiteNone, areCookiesSupported } from \"./JavaScriptSDK/CookieMgr\";\r\nexport { getDebugListener, getDebugExt } from \"./JavaScriptSDK/DbgExtensionUtils\";\r\nexport { createUniqueNamespace } from \"./JavaScriptSDK/DataCacheHelper\";\r\nexport { createUnloadHandlerContainer } from \"./JavaScriptSDK/UnloadHandlerContainer\";\r\nexport { createTraceParent, parseTraceParent, isValidTraceId, isValidSpanId, isValidTraceParent, isSampledFlag, formatTraceParent, findW3cTraceParent } from \"./JavaScriptSDK/W3cTraceParent\";\r\n//# sourceMappingURL=applicationinsights-core-js.js.map"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/applicationinsights-core-js",
|
|
3
3
|
"author": "Microsoft Application Insights Team",
|
|
4
|
-
"version": "2.8.4-nightly.2205-
|
|
4
|
+
"version": "2.8.4-nightly.2205-10",
|
|
5
5
|
"description": "Microsoft Application Insights Core Javascript SDK",
|
|
6
6
|
"homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme",
|
|
7
7
|
"keywords": [
|
|
@@ -14,7 +14,7 @@ import { INotificationListener } from "../JavaScriptSDK.Interfaces/INotification
|
|
|
14
14
|
import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
|
|
15
15
|
import { IProcessTelemetryContext, IProcessTelemetryUpdateContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
|
|
16
16
|
import { createProcessTelemetryContext, createProcessTelemetryUnloadContext, createProcessTelemetryUpdateContext, createTelemetryProxyChain } from "./ProcessTelemetryContext";
|
|
17
|
-
import { initializePlugins, sortPlugins, _getPluginState } from "./TelemetryHelpers";
|
|
17
|
+
import { createDistributedTraceContext, initializePlugins, sortPlugins, _getPluginState } from "./TelemetryHelpers";
|
|
18
18
|
import { eLoggingSeverity, _eInternalMessageId } from "../JavaScriptSDK.Enums/LoggingEnums";
|
|
19
19
|
import { IPerfManager } from "../JavaScriptSDK.Interfaces/IPerfManager";
|
|
20
20
|
import { getGblPerfMgr, PerfManager } from "./PerfManager";
|
|
@@ -40,6 +40,7 @@ import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnl
|
|
|
40
40
|
import { TelemetryUnloadReason } from "../JavaScriptSDK.Enums/TelemetryUnloadReason";
|
|
41
41
|
import { SendRequestReason } from "../JavaScriptSDK.Enums/SendRequestReason";
|
|
42
42
|
import { strAddNotificationListener, strDisabled, strEventsDiscarded, strEventsSendRequest, strEventsSent, strRemoveNotificationListener, strTeardown } from "./InternalConstants";
|
|
43
|
+
import { IDistributedTraceContext } from "../JavaScriptSDK.Interfaces/IDistributedTraceContext";
|
|
43
44
|
|
|
44
45
|
const strValidationError = "Plugins must provide initialize method";
|
|
45
46
|
const strNotificationManager = "_notificationManager";
|
|
@@ -151,6 +152,7 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
151
152
|
let _evtNamespace: string;
|
|
152
153
|
let _unloadHandlers: IUnloadHandlerContainer;
|
|
153
154
|
let _debugListener: INotificationListener | null;
|
|
155
|
+
let _traceCtx: IDistributedTraceContext | null;
|
|
154
156
|
|
|
155
157
|
/**
|
|
156
158
|
* Internal log poller
|
|
@@ -453,6 +455,18 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
453
455
|
|
|
454
456
|
_self.flush = _flushChannels;
|
|
455
457
|
|
|
458
|
+
_self.getTraceCtx = (createNew?: boolean): IDistributedTraceContext | null => {
|
|
459
|
+
if (!_traceCtx) {
|
|
460
|
+
_traceCtx = createDistributedTraceContext();
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
return _traceCtx;
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
_self.setTraceCtx = (traceCtx: IDistributedTraceContext): void => {
|
|
467
|
+
_traceCtx = traceCtx || null;
|
|
468
|
+
};
|
|
469
|
+
|
|
456
470
|
// Create the addUnloadCb
|
|
457
471
|
proxyFunctionAs(_self, "addUnloadCb", () => _unloadHandlers, "add");
|
|
458
472
|
|
|
@@ -480,6 +494,7 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
480
494
|
_internalLogsEventName = null;
|
|
481
495
|
_evtNamespace = createUniqueNamespace("AIBaseCore", true);
|
|
482
496
|
_unloadHandlers = createUnloadHandlerContainer();
|
|
497
|
+
_traceCtx = null;
|
|
483
498
|
}
|
|
484
499
|
|
|
485
500
|
function _createTelCtx(): IProcessTelemetryContext {
|
|
@@ -886,6 +901,22 @@ export class BaseCore implements IAppInsightsCore {
|
|
|
886
901
|
public flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): void {
|
|
887
902
|
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
888
903
|
}
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* Gets the current distributed trace context for this instance if available
|
|
907
|
+
* @param createNew - Optional flag to create a new instance if one doesn't currently exist, defaults to true
|
|
908
|
+
*/
|
|
909
|
+
public getTraceCtx(createNew?: boolean): IDistributedTraceContext | null {
|
|
910
|
+
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
911
|
+
return null;
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
/**
|
|
915
|
+
* Sets the current distributed trace context for this instance if available
|
|
916
|
+
*/
|
|
917
|
+
public setTraceCtx(newTracectx: IDistributedTraceContext): void {
|
|
918
|
+
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
919
|
+
}
|
|
889
920
|
|
|
890
921
|
protected releaseQueue() {
|
|
891
922
|
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
@@ -411,3 +411,48 @@ export function isXhrSupported(): boolean {
|
|
|
411
411
|
|
|
412
412
|
return isSupported;
|
|
413
413
|
}
|
|
414
|
+
|
|
415
|
+
function _getNamedValue(values: any, name: string) {
|
|
416
|
+
if (values) {
|
|
417
|
+
for (var i = 0; i < values.length; i++) {
|
|
418
|
+
var value = values[i] as any;
|
|
419
|
+
if (value.name) {
|
|
420
|
+
if(value.name === name) {
|
|
421
|
+
return value;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
return {};
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Helper function to fetch the named meta-tag from the page.
|
|
432
|
+
* @param name
|
|
433
|
+
*/
|
|
434
|
+
export function findMetaTag(name: string): any {
|
|
435
|
+
let doc = getDocument();
|
|
436
|
+
if (doc && name) {
|
|
437
|
+
// Look for a meta-tag
|
|
438
|
+
return _getNamedValue(doc.querySelectorAll("meta"), name).content;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
return null;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Helper function to fetch the named server timing value from the page response (first navigation event).
|
|
446
|
+
* @param name
|
|
447
|
+
*/
|
|
448
|
+
export function findNamedServerTiming(name: string): any {
|
|
449
|
+
let value: any;
|
|
450
|
+
let perf = getPerformance();
|
|
451
|
+
if (perf) {
|
|
452
|
+
// Try looking for a server-timing header
|
|
453
|
+
let navPerf = perf.getEntriesByType("navigation") || [];
|
|
454
|
+
value = _getNamedValue((navPerf.length > 0 ? navPerf[0] : {} as any).serverTiming, name).description;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
return value;
|
|
458
|
+
}
|
|
@@ -11,6 +11,9 @@ import { createElmNodeData } from "./DataCacheHelper";
|
|
|
11
11
|
import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";
|
|
12
12
|
import { IUnloadableComponent } from "../JavaScriptSDK.Interfaces/IUnloadableComponent";
|
|
13
13
|
import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState";
|
|
14
|
+
import { IDistributedTraceContext } from "../JavaScriptSDK.Interfaces/IDistributedTraceContext";
|
|
15
|
+
import { ITraceParent } from "../JavaScriptSDK.Interfaces/ITraceParent";
|
|
16
|
+
import { isValidSpanId, isValidTraceId } from "./W3cTraceParent";
|
|
14
17
|
|
|
15
18
|
const strDoUnload = "_doUnload";
|
|
16
19
|
export interface IPluginState {
|
|
@@ -93,11 +96,15 @@ export function sortPlugins<T = IPlugin>(plugins:T[]) {
|
|
|
93
96
|
// Sort by priority
|
|
94
97
|
return plugins.sort((extA, extB) => {
|
|
95
98
|
let result = 0;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
if (extB) {
|
|
100
|
+
let bHasProcess = isFunction(extB[strProcessTelemetry]);
|
|
101
|
+
if (isFunction(extA[strProcessTelemetry])) {
|
|
102
|
+
result = bHasProcess ? extA[strPriority] - extB[strPriority] : 1;
|
|
103
|
+
} else if (bHasProcess) {
|
|
104
|
+
result = -1;
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
result = extA ? 1 : -1;
|
|
101
108
|
}
|
|
102
109
|
|
|
103
110
|
return result;
|
|
@@ -132,4 +139,49 @@ export function unloadComponents(components: any | IUnloadableComponent[], unloa
|
|
|
132
139
|
}
|
|
133
140
|
|
|
134
141
|
return _doUnload();
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Creates a IDistributedTraceContext which optionally also "sets" the value on a parent
|
|
147
|
+
* @param parentCtx - An optional parent distributed trace instance
|
|
148
|
+
* @returns A new IDistributedTraceContext instance that uses an internal temporary object
|
|
149
|
+
*/
|
|
150
|
+
export function createDistributedTraceContext(parentCtx?: IDistributedTraceContext): IDistributedTraceContext {
|
|
151
|
+
let trace: ITraceParent = {} as ITraceParent;
|
|
152
|
+
|
|
153
|
+
return {
|
|
154
|
+
getName: (): string => {
|
|
155
|
+
return (trace as any).name;
|
|
156
|
+
},
|
|
157
|
+
setName: (newValue: string): void => {
|
|
158
|
+
parentCtx && parentCtx.setName(newValue);
|
|
159
|
+
(trace as any).name = newValue;
|
|
160
|
+
},
|
|
161
|
+
getTraceId: (): string => {
|
|
162
|
+
return trace.traceId;
|
|
163
|
+
},
|
|
164
|
+
setTraceId: (newValue: string): void => {
|
|
165
|
+
parentCtx && parentCtx.setTraceId(newValue);
|
|
166
|
+
if (isValidTraceId(newValue)) {
|
|
167
|
+
trace.traceId = newValue
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
getSpanId: (): string => {
|
|
171
|
+
return trace.spanId;
|
|
172
|
+
},
|
|
173
|
+
setSpanId: (newValue: string): void => {
|
|
174
|
+
parentCtx && parentCtx.setSpanId(newValue);
|
|
175
|
+
if (isValidSpanId(newValue)) {
|
|
176
|
+
trace.spanId = newValue
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
getTraceFlags: (): number => {
|
|
180
|
+
return trace.traceFlags;
|
|
181
|
+
},
|
|
182
|
+
setTraceFlags: (newTraceFlags?: number): void => {
|
|
183
|
+
parentCtx && parentCtx.setTraceFlags(newTraceFlags);
|
|
184
|
+
trace.traceFlags = newTraceFlags
|
|
185
|
+
}
|
|
186
|
+
};
|
|
135
187
|
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { ITraceParent } from "../JavaScriptSDK.Interfaces/ITraceParent";
|
|
2
|
+
import { generateW3CId } from "./CoreUtils";
|
|
3
|
+
import { findMetaTag, findNamedServerTiming } from "./EnvUtils";
|
|
4
|
+
import { isArray, isString, strTrim } from "./HelperFuncs";
|
|
5
|
+
|
|
6
|
+
// using {0,16} for leading and trailing whitespace just to constrain the possible runtime of a random string
|
|
7
|
+
const TRACE_PARENT_REGEX = /^([\da-f]{2})-([\da-f]{32})-([\da-f]{16})-([\da-f]{2})(-[^\s]*)?$/;
|
|
8
|
+
const DEFAULT_VERSION = "00";
|
|
9
|
+
const INVALID_VERSION = "ff";
|
|
10
|
+
const INVALID_TRACE_ID = "00000000000000000000000000000000";
|
|
11
|
+
const INVALID_SPAN_ID = "0000000000000000";
|
|
12
|
+
const SAMPLED_FLAG = 0x01;
|
|
13
|
+
|
|
14
|
+
function _isValid(value: string, len: number, invalidValue?: string): boolean {
|
|
15
|
+
if (value && value.length === len && value !== invalidValue) {
|
|
16
|
+
return !!value.match(/^[\da-f]*$/);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function _formatValue(value: string, len: number, defValue: string): string {
|
|
23
|
+
if (_isValid(value, len)) {
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return defValue;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function _formatFlags(value: number): string {
|
|
31
|
+
if (isNaN(value) || value < 0 || value > 255) {
|
|
32
|
+
value = 0x01;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let result = value.toString(16);
|
|
36
|
+
while (result.length < 2) {
|
|
37
|
+
result = "0" + result;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Create a new ITraceParent instance using the provided values.
|
|
45
|
+
* @param traceId - The traceId to use, when invalid a new random W3C id will be generated.
|
|
46
|
+
* @param spanId - The parent/span id to use, a new random value will be generated if it is invalid.
|
|
47
|
+
* @param flags - The traceFlags to use, defaults to zero (0) if not supplied or invalid
|
|
48
|
+
* @param version - The version to used, defaults to version "01" if not supplied or invalid.
|
|
49
|
+
* @returns
|
|
50
|
+
*/
|
|
51
|
+
export function createTraceParent(traceId?: string, spanId?: string, flags?: number, version?: string): ITraceParent {
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
version: _isValid(version, 2, INVALID_VERSION) ? version : DEFAULT_VERSION,
|
|
55
|
+
traceId: isValidTraceId(traceId) ? traceId : generateW3CId(),
|
|
56
|
+
spanId: isValidSpanId(spanId) ? spanId : generateW3CId().substr(0, 16),
|
|
57
|
+
traceFlags: flags >= 0 && flags <= 0xFF ? flags : 1
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Attempt to parse the provided string as a W3C TraceParent header value (https://www.w3.org/TR/trace-context/#traceparent-header)
|
|
63
|
+
*
|
|
64
|
+
* @param value
|
|
65
|
+
* @returns
|
|
66
|
+
*/
|
|
67
|
+
export function parseTraceParent(value: string): ITraceParent {
|
|
68
|
+
if (!value) {
|
|
69
|
+
// Don't pass a null/undefined or empty string
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (isArray(value)) {
|
|
74
|
+
// The value may have been encoded on the page into an array so handle this automatically
|
|
75
|
+
value = value[0] || "";
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (!value || !isString(value) || value.length > 8192) {
|
|
79
|
+
// limit potential processing based on total length
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// See https://www.w3.org/TR/trace-context/#versioning-of-traceparent
|
|
84
|
+
const match = TRACE_PARENT_REGEX.exec(strTrim(value));
|
|
85
|
+
if (!match || // No match
|
|
86
|
+
match[1] === INVALID_VERSION || // version ff is forbidden
|
|
87
|
+
match[2] === INVALID_TRACE_ID || // All zeros is considered to be invalid
|
|
88
|
+
match[3] === INVALID_SPAN_ID) { // All zeros is considered to be invalid
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
version: match[1],
|
|
94
|
+
traceId: match[2],
|
|
95
|
+
spanId: match[3],
|
|
96
|
+
traceFlags: parseInt(match[4], 16)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Is the provided W3c Trace Id a valid string representation, it must be a 32-character string
|
|
102
|
+
* of lowercase hexadecimal characters for example, 4bf92f3577b34da6a3ce929d0e0e4736.
|
|
103
|
+
* If all characters as zero (00000000000000000000000000000000) it will be considered an invalid value.
|
|
104
|
+
* @param value - The W3c trace Id to be validated
|
|
105
|
+
* @returns true if valid otherwise false
|
|
106
|
+
*/
|
|
107
|
+
export function isValidTraceId(value: string): boolean {
|
|
108
|
+
return _isValid(value, 32, INVALID_TRACE_ID);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Is the provided W3c span id (aka. parent id) a valid string representation, it must be a 16-character
|
|
113
|
+
* string of lowercase hexadecimal characters, for example, 00f067aa0ba902b7.
|
|
114
|
+
* If all characters are zero (0000000000000000) this is considered an invalid value.
|
|
115
|
+
* @param value - The W3c span id to be validated
|
|
116
|
+
* @returns true if valid otherwise false
|
|
117
|
+
*/
|
|
118
|
+
export function isValidSpanId(value: string): boolean {
|
|
119
|
+
return _isValid(value, 16, INVALID_SPAN_ID);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Validates that the provided ITraceParent instance conforms to the currently supported specifications
|
|
124
|
+
* @param value
|
|
125
|
+
* @returns
|
|
126
|
+
*/
|
|
127
|
+
export function isValidTraceParent(value: ITraceParent) {
|
|
128
|
+
if (!value ||
|
|
129
|
+
!_isValid(value.version, 2, INVALID_VERSION) ||
|
|
130
|
+
!_isValid(value.traceId, 32, INVALID_TRACE_ID) ||
|
|
131
|
+
!_isValid(value.spanId, 16, INVALID_SPAN_ID) ||
|
|
132
|
+
!_isValid(_formatFlags(value.traceFlags), 2)) {
|
|
133
|
+
|
|
134
|
+
// Each known field must contain a valid value
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Is the parsed traceParent indicating that the trace is currently sampled.
|
|
143
|
+
* @param value - The parsed traceParent value
|
|
144
|
+
* @returns
|
|
145
|
+
*/
|
|
146
|
+
export function isSampledFlag(value: ITraceParent) {
|
|
147
|
+
if (isValidTraceParent(value)) {
|
|
148
|
+
return (value.traceFlags & SAMPLED_FLAG) === SAMPLED_FLAG;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Format the ITraceParent value as a string using the supported and know version formats.
|
|
156
|
+
* So even if the passed traceParent is a later version the string value returned from this
|
|
157
|
+
* function will convert it to only the known version formats.
|
|
158
|
+
* This currently only supports version "00" and invalid "ff"
|
|
159
|
+
* @param value - The parsed traceParent value
|
|
160
|
+
* @returns
|
|
161
|
+
*/
|
|
162
|
+
export function formatTraceParent(value: ITraceParent) {
|
|
163
|
+
if (value) {
|
|
164
|
+
// Special Note: This only supports formatting as version 00, future versions should encode any known supported version
|
|
165
|
+
// So parsing a future version will populate the correct version value but reformatting will reduce it to version 00.
|
|
166
|
+
let flags = _formatFlags(value.traceFlags);
|
|
167
|
+
if (!_isValid(flags, 2)) {
|
|
168
|
+
flags = "01";
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
let version = value.version || DEFAULT_VERSION;
|
|
172
|
+
if (version !== "00" && version !== "ff") {
|
|
173
|
+
// Reduce version to "00"
|
|
174
|
+
version = DEFAULT_VERSION;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Format as version 00
|
|
178
|
+
return `${version}-${_formatValue(value.traceId, 32, INVALID_TRACE_ID)}-${_formatValue(value.spanId, 16, INVALID_SPAN_ID)}-${flags}`;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return "";
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Helper function to fetch the passed traceparent from the page, looking for it as a meta-tag or a Server-Timing header.
|
|
186
|
+
* @returns
|
|
187
|
+
*/
|
|
188
|
+
export function findW3cTraceParent(): ITraceParent {
|
|
189
|
+
const name = "traceparent";
|
|
190
|
+
let traceParent: ITraceParent = parseTraceParent(findMetaTag(name));
|
|
191
|
+
if (!traceParent) {
|
|
192
|
+
traceParent = parseTraceParent(findNamedServerTiming(name))
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return traceParent;
|
|
196
|
+
}
|
|
@@ -14,6 +14,7 @@ import { ITelemetryInitializerHandler, TelemetryInitializerFunction } from "./IT
|
|
|
14
14
|
import { ITelemetryUnloadState } from "./ITelemetryUnloadState";
|
|
15
15
|
import { UnloadHandler } from "../JavaScriptSDK/UnloadHandlerContainer";
|
|
16
16
|
import { SendRequestReason } from "../JavaScriptSDK.Enums/SendRequestReason";
|
|
17
|
+
import { IDistributedTraceContext } from "./IDistributedTraceContext";
|
|
17
18
|
|
|
18
19
|
export interface ILoadedPlugin<T extends IPlugin> {
|
|
19
20
|
plugin: T;
|
|
@@ -160,4 +161,15 @@ export interface IAppInsightsCore extends IPerfManagerProvider {
|
|
|
160
161
|
* @returns - true if the callback will be return after the flush is complete otherwise the caller should assume that any provided callback will never be called
|
|
161
162
|
*/
|
|
162
163
|
flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason, cbTimeout?: number): boolean | void;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Gets the current distributed trace context for this instance if available
|
|
167
|
+
* @param createNew - Optional flag to create a new instance if one doesn't currently exist, defaults to true
|
|
168
|
+
*/
|
|
169
|
+
getTraceCtx(createNew?: boolean): IDistributedTraceContext | null;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Sets the current distributed trace context for this instance if available
|
|
173
|
+
*/
|
|
174
|
+
setTraceCtx(newTraceCtx: IDistributedTraceContext | null | undefined): void;
|
|
163
175
|
}
|