diff --git a/.aiAutoMinify.json b/.aiAutoMinify.json index b31b8f235..8209d565e 100644 --- a/.aiAutoMinify.json +++ b/.aiAutoMinify.json @@ -5,8 +5,15 @@ "_eSetDynamicPropertyFlags", "ePendingOp", "CallbackType", + "eW3CTraceFlags", + "eRequestHeaders", "eTraceStateKeyType", + "eOfflineValue", "eDependencyTypes", + "eStorageType", + "FieldType", + "eDistributedTracingModes", + "EventPersistenceValue", "eEventsDiscardedReason", "eBatchDiscardedReason", "FeatureOptInMode", @@ -20,34 +27,26 @@ "TelemetryUnloadReason", "TelemetryUpdateReason", "eTraceHeadersMode", - "eW3CTraceFlags", - "eAttributeSource", - "AddAttributeResult", - "eAttributeFilter", "eAttributeChangeOp", "eOTelSamplingDecision", "eOTelSpanKind", - "eOTelSpanStatusCode" - ] - }, - "@microsoft/applicationinsights-perfmarkmeasure-js": { - "constEnums": [] - }, - "@microsoft/applicationinsights-common": { - "constEnums": [ - "eStorageType", - "FieldType", - "eDistributedTracingModes", - "EventPersistenceValue", - "eOfflineValue", - "eRequestHeaders", + "eOTelSpanStatusCode", + "eAttributeSource", + "AddAttributeResult", "DataPointType", "DependencyKind", "DependencySourceType", "eSeverityLevel", + "eAttributeFilter", "DataSanitizerValues" ] }, + "@microsoft/applicationinsights-perfmarkmeasure-js": { + "constEnums": [] + }, + "@microsoft/applicationinsights-common": { + "constEnums": [] + }, "@microsoft/applicationinsights-properties-js": { "constEnums": [] }, diff --git a/AISKU/Tests/Perf/src/AISKUPerf.Tests.ts b/AISKU/Tests/Perf/src/AISKUPerf.Tests.ts index 1d24d1dd5..023de9783 100644 --- a/AISKU/Tests/Perf/src/AISKUPerf.Tests.ts +++ b/AISKU/Tests/Perf/src/AISKUPerf.Tests.ts @@ -1,6 +1,6 @@ import { AITestClass, Assert } from "@microsoft/ai-test-framework"; import { AppInsightsInitPerfTestClass } from "./AISKUPerf"; -import { utlRemoveSessionStorage } from "@microsoft/applicationinsights-common"; +import { utlRemoveSessionStorage } from "@microsoft/applicationinsights-core-js"; import { createTimeoutPromise, doAwait } from "@nevware21/ts-async"; function isNullOrUndefined(value: any): boolean { diff --git a/AISKU/Tests/Unit/src/AISKUSize.Tests.ts b/AISKU/Tests/Unit/src/AISKUSize.Tests.ts index 9644ad7b2..e48d81793 100644 --- a/AISKU/Tests/Unit/src/AISKUSize.Tests.ts +++ b/AISKU/Tests/Unit/src/AISKUSize.Tests.ts @@ -2,7 +2,7 @@ import { AITestClass, Assert } from "@microsoft/ai-test-framework"; import { dumpObj } from '@nevware21/ts-utils'; import { createPromise, doAwait, IPromise } from '@nevware21/ts-async'; import { strUndefined } from "@microsoft/applicationinsights-core-js"; -import { utlRemoveSessionStorage } from "@microsoft/applicationinsights-common"; +import { utlRemoveSessionStorage } from "@microsoft/applicationinsights-core-js"; import * as pako from "pako"; import { Snippet } from "../../../src/Snippet"; diff --git a/AISKU/Tests/Unit/src/CdnPackaging.tests.ts b/AISKU/Tests/Unit/src/CdnPackaging.tests.ts index 5d84b058b..2aa3fd8e5 100644 --- a/AISKU/Tests/Unit/src/CdnPackaging.tests.ts +++ b/AISKU/Tests/Unit/src/CdnPackaging.tests.ts @@ -2,7 +2,7 @@ import { AITestClass, Assert } from "@microsoft/ai-test-framework"; import { AnalyticsPluginIdentifier, BreezeChannelIdentifier, DEFAULT_BREEZE_ENDPOINT, DisabledPropertyName, DistributedTracingModes, PropertiesPluginIdentifier, RequestHeaders, SeverityLevel -} from "@microsoft/applicationinsights-common"; +} from "@microsoft/applicationinsights-core-js"; import { dumpObj, LoggingSeverity, objForEachKey, objKeys, strUndefined } from "@microsoft/applicationinsights-core-js"; import { Snippet } from "../../../src/Snippet"; diff --git a/AISKU/Tests/Unit/src/CdnThrottle.tests.ts b/AISKU/Tests/Unit/src/CdnThrottle.tests.ts index 2d3142132..f0e0f44c6 100644 --- a/AISKU/Tests/Unit/src/CdnThrottle.tests.ts +++ b/AISKU/Tests/Unit/src/CdnThrottle.tests.ts @@ -1,6 +1,6 @@ import { ApplicationInsights, ApplicationInsightsContainer, IApplicationInsights, IConfig, IConfiguration, LoggingSeverity, Snippet, _eInternalMessageId } from '../../../src/applicationinsights-web' import { AITestClass, Assert, IFetchArgs, PollingAssert} from '@microsoft/ai-test-framework'; -import { IThrottleInterval, IThrottleLimit, IThrottleMgrConfig } from '@microsoft/applicationinsights-common'; +import { IThrottleInterval, IThrottleLimit, IThrottleMgrConfig } from '@microsoft/applicationinsights-core-js'; import { SinonSpy } from 'sinon'; import { AppInsightsSku } from '../../../src/AISku'; import { createSnippetV5 } from './testSnippetV5'; diff --git a/AISKU/Tests/Unit/src/IAnalyticsConfig.Tests.ts b/AISKU/Tests/Unit/src/IAnalyticsConfig.Tests.ts index d9bd8c6f5..26d123f2a 100644 --- a/AISKU/Tests/Unit/src/IAnalyticsConfig.Tests.ts +++ b/AISKU/Tests/Unit/src/IAnalyticsConfig.Tests.ts @@ -1,6 +1,6 @@ import { ApplicationInsights, IAnalyticsConfig, IAppInsights, IConfig, ApplicationAnalytics } from "../../../src/applicationinsights-web"; import { AITestClass, Assert } from "@microsoft/ai-test-framework"; -import { AnalyticsPluginIdentifier, utlRemoveSessionStorage } from "@microsoft/applicationinsights-common"; +import { AnalyticsPluginIdentifier, utlRemoveSessionStorage } from "@microsoft/applicationinsights-core-js"; import { AppInsightsCore, IConfiguration, isFunction, onConfigChange } from "@microsoft/applicationinsights-core-js"; import { Sender } from "@microsoft/applicationinsights-channel-js"; diff --git a/AISKU/Tests/Unit/src/OTelInit.Tests.ts b/AISKU/Tests/Unit/src/OTelInit.Tests.ts index 8af75a087..7b311d8e7 100644 --- a/AISKU/Tests/Unit/src/OTelInit.Tests.ts +++ b/AISKU/Tests/Unit/src/OTelInit.Tests.ts @@ -2,7 +2,7 @@ import { AITestClass, Assert } from "@microsoft/ai-test-framework"; import { ApplicationInsights } from "../../../src/applicationinsights-web"; import { eOTelSpanKind, eOTelSpanStatusCode, isTracingSuppressed, ITelemetryItem, unsuppressTracing } from "@microsoft/applicationinsights-core-js"; import { objIs, setBypassLazyCache } from "@nevware21/ts-utils"; -import { AnalyticsPluginIdentifier, PropertiesPluginIdentifier } from "@microsoft/applicationinsights-common"; +import { AnalyticsPluginIdentifier, PropertiesPluginIdentifier } from "@microsoft/applicationinsights-core-js"; /** * Integration Tests for Span APIs with Properties Plugin and Analytics Plugin diff --git a/AISKU/Tests/Unit/src/SnippetInitialization.Tests.ts b/AISKU/Tests/Unit/src/SnippetInitialization.Tests.ts index 4f1ce6e8d..ccdb5465d 100644 --- a/AISKU/Tests/Unit/src/SnippetInitialization.Tests.ts +++ b/AISKU/Tests/Unit/src/SnippetInitialization.Tests.ts @@ -10,7 +10,7 @@ import { BaseTelemetryPlugin, IProcessTelemetryContext, isNotNullOrUndefined, IT import { BreezeChannelIdentifier, ContextTagKeys, DistributedTracingModes, IConfig, IDependencyTelemetry, RequestHeaders, utlRemoveSessionStorage, utlSetSessionStorage -} from "@microsoft/applicationinsights-common"; +} from "@microsoft/applicationinsights-core-js"; import { getGlobal } from "@microsoft/applicationinsights-shims"; import { IPropTelemetryContext } from "@microsoft/applicationinsights-properties-js"; import { dumpObj, isPromiseLike, objHasOwnProperty, strSubstring } from "@nevware21/ts-utils"; diff --git a/AISKU/Tests/Unit/src/SpanHelperUtils.Tests.ts b/AISKU/Tests/Unit/src/SpanHelperUtils.Tests.ts index b59b79b7b..32c89c4d7 100644 --- a/AISKU/Tests/Unit/src/SpanHelperUtils.Tests.ts +++ b/AISKU/Tests/Unit/src/SpanHelperUtils.Tests.ts @@ -4,12 +4,12 @@ import { createDistributedTraceContext, eOTelSpanKind, eOTelSpanStatusCode, + IDistributedTraceInit, isReadableSpan, isSpanContextValid, ITelemetryItem, wrapSpanContext } from "@microsoft/applicationinsights-core-js"; -import { IDistributedTraceInit } from "@microsoft/applicationinsights-core-js/src/JavaScriptSDK.Interfaces/IDistributedTraceContext"; /** * Comprehensive tests for span helper utility functions diff --git a/AISKU/Tests/Unit/src/SpanUtils.Tests.ts b/AISKU/Tests/Unit/src/SpanUtils.Tests.ts index 6b6346b0e..22ee416d7 100644 --- a/AISKU/Tests/Unit/src/SpanUtils.Tests.ts +++ b/AISKU/Tests/Unit/src/SpanUtils.Tests.ts @@ -22,7 +22,7 @@ import { ATTR_HTTP_ROUTE, MicrosoftClientIp } from "@microsoft/applicationinsights-core-js"; -import { IRequestTelemetry } from "@microsoft/applicationinsights-common"; +import { IRequestTelemetry } from "@microsoft/applicationinsights-core-js"; export class SpanUtilsTests extends AITestClass { private static readonly _instrumentationKey = "b7170927-2d1c-44f1-acec-59f4e1751c11"; diff --git a/AISKU/Tests/Unit/src/ThrottleSentMessage.tests.ts b/AISKU/Tests/Unit/src/ThrottleSentMessage.tests.ts index 1e4fc388a..50caf5325 100644 --- a/AISKU/Tests/Unit/src/ThrottleSentMessage.tests.ts +++ b/AISKU/Tests/Unit/src/ThrottleSentMessage.tests.ts @@ -1,6 +1,6 @@ import { ApplicationInsights, ApplicationInsightsContainer, IApplicationInsights, IConfig, IConfiguration, LoggingSeverity, Snippet, _eInternalMessageId } from '../../../src/applicationinsights-web' import { AITestClass, Assert} from '@microsoft/ai-test-framework'; -import { IThrottleInterval, IThrottleLimit, IThrottleMgrConfig } from '@microsoft/applicationinsights-common'; +import { IThrottleInterval, IThrottleLimit, IThrottleMgrConfig } from '@microsoft/applicationinsights-core-js'; import { SinonSpy } from 'sinon'; import { AppInsightsSku } from '../../../src/AISku'; import { createSnippetV5 } from './testSnippetV5'; diff --git a/AISKU/Tests/Unit/src/UseSpan.Tests.ts b/AISKU/Tests/Unit/src/UseSpan.Tests.ts index b036bb478..207c35a61 100644 --- a/AISKU/Tests/Unit/src/UseSpan.Tests.ts +++ b/AISKU/Tests/Unit/src/UseSpan.Tests.ts @@ -1,9 +1,8 @@ import { AITestClass, Assert } from "@microsoft/ai-test-framework"; import { ApplicationInsights } from "../../../src/applicationinsights-web"; import { - IReadableSpan, eOTelSpanKind, eOTelSpanStatusCode, useSpan, ITelemetryItem, ISpanScope, ITraceHost + IAppInsightsCore, IReadableSpan, eOTelSpanKind, eOTelSpanStatusCode, useSpan, ITelemetryItem, ISpanScope, ITraceHost } from "@microsoft/applicationinsights-core-js"; -import { IAppInsightsCore } from "@microsoft/applicationinsights-core-js/src/applicationinsights-core-js"; export class UseSpanTests extends AITestClass { private static readonly _instrumentationKey = "b7170927-2d1c-44f1-acec-59f4e1751c11"; diff --git a/AISKU/Tests/Unit/src/applicationinsights.e2e.fetch.tests.ts b/AISKU/Tests/Unit/src/applicationinsights.e2e.fetch.tests.ts index 3d5a044a5..a2c601760 100644 --- a/AISKU/Tests/Unit/src/applicationinsights.e2e.fetch.tests.ts +++ b/AISKU/Tests/Unit/src/applicationinsights.e2e.fetch.tests.ts @@ -1,4 +1,4 @@ -import { DistributedTracingModes, IConfig } from '@microsoft/applicationinsights-common'; +import { DistributedTracingModes, IConfig } from '@microsoft/applicationinsights-core-js'; import { ApplicationInsightsTests } from './applicationinsights.e2e.tests'; import { IConfiguration } from '@microsoft/applicationinsights-core-js'; diff --git a/AISKU/Tests/Unit/src/applicationinsights.e2e.tests.ts b/AISKU/Tests/Unit/src/applicationinsights.e2e.tests.ts index 095f929c2..fc27484c9 100644 --- a/AISKU/Tests/Unit/src/applicationinsights.e2e.tests.ts +++ b/AISKU/Tests/Unit/src/applicationinsights.e2e.tests.ts @@ -2,13 +2,13 @@ import { AITestClass, Assert, PollingAssert, EventValidator, TraceValidator, Exc import { SinonSpy } from 'sinon'; import { ApplicationInsights } from '../../../src/applicationinsights-web' import { Sender } from '@microsoft/applicationinsights-channel-js'; -import { IDependencyTelemetry, ContextTagKeys, Exception, DistributedTracingModes, RequestHeaders, IAutoExceptionTelemetry, BreezeChannelIdentifier, IConfig, EventPersistence, EventDataType, PageViewDataType, TraceDataType, ExceptionDataType, MetricDataType, PageViewPerformanceDataType, RemoteDependencyDataType } from '@microsoft/applicationinsights-common'; +import { IDependencyTelemetry, ContextTagKeys, Exception, DistributedTracingModes, RequestHeaders, IAutoExceptionTelemetry, BreezeChannelIdentifier, IConfig, EventPersistence, EventDataType, PageViewDataType, TraceDataType, ExceptionDataType, MetricDataType, PageViewPerformanceDataType, RemoteDependencyDataType } from '@microsoft/applicationinsights-core-js'; import { ITelemetryItem, getGlobal, newId, dumpObj, BaseTelemetryPlugin, IProcessTelemetryContext, __getRegisteredEvents, arrForEach, IConfiguration, ActiveStatus, FeatureOptInMode } from "@microsoft/applicationinsights-core-js"; import { IPropTelemetryContext } from '@microsoft/applicationinsights-properties-js'; import { createAsyncResolvedPromise } from '@nevware21/ts-async'; import { CONFIG_ENDPOINT_URL } from '../../../src/InternalConstants'; import { OfflineChannel } from '@microsoft/applicationinsights-offlinechannel-js'; -import { IStackFrame } from '@microsoft/applicationinsights-common/src/Interfaces/Contracts/IStackFrame'; +import { IStackFrame } from '@microsoft/applicationinsights-core-js'; import { utcNow } from '@nevware21/ts-utils'; function _checkExpectedFrame(expectedFrame: IStackFrame, actualFrame: IStackFrame, index: number) { diff --git a/AISKU/Tests/Unit/src/sanitizer.e2e.tests.ts b/AISKU/Tests/Unit/src/sanitizer.e2e.tests.ts index 3a6048f60..6e1d55b29 100644 --- a/AISKU/Tests/Unit/src/sanitizer.e2e.tests.ts +++ b/AISKU/Tests/Unit/src/sanitizer.e2e.tests.ts @@ -3,7 +3,7 @@ import { Sender } from '@microsoft/applicationinsights-channel-js'; import { AITestClass, Assert, PollingAssert } from '@microsoft/ai-test-framework'; import { SinonSpy } from 'sinon'; import { newId } from '@microsoft/applicationinsights-core-js'; -import { BreezeChannelIdentifier } from '@microsoft/applicationinsights-common'; +import { BreezeChannelIdentifier } from '@microsoft/applicationinsights-core-js'; export class SanitizerE2ETests extends AITestClass { private readonly _instrumentationKey = 'b7170927-2d1c-44f1-acec-59f4e1751c11'; diff --git a/AISKU/Tests/Unit/src/sender.e2e.tests.ts b/AISKU/Tests/Unit/src/sender.e2e.tests.ts index b74fa774f..9d22b6d2b 100644 --- a/AISKU/Tests/Unit/src/sender.e2e.tests.ts +++ b/AISKU/Tests/Unit/src/sender.e2e.tests.ts @@ -1,6 +1,6 @@ import { ApplicationInsights, IApplicationInsights } from '../../../src/applicationinsights-web' import { Sender } from '@microsoft/applicationinsights-channel-js'; -import { BreezeChannelIdentifier, utlGetSessionStorage, utlRemoveSessionStorage } from '@microsoft/applicationinsights-common'; +import { BreezeChannelIdentifier, utlGetSessionStorage, utlRemoveSessionStorage } from '@microsoft/applicationinsights-core-js'; import { ActiveStatus, dumpObj, getJSON, isArray } from '@microsoft/applicationinsights-core-js'; import { SinonSpy } from 'sinon'; import { Assert, AITestClass, PollingAssert} from "@microsoft/ai-test-framework" diff --git a/AISKU/Tests/Unit/src/validate.e2e.tests.ts b/AISKU/Tests/Unit/src/validate.e2e.tests.ts index 95b8045a7..9adc6ddaa 100644 --- a/AISKU/Tests/Unit/src/validate.e2e.tests.ts +++ b/AISKU/Tests/Unit/src/validate.e2e.tests.ts @@ -3,7 +3,7 @@ import { Sender } from '@microsoft/applicationinsights-channel-js'; import { SinonSpy } from 'sinon'; import { AITestClass, Assert, PollingAssert } from '@microsoft/ai-test-framework'; import { dumpObj } from '@microsoft/applicationinsights-core-js'; -import { BreezeChannelIdentifier } from '@microsoft/applicationinsights-common'; +import { BreezeChannelIdentifier } from '@microsoft/applicationinsights-core-js'; export class ValidateE2ETests extends AITestClass { private readonly _instrumentationKey = 'b7170927-2d1c-44f1-acec-59f4e1751c11'; diff --git a/AISKU/Tests/es6-module-type-check/package.json b/AISKU/Tests/es6-module-type-check/package.json index 4e29d203e..b129e0fa7 100644 --- a/AISKU/Tests/es6-module-type-check/package.json +++ b/AISKU/Tests/es6-module-type-check/package.json @@ -32,7 +32,7 @@ "tslib": ">= 1.0.0" }, "dependencies": { - "@microsoft/applicationinsights-common": "3.3.11", + "@microsoft/applicationinsights-core-js": "3.3.11", "@microsoft/applicationinsights-web": "3.3.11" } } diff --git a/AISKU/Tests/es6-module-type-check/src/main.ts b/AISKU/Tests/es6-module-type-check/src/main.ts index 9d6515a9c..227ed05a5 100644 --- a/AISKU/Tests/es6-module-type-check/src/main.ts +++ b/AISKU/Tests/es6-module-type-check/src/main.ts @@ -1,2 +1,2 @@ -import { ContextTagKeys } from "@microsoft/applicationinsights-common"; +import { ContextTagKeys } from "@microsoft/applicationinsights-core-js"; import { ITelemetryItem } from "@microsoft/applicationinsights-web"; \ No newline at end of file diff --git a/AISKU/package.json b/AISKU/package.json index 95502c5d4..7b752a5cb 100644 --- a/AISKU/package.json +++ b/AISKU/package.json @@ -68,7 +68,6 @@ "@microsoft/applicationinsights-analytics-js": "3.3.11", "@microsoft/applicationinsights-channel-js": "3.3.11", "@microsoft/applicationinsights-cfgsync-js": "3.3.11", - "@microsoft/applicationinsights-common": "3.3.11", "@microsoft/applicationinsights-core-js": "3.3.11", "@microsoft/applicationinsights-dependencies-js": "3.3.11", "@microsoft/applicationinsights-properties-js": "3.3.11", diff --git a/AISKU/src/AISku.ts b/AISKU/src/AISku.ts index 679c7f0b8..51a55e209 100644 --- a/AISKU/src/AISku.ts +++ b/AISKU/src/AISku.ts @@ -7,20 +7,17 @@ import { AnalyticsPlugin, ApplicationInsights } from "@microsoft/applicationinsi import { CfgSyncPlugin, ICfgSyncConfig, ICfgSyncMode } from "@microsoft/applicationinsights-cfgsync-js"; import { Sender } from "@microsoft/applicationinsights-channel-js"; import { - AnalyticsPluginIdentifier, ConnectionString, DEFAULT_BREEZE_PATH, IAutoExceptionTelemetry, IConfig, IDependencyTelemetry, - IEventTelemetry, IExceptionTelemetry, IMetricTelemetry, IPageViewPerformanceTelemetry, IPageViewTelemetry, IRequestHeaders, - ITelemetryContext as Common_ITelemetryContext, IThrottleInterval, IThrottleLimit, IThrottleMgrConfig, ITraceTelemetry, - PropertiesPluginIdentifier, ThrottleMgr, parseConnectionString -} from "@microsoft/applicationinsights-common"; -import { - AppInsightsCore, FeatureOptInMode, IAppInsightsCore, IChannelControls, IConfigDefaults, IConfiguration, ICookieMgr, ICustomProperties, - IDiagnosticLogger, IDistributedTraceContext, IDynamicConfigHandler, ILoadedPlugin, INotificationManager, IOTelApi, IOTelSpanOptions, - IPlugin, IReadableSpan, ISpanScope, ITelemetryInitializerHandler, ITelemetryItem, ITelemetryPlugin, ITelemetryUnloadState, ITraceApi, - ITraceProvider, IUnloadHook, OTelTimeInput, UnloadHandler, WatcherFunction, _eInternalMessageId, _throwInternal, - addPageHideEventListener, addPageUnloadEventListener, cfgDfMerge, cfgDfValidate, createDynamicConfig, createOTelApi, - createProcessTelemetryContext, createTraceProvider, createUniqueNamespace, doPerf, eLoggingSeverity, hasDocument, hasWindow, isArray, - isFeatureEnabled, isFunction, isNullOrUndefined, isReactNative, isString, mergeEvtNamespace, onConfigChange, proxyAssign, proxyFunctions, - removePageHideEventListener, removePageUnloadEventListener, useSpan + AnalyticsPluginIdentifier, AppInsightsCore, ConnectionString, DEFAULT_BREEZE_PATH, FeatureOptInMode, IAppInsightsCore, + IAutoExceptionTelemetry, IChannelControls, IConfig, IConfigDefaults, IConfiguration, ICookieMgr, ICustomProperties, IDependencyTelemetry, + IDiagnosticLogger, IDistributedTraceContext, IDynamicConfigHandler, IEventTelemetry, IExceptionTelemetry, ILoadedPlugin, + IMetricTelemetry, INotificationManager, IOTelApi, IOTelSpanOptions, IPageViewPerformanceTelemetry, IPageViewTelemetry, IPlugin, + IReadableSpan, IRequestHeaders, ISpanScope, ITelemetryContext as Common_ITelemetryContext, ITelemetryInitializerHandler, ITelemetryItem, + ITelemetryPlugin, ITelemetryUnloadState, IThrottleInterval, IThrottleLimit, IThrottleMgrConfig, ITraceApi, ITraceProvider, + ITraceTelemetry, IUnloadHook, OTelTimeInput, PropertiesPluginIdentifier, ThrottleMgr, UnloadHandler, WatcherFunction, + _eInternalMessageId, _throwInternal, addPageHideEventListener, addPageUnloadEventListener, cfgDfMerge, cfgDfValidate, + createDynamicConfig, createOTelApi, createProcessTelemetryContext, createTraceProvider, createUniqueNamespace, doPerf, eLoggingSeverity, + hasDocument, hasWindow, isArray, isFeatureEnabled, isFunction, isNullOrUndefined, isReactNative, isString, mergeEvtNamespace, + onConfigChange, parseConnectionString, proxyAssign, proxyFunctions, removePageHideEventListener, removePageUnloadEventListener, useSpan } from "@microsoft/applicationinsights-core-js"; import { AjaxPlugin as DependenciesPlugin, DependencyInitializerFunction, DependencyListenerFunction, IDependencyInitializerHandler, diff --git a/AISKU/src/IApplicationInsights.ts b/AISKU/src/IApplicationInsights.ts index 1979fdbe5..6d3cf4fc7 100644 --- a/AISKU/src/IApplicationInsights.ts +++ b/AISKU/src/IApplicationInsights.ts @@ -2,9 +2,9 @@ // Licensed under the MIT License. import { AnalyticsPlugin } from "@microsoft/applicationinsights-analytics-js"; import { Sender } from "@microsoft/applicationinsights-channel-js"; -import { IAppInsights, IPropertiesPlugin, IRequestHeaders } from "@microsoft/applicationinsights-common"; import { - IConfiguration, ILoadedPlugin, IOTelApi, IPlugin, ITelemetryPlugin, ITelemetryUnloadState, ITraceApi, ITraceHost, UnloadHandler + IAppInsights, IConfiguration, ILoadedPlugin, IOTelApi, IPlugin, IPropertiesPlugin, IRequestHeaders, ITelemetryPlugin, + ITelemetryUnloadState, ITraceApi, ITraceHost, UnloadHandler } from "@microsoft/applicationinsights-core-js"; import { IDependenciesPlugin } from "@microsoft/applicationinsights-dependencies-js"; import { IPromise } from "@nevware21/ts-async"; diff --git a/AISKU/src/Init.ts b/AISKU/src/Init.ts index 997c66408..a831b9a5e 100644 --- a/AISKU/src/Init.ts +++ b/AISKU/src/Init.ts @@ -44,7 +44,7 @@ export { PropertiesPluginIdentifier, BreezeChannelIdentifier, AnalyticsPluginIdentifier -} from "@microsoft/applicationinsights-common"; +} from "@microsoft/applicationinsights-core-js"; // ---------------------------------------------------------------------------------------------------- // End of Exports available from the Cdn bundles @@ -87,7 +87,7 @@ export { eSeverityLevel, IRequestHeaders, EventPersistence -} from "@microsoft/applicationinsights-common"; +} from "@microsoft/applicationinsights-core-js"; export { ISenderConfig } from "@microsoft/applicationinsights-channel-js"; diff --git a/AISKU/src/Snippet.ts b/AISKU/src/Snippet.ts index 79955c805..45456a546 100644 --- a/AISKU/src/Snippet.ts +++ b/AISKU/src/Snippet.ts @@ -2,8 +2,7 @@ // Licensed under the MIT License. "use strict"; -import { IConfig } from "@microsoft/applicationinsights-common"; -import { IConfiguration } from "@microsoft/applicationinsights-core-js"; +import { IConfig, IConfiguration } from "@microsoft/applicationinsights-core-js"; /** * diff --git a/AISKU/src/applicationinsights-web.ts b/AISKU/src/applicationinsights-web.ts index 09d0af761..a627bf6a2 100644 --- a/AISKU/src/applicationinsights-web.ts +++ b/AISKU/src/applicationinsights-web.ts @@ -61,7 +61,7 @@ export { DistributedTracingModes, IRequestHeaders, EventPersistence -} from "@microsoft/applicationinsights-common"; +} from "@microsoft/applicationinsights-core-js"; export { Sender, ISenderConfig } from "@microsoft/applicationinsights-channel-js"; export { ApplicationInsights as ApplicationAnalytics, IAppInsightsInternal, IAnalyticsConfig } from "@microsoft/applicationinsights-analytics-js"; export { PropertiesPlugin } from "@microsoft/applicationinsights-properties-js"; diff --git a/AISKU/src/internal/trace/spanUtils.ts b/AISKU/src/internal/trace/spanUtils.ts index d3dec33b1..9ba03d029 100644 --- a/AISKU/src/internal/trace/spanUtils.ts +++ b/AISKU/src/internal/trace/spanUtils.ts @@ -1,25 +1,23 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { - CtxTagKeys, IContextTagKeys, IDependencyTelemetry, IRequestTelemetry, RemoteDependencyDataType, RemoteDependencyEnvelopeType, - RequestDataType, RequestEnvelopeType, createTelemetryItem, urlGetPathName -} from "@microsoft/applicationinsights-common"; import { ATTR_CLIENT_ADDRESS, ATTR_CLIENT_PORT, ATTR_ENDUSER_ID, ATTR_ENDUSER_PSEUDO_ID, ATTR_ERROR_TYPE, ATTR_EXCEPTION_MESSAGE, ATTR_EXCEPTION_STACKTRACE, ATTR_EXCEPTION_TYPE, ATTR_HTTP_REQUEST_METHOD, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_HTTP_ROUTE, ATTR_NETWORK_LOCAL_ADDRESS, ATTR_NETWORK_LOCAL_PORT, ATTR_NETWORK_PEER_ADDRESS, ATTR_NETWORK_PEER_PORT, ATTR_NETWORK_PROTOCOL_NAME, ATTR_NETWORK_PROTOCOL_VERSION, ATTR_NETWORK_TRANSPORT, ATTR_SERVER_ADDRESS, ATTR_SERVER_PORT, ATTR_URL_FULL, ATTR_URL_PATH, - ATTR_URL_QUERY, ATTR_URL_SCHEME, ATTR_USER_AGENT_ORIGINAL, DBSYSTEMVALUES_MONGODB, DBSYSTEMVALUES_MYSQL, DBSYSTEMVALUES_POSTGRESQL, - DBSYSTEMVALUES_REDIS, EXP_ATTR_ENDUSER_ID, EXP_ATTR_ENDUSER_PSEUDO_ID, EXP_ATTR_SYNTHETIC_TYPE, IAppInsightsCore, IAttributeContainer, - IConfiguration, IReadableSpan, ITelemetryItem, MicrosoftClientIp, OTelAttributeValue, SEMATTRS_DB_NAME, SEMATTRS_DB_OPERATION, - SEMATTRS_DB_STATEMENT, SEMATTRS_DB_SYSTEM, SEMATTRS_ENDUSER_ID, SEMATTRS_EXCEPTION_MESSAGE, SEMATTRS_EXCEPTION_STACKTRACE, - SEMATTRS_EXCEPTION_TYPE, SEMATTRS_HTTP_CLIENT_IP, SEMATTRS_HTTP_FLAVOR, SEMATTRS_HTTP_HOST, SEMATTRS_HTTP_METHOD, SEMATTRS_HTTP_ROUTE, - SEMATTRS_HTTP_SCHEME, SEMATTRS_HTTP_STATUS_CODE, SEMATTRS_HTTP_TARGET, SEMATTRS_HTTP_URL, SEMATTRS_HTTP_USER_AGENT, SEMATTRS_NET_HOST_IP, - SEMATTRS_NET_HOST_NAME, SEMATTRS_NET_HOST_PORT, SEMATTRS_NET_PEER_IP, SEMATTRS_NET_PEER_NAME, SEMATTRS_NET_PEER_PORT, - SEMATTRS_NET_TRANSPORT, SEMATTRS_PEER_SERVICE, SEMATTRS_RPC_GRPC_STATUS_CODE, SEMATTRS_RPC_SYSTEM, Tags, createAttributeContainer, - eDependencyTypes, eOTelSpanKind, eOTelSpanStatusCode, fieldRedaction, getDependencyTarget, getHttpMethod, getHttpStatusCode, getHttpUrl, - getLocationIp, getUrl, getUserAgent, hrTimeToMilliseconds, isSqlDB, isSyntheticSource + ATTR_URL_QUERY, ATTR_URL_SCHEME, ATTR_USER_AGENT_ORIGINAL, CtxTagKeys, DBSYSTEMVALUES_MONGODB, DBSYSTEMVALUES_MYSQL, + DBSYSTEMVALUES_POSTGRESQL, DBSYSTEMVALUES_REDIS, EXP_ATTR_ENDUSER_ID, EXP_ATTR_ENDUSER_PSEUDO_ID, EXP_ATTR_SYNTHETIC_TYPE, + IAppInsightsCore, IAttributeContainer, IConfiguration, IContextTagKeys, IDependencyTelemetry, IReadableSpan, IRequestTelemetry, + ITelemetryItem, MicrosoftClientIp, OTelAttributeValue, RemoteDependencyDataType, RemoteDependencyEnvelopeType, RequestDataType, + RequestEnvelopeType, SEMATTRS_DB_NAME, SEMATTRS_DB_OPERATION, SEMATTRS_DB_STATEMENT, SEMATTRS_DB_SYSTEM, SEMATTRS_ENDUSER_ID, + SEMATTRS_EXCEPTION_MESSAGE, SEMATTRS_EXCEPTION_STACKTRACE, SEMATTRS_EXCEPTION_TYPE, SEMATTRS_HTTP_CLIENT_IP, SEMATTRS_HTTP_FLAVOR, + SEMATTRS_HTTP_HOST, SEMATTRS_HTTP_METHOD, SEMATTRS_HTTP_ROUTE, SEMATTRS_HTTP_SCHEME, SEMATTRS_HTTP_STATUS_CODE, SEMATTRS_HTTP_TARGET, + SEMATTRS_HTTP_URL, SEMATTRS_HTTP_USER_AGENT, SEMATTRS_NET_HOST_IP, SEMATTRS_NET_HOST_NAME, SEMATTRS_NET_HOST_PORT, SEMATTRS_NET_PEER_IP, + SEMATTRS_NET_PEER_NAME, SEMATTRS_NET_PEER_PORT, SEMATTRS_NET_TRANSPORT, SEMATTRS_PEER_SERVICE, SEMATTRS_RPC_GRPC_STATUS_CODE, + SEMATTRS_RPC_SYSTEM, Tags, createAttributeContainer, createTelemetryItem, eDependencyTypes, eOTelSpanKind, eOTelSpanStatusCode, + fieldRedaction, getDependencyTarget, getHttpMethod, getHttpStatusCode, getHttpUrl, getLocationIp, getUrl, getUserAgent, + hrTimeToMilliseconds, isSqlDB, isSyntheticSource, urlGetPathName } from "@microsoft/applicationinsights-core-js"; import { ILazyValue, arrIncludes, asString, getLazy, isNullOrUndefined, strLower, strStartsWith } from "@nevware21/ts-utils"; import { STR_EMPTY, UNDEFINED_VALUE } from "../../InternalConstants"; diff --git a/AISKULight/Tests/Unit/src/config.tests.ts b/AISKULight/Tests/Unit/src/config.tests.ts index e234d8ff1..2cd6c46e5 100644 --- a/AISKULight/Tests/Unit/src/config.tests.ts +++ b/AISKULight/Tests/Unit/src/config.tests.ts @@ -1,7 +1,7 @@ import { AITestClass, Assert, PollingAssert } from "@microsoft/ai-test-framework"; import { ITelemetryItem, newId } from "@microsoft/applicationinsights-core-js"; import { ApplicationInsights} from "../../../src/index"; -import { BreezeChannelIdentifier, ContextTagKeys, utlRemoveSessionStorage } from "@microsoft/applicationinsights-common"; +import { BreezeChannelIdentifier, ContextTagKeys, utlRemoveSessionStorage } from "@microsoft/applicationinsights-core-js"; import { Sender } from "@microsoft/applicationinsights-channel-js"; export class ApplicationInsightsConfigTests extends AITestClass { diff --git a/AISKULight/Tests/Unit/src/dynamicconfig.tests.ts b/AISKULight/Tests/Unit/src/dynamicconfig.tests.ts index 6bfc1e34b..1405c691c 100644 --- a/AISKULight/Tests/Unit/src/dynamicconfig.tests.ts +++ b/AISKULight/Tests/Unit/src/dynamicconfig.tests.ts @@ -1,5 +1,5 @@ import { AITestClass, Assert, PollingAssert } from "@microsoft/ai-test-framework"; -import { IConfig } from "@microsoft/applicationinsights-common"; +import { IConfig } from "@microsoft/applicationinsights-core-js"; import { IConfiguration, IPayloadData, isString, ITelemetryItem, IXHROverride, newId } from "@microsoft/applicationinsights-core-js"; import { ApplicationInsights, ISenderConfig } from "../../../src/index"; import { createAsyncResolvedPromise } from "@nevware21/ts-async"; diff --git a/AISKULight/Tests/Unit/src/otelNegative.tests.ts b/AISKULight/Tests/Unit/src/otelNegative.tests.ts index a02a630cc..f8fc5780e 100644 --- a/AISKULight/Tests/Unit/src/otelNegative.tests.ts +++ b/AISKULight/Tests/Unit/src/otelNegative.tests.ts @@ -3,7 +3,7 @@ import { AITestClass, Assert } from "@microsoft/ai-test-framework"; import { ApplicationInsights } from "../../../src/index"; -import { utlRemoveSessionStorage } from "@microsoft/applicationinsights-common"; +import { utlRemoveSessionStorage } from "@microsoft/applicationinsights-core-js"; import { isNullOrUndefined, newId } from "@microsoft/applicationinsights-core-js"; /** diff --git a/AISKULight/package.json b/AISKULight/package.json index 2e0ce87b9..c9f6acea2 100644 --- a/AISKULight/package.json +++ b/AISKULight/package.json @@ -58,7 +58,6 @@ "dependencies": { "@microsoft/dynamicproto-js": "^2.0.3", "@microsoft/applicationinsights-shims": "3.0.1", - "@microsoft/applicationinsights-common": "3.3.11", "@microsoft/applicationinsights-channel-js": "3.3.11", "@microsoft/applicationinsights-core-js": "3.3.11", "@nevware21/ts-utils": ">= 0.11.8 < 2.x", diff --git a/AISKULight/src/index.ts b/AISKULight/src/index.ts index d74ad083f..d0084634c 100644 --- a/AISKULight/src/index.ts +++ b/AISKULight/src/index.ts @@ -3,11 +3,10 @@ import dynamicProto from "@microsoft/dynamicproto-js"; import { Sender } from "@microsoft/applicationinsights-channel-js"; -import { DEFAULT_BREEZE_PATH, IConfig, parseConnectionString } from "@microsoft/applicationinsights-common"; import { - AppInsightsCore, FeatureOptInMode, IConfigDefaults, IConfiguration, IDistributedTraceContext, IDynamicConfigHandler, ILoadedPlugin, - IPlugin, ITelemetryInitializerHandler, ITelemetryItem, ITelemetryPlugin, ITelemetryUnloadState, IUnloadHook, UnloadHandler, - WatcherFunction, cfgDfValidate, createDynamicConfig, onConfigChange, proxyFunctions + AppInsightsCore, DEFAULT_BREEZE_PATH, FeatureOptInMode, IConfig, IConfigDefaults, IConfiguration, IDistributedTraceContext, + IDynamicConfigHandler, ILoadedPlugin, IPlugin, ITelemetryInitializerHandler, ITelemetryItem, ITelemetryPlugin, ITelemetryUnloadState, + IUnloadHook, UnloadHandler, WatcherFunction, cfgDfValidate, createDynamicConfig, onConfigChange, parseConnectionString, proxyFunctions } from "@microsoft/applicationinsights-core-js"; import { IPromise, createSyncPromise, doAwaitResponse } from "@nevware21/ts-async"; import { isNullOrUndefined, isPromiseLike, isString, objDefine, throwError } from "@nevware21/ts-utils"; @@ -297,5 +296,5 @@ export { IPageViewPerformanceTelemetry, ITraceTelemetry, IRequestTelemetry -} from "@microsoft/applicationinsights-common"; +} from "@microsoft/applicationinsights-core-js"; export { Sender, ISenderConfig } from "@microsoft/applicationinsights-channel-js"; diff --git a/MOVE_LAYOUT_PLAN.md b/MOVE_LAYOUT_PLAN.md new file mode 100644 index 000000000..e091701bd --- /dev/null +++ b/MOVE_LAYOUT_PLAN.md @@ -0,0 +1,1438 @@ +# Move Layout Plan: AppInsightsCore → otel-core Structure + +This document outlines the file reorganization plan to align the MSNev2/AppInsightsCore structure with the MSNev3/otel-core layout. Follow the steps in order to complete the migration. + +--- + +## Prerequisites + +> **Required:** The [`MergeCommonToCore-Plan.md`](MergeCommonToCore-Plan.md) must be completed before executing this plan. +> +> This plan assumes: +> - The `src/Common/` folder exists (created by the MergeCommon plan) +> - All internal packages already import from `@microsoft/applicationinsights-core-js` +> - The AppInsightsCommon package is configured as a re-export layer +> +> See [Execution Order](MergeCommonToCore-Plan.md#execution-order) for the complete restructure sequence. + +--- + +## Critical Requirements + +### 1. Git History Preservation +**ALL file moves MUST use `git mv` to preserve file history.** + +```powershell +# CORRECT - preserves history +git mv "src/JavaScriptSDK/CoreUtils.ts" "src/utils/CoreUtils.ts" + +# INCORRECT - loses history (DO NOT USE) +Move-Item "src/JavaScriptSDK/CoreUtils.ts" "src/utils/CoreUtils.ts" +``` + +### 2. Import Path Updates +After each batch of file moves, ALL import statements must be updated immediately. The repo must remain buildable after every phase. + +### 3. BANNED: Deep Path Imports +**NEVER** use imports that reference internal source paths: +```typescript +// ❌ BANNED - Deep path imports into src/ folder structure +import { IDistributedTraceInit } from "@microsoft/applicationinsights-core-js/src/JavaScriptSDK.Interfaces/IDistributedTraceContext"; +import { IAppInsightsCore } from "@microsoft/applicationinsights-core-js/src/applicationinsights-core-js"; + +// ✅ CORRECT - Import from package public API +import { IDistributedTraceInit, IAppInsightsCore } from "@microsoft/applicationinsights-core-js"; +``` + +All public types/interfaces MUST be exported from the package's main entry point. + +### 4. BANNED: Internal index.ts Imports +**NEVER** import from index.ts files within the same project. Always import directly from the source file. + +The **ONLY** index.ts file that should exist is in the project root (`src/index.ts`). Do not create index.ts files in subdirectories. + +```typescript +// ❌ BANNED - Importing from index.ts within the same project +import { CoreUtils } from "./utils/index"; +import { DiagnosticLogger } from "../diagnostics/index"; +import { IConfiguration } from "./interfaces/ai/index"; + +// ✅ CORRECT - Import directly from the source file +import { CoreUtils } from "./utils/CoreUtils"; +import { DiagnosticLogger } from "../diagnostics/DiagnosticLogger"; +import { IConfiguration } from "./interfaces/ai/IConfiguration"; +``` + +**Rationale:** +- Prevents circular dependency issues +- Makes dependencies explicit and traceable +- Improves tree-shaking effectiveness +- Only the root `src/index.ts` should aggregate exports for the public API + +### 5. Rush Update Before Building +**This is a Rush-based monorepo.** After making changes to file structures, imports, or dependencies, you MUST run Rush update before attempting to build: + +```powershell +# Required before building after structural changes +rush update --recheck --full + +# If you encounter dependency issues, use the more aggressive purge option: +rush update --recheck --purge --full +``` + +**When to run Rush update:** +- After moving source files and updating import paths +- After moving test files +- After modifying package.json dependencies +- Before any `npx grunt` build commands + +### 6. Plan Documents Must NOT Be Committed +**The following plan documents are for execution guidance only and MUST NOT be committed as part of the migration:** + +- `shared/AppInsightsCore/MOVE_LAYOUT_PLAN.md` (this document) +- `MergeCommonToCore-Plan.md` (root-level merge plan) + +These documents contain internal planning details and should be deleted or kept locally after the migration is complete. Do not include them in any pull requests or commits related to the restructure. + +--- + +## Build Pipeline Configuration + +### Critical: Browser Output Name Must NOT Change +The browser bundle output name **MUST remain `applicationinsights-core-js`** regardless of the internal entry point renaming. This is essential for backward compatibility with consuming applications. + +### rollup.config.js (shared/AppInsightsCore/rollup.config.js) +The rollup configuration separates the internal entry point from the output name: + +```javascript +// OLD: +const entryPointName = "applicationinsights-core-js"; +// ... +export default createUnVersionedConfig(banner, + { + namespace: "Microsoft.ApplicationInsights", + version: version, + node: { + entryPoint: entryPointName, + outputName: entryPointName + }, + browser: { + entryPoint: entryPointName, + outputName: entryPointName + }, + }, + [ "applicationinsights-core-js" ], + false +); + +// NEW: +const entryPointName = "index"; +const browserOutputName = "applicationinsights-core-js"; // MUST NOT CHANGE +// ... +export default createUnVersionedConfig(banner, + { + namespace: "Microsoft.ApplicationInsights", + version: version, + node: { + entryPoint: entryPointName, + outputName: entryPointName // Node output uses index + }, + browser: { + entryPoint: entryPointName, + outputName: browserOutputName // Browser keeps original name + } + }, + ["index"], + false +); +``` + +**Key Points:** +- `entryPointName = "index"` - Points to the renamed `src/index.ts` +- `browserOutputName = "applicationinsights-core-js"` - **NEVER change this** +- Node output uses `index` (acceptable for npm package consumers) +- Browser output uses `applicationinsights-core-js` (CDN compatibility) + +### api-extractor.json (shared/AppInsightsCore/api-extractor.json) +The API extractor configuration points to the generated type definitions: + +```json +// OLD: +"mainEntryPointFilePath": "/build/types/applicationinsights-core-js.d.ts" + +// NEW: +"mainEntryPointFilePath": "/build/types/index.d.ts" +``` + +This references `index.d.ts` (generated from `index.ts`) which is correct after the rename. + +### Root gruntfile.js +The grunt configuration requires THREE changes: + +#### 1. Update InternalConstants Path (line ~295) +```javascript +if (pkg['name'] === "@microsoft/applicationinsights-core-js") { + nameMaps = aiCoreDefaultNameReplacements; + // OLD: internalConstants = [ "./src/JavaScriptSDK/InternalConstants.ts" ]; + internalConstants = [ "./src/constants/InternalConstants.ts" ]; // NEW +} +``` + +#### 2. Remove unitTestName from AppInsightsCommon Config (line ~482) +```javascript +// OLD: +"common": { + path: "./shared/AppInsightsCommon", + unitTestName: "aicommon.tests.js" + }, + +// NEW - Remove unitTestName (tests moved to AppInsightsCore): +"common": { + path: "./shared/AppInsightsCommon" + }, +``` + +#### 3. Disable commontest Tasks (lines ~861-862) +```javascript +// OLD: +grunt.registerTask("commontest", tsTestActions("common")); +grunt.registerTask("common-mintest", tsTestActions("common", true)); + +// NEW - Empty arrays (tests are now in AppInsightsCore): +grunt.registerTask("commontest", []); +grunt.registerTask("common-mintest", []); +``` + +### Build Outputs After Migration +After the entry point rename, the build outputs should be: + +| Output Type | File Name | Notes | +|-------------|-----------|-------| +| Browser Bundle | `applicationinsights-core-js.js` | **UNCHANGED** - CDN compatibility | +| Browser Bundle (min) | `applicationinsights-core-js.min.js` | **UNCHANGED** | +| Node Entry | `index.js` | Entry point for npm consumers | +| Type Definitions | `applicationinsights-core-js.d.ts` | Generated by api-extractor | + +--- + +## Source Structure Changes + +### Previous Structure (`src/`) +``` +├── applicationinsights-core-js.ts +├── __DynamicConstants.ts +├── Config/ +├── Common/ +│ ├── Interfaces/ +│ │ ├── Context/ +│ │ ├── Contracts/ +│ │ └── Telemetry/ +│ └── Telemetry/ +│ └── Common/ +├── JavaScriptSDK/ +├── JavaScriptSDK.Enums/ +├── JavaScriptSDK.Interfaces/ +└── OpenTelemetry/ + ├── attribute/ + ├── enums/ + ├── errors/ + ├── helpers/ + ├── interfaces/ + ├── noop/ + └── trace/ +``` + +### New Structure (`src/`) +``` +├── index.ts +├── __DynamicConstants.ts +├── config/ +├── constants/ +├── core/ +├── diagnostics/ +├── enums/ +│ ├── ai/ +│ └── otel/ +├── interfaces/ +│ ├── ai/ +│ │ ├── context/ +│ │ ├── contracts/ +│ │ └── telemetry/ +│ ├── config/ +│ └── otel/ +│ ├── attribute/ +│ ├── config/ +│ └── trace/ +├── internal/ +├── otel/ +│ ├── api/ +│ │ ├── errors/ +│ │ └── trace/ +│ └── attribute/ +├── telemetry/ +│ └── ai/ +│ └── Common/ +└── utils/ +``` + +--- + +## Source File Move Tables + +### Entry Point +| Source | Target | +|--------|--------| +| `applicationinsights-core-js.ts` | `index.ts` | + +### Config (`Config/` → `config/` + `interfaces/config/`) +| Source | Target | +|--------|--------| +| `Config/ConfigDefaultHelpers.ts` | `config/ConfigDefaultHelpers.ts` | +| `Config/ConfigDefaults.ts` | `config/ConfigDefaults.ts` | +| `Config/DynamicConfig.ts` | `config/DynamicConfig.ts` | +| `Config/DynamicProperty.ts` | `config/DynamicProperty.ts` | +| `Config/DynamicState.ts` | `config/DynamicState.ts` | +| `Config/DynamicSupport.ts` | `config/DynamicSupport.ts` | +| `Config/IDynamicWatcher.ts` | `config/IDynamicWatcher.ts` | +| `Config/IConfigDefaults.ts` | `interfaces/config/IConfigDefaults.ts` | +| `Config/IDynamicConfigHandler.ts` | `interfaces/config/IDynamicConfigHandler.ts` | +| `Config/IDynamicPropertyHandler.ts` | `interfaces/config/IDynamicPropertyHandler.ts` | +| `Config/_IDynamicConfigHandlerState.ts` | `interfaces/config/_IDynamicConfigHandlerState.ts` | + +### JavaScriptSDK → core/ +| Source | Target | +|--------|--------| +| `JavaScriptSDK/AggregationError.ts` | `core/AggregationError.ts` | +| `JavaScriptSDK/AppInsightsCore.ts` | `core/AppInsightsCore.ts` | +| `JavaScriptSDK/AsyncUtils.ts` | `core/AsyncUtils.ts` | +| `JavaScriptSDK/BaseTelemetryPlugin.ts` | `core/BaseTelemetryPlugin.ts` | +| `JavaScriptSDK/CookieMgr.ts` | `core/CookieMgr.ts` | +| `JavaScriptSDK/DbgExtensionUtils.ts` | `core/DbgExtensionUtils.ts` | +| `JavaScriptSDK/InstrumentHooks.ts` | `core/InstrumentHooks.ts` | +| `JavaScriptSDK/NotificationManager.ts` | `core/NotificationManager.ts` | +| `JavaScriptSDK/PerfManager.ts` | `core/PerfManager.ts` | +| `JavaScriptSDK/ProcessTelemetryContext.ts` | `core/ProcessTelemetryContext.ts` | +| `JavaScriptSDK/ResponseHelpers.ts` | `core/ResponseHelpers.ts` | +| `JavaScriptSDK/SenderPostManager.ts` | `core/SenderPostManager.ts` | +| `JavaScriptSDK/StatsBeat.ts` | `core/StatsBeat.ts` | +| `JavaScriptSDK/TelemetryHelpers.ts` | `core/TelemetryHelpers.ts` | +| `JavaScriptSDK/TelemetryInitializerPlugin.ts` | `core/TelemetryInitializerPlugin.ts` | +| `JavaScriptSDK/UnloadHandlerContainer.ts` | `core/UnloadHandlerContainer.ts` | +| `JavaScriptSDK/UnloadHookContainer.ts` | `core/UnloadHookContainer.ts` | + +### JavaScriptSDK → utils/ +| Source | Target | +|--------|--------| +| `JavaScriptSDK/CoreUtils.ts` | `utils/CoreUtils.ts` | +| `JavaScriptSDK/DataCacheHelper.ts` | `utils/DataCacheHelper.ts` | +| `JavaScriptSDK/EnvUtils.ts` | `utils/EnvUtils.ts` | +| `JavaScriptSDK/HelperFuncs.ts` | `utils/HelperFuncs.ts` | +| `JavaScriptSDK/RandomHelper.ts` | `utils/RandomHelper.ts` | +| `JavaScriptSDK/W3cTraceParent.ts` | `utils/TraceParent.ts` | + +### JavaScriptSDK → constants/ +| Source | Target | +|--------|--------| +| `JavaScriptSDK/Constants.ts` | `constants/Constants.ts` | +| `JavaScriptSDK/InternalConstants.ts` | `constants/InternalConstants.ts` | + +### JavaScriptSDK → diagnostics/ +| Source | Target | +|--------|--------| +| `JavaScriptSDK/DiagnosticLogger.ts` | `diagnostics/DiagnosticLogger.ts` | + +### JavaScriptSDK → internal/ +| Source | Target | +|--------|--------| +| `JavaScriptSDK/EventHelpers.ts` | `internal/EventHelpers.ts` | + +### JavaScriptSDK → telemetry/ +| Source | Target | +|--------|--------| +| `JavaScriptSDK/W3cTraceState.ts` | `telemetry/W3cTraceState.ts` | + +### JavaScriptSDK.Enums → enums/ +| Source | Target | +|--------|--------| +| `JavaScriptSDK.Enums/EnumHelperFuncs.ts` | `enums/EnumHelperFuncs.ts` | +| `JavaScriptSDK.Enums/W3CTraceFlags.ts` | `enums/W3CTraceFlags.ts` | + +### JavaScriptSDK.Enums → enums/ai/ +| Source | Target | +|--------|--------| +| `JavaScriptSDK.Enums/DependencyTypes.ts` | `enums/ai/DependencyTypes.ts` | +| `JavaScriptSDK.Enums/EventsDiscardedReason.ts` | `enums/ai/EventsDiscardedReason.ts` | +| `JavaScriptSDK.Enums/FeatureOptInEnums.ts` | `enums/ai/FeatureOptInEnums.ts` | +| `JavaScriptSDK.Enums/InitActiveStatusEnum.ts` | `enums/ai/InitActiveStatusEnum.ts` | +| `JavaScriptSDK.Enums/LoggingEnums.ts` | `enums/ai/LoggingEnums.ts` | +| `JavaScriptSDK.Enums/SendRequestReason.ts` | `enums/ai/SendRequestReason.ts` | +| `JavaScriptSDK.Enums/StatsType.ts` | `enums/ai/StatsType.ts` | +| `JavaScriptSDK.Enums/TelemetryUnloadReason.ts` | `enums/ai/TelemetryUnloadReason.ts` | +| `JavaScriptSDK.Enums/TelemetryUpdateReason.ts` | `enums/ai/TelemetryUpdateReason.ts` | +| `JavaScriptSDK.Enums/TraceHeadersMode.ts` | `enums/ai/TraceHeadersMode.ts` | + +### JavaScriptSDK.Interfaces → interfaces/ai/ +| Source | Target | +|--------|--------| +| `JavaScriptSDK.Interfaces/IAppInsightsCore.ts` | `interfaces/ai/IAppInsightsCore.ts` | +| `JavaScriptSDK.Interfaces/IChannelControls.ts` | `interfaces/ai/IChannelControls.ts` | +| `JavaScriptSDK.Interfaces/IChannelControlsHost.ts` | `interfaces/ai/IChannelControlsHost.ts` | +| `JavaScriptSDK.Interfaces/IConfiguration.ts` | `interfaces/ai/IConfiguration.ts` | +| `JavaScriptSDK.Interfaces/ICookieMgr.ts` | `interfaces/ai/ICookieMgr.ts` | +| `JavaScriptSDK.Interfaces/IDbgExtension.ts` | `interfaces/ai/IDbgExtension.ts` | +| `JavaScriptSDK.Interfaces/IDiagnosticLogger.ts` | `interfaces/ai/IDiagnosticLogger.ts` | +| `JavaScriptSDK.Interfaces/IDistributedTraceContext.ts` | `interfaces/ai/IDistributedTraceContext.ts` | +| `JavaScriptSDK.Interfaces/IExceptionConfig.ts` | `interfaces/ai/IExceptionConfig.ts` | +| `JavaScriptSDK.Interfaces/IFeatureOptIn.ts` | `interfaces/ai/IFeatureOptIn.ts` | +| `JavaScriptSDK.Interfaces/IInstrumentHooks.ts` | `interfaces/ai/IInstrumentHooks.ts` | +| `JavaScriptSDK.Interfaces/INetworkStatsbeat.ts` | `interfaces/ai/INetworkStatsbeat.ts` | +| `JavaScriptSDK.Interfaces/INotificationListener.ts` | `interfaces/ai/INotificationListener.ts` | +| `JavaScriptSDK.Interfaces/INotificationManager.ts` | `interfaces/ai/INotificationManager.ts` | +| `JavaScriptSDK.Interfaces/IPerfEvent.ts` | `interfaces/ai/IPerfEvent.ts` | +| `JavaScriptSDK.Interfaces/IPerfManager.ts` | `interfaces/ai/IPerfManager.ts` | +| `JavaScriptSDK.Interfaces/IProcessTelemetryContext.ts` | `interfaces/ai/IProcessTelemetryContext.ts` | +| `JavaScriptSDK.Interfaces/ISenderPostManager.ts` | `interfaces/ai/ISenderPostManager.ts` | +| `JavaScriptSDK.Interfaces/IStatsBeat.ts` | `interfaces/ai/IStatsBeat.ts` | +| `JavaScriptSDK.Interfaces/IStatsEventData.ts` | `interfaces/ai/IStatsEventData.ts` | +| `JavaScriptSDK.Interfaces/IStatsMgr.ts` | `interfaces/ai/IStatsMgr.ts` | +| `JavaScriptSDK.Interfaces/ITelemetryInitializers.ts` | `interfaces/ai/ITelemetryInitializers.ts` | +| `JavaScriptSDK.Interfaces/ITelemetryItem.ts` | `interfaces/ai/ITelemetryItem.ts` | +| `JavaScriptSDK.Interfaces/ITelemetryPlugin.ts` | `interfaces/ai/ITelemetryPlugin.ts` | +| `JavaScriptSDK.Interfaces/ITelemetryPluginChain.ts` | `interfaces/ai/ITelemetryPluginChain.ts` | +| `JavaScriptSDK.Interfaces/ITelemetryUnloadState.ts` | `interfaces/ai/ITelemetryUnloadState.ts` | +| `JavaScriptSDK.Interfaces/ITelemetryUpdateState.ts` | `interfaces/ai/ITelemetryUpdateState.ts` | +| `JavaScriptSDK.Interfaces/ITraceParent.ts` | `interfaces/ai/ITraceParent.ts` | +| `JavaScriptSDK.Interfaces/ITraceProvider.ts` | `interfaces/ai/ITraceProvider.ts` | +| `JavaScriptSDK.Interfaces/IUnloadableComponent.ts` | `interfaces/ai/IUnloadableComponent.ts` | +| `JavaScriptSDK.Interfaces/IUnloadHook.ts` | `interfaces/ai/IUnloadHook.ts` | +| `JavaScriptSDK.Interfaces/IW3cTraceState.ts` | `interfaces/ai/IW3cTraceState.ts` | +| `JavaScriptSDK.Interfaces/IXDomainRequest.ts` | `interfaces/ai/IXDomainRequest.ts` | +| `JavaScriptSDK.Interfaces/IXHROverride.ts` | `interfaces/ai/IXHROverride.ts` | + +### Common/ Root Files +| Source | Target | +|--------|--------| +| `Common/ConnectionStringParser.ts` | `telemetry/ConnectionStringParser.ts` | +| `Common/Constants.ts` | `constants/CoreInternalConstants.ts` | +| `Common/DomHelperFuncs.ts` | `utils/DomHelperFuncs.ts` | +| `Common/Enums.ts` | `enums/ai/Enums.ts` | +| `Common/HelperFuncs.ts` | `utils/HelperFuncsCore.ts` | +| `Common/Offline.ts` | `utils/Offline.ts` | +| `Common/RequestResponseHeaders.ts` | `telemetry/RequestResponseHeaders.ts` | +| `Common/StorageHelperFuncs.ts` | `utils/StorageHelperFuncs.ts` | +| `Common/TelemetryItemCreator.ts` | `telemetry/TelemetryItemCreator.ts` | +| `Common/ThrottleMgr.ts` | `diagnostics/ThrottleMgr.ts` | +| `Common/UrlHelperFuncs.ts` | `utils/UrlHelperFuncs.ts` | +| `Common/Util.ts` | `utils/Util.ts` | + +### Common/Interfaces → interfaces/ai/ +| Source | Target | +|--------|--------| +| `Common/Interfaces/ConnectionString.ts` | `interfaces/ai/ConnectionString.ts` | +| `Common/Interfaces/IAppInsights.ts` | `interfaces/ai/IAppInsights.ts` | +| `Common/Interfaces/IConfig.ts` | `interfaces/ai/IConfig.ts` | +| `Common/Interfaces/ICorrelationConfig.ts` | `interfaces/ai/ICorrelationConfig.ts` | +| `Common/Interfaces/IDependencyTelemetry.ts` | `interfaces/ai/IDependencyTelemetry.ts` | +| `Common/Interfaces/IEventTelemetry.ts` | `interfaces/ai/IEventTelemetry.ts` | +| `Common/Interfaces/IExceptionTelemetry.ts` | `interfaces/ai/IExceptionTelemetry.ts` | +| `Common/Interfaces/IMetricTelemetry.ts` | `interfaces/ai/IMetricTelemetry.ts` | +| `Common/Interfaces/IPageViewPerformanceTelemetry.ts` | `interfaces/ai/IPageViewPerformanceTelemetry.ts` | +| `Common/Interfaces/IPageViewTelemetry.ts` | `interfaces/ai/IPageViewTelemetry.ts` | +| `Common/Interfaces/IPartC.ts` | `interfaces/ai/IPartC.ts` | +| `Common/Interfaces/IPropertiesPlugin.ts` | `interfaces/ai/IPropertiesPlugin.ts` | +| `Common/Interfaces/IRequestContext.ts` | `interfaces/ai/IRequestContext.ts` | +| `Common/Interfaces/IRequestTelemetry.ts` | `interfaces/ai/IRequestTelemetry.ts` | +| `Common/Interfaces/IStorageBuffer.ts` | `interfaces/ai/IStorageBuffer.ts` | +| `Common/Interfaces/ITelemetryContext.ts` | `interfaces/ai/ITelemetryContext.ts` | +| `Common/Interfaces/IThrottleMgr.ts` | `interfaces/ai/IThrottleMgr.ts` | +| `Common/Interfaces/ITraceTelemetry.ts` | `interfaces/ai/ITraceTelemetry.ts` | +| `Common/Interfaces/PartAExtensions.ts` | `interfaces/ai/PartAExtensions.ts` | + +### Common/Interfaces/Context → interfaces/ai/context/ +| Source | Target | +|--------|--------| +| `Common/Interfaces/Context/IApplication.ts` | `interfaces/ai/context/IApplication.ts` | +| `Common/Interfaces/Context/IDevice.ts` | `interfaces/ai/context/IDevice.ts` | +| `Common/Interfaces/Context/IInternal.ts` | `interfaces/ai/context/IInternal.ts` | +| `Common/Interfaces/Context/ILocation.ts` | `interfaces/ai/context/ILocation.ts` | +| `Common/Interfaces/Context/IOperatingSystem.ts` | `interfaces/ai/context/IOperatingSystem.ts` | +| `Common/Interfaces/Context/ISample.ts` | `interfaces/ai/context/ISample.ts` | +| `Common/Interfaces/Context/ISession.ts` | `interfaces/ai/context/ISession.ts` | +| `Common/Interfaces/Context/ISessionManager.ts` | `interfaces/ai/context/ISessionManager.ts` | +| `Common/Interfaces/Context/ITelemetryTrace.ts` | `interfaces/ai/context/ITelemetryTrace.ts` | +| `Common/Interfaces/Context/IUser.ts` | `interfaces/ai/context/IUser.ts` | +| `Common/Interfaces/Context/IWeb.ts` | `interfaces/ai/context/IWeb.ts` | + +### Common/Interfaces/Contracts → interfaces/ai/contracts/ +| Source | Target | +|--------|--------| +| `Common/Interfaces/Contracts/AvailabilityData.ts` | `interfaces/ai/contracts/AvailabilityData.ts` | +| `Common/Interfaces/Contracts/ContextTagKeys.ts` | `interfaces/ai/contracts/ContextTagKeys.ts` | +| `Common/Interfaces/Contracts/DataPointType.ts` | `interfaces/ai/contracts/DataPointType.ts` | +| `Common/Interfaces/Contracts/DependencyKind.ts` | `interfaces/ai/contracts/DependencyKind.ts` | +| `Common/Interfaces/Contracts/DependencySourceType.ts` | `interfaces/ai/contracts/DependencySourceType.ts` | +| `Common/Interfaces/Contracts/IBase.ts` | `interfaces/ai/contracts/IBase.ts` | +| `Common/Interfaces/Contracts/IData.ts` | `interfaces/ai/contracts/IData.ts` | +| `Common/Interfaces/Contracts/IDataPoint.ts` | `interfaces/ai/contracts/IDataPoint.ts` | +| `Common/Interfaces/Contracts/IDomain.ts` | `interfaces/ai/contracts/IDomain.ts` | +| `Common/Interfaces/Contracts/IEnvelope.ts` | `interfaces/ai/contracts/IEnvelope.ts` | +| `Common/Interfaces/Contracts/IEventData.ts` | `interfaces/ai/contracts/IEventData.ts` | +| `Common/Interfaces/Contracts/IExceptionData.ts` | `interfaces/ai/contracts/IExceptionData.ts` | +| `Common/Interfaces/Contracts/IExceptionDetails.ts` | `interfaces/ai/contracts/IExceptionDetails.ts` | +| `Common/Interfaces/Contracts/IMessageData.ts` | `interfaces/ai/contracts/IMessageData.ts` | +| `Common/Interfaces/Contracts/IMetricData.ts` | `interfaces/ai/contracts/IMetricData.ts` | +| `Common/Interfaces/Contracts/IPageViewData.ts` | `interfaces/ai/contracts/IPageViewData.ts` | +| `Common/Interfaces/Contracts/IPageViewPerfData.ts` | `interfaces/ai/contracts/IPageViewPerfData.ts` | +| `Common/Interfaces/Contracts/IRemoteDependencyData.ts` | `interfaces/ai/contracts/IRemoteDependencyData.ts` | +| `Common/Interfaces/Contracts/IStackFrame.ts` | `interfaces/ai/contracts/IStackFrame.ts` | +| `Common/Interfaces/Contracts/SeverityLevel.ts` | `interfaces/ai/contracts/SeverityLevel.ts` | + +### Common/Interfaces/Telemetry → interfaces/ai/telemetry/ +| Source | Target | +|--------|--------| +| `Common/Interfaces/Telemetry/IEnvelope.ts` | `interfaces/ai/telemetry/IEnvelope.ts` | +| `Common/Interfaces/Telemetry/ISerializable.ts` | `interfaces/ai/telemetry/ISerializable.ts` | + +### Common/Telemetry → telemetry/ai/ +| Source | Target | +|--------|--------| +| `Common/Telemetry/DataTypes.ts` | `telemetry/ai/DataTypes.ts` | +| `Common/Telemetry/EnvelopeTypes.ts` | `telemetry/ai/EnvelopeTypes.ts` | +| `Common/Telemetry/Event.ts` | `telemetry/ai/Event.ts` | +| `Common/Telemetry/Exception.ts` | `telemetry/ai/Exception.ts` | +| `Common/Telemetry/Metric.ts` | `telemetry/ai/Metric.ts` | +| `Common/Telemetry/PageView.ts` | `telemetry/ai/PageView.ts` | +| `Common/Telemetry/PageViewPerformance.ts` | `telemetry/ai/PageViewPerformance.ts` | +| `Common/Telemetry/RemoteDependencyData.ts` | `telemetry/ai/RemoteDependencyData.ts` | +| `Common/Telemetry/Trace.ts` | `telemetry/ai/Trace.ts` | + +### Common/Telemetry/Common → telemetry/ai/Common/ +| Source | Target | +|--------|--------| +| `Common/Telemetry/Common/Data.ts` | `telemetry/ai/Common/Data.ts` | +| `Common/Telemetry/Common/DataPoint.ts` | `telemetry/ai/Common/DataPoint.ts` | +| `Common/Telemetry/Common/DataSanitizer.ts` | `telemetry/ai/Common/DataSanitizer.ts` | +| `Common/Telemetry/Common/Envelope.ts` | `telemetry/ai/Common/Envelope.ts` | + +### OpenTelemetry → otel/api/ +| Source | Target | +|--------|--------| +| `OpenTelemetry/otelApi.ts` | `otel/api/OTelApi.ts` | + +### OpenTelemetry/attribute → otel/attribute/ +| Source | Target | +|--------|--------| +| `OpenTelemetry/attribute/attributeContainer.ts` | `otel/attribute/attributeContainer.ts` | +| `OpenTelemetry/attribute/SemanticConventions.ts` | `otel/attribute/SemanticConventions.ts` | +| `OpenTelemetry/attribute/IAttributeContainer.ts` | `interfaces/otel/attribute/IAttributeContainer.ts` | + +### OpenTelemetry/enums → enums/otel/ +| Source | Target | +|--------|--------| +| `OpenTelemetry/enums/eAttributeChangeOp.ts` | `enums/otel/eAttributeChangeOp.ts` | +| `OpenTelemetry/enums/trace/OTelSamplingDecision.ts` | `enums/otel/OTelSamplingDecision.ts` | +| `OpenTelemetry/enums/trace/OTelSpanKind.ts` | `enums/otel/OTelSpanKind.ts` | +| `OpenTelemetry/enums/trace/OTelSpanStatus.ts` | `enums/otel/OTelSpanStatus.ts` | + +### OpenTelemetry/errors → otel/api/errors/ +| Source | Target | +|--------|--------| +| `OpenTelemetry/errors/OTelError.ts` | `otel/api/errors/OTelError.ts` | +| `OpenTelemetry/errors/OTelInvalidAttributeError.ts` | `otel/api/errors/OTelInvalidAttributeError.ts` | +| `OpenTelemetry/errors/OTelSpanError.ts` | `otel/api/errors/OTelSpanError.ts` | + +### OpenTelemetry/helpers → internal/ +| Source | Target | +|--------|--------| +| `OpenTelemetry/helpers/attributeHelpers.ts` | `internal/attributeHelpers.ts` | +| `OpenTelemetry/helpers/common.ts` | `internal/commonUtils.ts` | +| `OpenTelemetry/helpers/handleErrors.ts` | `internal/handleErrors.ts` | +| `OpenTelemetry/helpers/timeHelpers.ts` | `internal/timeHelpers.ts` | + +### OpenTelemetry/noop → internal/ +| Source | Target | +|--------|--------| +| `OpenTelemetry/noop/noopHelpers.ts` | `internal/noopHelpers.ts` | + +### OpenTelemetry/interfaces → interfaces/otel/ +| Source | Target | +|--------|--------| +| `OpenTelemetry/interfaces/IOTelApi.ts` | `interfaces/otel/IOTelApi.ts` | +| `OpenTelemetry/interfaces/IOTelApiCtx.ts` | `interfaces/otel/IOTelApiCtx.ts` | +| `OpenTelemetry/interfaces/IOTelAttributes.ts` | `interfaces/otel/IOTelAttributes.ts` | +| `OpenTelemetry/interfaces/IOTelException.ts` | `interfaces/otel/IOTelException.ts` | +| `OpenTelemetry/interfaces/IOTelHrTime.ts` | `interfaces/IOTelHrTime.ts` | + +### OpenTelemetry/interfaces/config → interfaces/otel/config/ +| Source | Target | +|--------|--------| +| `OpenTelemetry/interfaces/config/IOTelAttributeLimits.ts` | `interfaces/otel/config/IOTelAttributeLimits.ts` | +| `OpenTelemetry/interfaces/config/IOTelConfig.ts` | `interfaces/otel/config/IOTelConfig.ts` | +| `OpenTelemetry/interfaces/config/IOTelErrorHandlers.ts` | `interfaces/otel/config/IOTelErrorHandlers.ts` | +| `OpenTelemetry/interfaces/config/IOTelSpanLimits.ts` | `interfaces/otel/config/IOTelSpanLimits.ts` | +| `OpenTelemetry/interfaces/config/ITraceCfg.ts` | `interfaces/otel/config/IOTelTraceCfg.ts` | + +### OpenTelemetry/interfaces/trace → interfaces/otel/trace/ +| Source | Target | +|--------|--------| +| `OpenTelemetry/interfaces/trace/IOTelSpan.ts` | `interfaces/otel/trace/IOTelSpan.ts` | +| `OpenTelemetry/interfaces/trace/IOTelSpanCtx.ts` | `interfaces/otel/trace/IOTelSpanCtx.ts` | +| `OpenTelemetry/interfaces/trace/IOTelSpanOptions.ts` | `interfaces/otel/trace/IOTelSpanOptions.ts` | +| `OpenTelemetry/interfaces/trace/IOTelSpanStatus.ts` | `interfaces/otel/trace/IOTelSpanStatus.ts` | +| `OpenTelemetry/interfaces/trace/IOTelTracer.ts` | `interfaces/otel/trace/IOTelTracer.ts` | +| `OpenTelemetry/interfaces/trace/IOTelTracerProvider.ts` | `interfaces/otel/trace/IOTelTracerProvider.ts` | +| `OpenTelemetry/interfaces/trace/IOTelTraceState.ts` | `interfaces/otel/trace/IOTelTraceState.ts` | +| `OpenTelemetry/interfaces/trace/IReadableSpan.ts` | `interfaces/otel/trace/IReadableSpan.ts` | +| `OpenTelemetry/interfaces/trace/ITraceApi.ts` | `interfaces/otel/trace/IOTelTraceApi.ts` | + +### OpenTelemetry/trace → otel/api/trace/ +| Source | Target | +|--------|--------| +| `OpenTelemetry/trace/span.ts` | `otel/api/trace/span.ts` | +| `OpenTelemetry/trace/traceApi.ts` | `otel/api/trace/traceApi.ts` | +| `OpenTelemetry/trace/traceProvider.ts` | `otel/api/trace/traceProvider.ts` | +| `OpenTelemetry/trace/tracer.ts` | `otel/api/trace/tracer.ts` | +| `OpenTelemetry/trace/tracerProvider.ts` | `otel/api/trace/tracerProvider.ts` | +| `OpenTelemetry/trace/traceState.ts` | `otel/api/trace/traceState.ts` | +| `OpenTelemetry/trace/utils.ts` | `otel/api/trace/utils.ts` | + +--- + +## Test Structure Changes + +### Important: Test Migration Strategy + +Tests are migrated from TWO sources into AppInsightsCore: + +1. **AppInsightsCore Tests** - Use `git mv` to preserve history (files already in this repo) +2. **AppInsightsCommon Tests** - Use `git mv` from `../../AppInsightsCommon/Tests/Unit/src/` to `./Tests/Unit/src/ai/Common/` + - These tests are being consolidated into AppInsightsCore as part of the Common→Core merge + - After moving, the AppInsightsCommon/Tests folder should be deleted + +**Note on GlobalTestHooks.Test.ts:** +- AppInsightsCommon has its own `GlobalTestHooks.Test.ts` +- AppInsightsCore also has `GlobalTestHooks.Test.ts` +- Only the AppInsightsCore version is kept (moved to `ai/Core/GlobalTestHooks.Test.ts`) +- The AppInsightsCommon version is deleted (not duplicated) + +### Previous Test Structure + +**AppInsightsCore (`Tests/Unit/src/`):** +``` +├── aiunittests.ts +├── GlobalTestHooks.Test.ts +├── TestPlugins.ts +├── AppInsightsCoreSize.Tests.ts +├── ApplicationInsightsCore.Tests.ts +├── CookieManager.Tests.ts +├── Dynamic.Tests.ts +├── DynamicConfig.Tests.ts +├── EventHelper.Tests.ts +├── EventsDiscardedReason.Tests.ts +├── HelperFunc.Tests.ts +├── LoggingEnum.Tests.ts +├── SendPostManager.Tests.ts +├── StatsBeat.Tests.ts +├── UpdateConfig.Tests.ts +├── W3cTraceParentTests.ts +├── W3TraceState.Tests.ts +└── OpenTelemetry/ + ├── attributeContainer.Tests.ts + ├── commonUtils.Tests.ts + ├── errors.Tests.ts + ├── otelNegative.Tests.ts + ├── span.Tests.ts + ├── traceState.Tests.ts + └── traceUtils.Tests.ts +``` + +**AppInsightsCommon (`Tests/Unit/src/`) - To be migrated:** +``` +├── appinsights-common.tests.ts # Entry point - DELETE +├── GlobalTestHooks.Test.ts # Duplicate - DELETE +├── AppInsightsCommon.tests.ts # Move to ai/Common/ +├── ConnectionStringParser.tests.ts +├── Exception.tests.ts +├── RequestHeaders.tests.ts +├── SeverityLevel.tests.ts +├── ThrottleMgr.tests.ts # Move to ai/Core/ (diagnostics) +├── Util.tests.ts +└── W3CTraceStateModes.tests.ts +``` + +### New Test Structure (`Tests/Unit/src/`) - MSNev3 Aligned +``` +├── aiunittests.ts +├── ai/ +│ ├── Common/ # Common/telemetry tests (9 files) +│ │ ├── AppInsightsCommon.tests.ts +│ │ ├── ConnectionStringParser.tests.ts +│ │ ├── Exception.tests.ts +│ │ ├── RequestHeaders.tests.ts +│ │ ├── SeverityLevel.tests.ts +│ │ ├── Util.tests.ts +│ │ ├── W3cTraceParentTests.ts +│ │ ├── W3CTraceStateModes.tests.ts +│ │ └── W3TraceState.Tests.ts +│ └── Core/ # Core implementation tests (17 files) +│ ├── AppInsightsCoreSize.Tests.ts +│ ├── ApplicationInsightsCore.Tests.ts +│ ├── CookieManager.Tests.ts +│ ├── Dynamic.Tests.ts +│ ├── DynamicConfig.Tests.ts +│ ├── errors.Tests.ts +│ ├── EventHelper.Tests.ts +│ ├── EventsDiscardedReason.Tests.ts +│ ├── GlobalTestHooks.Test.ts +│ ├── HelperFunc.Tests.ts +│ ├── LoggingEnum.Tests.ts +│ ├── SendPostManager.Tests.ts +│ ├── StatsBeat.Tests.ts +│ ├── TestPlugins.ts +│ ├── ThrottleMgr.tests.ts +│ ├── traceState.Tests.ts +│ └── UpdateConfig.Tests.ts +├── api/ # Empty (future OTel API tests) +├── attribute/ +│ └── attributeContainer.Tests.ts +├── internal/ +│ ├── commonUtils.Tests.ts +│ └── otelNegative.Tests.ts +├── sdk/ # Empty (future OTel SDK tests) +└── trace/ + ├── span.Tests.ts + └── traceUtils.Tests.ts +``` + +### Test File Move Table + +#### → ai/Core/ (17 files) + +**From AppInsightsCore root Tests/Unit/src/:** + +| Source | Target | +|--------|--------| +| `ApplicationInsightsCore.Tests.ts` | `ai/Core/ApplicationInsightsCore.Tests.ts` | +| `AppInsightsCoreSize.Tests.ts` | `ai/Core/AppInsightsCoreSize.Tests.ts` | +| `CookieManager.Tests.ts` | `ai/Core/CookieManager.Tests.ts` | +| `Dynamic.Tests.ts` | `ai/Core/Dynamic.Tests.ts` | +| `DynamicConfig.Tests.ts` | `ai/Core/DynamicConfig.Tests.ts` | +| `UpdateConfig.Tests.ts` | `ai/Core/UpdateConfig.Tests.ts` | +| `SendPostManager.Tests.ts` | `ai/Core/SendPostManager.Tests.ts` | +| `StatsBeat.Tests.ts` | `ai/Core/StatsBeat.Tests.ts` | +| `EventsDiscardedReason.Tests.ts` | `ai/Core/EventsDiscardedReason.Tests.ts` | +| `LoggingEnum.Tests.ts` | `ai/Core/LoggingEnum.Tests.ts` | +| `EventHelper.Tests.ts` | `ai/Core/EventHelper.Tests.ts` | +| `HelperFunc.Tests.ts` | `ai/Core/HelperFunc.Tests.ts` | +| `GlobalTestHooks.Test.ts` | `ai/Core/GlobalTestHooks.Test.ts` | +| `TestPlugins.ts` | `ai/Core/TestPlugins.ts` | + +**From AppInsightsCore Tests/Unit/src/OpenTelemetry/:** + +| Source | Target | +|--------|--------| +| `OpenTelemetry/errors.Tests.ts` | `ai/Core/errors.Tests.ts` | +| `OpenTelemetry/traceState.Tests.ts` | `ai/Core/traceState.Tests.ts` | + +**From AppInsightsCommon Tests/Unit/src/ (moved to ai/Core/):** + +| Source (AppInsightsCommon) | Target | +|----------------------------|--------| +| `ThrottleMgr.tests.ts` | `ai/Core/ThrottleMgr.tests.ts` | + +#### → ai/Common/ (9 files) - FROM AppInsightsCommon +**Source Location: `../../AppInsightsCommon/Tests/Unit/src/`** + +These files are moved from the AppInsightsCommon package into AppInsightsCore: + +| Source (in AppInsightsCommon) | Target (in AppInsightsCore) | +|-------------------------------|----------------------------| +| `AppInsightsCommon.tests.ts` | `ai/Common/AppInsightsCommon.tests.ts` | +| `ConnectionStringParser.tests.ts` | `ai/Common/ConnectionStringParser.tests.ts` | +| `Exception.tests.ts` | `ai/Common/Exception.tests.ts` | +| `RequestHeaders.tests.ts` | `ai/Common/RequestHeaders.tests.ts` | +| `SeverityLevel.tests.ts` | `ai/Common/SeverityLevel.tests.ts` | +| `Util.tests.ts` | `ai/Common/Util.tests.ts` | +| `W3CTraceStateModes.tests.ts` | `ai/Common/W3CTraceStateModes.tests.ts` | + +**From AppInsightsCore root (already present, move to ai/Common/):** + +| Source (in AppInsightsCore) | Target | +|-----------------------------|--------| +| `W3cTraceParentTests.ts` | `ai/Common/W3cTraceParentTests.ts` | +| `W3TraceState.Tests.ts` | `ai/Common/W3TraceState.Tests.ts` | + +#### → attribute/ +| Source | Target | +|--------|--------| +| `OpenTelemetry/attributeContainer.Tests.ts` | `attribute/attributeContainer.Tests.ts` | + +#### → internal/ +| Source | Target | +|--------|--------| +| `OpenTelemetry/commonUtils.Tests.ts` | `internal/commonUtils.Tests.ts` | +| `OpenTelemetry/otelNegative.Tests.ts` | `internal/otelNegative.Tests.ts` | + +#### → trace/ +| Source | Target | +|--------|--------| +| `OpenTelemetry/span.Tests.ts` | `trace/span.Tests.ts` | +| `OpenTelemetry/traceUtils.Tests.ts` | `trace/traceUtils.Tests.ts` | + +#### Files Deleted from AppInsightsCommon (after moving tests to Core) +| Source | Notes | +|--------|-------| +| `appinsights-common.tests.ts` | Entry point file - no longer needed | +| `GlobalTestHooks.Test.ts` | Duplicate - Core has its own version | +| `../../AppInsightsCommon/Tests/UnitTests.html` | Test HTML runner - no longer needed | +| `../../AppInsightsCommon/Tests/tsconfig.json` | Test config - no longer needed | + +--- + +## Configuration Updates + +### tsconfig.json +Replace the `include` section: +```json +{ + "include": [ + "./src/index.ts", + "./src/__DynamicConstants.ts", + "./src/config/**/*.ts", + "./src/constants/**/*.ts", + "./src/core/**/*.ts", + "./src/diagnostics/**/*.ts", + "./src/enums/**/*.ts", + "./src/interfaces/**/*.ts", + "./src/internal/**/*.ts", + "./src/otel/**/*.ts", + "./src/telemetry/**/*.ts", + "./src/utils/**/*.ts" + ] +} +``` + +### Test Import Path Rules +After moving test files, update all import paths in test files: + +**For ai/Core/ and ai/Common/ files** (5 levels deep): +- Use `../../../../../src/` for source imports +- Change `from '../TestPlugins'` to `from './TestPlugins'` + +**For attribute/, internal/, trace/ files** (4 levels deep): +- Use `../../../../src/` for source imports + +### aiunittests.ts Content +```typescript +import '@microsoft/applicationinsights-shims'; + +// ai/Core tests - Core implementation tests +import { ApplicationInsightsCoreTests } from "./ai/Core/ApplicationInsightsCore.Tests"; +import { CookieManagerTests } from "./ai/Core/CookieManager.Tests"; +import { AppInsightsCoreSizeCheck } from "./ai/Core/AppInsightsCoreSize.Tests"; +import { SendPostManagerTests } from './ai/Core/SendPostManager.Tests'; +// import { StatsBeatTests } from './ai/Core/StatsBeat.Tests'; // Currently disabled +import { DynamicTests } from "./ai/Core/Dynamic.Tests"; +import { DynamicConfigTests } from "./ai/Core/DynamicConfig.Tests"; +import { UpdateConfigTests } from "./ai/Core/UpdateConfig.Tests"; +import { ThrottleMgrTest } from './ai/Core/ThrottleMgr.tests'; +import { LoggingEnumTests } from "./ai/Core/LoggingEnum.Tests"; +import { EventsDiscardedReasonTests } from "./ai/Core/EventsDiscardedReason.Tests"; +import { EventHelperTests } from "./ai/Core/EventHelper.Tests"; +import { HelperFuncTests } from './ai/Core/HelperFunc.Tests'; +import { OTelTraceApiTests } from './ai/Core/traceState.Tests'; +import { OpenTelemetryErrorsTests } from './ai/Core/errors.Tests'; +import { GlobalTestHooks } from "./ai/Core/GlobalTestHooks.Test"; + +// ai/Common tests - Common telemetry tests +import { W3cTraceParentTests } from "./ai/Common/W3cTraceParentTests"; +import { W3cTraceStateTests } from './ai/Common/W3TraceState.Tests'; +import { ConnectionStringParserTests } from './ai/Common/ConnectionStringParser.tests'; +import { RequestHeadersTests } from './ai/Common/RequestHeaders.tests'; +import { W3CTraceStateModesTests } from './ai/Common/W3CTraceStateModes.tests'; +import { DataSanitizerTests } from './ai/Common/AppInsightsCommon.tests'; +import { ExceptionTests } from './ai/Common/Exception.tests'; +import { SeverityLevelTests } from './ai/Common/SeverityLevel.tests'; +import { UtilTests } from './ai/Common/Util.tests'; + +// Internal tests +import { CommonUtilsTests } from './internal/commonUtils.Tests'; +import { OTelNegativeTests } from './internal/otelNegative.Tests'; + +// Trace tests +import { SpanTests } from './trace/span.Tests'; +import { TraceUtilsTests } from './trace/traceUtils.Tests'; + +// Attribute tests +import { AttributeContainerTests } from './attribute/attributeContainer.Tests'; + +export function runTests() { + new GlobalTestHooks().registerTests(); + + // Config tests + new DynamicTests().registerTests(); + new DynamicConfigTests().registerTests(); + new UpdateConfigTests().registerTests(); + + // Core tests + new ApplicationInsightsCoreTests().registerTests(); + new CookieManagerTests(false).registerTests(); + new CookieManagerTests(true).registerTests(); + new AppInsightsCoreSizeCheck().registerTests(); + new SendPostManagerTests().registerTests(); + // new StatsBeatTests(false).registerTests(); // Currently disabled + // new StatsBeatTests(true).registerTests(); // Currently disabled + + // Diagnostics tests + new ThrottleMgrTest().registerTests(); + + // Enum tests + new LoggingEnumTests().registerTests(); + new EventsDiscardedReasonTests().registerTests(); + + // Internal tests + new EventHelperTests().registerTests(); + new CommonUtilsTests().registerTests(); + new OTelNegativeTests().registerTests(); + + // Telemetry tests + new W3cTraceParentTests().registerTests(); + new W3cTraceStateTests().registerTests(); + new ConnectionStringParserTests().registerTests(); + new RequestHeadersTests().registerTests(); + new W3CTraceStateModesTests().registerTests(); + new DataSanitizerTests().registerTests(); + new ExceptionTests().registerTests(); + new SeverityLevelTests().registerTests(); + + // Utils tests + new HelperFuncTests().registerTests(); + new UtilTests().registerTests(); + + // OTel tests + new OTelTraceApiTests().registerTests(); + new OpenTelemetryErrorsTests().registerTests(); + new SpanTests().registerTests(); + new AttributeContainerTests().registerTests(); + new TraceUtilsTests().registerTests(); +} +``` + +**Note:** StatsBeat.Tests.ts is present in ai/Core/ but currently commented out in the test runner. The file exists and should be moved as part of the migration. + +--- + +## Additional Required Fixes (Outside AppInsightsCore) + +### AISKU Test Files - Fix Banned Imports +The following files use banned deep path imports that must be fixed: + +**AISKU/Tests/Unit/src/SpanHelperUtils.Tests.ts** +```typescript +// ❌ Remove this import: +import { IDistributedTraceInit } from "@microsoft/applicationinsights-core-js/src/JavaScriptSDK.Interfaces/IDistributedTraceContext"; + +// ✅ Add to existing import from public API: +import { + createDistributedTraceContext, + eOTelSpanKind, + eOTelSpanStatusCode, + IDistributedTraceInit, // Add here + isReadableSpan, + isSpanContextValid, + ITelemetryItem, + wrapSpanContext +} from "@microsoft/applicationinsights-core-js"; +``` + +**AISKU/Tests/Unit/src/UseSpan.Tests.ts** +```typescript +// ❌ Remove this import: +import { IAppInsightsCore } from "@microsoft/applicationinsights-core-js/src/applicationinsights-core-js"; + +// ✅ Add to existing import from public API: +import { + IAppInsightsCore, // Add here + IReadableSpan, eOTelSpanKind, eOTelSpanStatusCode, useSpan, ITelemetryItem, ISpanScope, ITraceHost +} from "@microsoft/applicationinsights-core-js"; +``` + +--- + +## AppInsightsCommon Deprecation (Merge into Core) + +As part of this migration, the `@microsoft/applicationinsights-common` package is being deprecated. All functionality has been merged into `@microsoft/applicationinsights-core-js`. + +### Delete AppInsightsCommon Tests Folder +Remove the entire Tests folder since tests are now in AppInsightsCore: + +```powershell +Set-Location "D:\MSNev2\ApplicationInsights-JS\shared\AppInsightsCommon" + +# Delete test files +git rm "Tests/Unit/src/appinsights-common.tests.ts" +git rm "Tests/Unit/src/AppInsightsCommon.tests.ts" +git rm "Tests/Unit/src/ConnectionStringParser.tests.ts" +git rm "Tests/Unit/src/Exception.tests.ts" +git rm "Tests/Unit/src/GlobalTestHooks.Test.ts" +git rm "Tests/Unit/src/RequestHeaders.tests.ts" +git rm "Tests/Unit/src/SeverityLevel.tests.ts" +git rm "Tests/Unit/src/ThrottleMgr.tests.ts" +git rm "Tests/Unit/src/Util.tests.ts" +git rm "Tests/Unit/src/W3CTraceStateModes.tests.ts" + +# Delete test config files +git rm "Tests/UnitTests.html" +git rm "Tests/tsconfig.json" +``` + +### Update AppInsightsCommon package.json +Add deprecation notice: + +```json +{ + "name": "@microsoft/applicationinsights-common", + "version": "3.3.11", + "description": "Microsoft Application Insights Common JavaScript Library (Compatibility Layer - Deprecated)", + "deprecated": "This package has been merged into @microsoft/applicationinsights-core-js. Please update your imports to use @microsoft/applicationinsights-core-js instead.", + // ... rest of package.json unchanged +} +``` + +### Rewrite applicationinsights-common.ts as Re-export Layer +Replace the entire content of `shared/AppInsightsCommon/src/applicationinsights-common.ts` with re-exports from core: + +```typescript +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/** + * @deprecated The @microsoft/applicationinsights-common package has been merged + * into @microsoft/applicationinsights-core-js for simplified dependency management + * and improved tree-shaking capabilities. + * + * Please migrate your imports: + * + * @example + * // Before: + * import { IConfig, ContextTagKeys } from "@microsoft/applicationinsights-common"; + * + * // After: + * import { IConfig, ContextTagKeys } from "@microsoft/applicationinsights-core-js"; + * + * This compatibility layer will be maintained through version 3.x and removed in 4.0.0. + * + * @see https://github.com/microsoft/ApplicationInsights-JS/blob/main/docs/upgrade/MergeCommonToCore.md + */ + +// Re-export everything from core for backward compatibility +export { + // Utility functions + correlationIdSetPrefix, correlationIdGetPrefix, correlationIdCanIncludeCorrelationHeader, + correlationIdGetCorrelationContext, correlationIdGetCorrelationContextValue, + dateTimeUtilsNow, dateTimeUtilsDuration, isInternalApplicationInsightsEndpoint, + createDistributedTraceContextFromTrace, + + // Throttle manager + ThrottleMgr, + + // Connection string parsing + parseConnectionString, ConnectionStringParser, + + // Enums + FieldType, eDistributedTracingModes, DistributedTracingModes, EventPersistence, + eSeverityLevel, SeverityLevel, + + // Request/Response + eRequestHeaders, RequestHeaders, + + // Constants + DisabledPropertyName, ProcessLegacy, SampleRate, HttpMethod, + DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH, strNotSpecified, + + // Contracts + AIData, AIBase, IDomain, + IStackFrame, IExceptionDetails, IExceptionData, IEventData, IMessageData, + IMetricData, IDataPoint, DataPointType, IPageViewPerfData, + DependencyKind, DependencySourceType, + + // Telemetry interfaces + ISerializable, IEnvelope, IPageViewData, IRemoteDependencyData, + IEventTelemetry, ITraceTelemetry, IMetricTelemetry, IDependencyTelemetry, + IExceptionTelemetry, IAutoExceptionTelemetry, IExceptionInternal, + IPageViewTelemetry, IPageViewTelemetryInternal, + IPageViewPerformanceTelemetry, IPageViewPerformanceTelemetryInternal, + IRequestTelemetry, + + // Telemetry classes + Envelope, Event, Exception, Metric, PageView, PageViewPerformance, + RemoteDependencyData, Trace, Data, + + // Configuration + IConfig, ConfigurationManager, IStorageBuffer, ICorrelationConfig, + + // Context tags + IContextTagKeys, ContextTagKeys, CtxTagKeys, Extensions, + + // Data types + EventDataType, ExceptionDataType, MetricDataType, PageViewDataType, + PageViewPerformanceDataType, RemoteDependencyDataType, RequestDataType, TraceDataType, + + // Envelope types + EventEnvelopeType, ExceptionEnvelopeType, MetricEnvelopeType, PageViewEnvelopeType, + PageViewPerformanceEnvelopeType, RemoteDependencyEnvelopeType, RequestEnvelopeType, + TraceEnvelopeType, + + // Data sanitization + DataSanitizerValues, dataSanitizeKeyAndAddUniqueness, dataSanitizeKey, + dataSanitizeString, dataSanitizeUrl, dataSanitizeMessage, dataSanitizeException, + dataSanitizeProperties, dataSanitizeMeasurements, dataSanitizeId, dataSanitizeInput, + dsPadNumber, + + // Telemetry creation + TelemetryItemCreator, createTelemetryItem, + + // Application Insights interfaces + IAppInsights, ITelemetryContext, IPropertiesPlugin, IRequestContext, + + // Context interfaces + IWeb, ISession, ISessionManager, IApplication, IDevice, IInternal, + ILocation, ISample, IOperatingSystem, IUser, IUserContext, ITelemetryTrace, + + // Helper functions + stringToBoolOrDefault, msToTimeSpan, getExtensionByName, isCrossOriginError, + + // Trace parent + ITraceParent, createTraceParent, parseTraceParent, isValidTraceId, isValidSpanId, + isValidTraceParent, isSampledFlag, formatTraceParent, findW3cTraceParent, + findAllScripts, isBeaconsSupported, + + // DOM helpers + createDomEvent, + + // Storage helpers + utlDisableStorage, utlEnableStorage, utlCanUseLocalStorage, utlGetLocalStorage, + utlSetLocalStorage, utlRemoveStorage, utlCanUseSessionStorage, + utlGetSessionStorageKeys, utlGetSessionStorage, utlSetSessionStorage, + utlRemoveSessionStorage, utlSetStoragePrefix, + + // URL helpers + urlParseUrl, urlGetAbsoluteUrl, urlGetPathName, urlGetCompleteUrl, + urlParseHost, urlParseFullHost, + + // Throttle manager interfaces + IThrottleLimit, IThrottleInterval, IThrottleMgrConfig, + IThrottleLocalStorageObj, IThrottleResult, + + // Offline support + IOfflineListener, createOfflineListener, IOfflineState, + eOfflineValue, OfflineCallback, + + // Request headers interface + IRequestHeaders, + + // Plugin identifiers + PropertiesPluginIdentifier, BreezeChannelIdentifier, AnalyticsPluginIdentifier + +} from "@microsoft/applicationinsights-core-js"; + +// Type re-exports (zero runtime cost) +export type { ConnectionString } from "@microsoft/applicationinsights-core-js"; +``` + +--- + +## Execution Script + +```powershell +# ============================================================================= +# Complete Migration Script - AppInsightsCore +# Run from: D:\MSNev2\ApplicationInsights-JS\shared\AppInsightsCore +# ============================================================================= + +Set-Location "D:\MSNev2\ApplicationInsights-JS\shared\AppInsightsCore" + +# ----------------------------------------------------------------------------- +# STEP 1: Create Source Directory Structure +# ----------------------------------------------------------------------------- + +$srcDirs = @( + "src/config", + "src/constants", + "src/core", + "src/diagnostics", + "src/enums/ai", + "src/enums/otel", + "src/interfaces/ai/context", + "src/interfaces/ai/contracts", + "src/interfaces/ai/telemetry", + "src/interfaces/config", + "src/interfaces/otel/attribute", + "src/interfaces/otel/config", + "src/interfaces/otel/trace", + "src/internal", + "src/otel/api/errors", + "src/otel/api/trace", + "src/otel/attribute", + "src/telemetry/ai/Common", + "src/utils" +) + +foreach ($dir in $srcDirs) { + New-Item -ItemType Directory -Force -Path $dir +} + +# ----------------------------------------------------------------------------- +# STEP 2: Move Source Files (use git mv for each) +# See "Source File Move Tables" section above for complete list +# Example: +# git mv "src/applicationinsights-core-js.ts" "src/index.ts" +# git mv "src/Config/DynamicConfig.ts" "src/config/DynamicConfig.ts" +# ... etc for all files listed in tables +# ----------------------------------------------------------------------------- + +# ----------------------------------------------------------------------------- +# STEP 3: Update Source Import Paths +# After moving all source files, update all import statements +# Use find/replace for each mapping in Import Path Mapping Table +# ----------------------------------------------------------------------------- + +# ----------------------------------------------------------------------------- +# STEP 4: Update tsconfig.json +# Replace include section as shown in Configuration Updates section +# ----------------------------------------------------------------------------- + +# ----------------------------------------------------------------------------- +# STEP 4b: Rush Update (Required before building) +# This is a Rush-based monorepo - must update dependencies after any changes +# ----------------------------------------------------------------------------- + +Set-Location "D:\MSNev2\ApplicationInsights-JS" +rush update --recheck --full + +# If you encounter dependency issues, use the more aggressive purge option: +# rush update --recheck --purge --full + +# ----------------------------------------------------------------------------- +# STEP 5: Build and Test Source Migration +# ----------------------------------------------------------------------------- + +Set-Location "D:\MSNev2\ApplicationInsights-JS\shared\AppInsightsCore" +npx grunt core +npx grunt coreunittest + +# ----------------------------------------------------------------------------- +# STEP 6: Create Test Directory Structure +# ----------------------------------------------------------------------------- + +$testDirs = @( + "Tests/Unit/src/ai/Common", + "Tests/Unit/src/ai/Core", + "Tests/Unit/src/api", + "Tests/Unit/src/attribute", + "Tests/Unit/src/internal", + "Tests/Unit/src/sdk", + "Tests/Unit/src/trace" +) + +Set-Location "D:\MSNev2\ApplicationInsights-JS\shared\AppInsightsCore" +foreach ($dir in $testDirs) { + New-Item -ItemType Directory -Force -Path $dir +} + +# ----------------------------------------------------------------------------- +# STEP 7: Move Test Files +# See "Test File Move Table" section for complete list +# ----------------------------------------------------------------------------- + +Set-Location "D:\MSNev2\ApplicationInsights-JS\shared\AppInsightsCore\Tests\Unit\src" + +# Move AppInsightsCore root tests to ai/Core/ +git mv "ApplicationInsightsCore.Tests.ts" "ai/Core/" +git mv "AppInsightsCoreSize.Tests.ts" "ai/Core/" +git mv "CookieManager.Tests.ts" "ai/Core/" +git mv "Dynamic.Tests.ts" "ai/Core/" +git mv "DynamicConfig.Tests.ts" "ai/Core/" +git mv "UpdateConfig.Tests.ts" "ai/Core/" +git mv "SendPostManager.Tests.ts" "ai/Core/" +git mv "StatsBeat.Tests.ts" "ai/Core/" +git mv "EventsDiscardedReason.Tests.ts" "ai/Core/" +git mv "LoggingEnum.Tests.ts" "ai/Core/" +git mv "EventHelper.Tests.ts" "ai/Core/" +git mv "HelperFunc.Tests.ts" "ai/Core/" +git mv "GlobalTestHooks.Test.ts" "ai/Core/" +git mv "TestPlugins.ts" "ai/Core/" + +# Move AppInsightsCore OpenTelemetry tests to appropriate locations +git mv "OpenTelemetry/errors.Tests.ts" "ai/Core/" +git mv "OpenTelemetry/traceState.Tests.ts" "ai/Core/" +git mv "OpenTelemetry/attributeContainer.Tests.ts" "attribute/" +git mv "OpenTelemetry/commonUtils.Tests.ts" "internal/" +git mv "OpenTelemetry/otelNegative.Tests.ts" "internal/" +git mv "OpenTelemetry/span.Tests.ts" "trace/" +git mv "OpenTelemetry/traceUtils.Tests.ts" "trace/" + +# Move AppInsightsCore root W3c tests to ai/Common/ +git mv "W3cTraceParentTests.ts" "ai/Common/" +git mv "W3TraceState.Tests.ts" "ai/Common/" + +# ----------------------------------------------------------------------------- +# STEP 7b: Move Tests from AppInsightsCommon to AppInsightsCore +# Run from repository root +# ----------------------------------------------------------------------------- + +Set-Location "D:\MSNev2\ApplicationInsights-JS" + +# Move ThrottleMgr to ai/Core/ (it tests diagnostics functionality) +git mv "shared/AppInsightsCommon/Tests/Unit/src/ThrottleMgr.tests.ts" "shared/AppInsightsCore/Tests/Unit/src/ai/Core/" + +# Move other test files from AppInsightsCommon to AppInsightsCore/Tests/Unit/src/ai/Common/ +git mv "shared/AppInsightsCommon/Tests/Unit/src/AppInsightsCommon.tests.ts" "shared/AppInsightsCore/Tests/Unit/src/ai/Common/" +git mv "shared/AppInsightsCommon/Tests/Unit/src/ConnectionStringParser.tests.ts" "shared/AppInsightsCore/Tests/Unit/src/ai/Common/" +git mv "shared/AppInsightsCommon/Tests/Unit/src/Exception.tests.ts" "shared/AppInsightsCore/Tests/Unit/src/ai/Common/" +git mv "shared/AppInsightsCommon/Tests/Unit/src/RequestHeaders.tests.ts" "shared/AppInsightsCore/Tests/Unit/src/ai/Common/" +git mv "shared/AppInsightsCommon/Tests/Unit/src/SeverityLevel.tests.ts" "shared/AppInsightsCore/Tests/Unit/src/ai/Common/" +git mv "shared/AppInsightsCommon/Tests/Unit/src/Util.tests.ts" "shared/AppInsightsCore/Tests/Unit/src/ai/Common/" +git mv "shared/AppInsightsCommon/Tests/Unit/src/W3CTraceStateModes.tests.ts" "shared/AppInsightsCore/Tests/Unit/src/ai/Common/" + +# Remove duplicate/unused files from AppInsightsCommon +git rm "shared/AppInsightsCommon/Tests/Unit/src/appinsights-common.tests.ts" +git rm "shared/AppInsightsCommon/Tests/Unit/src/GlobalTestHooks.Test.ts" +git rm "shared/AppInsightsCommon/Tests/UnitTests.html" +git rm "shared/AppInsightsCommon/Tests/tsconfig.json" + +# ----------------------------------------------------------------------------- +# STEP 8: Update Test Import Paths +# ----------------------------------------------------------------------------- + +# Fix ai/Core and ai/Common files - need ../../../../../src/ (5 levels) +Get-ChildItem -Path "ai/Core","ai/Common" -Filter "*.ts" -Recurse | ForEach-Object { + $content = Get-Content $_.FullName -Raw + # Fix various depth patterns to 5 levels + $content = $content -replace '\.\.\/\.\.\/\.\.\/src/', '../../../../../src/' + $content = $content -replace '\.\.\/\.\.\/\.\.\/\.\.\/src/', '../../../../../src/' + $content = $content -replace "from '\.\./TestPlugins'", "from './TestPlugins'" + Set-Content $_.FullName -Value $content -NoNewline +} + +# Fix internal, attribute, trace files - need ../../../../src/ (4 levels) +Get-ChildItem -Path "internal","attribute","trace" -Filter "*.ts" | ForEach-Object { + $content = Get-Content $_.FullName -Raw + $content = $content -replace '\.\.\/\.\.\/\.\.\/src/', '../../../../src/' + Set-Content $_.FullName -Value $content -NoNewline +} + +# ----------------------------------------------------------------------------- +# STEP 9: Update aiunittests.ts +# Replace entire content with the aiunittests.ts content shown above +# ----------------------------------------------------------------------------- + +# ----------------------------------------------------------------------------- +# STEP 10: Clean up empty directories +# ----------------------------------------------------------------------------- + +Remove-Item -Recurse -Force OpenTelemetry -ErrorAction SilentlyContinue + +# ----------------------------------------------------------------------------- +# STEP 10b: Rush Update (Required before building after test file moves) +# ----------------------------------------------------------------------------- + +Set-Location "D:\MSNev2\ApplicationInsights-JS" +rush update --recheck --full + +# ----------------------------------------------------------------------------- +# STEP 11: Build and Test +# ----------------------------------------------------------------------------- + +Set-Location "D:\MSNev2\ApplicationInsights-JS\shared\AppInsightsCore" +npx grunt core +npx grunt coreunittest + +# ----------------------------------------------------------------------------- +# STEP 12: Fix AISKU Banned Imports +# ----------------------------------------------------------------------------- + +Set-Location "D:\MSNev2\ApplicationInsights-JS" + +# Fix SpanHelperUtils.Tests.ts +$file = "AISKU/Tests/Unit/src/SpanHelperUtils.Tests.ts" +$content = Get-Content $file -Raw +$content = $content -replace "import \{ IDistributedTraceInit \} from `"@microsoft/applicationinsights-core-js/src/JavaScriptSDK\.Interfaces/IDistributedTraceContext`";", "" +$content = $content -replace "isReadableSpan,", "IDistributedTraceInit,`n isReadableSpan," +Set-Content $file -Value $content -NoNewline + +# Fix UseSpan.Tests.ts +$file = "AISKU/Tests/Unit/src/UseSpan.Tests.ts" +$content = Get-Content $file -Raw +$content = $content -replace "import \{ IAppInsightsCore \} from `"@microsoft/applicationinsights-core-js/src/applicationinsights-core-js`";", "" +$content = $content -replace "IReadableSpan,", "IAppInsightsCore,`n IReadableSpan," +Set-Content $file -Value $content -NoNewline + +# ----------------------------------------------------------------------------- +# STEP 12b: Rush Update (Required before final verification) +# ----------------------------------------------------------------------------- + +Set-Location "D:\MSNev2\ApplicationInsights-JS" +rush update --recheck --full + +# ----------------------------------------------------------------------------- +# STEP 13: Final Verification +# ----------------------------------------------------------------------------- + +Set-Location "D:\MSNev2\ApplicationInsights-JS\shared\AppInsightsCore" +npx grunt core +npx grunt coreunittest + +# Verify git history preserved +git log --follow --oneline -5 src/core/AppInsightsCore.ts +git log --follow --oneline -5 Tests/Unit/src/ai/Core/ApplicationInsightsCore.Tests.ts +``` + +--- + +## Verification Checklist + +After completing the migration, verify: + +### Build Verification +- [ ] `rush update --recheck --full` - Rush update completed successfully before building +- [ ] `npx grunt core` - Build passes with no errors +- [ ] `npx grunt coreunittest` - All 801 tests pass +- [ ] `npx grunt common` - AppInsightsCommon build passes (as re-export layer) +- [ ] Browser bundle output is `applicationinsights-core-js.js` (NOT `index.js`) + +### Git History Verification +- [ ] `git log --follow src/core/AppInsightsCore.ts` - Shows full history +- [ ] `git log --follow src/utils/CoreUtils.ts` - Shows full history +- [ ] `git log --follow Tests/Unit/src/ai/Core/ApplicationInsightsCore.Tests.ts` - Shows full history +- [ ] `git log --follow Tests/Unit/src/ai/Common/AppInsightsCommon.tests.ts` - Shows history from AppInsightsCommon + +### Structure Verification +- [ ] All old source directories removed: `Config/`, `JavaScriptSDK/`, `Common/`, `OpenTelemetry/`, `JavaScriptSDK.Enums/`, `JavaScriptSDK.Interfaces/` +- [ ] All old test directories removed: `Tests/Unit/src/Common/`, `Tests/Unit/src/OpenTelemetry/` +- [ ] New source directories exist: `config/`, `constants/`, `core/`, `diagnostics/`, `enums/`, `interfaces/`, `internal/`, `otel/`, `telemetry/`, `utils/` +- [ ] New test directories exist: `ai/Core/`, `ai/Common/`, `attribute/`, `internal/`, `trace/` + +### Import Verification +- [ ] No deep path imports exist (`grep -r "/src/" *.ts` returns no matches for external packages) +- [ ] No internal index.ts imports exist (only `src/index.ts` should have index.ts) +- [ ] All TestPlugins imports use `./TestPlugins` (not `../TestPlugins`) + +### Configuration Verification +- [ ] `tsconfig.json` - Updated with new include paths +- [ ] `rollup.config.js` - Uses `browserOutputName = "applicationinsights-core-js"` +- [ ] `api-extractor.json` - Points to `index.d.ts` +- [ ] `gruntfile.js` - InternalConstants path updated, commontest tasks empty + +### Test Count Verification +- [ ] `ai/Core/` contains 17 test files +- [ ] `ai/Common/` contains 9 test files +- [ ] `attribute/` contains 1 test file +- [ ] `internal/` contains 2 test files +- [ ] `trace/` contains 2 test files +- [ ] Total: 31 test files + aiunittests.ts = 32 files + +### Functionality Preservation +- [ ] All exports from `@microsoft/applicationinsights-core-js` continue to work +- [ ] All exports from `@microsoft/applicationinsights-common` work via re-export layer +- [ ] No functionality was deleted - only relocated diff --git a/MergeCommonToCore-Plan.md b/MergeCommonToCore-Plan.md new file mode 100644 index 000000000..f43e9493c --- /dev/null +++ b/MergeCommonToCore-Plan.md @@ -0,0 +1,2160 @@ +# AppInsightsCommon → AppInsightsCore Merge Plan + +**Status:** ✅ All Phases Complete - Ready for Release +**Created:** January 23, 2026 +**Updated:** January 26, 2026 +**Target Version:** 3.4.0 (Core), 3.3.12 (Common compatibility layer) + +--- + +## Related Plans + +> **Next Step:** After completing this plan, proceed to [`MOVE_LAYOUT_PLAN.md`](MOVE_LAYOUT_PLAN.md) for internal source restructuring to align with the otel-core layout. +> +> See [Execution Order](#execution-order) at the end of this document for the complete restructure sequence. + +--- + +## ⚠️ CRITICAL: Version Management + +**DO NOT manually update version numbers in package.json files or version.json!** + +The repository uses an automated versioning system: +- `version.json` contains a `"next": "minor"` setting +- Build pipeline script (`tools/release-tools/setVersion.js`) automatically increments versions +- Current version 3.3.11 will automatically become 3.4.0 on next release +- Manual version changes will conflict with automation and cause build issues + +**What this means for the merge:** +- Leave all package.json versions as "3.3.11" (or their current values) +- Leave version.json as-is +- Do NOT update dependency version numbers in package.json files +- The build system will handle version bumps automatically during release + +**Example of what NOT to do:** +```json +// ❌ WRONG - Do not manually change versions +"dependencies": { + "@microsoft/applicationinsights-core-js": "3.4.0" // ← Don't do this +} + +// ✅ CORRECT - Leave as-is, automation handles it +"dependencies": { + "@microsoft/applicationinsights-core-js": "3.3.11" // ← Keep current version +} +``` + +--- + +## Executive Summary + +This document outlines the plan to merge the `@microsoft/applicationinsights-common` package into `@microsoft/applicationinsights-core-js` while maintaining backward compatibility through a re-export shim layer. This consolidation will simplify the dependency graph, reduce maintenance overhead, and improve tree-shaking capabilities. + +### Goals +- ✅ Consolidate AppInsightsCommon functionality into AppInsightsCore +- ✅ Maintain 100% backward compatibility for external consumers +- ✅ Update all internal packages to use the unified Core package +- ✅ Establish clear deprecation timeline for Common package +- ✅ Preserve tree-shaking and bundle size optimizations +- ✅ Maintain or reduce consuming package bundle sizes (AISKU, extensions, channels) + +### Requirements (MUST NOT) +- 🚫 **NO breaking changes** for external users +- 🚫 **NO changes** to public API surface + +### Non-Goals +- ❌ Immediate removal of Common package (will maintain compatibility layer) +- ❌ Maintaining Core package bundle size (Core bundle will increase by absorbing Common functionality) + +--- + +## Current State Analysis + +### Package Dependencies + +**AppInsightsCommon** (`@microsoft/applicationinsights-common`) +- **Version:** 3.3.11 +- **Dependencies:** + - `@microsoft/applicationinsights-core-js` (3.3.11) + - `@microsoft/applicationinsights-shims` (3.0.1) + - `@microsoft/dynamicproto-js` (^2.0.3) + - `@nevware21/ts-utils` (>= 0.11.8 < 2.x) + +**AppInsightsCore** (`@microsoft/applicationinsights-core-js`) +- **Version:** 3.3.11 +- **Dependencies:** + - `@microsoft/applicationinsights-shims` (3.0.1) + - `@microsoft/dynamicproto-js` (^2.0.3) + - `@nevware21/ts-utils` (>= 0.11.8 < 2.x) + - `@nevware21/ts-async` (>= 0.5.4 < 2.x) + +**Note:** AppInsightsCommon already depends on AppInsightsCore, so no circular dependency exists. + +### Dependent Packages (15+) + +#### Extensions +1. `@microsoft/applicationinsights-analytics-js` +2. `@microsoft/applicationinsights-properties-js` +3. `@microsoft/applicationinsights-dependencies-js` +4. `@microsoft/applicationinsights-clickanalytics-js` +5. `@microsoft/applicationinsights-react-js` +6. `@microsoft/applicationinsights-angularplugin-js` +7. `@microsoft/applicationinsights-debugplugin-js` +8. `@microsoft/applicationinsights-perfmarkmeasure-js` +9. `@microsoft/applicationinsights-osplugin-js` +10. `@microsoft/applicationinsights-cfgsync-js` + +#### Channels +11. `@microsoft/applicationinsights-channel-js/offline-channel-js` +12. `@microsoft/applicationinsights-channel-js/tee-channel-js` + +#### Main SDKs +13. `@microsoft/applicationinsights-web` (AISKU) +14. `@microsoft/applicationinsights-web-basic` (AISKULight) + +#### Tools +15. Internal tools: chrome-debug-extension, applicationinsights-web-snippet + +--- + +## Phase 1: Merge AppInsightsCommon into AppInsightsCore + +### Objective +Move all AppInsightsCommon source files and tests into AppInsightsCore using git commands to preserve file history, update all internal package references, configure the build system, and verify everything compiles and passes tests. + +**CRITICAL:** All file moves MUST use `git mv` commands to preserve git history. Do NOT copy files. + +### Tasks + +#### 1.1 Create Directory Structure +``` +shared/AppInsightsCore/src/ + └── Common/ [NEW] + ├── Telemetry/ + │ ├── Common/ + │ │ ├── Data.ts + │ │ ├── DataSanitizer.ts + │ │ └── Envelope.ts + │ ├── Event.ts + │ ├── Exception.ts + │ ├── Metric.ts + │ ├── PageView.ts + │ ├── PageViewPerformance.ts + │ ├── RemoteDependencyData.ts + │ ├── Trace.ts + │ ├── DataTypes.ts + │ └── EnvelopeTypes.ts + ├── Interfaces/ + │ ├── Contracts/ + │ │ ├── ContextTagKeys.ts + │ │ ├── IBase.ts + │ │ ├── IData.ts + │ │ ├── IPageViewData.ts + │ │ ├── IRemoteDependencyData.ts + │ │ ├── IStackFrame.ts + │ │ └── SeverityLevel.ts + │ └── Context/ + │ ├── IApplication.ts + │ ├── IDevice.ts + │ ├── IInternal.ts + │ ├── ILocation.ts + │ ├── IOperatingSystem.ts + │ ├── ISample.ts + │ ├── ISession.ts + │ ├── ISessionManager.ts + │ ├── ITelemetryTrace.ts + │ ├── IUser.ts + │ └── IWeb.ts + ├── ConnectionStringParser.ts + ├── Constants.ts + ├── DomHelperFuncs.ts + ├── Enums.ts + ├── HelperFuncs.ts + ├── Offline.ts + ├── RequestResponseHeaders.ts + ├── StorageHelperFuncs.ts + ├── TelemetryItemCreator.ts + ├── ThrottleMgr.ts + ├── UrlHelperFuncs.ts + └── Util.ts +``` + +#### 1.2 Move Source Files +**IMPORTANT:** Use `git mv` to move (not copy) all files from `shared/AppInsightsCommon/src/` to `shared/AppInsightsCore/src/Common/` to preserve git history: +- [ ] Telemetry/* (13 files) +- [ ] Interfaces/* (30+ files) +- [ ] Root-level utility files (14 files) + +**Note:** Files must be moved using git commands to maintain file history tracking. Do NOT copy files. + +#### 1.3 Update Internal Import Paths +Within the moved files, update imports that reference other Common files: + +**CRITICAL:** After moving files, ALL imports from `@microsoft/applicationinsights-core-js` within the Common folder MUST be changed to import from actual source file locations, NOT from the root export file. This violates architecture principles and can cause circular dependencies. + +**WRONG Pattern (DO NOT USE):** +```typescript +// In Common/Telemetry/Event.ts +import { IDiagnosticLogger } from "../../applicationinsights-core-js"; // ❌ WRONG +``` + +**CORRECT Pattern:** +```typescript +// In Common/Telemetry/Event.ts +import { IDiagnosticLogger } from "../../JavaScriptSDK.Interfaces/IDiagnosticLogger"; // ✅ CORRECT +``` + +**Import Mapping Rules:** + +1. **Core Interfaces/Classes** - Import from actual source location: + - `IDiagnosticLogger` → `"../../JavaScriptSDK.Interfaces/IDiagnosticLogger"` + - `IProcessTelemetryContext` → `"../../JavaScriptSDK.Interfaces/IProcessTelemetryContext"` + - `ITelemetryItem` → `"../../JavaScriptSDK.Interfaces/ITelemetryItem"` + - `_eInternalMessageId` → `"../../JavaScriptSDK.Enums/LoggingEnums"` + - etc. + +2. **Utility Functions** - Import from @nevware21/ts-utils or specific modules: + - `dateNow` → `import { utcNow as dateNow } from "@nevware21/ts-utils"` + - `getGlobalInst` → `import { getInst as getGlobalInst } from "@nevware21/ts-utils"` + - `objKeys`, `isString`, etc. → `import { objKeys, isString } from "@nevware21/ts-utils"` + +3. **Special Cases:** + - `isTimeSpan` → `import { isTimeSpan } from "../../OpenTelemetry/helpers/timeHelpers"` + - Re-exported Core functions that originated elsewhere + +4. **Common Folder Internal Imports** - Use relative paths: + ```typescript + // In Common/Telemetry/Event.ts + import { ISerializable } from "../Interfaces/Telemetry/ISerializable"; // ✅ CORRECT + import { ContextTagKeys } from "../Interfaces/Contracts/ContextTagKeys"; // ✅ CORRECT + ``` + +**Systematic Fix Process:** +1. Run TypeScript build to identify TS2307 errors +2. Group errors by file and error type +3. For each Core import, find the actual source file location +4. Update import to use correct relative path +5. Re-run build and repeat until clean + +**Common Imports to Fix:** +- Remove any `import { ... } from "./applicationinsights-common"` (self-references) +- Core interfaces must use actual source paths +- Utility functions from ts-utils +- Internal Common references stay relative + +**Files Requiring Import Updates:** ~27 files across all Common subdirectories + +#### 1.4 Update Main Export File +Update `shared/AppInsightsCore/src/applicationinsights-core-js.ts` to export all Common content: + +**IMPORTANT:** Many contract interfaces that were used internally but not explicitly exported in the original Common package must now be exported to avoid compilation errors in consuming packages and tests. + +**Critical Missing Exports to Add:** +- `IStackFrame` - Stack frame information (used by exception handling) +- `IExceptionDetails` - Exception details in exception chains +- `IExceptionData` - Full exception data structure +- `IEventData` - Event data structure +- `IMessageData` - Message/trace data structure +- `IMetricData` - Metric data structure +- `IDataPoint` - Individual metric data points +- `DataPointType` - Enum for measurement vs aggregation +- `IPageViewPerfData` - Page view performance data +- `DependencyKind` - Enum for SQL/HTTP/Other dependencies +- `DependencySourceType` - Enum for dependency sources + +**Symptom of Missing Exports:** +``` +error TS2459: Module '"@microsoft/applicationinsights-core-js"' declares 'IStackFrame' locally, but it is not exported. +``` + +**Complete Export Section to Add:** + +```typescript +// Add at the end of the file: + +// ======================================== +// Application Insights Common Exports +// ======================================== + +// Utility functions +export { + correlationIdSetPrefix, correlationIdGetPrefix, correlationIdCanIncludeCorrelationHeader, + correlationIdGetCorrelationContext, correlationIdGetCorrelationContextValue, + dateTimeUtilsNow, dateTimeUtilsDuration, isInternalApplicationInsightsEndpoint, + createDistributedTraceContextFromTrace +} from "./Common/Util"; + +export { ThrottleMgr } from "./Common/ThrottleMgr"; +export { parseConnectionString, ConnectionStringParser } from "./Common/ConnectionStringParser"; +export { ConnectionString } from "./Common/Interfaces/ConnectionString"; +export { FieldType } from "./Common/Enums"; +export { IRequestHeaders, RequestHeaders, eRequestHeaders } from "./Common/RequestResponseHeaders"; +export { + DisabledPropertyName, ProcessLegacy, SampleRate, HttpMethod, + DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH, strNotSpecified +} from "./Common/Constants"; + +// Contracts (MUST include all interfaces used by consuming packages) +export { IData as AIData } from "./Common/Interfaces/Contracts/IData"; +export { IBase as AIBase } from "./Common/Interfaces/Contracts/IBase"; +export { IDomain } from "./Common/Interfaces/Contracts/IDomain"; +export { ISerializable } from "./Common/Interfaces/Telemetry/ISerializable"; +export { IEnvelope } from "./Common/Interfaces/Telemetry/IEnvelope"; +export { IStackFrame } from "./Common/Interfaces/Contracts/IStackFrame"; +export { IExceptionDetails } from "./Common/Interfaces/Contracts/IExceptionDetails"; +export { IExceptionData } from "./Common/Interfaces/Contracts/IExceptionData"; +export { IEventData } from "./Common/Interfaces/Contracts/IEventData"; +export { IMessageData } from "./Common/Interfaces/Contracts/IMessageData"; +export { IMetricData } from "./Common/Interfaces/Contracts/IMetricData"; +export { IDataPoint } from "./Common/Interfaces/Contracts/IDataPoint"; +export { DataPointType } from "./Common/Interfaces/Contracts/DataPointType"; +export { IPageViewPerfData } from "./Common/Interfaces/Contracts/IPageViewPerfData"; +export { DependencyKind } from "./Common/Interfaces/Contracts/DependencyKind"; +export { DependencySourceType } from "./Common/Interfaces/Contracts/DependencySourceType"; + +// [Rest of exports as shown in original plan...] +``` + +**Validation:** +- Compare with original `shared/AppInsightsCommon/src/applicationinsights-common.ts` exports +- Ensure ALL interfaces/types/classes are exported +- Build all consuming packages to verify no "locally declared but not exported" errors +- Check test files compile successfully + +// Telemetry classes +export { Envelope } from "./Common/Telemetry/Common/Envelope"; +export { Event } from "./Common/Telemetry/Event"; +export { Exception } from "./Common/Telemetry/Exception"; +export { Metric } from "./Common/Telemetry/Metric"; +export { PageView } from "./Common/Telemetry/PageView"; +export { IPageViewData } from "./Common/Interfaces/Contracts/IPageViewData"; +export { RemoteDependencyData } from "./Common/Telemetry/RemoteDependencyData"; +export { IRemoteDependencyData } from "./Common/Interfaces/Contracts/IRemoteDependencyData"; +export { Trace } from "./Common/Telemetry/Trace"; +export { PageViewPerformance } from "./Common/Telemetry/PageViewPerformance"; +export { Data } from "./Common/Telemetry/Common/Data"; + +// Telemetry interfaces +export { IEventTelemetry } from "./Common/Interfaces/IEventTelemetry"; +export { ITraceTelemetry } from "./Common/Interfaces/ITraceTelemetry"; +export { IMetricTelemetry } from "./Common/Interfaces/IMetricTelemetry"; +export { IDependencyTelemetry } from "./Common/Interfaces/IDependencyTelemetry"; +export { IExceptionTelemetry, IAutoExceptionTelemetry, IExceptionInternal } from "./Common/Interfaces/IExceptionTelemetry"; +export { IPageViewTelemetry, IPageViewTelemetryInternal } from "./Common/Interfaces/IPageViewTelemetry"; +export { IPageViewPerformanceTelemetry, IPageViewPerformanceTelemetryInternal } from "./Common/Interfaces/IPageViewPerformanceTelemetry"; +export { IRequestTelemetry } from "./Common/Interfaces/IRequestTelemetry"; + +// Severity level +export { eSeverityLevel, SeverityLevel } from "./Common/Interfaces/Contracts/SeverityLevel"; + +// Configuration +export { IConfig, ConfigurationManager } from "./Common/Interfaces/IConfig"; +export { IStorageBuffer } from "./Common/Interfaces/IStorageBuffer"; +export { ICorrelationConfig } from "./Common/Interfaces/ICorrelationConfig"; + +// Context tags and keys +export { IContextTagKeys, ContextTagKeys } from "./Common/Interfaces/Contracts/ContextTagKeys"; +export { CtxTagKeys, Extensions } from "./Common/Interfaces/PartAExtensions"; + +// Data types and envelope types +export { + EventDataType, ExceptionDataType, MetricDataType, PageViewDataType, + PageViewPerformanceDataType, RemoteDependencyDataType, RequestDataType, TraceDataType +} from "./Common/Telemetry/DataTypes"; + +export { + EventEnvelopeType, ExceptionEnvelopeType, MetricEnvelopeType, PageViewEnvelopeType, + PageViewPerformanceEnvelopeType, RemoteDependencyEnvelopeType, RequestEnvelopeType, TraceEnvelopeType +} from "./Common/Telemetry/EnvelopeTypes"; + +// Data sanitization +export { + DataSanitizerValues, dataSanitizeKeyAndAddUniqueness, dataSanitizeKey, dataSanitizeString, + dataSanitizeUrl, dataSanitizeMessage, dataSanitizeException, dataSanitizeProperties, + dataSanitizeMeasurements, dataSanitizeId, dataSanitizeInput, dsPadNumber +} from "./Common/Telemetry/Common/DataSanitizer"; + +// Telemetry item creator +export { TelemetryItemCreator, createTelemetryItem } from "./Common/TelemetryItemCreator"; + +// Application Insights interfaces +export { IAppInsights } from "./Common/Interfaces/IAppInsights"; +export { ITelemetryContext } from "./Common/Interfaces/ITelemetryContext"; +export { IPropertiesPlugin } from "./Common/Interfaces/IPropertiesPlugin"; +export { IRequestContext } from "./Common/Interfaces/IRequestContext"; + +// Context interfaces +export { IWeb } from "./Common/Interfaces/Context/IWeb"; +export { ISession } from "./Common/Interfaces/Context/ISession"; +export { ISessionManager } from "./Common/Interfaces/Context/ISessionManager"; +export { IApplication } from "./Common/Interfaces/Context/IApplication"; +export { IDevice } from "./Common/Interfaces/Context/IDevice"; +export { IInternal } from "./Common/Interfaces/Context/IInternal"; +export { ILocation } from "./Common/Interfaces/Context/ILocation"; +export { ISample } from "./Common/Interfaces/Context/ISample"; +export { IOperatingSystem } from "./Common/Interfaces/Context/IOperatingSystem"; +export { IUser, IUserContext } from "./Common/Interfaces/Context/IUser"; +export { ITelemetryTrace } from "./Common/Interfaces/Context/ITelemetryTrace"; + +// Enums +export { eDistributedTracingModes, DistributedTracingModes, EventPersistence } from "./Common/Enums"; + +// Helper functions +export { stringToBoolOrDefault, msToTimeSpan, getExtensionByName, isCrossOriginError } from "./Common/HelperFuncs"; +export { createDomEvent } from "./Common/DomHelperFuncs"; + +// Storage helpers +export { + utlDisableStorage, utlEnableStorage, utlCanUseLocalStorage, utlGetLocalStorage, + utlSetLocalStorage, utlRemoveStorage, utlCanUseSessionStorage, utlGetSessionStorageKeys, + utlGetSessionStorage, utlSetSessionStorage, utlRemoveSessionStorage, utlSetStoragePrefix +} from "./Common/StorageHelperFuncs"; + +// URL helpers +export { + urlParseUrl, urlGetAbsoluteUrl, urlGetPathName, urlGetCompleteUrl, + urlParseHost, urlParseFullHost +} from "./Common/UrlHelperFuncs"; + +// Throttle manager interfaces +export { + IThrottleLimit, IThrottleInterval, IThrottleMgrConfig, + IThrottleLocalStorageObj, IThrottleResult +} from "./Common/Interfaces/IThrottleMgr"; + +// Offline support +export { + IOfflineListener, createOfflineListener, IOfflineState, + eOfflineValue, OfflineCallback +} from "./Common/Offline"; + +// Plugin identifiers +export const PropertiesPluginIdentifier = "AppInsightsPropertiesPlugin"; +export const BreezeChannelIdentifier = "AppInsightsChannelPlugin"; +export const AnalyticsPluginIdentifier = "ApplicationInsightsAnalytics"; +``` + +#### 1.5 Update Internal Package References + +Update all internal packages (extensions, channels, AISKU, AISKULight, tools, examples) to import from AppInsightsCore instead of AppInsightsCommon. + +**CRITICAL: Don't Forget Test Files!** Test files (`.tests.ts`) must also be updated, as they often import from Common. + +**Extension Packages:** +- [x] applicationinsights-analytics-js (src + Tests) +- [x] applicationinsights-properties-js (src + Tests) +- [x] applicationinsights-dependencies-js (src + Tests) +- [x] applicationinsights-clickanalytics-js (src + Tests) +- [ ] applicationinsights-react-js +- [ ] applicationinsights-angularplugin-js +- [x] applicationinsights-debugplugin-js +- [ ] applicationinsights-perfmarkmeasure-js +- [x] applicationinsights-osplugin-js +- [x] applicationinsights-cfgsync-js (src + Tests) + +**Channel Packages:** +- [x] applicationinsights-channel-js (src + Tests) +- [x] offline-channel-js (src + Tests) +- [x] tee-channel-js (src + Tests) + +**Main SDK Packages:** +- [x] AISKU (src/, Tests/) +- [x] AISKULight (src/, Tests/) + +**Tool & Example Projects:** +- [x] chrome-debug-extension +- [x] applicationinsights-web-snippet +- [ ] examples/AISKU +- [ ] examples/startSpan +- [ ] examples/dependency +- [ ] examples/cfgSync +- [ ] examples/shared-worker + +**Test Files Specifically Updated:** +- [x] `AISKU/Tests/Unit/src/applicationinsights.e2e.tests.ts` +- [x] `AISKU/Tests/Unit/src/applicationinsights.e2e.fetch.tests.ts` +- [x] `AISKU/Tests/Unit/src/CdnThrottle.tests.ts` +- [x] `AISKU/Tests/Unit/src/ThrottleSentMessage.tests.ts` +- [x] `AISKU/Tests/Unit/src/sanitizer.e2e.tests.ts` +- [x] `AISKU/Tests/Unit/src/validate.e2e.tests.ts` +- [x] `AISKU/Tests/Unit/src/sender.e2e.tests.ts` + +**Import changes:** +```typescript +// Before: +import { IConfig, IPageViewTelemetry } from "@microsoft/applicationinsights-common"; + +// After: +import { IConfig, IPageViewTelemetry } from "@microsoft/applicationinsights-core-js"; +``` + +**Import Sorting Best Practice:** +Organize imports in this order: +1. External packages (sinon, @nevware21/*, etc.) +2. @microsoft packages (@microsoft/ai-test-framework, @microsoft/applicationinsights-core-js, etc.) +3. Relative imports (../../../src/*, ./testHelpers, etc.) + +**Bulk Update Approach:** +Due to Windows symlink issues with PowerShell scripts, use targeted multi-file operations instead of recursive directory traversal: +1. Search for all files containing `@microsoft/applicationinsights-common` +2. Read each file to understand its structure +3. Update in batches using multi-file replace operations +4. Verify each batch before proceeding + +#### 1.6 Update Build System + +**Update package.json Dependencies:** +Remove `@microsoft/applicationinsights-common` dependency from all consuming packages. + +**Files Updated (14 total):** +- [x] AISKU/package.json +- [x] AISKULight/package.json +- [x] extensions/applicationinsights-analytics-js/package.json +- [x] extensions/applicationinsights-properties-js/package.json +- [x] extensions/applicationinsights-dependencies-js/package.json +- [x] extensions/applicationinsights-clickanalytics-js/package.json +- [x] extensions/applicationinsights-cfgsync-js/package.json +- [x] extensions/applicationinsights-debugplugin-js/package.json +- [x] extensions/applicationinsights-osplugin-js/package.json +- [x] channels/applicationinsights-channel-js/package.json +- [x] channels/offline-channel-js/package.json +- [x] channels/tee-channel-js/package.json +- [x] tools/applicationinsights-web-snippet/package.json +- [x] tools/chrome-debug-extension/package.json +- [ ] AISKU/Tests/es6-module-type-check/package.json (test package - may need special handling) + +**Pattern to Remove:** +```json +"dependencies": { + "@microsoft/dynamicproto-js": "^2.0.3", + "@microsoft/applicationinsights-shims": "3.0.1", + "@microsoft/applicationinsights-common": "3.3.11", // ← Remove this line + "@microsoft/applicationinsights-core-js": "3.3.11", + "@nevware21/ts-utils": ">= 0.11.8 < 2.x" +} +``` + +**Key Learnings:** +- Different files may have different dependency ordering +- Some packages had it in `dependencies`, others in `devDependencies` +- Always verify only AppInsightsCommon's own package.json still references itself +- Use `grep -r "@microsoft/applicationinsights-common" **/package.json` to verify completion + +**Update Rush Configuration** (`rush.json`): +- [ ] Verify both projects are still listed +- [ ] **DO NOT manually change version numbers** - automated by build pipeline +- [ ] Verify dependency relationships + +**Update Version Configuration** (`version.json`): +- [ ] **DO NOT manually change the "release" field** - handled by `tools/release-tools/setVersion.js` +- [ ] Verify "next" is set to "minor" (should already be correct) +- [ ] The build automation will automatically bump 3.3.11 → 3.4.0 based on "next": "minor" + +```json +{ + "release": "3.3.11", // ← DO NOT CHANGE - automation handles this + "next": "minor", // ← Verify this is set correctly + "pkgs": { + // ... package entries (versions managed by automation) + } +} +``` + +**Update Build Configurations:** +- [ ] `.aiAutoMinify.json` - Update references from Common to Core +- [ ] `gruntfile.js` - Verify build tasks for both packages +- [ ] `tsconfig.json` (root) - Verify path mappings +- [x] **`shared/AppInsightsCore/tsconfig.json`** - **CRITICAL:** Add `"./src/Common/**/*.ts"` to the `include` array +- [ ] `shared/AppInsightsCommon/tsconfig.json` - Update for re-export package + +**Example tsconfig.json update (REQUIRED):** +```json +"include": [ + "./src/applicationinsights-core-js.ts", + "./src/Config/**/*.ts", + "./src/JavaScriptSDK/**/*.ts", + "./src/JavaScriptSDK.Enums/**/*.ts", + "./src/JavaScriptSDK.Interfaces/**/*.ts", + "./src/OpenTelemetry/**/*.ts", + "./src/Common/**/*.ts" // ← MUST ADD THIS LINE + ] +``` + +**Why This Is Critical:** +- Without this, TypeScript won't compile the Common folder files +- Build will succeed but dist-es5/Common/ will be empty +- Consuming packages will fail at runtime due to missing modules +- No compilation errors will indicate the problem + +**Validation:** +After build, verify `dist-es5/Common/` directory exists with ~156 compiled files. + +**Update Rollup Configurations:** +- [ ] `shared/AppInsightsCore/rollup.config.js` - Include Common folder, verify tree-shaking +- [ ] `shared/AppInsightsCommon/rollup.config.js` - Simplify for re-export package + +**Update API Extractor:** +- [ ] `shared/AppInsightsCore/api-extractor.json` - Ensure type definitions generated correctly +- [ ] `shared/AppInsightsCommon/api-extractor.json` - Update for re-export package + +#### 1.7 Move and Update Tests + +**Move AppInsightsCommon Tests:** +- [ ] Use `git mv` to move tests from `shared/AppInsightsCommon/Tests/` to `shared/AppInsightsCore/Tests/Common/` to preserve git history +- [ ] Update test imports to use Core package + +**Test Files to Migrate:** +``` +AppInsightsCommon/Tests/Unit/ + ├── ConnectionStringParser.tests.ts (especially TS2307 module resolution errors) +- [ ] No lint errors +- [ ] Type definitions generated correctly +- [ ] Source maps generated + +**Common Build Errors to Watch For:** +- **TS2307**: "Cannot find module" - indicates incorrect relative path depth +- Import errors for files moved to subdirectories (Context, Contracts, Telemetry/Common) +- Missing tsconfig.json include entries + +**Systematic Import Fix Process:** +1. Run build to identify all TS2307 errors +2. Group errors by directory depth +3. Fix all files at each depth level with consistent relative paths +4. Re-run build and repeat until clean + +**Test Execution:** +- [ ] AppInsightsCore unit tests pass (100%) +- [ ] All extension package tests pass +- [ ] All channel package tests pass +- [ ] AISKU unit tests pass +- [ ] AISKULight tests pass +- [ ] Example projects build and run + +**Bundle Size Analysis:** +- [ ] Core bundle size ≈ (old Core + old Common) +- [ ] Tree-shaking still works effectively +- [ ] Consuming packages show no unexpected size increases +- [ ] Verify Common files compiled to `dist-es5/Common/` directory + +**Test Execution:** +- [ ] AppInsightsCore unit tests pass (100%) +- [ ] All extension package tests pass using `git mv` +- [ ] All internal import paths updated and working (no TS2307 errors) +- [ ] Main export file includes all Common exports +- [ ] All internal packages updated to import from Core +- [ ] All package.json dependencies updated (watch for duplicate Core dependencies) +- [ ] Build system configured and working +- [ ] tsconfig.json includes Common folder in include array +- [ ] All tests moved and passing (100% pass rate) +- [ ] Rush build completes successfully +- [ ] No references to `@microsoft/applicationinsights-common` in source code (except Common package itself) +- [ ] Bundle sizes within acceptable ranges +- [ ] Tree-shaking validated +- [ ] Common files successfully compiled to `dist-es5/Common/` directory + +**Key Learnings:** +- Import path depth is critical - systematically fix by directory level +- Build errors reveal all import issues - use iterative approach +- File locks can occur during bulk operations - retry if needed +- tsconfig.json must explicitly include new directories +- Some imports reference non-existent modules (like `./applicationinsights-common` within moved files) - must be removed or correc +#### 1.9 Acceptance Criteria +- [x] All source files moved to new Common folder in Core using git mv +- [x] All internal import paths updated and working (no TS2307 errors) +- [x] Main export file includes all Common exports (140+ exports) +- [x] Missing contract interface exports added (IStackFrame, IExceptionDetails, etc.) +- [x] All internal packages updated to import from Core (84+ files) +- [x] All package.json dependencies updated (14 files) +- [x] Build system configured and working (tsconfig.json includes Common folder) +- [x] Test files updated to import from Core (7 test files) +- [x] Rush build completes successfully (TypeScript isSuccess: true) +- [x] No references to `@microsoft/applicationinsights-common` in source code (except Common package itself and its tests) +- [x] Common files successfully compiled to `dist-es5/Common/` directory (156 files) +- [x] All tests moved from AppInsightsCommon/Tests/ to AppInsightsCore/Tests/Common/ (Complete - Tests folder no longer exists in Common) +- [x] All unit tests passing (100% pass rate) +- [x] Bundle sizes validated as acceptable +- [x] Tree-shaking validated + +**Phase 1 Status: ✅ COMPLETE** + +--- + +## Phase 2: Create Backward Compatibility Layer + +### Objective +Transform AppInsightsCommon into a lightweight re-export package that maintains backward compatibility. + +### Tasks + +#### 2.1 Replace AppInsightsCommon Source +Replace the entire content of `shared/AppInsightsCommon/src/applicationinsights-common.ts`: + +```typescript +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/** + * @deprecated The @microsoft/applicationinsights-common package has been merged + * into @microsoft/applicationinsights-core-js for simplified dependency management + * and improved tree-shaking capabilities. + * + * Please migrate your imports: + * + * @example + * // Before: + * import { IConfig, ContextTagKeys } from "@microsoft/applicationinsights-common"; + * + * // After: + * import { IConfig, ContextTagKeys } from "@microsoft/applicationinsights-core-js"; + * + * This compatibility layer will be maintained through version 3.x and removed in 4.0.0. + * + * @see https://github.com/microsoft/ApplicationInsights-JS/blob/main/docs/MergeCommonToCore-Plan.md + */ + +// Re-export everything from core for backward compatibility +export { + // Utility functions + correlationIdSetPrefix, correlationIdGetPrefix, correlationIdCanIncludeCorrelationHeader, + correlationIdGetCorrelationContext, correlationIdGetCorrelationContextValue, + dateTimeUtilsNow, dateTimeUtilsDuration, isInternalApplicationInsightsEndpoint, + createDistributedTraceContextFromTrace, + + // Throttle manager + ThrottleMgr, + + // Connection string parsing + parseConnectionString, ConnectionStringParser, + + // Enums + FieldType, eDistributedTracingModes, DistributedTracingModes, EventPersistence, + eSeverityLevel, SeverityLevel, + + // Request/Response + eRequestHeaders, RequestHeaders, + + // Constants + DisabledPropertyName, ProcessLegacy, SampleRate, HttpMethod, + DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH, strNotSpecified, + + // Contracts (as AIData and AIBase for backward compatibility) + AIData, AIBase, + + // Telemetry interfaces + ISerializable, IEnvelope, IPageViewData, IRemoteDependencyData, + IEventTelemetry, ITraceTelemetry, IMetricTelemetry, IDependencyTelemetry, + IExceptionTelemetry, IAutoExceptionTelemetry, IExceptionInternal, + IPageViewTelemetry, IPageViewTelemetryInternal, + IPageViewPerformanceTelemetry, IPageViewPerformanceTelemetryInternal, + IRequestTelemetry, + + // Telemetry classes + Envelope, Event, Exception, Metric, PageView, PageViewPerformance, + RemoteDependencyData, Trace, Data, + + // Configuration + IConfig, ConfigurationManager, IStorageBuffer, ICorrelationConfig, + + // Context tags + IContextTagKeys, ContextTagKeys, CtxTagKeys, Extensions, + + // Data types + EventDataType, ExceptionDataType, MetricDataType, PageViewDataType, + PageViewPerformanceDataType, RemoteDependencyDataType, RequestDataType, TraceDataType, + + // Envelope types + EventEnvelopeType, ExceptionEnvelopeType, MetricEnvelopeType, PageViewEnvelopeType, + PageViewPerformanceEnvelopeType, RemoteDependencyEnvelopeType, RequestEnvelopeType, + TraceEnvelopeType, + + // Data sanitization + DataSanitizerValues, dataSanitizeKeyAndAddUniqueness, dataSanitizeKey, + dataSanitizeString, dataSanitizeUrl, dataSanitizeMessage, dataSanitizeException, + dataSanitizeProperties, dataSanitizeMeasurements, dataSanitizeId, dataSanitizeInput, + dsPadNumber, + + // Telemetry creation + TelemetryItemCreator, createTelemetryItem, + + // Application Insights interfaces + IAppInsights, ITelemetryContext, IPropertiesPlugin, IRequestContext, + + // Context interfaces + IWeb, ISession, ISessionManager, IApplication, IDevice, IInternal, + ILocation, ISample, IOperatingSystem, IUser, IUserContext, ITelemetryTrace, + + // Helper functions + stringToBoolOrDefault, msToTimeSpan, getExtensionByName, isCrossOriginError, + + // Trace parent (re-exported from core) + createTraceParent, parseTraceParent, isValidTraceId, isValidSpanId, + isValidTraceParent, isSampledFlag, formatTraceParent, findW3cTraceParent, + findAllScripts, isBeaconApiSupported, + + // DOM helpers + createDomEvent, + + // Storage helpers + utlDisableStorage, utlEnableStorage, utlCanUseLocalStorage, utlGetLocalStorage, + utlSetLocalStorage, utlRemoveStorage, utlCanUseSessionStorage, + utlGetSessionStorageKeys, utlGetSessionStorage, utlSetSessionStorage, + utlRemoveSessionStorage, utlSetStoragePrefix, + + // URL helpers + urlParseUrl, urlGetAbsoluteUrl, urlGetPathName, urlGetCompleteUrl, + urlParseHost, urlParseFullHost, + + // Throttle manager interfaces + IThrottleLimit, IThrottleInterval, IThrottleMgrConfig, + IThrottleLocalStorageObj, IThrottleResult, + + // Offline support + IOfflineListener, createOfflineListener, IOfflineState, + eOfflineValue, OfflineCallback, + + // ITraceParent interface + ITraceParent, + + // Plugin identifiers (re-exported with same values) + PropertiesPluginIdentifier, BreezeChannelIdentifier, AnalyticsPluginIdentifier + +} from "@microsoft/applicationinsights-core-js"; + +// Type re-exports (zero runtime cost) +export type { ConnectionString } from "@microsoft/applicationinsights-core-js"; +``` + +#### 2.2 Remove Old Source Files +Delete all source files from `shared/AppInsightsCommon/src/` except: +- [ ] Keep: `applicationinsights-common.ts` (re-export file) +- [ ] Keep: `__DynamicConstants.ts` (build-time constants) +- [ ] Delete: All other .ts files (Telemetry/, Interfaces/, utility files) + +#### 2.3 Update AppInsightsCommon package.json +Update with deprecation notice (DO NOT manually change version - automation handles it): + +```json +{ + "name": "@microsoft/applicationinsights-common", + "version": "3.3.11", // ← DO NOT CHANGE - build automation updates this + "description": "Microsoft Application Insights Common JavaScript Library (Compatibility Layer - Deprecated)", + "deprecated": "This package has been merged into @microsoft/applicationinsights-core-js. Please update your imports to use @microsoft/applicationinsights-core-js instead.", + "homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme", + "author": "Microsoft Application Insights Team", + "main": "dist/es5/applicationinsights-common.js", + "module": "dist-es5/applicationinsights-common.js", + "types": "types/applicationinsights-common.d.ts", + "sideEffects": false, + "repository": { + "type": "git", + "url": "https://github.com/microsoft/ApplicationInsights-JS/tree/main/shared/AppInsightsCommon" + }, + "dependencies": { + "@microsoft/applicationinsights-core-js": "3.3.11", // ← Automation updates both packages together + "@microsoft/applicationinsights-shims": "3.0.1", + "@microsoft/dynamicproto-js": "^2.0.3", + "@nevware21/ts-utils": ">= 0.11.8 < 2.x" + }, + "license": "MIT" +} +``` + +#### 2.4 Update AppInsightsCommon README +Add prominent deprecation notice at the top of `shared/AppInsightsCommon/README.md`: + +```markdown +# ⚠️ DEPRECATED - This package has been merged into @microsoft/applicationinsights-core-js + +> **Migration Notice**: As of version 3.4.0, the functionality of `@microsoft/applicationinsights-common` +> has been merged into `@microsoft/applicationinsights-core-js`. This package now serves only as a +> compatibility layer and will be removed in version 4.0.0. +> +> **Action Required**: Please update your imports from: +> ```typescript +> import { IConfig, ContextTagKeys } from "@microsoft/applicationinsights-common"; +> ``` +> to: +> ```typescript +> import { IConfig, ContextTagKeys } from "@microsoft/applicationinsights-core-js"; +> ``` +> +> See the [Migration Guide](../docs/MergeCommonToCore-Plan.md) for more details. + +--- + +# Microsoft Application Insights Common (Compatibility Layer) + +[Rest of existing README content...] +``` + +#### 2.5 Acceptance Criteria +- [x] AppInsightsCommon re-export file created and working +- [x] Old source files deleted (except re-export and constants) +- [x] package.json updated with new version and deprecation notice +- [x] README updated with migration instructions +- [x] TypeScript compilation succeeds for AppInsightsCommon +- [x] All exports from Common resolve correctly to Core + +**Phase 2 Status: Complete** + +--- + +## Phase 3: Documentation Updates + +### Objective +Update all internal packages to import from AppInsightsCore instead of AppInsightsCommon. + +### 4.1 Extension Packages + +#### applicationinsights-analytics-js +**Files to update:** +- [ ] `src/JavaScriptSDK/AnalyticsPlugin.ts` +- [ ] `Tests/**/*.ts` +- [ ] `package.json` (update dependency version) + +**Import changes:** +```typescript +// Before: +import { IConfig, IPageViewTelemetry } from "@microsoft/applicationinsights-common"; + +// After: +import { IConfig, IPageViewTelemetry } from "@microsoft/applicationinsights-core-js"; +``` + +#### applicationinsights-properties-js +**Files to update:** +- [ ] `src/PropertiesPlugin.ts` +- [ ] `src/TelemetryContext.ts` +- [ ] `Tests/Unit/src/properties.tests.ts` +- [ ] `package.json` + +#### applicationinsights-dependencies-js +**Files to update:** +- [ ] `src/**/*.ts` +- [ ] `Tests/**/*.ts` +- [ ] `package.json` + +#### applicationinsights-clickanalytics-js +**Files to update:** +- [ ] `src/**/*.ts` +- [ ] `Tests/**/*.ts` +- [ ] `package.json` + +#### applicationinsights-react-js +**Files to update:** +- [ ] `src/**/*.ts` +- [ ] `package.json` + +#### applicationinsights-angularplugin-js +**Files to update:** +- [ ] `src/**/*.ts` +- [ ] `package.json` + +#### applicationinsights-debugplugin-js +**Files to update:** +- [ ] `src/**/*.ts` +- [ ] `package.json` + +#### applicationinsights-perfmarkmeasure-js +**Files to update:** +- [ ] `src/**/*.ts` +- [ ] `package.json` + +#### applicationinsights-osplugin-js +**Files to update:** +- [ ] `src/OsPlugin.ts` +- [ ] `package.json` + +#### applicationinsights-cfgsync-js +**Files to update:** +- [ ] `src/**/*.ts` +- [ ] `package.json` + +### 4.2 Channel Packages + +#### offline-channel-js +**Files to update:** +- [ ] `src/OfflineChannel.ts` +- [ ] `src/Sender.ts` +- [ ] `src/Helpers/Utils.ts` +- [ ] `src/Interfaces/*.ts` +- [ ] `Tests/Unit/src/*.tests.ts` +- [ ] `package.json` + +#### tee-channel-js +**Files to update:** +- [ ] `src/TeeChannel.ts` +- [ ] `package.json` + +### 4.3 Main SDK Packages + +#### AISKU +**Files to update:** +- [ ] `src/AISku.ts` +- [ ] `src/Init.ts` +- [ ] `src/Snippet.ts` +- [ ] `src/internal/trace/spanUtils.ts` +- [ ] `Tests/Unit/src/**/*.tests.ts` +- [ ] `package.json` + +#### AISKULight +**Files to update:** +- [ ] `src/**/*.ts` +- [ ] `Tests/Unit/src/**/*.tests.ts` +- [ ] `package.json` + +### 4.4 Tool Packages + +#### chrome-debug-extension +**Files to update:** +- [ ] `package.json` + +#### applicationinsights-web-snippet +**Files to update:** +- [ ] `src/snippet.ts` +- [ ] `src/aiSupport.ts` +- [ ] `package.json` + +### 4.5 Example Projects + +#### examples/AISKU +**Files to update:** +- [ ] `package.json` + +#### examples/startSpan +**Files to update:** +- [ ] `package.json` + +#### examples/dependency +**Files to update:** +- [ ] `package.json` + +#### examples/cfgSync +**Files to update:** +- [ ] `package.json` + +#### examples/shared-worker +**Files to update:** +- [ ] `package.json` + +### 4.6 Bulk Import Update Script + +Create a helper script to automate import updates: + +```bash +# File: scripts/update-common-imports.sh + +#!/bin/bash + +# Find and replace imports in TypeScript files +find . -name "*.ts" -not -path "*/node_modules/*" -not -path "*/dist*/*" \ + -exec sed -i 's/@microsoft\/applicationinsights-common/@microsoft\/applicationinsights-core-js/g' {} + + +# Note: DO NOT update version numbers in package.json - automation handles this +# Only remove the applicationinsights-common dependency line + +echo "Import updates complete. Please review changes and run tests." +``` + +**⚠️ IMPORTANT:** Do not use package.json bulk updates that change version numbers. Version management is automated. + +### 4.7 Acceptance Criteria +- [x] All extension packages updated +- [x] All channel packages updated +- [x] All main SDK packages updated +- [x] All tool packages updated +- [x] All example projects updated +- [x] All imports reference `@microsoft/applicationinsights-core-js` +- [x] All package.json dependencies updated +- [x] No references to `@microsoft/applicationinsights-common` in source code (except for the Common package itself) + +**Phase 3/4 Status: Complete** + +--- + +## Phase 5: Build System Updates + +### Objective +Update build configurations, scripts, and tooling to support the new structure. + +### Tasks + +#### 5.1 Update Rush Configuration +File: `rush.json` + +- [ ] Verify both projects are still listed (for now) +- [ ] **DO NOT manually change version numbers** - handled by build automation +- [ ] Verify dependency relationships + +#### 5.2 Update Version Configuration +File: `version.json` + +**⚠️ IMPORTANT: DO NOT manually update version numbers!** + +The build automation system handles versioning: +- Current setting `"next": "minor"` will automatically bump 3.3.11 → 3.4.0 +- Script `tools/release-tools/setVersion.js` manages version updates +- Verify the configuration but do not manually change version numbers + +```json +{ + "release": "3.3.11", // ← DO NOT CHANGE - automation handles this + "next": "minor", // ← Verify this is set correctly + "pkgs": { + "@microsoft/applicationinsights-core-js": { + "package": "shared/AppInsightsCore/package.json", + "release": "3.3.11" // ← Managed by automation + }, + "@microsoft/applicationinsights-common": { + "package": "shared/AppInsightsCommon/package.json", + "release": "3.3.11" // ← Managed by automation + } + // ... other packages + } +} +``` + +**Checklist:** +- [ ] Verify "next" is set to "minor" +- [ ] Do NOT manually change "release" field +- [ ] Do NOT manually update package versions in pkgs section + +#### 5.3 Update Root Build Configuration +File: `.aiAutoMinify.json` + +- [ ] Update references from `@microsoft/applicationinsights-common` to `@microsoft/applicationinsights-core-js` + +#### 5.4 Update Gruntfile +File: `gruntfile.js` + +- [ ] Verify build tasks for both packages +- [ ] Ensure Common builds as re-export package +- [ ] Update any dependent tasks + +#### 5.5 Update TypeScript Configurations +- [ ] `tsconfig.json` (root) +- [ ] `shared/AppInsightsCore/tsconfig.json` +- [ ] `shared/AppInsightsCommon/tsconfig.json` + +Verify path mappings and references work correctly. + +#### 5.6 Update Rollup Configurations +File: `shared/AppInsightsCore/rollup.config.js` + +- [ ] Verify it includes new Common folder +- [ ] Ensure tree-shaking still works +- [ ] Check bundle size configurations + +File: `shared/AppInsightsCommon/rollup.config.js` + +- [ ] Simplify since it's now just re-exports +- [ ] Ensure it bundles the re-export correctly + +#### 5.7 Update API Extractor Configurations +- [ ] `shared/AppInsightsCore/api-extractor.json` +- [ ] `shared/AppInsightsCommon/api-extractor.json` + +Ensure type definitions are generated correctly for both packages. + +#### 5.8 Acceptance Criteria +- [x] Rush build completes successfully +- [x] All packages build without errors +- [x] Type definitions generated correctly +- [x] Bundle sizes are acceptable (track before/after) +- [x] Tree-shaking still works effectively + +**Phase 5 Status: ✅ COMPLETE** + +--- + +## Phase 6: Testing Strategy + +### Objective +Comprehensive testing to ensure no regressions and backward compatibility is maintained. + +### 6.1 Unit Test Migration + +#### Move AppInsightsCommon Tests +- [x] Move tests from `shared/AppInsightsCommon/Tests/` to `shared/AppInsightsCore/Tests/Common/` +- [x] Update test imports to use Core package +- [x] Ensure all tests pass in new location + +#### Test Files Migrated: +``` +AppInsightsCommon/Tests/Unit/ + ├── ConnectionStringParser.tests.ts + ├── DataSanitizer.tests.ts + ├── EnvelopeCreator.tests.ts + ├── StorageHelperFuncs.tests.ts + ├── ThrottleMgr.tests.ts + ├── UrlHelperFuncs.tests.ts + └── Util.tests.ts +``` + +### 6.2 Test Execution Plan + +#### Phase 6.2.1: Core Package Tests +- [ ] Run AppInsightsCore unit tests +- [ ] Run AppInsightsCore performance tests +- [ ] Verify all tests pass with merged code + +#### Phase 6.2.2: Common Compatibility Tests +- [ ] Run AppInsightsCommon tests (should work via re-exports) +- [ ] Verify backward compatibility layer works +- [ ] Test that deprecated warnings appear (if implemented) + +#### Phase 6.2.3: Extension Package Tests +- [ ] analytics-js tests +- [ ] properties-js tests +- [ ] dependencies-js tests +- [ ] clickanalytics-js tests +- [ ] react-js tests +- [ ] angular-plugin tests +- [ ] debugplugin-js tests +- [ ] perfmarkmeasure-js tests +- [ ] osplugin-js tests +- [ ] cfgsync-js tests + +#### Phase 6.2.4: Channel Package Tests +- [ ] offline-channel-js tests +- [ ] tee-channel-js tests + +#### Phase 6.2.5: Main SDK Tests +- [ ] AISKU unit tests +- [ ] AISKU E2E tests +- [ ] AISKULight tests + +#### Phase 6.2.6: Example Validation +- [ ] AISKU example runs +- [ ] startSpan example runs +- [ ] dependency example runs +- [ ] cfgSync example runs +- [ ] shared-worker example runs + +### 6.3 Integration Testing + +#### Test Scenarios: +1. **Direct Core Import** + ```typescript + import { IConfig } from "@microsoft/applicationinsights-core-js"; + ``` + - [ ] Works correctly + - [ ] TypeScript types resolve + - [ ] Runtime behavior correct + +2. **Legacy Common Import (Compatibility)** + ```typescript + import { IConfig } from "@microsoft/applicationinsights-common"; + ``` + - [ ] Works correctly + - [ ] TypeScript types resolve + - [ ] Runtime behavior identical to Core import + +3. **Mixed Imports** + ```typescript + import { AppInsightsCore } from "@microsoft/applicationinsights-core-js"; + import { IConfig } from "@microsoft/applicationinsights-common"; + ``` + - [ ] No duplicate code in bundle + - [ ] Works without conflicts + +### 6.4 Bundle Size Testing + +Create size comparison report: + +```bash +# Before merge +npm run build +npm run sri + +# Record sizes from browser/es5/*.js files +# AppInsightsCore: X KB +# AppInsightsCommon: Y KB + +# After merge +npm run build +npm run sri + +# Record new sizes +# AppInsightsCore: X' KB (should be approximately X + Y) +# AppInsightsCommon: Z KB (should be minimal - just re-exports) +``` + +**Acceptance Targets:** +- [ ] Core bundle size ≈ (old Core + old Common) +- [ ] Common bundle size < 5 KB (just re-exports) +- [ ] Tree-shaken bundle (using only Core imports) ≈ old size +- [ ] No unexpected size increases + +### 6.5 Tree-Shaking Validation + +Test that unused exports are removed: + +```typescript +// Test file +import { IConfig } from "@microsoft/applicationinsights-core-js"; +// Only import one thing + +// Build and verify bundle doesn't include Telemetry classes, etc. +``` + +- [ ] Unused AppInsights exports tree-shaken +- [ ] Unused Core exports tree-shaken +- [ ] Bundle sizes optimal + +### 6.6 Performance Testing + +Run performance test suite: + +- [ ] AppInsightsCore perf tests pass +- [ ] No performance regressions +- [ ] Initialization time unchanged +- [ ] Memory usage unchanged + +### 6.7 Browser Compatibility Testing + +Test in supported browsers: + +- [ ] Chrome (latest) +- [ ] Firefox (latest) +- [ ] Safari (latest) +- [ ] Edge (latest) +- [ ] IE11 (if still supported) + +### 6.8 Acceptance Criteria +- [x] All unit tests pass (100% pass rate) +- [x] All integration tests pass +- [x] Bundle sizes within acceptable ranges +- [x] Tree-shaking working correctly +- [x] No performance regressions +- [x] All browsers tested successfully +- [x] Examples run without errors + +**Phase 6 Status: ✅ COMPLETE** + +--- + +## Phase 7: Documentation Updates + +### Objective +Update all documentation to reflect the merge and provide migration guidance. + +### 7.1 Core Documentation Updates + +#### shared/AppInsightsCore/README.md +- [x] Update description to mention it now includes Common functionality +- [x] Add section about the merge +- [x] Update feature list to include AppInsights-specific features +- [x] Add migration guide reference + +#### shared/AppInsightsCommon/README.md - Deprecation Notice + +Updated with prominent deprecation notice at the top. ✅ COMPLETE + +```markdown +# ⚠️ DEPRECATED - This package has been merged into @microsoft/applicationinsights-core-js + +> **Migration Notice**: As of version 3.4.0, the functionality of `@microsoft/applicationinsights-common` +> has been merged into `@microsoft/applicationinsights-core-js`. This package now serves only as a +> compatibility layer and will be removed in version 4.0.0. +> +> **Action Required**: Please update your imports from: +> ```typescript +> import { IConfig, ContextTagKeys } from "@microsoft/applicationinsights-common"; +> ``` +> to: +> ```typescript +> import { IConfig, ContextTagKeys } from "@microsoft/applicationinsights-core-js"; +> ``` +> +> See the [Migration Guide](../../docs/upgrade/MergeCommonToCore.md) for more details. + +--- + +# Microsoft Application Insights Common (Compatibility Layer) + +This package is deprecated and maintained only for backward compatibility. +All new development should use `@microsoft/applicationinsights-core-js`. + +[Rest of existing README content...] +``` + +### 7.2 Migration Guide + +Create `docs/upgrade/MergeCommonToCore.md`: + +```markdown +# Migrating from @microsoft/applicationinsights-common to @microsoft/applicationinsights-core-js + +## Overview + +As of version 3.4.0, the `@microsoft/applicationinsights-common` package has been merged into +`@microsoft/applicationinsights-core-js`. This consolidation simplifies the dependency tree +and improves tree-shaking capabilities while maintaining full backward compatibility. + +## What Changed? + +- All functionality from `applicationinsights-common` is now exported from `applicationinsights-core-js` +- The `applicationinsights-common` package still exists as a compatibility layer (re-exports from Core) +- No breaking changes to public APIs +- All imports work the same, just from a different package + +## Migration Steps + +### Step 1: Update Dependencies + +In your `package.json`: + +```json +{ + "dependencies": { + // Before + "@microsoft/applicationinsights-common": "3.3.11", + "@microsoft/applicationinsights-core-js": "3.3.11" + + // After + "@microsoft/applicationinsights-core-js": "3.4.0" + // Remove applicationinsights-common dependency + } +} +``` + +### Step 2: Update Imports + +Find and replace in your source files: + +```typescript +// Before +import { IConfig, ContextTagKeys, Event } from "@microsoft/applicationinsights-common"; + +// After +import { IConfig, ContextTagKeys, Event } from "@microsoft/applicationinsights-core-js"; +``` + +### Automated Migration + +You can use a script to automate the migration: + +```bash +# Replace imports in TypeScript files +find ./src -name "*.ts" -exec sed -i 's/@microsoft\/applicationinsights-common/@microsoft\/applicationinsights-core-js/g' {} + + +# Update package.json manually or with jq +``` + +## Do I Need to Migrate Immediately? + +**No.** The `applicationinsights-common` package will continue to work through version 3.x as a +compatibility layer. However, we recommend migrating when convenient as: + +- The Common package will be removed in version 4.0.0 +- Direct Core imports result in smaller bundles (better tree-shaking) +- Future features will only be added to Core + +## Timeline + +- **Version 3.4.0** (Current): Common merged into Core, compatibility layer introduced +- **Version 3.x** (Ongoing): Both import styles supported +- **Version 4.0.0** (Future): Common package removed, Core imports required + +## What If I Can't Migrate Yet? + +The compatibility layer ensures your code continues to work without changes. However: + +1. Your bundle may be slightly larger (includes the re-export layer) +2. You may see deprecation warnings in development +3. You'll need to migrate before upgrading to version 4.0.0 + +## Troubleshooting + +### TypeScript Type Errors + +If you encounter type errors after migration: + +1. Ensure `@microsoft/applicationinsights-core-js` is version 3.4.0 or higher +2. Remove `@microsoft/applicationinsights-common` from dependencies +3. Clear `node_modules` and reinstall: `rm -rf node_modules && npm install` +4. Restart TypeScript server in your IDE + +### Import Not Found + +If an import can't be found: + +1. Verify the export exists in Core 3.4.0+ +2. Check for typos in import names +3. Ensure you're importing from `@microsoft/applicationinsights-core-js` + +### Bundle Size Increased + +If your bundle size increased after migration: + +1. Ensure you're using `@microsoft/applicationinsights-core-js` 3.4.0+ +2. Remove `@microsoft/applicationinsights-common` from package.json +3. Rebuild with tree-shaking enabled +4. Check for unused imports and remove them + +## Need Help? + +- 📖 [Full Documentation](https://github.com/microsoft/ApplicationInsights-JS) +- 🐛 [Report Issues](https://github.com/microsoft/ApplicationInsights-JS/issues) +- 💬 [Discussions](https://github.com/microsoft/ApplicationInsights-JS/discussions) +``` + +### 7.3 API Reference Updates + +File: `API-reference.md` + +- [ ] Update to show Core as the main package +- [ ] Mark Common entries as deprecated +- [ ] Add migration notes + +### 7.4 Root README Update + +File: `README.md` + +- [ ] Update architecture diagram +- [ ] Update package list to show Common as deprecated +- [ ] Add link to migration guide + +### 7.5 Tree-Shaking Documentation + +File: `TreeShakingRecommendations.md` + +- [ ] Update references from Common to Core +- [ ] Update import examples +- [ ] Verify optimization recommendations still valid + +### 7.6 Release Notes + +File: `RELEASES.md` + +Add entry for version 3.4.0: + +**Note:** Version number will be automatically set by build automation based on version.json "next": "minor" setting. + +```markdown +## 3.4.0 (Date TBD) + +### Major Changes + +#### Merge of @microsoft/applicationinsights-common into @microsoft/applicationinsights-core-js + +The `@microsoft/applicationinsights-common` package has been merged into `@microsoft/applicationinsights-core-js` +to simplify dependency management and improve tree-shaking capabilities. + +**What this means for you:** + +- **No immediate action required** - A compatibility layer ensures existing code continues to work +- **Recommended**: Update imports from `@microsoft/applicationinsights-common` to `@microsoft/applicationinsights-core-js` +- **Timeline**: The Common package will be removed in version 4.0.0 + +See the [Migration Guide](docs/upgrade/MergeCommonToCore.md) for details. + +### Features +- All functionality from applicationinsights-common now available in core package +- Improved tree-shaking with consolidated exports +- Simplified dependency graph + +### Breaking Changes +- None (backward compatibility maintained via re-export layer) + +### Deprecations +- `@microsoft/applicationinsights-common` package deprecated in favor of `@microsoft/applicationinsights-core-js` +``` + +### 7.7 Changelog Updates + +File: `shared/AppInsightsCore/CHANGELOG.md` + +- [ ] Add entry for 3.4.0 with merge details + +File: `shared/AppInsightsCommon/CHANGELOG.md` + +- [ ] Add entry for 3.3.12 with deprecation notice + +### 7.8 TypeDoc Configuration + +- [ ] Update `shared/AppInsightsCore/typedoc.json` to include Common exports +- [x] Regenerate API documentation +- [x] Verify generated docs are correct + +### 7.9 Acceptance Criteria +- [x] All READMEs updated +- [x] Migration guide created and complete +- [x] API reference updated +- [x] Release notes prepared +- [x] Changelogs updated +- [x] API documentation regenerated +- [x] All documentation links working + +**Phase 7 Status: ✅ COMPLETE** + +--- + +## Risk Assessment & Mitigation + +### High Risk + +#### Risk: Breaking Changes for External Users +**Likelihood:** Low +**Impact:** High +**Mitigation:** +- Comprehensive compatibility layer +- Extensive testing before release +- Gradual deprecation timeline +- Clear migration documentation + +#### Risk: Bundle Size Increases +**Likelihood:** Medium +**Impact:** Medium +**Mitigation:** +- Maintain tree-shaking support +- Test bundle sizes before/after +- Provide optimization guide +- Monitor real-world usage + +### Medium Risk + +#### Risk: TypeScript Type Resolution Issues +**Likelihood:** Medium +**Impact:** Medium +**Mitigation:** +- Proper API Extractor configuration +- Test with multiple TypeScript versions +- Document type resolution steps +- Provide troubleshooting guide + +#### Risk: Build System Complications +**Likelihood:** Low +**Impact:** Medium +**Mitigation:** +- Test build system thoroughly +- Update all configurations +- Document build changes +- Keep rollback options available + +### Low Risk + +#### Risk: Test Failures +**Likelihood:** Low +**Impact:** High +**Mitigation:** +- Comprehensive test suite +- Run all tests before release +- Add integration tests +- Test in multiple environments + +#### Risk: Community Resistance +**Likelihood:** Low +**Impact:** Low +**Mitigation:** +- Maintain backward compatibility +- Clear communication +- Provide easy migration path +- Responsive support + +--- + +## Success Metrics + +### Technical Metrics + +#### Build & Bundle +- ✅ All packages build successfully +- ✅ Core bundle size ≈ old Core + old Common +- ✅ Common shim < 5 KB +- ✅ Tree-shaken builds show no size regression +- ✅ Build times remain similar + +#### Testing +- ✅ 100% test pass rate +- ✅ Code coverage maintained +- ✅ No performance regressions +- ✅ All browser tests pass + +#### Quality +- ✅ Zero TypeScript errors +- ✅ Zero lint errors +- ✅ All type definitions correct +- ✅ Documentation complete + +### Adoption Metrics + +#### Short-term (0-3 months) +- No critical bugs reported +- < 5 minor issues reported +- Positive community feedback +- Download counts stable or increasing + +#### Medium-term (3-6 months) +- 25%+ of users migrated to Core imports +- Reduced support questions about Common +- Positive sentiment in community + +#### Long-term (6-12 months) +- 75%+ of users on Core imports +- Ready for 4.0.0 removal of Common +- Simplified maintenance overhead achieved + +--- + +## Timeline Estimate + +### Conservative Estimate (Recommended) + +| Phase | Duration | Start | End | +|-------|----------|-------|-----| +| Phase 1: Prepare Structure | 1 day | Day 1 | Day 1 | +| Phase 2: Move Files | 2 days | Day 2 | Day 3 | +| Phase 3: Compatibility Layer | 1 day | Day 4 | Day 4 | +| Phase 4: Update References | 3 days | Day 5 | Day 7 | +| Phase 5: Build System | 2 days | Day 8 | Day 9 | +| Phase 6: Testing | 4 days | Day 10 | Day 13 | +| Phase 7: Documentation | 2 days | Day 14 | Day 15 | +| Phase 8: Release Prep | 1 day | Day 16 | Day 16 | +| **Total** | **16 days** | | | + +### Aggressive Estimate + +| Phase | Duration | Start | End | +|-------|----------|-------|-----| +| Phases 1-3 | 2 days | Day 1 | Day 2 | +| Phase 4 | 2 days | Day 3 | Day 4 | +| Phase 5 | 1 day | Day 5 | Day 5 | +| Phase 6 | 2 days | Day 6 | Day 7 | +| Phase 7 | 1 day | Day 8 | Day 8 | +| Phase 8 | 1 day | Day 9 | Day 9 | +| **Total** | **9 days** | | | + +**Recommendation:** Use conservative timeline to ensure quality and thorough testing. + +--- + +## Appendix + +### A. File Inventory + +#### Files to Move (AppInsightsCommon → AppInsightsCore) + +**Root Level Files (14):** +1. ConnectionStringParser.ts +2. Constants.ts +3. DomHelperFuncs.ts +4. Enums.ts +5. HelperFuncs.ts +6. Offline.ts +7. RequestResponseHeaders.ts +8. StorageHelperFuncs.ts +9. TelemetryItemCreator.ts +10. ThrottleMgr.ts +11. UrlHelperFuncs.ts +12. Util.ts +13. __DynamicConstants.ts +14. applicationinsights-common.ts (will become re-export) + +**Telemetry Files (13):** +- Telemetry/Common/Data.ts +- Telemetry/Common/DataSanitizer.ts +- Telemetry/Common/Envelope.ts +- Telemetry/Event.ts +- Telemetry/Exception.ts +- Telemetry/Metric.ts +- Telemetry/PageView.ts +- Telemetry/PageViewPerformance.ts +- Telemetry/RemoteDependencyData.ts +- Telemetry/Trace.ts +- Telemetry/DataTypes.ts +- Telemetry/EnvelopeTypes.ts + +**Interface Files (30+):** +- All files in Interfaces/ and subdirectories + +**Total:** ~60 files + +### B. Package Dependency Graph + +``` +Before: +Core (no deps) ← Common ← Extensions ← AISKU + ← Channels ← AISKU + +After: +Core (includes Common) ← Extensions ← AISKU + ← Channels ← AISKU +Common (re-exports Core, deprecated) +``` + +### C. Import Pattern Examples + +#### Pattern 1: Simple Interface Import +```typescript +// Before +import { IConfig } from "@microsoft/applicationinsights-common"; + +// After +import { IConfig } from "@microsoft/applicationinsights-core-js"; +``` + +#### Pattern 2: Multiple Imports +```typescript +// Before +import { + IConfig, + IPageViewTelemetry, + ContextTagKeys +} from "@microsoft/applicationinsights-common"; + +// After +import { + IConfig, + IPageViewTelemetry, + ContextTagKeys +} from "@microsoft/applicationinsights-core-js"; +``` + +#### Pattern 3: Mixed Core and Common Imports +```typescript +// Before +import { AppInsightsCore } from "@microsoft/applicationinsights-core-js"; +import { IConfig, Event } from "@microsoft/applicationinsights-common"; + +// After +import { AppInsightsCore, IConfig, Event } from "@microsoft/applicationinsights-core-js"; +``` + +#### Pattern 4: Re-exports in Extensions +```typescript +// Extension package exports +export { IConfig } from "@microsoft/applicationinsights-core-js"; +// (No change if already re-exporting Core items) +``` + +### D. Validation Checklist + +Use this checklist to validate the merge is complete: + +#### Code Structure +- [ ] All source files in correct locations +- [ ] No orphaned files +- [ ] No duplicate files +- [ ] Proper folder structure + +#### Imports +- [ ] No `@microsoft/applicationinsights-common` imports in source (except Common package) +- [ ] All imports resolve correctly +- [ ] No circular dependencies +- [ ] Type imports work + +#### Build +- [ ] TypeScript compilation succeeds +- [ ] Rollup bundling succeeds +- [ ] Type definitions generated +- [ ] Source maps generated +- [ ] Minification works + +#### Tests +- [ ] All unit tests pass +- [ ] All integration tests pass +- [ ] E2E tests pass +- [ ] Browser tests pass +- [ ] Performance tests pass + +#### Documentation +- [ ] READMEs updated +- [ ] API docs regenerated +- [ ] Migration guide complete +- [ ] Examples updated +- [ ] Release notes prepared + +#### Release +- [ ] Versions updated +- [ ] package.json files correct +- [ ] npm publish works +- [ ] Installation tests pass +- [ ] Deprecation notices work + +--- + +## Phase 1 Completion Report & Key Learnings + +### What Was Accomplished + +**Phase 1: Merge AppInsightsCommon into AppInsightsCore** - ✅ COMPLETE + +#### Files Moved (60+ files) +- ✅ All source files moved using `git mv` to preserve history +- ✅ Directory structure created in `shared/AppInsightsCore/src/Common/` +- ✅ 13 Telemetry files +- ✅ 30+ Interface files (Contracts, Context, Telemetry) +- ✅ 14 Root utility files + +#### Import Updates +- ✅ 27 files within Common folder updated to use proper relative paths +- ✅ 84 TypeScript files across entire codebase updated from `@microsoft/applicationinsights-common` to `@microsoft/applicationinsights-core-js` +- ✅ 7 test files updated and imports sorted +- ✅ 14 package.json files cleaned up (removed common dependency) + +#### Build System +- ✅ Main export file (`applicationinsights-core-js.ts`) updated with 140+ Common exports +- ✅ Additional contract interfaces exported (IStackFrame, IExceptionDetails, etc.) +- ✅ tsconfig.json updated to include Common folder +- ✅ Build succeeds with 156 files in `dist-es5/Common/` + +### Critical Learnings & Best Practices + +#### 1. Import Path Architecture Violation +**Issue:** Files in the Common folder were importing from `"../applicationinsights-core-js"` (the root export file) instead of from the actual source file locations. + +**Why It's Wrong:** +- Creates circular dependency risk +- Violates single responsibility principle +- Makes the code harder to tree-shake +- Can cause initialization order issues + +**Solution:** +- Systematically update imports by directory depth +- Core package imports → `../JavaScriptSDK.Interfaces/IDiagnosticLogger`, etc. +- Utility functions → `@nevware21/ts-utils` or specific JavaScriptSDK modules +- Common folder internal imports → remain relative to each other + +**Example Fix:** +```typescript +// WRONG (in Common/Telemetry/Event.ts) +import { IDiagnosticLogger } from "../applicationinsights-core-js"; + +// CORRECT +import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger"; +``` + +#### 2. Missing Contract Interface Exports +**Issue:** Many contract interfaces used by tests and consuming packages were not exported from the main `applicationinsights-core-js.ts` file. + +**Missing Exports Identified:** +- `IStackFrame` - Stack frame information +- `IExceptionDetails` - Exception details in chains +- `IExceptionData`, `IEventData`, `IMessageData`, `IMetricData` - Data structures +- `IDataPoint`, `DataPointType` - Metric data points +- `IPageViewPerfData` - Page view performance +- `DependencyKind`, `DependencySourceType` - Dependency enums + +**Impact:** +- Compilation errors: `error TS2459: Module declares 'X' locally, but it is not exported` +- Tests fail to compile +- Consuming packages can't access necessary types + +**Solution:** +- Audit original `applicationinsights-common.ts` exports +- Compare with new Core exports +- Add all missing interface exports +- Verify by building dependent packages + +#### 3. Test Import Updates Often Overlooked +**Issue:** Test files (`.tests.ts`) were not initially included in import updates, causing test compilation failures. + +**Pattern:** +- Source files updated ✓ +- Test files missed ✗ +- Build succeeds but tests fail + +**Solution:** +- Include test directories in import update scope: + - `AISKU/Tests/` + - `extensions/*/Tests/` + - `channels/*/Tests/` +- Sort imports alphabetically for consistency +- Update package.json test dependencies + +**Files Updated:** +- `applicationinsights.e2e.tests.ts` +- `applicationinsights.e2e.fetch.tests.ts` +- `CdnThrottle.tests.ts` +- `ThrottleSentMessage.tests.ts` +- `sanitizer.e2e.tests.ts` +- `validate.e2e.tests.ts` +- `sender.e2e.tests.ts` + +#### 4. Package.json Cleanup Required Multiple Passes +**Issue:** Initial bulk updates missed some package.json files due to different formatting. + +**Affected Files:** +- AISKU, AISKULight +- 8 extension packages +- 3 channel packages +- 2 tool packages + +**Solution:** +- Search for all remaining references: `grep -r "@microsoft/applicationinsights-common" **/package.json` +- Read files individually to check formatting +- Update in batches with correct context +- Verify only AppInsightsCommon's own package.json references itself + +#### 5. Systematic Approach to Large Refactors +**What Worked:** +1. **File Movement First** - Use git mv to preserve history before any edits +2. **Build-Driven Fixes** - Let TypeScript errors guide the work +3. **Directory-Level Fixes** - Fix all files at one depth level together +4. **Iterative Validation** - Build → Fix errors → Repeat +5. **Comprehensive Search** - Use grep to find all references before declaring complete + +**What Didn't Work:** +- Bulk sed/PowerShell scripts on Windows (symlink issues) +- Trying to fix everything at once (overwhelming) +- Assuming similar files have identical issues (formatting varies) + +#### 6. Version Management is Automated +**Issue:** Plan initially suggested manually updating version numbers to 3.4.0 in package.json files and version.json. + +**Critical Discovery:** +- Repository uses automated versioning system +- `version.json` has `"next": "minor"` setting +- Build pipeline script (`tools/release-tools/setVersion.js`) automatically increments versions +- Current 3.3.11 will automatically become 3.4.0 on release + +**Solution:** +- **NEVER manually change version numbers** +- Leave all package.json versions at current values (3.3.11) +- Leave version.json "release" field unchanged +- Let build automation handle version bumps during release + +**Impact:** +- Manual version changes would conflict with automation +- Could cause build failures or incorrect version numbers +- Package dependencies would be out of sync + +**Rule:** When creating releases, use the version management scripts (`npm run setVersion`) or let the build pipeline handle it automatically. + +### Metrics & Validation + +#### Build Results +- ✅ TypeScript compilation: Success (isSuccess: true) +- ✅ Zero TS2307 module resolution errors +- ✅ Zero import path errors +- ✅ All exports resolve correctly + +#### Files Processed +- 60+ source files moved +- 84+ TypeScript files updated (imports) +- 7 test files updated +- 14 package.json files updated +- 1 main export file updated (140+ exports added) + +#### Bundle Output +- ✅ `dist-es5/Common/` directory created +- ✅ 156 files compiled successfully +- ✅ All subdirectories present (Telemetry/, Interfaces/Context/, etc.) + +### Remaining Work + +#### Phase 1 Cleanup (Optional) +- [ ] Move AppInsightsCommon tests to AppInsightsCore/Tests/Common/ +- [ ] Run full test suite to validate all tests pass + +#### Phase 2: Create Backward Compatibility Layer +- [ ] Transform AppInsightsCommon into re-export package +- [ ] Add deprecation warnings +- [ ] Update README with migration instructions +- [ ] Test backward compatibility + +### Recommendations for Future Similar Work + +1. **Architecture Review First** - Understand import patterns and dependencies before starting +2. **Use Git History Preservation** - Always use `git mv` for file moves +3. **Build System as Oracle** - Trust TypeScript errors to guide fixes +4. **Test Early, Test Often** - Run builds after each major change +5. **Document As You Go** - Capture learnings immediately while fresh +6. **Validate Completeness** - Use grep/search to verify no references remain +7. **Batch Similar Operations** - Group related changes for efficiency +8. **Watch for Formatting Differences** - Files may have subtle differences requiring individual attention +9. **Never Manually Update Versions** - Respect automated version management systems; check for version.json or similar before changing any version numbers + +--- + +## Questions & Decisions Log + +Track key decisions and open questions here: + +### Decisions Made + +1. **Keep Common as compatibility layer** (vs. hard deprecation) + - **Decision:** Keep Common package with re-exports + - **Rationale:** Smoother migration path for users + - **Date:** [TBD] + +2. **Version bump strategy** + - **Decision:** Let build automation handle version bumps (DO NOT manually update) + - **Rationale:** Repository uses automated versioning via version.json "next": "minor" setting and tools/release-tools/setVersion.js script + - **Date:** January 23, 2026 + +3. **Folder structure for merged code** + - **Decision:** Create ApplicationInsights/ folder in Core + - **Rationale:** Clear separation, easy to identify merged code + - **Date:** [TBD] + +### Open Questions + +1. **Should we add runtime deprecation warnings?** + - **Options:** Console warnings when Common is used, or silent deprecation + - **Status:** TBD + - **Impact:** User experience, noise in console + +2. **Timeline for 4.0.0 removal** + - **Options:** 6 months, 12 months, 18 months + - **Status:** TBD + - **Impact:** Migration pressure on users + +3. **Should we create a codemod/automated migration tool?** + - **Options:** Build jscodeshift transformer, or just document sed commands + - **Status:** TBD + - **Impact:** Migration effort for users + +--- + +## Execution Order + +The AppInsightsCore restructure involves two sequential plans. Execute them in order: + +| # | Plan | Status | Description | +|---|------|--------|-------------| +| 1 | **MergeCommonToCore-Plan.md** (this document) | ✅ Complete | Merges `@microsoft/applicationinsights-common` into `@microsoft/applicationinsights-core-js` | +| 2 | [**MOVE_LAYOUT_PLAN.md**](MOVE_LAYOUT_PLAN.md) | ⬜ Pending | Reorganizes internal source structure to align with otel-core layout | + +### Why Two Plans? + +1. **Distinct Objectives** - MergeCommon consolidates packages; MoveLayout reorganizes internal structure +2. **Git History** - Separate commits with clear purpose for easier review/revert +3. **Rollback Granularity** - Can validate MergeCommon before starting MoveLayout +4. **Context Management** - Each document maintains focused scope + +### Checkpoint After Plan 1 + +Before proceeding to Plan 2, verify: +- [ ] All internal packages import from `@microsoft/applicationinsights-core-js` +- [ ] `src/Common/` folder exists with 60+ files +- [ ] Build succeeds with 156 files in `dist-es5/Common/` +- [ ] All tests pass + +--- + +## Contact & Ownership + +**Plan Owner:** [TBD] +**Technical Lead:** [TBD] +**Release Manager:** [TBD] + +**Review Status:** +- [ ] Technical review complete +- [ ] Architecture review complete +- [ ] Security review complete +- [ ] Release review complete + +**Approvals:** +- [ ] Technical Lead +- [ ] Architecture Team +- [ ] Release Manager +- [ ] Product Owner + +--- + +*Document Version: 1.0* +*Last Updated: January 23, 2026* +*Status: Draft - Awaiting Review* diff --git a/RELEASES.md b/RELEASES.md index 2b5bdfa4c..ca31c6a9d 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -6,6 +6,13 @@ ### Significant Changes +- **AppInsightsCommon Merged into AppInsightsCore**: The `@microsoft/applicationinsights-common` package has been merged into `@microsoft/applicationinsights-core-js` to simplify dependency management and improve tree-shaking capabilities. + - All exports previously in `applicationinsights-common` are now available from `applicationinsights-core-js` + - The `applicationinsights-common` package continues to work as a compatibility layer (re-exports from Core) + - No breaking changes to existing APIs + - See the [Migration Guide](docs/upgrade/MergeCommonToCore.md) for details on updating your imports + - **Timeline**: The Common package will be deprecated and eventually removed in version 4.0.0 + - **W3C Trace State Support**: Added full support for managing W3C Trace State and sending headers in distributed tracing, including new distributed tracing modes `AI_AND_W3C_TRACE` and `W3C_TRACE` that enable the [`tracestate`](https://www.w3.org/TR/trace-context/#tracestate-header) header to be sent with requests when trace state information is available, the existing states will continue to not send the header. - **New Distributed Tracing Modes**: Added new `eDistributedTracingModes` enum values: diff --git a/channels/1ds-post-js/test/Unit/src/HttpManagerTest.ts b/channels/1ds-post-js/test/Unit/src/HttpManagerTest.ts index 0e26325a6..2040a8cd7 100644 --- a/channels/1ds-post-js/test/Unit/src/HttpManagerTest.ts +++ b/channels/1ds-post-js/test/Unit/src/HttpManagerTest.ts @@ -5,6 +5,7 @@ import { PostChannel, IXHROverride, IPayloadData } from "../../../src/Index"; import { IPostTransmissionTelemetryItem, EventBatchNotificationReason, IChannelConfiguration } from "../../../src/DataModels"; import { EventBatch } from "../../../src/EventBatch"; import { retryPolicyShouldRetryForStatus } from "../../../src/RetryPolicy"; +import { setBypassLazyCache } from "@nevware21/ts-utils"; interface EventDetail { batches: EventBatch[]; @@ -36,6 +37,9 @@ export class HttpManagerTest extends AITestClass { } public testInitialize() { + super.testInitialize(); + setBypassLazyCache(true); + // Reset the cached isBeacons supported isBeaconsSupported(false); @@ -61,9 +65,10 @@ export class HttpManagerTest extends AITestClass { if (this.core && this.core.isInitialized()) { this.core.unload(false); } + super.testFinishedCleanup(); } - public registerTests() { + public registerTests() { let _requeueNotification = (batches: EventBatch[], reason?: EventBatchNotificationReason, isSyncRequest?: boolean) => { this._requeueEvents.push({ batches: batches, diff --git a/channels/1ds-post-js/test/Unit/src/PostChannelTest.ts b/channels/1ds-post-js/test/Unit/src/PostChannelTest.ts index b10e27f3f..56471395a 100644 --- a/channels/1ds-post-js/test/Unit/src/PostChannelTest.ts +++ b/channels/1ds-post-js/test/Unit/src/PostChannelTest.ts @@ -5,6 +5,7 @@ import { IPostTransmissionTelemetryItem, IChannelConfiguration } from '../../../ import { SinonSpy } from 'sinon'; import { createAsyncResolvedPromise, IPromise } from "@nevware21/ts-async"; import { ActiveStatus } from "@microsoft/1ds-core-js"; +import { setBypassLazyCache } from "@nevware21/ts-utils"; interface IEventsSendRequests { @@ -46,6 +47,9 @@ export class PostChannelTest extends AITestClass { public testInitialize() { + super.testInitialize(); + setBypassLazyCache(true); + // Reset the cached isBeacons supported isBeaconsSupported(false); @@ -83,6 +87,7 @@ export class PostChannelTest extends AITestClass { this.core.unload(false); } this.ctx = null; + super.testFinishedCleanup(); } public registerTests() { diff --git a/channels/applicationinsights-channel-js/Tests/Unit/src/Sample.tests.ts b/channels/applicationinsights-channel-js/Tests/Unit/src/Sample.tests.ts index 982033d0a..0b8028de2 100644 --- a/channels/applicationinsights-channel-js/Tests/Unit/src/Sample.tests.ts +++ b/channels/applicationinsights-channel-js/Tests/Unit/src/Sample.tests.ts @@ -1,7 +1,7 @@ import { AITestClass } from "@microsoft/ai-test-framework"; import { createSampler } from "../../../src/TelemetryProcessors/Sample"; import { ITelemetryItem, isBeaconsSupported, newId } from "@microsoft/applicationinsights-core-js"; -import { TelemetryItemCreator, IPageViewTelemetry, PageViewDataType, PageViewEnvelopeType, ISample } from "@microsoft/applicationinsights-common"; +import { TelemetryItemCreator, IPageViewTelemetry, PageViewDataType, PageViewEnvelopeType, ISample } from "@microsoft/applicationinsights-core-js"; import { getHashCodeScore } from "../../../src/TelemetryProcessors/SamplingScoreGenerators/HashCodeScoreGenerator"; export class SampleTests extends AITestClass { diff --git a/channels/applicationinsights-channel-js/Tests/Unit/src/Sender.tests.ts b/channels/applicationinsights-channel-js/Tests/Unit/src/Sender.tests.ts index 3a1ae2610..625047318 100644 --- a/channels/applicationinsights-channel-js/Tests/Unit/src/Sender.tests.ts +++ b/channels/applicationinsights-channel-js/Tests/Unit/src/Sender.tests.ts @@ -1,9 +1,12 @@ import { AITestClass, PollingAssert } from "@microsoft/ai-test-framework"; import { Sender } from "../../../src/Sender"; -import { ExceptionDataType, IOfflineListener, createOfflineListener, utlGetSessionStorageKeys, utlRemoveSessionStorage } from "@microsoft/applicationinsights-common"; +import { ExceptionDataType, IOfflineListener, createOfflineListener, utlGetSessionStorageKeys, utlRemoveSessionStorage } from "@microsoft/applicationinsights-core-js"; import { EnvelopeCreator } from '../../../src/EnvelopeCreator'; -import { Exception, CtxTagKeys, isBeaconApiSupported, DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH, utlCanUseSessionStorage, utlGetSessionStorage, utlSetSessionStorage } from "@microsoft/applicationinsights-common"; -import { ITelemetryItem, AppInsightsCore, ITelemetryPlugin, DiagnosticLogger, NotificationManager, SendRequestReason, _eInternalMessageId, safeGetLogger, isString, isArray, arrForEach, isBeaconsSupported, IXHROverride, IPayloadData,TransportType, getWindow, ActiveStatus } from "@microsoft/applicationinsights-core-js"; +import { + Exception, CtxTagKeys, DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH, utlCanUseSessionStorage, utlGetSessionStorage, utlSetSessionStorage, + ITelemetryItem, AppInsightsCore, ITelemetryPlugin, DiagnosticLogger, NotificationManager, SendRequestReason, _eInternalMessageId, safeGetLogger, + isString, isArray, arrForEach, isBeaconsSupported, IXHROverride, IPayloadData,TransportType, getWindow, ActiveStatus +} from "@microsoft/applicationinsights-core-js"; import { ArraySendBuffer, SessionStorageSendBuffer } from "../../../src/SendBuffer"; import { IInternalStorageItem, ISenderConfig } from "../../../src/Interfaces"; import { createAsyncResolvedPromise } from "@nevware21/ts-async"; @@ -1663,7 +1666,7 @@ export class SenderTests extends AITestClass { baseData: {} }; - QUnit.assert.ok(isBeaconApiSupported(), "Beacon API is supported"); + QUnit.assert.ok(isBeaconsSupported(), "Beacon API is supported"); QUnit.assert.equal(false, sendBeaconCalled, "Beacon API was not called before"); QUnit.assert.equal(0, this._getXhrRequests().length, "xhr sender was not called before"); @@ -1707,7 +1710,7 @@ export class SenderTests extends AITestClass { baseData: {} }; - QUnit.assert.ok(isBeaconApiSupported(), "Beacon API is supported"); + QUnit.assert.ok(isBeaconsSupported(), "Beacon API is supported"); QUnit.assert.equal(false, sendBeaconCalled, "Beacon API was not called before"); QUnit.assert.equal(0, this._getXhrRequests().length, "xhr sender was not called before"); @@ -1780,7 +1783,7 @@ export class SenderTests extends AITestClass { baseData: {} }; - QUnit.assert.ok(isBeaconApiSupported(), "Beacon API is supported"); + QUnit.assert.ok(isBeaconsSupported(), "Beacon API is supported"); QUnit.assert.equal(false, sendBeaconCalled, "Beacon API was not called before"); QUnit.assert.equal(0, this._getXhrRequests().length, "xhr sender was not called before"); @@ -1853,7 +1856,7 @@ export class SenderTests extends AITestClass { baseData: {} }; - QUnit.assert.ok(isBeaconApiSupported(), "Beacon API is supported"); + QUnit.assert.ok(isBeaconsSupported(), "Beacon API is supported"); QUnit.assert.equal(false, sendBeaconCalled, "Beacon API was not called before"); QUnit.assert.equal(0, this._getXhrRequests().length, "xhr sender was not called before"); @@ -1927,7 +1930,7 @@ export class SenderTests extends AITestClass { baseData: {} }; - QUnit.assert.ok(isBeaconApiSupported(), "Beacon API is supported"); + QUnit.assert.ok(isBeaconsSupported(), "Beacon API is supported"); QUnit.assert.equal(false, sendBeaconCalled, "Beacon API was not called before"); QUnit.assert.equal(0, this._getXhrRequests().length, "xhr sender was not called before"); @@ -2000,7 +2003,7 @@ export class SenderTests extends AITestClass { baseData: {} }; - QUnit.assert.ok(isBeaconApiSupported(), "Beacon API is supported"); + QUnit.assert.ok(isBeaconsSupported(), "Beacon API is supported"); QUnit.assert.equal(false, sendBeaconCalled, "Beacon API was not called before"); QUnit.assert.equal(0, this._getXhrRequests().length, "xhr sender was not called before"); @@ -2052,7 +2055,7 @@ export class SenderTests extends AITestClass { baseData: {} }; - QUnit.assert.ok(isBeaconApiSupported(), "Beacon API is supported"); + QUnit.assert.ok(isBeaconsSupported(), "Beacon API is supported"); QUnit.assert.equal(false, sendBeaconCalled, "Beacon API was not called before"); QUnit.assert.equal(0, this._getXhrRequests().length, "xhr sender was not called before"); @@ -2126,7 +2129,7 @@ export class SenderTests extends AITestClass { baseData: {} }; - QUnit.assert.ok(isBeaconApiSupported(), "Beacon API is supported"); + QUnit.assert.ok(isBeaconsSupported(), "Beacon API is supported"); QUnit.assert.equal(false, sendBeaconCalled, "Beacon API was not called before"); QUnit.assert.equal(0, this._getXhrRequests().length, "xhr sender was not called before"); @@ -2199,7 +2202,7 @@ export class SenderTests extends AITestClass { baseData: {} }; - QUnit.assert.ok(isBeaconApiSupported(), "Beacon API is supported"); + QUnit.assert.ok(isBeaconsSupported(), "Beacon API is supported"); QUnit.assert.equal(false, sendBeaconCalled, "Beacon API was not called before"); QUnit.assert.equal(0, this._getXhrRequests().length, "xhr sender was not called before"); @@ -2265,7 +2268,7 @@ export class SenderTests extends AITestClass { let buffer = sender._buffer; - QUnit.assert.ok(isBeaconApiSupported(), "Beacon API is supported"); + QUnit.assert.ok(isBeaconsSupported(), "Beacon API is supported"); QUnit.assert.equal(false, sendBeaconCalled, "Beacon API was not called before"); QUnit.assert.equal(0, this._getXhrRequests().length, "xhr sender was not called before"); QUnit.assert.equal(0, buffer.getItems().length, "sender buffer should be clear"); @@ -2352,7 +2355,7 @@ export class SenderTests extends AITestClass { let buffer = sender._buffer; - QUnit.assert.ok(isBeaconApiSupported(), "Beacon API is supported"); + QUnit.assert.ok(isBeaconsSupported(), "Beacon API is supported"); QUnit.assert.equal(0, sendBeaconCalled, "Beacon API was not called before"); QUnit.assert.equal(0, this._getXhrRequests().length, "xhr sender was not called before"); QUnit.assert.equal(0, buffer.getItems().length, "sender buffer should be clear"); @@ -2442,7 +2445,7 @@ export class SenderTests extends AITestClass { let buffer = sender._buffer; - QUnit.assert.ok(isBeaconApiSupported(), "Beacon API is supported"); + QUnit.assert.ok(isBeaconsSupported(), "Beacon API is supported"); QUnit.assert.equal(0, sendBeaconCalled, "Beacon API was not called before"); QUnit.assert.equal(0, this._getXhrRequests().length, "xhr sender was not called before"); QUnit.assert.equal(0, buffer.getItems().length, "sender buffer should be clear"); @@ -2529,7 +2532,7 @@ export class SenderTests extends AITestClass { let buffer = sender._buffer; - QUnit.assert.ok(isBeaconApiSupported(), "Beacon API is supported"); + QUnit.assert.ok(isBeaconsSupported(), "Beacon API is supported"); QUnit.assert.equal(0, sendBeaconCalled, "Beacon API was not called before"); QUnit.assert.equal(0, this._getXhrRequests().length, "xhr sender was not called before"); QUnit.assert.equal(0, buffer.getItems().length, "sender buffer should be clear"); @@ -2628,7 +2631,7 @@ export class SenderTests extends AITestClass { let buffer = sender._buffer; - QUnit.assert.ok(isBeaconApiSupported(), "Beacon API is supported"); + QUnit.assert.ok(isBeaconsSupported(), "Beacon API is supported"); QUnit.assert.equal(0, sendBeaconCalled, "Beacon API was not called before"); QUnit.assert.equal(0, this._getXhrRequests().length, "xhr sender was not called before"); QUnit.assert.equal(0, buffer.getItems().length, "sender buffer should be clear"); @@ -2723,7 +2726,7 @@ export class SenderTests extends AITestClass { let buffer = sender._buffer; - QUnit.assert.ok(isBeaconApiSupported(), "Beacon API is supported"); + QUnit.assert.ok(isBeaconsSupported(), "Beacon API is supported"); QUnit.assert.equal(0, sendBeaconCalled, "Beacon API was not called before"); QUnit.assert.equal(0, this._getXhrRequests().length, "xhr sender was not called before"); QUnit.assert.equal(0, buffer.getItems().length, "sender buffer should be clear"); @@ -2829,7 +2832,7 @@ export class SenderTests extends AITestClass { let buffer = sender._buffer; - QUnit.assert.ok(isBeaconApiSupported(), "Beacon API is supported"); + QUnit.assert.ok(isBeaconsSupported(), "Beacon API is supported"); QUnit.assert.equal(0, sendBeaconCalled, "Beacon API was not called before"); QUnit.assert.equal(0, this._getXhrRequests().length, "xhr sender was not called before"); QUnit.assert.equal(0, buffer.getItems().length, "sender buffer should be clear"); @@ -2896,7 +2899,7 @@ export class SenderTests extends AITestClass { baseData: {} }; - QUnit.assert.ok(isBeaconApiSupported(), "Beacon API is supported"); + QUnit.assert.ok(isBeaconsSupported(), "Beacon API is supported"); QUnit.assert.equal(false, sendBeaconCalled, "Beacon API was not called before"); QUnit.assert.equal(0, this._getXhrRequests().length, "xhr sender was not called before"); @@ -2947,7 +2950,7 @@ export class SenderTests extends AITestClass { baseData: {} }; - QUnit.assert.ok(isBeaconApiSupported(), "Beacon API is supported"); + QUnit.assert.ok(isBeaconsSupported(), "Beacon API is supported"); QUnit.assert.equal(false, sendBeaconCalled, "Beacon API was not called before"); QUnit.assert.equal(0, this._getXhrRequests().length, "xhr sender was not called before"); diff --git a/channels/applicationinsights-channel-js/Tests/Unit/src/StatsBeat.tests.ts b/channels/applicationinsights-channel-js/Tests/Unit/src/StatsBeat.tests.ts index 71ccf4478..7b85a2396 100644 --- a/channels/applicationinsights-channel-js/Tests/Unit/src/StatsBeat.tests.ts +++ b/channels/applicationinsights-channel-js/Tests/Unit/src/StatsBeat.tests.ts @@ -3,7 +3,7 @@ // import { Sender } from "../../../src/Sender"; // import { SinonSpy, SinonStub } from "sinon"; // import { ISenderConfig } from "../../../types/applicationinsights-channel-js"; -// import { isBeaconApiSupported } from "@microsoft/applicationinsights-common"; +// import { isBeaconsSupported } from "@microsoft/applicationinsights-core-js"; // export class StatsbeatTests extends AITestClass { // private _core: AppInsightsCore; @@ -270,7 +270,7 @@ // sendBeaconCalled = true; // return true; // }); -// QUnit.assert.ok(isBeaconApiSupported(), "Beacon API is supported"); +// QUnit.assert.ok(isBeaconsSupported(), "Beacon API is supported"); // this.processTelemetryAndFlush(sender, telemetryItem); // } // ].concat(PollingAssert.createPollingAssert(() => { diff --git a/channels/applicationinsights-channel-js/package.json b/channels/applicationinsights-channel-js/package.json index c0ed8c47d..f2e1758fd 100644 --- a/channels/applicationinsights-channel-js/package.json +++ b/channels/applicationinsights-channel-js/package.json @@ -58,7 +58,6 @@ "@microsoft/dynamicproto-js": "^2.0.3", "@microsoft/applicationinsights-shims": "3.0.1", "@microsoft/applicationinsights-core-js": "3.3.11", - "@microsoft/applicationinsights-common": "3.3.11", "@nevware21/ts-utils": ">= 0.11.8 < 2.x", "@nevware21/ts-async": ">= 0.5.4 < 2.x" }, diff --git a/channels/applicationinsights-channel-js/src/EnvelopeCreator.ts b/channels/applicationinsights-channel-js/src/EnvelopeCreator.ts index ab34aa8eb..8fcb9d7c4 100644 --- a/channels/applicationinsights-channel-js/src/EnvelopeCreator.ts +++ b/channels/applicationinsights-channel-js/src/EnvelopeCreator.ts @@ -1,13 +1,11 @@ import { AIData, CtxTagKeys, Envelope, Event, EventDataType, EventEnvelopeType, Exception, ExceptionDataType, ExceptionEnvelopeType, HttpMethod, - IDependencyTelemetry, IEnvelope, IExceptionInternal, IPageViewPerformanceTelemetry, IPageViewTelemetryInternal, IRemoteDependencyData, - IRequestTelemetry, ISerializable, IWeb, Metric, MetricDataType, MetricEnvelopeType, PageView, PageViewDataType, PageViewEnvelopeType, - PageViewPerformance, PageViewPerformanceDataType, PageViewPerformanceEnvelopeType, RemoteDependencyDataType, RequestDataType, SampleRate, - Trace, TraceDataType, TraceEnvelopeType, dataSanitizeString -} from "@microsoft/applicationinsights-common"; -import { - IDiagnosticLogger, ITelemetryItem, Tags, _eInternalMessageId, _throwInternal, _warnToConsole, eLoggingSeverity, getJSON, hasJSON, isDate, - isNullOrUndefined, isNumber, isString, isTruthy, objForEachKey, optimizeObject, setValue, toISOString + IDependencyTelemetry, IDiagnosticLogger, IEnvelope, IExceptionInternal, IPageViewPerformanceTelemetry, IPageViewTelemetryInternal, + IRemoteDependencyData, IRequestTelemetry, ISerializable, ITelemetryItem, IWeb, Metric, MetricDataType, MetricEnvelopeType, PageView, + PageViewDataType, PageViewEnvelopeType, PageViewPerformance, PageViewPerformanceDataType, PageViewPerformanceEnvelopeType, + RemoteDependencyDataType, RequestDataType, SampleRate, Tags, Trace, TraceDataType, TraceEnvelopeType, _eInternalMessageId, + _throwInternal, _warnToConsole, dataSanitizeString, eLoggingSeverity, getJSON, hasJSON, isDate, isNullOrUndefined, isNumber, isString, + isTruthy, objForEachKey, optimizeObject, setValue, toISOString } from "@microsoft/applicationinsights-core-js"; import { IRequestData } from "./Interfaces/Contracts/IRequestData"; import { STR_DURATION } from "./InternalConstants"; diff --git a/channels/applicationinsights-channel-js/src/Interfaces.ts b/channels/applicationinsights-channel-js/src/Interfaces.ts index 3a0d975ef..76a091f81 100644 --- a/channels/applicationinsights-channel-js/src/Interfaces.ts +++ b/channels/applicationinsights-channel-js/src/Interfaces.ts @@ -1,5 +1,4 @@ -import { IStorageBuffer } from "@microsoft/applicationinsights-common"; -import { IXHROverride } from "@microsoft/applicationinsights-core-js"; +import { IStorageBuffer, IXHROverride } from "@microsoft/applicationinsights-core-js"; /** * Internal interface for sendBuffer, do not export it diff --git a/channels/applicationinsights-channel-js/src/Interfaces/Contracts/IRequestData.ts b/channels/applicationinsights-channel-js/src/Interfaces/Contracts/IRequestData.ts index 8601cde9d..47207fcd2 100644 --- a/channels/applicationinsights-channel-js/src/Interfaces/Contracts/IRequestData.ts +++ b/channels/applicationinsights-channel-js/src/Interfaces/Contracts/IRequestData.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { IDomain } from "@microsoft/applicationinsights-common/src/Interfaces/Contracts/IDomain"; +import { IDomain } from "@microsoft/applicationinsights-core-js"; /** * This interface indentifies the serialized request data contract that is sent to Application Insights backend diff --git a/channels/applicationinsights-channel-js/src/SendBuffer.ts b/channels/applicationinsights-channel-js/src/SendBuffer.ts index 239425269..961eca1f0 100644 --- a/channels/applicationinsights-channel-js/src/SendBuffer.ts +++ b/channels/applicationinsights-channel-js/src/SendBuffer.ts @@ -1,8 +1,7 @@ import dynamicProto from "@microsoft/dynamicproto-js"; -import { utlGetSessionStorage, utlRemoveSessionStorage, utlSetSessionStorage } from "@microsoft/applicationinsights-common"; import { IDiagnosticLogger, _eInternalMessageId, _throwInternal, arrForEach, arrIndexOf, dumpObj, eLoggingSeverity, getExceptionName, getJSON, - isArray, isFunction, isNullOrUndefined, isString + isArray, isFunction, isNullOrUndefined, isString, utlGetSessionStorage, utlRemoveSessionStorage, utlSetSessionStorage } from "@microsoft/applicationinsights-core-js"; import { IInternalStorageItem, ISenderConfig } from "./Interfaces"; diff --git a/channels/applicationinsights-channel-js/src/Sender.ts b/channels/applicationinsights-channel-js/src/Sender.ts index 732505599..cd0546c03 100644 --- a/channels/applicationinsights-channel-js/src/Sender.ts +++ b/channels/applicationinsights-channel-js/src/Sender.ts @@ -1,19 +1,16 @@ import dynamicProto from "@microsoft/dynamicproto-js"; import { - BreezeChannelIdentifier, DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH, EventDataType, ExceptionDataType, IConfig, IEnvelope, - IOfflineListener, ISample, IStorageBuffer, MetricDataType, PageViewDataType, PageViewPerformanceDataType, ProcessLegacy, - RemoteDependencyDataType, RequestDataType, RequestHeaders, SampleRate, TraceDataType, createOfflineListener, eRequestHeaders, - isInternalApplicationInsightsEndpoint, utlCanUseSessionStorage, utlSetStoragePrefix -} from "@microsoft/applicationinsights-common"; -import { - ActiveStatus, BaseTelemetryPlugin, IAppInsightsCore, IBackendResponse, IChannelControls, IConfigDefaults, IConfiguration, - IDiagnosticLogger, IInternalOfflineSupport, INotificationManager, IPayloadData, IPlugin, IProcessTelemetryContext, - IProcessTelemetryUnloadContext, ITelemetryItem, ITelemetryPluginChain, ITelemetryUnloadState, IXDomainRequest, IXHROverride, - OnCompleteCallback, SendPOSTFunction, SendRequestReason, SenderPostManager, TransportType, _ISendPostMgrConfig, _ISenderOnComplete, - _eInternalMessageId, _throwInternal, _warnToConsole, arrForEach, cfgDfBoolean, cfgDfValidate, createProcessTelemetryContext, - createUniqueNamespace, dateNow, dumpObj, eLoggingSeverity, formatErrorMessageXdr, formatErrorMessageXhr, getExceptionName, getIEVersion, - isArray, isBeaconsSupported, isFeatureEnabled, isFetchSupported, isNullOrUndefined, mergeEvtNamespace, objExtend, onConfigChange, - parseResponse, prependTransports, runTargetUnload + ActiveStatus, BaseTelemetryPlugin, BreezeChannelIdentifier, DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH, EventDataType, + ExceptionDataType, IAppInsightsCore, IBackendResponse, IChannelControls, IConfig, IConfigDefaults, IConfiguration, IDiagnosticLogger, + IEnvelope, IInternalOfflineSupport, INotificationManager, IOfflineListener, IPayloadData, IPlugin, IProcessTelemetryContext, + IProcessTelemetryUnloadContext, ISample, IStorageBuffer, ITelemetryItem, ITelemetryPluginChain, ITelemetryUnloadState, IXDomainRequest, + IXHROverride, MetricDataType, OnCompleteCallback, PageViewDataType, PageViewPerformanceDataType, ProcessLegacy, RemoteDependencyDataType, + RequestDataType, RequestHeaders, SampleRate, SendPOSTFunction, SendRequestReason, SenderPostManager, TraceDataType, TransportType, + _ISendPostMgrConfig, _ISenderOnComplete, _eInternalMessageId, _throwInternal, _warnToConsole, arrForEach, cfgDfBoolean, cfgDfValidate, + createOfflineListener, createProcessTelemetryContext, createUniqueNamespace, dateNow, dumpObj, eLoggingSeverity, eRequestHeaders, + formatErrorMessageXdr, formatErrorMessageXhr, getExceptionName, getIEVersion, isArray, isBeaconsSupported, isFeatureEnabled, + isFetchSupported, isInternalApplicationInsightsEndpoint, isNullOrUndefined, mergeEvtNamespace, objExtend, onConfigChange, parseResponse, + prependTransports, runTargetUnload, utlCanUseSessionStorage, utlSetStoragePrefix } from "@microsoft/applicationinsights-core-js"; import { IPromise, createPromise, doAwait, doAwaitResponse } from "@nevware21/ts-async"; import { diff --git a/channels/applicationinsights-channel-js/src/Serializer.ts b/channels/applicationinsights-channel-js/src/Serializer.ts index d9a1d1453..4cbeed663 100644 --- a/channels/applicationinsights-channel-js/src/Serializer.ts +++ b/channels/applicationinsights-channel-js/src/Serializer.ts @@ -2,7 +2,7 @@ import dynamicProto from "@microsoft/dynamicproto-js" import { IDiagnosticLogger, _eInternalMessageId, _throwInternal, eLoggingSeverity, getJSON, isArray, isFunction, isNullOrUndefined, isObject, objForEachKey } from "@microsoft/applicationinsights-core-js"; -import { FieldType, ISerializable } from "@microsoft/applicationinsights-common"; +import { FieldType, ISerializable } from "@microsoft/applicationinsights-core-js"; const enum eSerializeType { String = 1, diff --git a/channels/applicationinsights-channel-js/src/Telemetry/Common/Data.ts b/channels/applicationinsights-channel-js/src/Telemetry/Common/Data.ts index c7bbabdc8..6e837c181 100644 --- a/channels/applicationinsights-channel-js/src/Telemetry/Common/Data.ts +++ b/channels/applicationinsights-channel-js/src/Telemetry/Common/Data.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { AIData, FieldType, ISerializable } from "@microsoft/applicationinsights-common"; +import { AIData, FieldType, ISerializable } from "@microsoft/applicationinsights-core-js"; export function _createData(baseType: string, data: TDomain): AIData & ISerializable { return { diff --git a/channels/applicationinsights-channel-js/src/Telemetry/RemoteDependencyData.ts b/channels/applicationinsights-channel-js/src/Telemetry/RemoteDependencyData.ts index dc39051bd..8a101e086 100644 --- a/channels/applicationinsights-channel-js/src/Telemetry/RemoteDependencyData.ts +++ b/channels/applicationinsights-channel-js/src/Telemetry/RemoteDependencyData.ts @@ -2,10 +2,9 @@ // Licensed under the MIT License. import { - FieldType, IRemoteDependencyData, ISerializable, dataSanitizeMeasurements, dataSanitizeProperties, dataSanitizeString, dataSanitizeUrl, - msToTimeSpan, urlParseUrl -} from "@microsoft/applicationinsights-common"; -import { IDiagnosticLogger } from "@microsoft/applicationinsights-core-js"; + FieldType, IDiagnosticLogger, IRemoteDependencyData, ISerializable, dataSanitizeMeasurements, dataSanitizeProperties, dataSanitizeString, + dataSanitizeUrl, msToTimeSpan, urlParseUrl +} from "@microsoft/applicationinsights-core-js"; export const RemoteDependencyEnvelopeType = "Microsoft.ApplicationInsights.{0}.RemoteDependency"; diff --git a/channels/applicationinsights-channel-js/src/Telemetry/RequestData.ts b/channels/applicationinsights-channel-js/src/Telemetry/RequestData.ts index 8c6303972..63cf86809 100644 --- a/channels/applicationinsights-channel-js/src/Telemetry/RequestData.ts +++ b/channels/applicationinsights-channel-js/src/Telemetry/RequestData.ts @@ -2,9 +2,9 @@ // Licensed under the MIT License. import { - FieldType, ISerializable, dataSanitizeMeasurements, dataSanitizeProperties, dataSanitizeString, dataSanitizeUrl, msToTimeSpan -} from "@microsoft/applicationinsights-common"; -import { IDiagnosticLogger, asString } from "@microsoft/applicationinsights-core-js"; + FieldType, IDiagnosticLogger, ISerializable, asString, dataSanitizeMeasurements, dataSanitizeProperties, dataSanitizeString, + dataSanitizeUrl, msToTimeSpan +} from "@microsoft/applicationinsights-core-js"; import { IRequestData } from "../Interfaces/Contracts/IRequestData"; export const RequestEnvelopeType = "Microsoft.ApplicationInsights.{0}.Request"; diff --git a/channels/applicationinsights-channel-js/src/TelemetryProcessors/Sample.ts b/channels/applicationinsights-channel-js/src/TelemetryProcessors/Sample.ts index 096fa73de..5f0405bfb 100644 --- a/channels/applicationinsights-channel-js/src/TelemetryProcessors/Sample.ts +++ b/channels/applicationinsights-channel-js/src/TelemetryProcessors/Sample.ts @@ -1,9 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { ISample, MetricDataType } from "@microsoft/applicationinsights-common"; import { - IDiagnosticLogger, ITelemetryItem, _eInternalMessageId, _throwInternal, eLoggingSeverity + IDiagnosticLogger, ISample, ITelemetryItem, MetricDataType, _eInternalMessageId, _throwInternal, eLoggingSeverity } from "@microsoft/applicationinsights-core-js"; import { IScoreGenerator, createSamplingScoreGenerator } from "./SamplingScoreGenerators/SamplingScoreGenerator"; diff --git a/channels/applicationinsights-channel-js/src/TelemetryProcessors/SamplingScoreGenerators/SamplingScoreGenerator.ts b/channels/applicationinsights-channel-js/src/TelemetryProcessors/SamplingScoreGenerators/SamplingScoreGenerator.ts index 0c3cc51bc..0defe9f48 100644 --- a/channels/applicationinsights-channel-js/src/TelemetryProcessors/SamplingScoreGenerators/SamplingScoreGenerator.ts +++ b/channels/applicationinsights-channel-js/src/TelemetryProcessors/SamplingScoreGenerators/SamplingScoreGenerator.ts @@ -1,8 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { ContextTagKeys } from "@microsoft/applicationinsights-common"; -import { ITelemetryItem } from "@microsoft/applicationinsights-core-js"; +import { ContextTagKeys, ITelemetryItem } from "@microsoft/applicationinsights-core-js"; import { getHashCodeScore } from "./HashCodeScoreGenerator"; export interface IScoreGenerator { diff --git a/channels/offline-channel-js/Tests/Unit/src/TestHelper.ts b/channels/offline-channel-js/Tests/Unit/src/TestHelper.ts index c1b54d539..80632598c 100644 --- a/channels/offline-channel-js/Tests/Unit/src/TestHelper.ts +++ b/channels/offline-channel-js/Tests/Unit/src/TestHelper.ts @@ -1,4 +1,4 @@ -import { BreezeChannelIdentifier, DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH, IConfig } from "@microsoft/applicationinsights-common"; +import { BreezeChannelIdentifier, DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH, IConfig } from "@microsoft/applicationinsights-core-js"; import { BaseTelemetryPlugin, IAppInsightsCore, IChannelControls, IConfiguration, IInternalOfflineSupport, IPayloadData, IPlugin, ITelemetryItem } from "@microsoft/applicationinsights-core-js"; export class TestChannel extends BaseTelemetryPlugin implements IChannelControls { diff --git a/channels/offline-channel-js/Tests/Unit/src/channel.tests.ts b/channels/offline-channel-js/Tests/Unit/src/channel.tests.ts index 45d7c4412..deacf5f9a 100644 --- a/channels/offline-channel-js/Tests/Unit/src/channel.tests.ts +++ b/channels/offline-channel-js/Tests/Unit/src/channel.tests.ts @@ -1,5 +1,5 @@ import { AITestClass, Assert, PollingAssert } from "@microsoft/ai-test-framework"; -import { DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH, EventPersistence, IConfig } from "@microsoft/applicationinsights-common"; +import { DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH, EventPersistence, IConfig } from "@microsoft/applicationinsights-core-js"; import { AppInsightsCore, IConfiguration, arrForEach, getGlobal, getGlobalInst, objKeys } from "@microsoft/applicationinsights-core-js"; import { TestChannel, mockTelemetryItem } from "./TestHelper"; import { OfflineChannel } from "../../../src/OfflineChannel" diff --git a/channels/offline-channel-js/Tests/Unit/src/customprovider.tests.ts b/channels/offline-channel-js/Tests/Unit/src/customprovider.tests.ts index 0424cf22c..d6d709171 100644 --- a/channels/offline-channel-js/Tests/Unit/src/customprovider.tests.ts +++ b/channels/offline-channel-js/Tests/Unit/src/customprovider.tests.ts @@ -4,7 +4,7 @@ import { AppInsightsCore, arrForEach, createDynamicConfig, getJSON, IConfigurati import { OfflineBatchHandler } from "../../../src/OfflineBatchHandler"; import { ILocalStorageProviderContext, IOfflineChannelConfiguration, IOfflineProvider, eStorageProviders } from "../../../src/Interfaces/IOfflineProvider"; import { getTimeId } from "../../../src/Helpers/Utils"; -import { DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH, IConfig } from "@microsoft/applicationinsights-common"; +import { DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH, IConfig } from "@microsoft/applicationinsights-core-js"; import { mockTelemetryItem, TestChannel } from "./TestHelper"; import { OfflineChannel } from "../../../src/OfflineChannel"; diff --git a/channels/offline-channel-js/Tests/Unit/src/dbprovider.tests.ts b/channels/offline-channel-js/Tests/Unit/src/dbprovider.tests.ts index 5b970ebc9..49a8fccd3 100644 --- a/channels/offline-channel-js/Tests/Unit/src/dbprovider.tests.ts +++ b/channels/offline-channel-js/Tests/Unit/src/dbprovider.tests.ts @@ -4,7 +4,7 @@ import { createAsyncPromise, createAsyncRejectedPromise, createSyncPromise, doAw import { arrForEach, strSubstr } from "@nevware21/ts-utils"; import { TestChannel } from "./TestHelper"; import { AppInsightsCore, IConfiguration, createDynamicConfig, generateW3CId, newGuid } from "@microsoft/applicationinsights-core-js"; -import { DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH, IConfig } from "@microsoft/applicationinsights-common"; +import { DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH, IConfig } from "@microsoft/applicationinsights-core-js"; import { IStorageTelemetryItem } from "../../../src/Interfaces/IOfflineProvider"; export class OfflineDbProviderTests extends AITestClass { diff --git a/channels/offline-channel-js/Tests/Unit/src/offlinebatchhandler.tests.ts b/channels/offline-channel-js/Tests/Unit/src/offlinebatchhandler.tests.ts index 779c89abd..f3c2cc4f1 100644 --- a/channels/offline-channel-js/Tests/Unit/src/offlinebatchhandler.tests.ts +++ b/channels/offline-channel-js/Tests/Unit/src/offlinebatchhandler.tests.ts @@ -1,7 +1,7 @@ import { AITestClass, Assert, PollingAssert } from "@microsoft/ai-test-framework"; import { AppInsightsCore, IConfiguration, IPayloadData, OnCompleteCallback, arrForEach, createDynamicConfig, newGuid } from "@microsoft/applicationinsights-core-js"; import { TestChannel } from "./TestHelper"; -import { DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH, IConfig } from "@microsoft/applicationinsights-common"; +import { DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH, IConfig } from "@microsoft/applicationinsights-core-js"; import { IOfflineChannelConfiguration, eStorageProviders } from "../../../src/Interfaces/IOfflineProvider"; import { OfflineBatchHandler } from "../../../src/OfflineBatchHandler"; import { createAsyncRejectedPromise, doAwait, doAwaitResponse } from "@nevware21/ts-async"; diff --git a/channels/offline-channel-js/Tests/Unit/src/offlinetimer.tests.ts b/channels/offline-channel-js/Tests/Unit/src/offlinetimer.tests.ts index 69f3582e6..0dfb9c736 100644 --- a/channels/offline-channel-js/Tests/Unit/src/offlinetimer.tests.ts +++ b/channels/offline-channel-js/Tests/Unit/src/offlinetimer.tests.ts @@ -1,5 +1,5 @@ import { AITestClass, Assert } from "@microsoft/ai-test-framework"; -import { DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH, EventPersistence, IConfig } from "@microsoft/applicationinsights-common"; +import { DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH, EventPersistence, IConfig } from "@microsoft/applicationinsights-core-js"; import { AppInsightsCore, IConfiguration, IPayloadData, OnCompleteCallback } from "@microsoft/applicationinsights-core-js"; import { TestChannel, mockTelemetryItem } from "./TestHelper"; import { OfflineChannel } from "../../../src/OfflineChannel"; diff --git a/channels/offline-channel-js/Tests/Unit/src/webprovider.tests.ts b/channels/offline-channel-js/Tests/Unit/src/webprovider.tests.ts index f50c48ea4..2813d19c9 100644 --- a/channels/offline-channel-js/Tests/Unit/src/webprovider.tests.ts +++ b/channels/offline-channel-js/Tests/Unit/src/webprovider.tests.ts @@ -1,7 +1,7 @@ import { AITestClass, Assert } from "@microsoft/ai-test-framework"; import { AppInsightsCore, IConfiguration, arrForEach, createDynamicConfig, eBatchDiscardedReason, generateW3CId, isArray } from "@microsoft/applicationinsights-core-js"; import { WebStorageProvider } from "../../../src/Providers/WebStorageProvider"; -import { DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH, IConfig } from "@microsoft/applicationinsights-common"; +import { DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH, IConfig } from "@microsoft/applicationinsights-core-js"; import { TestChannel } from "./TestHelper"; import { IOfflineChannelConfiguration, IStorageTelemetryItem } from "../../../src/Interfaces/IOfflineProvider"; import { doAwaitResponse } from "@nevware21/ts-async"; diff --git a/channels/offline-channel-js/package.json b/channels/offline-channel-js/package.json index c7420aab6..957c77b50 100644 --- a/channels/offline-channel-js/package.json +++ b/channels/offline-channel-js/package.json @@ -32,7 +32,6 @@ "@microsoft/dynamicproto-js": "^2.0.3", "@microsoft/applicationinsights-shims": "3.0.1", "@microsoft/applicationinsights-core-js": "3.3.11", - "@microsoft/applicationinsights-common": "3.3.11", "@nevware21/ts-utils": ">= 0.11.8 < 2.x", "@nevware21/ts-async": ">= 0.5.4 < 2.x" }, diff --git a/channels/offline-channel-js/src/Helpers/Utils.ts b/channels/offline-channel-js/src/Helpers/Utils.ts index eef744efc..46a0a52c4 100644 --- a/channels/offline-channel-js/src/Helpers/Utils.ts +++ b/channels/offline-channel-js/src/Helpers/Utils.ts @@ -1,9 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { EventPersistence } from "@microsoft/applicationinsights-common"; import { - INotificationManager, ITelemetryItem, NotificationManager, eLoggingSeverity, generateW3CId + EventPersistence, INotificationManager, ITelemetryItem, NotificationManager, eLoggingSeverity, generateW3CId } from "@microsoft/applicationinsights-core-js"; import { isNumber, isString, objKeys, strSubstr } from "@nevware21/ts-utils"; import { IPostTransmissionTelemetryItem } from "../Interfaces/IInMemoryBatch"; diff --git a/channels/offline-channel-js/src/Interfaces/IInMemoryBatch.ts b/channels/offline-channel-js/src/Interfaces/IInMemoryBatch.ts index 55a0c95f0..7a8297d3b 100644 --- a/channels/offline-channel-js/src/Interfaces/IInMemoryBatch.ts +++ b/channels/offline-channel-js/src/Interfaces/IInMemoryBatch.ts @@ -1,8 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { EventPersistence } from "@microsoft/applicationinsights-common"; -import { ITelemetryItem } from "@microsoft/applicationinsights-core-js"; +import { EventPersistence, ITelemetryItem } from "@microsoft/applicationinsights-core-js"; /** * An internal interface which defines a in memory batch diff --git a/channels/offline-channel-js/src/Interfaces/IOfflineBatch.ts b/channels/offline-channel-js/src/Interfaces/IOfflineBatch.ts index a4bf6dc39..bf12a37e1 100644 --- a/channels/offline-channel-js/src/Interfaces/IOfflineBatch.ts +++ b/channels/offline-channel-js/src/Interfaces/IOfflineBatch.ts @@ -1,9 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { IOfflineListener } from "@microsoft/applicationinsights-common"; import { - IPayloadData, IProcessTelemetryUnloadContext, ITelemetryUnloadState, IXHROverride, createEnumStyle + IOfflineListener, IPayloadData, IProcessTelemetryUnloadContext, ITelemetryUnloadState, IXHROverride, createEnumStyle } from "@microsoft/applicationinsights-core-js"; import { IPromise } from "@nevware21/ts-async"; diff --git a/channels/offline-channel-js/src/Interfaces/IOfflineProvider.ts b/channels/offline-channel-js/src/Interfaces/IOfflineProvider.ts index 1851ab2d3..525a071e1 100644 --- a/channels/offline-channel-js/src/Interfaces/IOfflineProvider.ts +++ b/channels/offline-channel-js/src/Interfaces/IOfflineProvider.ts @@ -1,9 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { EventPersistence } from "@microsoft/applicationinsights-common"; import { - INotificationManager, IPayloadData, IProcessTelemetryContext, IXHROverride, createEnumStyle + EventPersistence, INotificationManager, IPayloadData, IProcessTelemetryContext, IXHROverride, createEnumStyle } from "@microsoft/applicationinsights-core-js"; import { IPromise } from "@nevware21/ts-async"; diff --git a/channels/offline-channel-js/src/OfflineChannel.ts b/channels/offline-channel-js/src/OfflineChannel.ts index b313b6b8b..f014830a4 100644 --- a/channels/offline-channel-js/src/OfflineChannel.ts +++ b/channels/offline-channel-js/src/OfflineChannel.ts @@ -3,14 +3,12 @@ import dynamicProto from "@microsoft/dynamicproto-js"; import { - BreezeChannelIdentifier, EventPersistence, IConfig, IOfflineListener, createOfflineListener -} from "@microsoft/applicationinsights-common"; -import { - BaseTelemetryPlugin, EventsDiscardedReason, IAppInsightsCore, IChannelControls, IConfigDefaults, IConfiguration, IDiagnosticLogger, - IInternalOfflineSupport, INotificationListener, INotificationManager, IPayloadData, IPlugin, IProcessTelemetryContext, - IProcessTelemetryUnloadContext, ITelemetryItem, ITelemetryPluginChain, ITelemetryUnloadState, IXHROverride, SendRequestReason, - _eInternalMessageId, _throwInternal, arrForEach, createProcessTelemetryContext, createUniqueNamespace, dateNow, eBatchDiscardedReason, - eLoggingSeverity, mergeEvtNamespace, onConfigChange, runTargetUnload + BaseTelemetryPlugin, BreezeChannelIdentifier, EventPersistence, EventsDiscardedReason, IAppInsightsCore, IChannelControls, IConfig, + IConfigDefaults, IConfiguration, IDiagnosticLogger, IInternalOfflineSupport, INotificationListener, INotificationManager, + IOfflineListener, IPayloadData, IPlugin, IProcessTelemetryContext, IProcessTelemetryUnloadContext, ITelemetryItem, ITelemetryPluginChain, + ITelemetryUnloadState, IXHROverride, SendRequestReason, _eInternalMessageId, _throwInternal, arrForEach, createOfflineListener, + createProcessTelemetryContext, createUniqueNamespace, dateNow, eBatchDiscardedReason, eLoggingSeverity, mergeEvtNamespace, + onConfigChange, runTargetUnload } from "@microsoft/applicationinsights-core-js"; import { IPromise, ITaskScheduler, createAsyncPromise, createTaskScheduler } from "@nevware21/ts-async"; import { diff --git a/channels/offline-channel-js/src/Sender.ts b/channels/offline-channel-js/src/Sender.ts index 46c6be098..85ce8cf08 100644 --- a/channels/offline-channel-js/src/Sender.ts +++ b/channels/offline-channel-js/src/Sender.ts @@ -2,12 +2,12 @@ // Licensed under the MIT License. import dynamicProto from "@microsoft/dynamicproto-js"; -import { BreezeChannelIdentifier, IConfig, utlSetStoragePrefix } from "@microsoft/applicationinsights-common"; import { - IAppInsightsCore, IConfiguration, IDiagnosticLogger, IProcessTelemetryContext, IProcessTelemetryUnloadContext, ITelemetryUnloadState, - IUnloadHookContainer, IXDomainRequest, IXHROverride, OnCompleteCallback, SendRequestReason, SenderPostManager, TransportType, - _ISendPostMgrConfig, _ISenderOnComplete, _eInternalMessageId, _throwInternal, createProcessTelemetryContext, eLoggingSeverity, - formatErrorMessageXdr, getResponseText, onConfigChange, parseResponse, prependTransports + BreezeChannelIdentifier, IAppInsightsCore, IConfig, IConfiguration, IDiagnosticLogger, IProcessTelemetryContext, + IProcessTelemetryUnloadContext, ITelemetryUnloadState, IUnloadHookContainer, IXDomainRequest, IXHROverride, OnCompleteCallback, + SendRequestReason, SenderPostManager, TransportType, _ISendPostMgrConfig, _ISenderOnComplete, _eInternalMessageId, _throwInternal, + createProcessTelemetryContext, eLoggingSeverity, formatErrorMessageXdr, getResponseText, onConfigChange, parseResponse, + prependTransports, utlSetStoragePrefix } from "@microsoft/applicationinsights-core-js"; import { IPromise } from "@nevware21/ts-async"; import { isFunction } from "@nevware21/ts-utils"; diff --git a/channels/tee-channel-js/package.json b/channels/tee-channel-js/package.json index 79a5383d5..22e3f32ea 100644 --- a/channels/tee-channel-js/package.json +++ b/channels/tee-channel-js/package.json @@ -59,7 +59,6 @@ "@microsoft/dynamicproto-js": "^2.0.3", "@microsoft/applicationinsights-shims": "3.0.1", "@microsoft/applicationinsights-core-js": "3.3.11", - "@microsoft/applicationinsights-common": "3.3.11", "@nevware21/ts-utils": ">= 0.11.8 < 2.x", "@nevware21/ts-async": ">= 0.5.4 < 2.x" }, diff --git a/channels/tee-channel-js/src/TeeChannel.ts b/channels/tee-channel-js/src/TeeChannel.ts index ec8e32b93..95ef9fd45 100644 --- a/channels/tee-channel-js/src/TeeChannel.ts +++ b/channels/tee-channel-js/src/TeeChannel.ts @@ -2,9 +2,8 @@ // Licensed under the MIT License. import dynamicProto from "@microsoft/dynamicproto-js"; -import { IConfig } from "@microsoft/applicationinsights-common"; import { - BaseTelemetryPlugin, IAppInsightsCore, IChannelControls, IChannelControlsHost, IConfigDefaults, IConfiguration, IPlugin, + BaseTelemetryPlugin, IAppInsightsCore, IChannelControls, IChannelControlsHost, IConfig, IConfigDefaults, IConfiguration, IPlugin, IProcessTelemetryContext, IProcessTelemetryUnloadContext, IProcessTelemetryUpdateContext, ITelemetryItem, ITelemetryPluginChain, ITelemetryUnloadState, ITelemetryUpdateState, SendRequestReason, cfgDfBoolean, createProcessTelemetryContext, initializePlugins, onConfigChange, proxyFunctions diff --git a/common/Tests/Framework/src/AITestClass.ts b/common/Tests/Framework/src/AITestClass.ts index e14c8d3bb..eadfec4a6 100644 --- a/common/Tests/Framework/src/AITestClass.ts +++ b/common/Tests/Framework/src/AITestClass.ts @@ -10,7 +10,7 @@ import { StepResult } from "./StepResult"; import { IFakeXMLHttpRequest } from "./interfaces/FakeXMLHttpRequest"; import { IFetchRequest } from "./interfaces/IFetchRequest"; import { IBeaconRequest } from "./interfaces/IBeaconRequest"; -import { createPromise, createSyncPromise, createTaskScheduler, createTimeoutPromise, doAwait, doAwaitResponse, FinallyPromiseHandler, IPromise, RejectedPromiseHandler, ResolvedPromiseHandler } from "@nevware21/ts-async"; +import { createPromise, createSyncPromise, createTaskScheduler, createTimeoutPromise, doAwait, FinallyPromiseHandler, IPromise, RejectedPromiseHandler, ResolvedPromiseHandler } from "@nevware21/ts-async"; import { AITestQueueTask, IAsyncQueue } from "./interfaces/IASyncQueue"; const stepRetryCnt = "retryCnt"; @@ -1444,6 +1444,9 @@ export class AITestClass { } private _restoreIE() { + // We need to clear any lazy cached global values + setBypassLazyCache(true); + this._restoreObject(this._orgObjectFuncs); this._orgObjectFuncs = null; @@ -1453,8 +1456,6 @@ export class AITestClass { let global = window as any; global["Symbol"] = this._orgSymbol; this._orgSymbol = null; - - setBypassLazyCache(true); } } @@ -1469,6 +1470,9 @@ export class AITestClass { } } + // clear any lazy cached global values + setBypassLazyCache(true); + let global = getGlobal() as any; if (!this._orgFetch) { this._orgFetch = global.fetch; @@ -1490,9 +1494,6 @@ export class AITestClass { this._orgSymbol = global["Symbol"]; global["Symbol"] = undefined; } - - // clear any lazy cached global values - setBypassLazyCache(true); } private _unhookXhr() { diff --git a/common/config/rush/npm-shrinkwrap.json b/common/config/rush/npm-shrinkwrap.json index 1574d3f07..712810d0f 100644 --- a/common/config/rush/npm-shrinkwrap.json +++ b/common/config/rush/npm-shrinkwrap.json @@ -431,17 +431,17 @@ "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==" }, "node_modules/@microsoft/api-extractor": { - "version": "7.55.2", - "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.55.2.tgz", - "integrity": "sha512-1jlWO4qmgqYoVUcyh+oXYRztZde/pAi7cSVzBz/rc+S7CoVzDasy8QE13dx6sLG4VRo8SfkkLbFORR6tBw4uGQ==", + "version": "7.56.0", + "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.56.0.tgz", + "integrity": "sha512-H0V69QG5jIb9Ayx35NVBv2lOgFSS3q+Eab2oyGEy0POL3ovYPST+rCNPbwYoczOZXNG8IKjWUmmAMxmDTsXlQA==", "dependencies": { "@microsoft/api-extractor-model": "7.32.2", "@microsoft/tsdoc": "~0.16.0", "@microsoft/tsdoc-config": "~0.18.0", "@rushstack/node-core-library": "5.19.1", "@rushstack/rig-package": "0.6.0", - "@rushstack/terminal": "0.19.5", - "@rushstack/ts-command-line": "5.1.5", + "@rushstack/terminal": "0.21.0", + "@rushstack/ts-command-line": "5.1.7", "diff": "~8.0.2", "lodash": "~4.17.15", "minimatch": "10.0.3", @@ -800,7 +800,7 @@ "node_modules/@rush-temp/applicationinsights-analytics-js": { "version": "0.0.0", "resolved": "file:projects/applicationinsights-analytics-js.tgz", - "integrity": "sha512-Zg6M9KT1p7WkJymEf4FJMySBTffxkMM6sTNMk/jh8lAqypjhMrnZODAkERcEBv/PtIvdJBmsEm6tuvVQyhtB3g==", + "integrity": "sha512-Ni9Enj/Le/qnsgCRABSlaOHH8ma6OPhRW7RuIZyDelTD8XP8cQL8Joa+Ng608teAcajT0v2f/FdVFebE/j3Ywg==", "dependencies": { "@microsoft/api-extractor": "^7.40.0", "@microsoft/dynamicproto-js": "^2.0.3", @@ -828,7 +828,7 @@ "node_modules/@rush-temp/applicationinsights-cfgsync-js": { "version": "0.0.0", "resolved": "file:projects/applicationinsights-cfgsync-js.tgz", - "integrity": "sha512-5a4vSrF7kbBw9EvYPA8IfeBMse2Zkv9bjr9XjUkCSJHqHgnFbkns+YVwrWAMfaTJ6sLiTk4xlkbY4tEZl25sag==", + "integrity": "sha512-B3titPfeIiUFSV55pG6WRWWb+sObg+hdPkCMaVKySVoRCIfzjJCSTXaETtsR9ylinXU1Kxj9zsTAQv1VAxF/aA==", "dependencies": { "@microsoft/api-extractor": "^7.40.0", "@microsoft/dynamicproto-js": "^2.0.3", @@ -857,7 +857,7 @@ "node_modules/@rush-temp/applicationinsights-channel-js": { "version": "0.0.0", "resolved": "file:projects/applicationinsights-channel-js.tgz", - "integrity": "sha512-X7uQ+MbS51rJ7Q0hOOtCny/kQR8xHHsQqDJGlCr9WYNmaImoW7+bK0dW4aAguTtBLv+7Aao7Q+hf8iFur8vNBA==", + "integrity": "sha512-ojWUfmLGqa68QfCtSaAgeFaeTH26sG20Ih4Je4q9OHNnIVV+pxg4JgKfpXbZmKkyx0/aaJgjAsgnBY1xs3a4hg==", "dependencies": { "@microsoft/api-extractor": "^7.40.0", "@microsoft/dynamicproto-js": "^2.0.3", @@ -885,7 +885,7 @@ "node_modules/@rush-temp/applicationinsights-chrome-debug-extension": { "version": "0.0.0", "resolved": "file:projects/applicationinsights-chrome-debug-extension.tgz", - "integrity": "sha512-A9wzsP1gTFKlUUJ0m2bTiyX0NwElj0Y4qkCA3aywVS6wJLxDNXYw8QIxFNeLdzqc+NcUdyDOEbqSFO0t6y1usA==", + "integrity": "sha512-aNAkiIlav3gxNG+UXDOzCHhsD9FFIDMc2cs6jqnRseZle8ob/aejGChjKp078hOs+Ix9zEt8FuyC4ptn+jKm9w==", "dependencies": { "@microsoft/dynamicproto-js": "^2.0.3", "@nevware21/grunt-eslint-ts": "^0.2.2", @@ -921,7 +921,7 @@ "node_modules/@rush-temp/applicationinsights-clickanalytics-js": { "version": "0.0.0", "resolved": "file:projects/applicationinsights-clickanalytics-js.tgz", - "integrity": "sha512-zTB00a6yntz/q1GdEzY8SAXkPV9drgxRFaluOFNv4T7cAFmGGdt751sTbgSosK6sGE2px6hg+S+X62ywwaATAw==", + "integrity": "sha512-1aP2WKWqBGqbjtxaL62dOq8VFk2+2tAKxeTSiiX7MNd521XhjHc4xUbDEe8gMC7agaY4H2hkd9AwY2sn5I9JiA==", "dependencies": { "@microsoft/api-extractor": "^7.40.0", "@microsoft/dynamicproto-js": "^2.0.3", @@ -946,7 +946,7 @@ "node_modules/@rush-temp/applicationinsights-common": { "version": "0.0.0", "resolved": "file:projects/applicationinsights-common.tgz", - "integrity": "sha512-a/0ulnOKHn4TWdoIbJEQU2alqvVZofQ6ZBdmUBd38crRs9ceMTIZqjbYaF6nPee5y4I/WOh7vjPCqXb9E8eUhg==", + "integrity": "sha512-NPMVYrYJb0uAZlDT1Itb5ya0vdiUKiDZM9Q6UA+EWZU+634dRntv3rGPT3PcWLutqriIMElh57TYAARTxeirNA==", "dependencies": { "@microsoft/api-extractor": "^7.40.0", "@microsoft/dynamicproto-js": "^2.0.3", @@ -1001,7 +1001,7 @@ "node_modules/@rush-temp/applicationinsights-debugplugin-js": { "version": "0.0.0", "resolved": "file:projects/applicationinsights-debugplugin-js.tgz", - "integrity": "sha512-Dth5iQK7f+ozim5vuNWo3xWOVEqd0McRV996k2bbRAS6BbpphhjY1qIZFWAJSCE0WIRd8ThsWB/ryhoDDhp5cA==", + "integrity": "sha512-hEZ95vYGtREkFxMiSAyM3AkjgIt9PcsIVtbLDH39dPfPTNy8mCyywFSKPSLFuuEzYHOjUW1dWLi+1fQLyyjwQg==", "dependencies": { "@microsoft/api-extractor": "^7.40.0", "@microsoft/dynamicproto-js": "^2.0.3", @@ -1026,7 +1026,7 @@ "node_modules/@rush-temp/applicationinsights-dependencies-js": { "version": "0.0.0", "resolved": "file:projects/applicationinsights-dependencies-js.tgz", - "integrity": "sha512-myjWDD7PY7lA7VGfCXX1IDT4zJReF5Wr8gWv6Z/ClszXTmbDkSX6UhiuKsFSDjBc1TLG+lQi5MowS6mXXor3Sg==", + "integrity": "sha512-prvNZHFYxbDdViRX9iqWMYSqE/6SkWJJuTtlvA7Oo/q2bHBgCySs35TtVGrf3pDGrBsJCskOaEcBfQAdSqJFPA==", "dependencies": { "@microsoft/api-extractor": "^7.40.0", "@microsoft/dynamicproto-js": "^2.0.3", @@ -1172,7 +1172,7 @@ "node_modules/@rush-temp/applicationinsights-offlinechannel-js": { "version": "0.0.0", "resolved": "file:projects/applicationinsights-offlinechannel-js.tgz", - "integrity": "sha512-FfMQnwiBTraJ0LwAlzNJ3s9D9ruUPAWzWHOVfJfRcN16vyPlLW3748nI+Hg7IA75eIHsp/DxlI0g58p9cX/BpA==", + "integrity": "sha512-bAWCA4zZh2IXvUJGBTfsU0Agndlnx/zSkFs1K1BMY6jAEy26kjI77yNhE3F1eHlttOSWWIxYWZ9xLVg/eb+Dpw==", "dependencies": { "@microsoft/api-extractor": "^7.40.0", "@microsoft/dynamicproto-js": "^2.0.3", @@ -1200,7 +1200,7 @@ "node_modules/@rush-temp/applicationinsights-osplugin-js": { "version": "0.0.0", "resolved": "file:projects/applicationinsights-osplugin-js.tgz", - "integrity": "sha512-yP2PcwFWo94+u4Fr0Ku9z2vMwfSn1EYyeNal8j2NsF6Zx+vCrT3dgIIAAAVIXhT8MyvTrs+ZankHLPfU7iqT+g==", + "integrity": "sha512-9Be4B4Nue46rmQOO9/5X8lHy7CFClSA2VhtOSf6bNChP4gMOUaRHtqdGPa4xakHhIGitufTt07NlcozFQViegA==", "dependencies": { "@microsoft/api-extractor": "^7.40.0", "@microsoft/dynamicproto-js": "^2.0.3", @@ -1249,7 +1249,7 @@ "node_modules/@rush-temp/applicationinsights-properties-js": { "version": "0.0.0", "resolved": "file:projects/applicationinsights-properties-js.tgz", - "integrity": "sha512-e/yF3zU1jDXXEhK8UbAe8+08ntoneoxWctQbOG1commQA5C2sa5d2E/O1VczAc92Bn6rJLtdwcb2qb6p9az69Q==", + "integrity": "sha512-6QUJAjdMG0cjw3R/AD6X55ko95aUVgbFBvgfJqbypNutE6bOcyFhqECMTSsW/byQmpZH1pV4vzRn7o0zQ0clKA==", "dependencies": { "@microsoft/api-extractor": "^7.40.0", "@microsoft/dynamicproto-js": "^2.0.3", @@ -1342,7 +1342,7 @@ "node_modules/@rush-temp/applicationinsights-teechannel-js": { "version": "0.0.0", "resolved": "file:projects/applicationinsights-teechannel-js.tgz", - "integrity": "sha512-23AZra48M327XtCX18fEPwLPZTb227dOk2rsDKZDPcuZXk7nbtvLpjT8x0KHFOMIktFbvy1ESy9uXth8cYGUSA==", + "integrity": "sha512-HeGjRWECidEMZykHxP80H4pkDiKkeqXXs210DZSBaIUqNVEJ6AACZecA+u2M8yKPo42g0UQWgYfCmDXVUJ0pjA==", "dependencies": { "@microsoft/api-extractor": "^7.40.0", "@microsoft/dynamicproto-js": "^2.0.3", @@ -1370,7 +1370,7 @@ "node_modules/@rush-temp/applicationinsights-test-module-type-check": { "version": "0.0.0", "resolved": "file:projects/applicationinsights-test-module-type-check.tgz", - "integrity": "sha512-pl22mxpx/0XlVihOR5DHAsh72iySgy8saXz7YFsnvDmABiuPtipWIJM4K/K0RIl06fBGiYkDM0w3E6QGLSVysg==", + "integrity": "sha512-gSGMPEpeFKfdRtFcBcDWaImmonXPeWRLNrMfngbdgbg8BDQDj6U3d/KLHuVpxUW0RTnCqZ1XbexhP6qa1omTGQ==", "dependencies": { "tslib": ">= 1.0.0", "typescript": "^4.9.3" @@ -1379,7 +1379,7 @@ "node_modules/@rush-temp/applicationinsights-web": { "version": "0.0.0", "resolved": "file:projects/applicationinsights-web.tgz", - "integrity": "sha512-xtxtbhTrqtx1y5YL4g+7jqkpyCchMGu6MqrlCY95DJpVFD2j1g6xq9nqEWcW3+JIUwjPgL/FcNLCCOUGlGQepw==", + "integrity": "sha512-rgF++eKqFsvgJUYwaqYJlnyahjvqf97+NJev04Ph0VZH97QrIWxwkQMPaydsBYInF07P7mHQjbmJuIxNQ584zw==", "dependencies": { "@microsoft/api-extractor": "^7.40.0", "@microsoft/dynamicproto-js": "^2.0.3", @@ -1411,7 +1411,7 @@ "node_modules/@rush-temp/applicationinsights-web-basic": { "version": "0.0.0", "resolved": "file:projects/applicationinsights-web-basic.tgz", - "integrity": "sha512-ZZPXhDKANioB4UXJv2UxDSP3NpXxroyMG7eGnfk6XEczpgUXl2miyp+7xcQUdubRYjNU0EWUkR08dW9AUTjxEA==", + "integrity": "sha512-3mG44RRJZL4MSjJ/l4VxkVMegrIqZHEzNsh+3ASGMqJXT0uu99X5TmbFFcuUstrCLoSY+sXOqaBnAE7ZdUVHfA==", "dependencies": { "@microsoft/api-extractor": "^7.40.0", "@microsoft/dynamicproto-js": "^2.0.3", @@ -1444,7 +1444,7 @@ "node_modules/@rush-temp/applicationinsights-web-snippet": { "version": "0.0.0", "resolved": "file:projects/applicationinsights-web-snippet.tgz", - "integrity": "sha512-oFy+kRj8pCkEKTCRsKy3GrQ3+FDJIjJ20eh9U3Kc4Q1IchordwCiC9DIaPdATQWnjJJgvtDuOmFnDfQdZLTYxg==", + "integrity": "sha512-/PtsA8Q9K9jXPra/imxYII5nf0xxttVkO4xRT9MpxZvz3OvTkmWakDQpdEIXTQ3Y6j2cZYJOQCkLKmvyqL9tsQ==", "dependencies": { "@microsoft/api-extractor": "^7.40.0", "@microsoft/dynamicproto-js": "^2.0.3", @@ -1526,9 +1526,9 @@ } }, "node_modules/@rushstack/terminal": { - "version": "0.19.5", - "resolved": "https://registry.npmjs.org/@rushstack/terminal/-/terminal-0.19.5.tgz", - "integrity": "sha512-6k5tpdB88G0K7QrH/3yfKO84HK9ggftfUZ51p7fePyCE7+RLLHkWZbID9OFWbXuna+eeCFE7AkKnRMHMxNbz7Q==", + "version": "0.21.0", + "resolved": "https://registry.npmjs.org/@rushstack/terminal/-/terminal-0.21.0.tgz", + "integrity": "sha512-cLaI4HwCNYmknM5ns4G+drqdEB6q3dCPV423+d3TZeBusYSSm09+nR7CnhzJMjJqeRcdMAaLnrA4M/3xDz4R3w==", "dependencies": { "@rushstack/node-core-library": "5.19.1", "@rushstack/problem-matcher": "0.1.1", @@ -1544,11 +1544,11 @@ } }, "node_modules/@rushstack/ts-command-line": { - "version": "5.1.5", - "resolved": "https://registry.npmjs.org/@rushstack/ts-command-line/-/ts-command-line-5.1.5.tgz", - "integrity": "sha512-YmrFTFUdHXblYSa+Xc9OO9FsL/XFcckZy0ycQ6q7VSBsVs5P0uD9vcges5Q9vctGlVdu27w+Ct6IuJ458V0cTQ==", + "version": "5.1.7", + "resolved": "https://registry.npmjs.org/@rushstack/ts-command-line/-/ts-command-line-5.1.7.tgz", + "integrity": "sha512-Ugwl6flarZcL2nqH5IXFYk3UR3mBVDsVFlCQW/Oaqidvdb/5Ota6b/Z3JXWIdqV3rOR2/JrYoAHanWF5rgenXA==", "dependencies": { - "@rushstack/terminal": "0.19.5", + "@rushstack/terminal": "0.21.0", "@types/argparse": "1.0.38", "argparse": "~1.0.9", "string-argv": "~0.3.1" @@ -1811,16 +1811,16 @@ } }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.53.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.53.1.tgz", - "integrity": "sha512-cFYYFZ+oQFi6hUnBTbLRXfTJiaQtYE3t4O692agbBl+2Zy+eqSKWtPjhPXJu1G7j4RLjKgeJPDdq3EqOwmX5Ag==", + "version": "8.54.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.54.0.tgz", + "integrity": "sha512-hAAP5io/7csFStuOmR782YmTthKBJ9ND3WVL60hcOjvtGFb+HJxH4O5huAcmcZ9v9G8P+JETiZ/G1B8MALnWZQ==", "peer": true, "dependencies": { "@eslint-community/regexpp": "^4.12.2", - "@typescript-eslint/scope-manager": "8.53.1", - "@typescript-eslint/type-utils": "8.53.1", - "@typescript-eslint/utils": "8.53.1", - "@typescript-eslint/visitor-keys": "8.53.1", + "@typescript-eslint/scope-manager": "8.54.0", + "@typescript-eslint/type-utils": "8.54.0", + "@typescript-eslint/utils": "8.54.0", + "@typescript-eslint/visitor-keys": "8.54.0", "ignore": "^7.0.5", "natural-compare": "^1.4.0", "ts-api-utils": "^2.4.0" @@ -1833,21 +1833,21 @@ "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "@typescript-eslint/parser": "^8.53.1", + "@typescript-eslint/parser": "^8.54.0", "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "node_modules/@typescript-eslint/parser": { - "version": "8.53.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.53.1.tgz", - "integrity": "sha512-nm3cvFN9SqZGXjmw5bZ6cGmvJSyJPn0wU9gHAZZHDnZl2wF9PhHv78Xf06E0MaNk4zLVHL8hb2/c32XvyJOLQg==", + "version": "8.54.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.54.0.tgz", + "integrity": "sha512-BtE0k6cjwjLZoZixN0t5AKP0kSzlGu7FctRXYuPAm//aaiZhmfq1JwdYpYr1brzEspYyFeF+8XF5j2VK6oalrA==", "peer": true, "dependencies": { - "@typescript-eslint/scope-manager": "8.53.1", - "@typescript-eslint/types": "8.53.1", - "@typescript-eslint/typescript-estree": "8.53.1", - "@typescript-eslint/visitor-keys": "8.53.1", + "@typescript-eslint/scope-manager": "8.54.0", + "@typescript-eslint/types": "8.54.0", + "@typescript-eslint/typescript-estree": "8.54.0", + "@typescript-eslint/visitor-keys": "8.54.0", "debug": "^4.4.3" }, "engines": { @@ -1863,13 +1863,13 @@ } }, "node_modules/@typescript-eslint/project-service": { - "version": "8.53.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.53.1.tgz", - "integrity": "sha512-WYC4FB5Ra0xidsmlPb+1SsnaSKPmS3gsjIARwbEkHkoWloQmuzcfypljaJcR78uyLA1h8sHdWWPHSLDI+MtNog==", + "version": "8.54.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.54.0.tgz", + "integrity": "sha512-YPf+rvJ1s7MyiWM4uTRhE4DvBXrEV+d8oC3P9Y2eT7S+HBS0clybdMIPnhiATi9vZOYDc7OQ1L/i6ga6NFYK/g==", "peer": true, "dependencies": { - "@typescript-eslint/tsconfig-utils": "^8.53.1", - "@typescript-eslint/types": "^8.53.1", + "@typescript-eslint/tsconfig-utils": "^8.54.0", + "@typescript-eslint/types": "^8.54.0", "debug": "^4.4.3" }, "engines": { @@ -1884,13 +1884,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "8.53.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.53.1.tgz", - "integrity": "sha512-Lu23yw1uJMFY8cUeq7JlrizAgeQvWugNQzJp8C3x8Eo5Jw5Q2ykMdiiTB9vBVOOUBysMzmRRmUfwFrZuI2C4SQ==", + "version": "8.54.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.54.0.tgz", + "integrity": "sha512-27rYVQku26j/PbHYcVfRPonmOlVI6gihHtXFbTdB5sb6qA0wdAQAbyXFVarQ5t4HRojIz64IV90YtsjQSSGlQg==", "peer": true, "dependencies": { - "@typescript-eslint/types": "8.53.1", - "@typescript-eslint/visitor-keys": "8.53.1" + "@typescript-eslint/types": "8.54.0", + "@typescript-eslint/visitor-keys": "8.54.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -1901,9 +1901,9 @@ } }, "node_modules/@typescript-eslint/tsconfig-utils": { - "version": "8.53.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.53.1.tgz", - "integrity": "sha512-qfvLXS6F6b1y43pnf0pPbXJ+YoXIC7HKg0UGZ27uMIemKMKA6XH2DTxsEDdpdN29D+vHV07x/pnlPNVLhdhWiA==", + "version": "8.54.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.54.0.tgz", + "integrity": "sha512-dRgOyT2hPk/JwxNMZDsIXDgyl9axdJI3ogZ2XWhBPsnZUv+hPesa5iuhdYt2gzwA9t8RE5ytOJ6xB0moV0Ujvw==", "peer": true, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -1917,14 +1917,14 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "8.53.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.53.1.tgz", - "integrity": "sha512-MOrdtNvyhy0rHyv0ENzub1d4wQYKb2NmIqG7qEqPWFW7Mpy2jzFC3pQ2yKDvirZB7jypm5uGjF2Qqs6OIqu47w==", + "version": "8.54.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.54.0.tgz", + "integrity": "sha512-hiLguxJWHjjwL6xMBwD903ciAwd7DmK30Y9Axs/etOkftC3ZNN9K44IuRD/EB08amu+Zw6W37x9RecLkOo3pMA==", "peer": true, "dependencies": { - "@typescript-eslint/types": "8.53.1", - "@typescript-eslint/typescript-estree": "8.53.1", - "@typescript-eslint/utils": "8.53.1", + "@typescript-eslint/types": "8.54.0", + "@typescript-eslint/typescript-estree": "8.54.0", + "@typescript-eslint/utils": "8.54.0", "debug": "^4.4.3", "ts-api-utils": "^2.4.0" }, @@ -1941,9 +1941,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "8.53.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.53.1.tgz", - "integrity": "sha512-jr/swrr2aRmUAUjW5/zQHbMaui//vQlsZcJKijZf3M26bnmLj8LyZUpj8/Rd6uzaek06OWsqdofN/Thenm5O8A==", + "version": "8.54.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.54.0.tgz", + "integrity": "sha512-PDUI9R1BVjqu7AUDsRBbKMtwmjWcn4J3le+5LpcFgWULN3LvHC5rkc9gCVxbrsrGmO1jfPybN5s6h4Jy+OnkAA==", "peer": true, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -1954,15 +1954,15 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.53.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.53.1.tgz", - "integrity": "sha512-RGlVipGhQAG4GxV1s34O91cxQ/vWiHJTDHbXRr0li2q/BGg3RR/7NM8QDWgkEgrwQYCvmJV9ichIwyoKCQ+DTg==", + "version": "8.54.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.54.0.tgz", + "integrity": "sha512-BUwcskRaPvTk6fzVWgDPdUndLjB87KYDrN5EYGetnktoeAvPtO4ONHlAZDnj5VFnUANg0Sjm7j4usBlnoVMHwA==", "peer": true, "dependencies": { - "@typescript-eslint/project-service": "8.53.1", - "@typescript-eslint/tsconfig-utils": "8.53.1", - "@typescript-eslint/types": "8.53.1", - "@typescript-eslint/visitor-keys": "8.53.1", + "@typescript-eslint/project-service": "8.54.0", + "@typescript-eslint/tsconfig-utils": "8.54.0", + "@typescript-eslint/types": "8.54.0", + "@typescript-eslint/visitor-keys": "8.54.0", "debug": "^4.4.3", "minimatch": "^9.0.5", "semver": "^7.7.3", @@ -2017,15 +2017,15 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "8.53.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.53.1.tgz", - "integrity": "sha512-c4bMvGVWW4hv6JmDUEG7fSYlWOl3II2I4ylt0NM+seinYQlZMQIaKaXIIVJWt9Ofh6whrpM+EdDQXKXjNovvrg==", + "version": "8.54.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.54.0.tgz", + "integrity": "sha512-9Cnda8GS57AQakvRyG0PTejJNlA2xhvyNtEVIMlDWOOeEyBkYWhGPnfrIAnqxLMTSTo6q8g12XVjjev5l1NvMA==", "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.9.1", - "@typescript-eslint/scope-manager": "8.53.1", - "@typescript-eslint/types": "8.53.1", - "@typescript-eslint/typescript-estree": "8.53.1" + "@typescript-eslint/scope-manager": "8.54.0", + "@typescript-eslint/types": "8.54.0", + "@typescript-eslint/typescript-estree": "8.54.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -2040,12 +2040,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.53.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.53.1.tgz", - "integrity": "sha512-oy+wV7xDKFPRyNggmXuZQSBzvoLnpmJs+GhzRhPjrxl2b/jIlyjVokzm47CZCDUdXKr2zd7ZLodPfOBpOPyPlg==", + "version": "8.54.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.54.0.tgz", + "integrity": "sha512-VFlhGSl4opC0bprJiItPQ1RfUhGDIBokcPwaFH4yiBCaNPeld/9VeXbiPO1cLyorQi1G1vL+ecBk1x8o1axORA==", "peer": true, "dependencies": { - "@typescript-eslint/types": "8.53.1", + "@typescript-eslint/types": "8.54.0", "eslint-visitor-keys": "^4.2.1" }, "engines": { @@ -2378,9 +2378,9 @@ } }, "node_modules/bare-fs": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/bare-fs/-/bare-fs-4.5.2.tgz", - "integrity": "sha512-veTnRzkb6aPHOvSKIOy60KzURfBdUflr5VReI+NSaPL6xf+XLdONQgZgpYvUuZLVQ8dCqxpBAudaOM1+KpAUxw==", + "version": "4.5.3", + "resolved": "https://registry.npmjs.org/bare-fs/-/bare-fs-4.5.3.tgz", + "integrity": "sha512-9+kwVx8QYvt3hPWnmb19tPnh38c6Nihz8Lx3t0g9+4GoIf3/fTgYwM4Z6NxgI+B9elLQA7mLE9PpqcWtOMRDiQ==", "optional": true, "dependencies": { "bare-events": "^2.5.4", @@ -2469,9 +2469,9 @@ ] }, "node_modules/baseline-browser-mapping": { - "version": "2.9.17", - "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.9.17.tgz", - "integrity": "sha512-agD0MgJFUP/4nvjqzIB29zRPUuCF7Ge6mEv9s8dHrtYD7QWXRcx75rOADE/d5ah1NI+0vkDl0yorDd5U852IQQ==", + "version": "2.9.19", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.9.19.tgz", + "integrity": "sha512-ipDqC8FrAl/76p2SSWKSI+H9tFwm7vYqXQrItCuiVPt26Km0jS+NzSsBWAaBusvSbQcfJG+JitdMm+wZAgTYqg==", "bin": { "baseline-browser-mapping": "dist/cli.js" } @@ -2586,9 +2586,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001765", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001765.tgz", - "integrity": "sha512-LWcNtSyZrakjECqmpP4qdg0MMGdN368D7X8XvvAqOcqMv0RxnlqVKZl2V6/mBR68oYMxOZPLw/gO7DuisMHUvQ==", + "version": "1.0.30001766", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001766.tgz", + "integrity": "sha512-4C0lfJ0/YPjJQHagaE9x2Elb69CIqEPZeG0anQt9SIvIoOH4a4uaRl73IavyO+0qZh6MDLH//DrXThEYKHkmYA==", "funding": [ { "type": "opencollective", @@ -2966,9 +2966,9 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/electron-to-chromium": { - "version": "1.5.277", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.277.tgz", - "integrity": "sha512-wKXFZw4erWmmOz5N/grBoJ2XrNJGDFMu2+W5ACHza5rHtvsqrK4gb6rnLC7XxKB9WlJ+RmyQatuEXmtm86xbnw==" + "version": "1.5.283", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.283.tgz", + "integrity": "sha512-3vifjt1HgrGW/h76UEeny+adYApveS9dH2h3p57JYzBSXJIKUJAvtmIytDKjcSCt9xHfrNCFJ7gts6vkhuq++w==" }, "node_modules/emoji-regex": { "version": "8.0.0", @@ -6125,9 +6125,9 @@ } }, "node_modules/sinon/node_modules/diff": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.1.tgz", + "integrity": "sha512-Z3u54A8qGyqFOSr2pk0ijYs8mOE9Qz8kTvtKeBI+upoG9j04Sq+oI7W8zAJiQybDcESET8/uIdHzs0p3k4fZlw==", "engines": { "node": ">=0.3.1" } @@ -6676,9 +6676,9 @@ } }, "node_modules/unist-util-visit": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", - "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.1.0.tgz", + "integrity": "sha512-m+vIdyeCOpdr/QeQCu2EzxX/ohgS8KbnPDgFni4dQsfSCtpz8UqDyY5GjRru8PDKuYn7Fq19j1CQ+nJSsGKOzg==", "dependencies": { "@types/unist": "^3.0.0", "unist-util-is": "^6.0.0", diff --git a/docs/upgrade/MergeCommonToCore.md b/docs/upgrade/MergeCommonToCore.md new file mode 100644 index 000000000..265461831 --- /dev/null +++ b/docs/upgrade/MergeCommonToCore.md @@ -0,0 +1,114 @@ +# Migrating from @microsoft/applicationinsights-common to @microsoft/applicationinsights-core-js + +## Overview + +As of version 3.4.0, the `@microsoft/applicationinsights-common` package has been merged into +`@microsoft/applicationinsights-core-js`. This consolidation simplifies the dependency tree +and improves tree-shaking capabilities while maintaining full backward compatibility. + +## What Changed? + +- All functionality from `applicationinsights-common` is now exported from `applicationinsights-core-js` +- The `applicationinsights-common` package still exists as a compatibility layer (re-exports from Core) +- No breaking changes to public APIs +- All imports work the same, just from a different package + +## Migration Steps + +### Step 1: Update Dependencies + +In your `package.json`: + +```json +{ + "dependencies": { + // Before + "@microsoft/applicationinsights-common": "3.3.11", + "@microsoft/applicationinsights-core-js": "3.3.11" + + // After + "@microsoft/applicationinsights-core-js": "3.4.0" + // Remove applicationinsights-common dependency + } +} +``` + +### Step 2: Update Imports + +Find and replace in your source files: + +```typescript +// Before +import { IConfig, ContextTagKeys, Event } from "@microsoft/applicationinsights-common"; + +// After +import { IConfig, ContextTagKeys, Event } from "@microsoft/applicationinsights-core-js"; +``` + +### Automated Migration + +You can use a script to automate the migration: + +```bash +# Replace imports in TypeScript files +find ./src -name "*.ts" -exec sed -i 's/@microsoft\/applicationinsights-common/@microsoft\/applicationinsights-core-js/g' {} + + +# Update package.json manually or with jq +``` + +## Do I Need to Migrate Immediately? + +**No.** The `applicationinsights-common` package will continue to work through version 3.x as a +compatibility layer. However, we recommend migrating when convenient as: + +- The Common package will be removed in version 4.0.0 +- Direct Core imports result in smaller bundles (better tree-shaking) +- Future features will only be added to Core + +## Timeline + +- **Version 3.4.0** (Current): Common merged into Core, compatibility layer introduced +- **Version 3.x** (Ongoing): Both import styles supported +- **Version 4.0.0** (Future): Common package removed, Core imports required + +## What If I Can't Migrate Yet? + +The compatibility layer ensures your code continues to work without changes. However: + +1. Your bundle may be slightly larger (includes the re-export layer) +2. You may see deprecation warnings in development +3. You'll need to migrate before upgrading to version 4.0.0 + +## Troubleshooting + +### TypeScript Type Errors + +If you encounter type errors after migration: + +1. Ensure `@microsoft/applicationinsights-core-js` is version 3.4.0 or higher +2. Remove `@microsoft/applicationinsights-common` from dependencies +3. Clear `node_modules` and reinstall: `rm -rf node_modules && npm install` +4. Restart TypeScript server in your IDE + +### Import Not Found + +If an import can't be found: + +1. Verify the export exists in Core 3.4.0+ +2. Check for typos in import names +3. Ensure you're importing from `@microsoft/applicationinsights-core-js` + +### Bundle Size Increased + +If your bundle size increased after migration: + +1. Ensure you're using `@microsoft/applicationinsights-core-js` 3.4.0+ +2. Remove `@microsoft/applicationinsights-common` from package.json +3. Rebuild with tree-shaking enabled +4. Check for unused imports and remove them + +## Need Help? + +- 📖 [Full Documentation](https://github.com/microsoft/ApplicationInsights-JS) +- 🐛 [Report Issues](https://github.com/microsoft/ApplicationInsights-JS/issues) +- 💬 [Discussions](https://github.com/microsoft/ApplicationInsights-JS/discussions) diff --git a/extensions/applicationinsights-analytics-js/Tests/Unit/src/AnalyticsPlugin.tests.ts b/extensions/applicationinsights-analytics-js/Tests/Unit/src/AnalyticsPlugin.tests.ts index fb399e909..07a788527 100644 --- a/extensions/applicationinsights-analytics-js/Tests/Unit/src/AnalyticsPlugin.tests.ts +++ b/extensions/applicationinsights-analytics-js/Tests/Unit/src/AnalyticsPlugin.tests.ts @@ -16,7 +16,7 @@ import { ExceptionEnvelopeType, TraceEnvelopeType, PageViewPerformanceEnvelopeType -} from "@microsoft/applicationinsights-common"; +} from "@microsoft/applicationinsights-core-js"; import { ITelemetryItem, AppInsightsCore, IPlugin, IConfiguration, IAppInsightsCore, setEnableEnvMocks, getLocation, dumpObj, __getRegisteredEvents, createCookieMgr, findAllScripts } from "@microsoft/applicationinsights-core-js"; import { Sender } from "@microsoft/applicationinsights-channel-js" import { PropertiesPlugin } from "@microsoft/applicationinsights-properties-js"; diff --git a/extensions/applicationinsights-analytics-js/Tests/Unit/src/TelemetryItemCreator.tests.ts b/extensions/applicationinsights-analytics-js/Tests/Unit/src/TelemetryItemCreator.tests.ts index ca9da19cb..d1db042ec 100644 --- a/extensions/applicationinsights-analytics-js/Tests/Unit/src/TelemetryItemCreator.tests.ts +++ b/extensions/applicationinsights-analytics-js/Tests/Unit/src/TelemetryItemCreator.tests.ts @@ -24,7 +24,7 @@ import { TraceEnvelopeType, MetricEnvelopeType, RemoteDependencyEnvelopeType, -} from '@microsoft/applicationinsights-common'; +} from '@microsoft/applicationinsights-core-js'; import { AnalyticsPlugin } from '../../../src/JavaScriptSDK/AnalyticsPlugin' import { IAppInsightsCore, AppInsightsCore, diff --git a/extensions/applicationinsights-analytics-js/package.json b/extensions/applicationinsights-analytics-js/package.json index 2dfc69d92..74a8ba512 100644 --- a/extensions/applicationinsights-analytics-js/package.json +++ b/extensions/applicationinsights-analytics-js/package.json @@ -62,7 +62,6 @@ "@microsoft/dynamicproto-js": "^2.0.3", "@microsoft/applicationinsights-shims": "3.0.1", "@microsoft/applicationinsights-core-js": "3.3.11", - "@microsoft/applicationinsights-common": "3.3.11", "@nevware21/ts-utils": ">= 0.11.8 < 2.x" }, "license": "MIT" diff --git a/extensions/applicationinsights-analytics-js/src/JavaScriptSDK/AnalyticsPlugin.ts b/extensions/applicationinsights-analytics-js/src/JavaScriptSDK/AnalyticsPlugin.ts index 784ccd284..d81c9f218 100644 --- a/extensions/applicationinsights-analytics-js/src/JavaScriptSDK/AnalyticsPlugin.ts +++ b/extensions/applicationinsights-analytics-js/src/JavaScriptSDK/AnalyticsPlugin.ts @@ -5,21 +5,19 @@ import dynamicProto from "@microsoft/dynamicproto-js"; import { - AnalyticsPluginIdentifier, EventDataType, EventEnvelopeType, Exception, ExceptionDataType, ExceptionEnvelopeType, IAppInsights, - IAutoExceptionTelemetry, IConfig, IDependencyTelemetry, IEventTelemetry, IExceptionInternal, IExceptionTelemetry, IMetricTelemetry, - IPageViewPerformanceTelemetry, IPageViewPerformanceTelemetryInternal, IPageViewTelemetry, IPageViewTelemetryInternal, ITraceTelemetry, - MetricDataType, MetricEnvelopeType, PageViewDataType, PageViewEnvelopeType, PageViewPerformanceDataType, PageViewPerformanceEnvelopeType, - RemoteDependencyDataType, TraceDataType, TraceEnvelopeType, createDomEvent, createTelemetryItem, dataSanitizeString, eSeverityLevel, - isCrossOriginError, strNotSpecified, utlDisableStorage, utlEnableStorage, utlSetStoragePrefix -} from "@microsoft/applicationinsights-common"; -import { - BaseTelemetryPlugin, IAppInsightsCore, IConfigDefaults, IConfiguration, ICookieMgr, ICustomProperties, IDistributedTraceContext, - IExceptionConfig, IInstrumentCallDetails, IPlugin, IProcessTelemetryContext, IProcessTelemetryUnloadContext, - ITelemetryInitializerHandler, ITelemetryItem, ITelemetryPluginChain, ITelemetryUnloadState, InstrumentEvent, - TelemetryInitializerFunction, _eInternalMessageId, arrForEach, cfgDfBoolean, cfgDfMerge, cfgDfSet, cfgDfString, cfgDfValidate, - createDistributedTraceContext, createProcessTelemetryContext, createUniqueNamespace, dumpObj, eLoggingSeverity, eventOff, eventOn, - fieldRedaction, findAllScripts, generateW3CId, getDocument, getExceptionName, getHistory, getLocation, getWindow, hasHistory, hasWindow, - isFunction, isNullOrUndefined, isString, isUndefined, mergeEvtNamespace, onConfigChange, safeGetCookieMgr, strUndefined, throwError + AnalyticsPluginIdentifier, BaseTelemetryPlugin, EventDataType, EventEnvelopeType, Exception, ExceptionDataType, ExceptionEnvelopeType, + IAppInsights, IAppInsightsCore, IAutoExceptionTelemetry, IConfig, IConfigDefaults, IConfiguration, ICookieMgr, ICustomProperties, + IDependencyTelemetry, IDistributedTraceContext, IEventTelemetry, IExceptionConfig, IExceptionInternal, IExceptionTelemetry, + IInstrumentCallDetails, IMetricTelemetry, IPageViewPerformanceTelemetry, IPageViewPerformanceTelemetryInternal, IPageViewTelemetry, + IPageViewTelemetryInternal, IPlugin, IProcessTelemetryContext, IProcessTelemetryUnloadContext, ITelemetryInitializerHandler, + ITelemetryItem, ITelemetryPluginChain, ITelemetryUnloadState, ITraceTelemetry, InstrumentEvent, MetricDataType, MetricEnvelopeType, + PageViewDataType, PageViewEnvelopeType, PageViewPerformanceDataType, PageViewPerformanceEnvelopeType, RemoteDependencyDataType, + TelemetryInitializerFunction, TraceDataType, TraceEnvelopeType, _eInternalMessageId, arrForEach, cfgDfBoolean, cfgDfMerge, cfgDfSet, + cfgDfString, cfgDfValidate, createDistributedTraceContext, createDomEvent, createProcessTelemetryContext, createTelemetryItem, + createUniqueNamespace, dataSanitizeString, dumpObj, eLoggingSeverity, eSeverityLevel, eventOff, eventOn, fieldRedaction, findAllScripts, + generateW3CId, getDocument, getExceptionName, getHistory, getLocation, getWindow, hasHistory, hasWindow, isCrossOriginError, isFunction, + isNullOrUndefined, isString, isUndefined, mergeEvtNamespace, onConfigChange, safeGetCookieMgr, strNotSpecified, strUndefined, throwError, + utlDisableStorage, utlEnableStorage, utlSetStoragePrefix } from "@microsoft/applicationinsights-core-js"; import { IAjaxMonitorPlugin } from "@microsoft/applicationinsights-dependencies-js"; import { isArray, isError, objDeepFreeze, objDefine, scheduleTimeout, strIndexOf } from "@nevware21/ts-utils"; diff --git a/extensions/applicationinsights-analytics-js/src/JavaScriptSDK/Telemetry/PageViewManager.ts b/extensions/applicationinsights-analytics-js/src/JavaScriptSDK/Telemetry/PageViewManager.ts index 2032518e3..f3f6847f6 100644 --- a/extensions/applicationinsights-analytics-js/src/JavaScriptSDK/Telemetry/PageViewManager.ts +++ b/extensions/applicationinsights-analytics-js/src/JavaScriptSDK/Telemetry/PageViewManager.ts @@ -2,11 +2,9 @@ // Licensed under the MIT License. import { - IPageViewPerformanceTelemetryInternal, IPageViewTelemetry, IPageViewTelemetryInternal, dateTimeUtilsDuration -} from "@microsoft/applicationinsights-common"; -import { - IAppInsightsCore, IDiagnosticLogger, IProcessTelemetryUnloadContext, ITelemetryUnloadState, _eInternalMessageId, _throwInternal, - arrForEach, dumpObj, eLoggingSeverity, fieldRedaction, getDocument, getExceptionName, getLocation, isNullOrUndefined + IAppInsightsCore, IDiagnosticLogger, IPageViewPerformanceTelemetryInternal, IPageViewTelemetry, IPageViewTelemetryInternal, + IProcessTelemetryUnloadContext, ITelemetryUnloadState, _eInternalMessageId, _throwInternal, arrForEach, dateTimeUtilsDuration, dumpObj, + eLoggingSeverity, fieldRedaction, getDocument, getExceptionName, getLocation, isNullOrUndefined } from "@microsoft/applicationinsights-core-js"; import { ITimerHandler, getPerformance, isUndefined, isWebWorker, scheduleTimeout } from "@nevware21/ts-utils"; import { IPageViewPerformanceManager } from "./PageViewPerformanceManager"; diff --git a/extensions/applicationinsights-analytics-js/src/JavaScriptSDK/Telemetry/PageViewPerformanceManager.ts b/extensions/applicationinsights-analytics-js/src/JavaScriptSDK/Telemetry/PageViewPerformanceManager.ts index 724e01f91..45415ee75 100644 --- a/extensions/applicationinsights-analytics-js/src/JavaScriptSDK/Telemetry/PageViewPerformanceManager.ts +++ b/extensions/applicationinsights-analytics-js/src/JavaScriptSDK/Telemetry/PageViewPerformanceManager.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { IPageViewPerformanceTelemetryInternal, dateTimeUtilsDuration, msToTimeSpan } from "@microsoft/applicationinsights-common"; import { - IAppInsightsCore, IDiagnosticLogger, _eInternalMessageId, _throwInternal, eLoggingSeverity, getNavigator, getPerformance, safeGetLogger + IAppInsightsCore, IDiagnosticLogger, IPageViewPerformanceTelemetryInternal, _eInternalMessageId, _throwInternal, dateTimeUtilsDuration, + eLoggingSeverity, getNavigator, getPerformance, msToTimeSpan, safeGetLogger } from "@microsoft/applicationinsights-core-js"; import { mathFloor, strIndexOf } from "@nevware21/ts-utils"; diff --git a/extensions/applicationinsights-analytics-js/src/JavaScriptSDK/Telemetry/PageVisitTimeManager.ts b/extensions/applicationinsights-analytics-js/src/JavaScriptSDK/Telemetry/PageVisitTimeManager.ts index 403d901ad..7cc4c2d4e 100644 --- a/extensions/applicationinsights-analytics-js/src/JavaScriptSDK/Telemetry/PageVisitTimeManager.ts +++ b/extensions/applicationinsights-analytics-js/src/JavaScriptSDK/Telemetry/PageVisitTimeManager.ts @@ -2,10 +2,8 @@ // Licensed under the MIT License. import { - utlCanUseSessionStorage, utlGetSessionStorage, utlRemoveSessionStorage, utlSetSessionStorage -} from "@microsoft/applicationinsights-common"; -import { - IDiagnosticLogger, _warnToConsole, dateNow, dumpObj, getJSON, hasJSON, throwError + IDiagnosticLogger, _warnToConsole, dateNow, dumpObj, getJSON, hasJSON, throwError, utlCanUseSessionStorage, utlGetSessionStorage, + utlRemoveSessionStorage, utlSetSessionStorage } from "@microsoft/applicationinsights-core-js"; export interface IPageVisitData { diff --git a/extensions/applicationinsights-analytics-js/src/JavaScriptSDK/Timing.ts b/extensions/applicationinsights-analytics-js/src/JavaScriptSDK/Timing.ts index fde3058b3..6cbeee1c6 100644 --- a/extensions/applicationinsights-analytics-js/src/JavaScriptSDK/Timing.ts +++ b/extensions/applicationinsights-analytics-js/src/JavaScriptSDK/Timing.ts @@ -1,8 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { dateTimeUtilsDuration } from "@microsoft/applicationinsights-common"; -import { IDiagnosticLogger, _eInternalMessageId, _throwInternal, eLoggingSeverity } from "@microsoft/applicationinsights-core-js"; +import { + IDiagnosticLogger, _eInternalMessageId, _throwInternal, dateTimeUtilsDuration, eLoggingSeverity +} from "@microsoft/applicationinsights-core-js"; /** * Internal interface for Timing. diff --git a/extensions/applicationinsights-cfgsync-js/Tests/Unit/src/cfgsynchelper.tests.ts b/extensions/applicationinsights-cfgsync-js/Tests/Unit/src/cfgsynchelper.tests.ts index 4bb519311..1b08dfc6d 100644 --- a/extensions/applicationinsights-cfgsync-js/Tests/Unit/src/cfgsynchelper.tests.ts +++ b/extensions/applicationinsights-cfgsync-js/Tests/Unit/src/cfgsynchelper.tests.ts @@ -1,7 +1,7 @@ import { AITestClass, Assert } from "@microsoft/ai-test-framework"; import { NonOverrideCfg } from "../../../src/Interfaces/ICfgSyncConfig"; import { ICookieMgrConfig, AppInsightsCore, CdnFeatureMode, FeatureOptInMode, IAppInsightsCore, IConfiguration, IFeatureOptIn, IFeatureOptInDetails, INotificationManager, IPlugin, ITelemetryItem, PerfManager, suppressTracing } from "@microsoft/applicationinsights-core-js"; -import { IConfig, IStorageBuffer } from "@microsoft/applicationinsights-common"; +import { IConfig, IStorageBuffer } from "@microsoft/applicationinsights-core-js"; import { resolveCdnFeatureCfg, replaceByNonOverrideCfg, applyCdnfeatureCfg } from "../../../src/CfgSyncHelperFuncs"; import { ICfgSyncCdnConfig } from "../../../src/Interfaces/ICfgSyncCdnConfig"; diff --git a/extensions/applicationinsights-cfgsync-js/Tests/Unit/src/cfgsyncplugin.tests.ts b/extensions/applicationinsights-cfgsync-js/Tests/Unit/src/cfgsyncplugin.tests.ts index 9e94cb4a1..41129ecde 100644 --- a/extensions/applicationinsights-cfgsync-js/Tests/Unit/src/cfgsyncplugin.tests.ts +++ b/extensions/applicationinsights-cfgsync-js/Tests/Unit/src/cfgsyncplugin.tests.ts @@ -3,7 +3,7 @@ import { AppInsightsCore, FeatureOptInMode, IAppInsightsCore, IPlugin, ITelemetr import { IConfiguration } from "@microsoft/applicationinsights-core-js"; import { CfgSyncPlugin } from "../../../../applicationinsights-cfgsync-js/src/applicationinsights-cfgsync-js"; import { ICfgSyncConfig, ICfgSyncMode, NonOverrideCfg } from "../../../src/Interfaces/ICfgSyncConfig"; -import { DisabledPropertyName, IConfig } from "@microsoft/applicationinsights-common"; +import { DisabledPropertyName, IConfig } from "@microsoft/applicationinsights-core-js"; import { createSyncPromise } from "@nevware21/ts-async"; diff --git a/extensions/applicationinsights-cfgsync-js/package.json b/extensions/applicationinsights-cfgsync-js/package.json index bc6a6ba6b..3b7c1b5f8 100644 --- a/extensions/applicationinsights-cfgsync-js/package.json +++ b/extensions/applicationinsights-cfgsync-js/package.json @@ -58,7 +58,6 @@ "@microsoft/dynamicproto-js": "^2.0.3", "@microsoft/applicationinsights-shims": "3.0.1", "@microsoft/applicationinsights-core-js": "3.3.11", - "@microsoft/applicationinsights-common": "3.3.11", "@nevware21/ts-utils": ">= 0.11.8 < 2.x", "@nevware21/ts-async": ">= 0.5.4 < 2.x" }, diff --git a/extensions/applicationinsights-cfgsync-js/src/CfgSyncHelperFuncs.ts b/extensions/applicationinsights-cfgsync-js/src/CfgSyncHelperFuncs.ts index 5d5f5ecd0..6e88b750c 100644 --- a/extensions/applicationinsights-cfgsync-js/src/CfgSyncHelperFuncs.ts +++ b/extensions/applicationinsights-cfgsync-js/src/CfgSyncHelperFuncs.ts @@ -1,6 +1,5 @@ -import { IConfig } from "@microsoft/applicationinsights-common"; import { - CdnFeatureMode, FeatureOptInMode, IAppInsightsCore, IConfiguration, IFeatureOptIn + CdnFeatureMode, FeatureOptInMode, IAppInsightsCore, IConfig, IConfiguration, IFeatureOptIn } from "@microsoft/applicationinsights-core-js"; import { isNullOrUndefined, isObject, objExtend, objForEachKey, setValueByKey } from "@nevware21/ts-utils"; import { ICfgSyncCdnConfig } from "./Interfaces/ICfgSyncCdnConfig"; diff --git a/extensions/applicationinsights-cfgsync-js/src/CfgSyncPlugin.ts b/extensions/applicationinsights-cfgsync-js/src/CfgSyncPlugin.ts index 67dba2bd2..cfd0356b5 100644 --- a/extensions/applicationinsights-cfgsync-js/src/CfgSyncPlugin.ts +++ b/extensions/applicationinsights-cfgsync-js/src/CfgSyncPlugin.ts @@ -4,9 +4,8 @@ */ import dynamicProto from "@microsoft/dynamicproto-js"; -import { DisabledPropertyName, IConfig } from "@microsoft/applicationinsights-common"; import { - BaseTelemetryPlugin, IAppInsightsCore, IConfigDefaults, IConfiguration, IPlugin, IProcessTelemetryContext, + BaseTelemetryPlugin, DisabledPropertyName, IAppInsightsCore, IConfig, IConfigDefaults, IConfiguration, IPlugin, IProcessTelemetryContext, IProcessTelemetryUnloadContext, ITelemetryItem, ITelemetryPluginChain, ITelemetryUnloadState, createProcessTelemetryContext, createUniqueNamespace, eventOff, eventOn, getGlobal, getJSON, isFetchSupported, isXhrSupported, mergeEvtNamespace, onConfigChange, sendCustomEvent diff --git a/extensions/applicationinsights-cfgsync-js/src/Interfaces/ICfgSyncConfig.ts b/extensions/applicationinsights-cfgsync-js/src/Interfaces/ICfgSyncConfig.ts index 771e6be4e..a25380cec 100644 --- a/extensions/applicationinsights-cfgsync-js/src/Interfaces/ICfgSyncConfig.ts +++ b/extensions/applicationinsights-cfgsync-js/src/Interfaces/ICfgSyncConfig.ts @@ -1,5 +1,4 @@ -import { IConfig } from "@microsoft/applicationinsights-common"; -import { IConfiguration } from "@microsoft/applicationinsights-core-js"; +import { IConfig, IConfiguration } from "@microsoft/applicationinsights-core-js"; export interface ICfgSyncConfig { /** diff --git a/extensions/applicationinsights-cfgsync-js/src/Interfaces/ICfgSyncPlugin.ts b/extensions/applicationinsights-cfgsync-js/src/Interfaces/ICfgSyncPlugin.ts index bdf9c7624..5086e1ce9 100644 --- a/extensions/applicationinsights-cfgsync-js/src/Interfaces/ICfgSyncPlugin.ts +++ b/extensions/applicationinsights-cfgsync-js/src/Interfaces/ICfgSyncPlugin.ts @@ -1,5 +1,4 @@ -import { IConfig } from "@microsoft/applicationinsights-common"; -import { IConfiguration } from "@microsoft/applicationinsights-core-js"; +import { IConfig, IConfiguration } from "@microsoft/applicationinsights-core-js"; export declare interface ICfgSyncPlugin { /** @@ -32,4 +31,4 @@ export declare interface ICfgSyncPlugin { * Resume the sending/receiving of events */ resume(): void; -} \ No newline at end of file +} diff --git a/extensions/applicationinsights-clickanalytics-js/Tests/Unit/src/ClickEventTest.ts b/extensions/applicationinsights-clickanalytics-js/Tests/Unit/src/ClickEventTest.ts index 1951ad91f..4e5953219 100644 --- a/extensions/applicationinsights-clickanalytics-js/Tests/Unit/src/ClickEventTest.ts +++ b/extensions/applicationinsights-clickanalytics-js/Tests/Unit/src/ClickEventTest.ts @@ -3,7 +3,7 @@ */ import { Assert, AITestClass } from "@microsoft/ai-test-framework"; -import { IConfig, utlCanUseLocalStorage } from "@microsoft/applicationinsights-common"; +import { IConfig, utlCanUseLocalStorage } from "@microsoft/applicationinsights-core-js"; import { ITelemetryItem, AppInsightsCore, IPlugin, IConfiguration, DiagnosticLogger, hasDocument, isFunction, IAppInsightsCore } from '@microsoft/applicationinsights-core-js'; import { ClickAnalyticsPlugin, BehaviorMapValidator, BehaviorValueValidator, BehaviorEnumValidator } from '../../../src/ClickAnalyticsPlugin'; import { PageAction } from "../../../src/events/PageAction"; diff --git a/extensions/applicationinsights-clickanalytics-js/package.json b/extensions/applicationinsights-clickanalytics-js/package.json index 648b11b22..d102eba81 100644 --- a/extensions/applicationinsights-clickanalytics-js/package.json +++ b/extensions/applicationinsights-clickanalytics-js/package.json @@ -52,7 +52,6 @@ "@microsoft/dynamicproto-js": "^2.0.3", "@microsoft/applicationinsights-shims": "3.0.1", "@microsoft/applicationinsights-core-js": "3.3.11", - "@microsoft/applicationinsights-common": "3.3.11", "@microsoft/applicationinsights-properties-js": "3.3.11", "@nevware21/ts-utils": ">= 0.11.8 < 2.x" }, diff --git a/extensions/applicationinsights-clickanalytics-js/src/ClickAnalyticsPlugin.ts b/extensions/applicationinsights-clickanalytics-js/src/ClickAnalyticsPlugin.ts index 5cd0502ad..da4cb1b7f 100644 --- a/extensions/applicationinsights-clickanalytics-js/src/ClickAnalyticsPlugin.ts +++ b/extensions/applicationinsights-clickanalytics-js/src/ClickAnalyticsPlugin.ts @@ -3,12 +3,12 @@ */ import dynamicProto from "@microsoft/dynamicproto-js"; -import { IConfig, IPropertiesPlugin, PropertiesPluginIdentifier } from "@microsoft/applicationinsights-common"; import { - BaseTelemetryPlugin, IAppInsightsCore, IConfigDefaults, IConfiguration, ICustomProperties, IPlugin, IProcessTelemetryContext, - IProcessTelemetryUnloadContext, ITelemetryItem, ITelemetryPluginChain, ITelemetryUnloadState, _eInternalMessageId, _throwInternal, - arrForEach, cfgDfFunc, cfgDfMerge, cfgDfString, cfgDfValidate, createProcessTelemetryContext, dumpObj, eLoggingSeverity, - getExceptionName, isNullOrUndefined, onConfigChange, throwError, unloadComponents + BaseTelemetryPlugin, IAppInsightsCore, IConfig, IConfigDefaults, IConfiguration, ICustomProperties, IPlugin, IProcessTelemetryContext, + IProcessTelemetryUnloadContext, IPropertiesPlugin, ITelemetryItem, ITelemetryPluginChain, ITelemetryUnloadState, + PropertiesPluginIdentifier, _eInternalMessageId, _throwInternal, arrForEach, cfgDfFunc, cfgDfMerge, cfgDfString, cfgDfValidate, + createProcessTelemetryContext, dumpObj, eLoggingSeverity, getExceptionName, isNullOrUndefined, onConfigChange, throwError, + unloadComponents } from "@microsoft/applicationinsights-core-js"; import { PropertiesPlugin } from "@microsoft/applicationinsights-properties-js"; import { getDocument, hasDocument, objDeepFreeze, strSubstring, strTrim } from "@nevware21/ts-utils"; diff --git a/extensions/applicationinsights-clickanalytics-js/src/Interfaces/Datamodel.ts b/extensions/applicationinsights-clickanalytics-js/src/Interfaces/Datamodel.ts index d57aba03d..da6a7c938 100644 --- a/extensions/applicationinsights-clickanalytics-js/src/Interfaces/Datamodel.ts +++ b/extensions/applicationinsights-clickanalytics-js/src/Interfaces/Datamodel.ts @@ -2,8 +2,7 @@ * @copyright Microsoft 2020 */ -import { IEventTelemetry } from "@microsoft/applicationinsights-common"; -import { IUnloadableComponent } from "@microsoft/applicationinsights-core-js"; +import { IEventTelemetry, IUnloadableComponent } from "@microsoft/applicationinsights-core-js"; /** * ClickAnalytics Configuration diff --git a/extensions/applicationinsights-clickanalytics-js/src/events/PageAction.ts b/extensions/applicationinsights-clickanalytics-js/src/events/PageAction.ts index 8461e2d8f..f4afa0327 100644 --- a/extensions/applicationinsights-clickanalytics-js/src/events/PageAction.ts +++ b/extensions/applicationinsights-clickanalytics-js/src/events/PageAction.ts @@ -3,10 +3,9 @@ */ import dynamicProto from "@microsoft/dynamicproto-js"; -import { strNotSpecified } from "@microsoft/applicationinsights-common"; import { ICustomProperties, IDiagnosticLogger, ITelemetryItem, _eInternalMessageId, _throwInternal, eLoggingSeverity, getPerformance, objExtend, - objForEachKey + objForEachKey, strNotSpecified } from "@microsoft/applicationinsights-core-js"; import { ClickAnalyticsPlugin } from "../ClickAnalyticsPlugin"; import { getClickTarget } from "../DataCollector"; diff --git a/extensions/applicationinsights-debugplugin-js/package.json b/extensions/applicationinsights-debugplugin-js/package.json index 0b9d17f37..23c28e883 100644 --- a/extensions/applicationinsights-debugplugin-js/package.json +++ b/extensions/applicationinsights-debugplugin-js/package.json @@ -52,7 +52,6 @@ }, "dependencies": { "@microsoft/dynamicproto-js": "^2.0.3", - "@microsoft/applicationinsights-common": "3.3.11", "@microsoft/applicationinsights-core-js": "3.3.11", "@microsoft/applicationinsights-shims": "3.0.1", "@nevware21/ts-utils": ">= 0.11.8 < 2.x" diff --git a/extensions/applicationinsights-dependencies-js/Tests/Unit/src/W3CTraceStateDependency.tests.ts b/extensions/applicationinsights-dependencies-js/Tests/Unit/src/W3CTraceStateDependency.tests.ts index b5ab860b9..d2dd4fba0 100644 --- a/extensions/applicationinsights-dependencies-js/Tests/Unit/src/W3CTraceStateDependency.tests.ts +++ b/extensions/applicationinsights-dependencies-js/Tests/Unit/src/W3CTraceStateDependency.tests.ts @@ -1,6 +1,6 @@ import { Assert, AITestClass } from "@microsoft/ai-test-framework"; -import { eDistributedTracingModes } from "@microsoft/applicationinsights-common"; -import { RequestHeaders } from "@microsoft/applicationinsights-common"; +import { eDistributedTracingModes } from "@microsoft/applicationinsights-core-js"; +import { RequestHeaders } from "@microsoft/applicationinsights-core-js"; import { AppInsightsCore } from "@microsoft/applicationinsights-core-js"; import { createPromise } from "@nevware21/ts-async"; diff --git a/extensions/applicationinsights-dependencies-js/Tests/Unit/src/ajax.tests.ts b/extensions/applicationinsights-dependencies-js/Tests/Unit/src/ajax.tests.ts index a3d6db09b..2714c94b8 100644 --- a/extensions/applicationinsights-dependencies-js/Tests/Unit/src/ajax.tests.ts +++ b/extensions/applicationinsights-dependencies-js/Tests/Unit/src/ajax.tests.ts @@ -2,7 +2,7 @@ import { SinonStub } from "sinon"; import { Assert, AITestClass, PollingAssert } from "@microsoft/ai-test-framework"; import { createAllPromise, createAsyncResolvedPromise, createPromise, createSyncPromise, createTimeoutPromise } from "@nevware21/ts-async"; import { AjaxMonitor } from "../../../src/ajax"; -import { DisabledPropertyName, IConfig, DistributedTracingModes, RequestHeaders, IDependencyTelemetry, IRequestContext, formatTraceParent, createTraceParent, PropertiesPluginIdentifier } from "@microsoft/applicationinsights-common"; +import { DisabledPropertyName, IConfig, DistributedTracingModes, RequestHeaders, IDependencyTelemetry, IRequestContext, formatTraceParent, createTraceParent, PropertiesPluginIdentifier } from "@microsoft/applicationinsights-core-js"; import { AppInsightsCore, IConfiguration, ITelemetryItem, ITelemetryPlugin, IChannelControls, _eInternalMessageId, getPerformance, getGlobalInst, getGlobal, generateW3CId, arrForEach, diff --git a/extensions/applicationinsights-dependencies-js/package.json b/extensions/applicationinsights-dependencies-js/package.json index 70b7b9f98..b779cbfd7 100644 --- a/extensions/applicationinsights-dependencies-js/package.json +++ b/extensions/applicationinsights-dependencies-js/package.json @@ -58,7 +58,6 @@ "@microsoft/dynamicproto-js": "^2.0.3", "@microsoft/applicationinsights-shims": "3.0.1", "@microsoft/applicationinsights-core-js": "3.3.11", - "@microsoft/applicationinsights-common": "3.3.11", "@nevware21/ts-utils": ">= 0.11.8 < 2.x", "@nevware21/ts-async": ">= 0.5.4 < 2.x" }, diff --git a/extensions/applicationinsights-dependencies-js/src/DependencyInitializer.ts b/extensions/applicationinsights-dependencies-js/src/DependencyInitializer.ts index c61892acf..5a090e557 100644 --- a/extensions/applicationinsights-dependencies-js/src/DependencyInitializer.ts +++ b/extensions/applicationinsights-dependencies-js/src/DependencyInitializer.ts @@ -1,4 +1,4 @@ -import { IDependencyTelemetry } from "@microsoft/applicationinsights-common"; +import { IDependencyTelemetry } from "@microsoft/applicationinsights-core-js"; import { IDependencyHandler } from "./DependencyListener"; export interface IDependencyInitializerDetails { diff --git a/extensions/applicationinsights-dependencies-js/src/ajax.ts b/extensions/applicationinsights-dependencies-js/src/ajax.ts index 160c23d3a..6cc0d50fa 100644 --- a/extensions/applicationinsights-dependencies-js/src/ajax.ts +++ b/extensions/applicationinsights-dependencies-js/src/ajax.ts @@ -3,18 +3,16 @@ import dynamicProto from "@microsoft/dynamicproto-js"; import { - DisabledPropertyName, IConfig, ICorrelationConfig, IDependencyTelemetry, IRequestContext, ITelemetryContext, PropertiesPluginIdentifier, - RemoteDependencyDataType, RemoteDependencyEnvelopeType, RequestHeaders, correlationIdCanIncludeCorrelationHeader, - correlationIdGetCorrelationContext, createDistributedTraceContextFromTrace, createTelemetryItem, createTraceParent, dateTimeUtilsNow, - eDistributedTracingModes, eRequestHeaders, formatTraceParent, isInternalApplicationInsightsEndpoint -} from "@microsoft/applicationinsights-common"; -import { - BaseTelemetryPlugin, IAppInsightsCore, IConfigDefaults, IConfiguration, ICustomProperties, IDistributedTraceContext, - IInstrumentCallDetails, IInstrumentHooksCallbacks, IPlugin, IProcessTelemetryContext, ITelemetryItem, ITelemetryPluginChain, - InstrumentFunc, InstrumentProto, _eInternalMessageId, _throwInternal, arrForEach, createDistributedTraceContext, - createProcessTelemetryContext, createUniqueNamespace, dumpObj, eLoggingSeverity, eW3CTraceFlags, eventOn, fieldRedaction, generateW3CId, - getExceptionName, getGlobal, getIEVersion, getLocation, getPerformance, isFunction, isNullOrUndefined, isString, isXhrSupported, - mergeEvtNamespace, onConfigChange, strPrototype, strTrim + BaseTelemetryPlugin, DisabledPropertyName, IAppInsightsCore, IConfig, IConfigDefaults, IConfiguration, ICorrelationConfig, + ICustomProperties, IDependencyTelemetry, IDistributedTraceContext, IInstrumentCallDetails, IInstrumentHooksCallbacks, IPlugin, + IProcessTelemetryContext, IRequestContext, ITelemetryContext, ITelemetryItem, ITelemetryPluginChain, InstrumentFunc, InstrumentProto, + PropertiesPluginIdentifier, RemoteDependencyDataType, RemoteDependencyEnvelopeType, RequestHeaders, _eInternalMessageId, _throwInternal, + arrForEach, correlationIdCanIncludeCorrelationHeader, correlationIdGetCorrelationContext, createDistributedTraceContext, + createDistributedTraceContextFromTrace, createProcessTelemetryContext, createTelemetryItem, createTraceParent, createUniqueNamespace, + dateTimeUtilsNow, dumpObj, eDistributedTracingModes, eLoggingSeverity, eRequestHeaders, eW3CTraceFlags, eventOn, fieldRedaction, + formatTraceParent, generateW3CId, getExceptionName, getGlobal, getIEVersion, getLocation, getPerformance, isFunction, + isInternalApplicationInsightsEndpoint, isNullOrUndefined, isString, isXhrSupported, mergeEvtNamespace, onConfigChange, strPrototype, + strTrim } from "@microsoft/applicationinsights-core-js"; import { isWebWorker, objDefineProps, objFreeze, scheduleTimeout, strIndexOf, strSplit, strSubstr } from "@nevware21/ts-utils"; import { DependencyInitializerFunction, IDependencyInitializerDetails, IDependencyInitializerHandler } from "./DependencyInitializer"; diff --git a/extensions/applicationinsights-dependencies-js/src/ajaxRecord.ts b/extensions/applicationinsights-dependencies-js/src/ajaxRecord.ts index 407948145..d18b79819 100644 --- a/extensions/applicationinsights-dependencies-js/src/ajaxRecord.ts +++ b/extensions/applicationinsights-dependencies-js/src/ajaxRecord.ts @@ -3,10 +3,8 @@ import type { IAjaxRecordInternal } from "./ajax"; import { - Extensions, IDependencyTelemetry, dataSanitizeUrl, dateTimeUtilsDuration, msToTimeSpan, urlGetAbsoluteUrl, urlGetCompleteUrl -} from "@microsoft/applicationinsights-common"; -import { - IDiagnosticLogger, IDistributedTraceContext, arrForEach, isNullOrUndefined, isNumber, isString, normalizeJsName, objForEachKey, objKeys + Extensions, IDependencyTelemetry, IDiagnosticLogger, IDistributedTraceContext, arrForEach, dataSanitizeUrl, dateTimeUtilsDuration, + isNullOrUndefined, isNumber, isString, msToTimeSpan, normalizeJsName, objForEachKey, objKeys, urlGetAbsoluteUrl, urlGetCompleteUrl } from "@microsoft/applicationinsights-core-js"; import { mathRound } from "@nevware21/ts-utils"; import { STR_DURATION, STR_PROPERTIES } from "./InternalConstants"; diff --git a/extensions/applicationinsights-dependencies-js/src/applicationinsights-dependencies-js.ts b/extensions/applicationinsights-dependencies-js/src/applicationinsights-dependencies-js.ts index 73a194492..2389a5060 100644 --- a/extensions/applicationinsights-dependencies-js/src/applicationinsights-dependencies-js.ts +++ b/extensions/applicationinsights-dependencies-js/src/applicationinsights-dependencies-js.ts @@ -6,4 +6,4 @@ export { } from "./ajax"; export { IDependencyHandler, IDependencyListenerHandler, IDependencyListenerDetails, DependencyListenerFunction } from "./DependencyListener"; export { IDependencyInitializerHandler, IDependencyInitializerDetails, DependencyInitializerFunction } from "./DependencyInitializer"; -export { ICorrelationConfig, eDistributedTracingModes, DistributedTracingModes } from "@microsoft/applicationinsights-common"; +export { ICorrelationConfig, eDistributedTracingModes, DistributedTracingModes } from "@microsoft/applicationinsights-core-js"; diff --git a/extensions/applicationinsights-osplugin-js/package.json b/extensions/applicationinsights-osplugin-js/package.json index 60676de71..8395bd10e 100644 --- a/extensions/applicationinsights-osplugin-js/package.json +++ b/extensions/applicationinsights-osplugin-js/package.json @@ -30,7 +30,6 @@ }, "dependencies": { "@microsoft/applicationinsights-shims": "3.0.1", - "@microsoft/applicationinsights-common": "3.3.11", "@microsoft/dynamicproto-js": "^2.0.3", "@microsoft/applicationinsights-core-js": "3.3.11", "@nevware21/ts-utils": ">= 0.11.8 < 2.x", diff --git a/extensions/applicationinsights-osplugin-js/src/OsPlugin.ts b/extensions/applicationinsights-osplugin-js/src/OsPlugin.ts index f51f7c55d..a559e0608 100644 --- a/extensions/applicationinsights-osplugin-js/src/OsPlugin.ts +++ b/extensions/applicationinsights-osplugin-js/src/OsPlugin.ts @@ -5,13 +5,11 @@ */ import dynamicProto from "@microsoft/dynamicproto-js"; import { - Extensions, IConfig, utlCanUseSessionStorage, utlGetSessionStorage, utlSetSessionStorage -} from "@microsoft/applicationinsights-common"; -import { - BaseTelemetryPlugin, IAppInsightsCore, IConfigDefaults, IConfiguration, IPlugin, IProcessTelemetryContext, + BaseTelemetryPlugin, Extensions, IAppInsightsCore, IConfig, IConfigDefaults, IConfiguration, IPlugin, IProcessTelemetryContext, IProcessTelemetryUnloadContext, ITelemetryItem, ITelemetryUnloadState, _eInternalMessageId, _throwInternal, addPageHideEventListener, addPageUnloadEventListener, arrForEach, createProcessTelemetryContext, createUniqueNamespace, eLoggingSeverity, getSetValue, - mergeEvtNamespace, onConfigChange, removePageHideEventListener, removePageUnloadEventListener, setValue + mergeEvtNamespace, onConfigChange, removePageHideEventListener, removePageUnloadEventListener, setValue, utlCanUseSessionStorage, + utlGetSessionStorage, utlSetSessionStorage } from "@microsoft/applicationinsights-core-js"; import { IPromise, doAwaitResponse } from "@nevware21/ts-async"; import { ITimerHandler, isString, objDeepFreeze, scheduleTimeout } from "@nevware21/ts-utils"; diff --git a/extensions/applicationinsights-properties-js/Tests/Unit/src/properties.tests.ts b/extensions/applicationinsights-properties-js/Tests/Unit/src/properties.tests.ts index 69630dafa..d93f2ad01 100644 --- a/extensions/applicationinsights-properties-js/Tests/Unit/src/properties.tests.ts +++ b/extensions/applicationinsights-properties-js/Tests/Unit/src/properties.tests.ts @@ -3,7 +3,7 @@ import { AppInsightsCore, IConfiguration, DiagnosticLogger, ITelemetryItem, crea import PropertiesPlugin from "../../../src/PropertiesPlugin"; import { IPropertiesConfig } from "../../../src/Interfaces/IPropertiesConfig"; import { TelemetryContext } from "../../../src/TelemetryContext"; -import { IConfig, utlCanUseLocalStorage, utlGetLocalStorage } from "@microsoft/applicationinsights-common"; +import { IConfig, utlCanUseLocalStorage, utlGetLocalStorage } from "@microsoft/applicationinsights-core-js"; import { TestChannelPlugin } from "./TestChannelPlugin"; import { SinonStub } from 'sinon'; diff --git a/extensions/applicationinsights-properties-js/package.json b/extensions/applicationinsights-properties-js/package.json index b0f3b23f7..5d99cf531 100644 --- a/extensions/applicationinsights-properties-js/package.json +++ b/extensions/applicationinsights-properties-js/package.json @@ -59,7 +59,6 @@ "@microsoft/dynamicproto-js": "^2.0.3", "@microsoft/applicationinsights-shims": "3.0.1", "@microsoft/applicationinsights-core-js": "3.3.11", - "@microsoft/applicationinsights-common": "3.3.11", "@nevware21/ts-utils": ">= 0.11.8 < 2.x" }, "license": "MIT" diff --git a/extensions/applicationinsights-properties-js/src/Context/Application.ts b/extensions/applicationinsights-properties-js/src/Context/Application.ts index 5fa0e2e01..0ef9cf9f6 100644 --- a/extensions/applicationinsights-properties-js/src/Context/Application.ts +++ b/extensions/applicationinsights-properties-js/src/Context/Application.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { IApplication } from "@microsoft/applicationinsights-common"; +import { IApplication } from "@microsoft/applicationinsights-core-js"; export class Application implements IApplication { /** diff --git a/extensions/applicationinsights-properties-js/src/Context/Device.ts b/extensions/applicationinsights-properties-js/src/Context/Device.ts index be7f00c14..c956b9022 100644 --- a/extensions/applicationinsights-properties-js/src/Context/Device.ts +++ b/extensions/applicationinsights-properties-js/src/Context/Device.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { IDevice } from "@microsoft/applicationinsights-common"; +import { IDevice } from "@microsoft/applicationinsights-core-js"; export class Device implements IDevice { diff --git a/extensions/applicationinsights-properties-js/src/Context/Internal.ts b/extensions/applicationinsights-properties-js/src/Context/Internal.ts index c216bc0b2..052f3b33d 100644 --- a/extensions/applicationinsights-properties-js/src/Context/Internal.ts +++ b/extensions/applicationinsights-properties-js/src/Context/Internal.ts @@ -1,8 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { IInternal } from "@microsoft/applicationinsights-common"; -import { IUnloadHookContainer, onConfigChange } from "@microsoft/applicationinsights-core-js"; +import { IInternal, IUnloadHookContainer, onConfigChange } from "@microsoft/applicationinsights-core-js"; import { IPropertiesConfig } from "../Interfaces/IPropertiesConfig"; const Version = "#version#"; @@ -46,4 +45,4 @@ export class Internal implements IInternal { unloadHookContainer && unloadHookContainer.add(unloadHook); } -} \ No newline at end of file +} diff --git a/extensions/applicationinsights-properties-js/src/Context/Location.ts b/extensions/applicationinsights-properties-js/src/Context/Location.ts index 2dbf20681..eb7c9e22d 100644 --- a/extensions/applicationinsights-properties-js/src/Context/Location.ts +++ b/extensions/applicationinsights-properties-js/src/Context/Location.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { ILocation } from "@microsoft/applicationinsights-common"; +import { ILocation } from "@microsoft/applicationinsights-core-js"; export class Location implements ILocation { diff --git a/extensions/applicationinsights-properties-js/src/Context/Session.ts b/extensions/applicationinsights-properties-js/src/Context/Session.ts index fdd938ede..6b47d25cb 100644 --- a/extensions/applicationinsights-properties-js/src/Context/Session.ts +++ b/extensions/applicationinsights-properties-js/src/Context/Session.ts @@ -3,11 +3,9 @@ import dynamicProto from "@microsoft/dynamicproto-js"; import { - ISession, ISessionManager, utlCanUseLocalStorage, utlGetLocalStorage, utlSetLocalStorage -} from "@microsoft/applicationinsights-common"; -import { - IAppInsightsCore, ICookieMgr, IDiagnosticLogger, IUnloadHookContainer, _eInternalMessageId, _throwInternal, dateNow, dumpObj, - eLoggingSeverity, getExceptionName, isFunction, newId, onConfigChange, safeGetCookieMgr, safeGetLogger + IAppInsightsCore, ICookieMgr, IDiagnosticLogger, ISession, ISessionManager, IUnloadHookContainer, _eInternalMessageId, _throwInternal, + dateNow, dumpObj, eLoggingSeverity, getExceptionName, isFunction, newId, onConfigChange, safeGetCookieMgr, safeGetLogger, + utlCanUseLocalStorage, utlGetLocalStorage, utlSetLocalStorage } from "@microsoft/applicationinsights-core-js"; const SESSION_COOKIE_NAME = "ai_session"; diff --git a/extensions/applicationinsights-properties-js/src/Context/User.ts b/extensions/applicationinsights-properties-js/src/Context/User.ts index 7418b6f3f..b2cdcb475 100644 --- a/extensions/applicationinsights-properties-js/src/Context/User.ts +++ b/extensions/applicationinsights-properties-js/src/Context/User.ts @@ -2,10 +2,9 @@ // Licensed under the MIT License. import dynamicProto from "@microsoft/dynamicproto-js"; -import { IUserContext, utlRemoveStorage } from "@microsoft/applicationinsights-common"; import { - IAppInsightsCore, ICookieMgr, IUnloadHookContainer, _eInternalMessageId, _throwInternal, eLoggingSeverity, newId, onConfigChange, - safeGetCookieMgr, safeGetLogger, toISOString + IAppInsightsCore, ICookieMgr, IUnloadHookContainer, IUserContext, _eInternalMessageId, _throwInternal, eLoggingSeverity, newId, + onConfigChange, safeGetCookieMgr, safeGetLogger, toISOString, utlRemoveStorage } from "@microsoft/applicationinsights-core-js"; import { objDefine } from "@nevware21/ts-utils"; import { IPropertiesConfig } from "../Interfaces/IPropertiesConfig"; diff --git a/extensions/applicationinsights-properties-js/src/Interfaces/IPropTelemetryContext.ts b/extensions/applicationinsights-properties-js/src/Interfaces/IPropTelemetryContext.ts index 00d05065f..ec64a96be 100644 --- a/extensions/applicationinsights-properties-js/src/Interfaces/IPropTelemetryContext.ts +++ b/extensions/applicationinsights-properties-js/src/Interfaces/IPropTelemetryContext.ts @@ -1,8 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { ISessionManager, ITelemetryContext } from "@microsoft/applicationinsights-common"; -import { IProcessTelemetryContext, ITelemetryItem } from "@microsoft/applicationinsights-core-js"; +import { IProcessTelemetryContext, ISessionManager, ITelemetryContext, ITelemetryItem } from "@microsoft/applicationinsights-core-js"; export interface IPropTelemetryContext extends ITelemetryContext { readonly sessionManager: ISessionManager; // The session manager that manages session on the base of cookies. diff --git a/extensions/applicationinsights-properties-js/src/PropertiesPlugin.ts b/extensions/applicationinsights-properties-js/src/PropertiesPlugin.ts index 2efd95fe5..7db256a34 100644 --- a/extensions/applicationinsights-properties-js/src/PropertiesPlugin.ts +++ b/extensions/applicationinsights-properties-js/src/PropertiesPlugin.ts @@ -5,12 +5,11 @@ import dynamicProto from "@microsoft/dynamicproto-js"; import { - BreezeChannelIdentifier, IConfig, IPropertiesPlugin, PageView, PageViewEnvelopeType, PropertiesPluginIdentifier, utlSetStoragePrefix -} from "@microsoft/applicationinsights-common"; -import { - BaseTelemetryPlugin, IAppInsightsCore, IConfigDefaults, IConfiguration, IPlugin, IProcessTelemetryContext, - IProcessTelemetryUnloadContext, ITelemetryItem, ITelemetryPluginChain, ITelemetryUnloadState, _InternalLogMessage, _eInternalMessageId, - _logInternalMessage, createProcessTelemetryContext, eLoggingSeverity, getNavigator, getSetValue, isNullOrUndefined, onConfigChange + BaseTelemetryPlugin, BreezeChannelIdentifier, IAppInsightsCore, IConfig, IConfigDefaults, IConfiguration, IPlugin, + IProcessTelemetryContext, IProcessTelemetryUnloadContext, IPropertiesPlugin, ITelemetryItem, ITelemetryPluginChain, + ITelemetryUnloadState, PageView, PageViewEnvelopeType, PropertiesPluginIdentifier, _InternalLogMessage, _eInternalMessageId, + _logInternalMessage, createProcessTelemetryContext, eLoggingSeverity, getNavigator, getSetValue, isNullOrUndefined, onConfigChange, + utlSetStoragePrefix } from "@microsoft/applicationinsights-core-js"; import { isString, objDeepFreeze, objDefine } from "@nevware21/ts-utils"; import { IPropTelemetryContext } from "./Interfaces/IPropTelemetryContext"; diff --git a/extensions/applicationinsights-properties-js/src/TelemetryContext.ts b/extensions/applicationinsights-properties-js/src/TelemetryContext.ts index a740d7705..b040d4ec8 100644 --- a/extensions/applicationinsights-properties-js/src/TelemetryContext.ts +++ b/extensions/applicationinsights-properties-js/src/TelemetryContext.ts @@ -5,12 +5,9 @@ import dynamicProto from "@microsoft/dynamicproto-js"; import { - CtxTagKeys, Extensions, IApplication, IDevice, IInternal, ILocation, IOperatingSystem, ISession, ISessionManager, ITelemetryTrace, - IUserContext, IWeb, PageViewDataType, dataSanitizeString -} from "@microsoft/applicationinsights-common"; -import { - IAppInsightsCore, IDistributedTraceContext, IProcessTelemetryContext, ITelemetryItem, IUnloadHookContainer, _InternalLogMessage, - getSetValue, hasWindow, isNullOrUndefined, isString, objKeys, setValue + CtxTagKeys, Extensions, IAppInsightsCore, IApplication, IDevice, IDistributedTraceContext, IInternal, ILocation, IOperatingSystem, + IProcessTelemetryContext, ISession, ISessionManager, ITelemetryItem, ITelemetryTrace, IUnloadHookContainer, IUserContext, IWeb, + PageViewDataType, _InternalLogMessage, dataSanitizeString, getSetValue, hasWindow, isNullOrUndefined, isString, objKeys, setValue } from "@microsoft/applicationinsights-core-js"; import { fnCall, getDeferred, isFunction, isUndefined, objDefine, objDefineProps, strLetterCase } from "@nevware21/ts-utils"; import { Application } from "./Context/Application"; diff --git a/extensions/applicationinsights-properties-js/src/applicationinsights-properties-js.ts b/extensions/applicationinsights-properties-js/src/applicationinsights-properties-js.ts index 23093f467..86161ec14 100644 --- a/extensions/applicationinsights-properties-js/src/applicationinsights-properties-js.ts +++ b/extensions/applicationinsights-properties-js/src/applicationinsights-properties-js.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. import PropertiesPlugin from "./PropertiesPlugin"; -import { ITelemetryTrace } from "@microsoft/applicationinsights-common"; +import { ITelemetryTrace } from "@microsoft/applicationinsights-core-js"; import { ISessionConfig, Session, _SessionManager } from "./Context/Session"; import { IPropTelemetryContext } from "./Interfaces/IPropTelemetryContext"; diff --git a/gruntfile.js b/gruntfile.js index 1b81f6cd8..b96aa687d 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -292,7 +292,7 @@ module.exports = function (grunt) { var internalConstants = aiInternalConstants; if (pkg['name'] === "@microsoft/applicationinsights-core-js") { nameMaps = aiCoreDefaultNameReplacements; - internalConstants = [ "./src/JavaScriptSDK/InternalConstants.ts" ]; + internalConstants = [ "./src/constants/InternalConstants.ts" ]; } var aiMinify = buildCmds["ai-minify"]; @@ -859,8 +859,8 @@ module.exports = function (grunt) { grunt.registerTask("common", tsBuildActions("common")); grunt.registerTask("common-min", minTasks("common")); grunt.registerTask("common-restore", restoreTasks("common")); - grunt.registerTask("commontest", tsTestActions("common")); - grunt.registerTask("common-mintest", tsTestActions("common", true)); + grunt.registerTask("commontest", []); + grunt.registerTask("common-mintest", []); grunt.registerTask("ai", tsBuildActions("appinsights")); grunt.registerTask("ai-min", minTasks("appinsights")); diff --git a/shared/1ds-core-js/src/AppInsightsCore.ts b/shared/1ds-core-js/src/AppInsightsCore.ts index c926f15a2..76dadcb27 100644 --- a/shared/1ds-core-js/src/AppInsightsCore.ts +++ b/shared/1ds-core-js/src/AppInsightsCore.ts @@ -19,11 +19,12 @@ import { FullVersionString, getTime, isLatency } from "./Utils"; * WE MUST include all defaults here to ensure that the config is created with all of the properties * defined as dynamic. */ -const defaultConfig: IConfigDefaults = objDeepFreeze({ +const defaultConfig: IConfigDefaults = (/*#__PURE__*/ objDeepFreeze({ endpointUrl: STR_DEFAULT_ENDPOINT_URL, propertyStorageOverride: { isVal: _chkPropOverride } -}); +})); +/*#__NO_SIDE_EFFECTS__*/ function _chkPropOverride(propertyStorageOverride: IPropertyStorageOverride) { // Validate property storage override if (propertyStorageOverride && (!propertyStorageOverride.getProperty || !propertyStorageOverride.setProperty)) { diff --git a/shared/1ds-core-js/src/extSpanUtils.ts b/shared/1ds-core-js/src/extSpanUtils.ts index 35e7135ee..edca811c9 100644 --- a/shared/1ds-core-js/src/extSpanUtils.ts +++ b/shared/1ds-core-js/src/extSpanUtils.ts @@ -31,9 +31,9 @@ const AzNamespace = "az.namespace"; const AzResourceNamespace = "azure.resource_provider.namespace"; const PORT_REGEX: ILazyValue = (/*#__PURE__*/ getLazy(() => new RegExp(/(https?)(:\/\/.*)(:\d+)(\S*)/))); -const HTTP_DOT = (/*#__PURE__*/ "http."); +const HTTP_DOT = "http."; -const _MS_PROCESSED_BY_METRICS_EXTRACTORS = (/* #__PURE__*/"_MS.ProcessedByMetricExtractors"); +const _MS_PROCESSED_BY_METRICS_EXTRACTORS = "_MS.ProcessedByMetricExtractors"; /** * Legacy HTTP semantic convention values diff --git a/shared/AppInsightsCommon/README.md b/shared/AppInsightsCommon/README.md index 64bf944d4..edd47b795 100644 --- a/shared/AppInsightsCommon/README.md +++ b/shared/AppInsightsCommon/README.md @@ -1,10 +1,29 @@ -# Microsoft Application Insights JavaScript SDK - Common +# ⚠️ DEPRECATED - This package has been merged into @microsoft/applicationinsights-core-js + +> **Migration Notice**: As of version 3.4.0, the functionality of `@microsoft/applicationinsights-common` +> has been merged into `@microsoft/applicationinsights-core-js`. This package now serves only as a +> compatibility layer and will be removed in version 4.0.0. +> +> **Action Required**: Please update your imports from: +> ```typescript +> import { IConfig, ContextTagKeys } from "@microsoft/applicationinsights-common"; +> ``` +> to: +> ```typescript +> import { IConfig, ContextTagKeys } from "@microsoft/applicationinsights-core-js"; +> ``` +> +> See the [Migration Guide](../../docs/upgrade/MergeCommonToCore.md) for more details. + +--- + +# Microsoft Application Insights JavaScript SDK - Common (Compatibility Layer) [![GitHub Workflow Status (main)](https://img.shields.io/github/actions/workflow/status/microsoft/ApplicationInsights-JS/ci.yml?branch=main)](https://github.com/microsoft/ApplicationInsights-JS/tree/main) [![Build Status](https://dev.azure.com/mseng/AppInsights/_apis/build/status%2FAppInsights%20-%20DevTools%2F1DS%20JavaScript%20SDK%20web%20SKU%20(main%3B%20master)?branchName=main)](https://dev.azure.com/mseng/AppInsights/_build/latest?definitionId=8184&branchName=main) [![npm version](https://badge.fury.io/js/%40microsoft%2Fapplicationinsights-common.svg)](https://badge.fury.io/js/%40microsoft%2Fapplicationinsights-common) -Common library for the Application Insights Javascript SDK +This package is deprecated and maintained only for backward compatibility. All new development should use `@microsoft/applicationinsights-core-js`. ## V3.x Release Breaking changes diff --git a/shared/AppInsightsCommon/Tests/Unit/src/GlobalTestHooks.Test.ts b/shared/AppInsightsCommon/Tests/Unit/src/GlobalTestHooks.Test.ts deleted file mode 100644 index b67bf2fe7..000000000 --- a/shared/AppInsightsCommon/Tests/Unit/src/GlobalTestHooks.Test.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Assert } from "@microsoft/ai-test-framework"; -import { _testHookMaxUnloadHooksCb } from "@microsoft/applicationinsights-core-js"; -import { dumpObj } from "@nevware21/ts-utils"; - -export class GlobalTestHooks { - - public registerTests() { - // Set a global maximum - _testHookMaxUnloadHooksCb(20, (state: string, hooks: Array) => { - Assert.ok(false, "Max unload hooks exceeded [" + hooks.length + "] - " + state + " - " + dumpObj(hooks)); - }); - } -} diff --git a/shared/AppInsightsCommon/Tests/UnitTests.html b/shared/AppInsightsCommon/Tests/UnitTests.html deleted file mode 100644 index f7c59889e..000000000 --- a/shared/AppInsightsCommon/Tests/UnitTests.html +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - Tests for Application Insights JavaScript API - - - - - - - - - -
-
-
- - - \ No newline at end of file diff --git a/shared/AppInsightsCommon/Tests/tsconfig.json b/shared/AppInsightsCommon/Tests/tsconfig.json deleted file mode 100644 index d1b20db2c..000000000 --- a/shared/AppInsightsCommon/Tests/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compilerOptions": { - "sourceMap": true, - "inlineSources": true, - "noImplicitAny": false, - "module": "amd", - "moduleResolution": "Node", - "target": "es5", - "alwaysStrict": true, - "declaration": true - }, - "files": [] -} \ No newline at end of file diff --git a/shared/AppInsightsCommon/package.json b/shared/AppInsightsCommon/package.json index 57a39c152..47f6bba5f 100644 --- a/shared/AppInsightsCommon/package.json +++ b/shared/AppInsightsCommon/package.json @@ -18,8 +18,8 @@ "build:esm": "grunt common", "build:browser": "rollup -c rollup.config.js --bundleConfigAsCjs", "rebuild": "npm run build", - "test": "grunt commontest", - "mintest": "grunt common-mintest", + "test": "", + "mintest": "", "lint": "tslint -p tsconfig.json", "dtsgen": "api-extractor run --local && node ../../scripts/dtsgen.js \"Microsoft Application Insights Common JavaScript Library\"", "sri": "node ../../tools/subResourceIntegrity/generateIntegrityFile.js", @@ -29,7 +29,6 @@ "api-docs": "typedoc" }, "devDependencies": { - "@microsoft/ai-test-framework": "0.0.1", "@microsoft/applicationinsights-rollup-plugin-uglify3-js": "1.0.0", "@microsoft/applicationinsights-rollup-es5": "1.0.2", "@microsoft/api-extractor": "^7.40.0", diff --git a/shared/AppInsightsCommon/src/Telemetry/EnvelopeTypes.ts b/shared/AppInsightsCommon/src/Telemetry/EnvelopeTypes.ts deleted file mode 100644 index bd72cbf7a..000000000 --- a/shared/AppInsightsCommon/src/Telemetry/EnvelopeTypes.ts +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -/* #__NO_SIDE_EFFECTS__# */ -function _AddPrefix(name: string) { - return "Microsoft.ApplicationInsights.{0}." + name; -} - -export const EventEnvelopeType = (/* __PURE__ */ _AddPrefix("Event")); -export const ExceptionEnvelopeType = (/* __PURE__ */ _AddPrefix("Exception")); -export const MetricEnvelopeType = (/* __PURE__ */ _AddPrefix("Metric")); -export const PageViewEnvelopeType = (/* __PURE__ */ _AddPrefix("Pageview")); -export const PageViewPerformanceEnvelopeType = (/* __PURE__ */ _AddPrefix("PageviewPerformance")); -export const RemoteDependencyEnvelopeType = (/* __PURE__ */ _AddPrefix("RemoteDependency")); -export const RequestEnvelopeType = (/* __PURE__ */ _AddPrefix("Request")); -export const TraceEnvelopeType = (/* __PURE__ */ _AddPrefix("Message")); \ No newline at end of file diff --git a/shared/AppInsightsCommon/src/applicationinsights-common.ts b/shared/AppInsightsCommon/src/applicationinsights-common.ts index d7d3e4ada..36be30b15 100644 --- a/shared/AppInsightsCommon/src/applicationinsights-common.ts +++ b/shared/AppInsightsCommon/src/applicationinsights-common.ts @@ -1,90 +1,125 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the -export { - correlationIdSetPrefix, correlationIdGetPrefix, correlationIdCanIncludeCorrelationHeader, correlationIdGetCorrelationContext, - correlationIdGetCorrelationContextValue, dateTimeUtilsNow, dateTimeUtilsDuration, isInternalApplicationInsightsEndpoint, - createDistributedTraceContextFromTrace -} from "./Util"; -export { ThrottleMgr } from "./ThrottleMgr"; -export { parseConnectionString, ConnectionStringParser } from "./ConnectionStringParser"; -export { ConnectionString } from "./Interfaces/ConnectionString"; -export { FieldType } from "./Enums"; -export { IRequestHeaders, RequestHeaders, eRequestHeaders } from "./RequestResponseHeaders"; -export { DisabledPropertyName, ProcessLegacy, SampleRate, HttpMethod, DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH, strNotSpecified } from "./Constants"; -export { IData as AIData } from "./Interfaces/Contracts/IData"; -export { IBase as AIBase } from "./Interfaces/Contracts/IBase"; -export { ISerializable } from "./Interfaces/Telemetry/ISerializable"; -export { IEnvelope } from "./Interfaces/Telemetry/IEnvelope"; -export { Envelope } from "./Telemetry/Common/Envelope"; -export { Event } from "./Telemetry/Event"; -export { Exception } from "./Telemetry/Exception"; -export { Metric } from "./Telemetry/Metric"; -export { PageView } from "./Telemetry/PageView"; -export { IPageViewData } from "./Interfaces/Contracts/IPageViewData"; -export { RemoteDependencyData } from "./Telemetry/RemoteDependencyData"; -export { IRemoteDependencyData } from "./Interfaces/Contracts/IRemoteDependencyData"; -export { IEventTelemetry } from "./Interfaces/IEventTelemetry"; -export { ITraceTelemetry } from "./Interfaces/ITraceTelemetry"; -export { IMetricTelemetry } from "./Interfaces/IMetricTelemetry"; -export { IDependencyTelemetry } from "./Interfaces/IDependencyTelemetry"; -export { IExceptionTelemetry, IAutoExceptionTelemetry, IExceptionInternal } from "./Interfaces/IExceptionTelemetry"; -export { IPageViewTelemetry, IPageViewTelemetryInternal } from "./Interfaces/IPageViewTelemetry"; -export { IPageViewPerformanceTelemetry, IPageViewPerformanceTelemetryInternal } from "./Interfaces/IPageViewPerformanceTelemetry"; -export { IRequestTelemetry } from "./Interfaces/IRequestTelemetry"; -export { Trace } from "./Telemetry/Trace"; -export { PageViewPerformance } from "./Telemetry/PageViewPerformance"; -export { Data } from "./Telemetry/Common/Data"; -export { eSeverityLevel, SeverityLevel } from "./Interfaces/Contracts/SeverityLevel"; -export { IConfig, ConfigurationManager } from "./Interfaces/IConfig"; -export { IStorageBuffer } from "./Interfaces/IStorageBuffer"; -export { IContextTagKeys, ContextTagKeys } from "./Interfaces/Contracts/ContextTagKeys"; -export { - EventDataType, ExceptionDataType, MetricDataType, PageViewDataType, PageViewPerformanceDataType, RemoteDependencyDataType, - RequestDataType, TraceDataType -} from "./Telemetry/DataTypes"; -export { - EventEnvelopeType, ExceptionEnvelopeType, MetricEnvelopeType, PageViewEnvelopeType, PageViewPerformanceEnvelopeType, - RemoteDependencyEnvelopeType, RequestEnvelopeType, TraceEnvelopeType -} from "./Telemetry/EnvelopeTypes" +// Licensed under the MIT License. + +/** + * @deprecated The @microsoft/applicationinsights-common package has been merged + * into @microsoft/applicationinsights-core-js for simplified dependency management + * and improved tree-shaking capabilities. + * + * Please migrate your imports from "@microsoft/applicationinsights-common" to + * "@microsoft/applicationinsights-core-js". + * + * This compatibility layer will be maintained through version 3.x and removed in 4.0.0. + */ + +// Re-export everything from core for backward compatibility export { + // Utility functions + correlationIdSetPrefix, correlationIdGetPrefix, correlationIdCanIncludeCorrelationHeader, + correlationIdGetCorrelationContext, correlationIdGetCorrelationContextValue, + dateTimeUtilsNow, dateTimeUtilsDuration, isInternalApplicationInsightsEndpoint, + createDistributedTraceContextFromTrace, + + // Throttle manager + ThrottleMgr, + + // Connection string parsing + parseConnectionString, ConnectionStringParser, + + // Enums + FieldType, eDistributedTracingModes, DistributedTracingModes, EventPersistence, + eSeverityLevel, SeverityLevel, + + // Request/Response + eRequestHeaders, RequestHeaders, + + // Constants + DisabledPropertyName, ProcessLegacy, SampleRate, HttpMethod, + DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH, strNotSpecified, + + // Contracts (as AIData and AIBase for backward compatibility) + AIData, AIBase, + + // Telemetry interfaces + ISerializable, IEnvelope, IPageViewData, IRemoteDependencyData, + IEventTelemetry, ITraceTelemetry, IMetricTelemetry, IDependencyTelemetry, + IExceptionTelemetry, IAutoExceptionTelemetry, IExceptionInternal, + IPageViewTelemetry, IPageViewTelemetryInternal, + IPageViewPerformanceTelemetry, IPageViewPerformanceTelemetryInternal, + IRequestTelemetry, + + // Telemetry classes + Envelope, Event, Exception, Metric, PageView, PageViewPerformance, + RemoteDependencyData, Trace, Data, + + // Data Sanitizer DataSanitizerValues, - dataSanitizeKeyAndAddUniqueness, dataSanitizeKey, dataSanitizeString, dataSanitizeUrl, dataSanitizeMessage, - dataSanitizeException, dataSanitizeProperties, dataSanitizeMeasurements, dataSanitizeId, dataSanitizeInput, - dsPadNumber -} from "./Telemetry/Common/DataSanitizer"; -export { TelemetryItemCreator, createTelemetryItem } from "./TelemetryItemCreator"; -export { ICorrelationConfig } from "./Interfaces/ICorrelationConfig"; -export { IAppInsights } from "./Interfaces/IAppInsights"; -export { IWeb } from "./Interfaces/Context/IWeb"; -export { CtxTagKeys, Extensions } from "./Interfaces/PartAExtensions"; -export { ISession } from "./Interfaces/Context/ISession"; -export { ISessionManager } from "./Interfaces/Context/ISessionManager"; -export { ITelemetryContext } from "./Interfaces/ITelemetryContext"; -export { IApplication } from "./Interfaces/Context/IApplication"; -export { IDevice } from "./Interfaces/Context/IDevice"; -export { IInternal } from "./Interfaces/Context/IInternal"; -export { ILocation } from "./Interfaces/Context/ILocation"; -export { ISample } from "./Interfaces/Context/ISample"; -export { IOperatingSystem } from "./Interfaces/Context/IOperatingSystem"; -export { IPropertiesPlugin } from "./Interfaces/IPropertiesPlugin"; -export { IUser, IUserContext } from "./Interfaces/Context/IUser"; -export { ITelemetryTrace } from "./Interfaces/Context/ITelemetryTrace"; -export { IRequestContext } from "./Interfaces/IRequestContext"; -export { eDistributedTracingModes, DistributedTracingModes, EventPersistence } from "./Enums"; -export { stringToBoolOrDefault, msToTimeSpan, getExtensionByName, isCrossOriginError } from "./HelperFuncs"; -export { - isBeaconsSupported as isBeaconApiSupported, - ITraceParent, createTraceParent, parseTraceParent, isValidTraceId, isValidSpanId, isValidTraceParent, isSampledFlag, formatTraceParent, findW3cTraceParent, findAllScripts + dataSanitizeKeyAndAddUniqueness, dataSanitizeKey, dataSanitizeString, + dataSanitizeUrl, dataSanitizeMessage, dataSanitizeException, + dataSanitizeProperties, dataSanitizeMeasurements, dataSanitizeId, + dataSanitizeInput, dsPadNumber, + + // Configuration + IConfig, ConfigurationManager, IStorageBuffer, ICorrelationConfig, + + // Context tags + IContextTagKeys, ContextTagKeys, CtxTagKeys, Extensions, + + // Data types + EventDataType, ExceptionDataType, MetricDataType, PageViewDataType, + PageViewPerformanceDataType, RemoteDependencyDataType, RequestDataType, TraceDataType, + + // Envelope types + EventEnvelopeType, ExceptionEnvelopeType, MetricEnvelopeType, PageViewEnvelopeType, + PageViewPerformanceEnvelopeType, RemoteDependencyEnvelopeType, RequestEnvelopeType, + TraceEnvelopeType, + + // Telemetry creation + TelemetryItemCreator, createTelemetryItem, + + // Application Insights interfaces + IAppInsights, ITelemetryContext, IPropertiesPlugin, IRequestContext, + + // Context interfaces + IWeb, ISession, ISessionManager, IApplication, IDevice, IInternal, + ILocation, ISample, IOperatingSystem, IUser, IUserContext, ITelemetryTrace, + + // Helper functions + stringToBoolOrDefault, msToTimeSpan, getExtensionByName, isCrossOriginError, + + // Trace parent functions (re-exported from core) + createTraceParent, parseTraceParent, isValidTraceId, isValidSpanId, + isValidTraceParent, isSampledFlag, formatTraceParent, findW3cTraceParent, + findAllScripts, isBeaconsSupported as isBeaconApiSupported, + + // DOM helpers + createDomEvent, + + // Storage helpers + utlDisableStorage, utlEnableStorage, utlCanUseLocalStorage, utlGetLocalStorage, + utlSetLocalStorage, utlRemoveStorage, utlCanUseSessionStorage, + utlGetSessionStorageKeys, utlGetSessionStorage, utlSetSessionStorage, + utlRemoveSessionStorage, utlSetStoragePrefix, + + // URL helpers + urlParseUrl, urlGetAbsoluteUrl, urlGetPathName, urlGetCompleteUrl, + urlParseHost, urlParseFullHost, + + // Throttle manager interfaces + IThrottleLimit, IThrottleInterval, IThrottleMgrConfig, + IThrottleLocalStorageObj, IThrottleResult, + + // Offline support + IOfflineListener, createOfflineListener, IOfflineState, + eOfflineValue, OfflineCallback, + + // ITraceParent interface + ITraceParent, + + // Plugin identifiers + PropertiesPluginIdentifier, BreezeChannelIdentifier, AnalyticsPluginIdentifier + } from "@microsoft/applicationinsights-core-js"; -export { createDomEvent } from "./DomHelperFuncs"; -export { - utlDisableStorage, utlEnableStorage, utlCanUseLocalStorage, utlGetLocalStorage, utlSetLocalStorage, utlRemoveStorage, - utlCanUseSessionStorage, utlGetSessionStorageKeys, utlGetSessionStorage, utlSetSessionStorage, utlRemoveSessionStorage, utlSetStoragePrefix -} from "./StorageHelperFuncs"; -export { urlParseUrl, urlGetAbsoluteUrl, urlGetPathName, urlGetCompleteUrl, urlParseHost, urlParseFullHost } from "./UrlHelperFuncs"; -export { IThrottleLimit, IThrottleInterval, IThrottleMgrConfig, IThrottleLocalStorageObj, IThrottleResult } from "./Interfaces/IThrottleMgr"; -export { IOfflineListener, createOfflineListener, IOfflineState, eOfflineValue, OfflineCallback } from "./Offline"; -export const PropertiesPluginIdentifier = "AppInsightsPropertiesPlugin"; -export const BreezeChannelIdentifier = "AppInsightsChannelPlugin"; -export const AnalyticsPluginIdentifier = "ApplicationInsightsAnalytics"; +// Type re-exports (zero runtime cost) +export type { ConnectionString, IRequestHeaders } from "@microsoft/applicationinsights-core-js"; diff --git a/shared/AppInsightsCore/README.md b/shared/AppInsightsCore/README.md index c58c205db..3b82afafb 100644 --- a/shared/AppInsightsCore/README.md +++ b/shared/AppInsightsCore/README.md @@ -8,6 +8,17 @@ Core SDK layer for next version of application insights javascript SDK. +## V3.4.0 - Common Package Merged + +As of version 3.4.0, the functionality from `@microsoft/applicationinsights-common` has been merged into this package (`@microsoft/applicationinsights-core-js`). This consolidation simplifies the dependency tree and improves tree-shaking capabilities. + +**What this means:** +- All exports previously in `applicationinsights-common` are now available from `applicationinsights-core-js` +- The `applicationinsights-common` package continues to work as a compatibility layer (re-exports from Core) +- No breaking changes to existing APIs + +See the [Migration Guide](../../docs/upgrade/MergeCommonToCore.md) for details on updating your imports. + ## V3.x Release Breaking changes - Removed ES3 / IE8 Support diff --git a/shared/AppInsightsCore/Tests/Unit/src/AppInsightsCoreSize.Tests.ts b/shared/AppInsightsCore/Tests/Unit/src/AppInsightsCoreSize.Tests.ts index 30ca34051..98af1328b 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/AppInsightsCoreSize.Tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/AppInsightsCoreSize.Tests.ts @@ -51,11 +51,11 @@ function _checkSize(checkType: string, maxSize: number, size: number, isNightly: } export class AppInsightsCoreSizeCheck extends AITestClass { - private readonly MAX_RAW_SIZE = 96; - private readonly MAX_BUNDLE_SIZE = 96; - private readonly MAX_RAW_DEFLATE_SIZE = 39; - private readonly MAX_BUNDLE_DEFLATE_SIZE = 39; - private readonly rawFilePath = "../dist/es5/applicationinsights-core-js.min.js"; + private readonly MAX_RAW_SIZE = 124; + private readonly MAX_BUNDLE_SIZE = 124; + private readonly MAX_RAW_DEFLATE_SIZE = 49; + private readonly MAX_BUNDLE_DEFLATE_SIZE = 49; + private readonly rawFilePath = "../dist/es5/index.min.js"; private readonly prodFilePath = "../browser/es5/applicationinsights-core-js.min.js"; public testInitialize() { diff --git a/shared/AppInsightsCore/Tests/Unit/src/ApplicationInsightsCore.Tests.ts b/shared/AppInsightsCore/Tests/Unit/src/ApplicationInsightsCore.Tests.ts index 1e173596d..22937cb82 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/ApplicationInsightsCore.Tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/ApplicationInsightsCore.Tests.ts @@ -4,13 +4,14 @@ import { random32, mwcRandomSeed, newId, randomValue, mwcRandom32, isNullOrUndefined, SenderPostManager, OnCompleteCallback, IPayloadData, _ISenderOnComplete, TransportType, _ISendPostMgrConfig, fieldRedaction, isString -} from "../../../src/applicationinsights-core-js" -import { AppInsightsCore } from "../../../src/JavaScriptSDK/AppInsightsCore"; -import { IChannelControls } from "../../../src/JavaScriptSDK.Interfaces/IChannelControls"; -import { _eInternalMessageId, LoggingSeverity } from "../../../src/JavaScriptSDK.Enums/LoggingEnums"; -import { _InternalLogMessage, DiagnosticLogger } from "../../../src/JavaScriptSDK/DiagnosticLogger"; -import { ActiveStatus } from "../../../src/JavaScriptSDK.Enums/InitActiveStatusEnum"; +} from "../../../src/index" +import { AppInsightsCore } from "../../../src/core/AppInsightsCore"; +import { IChannelControls } from "../../../src/interfaces/ai/IChannelControls"; +import { _eInternalMessageId, LoggingSeverity } from "../../../src/enums/ai/LoggingEnums"; +import { _InternalLogMessage, DiagnosticLogger } from "../../../src/diagnostics/DiagnosticLogger"; +import { ActiveStatus } from "../../../src/enums/ai/InitActiveStatusEnum"; import { createAsyncPromise, createAsyncRejectedPromise, createAsyncResolvedPromise, createPromise, createTimeoutPromise, doAwait, doAwaitResponse } from "@nevware21/ts-async"; +import { setBypassLazyCache } from "@nevware21/ts-utils"; const AIInternalMessagePrefix = "AITR_"; const MaxInt32 = 0xFFFFFFFF; @@ -21,6 +22,7 @@ export class ApplicationInsightsCoreTests extends AITestClass { public testInitialize() { super.testInitialize(); this.ctx = {}; + setBypassLazyCache(true); } public testCleanup() { diff --git a/shared/AppInsightsCommon/Tests/Unit/src/AppInsightsCommon.tests.ts b/shared/AppInsightsCore/Tests/Unit/src/Common/AppInsightsCommon.tests.ts similarity index 98% rename from shared/AppInsightsCommon/Tests/Unit/src/AppInsightsCommon.tests.ts rename to shared/AppInsightsCore/Tests/Unit/src/Common/AppInsightsCommon.tests.ts index 16e034509..19a432098 100644 --- a/shared/AppInsightsCommon/Tests/Unit/src/AppInsightsCommon.tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/Common/AppInsightsCommon.tests.ts @@ -1,7 +1,8 @@ import { strRepeat } from "@nevware21/ts-utils"; import { Assert, AITestClass } from "@microsoft/ai-test-framework"; -import { DiagnosticLogger, IConfiguration } from "@microsoft/applicationinsights-core-js"; -import { dataSanitizeInput, dataSanitizeKey, dataSanitizeMessage, DataSanitizerValues, dataSanitizeString, dataSanitizeUrl } from "../../../src/Telemetry/Common/DataSanitizer"; +import { DiagnosticLogger } from "../../../../src/diagnostics/DiagnosticLogger"; +import { IConfiguration } from "../../../../src/interfaces/ai/IConfiguration"; +import { dataSanitizeInput, dataSanitizeKey, dataSanitizeMessage, DataSanitizerValues, dataSanitizeString, dataSanitizeUrl } from "../../../../src/telemetry/ai/Common/DataSanitizer"; export class ApplicationInsightsTests extends AITestClass { diff --git a/shared/AppInsightsCommon/Tests/Unit/src/ConnectionStringParser.tests.ts b/shared/AppInsightsCore/Tests/Unit/src/Common/ConnectionStringParser.tests.ts similarity index 97% rename from shared/AppInsightsCommon/Tests/Unit/src/ConnectionStringParser.tests.ts rename to shared/AppInsightsCore/Tests/Unit/src/Common/ConnectionStringParser.tests.ts index 866110abc..06ff93cfc 100644 --- a/shared/AppInsightsCommon/Tests/Unit/src/ConnectionStringParser.tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/Common/ConnectionStringParser.tests.ts @@ -1,6 +1,6 @@ import { Assert, AITestClass } from "@microsoft/ai-test-framework"; -import { ConnectionStringParser } from "../../../src/ConnectionStringParser"; -import * as Constants from "../../../src/Constants"; +import { ConnectionStringParser } from "../../../../src/telemetry/ConnectionStringParser"; +import * as Constants from "../../../../src/constants/Constants"; const runTest = (options: { connectionString: string, diff --git a/shared/AppInsightsCommon/Tests/Unit/src/Exception.tests.ts b/shared/AppInsightsCore/Tests/Unit/src/Common/Exception.tests.ts similarity index 98% rename from shared/AppInsightsCommon/Tests/Unit/src/Exception.tests.ts rename to shared/AppInsightsCore/Tests/Unit/src/Common/Exception.tests.ts index 495c3c7e2..c15dcabed 100644 --- a/shared/AppInsightsCommon/Tests/Unit/src/Exception.tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/Common/Exception.tests.ts @@ -1,9 +1,10 @@ import { Assert, AITestClass } from "@microsoft/ai-test-framework"; -import { DataSanitizerValues, Exception } from "../../../src/applicationinsights-common" -import { DiagnosticLogger } from "@microsoft/applicationinsights-core-js"; -import { IExceptionInternal, IExceptionDetailsInternal, IExceptionStackFrameInternal } from "../../../src/Interfaces/IExceptionTelemetry"; -import { _createExceptionDetails, _createExDetailsFromInterface, _extractStackFrame, _parsedFrameToInterface, _IParsedStackFrame } from "../../../src/Telemetry/Exception"; -import { IStackFrame } from "../../../src/Interfaces/Contracts/IStackFrame"; +import { DataSanitizerValues } from "../../../../src/telemetry/ai/Common/DataSanitizer"; +import { Exception } from "../../../../src/telemetry/ai/Exception"; +import { DiagnosticLogger } from "../../../../src/diagnostics/DiagnosticLogger"; +import { IExceptionInternal, IExceptionDetailsInternal, IExceptionStackFrameInternal } from "../../../../src/interfaces/ai/IExceptionTelemetry"; +import { _createExceptionDetails, _createExDetailsFromInterface, _extractStackFrame, _parsedFrameToInterface, _IParsedStackFrame } from "../../../../src/telemetry/ai/Exception"; +import { IStackFrame } from "../../../../src/interfaces/ai/contracts/IStackFrame"; function _checkExpectedFrame(expectedFrame: IStackFrame, actualFrame: IStackFrame, index: number) { Assert.equal(expectedFrame.assembly, actualFrame.assembly, index + ") Assembly is not as expected"); @@ -530,4 +531,4 @@ export class ExceptionTests extends AITestClass { } }); } -} \ No newline at end of file +} diff --git a/shared/AppInsightsCommon/Tests/Unit/src/RequestHeaders.tests.ts b/shared/AppInsightsCore/Tests/Unit/src/Common/RequestHeaders.tests.ts similarity index 97% rename from shared/AppInsightsCommon/Tests/Unit/src/RequestHeaders.tests.ts rename to shared/AppInsightsCore/Tests/Unit/src/Common/RequestHeaders.tests.ts index f178549d1..7f339442a 100644 --- a/shared/AppInsightsCommon/Tests/Unit/src/RequestHeaders.tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/Common/RequestHeaders.tests.ts @@ -1,5 +1,5 @@ import { Assert, AITestClass } from "@microsoft/ai-test-framework"; -import { eRequestHeaders, RequestHeaders } from "../../../src/RequestResponseHeaders"; +import { eRequestHeaders, RequestHeaders } from "../../../../src/telemetry/RequestResponseHeaders"; export class RequestHeadersTests extends AITestClass { @@ -48,4 +48,4 @@ export class RequestHeadersTests extends AITestClass { } }); } -} \ No newline at end of file +} diff --git a/shared/AppInsightsCommon/Tests/Unit/src/SeverityLevel.tests.ts b/shared/AppInsightsCore/Tests/Unit/src/Common/SeverityLevel.tests.ts similarity index 97% rename from shared/AppInsightsCommon/Tests/Unit/src/SeverityLevel.tests.ts rename to shared/AppInsightsCore/Tests/Unit/src/Common/SeverityLevel.tests.ts index c278df8a0..5c7b38a4b 100644 --- a/shared/AppInsightsCommon/Tests/Unit/src/SeverityLevel.tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/Common/SeverityLevel.tests.ts @@ -1,5 +1,5 @@ import { Assert, AITestClass } from "@microsoft/ai-test-framework"; -import { eSeverityLevel, SeverityLevel } from "../../../src/applicationinsights-common"; +import { eSeverityLevel, SeverityLevel } from "../../../../src/interfaces/ai/contracts/SeverityLevel"; export class SeverityLevelTests extends AITestClass { @@ -55,4 +55,4 @@ export class SeverityLevelTests extends AITestClass { } }); } -} \ No newline at end of file +} diff --git a/shared/AppInsightsCommon/Tests/Unit/src/ThrottleMgr.tests.ts b/shared/AppInsightsCore/Tests/Unit/src/Common/ThrottleMgr.tests.ts similarity index 99% rename from shared/AppInsightsCommon/Tests/Unit/src/ThrottleMgr.tests.ts rename to shared/AppInsightsCore/Tests/Unit/src/Common/ThrottleMgr.tests.ts index 5d6a39462..efde4a2f6 100644 --- a/shared/AppInsightsCommon/Tests/Unit/src/ThrottleMgr.tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/Common/ThrottleMgr.tests.ts @@ -1,10 +1,14 @@ import { Assert, AITestClass } from "@microsoft/ai-test-framework"; -import { AppInsightsCore, IAppInsightsCore, IConfiguration, IPlugin, _eInternalMessageId } from "@microsoft/applicationinsights-core-js"; -import { ThrottleMgr} from "../../../src/ThrottleMgr"; +import { AppInsightsCore } from "../../../../src/core/AppInsightsCore"; +import { IAppInsightsCore } from "../../../../src/interfaces/ai/IAppInsightsCore"; +import { IConfiguration } from "../../../../src/interfaces/ai/IConfiguration"; +import { IPlugin } from "../../../../src/interfaces/ai/ITelemetryPlugin"; +import { _eInternalMessageId } from "../../../../src/enums/ai/LoggingEnums"; +import { ThrottleMgr } from "../../../../src/diagnostics/ThrottleMgr"; import { SinonSpy } from "sinon"; -import { utlCanUseLocalStorage } from "../../../src/StorageHelperFuncs"; -import { IThrottleInterval, IThrottleLimit, IThrottleMgrConfig, IThrottleResult } from "../../../src/Interfaces/IThrottleMgr"; -import { IConfig } from "../../../types/applicationinsights-common"; +import { utlCanUseLocalStorage } from "../../../../src/utils/StorageHelperFuncs"; +import { IThrottleInterval, IThrottleLimit, IThrottleMgrConfig, IThrottleResult } from "../../../../src/interfaces/ai/IThrottleMgr"; +import { IConfig } from "../../../../src/interfaces/ai/IConfig"; const daysInMonth = [ 31, // Jan @@ -1673,4 +1677,4 @@ class ChannelPlugin implements IPlugin { private _processTelemetry(env: any) { } -} \ No newline at end of file +} diff --git a/shared/AppInsightsCommon/Tests/Unit/src/Util.tests.ts b/shared/AppInsightsCore/Tests/Unit/src/Common/Util.tests.ts similarity index 98% rename from shared/AppInsightsCommon/Tests/Unit/src/Util.tests.ts rename to shared/AppInsightsCore/Tests/Unit/src/Common/Util.tests.ts index 57479d3a9..7bf27cbc8 100644 --- a/shared/AppInsightsCommon/Tests/Unit/src/Util.tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/Common/Util.tests.ts @@ -1,9 +1,11 @@ import { Assert, AITestClass } from "@microsoft/ai-test-framework"; -import { ICorrelationConfig } from "../../../src/Interfaces/ICorrelationConfig"; -import { getIEVersion, strStartsWith, uaDisallowsSameSiteNone } from "@microsoft/applicationinsights-core-js"; -import { correlationIdCanIncludeCorrelationHeader } from "../../../src/Util"; -import { createDomEvent } from "../../../src/DomHelperFuncs"; -import { urlParseFullHost, urlParseHost, urlParseUrl } from "../../../src/UrlHelperFuncs"; +import { setBypassLazyCache, strStartsWith } from "@nevware21/ts-utils"; +import { ICorrelationConfig } from "../../../../src/interfaces/ai/ICorrelationConfig"; +import { getIEVersion } from "../../../../src/utils/EnvUtils"; +import { uaDisallowsSameSiteNone } from "../../../../src/core/CookieMgr"; +import { correlationIdCanIncludeCorrelationHeader } from "../../../../src/utils/Util"; +import { createDomEvent } from "../../../../src/utils/DomHelperFuncs"; +import { urlParseFullHost, urlParseHost, urlParseUrl } from "../../../../src/utils/UrlHelperFuncs"; export class UtilTests extends AITestClass { private testRegexLists = (config: ICorrelationConfig, exp: boolean, host: string) => { @@ -15,9 +17,13 @@ export class UtilTests extends AITestClass { }; public testInitialize() { + super.testInitialize(); + setBypassLazyCache(true); } - public testCleanup() {} + public testCleanup() { + super.testCleanup(); + } public registerTests() { this.testCase({ diff --git a/shared/AppInsightsCommon/Tests/Unit/src/W3CTraceStateModes.tests.ts b/shared/AppInsightsCore/Tests/Unit/src/Common/W3CTraceStateModes.tests.ts similarity index 99% rename from shared/AppInsightsCommon/Tests/Unit/src/W3CTraceStateModes.tests.ts rename to shared/AppInsightsCore/Tests/Unit/src/Common/W3CTraceStateModes.tests.ts index a89f42059..de4b0d8f8 100644 --- a/shared/AppInsightsCommon/Tests/Unit/src/W3CTraceStateModes.tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/Common/W3CTraceStateModes.tests.ts @@ -1,5 +1,5 @@ import { Assert, AITestClass } from "@microsoft/ai-test-framework"; -import { eDistributedTracingModes } from "../../../src/Enums"; +import { eDistributedTracingModes } from "../../../../src/enums/ai/Enums"; /** * Helper function to check if a mode should include tracestate header diff --git a/shared/AppInsightsCommon/Tests/Unit/src/appinsights-common.tests.ts b/shared/AppInsightsCore/Tests/Unit/src/Common/appinsights-common.tests.ts similarity index 94% rename from shared/AppInsightsCommon/Tests/Unit/src/appinsights-common.tests.ts rename to shared/AppInsightsCore/Tests/Unit/src/Common/appinsights-common.tests.ts index 956ae0834..e3475cae6 100644 --- a/shared/AppInsightsCommon/Tests/Unit/src/appinsights-common.tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/Common/appinsights-common.tests.ts @@ -5,7 +5,7 @@ import { ConnectionStringParserTests } from "./ConnectionStringParser.tests"; import { SeverityLevelTests } from "./SeverityLevel.tests"; import { RequestHeadersTests } from "./RequestHeaders.tests"; import { ThrottleMgrTest } from "./ThrottleMgr.tests"; -import { GlobalTestHooks } from "./GlobalTestHooks.Test"; +import { GlobalTestHooks } from "../GlobalTestHooks.Test"; import { W3CTraceStateModesTests } from "./W3CTraceStateModes.tests"; export function runTests() { diff --git a/shared/AppInsightsCore/Tests/Unit/src/CookieManager.Tests.ts b/shared/AppInsightsCore/Tests/Unit/src/CookieManager.Tests.ts index 684b7d2de..32bfe6074 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/CookieManager.Tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/CookieManager.Tests.ts @@ -1,7 +1,8 @@ import { Assert, AITestClass } from "@microsoft/ai-test-framework"; -import { AppInsightsCore, createCookieMgr, IAppInsightsCore, IConfiguration, ICookieMgrConfig, IPlugin, ITelemetryItem, newId, objExtend } from "../../../src/applicationinsights-core-js" -import { _eInternalMessageId } from "../../../src/JavaScriptSDK.Enums/LoggingEnums"; -import { _InternalLogMessage } from "../../../src/JavaScriptSDK/DiagnosticLogger"; +import { AppInsightsCore, createCookieMgr, IAppInsightsCore, IConfiguration, ICookieMgrConfig, IPlugin, ITelemetryItem, newId, objExtend } from "../../../src/index" +import { _eInternalMessageId } from "../../../src/enums/ai/LoggingEnums"; +import { _InternalLogMessage } from "../../../src/diagnostics/DiagnosticLogger"; +import { setBypassLazyCache } from "@nevware21/ts-utils"; export class CookieManagerTests extends AITestClass { private _cookieMgrCfg: ICookieMgrConfig; @@ -15,6 +16,7 @@ export class CookieManagerTests extends AITestClass { public testInitialize() { let _self = this; super.testInitialize(); + setBypassLazyCache(true); _self._testCookies = {}; _self._cookieMgrCfg = { getCookie: (name) => { diff --git a/shared/AppInsightsCore/Tests/Unit/src/Dynamic.Tests.ts b/shared/AppInsightsCore/Tests/Unit/src/Dynamic.Tests.ts index fe5c0ff06..22d6b024e 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/Dynamic.Tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/Dynamic.Tests.ts @@ -1,15 +1,15 @@ import { Assert, AITestClass } from "@microsoft/ai-test-framework"; import { dumpObj } from "@nevware21/ts-utils"; -import { AppInsightsCore } from "../../../src/JavaScriptSDK/AppInsightsCore"; -import { _eInternalMessageId } from "../../../src/JavaScriptSDK.Enums/LoggingEnums"; -import { _InternalLogMessage } from "../../../src/JavaScriptSDK/DiagnosticLogger"; -import { IConfiguration } from "../../../src/JavaScriptSDK.Interfaces/IConfiguration"; -import { IPlugin, ITelemetryPlugin } from "../../../src/JavaScriptSDK.Interfaces/ITelemetryPlugin"; -import { ITelemetryItem } from "../../../src/JavaScriptSDK.Interfaces/ITelemetryItem"; -import { BaseTelemetryPlugin } from "../../../src/JavaScriptSDK/BaseTelemetryPlugin"; -import { IAppInsightsCore } from "../../../src/JavaScriptSDK.Interfaces/IAppInsightsCore"; -import { ITelemetryPluginChain } from "../../../src/JavaScriptSDK.Interfaces/ITelemetryPluginChain"; -import { IProcessTelemetryContext } from "../../../src/JavaScriptSDK.Interfaces/IProcessTelemetryContext"; +import { AppInsightsCore } from "../../../src/core/AppInsightsCore"; +import { _eInternalMessageId } from "../../../src/enums/ai/LoggingEnums"; +import { _InternalLogMessage } from "../../../src/diagnostics/DiagnosticLogger"; +import { IConfiguration } from "../../../src/interfaces/ai/IConfiguration"; +import { IPlugin, ITelemetryPlugin } from "../../../src/interfaces/ai/ITelemetryPlugin"; +import { ITelemetryItem } from "../../../src/interfaces/ai/ITelemetryItem"; +import { BaseTelemetryPlugin } from "../../../src/core/BaseTelemetryPlugin"; +import { IAppInsightsCore } from "../../../src/interfaces/ai/IAppInsightsCore"; +import { ITelemetryPluginChain } from "../../../src/interfaces/ai/ITelemetryPluginChain"; +import { IProcessTelemetryContext } from "../../../src/interfaces/ai/IProcessTelemetryContext"; import { OldTrackPlugin, TestChannelPlugin, TestPlugin } from "./TestPlugins"; export class DynamicTests extends AITestClass { diff --git a/shared/AppInsightsCore/Tests/Unit/src/DynamicConfig.Tests.ts b/shared/AppInsightsCore/Tests/Unit/src/DynamicConfig.Tests.ts index 78b07e4a3..e80c745f3 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/DynamicConfig.Tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/DynamicConfig.Tests.ts @@ -1,21 +1,21 @@ import { Assert, AITestClass } from "@microsoft/ai-test-framework"; -import { eLoggingSeverity, _eInternalMessageId, LoggingSeverity, _InternalMessageId } from "../../../src/JavaScriptSDK.Enums/LoggingEnums"; -import { _InternalLogMessage } from "../../../src/JavaScriptSDK/DiagnosticLogger"; -import { IConfigDefaults } from "../../../src/Config/IConfigDefaults"; -import { IConfiguration } from "../../../src/JavaScriptSDK.Interfaces/IConfiguration"; -import { blockDynamicConversion, forceDynamicConversion, getDynamicConfigHandler } from "../../../src/Config/DynamicSupport"; -import { createDynamicConfig, onConfigChange } from "../../../src/Config/DynamicConfig"; +import { eLoggingSeverity, _eInternalMessageId, LoggingSeverity, _InternalMessageId } from "../../../src/enums/ai/LoggingEnums"; +import { _InternalLogMessage } from "../../../src/diagnostics/DiagnosticLogger"; +import { IConfigDefaults } from "../../../src/interfaces/config/IConfigDefaults"; +import { IConfiguration } from "../../../src/interfaces/ai/IConfiguration"; +import { blockDynamicConversion, forceDynamicConversion, getDynamicConfigHandler } from "../../../src/config/DynamicSupport"; +import { createDynamicConfig, onConfigChange } from "../../../src/config/DynamicConfig"; import { arrForEach, dumpObj, isArray, isFunction, objForEachKey, objKeys, isPlainObject, objHasOwn, objDeepFreeze, objDefineProps, strContains } from "@nevware21/ts-utils"; -import { IAppInsightsCore } from "../../../src/JavaScriptSDK.Interfaces/IAppInsightsCore"; -import { INotificationManager } from "../../../src/JavaScriptSDK.Interfaces/INotificationManager"; -import { IPerfManager } from "../../../src/JavaScriptSDK.Interfaces/IPerfManager"; -import { AppInsightsCore, DiagnosticLogger, IDiagnosticLogger, IProcessTelemetryContext } from "../../../src/applicationinsights-core-js"; -import { ITelemetryItem } from "../../../src/JavaScriptSDK.Interfaces/ITelemetryItem"; -import { ITelemetryPluginChain } from "../../../src/JavaScriptSDK.Interfaces/ITelemetryPluginChain"; -import { ITelemetryPlugin } from "../../../src/JavaScriptSDK.Interfaces/ITelemetryPlugin"; -import { IChannelControls } from "../../../src/JavaScriptSDK.Interfaces/IChannelControls"; +import { IAppInsightsCore } from "../../../src/interfaces/ai/IAppInsightsCore"; +import { INotificationManager } from "../../../src/interfaces/ai/INotificationManager"; +import { IPerfManager } from "../../../src/interfaces/ai/IPerfManager"; +import { AppInsightsCore, DiagnosticLogger, IDiagnosticLogger, IProcessTelemetryContext } from "../../../src/index"; +import { ITelemetryItem } from "../../../src/interfaces/ai/ITelemetryItem"; +import { ITelemetryPluginChain } from "../../../src/interfaces/ai/ITelemetryPluginChain"; +import { ITelemetryPlugin } from "../../../src/interfaces/ai/ITelemetryPlugin"; +import { IChannelControls } from "../../../src/interfaces/ai/IChannelControls"; import { TestPlugin, TestSamplingPlugin, TrackPlugin } from "./TestPlugins"; -import { STR_CHANNELS, STR_CREATE_PERF_MGR, STR_EXTENSIONS, STR_EXTENSION_CONFIG, UNDEFINED_VALUE } from "../../../src/JavaScriptSDK/InternalConstants"; +import { STR_CHANNELS, STR_CREATE_PERF_MGR, STR_EXTENSIONS, STR_EXTENSION_CONFIG, UNDEFINED_VALUE } from "../../../src/constants/InternalConstants"; const coreDefaultConfig: IConfigDefaults = objDeepFreeze({ cookieCfg: {}, diff --git a/shared/AppInsightsCore/Tests/Unit/src/EventHelper.Tests.ts b/shared/AppInsightsCore/Tests/Unit/src/EventHelper.Tests.ts index 879809b69..a91f419f2 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/EventHelper.Tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/EventHelper.Tests.ts @@ -1,13 +1,15 @@ import { Assert, AITestClass } from "@microsoft/ai-test-framework"; -import { addEventHandler, createUniqueNamespace, removeEventHandler } from "../../../src/applicationinsights-core-js"; -import { _eInternalMessageId } from "../../../src/JavaScriptSDK.Enums/LoggingEnums"; -import { _InternalLogMessage } from "../../../src/JavaScriptSDK/DiagnosticLogger"; -import { mergeEvtNamespace, __getRegisteredEvents } from "../../../src/JavaScriptSDK/EventHelpers"; +import { addEventHandler, createUniqueNamespace, removeEventHandler } from "../../../src/index"; +import { _eInternalMessageId } from "../../../src/enums/ai/LoggingEnums"; +import { _InternalLogMessage } from "../../../src/diagnostics/DiagnosticLogger"; +import { mergeEvtNamespace, __getRegisteredEvents } from "../../../src/internal/EventHelpers"; +import { setBypassLazyCache } from "@nevware21/ts-utils"; export class EventHelperTests extends AITestClass { public testInitialize() { super.testInitialize(); + setBypassLazyCache(true); } public testCleanup() { @@ -283,15 +285,15 @@ export class EventHelperTests extends AITestClass { function _checkRegisteredAddEventHandler(name: string, expected: number) { let registered = __getRegisteredEvents(window, name); - Assert.equal(expected, registered.length, "Check that window event was registered"); + Assert.equal(expected, registered.length, "Check that window event was registered for " + name); - if (window["body"]) { + if (window && window["body"]) { registered = __getRegisteredEvents(window["body"], name); - Assert.equal(expected, registered.length, "Check that window.body event was registered"); + Assert.equal(expected, registered.length, "Check that window.body event was registered for " + name); } registered = __getRegisteredEvents(document, name); - Assert.equal(expected, registered.length, "Check that document event was registered"); + Assert.equal(expected, registered.length, "Check that document event was registered for " + name); } } } \ No newline at end of file diff --git a/shared/AppInsightsCore/Tests/Unit/src/EventsDiscardedReason.Tests.ts b/shared/AppInsightsCore/Tests/Unit/src/EventsDiscardedReason.Tests.ts index 63faef72c..1ff46d9f5 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/EventsDiscardedReason.Tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/EventsDiscardedReason.Tests.ts @@ -1,5 +1,5 @@ import { Assert, AITestClass } from "@microsoft/ai-test-framework"; -import { eEventsDiscardedReason, EventsDiscardedReason } from "../../../src/JavaScriptSDK.Enums/EventsDiscardedReason"; +import { eEventsDiscardedReason, EventsDiscardedReason } from "../../../src/enums/ai/EventsDiscardedReason"; export class EventsDiscardedReasonTests extends AITestClass { diff --git a/shared/AppInsightsCore/Tests/Unit/src/GlobalTestHooks.Test.ts b/shared/AppInsightsCore/Tests/Unit/src/GlobalTestHooks.Test.ts index 99e370c4a..2b4370171 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/GlobalTestHooks.Test.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/GlobalTestHooks.Test.ts @@ -1,5 +1,5 @@ import { Assert } from "@microsoft/ai-test-framework"; -import { _testHookMaxUnloadHooksCb } from "../../../src/JavaScriptSDK/UnloadHookContainer"; +import { _testHookMaxUnloadHooksCb } from "../../../src/core/UnloadHookContainer"; import { dumpObj } from "@nevware21/ts-utils"; export class GlobalTestHooks { diff --git a/shared/AppInsightsCore/Tests/Unit/src/HelperFunc.Tests.ts b/shared/AppInsightsCore/Tests/Unit/src/HelperFunc.Tests.ts index 899443c7f..8ebec0710 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/HelperFunc.Tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/HelperFunc.Tests.ts @@ -1,10 +1,10 @@ import { Assert, AITestClass } from "@microsoft/ai-test-framework"; -import { _eInternalMessageId } from "../../../src/JavaScriptSDK.Enums/LoggingEnums"; -import { _InternalLogMessage } from "../../../src/JavaScriptSDK/DiagnosticLogger"; -import { normalizeJsName, objExtend, _getObjProto, isFeatureEnabled } from "../../../src/JavaScriptSDK/HelperFuncs"; -import { AppInsightsCore } from "../../../src/JavaScriptSDK/AppInsightsCore"; +import { _eInternalMessageId } from "../../../src/enums/ai/LoggingEnums"; +import { _InternalLogMessage } from "../../../src/diagnostics/DiagnosticLogger"; +import { normalizeJsName, objExtend, _getObjProto, isFeatureEnabled } from "../../../src/utils/HelperFuncs"; +import { AppInsightsCore } from "../../../src/core/AppInsightsCore"; import { isArray, isObject, objKeys, strEndsWith, strStartsWith, isPlainObject, utcNow } from "@nevware21/ts-utils"; -import { FeatureOptInMode, IConfiguration, IFeatureOptInDetails, dumpObj } from "../../../src/applicationinsights-core-js"; +import { FeatureOptInMode, IConfiguration, IFeatureOptInDetails, dumpObj } from "../../../src/index"; diff --git a/shared/AppInsightsCore/Tests/Unit/src/LoggingEnum.Tests.ts b/shared/AppInsightsCore/Tests/Unit/src/LoggingEnum.Tests.ts index 7cbf4d1bc..3a47e7b01 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/LoggingEnum.Tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/LoggingEnum.Tests.ts @@ -1,7 +1,7 @@ import { Assert, AITestClass } from "@microsoft/ai-test-framework"; import { isString, objForEachKey } from "@nevware21/ts-utils"; -import { LoggingSeverity, eLoggingSeverity, _eInternalMessageId } from "../../../src/JavaScriptSDK.Enums/LoggingEnums"; -import { _InternalLogMessage } from "../../../src/JavaScriptSDK/DiagnosticLogger"; +import { LoggingSeverity, eLoggingSeverity, _eInternalMessageId } from "../../../src/enums/ai/LoggingEnums"; +import { _InternalLogMessage } from "../../../src/diagnostics/DiagnosticLogger"; type NoRepeats = { [M in keyof T]: { [N in keyof T]: N extends M ? never : T[M] extends T[N] ? unknown : never diff --git a/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/attributeContainer.Tests.ts b/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/attributeContainer.Tests.ts index c67ec9047..256f3ea6c 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/attributeContainer.Tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/attributeContainer.Tests.ts @@ -1,10 +1,10 @@ import { AITestClass, Assert } from "@microsoft/ai-test-framework"; import { objKeys } from "@nevware21/ts-utils"; -import { createAttributeContainer, addAttributes, isAttributeContainer, createAttributeSnapshot } from "../../../../src/OpenTelemetry/attribute/attributeContainer"; -import { eAttributeFilter, IAttributeChangeInfo } from "../../../../src/OpenTelemetry/attribute/IAttributeContainer"; -import { eAttributeChangeOp } from "../../../../src/OpenTelemetry/enums/eAttributeChangeOp"; -import { IOTelConfig } from "../../../../src/OpenTelemetry/interfaces/config/IOTelConfig"; -import { IOTelAttributes } from "../../../../src/OpenTelemetry/interfaces/IOTelAttributes"; +import { createAttributeContainer, addAttributes, isAttributeContainer, createAttributeSnapshot } from "../../../../src/otel/attribute/attributeContainer"; +import { eAttributeFilter, IAttributeChangeInfo } from "../../../../src/interfaces/otel/attribute/IAttributeContainer"; +import { eAttributeChangeOp } from "../../../../src/enums/otel/eAttributeChangeOp"; +import { IOTelConfig } from "../../../../src/interfaces/otel/config/IOTelConfig"; +import { IOTelAttributes } from "../../../../src/interfaces/otel/IOTelAttributes"; export class AttributeContainerTests extends AITestClass { diff --git a/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/commonUtils.Tests.ts b/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/commonUtils.Tests.ts index 14094795b..92cf3bbad 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/commonUtils.Tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/commonUtils.Tests.ts @@ -2,11 +2,11 @@ import { Assert, AITestClass } from "@microsoft/ai-test-framework"; import { getGlobal } from "@nevware21/ts-utils"; import { handleAttribError, handleSpanError, handleDebug, handleWarn, handleError, handleNotImplemented -} from "../../../../src/OpenTelemetry/helpers/handleErrors"; -import { getUrl, getHttpUrl } from "../../../../src/OpenTelemetry/helpers/common"; -import { createAttributeContainer } from "../../../../src/OpenTelemetry/attribute/attributeContainer"; -import { IOTelErrorHandlers } from "../../../../src/OpenTelemetry/interfaces/config/IOTelErrorHandlers"; -import { IOTelConfig } from "../../../../src/OpenTelemetry/interfaces/config/IOTelConfig"; +} from "../../../../src/internal/handleErrors"; +import { getUrl, getHttpUrl } from "../../../../src/internal/commonUtils"; +import { createAttributeContainer } from "../../../../src/otel/attribute/attributeContainer"; +import { IOTelErrorHandlers } from "../../../../src/interfaces/otel/config/IOTelErrorHandlers"; +import { IOTelConfig } from "../../../../src/interfaces/otel/config/IOTelConfig"; export class CommonUtilsTests extends AITestClass { diff --git a/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/errors.Tests.ts b/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/errors.Tests.ts index f0c708dfb..50012728a 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/errors.Tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/errors.Tests.ts @@ -5,15 +5,15 @@ import { OpenTelemetryErrorConstructor, getOpenTelemetryError, throwOTelError -} from "../../../../src/OpenTelemetry/errors/OTelError"; +} from "../../../../src/otel/api/errors/OTelError"; import { OTelInvalidAttributeError, throwOTelInvalidAttributeError -} from "../../../../src/OpenTelemetry/errors/OTelInvalidAttributeError"; +} from "../../../../src/otel/api/errors/OTelInvalidAttributeError"; import { OTelSpanError, throwOTelSpanError -} from "../../../../src/OpenTelemetry/errors/OTelSpanError"; +} from "../../../../src/otel/api/errors/OTelSpanError"; export class OpenTelemetryErrorsTests extends AITestClass { diff --git a/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/otelNegative.Tests.ts b/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/otelNegative.Tests.ts index aa590affd..32967a14a 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/otelNegative.Tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/otelNegative.Tests.ts @@ -2,14 +2,14 @@ // Licensed under the MIT License. import { AITestClass, Assert } from "@microsoft/ai-test-framework"; -import { AppInsightsCore } from "../../../../src/applicationinsights-core-js"; -import { IAppInsightsCore } from "../../../../src/JavaScriptSDK.Interfaces/IAppInsightsCore"; -import { createOTelApi } from "../../../../src/OpenTelemetry/otelApi"; -import { IOTelApi } from "../../../../src/OpenTelemetry/interfaces/IOTelApi"; -import { IOTelApiCtx } from "../../../../src/OpenTelemetry/interfaces/IOTelApiCtx"; -import { createNonRecordingSpan, wrapSpanContext, withSpan, useSpan, isTracingSuppressed, suppressTracing, unsuppressTracing } from "../../../../src/OpenTelemetry/trace/utils"; -import { createDistributedTraceContext } from "../../../../src/JavaScriptSDK/TelemetryHelpers"; -import { IChannelControls } from "../../../../src/JavaScriptSDK.Interfaces/IChannelControls"; +import { AppInsightsCore } from "../../../../src/index"; +import { IAppInsightsCore } from "../../../../src/interfaces/ai/IAppInsightsCore"; +import { createOTelApi } from "../../../../src/otel/api/OTelApi"; +import { IOTelApi } from "../../../../src/interfaces/otel/IOTelApi"; +import { IOTelApiCtx } from "../../../../src/interfaces/otel/IOTelApiCtx"; +import { createNonRecordingSpan, wrapSpanContext, withSpan, useSpan, isTracingSuppressed, suppressTracing, unsuppressTracing } from "../../../../src/otel/api/trace/utils"; +import { createDistributedTraceContext } from "../../../../src/core/TelemetryHelpers"; +import { IChannelControls } from "../../../../src/interfaces/ai/IChannelControls"; /** * Negative tests for OpenTelemetry SDK helpers in AppInsights Core diff --git a/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/span.Tests.ts b/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/span.Tests.ts index 2bd2168bc..83e5b7cdc 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/span.Tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/span.Tests.ts @@ -1,23 +1,23 @@ import { Assert, AITestClass } from "@microsoft/ai-test-framework"; import { getDeferred, ICachedValue, isNullOrUndefined, mathMin, objDefine, perfNow, strSubstr } from "@nevware21/ts-utils"; -import { createSpan } from "../../../../src/OpenTelemetry/trace/span"; -import { createOTelApi } from "../../../../src/OpenTelemetry/otelApi"; -import { IOTelSpanCtx } from "../../../../src/OpenTelemetry/interfaces/trace/IOTelSpanCtx"; -import { IOTelApi } from "../../../../src/OpenTelemetry/interfaces/IOTelApi"; -import { IOTelConfig } from "../../../../src/OpenTelemetry/interfaces/config/IOTelConfig"; -import { eOTelSpanStatusCode } from "../../../../src/OpenTelemetry/enums/trace/OTelSpanStatus"; -import { IOTelAttributes } from "../../../../src/OpenTelemetry/interfaces/IOTelAttributes"; -import { IReadableSpan } from "../../../../src/OpenTelemetry/interfaces/trace/IReadableSpan"; -import { IDistributedTraceContext } from "../../../../src/JavaScriptSDK.Interfaces/IDistributedTraceContext"; -import { createDistributedTraceContext } from "../../../../src/JavaScriptSDK/TelemetryHelpers"; -import { generateW3CId } from "../../../../src/JavaScriptSDK/CoreUtils"; -import { suppressTracing, unsuppressTracing, isTracingSuppressed, useSpan, withSpan } from "../../../../src/OpenTelemetry/trace/utils"; -import { ITraceCfg } from "../../../../src/OpenTelemetry/interfaces/config/ITraceCfg"; -import { AppInsightsCore } from "../../../../src/JavaScriptSDK/AppInsightsCore"; -import { IConfiguration } from "../../../../src/JavaScriptSDK.Interfaces/IConfiguration"; -import { ITraceProvider, ISpanScope, ITraceHost } from "../../../../src/JavaScriptSDK.Interfaces/ITraceProvider"; -import { IOTelSpanOptions } from "../../../../src/OpenTelemetry/interfaces/trace/IOTelSpanOptions"; -import { eOTelSpanKind } from "../../../../src/OpenTelemetry/enums/trace/OTelSpanKind"; +import { createSpan } from "../../../../src/otel/api/trace/span"; +import { createOTelApi } from "../../../../src/otel/api/OTelApi"; +import { IOTelSpanCtx } from "../../../../src/interfaces/otel/trace/IOTelSpanCtx"; +import { IOTelApi } from "../../../../src/interfaces/otel/IOTelApi"; +import { IOTelConfig } from "../../../../src/interfaces/otel/config/IOTelConfig"; +import { eOTelSpanStatusCode } from "../../../../src/enums/otel/OTelSpanStatus"; +import { IOTelAttributes } from "../../../../src/interfaces/otel/IOTelAttributes"; +import { IReadableSpan } from "../../../../src/interfaces/otel/trace/IReadableSpan"; +import { IDistributedTraceContext } from "../../../../src/interfaces/ai/IDistributedTraceContext"; +import { createDistributedTraceContext } from "../../../../src/core/TelemetryHelpers"; +import { generateW3CId } from "../../../../src/utils/CoreUtils"; +import { suppressTracing, unsuppressTracing, isTracingSuppressed, useSpan, withSpan } from "../../../../src/otel/api/trace/utils"; +import { ITraceCfg } from "../../../../src/interfaces/otel/config/IOTelTraceCfg"; +import { AppInsightsCore } from "../../../../src/core/AppInsightsCore"; +import { IConfiguration } from "../../../../src/interfaces/ai/IConfiguration"; +import { ITraceProvider, ISpanScope, ITraceHost } from "../../../../src/interfaces/ai/ITraceProvider"; +import { IOTelSpanOptions } from "../../../../src/interfaces/otel/trace/IOTelSpanOptions"; +import { eOTelSpanKind } from "../../../../src/enums/otel/OTelSpanKind"; export class SpanTests extends AITestClass { diff --git a/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/traceState.Tests.ts b/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/traceState.Tests.ts index 1b81aa6fc..86c6ad9a6 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/traceState.Tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/traceState.Tests.ts @@ -1,5 +1,5 @@ import { Assert, AITestClass } from "@microsoft/ai-test-framework"; -import { createOTelTraceState } from "../../../../src/OpenTelemetry/trace/traceState"; +import { createOTelTraceState } from "../../../../src/otel/api/trace/traceState"; import { strRepeat } from "@nevware21/ts-utils"; export class OTelTraceApiTests extends AITestClass { diff --git a/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/traceUtils.Tests.ts b/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/traceUtils.Tests.ts index 79f7faacf..5c5d341b0 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/traceUtils.Tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/OpenTelemetry/traceUtils.Tests.ts @@ -1,19 +1,19 @@ import { AITestClass, Assert } from "@microsoft/ai-test-framework"; -import { isSpanContextValid, wrapSpanContext, createNonRecordingSpan, isReadableSpan, useSpan, withSpan } from "../../../../src/OpenTelemetry/trace/utils"; -import { createTraceProvider } from "../../../../src/OpenTelemetry/trace/traceProvider"; -import { IDistributedTraceContext } from "../../../../src/JavaScriptSDK.Interfaces/IDistributedTraceContext"; +import { isSpanContextValid, wrapSpanContext, createNonRecordingSpan, isReadableSpan, useSpan, withSpan } from "../../../../src/otel/api/trace/utils"; +import { createTraceProvider } from "../../../../src/otel/api/trace/traceProvider"; +import { IDistributedTraceContext } from "../../../../src/interfaces/ai/IDistributedTraceContext"; import { createPromise, createRejectedPromise, doAwait } from "@nevware21/ts-async"; import { createCachedValue, isNullOrUndefined } from "@nevware21/ts-utils"; -import { IOTelApi } from "../../../../src/OpenTelemetry/interfaces/IOTelApi"; -import { createOTelApi } from "../../../../src/OpenTelemetry/otelApi"; -import { eOTelSpanKind } from "../../../../src/OpenTelemetry/enums/trace/OTelSpanKind"; -import { IOTelSpanCtx } from "../../../../src/OpenTelemetry/interfaces/trace/IOTelSpanCtx"; -import { createSpan } from "../../../../src/OpenTelemetry/trace/span"; -import { createW3cTraceState } from "../../../../src/JavaScriptSDK/W3cTraceState"; -import { createDistributedTraceContext } from "../../../../src/JavaScriptSDK/TelemetryHelpers"; -import { IAppInsightsCore } from "../../../../src/JavaScriptSDK.Interfaces/IAppInsightsCore"; -import { AppInsightsCore, ITraceHost } from "../../../../src/applicationinsights-core-js"; -import { IChannelControls } from "../../../../src/JavaScriptSDK.Interfaces/IChannelControls"; +import { IOTelApi } from "../../../../src/interfaces/otel/IOTelApi"; +import { createOTelApi } from "../../../../src/otel/api/OTelApi"; +import { eOTelSpanKind } from "../../../../src/enums/otel/OTelSpanKind"; +import { IOTelSpanCtx } from "../../../../src/interfaces/otel/trace/IOTelSpanCtx"; +import { createSpan } from "../../../../src/otel/api/trace/span"; +import { createW3cTraceState } from "../../../../src/telemetry/W3cTraceState"; +import { createDistributedTraceContext } from "../../../../src/core/TelemetryHelpers"; +import { IAppInsightsCore } from "../../../../src/interfaces/ai/IAppInsightsCore"; +import { AppInsightsCore, ITraceHost } from "../../../../src/index"; +import { IChannelControls } from "../../../../src/interfaces/ai/IChannelControls"; function _createDistributedContext(traceId: string, spanId: string, traceFlags: number, traceState?: string): IDistributedTraceContext { const theContext: IDistributedTraceContext = { diff --git a/shared/AppInsightsCore/Tests/Unit/src/SendPostManager.Tests.ts b/shared/AppInsightsCore/Tests/Unit/src/SendPostManager.Tests.ts index fad029b30..cad8d04d5 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/SendPostManager.Tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/SendPostManager.Tests.ts @@ -1,8 +1,8 @@ import { Assert, AITestClass } from "@microsoft/ai-test-framework"; -import { _eInternalMessageId } from "../../../src/JavaScriptSDK.Enums/LoggingEnums"; -import { _InternalLogMessage } from "../../../src/JavaScriptSDK/DiagnosticLogger"; -import { SenderPostManager } from "../../../src/JavaScriptSDK/SenderPostManager"; -import { IPayloadData } from "../../../src/JavaScriptSDK.Interfaces/IXHROverride"; +import { _eInternalMessageId } from "../../../src/enums/ai/LoggingEnums"; +import { _InternalLogMessage } from "../../../src/diagnostics/DiagnosticLogger"; +import { SenderPostManager } from "../../../src/core/SenderPostManager"; +import { IPayloadData } from "../../../src/interfaces/ai/IXHROverride"; import { getInst, isFunction, mathRandom } from "@nevware21/ts-utils"; import { createPromise, doAwaitResponse } from "@nevware21/ts-async"; diff --git a/shared/AppInsightsCore/Tests/Unit/src/StatsBeat.Tests.ts b/shared/AppInsightsCore/Tests/Unit/src/StatsBeat.Tests.ts index 3ba1eb90c..9d66d0166 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/StatsBeat.Tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/StatsBeat.Tests.ts @@ -1,15 +1,15 @@ // import * as sinon from "sinon"; // import { Assert, AITestClass } from "@microsoft/ai-test-framework"; -// import { IPayloadData } from "../../../src/JavaScriptSDK.Interfaces/IXHROverride"; +// import { IPayloadData } from "../../../src/interfaces/ai/IXHROverride"; // import { IStatsMgr } from "../../../src/JavaScriptSDK.Interfaces/IStatsMgr"; -// import { AppInsightsCore } from "../../../src/JavaScriptSDK/AppInsightsCore"; -// import { IConfiguration } from "../../../src/JavaScriptSDK.Interfaces/IConfiguration"; +// import { AppInsightsCore } from "../../../src/core/AppInsightsCore"; +// import { IConfiguration } from "../../../src/interfaces/ai/IConfiguration"; // import { createStatsMgr } from "../../../src/JavaScriptSDK/StatsBeat"; // import { IStatsBeatState } from "../../../src/JavaScriptSDK.Interfaces/IStatsBeat"; // import { eStatsType } from "../../../src/JavaScriptSDK.Enums/StatsType"; -// import { ITelemetryItem } from "../../../src/JavaScriptSDK.Interfaces/ITelemetryItem"; -// import { IPlugin } from "../../../src/JavaScriptSDK.Interfaces/ITelemetryPlugin"; -// import { IAppInsightsCore } from "../../../src/JavaScriptSDK.Interfaces/IAppInsightsCore"; +// import { ITelemetryItem } from "../../../src/interfaces/ai/ITelemetryItem"; +// import { IPlugin } from "../../../src/interfaces/ai/ITelemetryPlugin"; +// import { IAppInsightsCore } from "../../../src/interfaces/ai/IAppInsightsCore"; // import { FeatureOptInMode } from "../../../src/JavaScriptSDK.Enums/FeatureOptInEnums"; // const STATS_COLLECTION_SHORT_INTERVAL: number = 900; // 15 minutes diff --git a/shared/AppInsightsCore/Tests/Unit/src/TestPlugins.ts b/shared/AppInsightsCore/Tests/Unit/src/TestPlugins.ts index 78b07c556..b81c3a3f8 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/TestPlugins.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/TestPlugins.ts @@ -1,16 +1,16 @@ import { Assert, AITestClass } from "@microsoft/ai-test-framework"; -import { _eInternalMessageId } from "../../../src/JavaScriptSDK.Enums/LoggingEnums"; -import { _InternalLogMessage } from "../../../src/JavaScriptSDK/DiagnosticLogger"; -import { ITelemetryItem } from "../../../src/JavaScriptSDK.Interfaces/ITelemetryItem"; -import { IProcessTelemetryContext, IProcessTelemetryUpdateContext } from "../../../src/JavaScriptSDK.Interfaces/IProcessTelemetryContext"; -import { TelemetryUpdateReason } from "../../../src/JavaScriptSDK.Enums/TelemetryUpdateReason"; -import { IConfiguration } from "../../../src/JavaScriptSDK.Interfaces/IConfiguration"; -import { IPlugin, ITelemetryPlugin } from "../../../src/JavaScriptSDK.Interfaces/ITelemetryPlugin"; -import { BaseTelemetryPlugin } from "../../../src/JavaScriptSDK/BaseTelemetryPlugin"; -import { IAppInsightsCore } from "../../../src/JavaScriptSDK.Interfaces/IAppInsightsCore"; -import { ITelemetryPluginChain } from "../../../src/JavaScriptSDK.Interfaces/ITelemetryPluginChain"; -import { ITelemetryUpdateState } from "../../../src/JavaScriptSDK.Interfaces/ITelemetryUpdateState"; -import { IChannelControls } from "../../../src/JavaScriptSDK.Interfaces/IChannelControls"; +import { _eInternalMessageId } from "../../../src/enums/ai/LoggingEnums"; +import { _InternalLogMessage } from "../../../src/diagnostics/DiagnosticLogger"; +import { ITelemetryItem } from "../../../src/interfaces/ai/ITelemetryItem"; +import { IProcessTelemetryContext, IProcessTelemetryUpdateContext } from "../../../src/interfaces/ai/IProcessTelemetryContext"; +import { TelemetryUpdateReason } from "../../../src/enums/ai/TelemetryUpdateReason"; +import { IConfiguration } from "../../../src/interfaces/ai/IConfiguration"; +import { IPlugin, ITelemetryPlugin } from "../../../src/interfaces/ai/ITelemetryPlugin"; +import { BaseTelemetryPlugin } from "../../../src/core/BaseTelemetryPlugin"; +import { IAppInsightsCore } from "../../../src/interfaces/ai/IAppInsightsCore"; +import { ITelemetryPluginChain } from "../../../src/interfaces/ai/ITelemetryPluginChain"; +import { ITelemetryUpdateState } from "../../../src/interfaces/ai/ITelemetryUpdateState"; +import { IChannelControls } from "../../../src/interfaces/ai/IChannelControls"; export class TestPlugin implements IPlugin { diff --git a/shared/AppInsightsCore/Tests/Unit/src/UpdateConfig.Tests.ts b/shared/AppInsightsCore/Tests/Unit/src/UpdateConfig.Tests.ts index 45603fb90..9d6d08de4 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/UpdateConfig.Tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/UpdateConfig.Tests.ts @@ -1,9 +1,9 @@ import { Assert, AITestClass } from "@microsoft/ai-test-framework"; import { dumpObj } from "@nevware21/ts-utils"; -import { AppInsightsCore } from "../../../src/JavaScriptSDK/AppInsightsCore"; -import { _eInternalMessageId } from "../../../src/JavaScriptSDK.Enums/LoggingEnums"; -import { _InternalLogMessage } from "../../../src/JavaScriptSDK/DiagnosticLogger"; -import { IConfiguration } from "../../../src/JavaScriptSDK.Interfaces/IConfiguration"; +import { AppInsightsCore } from "../../../src/core/AppInsightsCore"; +import { _eInternalMessageId } from "../../../src/enums/ai/LoggingEnums"; +import { _InternalLogMessage } from "../../../src/diagnostics/DiagnosticLogger"; +import { IConfiguration } from "../../../src/interfaces/ai/IConfiguration"; import { OldTrackPlugin, TestChannelPlugin, TestPlugin, TestSamplingPlugin, TrackPlugin } from "./TestPlugins"; const AIInternalMessagePrefix = "AITR_"; diff --git a/shared/AppInsightsCore/Tests/Unit/src/W3TraceState.Tests.ts b/shared/AppInsightsCore/Tests/Unit/src/W3TraceState.Tests.ts index 3a6a05270..46afae8d9 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/W3TraceState.Tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/W3TraceState.Tests.ts @@ -1,6 +1,6 @@ import { Assert, AITestClass } from "@microsoft/ai-test-framework"; import { asString, strRepeat } from "@nevware21/ts-utils"; -import { createW3cTraceState, isW3cTraceState, snapshotW3cTraceState } from "../../../src/JavaScriptSDK/W3cTraceState"; +import { createW3cTraceState, isW3cTraceState, snapshotW3cTraceState } from "../../../src/telemetry/W3cTraceState"; export class W3cTraceStateTests extends AITestClass { diff --git a/shared/AppInsightsCore/Tests/Unit/src/W3cTraceParentTests.ts b/shared/AppInsightsCore/Tests/Unit/src/W3cTraceParentTests.ts index 7187ed51f..99c02f9ea 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/W3cTraceParentTests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/W3cTraceParentTests.ts @@ -1,8 +1,8 @@ import { Assert, AITestClass } from "@microsoft/ai-test-framework"; import { utcNow } from "@nevware21/ts-utils"; -import { ITraceParent } from "../../../src/JavaScriptSDK.Interfaces/ITraceParent"; -import { generateW3CId, newGuid } from "../../../src/JavaScriptSDK/CoreUtils"; -import { formatTraceParent, isSampledFlag, isValidSpanId, isValidTraceId, isValidTraceParent, parseTraceParent } from "../../../src/JavaScriptSDK/W3cTraceParent"; +import { ITraceParent } from "../../../src/interfaces/ai/ITraceParent"; +import { generateW3CId, newGuid } from "../../../src/utils/CoreUtils"; +import { formatTraceParent, isSampledFlag, isValidSpanId, isValidTraceId, isValidTraceParent, parseTraceParent } from "../../../src/utils/TraceParent"; export class W3cTraceParentTests extends AITestClass { diff --git a/shared/AppInsightsCore/Tests/Unit/src/aiunittests.ts b/shared/AppInsightsCore/Tests/Unit/src/aiunittests.ts index 74b7b9fd5..575a29a4a 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/aiunittests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/aiunittests.ts @@ -22,6 +22,16 @@ import { W3cTraceStateTests } from './W3TraceState.Tests'; import { OTelNegativeTests } from './OpenTelemetry/otelNegative.Tests'; import { TraceUtilsTests } from './OpenTelemetry/traceUtils.Tests'; +// Application Insights Common tests (merged from AppInsightsCommon) +import { ApplicationInsightsTests } from './Common/AppInsightsCommon.tests'; +import { ConnectionStringParserTests } from './Common/ConnectionStringParser.tests'; +import { ExceptionTests } from './Common/Exception.tests'; +import { RequestHeadersTests } from './Common/RequestHeaders.tests'; +import { SeverityLevelTests } from './Common/SeverityLevel.tests'; +import { ThrottleMgrTest } from './Common/ThrottleMgr.tests'; +import { UtilTests } from './Common/Util.tests'; +import { W3CTraceStateModesTests } from './Common/W3CTraceStateModes.tests'; + export function runTests() { new GlobalTestHooks().registerTests(); new DynamicTests().registerTests(); @@ -47,4 +57,14 @@ export function runTests() { // new StatsBeatTests(false).registerTests(); // new StatsBeatTests(true).registerTests(); new SendPostManagerTests().registerTests(); + + // Application Insights Common tests (merged from AppInsightsCommon) + new ApplicationInsightsTests().registerTests(); + new ConnectionStringParserTests().registerTests(); + new ExceptionTests().registerTests(); + new RequestHeadersTests().registerTests(); + new SeverityLevelTests().registerTests(); + new ThrottleMgrTest().registerTests(); + new UtilTests().registerTests(); + new W3CTraceStateModesTests().registerTests(); } diff --git a/shared/AppInsightsCore/api-extractor.json b/shared/AppInsightsCore/api-extractor.json index 217a20851..1209227df 100644 --- a/shared/AppInsightsCore/api-extractor.json +++ b/shared/AppInsightsCore/api-extractor.json @@ -45,7 +45,7 @@ * * SUPPORTED TOKENS: , , */ - "mainEntryPointFilePath": "/build/types/applicationinsights-core-js.d.ts", + "mainEntryPointFilePath": "/build/types/index.d.ts", /** * A list of NPM package names whose exports should be treated as part of this package. diff --git a/shared/AppInsightsCore/package.json b/shared/AppInsightsCore/package.json index e1980c076..4caa06060 100644 --- a/shared/AppInsightsCore/package.json +++ b/shared/AppInsightsCore/package.json @@ -13,8 +13,8 @@ "browser performance monitoring", "web analytics" ], - "main": "dist/es5/applicationinsights-core-js.js", - "module": "dist-es5/applicationinsights-core-js.js", + "main": "dist/es5/index.js", + "module": "dist-es5/index.js", "types": "types/applicationinsights-core-js.d.ts", "scripts": { "clean": "git clean -xdf", diff --git a/shared/AppInsightsCore/rollup.config.js b/shared/AppInsightsCore/rollup.config.js index 7ff1b6e4e..2561bfe5e 100644 --- a/shared/AppInsightsCore/rollup.config.js +++ b/shared/AppInsightsCore/rollup.config.js @@ -2,7 +2,8 @@ import { createUnVersionedConfig } from "../../rollup.base.config"; import { updateDistEsmFiles } from "../../tools/updateDistEsm/updateDistEsm"; const version = require("./package.json").version; -const entryPointName = "applicationinsights-core-js"; +const entryPointName = "index"; +const browserOutputName = "applicationinsights-core-js"; // MUST NOT CHANGE - CDN compatibility const banner = [ "/*!", ` * Application Insights JavaScript SDK - Core, ${version}`, @@ -23,13 +24,13 @@ export default createUnVersionedConfig(banner, version: version, node: { entryPoint: entryPointName, - outputName: entryPointName + outputName: entryPointName // Node output uses index }, browser: { entryPoint: entryPointName, - outputName: entryPointName + outputName: browserOutputName // Browser keeps original name for CDN }, }, - [ "applicationinsights-core-js" ], + ["index"], false ); \ No newline at end of file diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/Constants.ts b/shared/AppInsightsCore/src/JavaScriptSDK/Constants.ts deleted file mode 100644 index 38e9922eb..000000000 --- a/shared/AppInsightsCore/src/JavaScriptSDK/Constants.ts +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -export const ChannelControllerPriority = 500; - -export const DisabledPropertyName: string = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation"; -// export const SampleRate = "sampleRate"; -// export const ProcessLegacy = "ProcessLegacy"; -// export const HttpMethod = "http.method"; -// export const DEFAULT_BREEZE_ENDPOINT = "https://dc.services.visualstudio.com"; -// export const DEFAULT_BREEZE_PATH = "/v2/track"; -// export const strNotSpecified = "not_specified"; -// export const strIkey = "iKey"; - diff --git a/shared/AppInsightsCore/src/OpenTelemetry/attribute/SemanticConventions.ts b/shared/AppInsightsCore/src/OpenTelemetry/attribute/SemanticConventions.ts deleted file mode 100644 index 832a92b37..000000000 --- a/shared/AppInsightsCore/src/OpenTelemetry/attribute/SemanticConventions.ts +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -const MICROSOFT_APPLICATIONINSIGHTS_NAME = (/* #__PURE__ */"Microsoft.ApplicationInsights."); -const MICROSOFT_DOT = (/* #__PURE__ */"microsoft."); -const CLIENT_DOT = (/*#__PURE__*/ "client."); -const HTTP_DOT = (/*#__PURE__*/ "http."); -const NET_DOT = (/*#__PURE__*/ "net."); -const PEER_DOT = (/*#__PURE__*/ "peer."); -const EXCEPTION_DOT = (/*#__PURE__*/ "exception."); -const ENDUSER_DOT = (/*#__PURE__*/ "enduser."); -const URL_DOT = (/*#__PURE__*/ "url."); -const DB_DOT = (/*#__PURE__*/ "db."); -const NETWORK_DOT = (/*#__PURE__*/ "network."); - -export const AzureMonitorSampleRate = (/* #__PURE__*/ MICROSOFT_DOT + "sample_rate"); -export const ApplicationInsightsCustomEventName = (/* #__PURE__*/ MICROSOFT_DOT + "custom_event.name"); -export const MicrosoftClientIp = (/* #__PURE__*/ MICROSOFT_DOT + CLIENT_DOT + "ip"); - -export const ApplicationInsightsMessageName = (/* #__PURE__*/ MICROSOFT_APPLICATIONINSIGHTS_NAME + "Message"); -export const ApplicationInsightsExceptionName = (/* #__PURE__*/ MICROSOFT_APPLICATIONINSIGHTS_NAME + "Exception"); -export const ApplicationInsightsPageViewName = (/* #__PURE__*/ MICROSOFT_APPLICATIONINSIGHTS_NAME + "PageView"); -export const ApplicationInsightsAvailabilityName = (/* #__PURE__*/ MICROSOFT_APPLICATIONINSIGHTS_NAME + "Availability"); -export const ApplicationInsightsEventName = (/* #__PURE__*/ MICROSOFT_APPLICATIONINSIGHTS_NAME + "Event"); - -export const ApplicationInsightsBaseType = (/* #__PURE__*/ "_MS.baseType"); -export const ApplicationInsightsMessageBaseType = (/* #__PURE__*/ "MessageData"); -export const ApplicationInsightsExceptionBaseType = (/* #__PURE__*/ "ExceptionData"); -export const ApplicationInsightsPageViewBaseType = (/* #__PURE__*/ "PageViewData"); -export const ApplicationInsightsAvailabilityBaseType = (/* #__PURE__*/ "AvailabilityData"); -export const ApplicationInsightsEventBaseType = (/* #__PURE__*/ "EventData"); - -export const ATTR_ENDUSER_ID = (/* #__PURE__*/ENDUSER_DOT + "id"); -export const ATTR_ENDUSER_PSEUDO_ID = (/* #__PURE__*/ENDUSER_DOT + "pseudo_id"); -export const ATTR_HTTP_ROUTE = (/* #__PURE__*/HTTP_DOT + "route"); - -export const SEMATTRS_NET_PEER_IP = (/*#__PURE__*/ NET_DOT + PEER_DOT + "ip"); -export const SEMATTRS_NET_PEER_NAME = (/*#__PURE__*/ NET_DOT + PEER_DOT + "name"); -export const SEMATTRS_NET_HOST_IP = (/*#__PURE__*/ NET_DOT + "host.ip"); -export const SEMATTRS_PEER_SERVICE = (/*#__PURE__*/ PEER_DOT + "service"); -export const SEMATTRS_HTTP_USER_AGENT = (/*#__PURE__*/ HTTP_DOT + "user_agent"); -export const SEMATTRS_HTTP_METHOD = (/*#__PURE__*/ HTTP_DOT + "method"); -export const SEMATTRS_HTTP_URL = (/*#__PURE__*/ HTTP_DOT + "url"); -export const SEMATTRS_HTTP_STATUS_CODE = (/*#__PURE__*/ HTTP_DOT + "status_code"); -export const SEMATTRS_HTTP_ROUTE = (/*#__PURE__*/ HTTP_DOT + "route"); -export const SEMATTRS_HTTP_HOST = (/*#__PURE__*/ HTTP_DOT + "host"); -export const SEMATTRS_DB_SYSTEM = (/*#__PURE__*/ DB_DOT + "system"); -export const SEMATTRS_DB_STATEMENT = (/*#__PURE__*/ DB_DOT + "statement"); -export const SEMATTRS_DB_OPERATION = (/*#__PURE__*/ DB_DOT + "operation"); -export const SEMATTRS_DB_NAME = (/*#__PURE__*/ DB_DOT + "name"); -export const SEMATTRS_RPC_SYSTEM = (/*#__PURE__*/ "rpc.system"); -export const SEMATTRS_RPC_GRPC_STATUS_CODE = (/*#__PURE__*/ "rpc.grpc.status_code"); -export const SEMATTRS_EXCEPTION_TYPE = (/*#__PURE__*/ EXCEPTION_DOT + "type"); -export const SEMATTRS_EXCEPTION_MESSAGE = (/*#__PURE__*/ EXCEPTION_DOT + "message"); -export const SEMATTRS_EXCEPTION_STACKTRACE = (/*#__PURE__*/ EXCEPTION_DOT + "stacktrace"); -export const SEMATTRS_HTTP_SCHEME = (/*#__PURE__*/ HTTP_DOT + "scheme"); -export const SEMATTRS_HTTP_TARGET = (/*#__PURE__*/ HTTP_DOT + "target"); -export const SEMATTRS_HTTP_FLAVOR = (/*#__PURE__*/ HTTP_DOT + "flavor"); -export const SEMATTRS_NET_TRANSPORT = (/*#__PURE__*/ NET_DOT + "transport"); -export const SEMATTRS_NET_HOST_NAME = (/*#__PURE__*/ NET_DOT + "host.name"); -export const SEMATTRS_NET_HOST_PORT = (/*#__PURE__*/ NET_DOT + "host.port"); -export const SEMATTRS_NET_PEER_PORT = (/*#__PURE__*/ NET_DOT + PEER_DOT + "port"); -export const SEMATTRS_HTTP_CLIENT_IP = (/*#__PURE__*/ HTTP_DOT + "client_ip"); -export const SEMATTRS_ENDUSER_ID = (/*#__PURE__*/ ENDUSER_DOT + "id"); - -export const ATTR_CLIENT_ADDRESS = (/*#__PURE__*/ CLIENT_DOT + "address"); -export const ATTR_CLIENT_PORT = (/*#__PURE__*/ CLIENT_DOT + "port"); -export const ATTR_SERVER_ADDRESS = (/*#__PURE__*/ "server.address"); -export const ATTR_SERVER_PORT = (/*#__PURE__*/ "server.port"); -export const ATTR_URL_FULL = (/*#__PURE__*/ URL_DOT + "full"); -export const ATTR_URL_PATH = (/*#__PURE__*/ URL_DOT + "path"); -export const ATTR_URL_QUERY = (/*#__PURE__*/ URL_DOT + "query"); -export const ATTR_URL_SCHEME = (/*#__PURE__*/ URL_DOT + "scheme"); -export const ATTR_ERROR_TYPE = (/*#__PURE__*/ "error.type"); -export const ATTR_NETWORK_LOCAL_ADDRESS = (/*#__PURE__*/ NETWORK_DOT + "local.address"); -export const ATTR_NETWORK_LOCAL_PORT = (/*#__PURE__*/ NETWORK_DOT + "local.port"); -export const ATTR_NETWORK_PROTOCOL_NAME = (/*#__PURE__*/ NETWORK_DOT + "protocol.name"); -export const ATTR_NETWORK_PEER_ADDRESS = (/*#__PURE__*/ NETWORK_DOT + PEER_DOT + "address"); -export const ATTR_NETWORK_PEER_PORT = (/*#__PURE__*/ NETWORK_DOT + PEER_DOT + "port"); -export const ATTR_NETWORK_PROTOCOL_VERSION = (/*#__PURE__*/ NETWORK_DOT + "protocol.version"); -export const ATTR_NETWORK_TRANSPORT = (/*#__PURE__*/ NETWORK_DOT + "transport"); -export const ATTR_USER_AGENT_ORIGINAL = (/*#__PURE__*/ "user_agent.original"); -export const ATTR_HTTP_REQUEST_METHOD = (/*#__PURE__*/ HTTP_DOT + "request.method"); -export const ATTR_HTTP_RESPONSE_STATUS_CODE = (/*#__PURE__*/ HTTP_DOT + "response.status_code"); -export const ATTR_EXCEPTION_TYPE = (/*#__PURE__*/ EXCEPTION_DOT + "type"); -export const ATTR_EXCEPTION_MESSAGE = (/*#__PURE__*/ EXCEPTION_DOT + "message"); -export const ATTR_EXCEPTION_STACKTRACE = (/*#__PURE__*/ EXCEPTION_DOT + "stacktrace"); -export const EXP_ATTR_ENDUSER_ID = (/*#__PURE__*/ ENDUSER_DOT + "id"); -export const EXP_ATTR_ENDUSER_PSEUDO_ID = (/*#__PURE__*/ ENDUSER_DOT + "pseudo_id"); -export const EXP_ATTR_SYNTHETIC_TYPE = (/*#__PURE__*/ "synthetic.type"); - - -export const DBSYSTEMVALUES_MONGODB = (/*#__PURE__*/ "mongodb"); -export const DBSYSTEMVALUES_COSMOSDB = (/*#__PURE__*/ "cosmosdb"); -export const DBSYSTEMVALUES_MYSQL = (/*#__PURE__*/ "mysql"); -export const DBSYSTEMVALUES_POSTGRESQL = (/*#__PURE__*/ "postgresql"); -export const DBSYSTEMVALUES_REDIS = (/*#__PURE__*/ "redis"); -export const DBSYSTEMVALUES_DB2 = (/*#__PURE__*/ "db2"); -export const DBSYSTEMVALUES_DERBY = (/*#__PURE__*/ "derby"); -export const DBSYSTEMVALUES_MARIADB = (/*#__PURE__*/ "mariadb"); -export const DBSYSTEMVALUES_MSSQL = (/*#__PURE__*/ "mssql"); -export const DBSYSTEMVALUES_ORACLE = (/*#__PURE__*/ "oracle"); -export const DBSYSTEMVALUES_SQLITE = (/*#__PURE__*/ "sqlite"); -export const DBSYSTEMVALUES_OTHER_SQL = (/*#__PURE__*/ "other_sql"); -export const DBSYSTEMVALUES_HSQLDB = (/*#__PURE__*/ "hsqldb"); -export const DBSYSTEMVALUES_H2 = (/*#__PURE__*/ "h2"); diff --git a/shared/AppInsightsCore/src/applicationinsights-core-js.ts b/shared/AppInsightsCore/src/applicationinsights-core-js.ts deleted file mode 100644 index 88fb740dc..000000000 --- a/shared/AppInsightsCore/src/applicationinsights-core-js.ts +++ /dev/null @@ -1,207 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -export { IConfiguration } from "./JavaScriptSDK.Interfaces/IConfiguration"; -export { IChannelControls, MinChannelPriorty, IInternalOfflineSupport } from "./JavaScriptSDK.Interfaces/IChannelControls"; -export { IChannelControlsHost } from "./JavaScriptSDK.Interfaces/IChannelControlsHost"; -export { ITelemetryPlugin, IPlugin } from "./JavaScriptSDK.Interfaces/ITelemetryPlugin"; -export { IExceptionConfig } from "./JavaScriptSDK.Interfaces/IExceptionConfig"; -export { IAppInsightsCore, ILoadedPlugin } from "./JavaScriptSDK.Interfaces/IAppInsightsCore"; -export { ITelemetryItem, ICustomProperties, Tags } from "./JavaScriptSDK.Interfaces/ITelemetryItem"; -export { IBaseProcessingContext, IProcessTelemetryContext, IProcessTelemetryUnloadContext, IProcessTelemetryUpdateContext } from "./JavaScriptSDK.Interfaces/IProcessTelemetryContext"; -export { INotificationListener } from "./JavaScriptSDK.Interfaces/INotificationListener"; -export { ITelemetryPluginChain } from "./JavaScriptSDK.Interfaces/ITelemetryPluginChain"; -export { IDiagnosticLogger } from "./JavaScriptSDK.Interfaces/IDiagnosticLogger"; -export { InstrumentorHooksCallback, IInstrumentHooksCallbacks, IInstrumentHooks, IInstrumentHook, IInstrumentCallDetails } from "./JavaScriptSDK.Interfaces/IInstrumentHooks"; -export { IUnloadableComponent } from "./JavaScriptSDK.Interfaces/IUnloadableComponent"; -export { IPayloadData, SendPOSTFunction, IXHROverride, OnCompleteCallback } from "./JavaScriptSDK.Interfaces/IXHROverride" -export { IUnloadHook, ILegacyUnloadHook } from "./JavaScriptSDK.Interfaces/IUnloadHook"; -export { eEventsDiscardedReason, EventsDiscardedReason, eBatchDiscardedReason, BatchDiscardedReason } from "./JavaScriptSDK.Enums/EventsDiscardedReason"; -export { eDependencyTypes, DependencyTypes } from "./JavaScriptSDK.Enums/DependencyTypes"; -export { SendRequestReason, TransportType } from "./JavaScriptSDK.Enums/SendRequestReason"; -//export { StatsType, eStatsType } from "./JavaScriptSDK.Enums/StatsType"; -export { TelemetryUpdateReason } from "./JavaScriptSDK.Enums/TelemetryUpdateReason"; -export { TelemetryUnloadReason } from "./JavaScriptSDK.Enums/TelemetryUnloadReason"; -export { eActiveStatus, ActiveStatus } from "./JavaScriptSDK.Enums/InitActiveStatusEnum" -export { throwAggregationError } from "./JavaScriptSDK/AggregationError"; -export { AppInsightsCore } from "./JavaScriptSDK/AppInsightsCore"; -export { BaseTelemetryPlugin } from "./JavaScriptSDK/BaseTelemetryPlugin"; -export { randomValue, random32, mwcRandomSeed, mwcRandom32, newId } from "./JavaScriptSDK/RandomHelper"; -export { Undefined, newGuid, generateW3CId } from "./JavaScriptSDK/CoreUtils"; -export { runTargetUnload, doUnloadAll } from "./JavaScriptSDK/AsyncUtils"; -export { - normalizeJsName, toISOString, getExceptionName, strContains, setValue, getSetValue, - proxyAssign, proxyFunctions, proxyFunctionAs, createClassFromInterface, optimizeObject, - isNotUndefined, isNotNullOrUndefined, objExtend, isFeatureEnabled, getResponseText, formatErrorMessageXdr, formatErrorMessageXhr, prependTransports, - openXhr, _appendHeader, _getAllResponseHeaders, setObjStringTag, setProtoTypeName -} from "./JavaScriptSDK/HelperFuncs"; -export { parseResponse } from "./JavaScriptSDK/ResponseHelpers"; -export { IXDomainRequest, IBackendResponse } from "./JavaScriptSDK.Interfaces/IXDomainRequest"; -export { _ISenderOnComplete, _ISendPostMgrConfig, _ITimeoutOverrideWrapper, _IInternalXhrOverride } from "./JavaScriptSDK.Interfaces/ISenderPostManager"; -export { SenderPostManager } from "./JavaScriptSDK/SenderPostManager"; -//export { IStatsBeat, IStatsBeatConfig, IStatsBeatKeyMap as IStatsBeatEndpoints, IStatsBeatState} from "./JavaScriptSDK.Interfaces/IStatsBeat"; -//export { IStatsEventData } from "./JavaScriptSDK.Interfaces/IStatsEventData"; -//export { IStatsMgr, IStatsMgrConfig } from "./JavaScriptSDK.Interfaces/IStatsMgr"; -//export { createStatsMgr } from "./JavaScriptSDK/StatsBeat"; -export { - isArray, isTypeof, isUndefined, isNullOrUndefined, isStrictUndefined, objHasOwnProperty as hasOwnProperty, isObject, isFunction, - strEndsWith, strStartsWith, isDate, isError, isString, isNumber, isBoolean, arrForEach, arrIndexOf, - arrReduce, arrMap, strTrim, objKeys, objCreate, objDefine, objDefineProp, objDefineAccessors, throwError, isSymbol, - isNotTruthy, isTruthy, objFreeze, objSeal, objToString, objDeepFreeze as deepFreeze, - getInst as getGlobalInst, hasWindow, getWindow, hasDocument, getDocument, hasNavigator, getNavigator, hasHistory, - getHistory, dumpObj, asString, objForEachKey, getPerformance, utcNow as dateNow, perfNow, - ObjDefinePropDescriptor -} from "@nevware21/ts-utils"; -export { EnumValue, createEnumStyle, createValueMap } from "./JavaScriptSDK.Enums/EnumHelperFuncs"; -export { - attachEvent, detachEvent, addEventHandler, addEventListeners, addPageUnloadEventListener, addPageHideEventListener, addPageShowEventListener, - removeEventHandler, removeEventListeners, removePageUnloadEventListener, removePageHideEventListener, removePageShowEventListener, eventOn, eventOff, - mergeEvtNamespace, _IRegisteredEvents, __getRegisteredEvents -} from "./JavaScriptSDK/EventHelpers"; - -export { - getCrypto, getMsCrypto, getLocation, hasJSON, getJSON, - isReactNative, getConsole, isIE, getIEVersion, isSafari, - setEnableEnvMocks, isBeaconsSupported, isFetchSupported, useXDomainRequest, isXhrSupported, - findMetaTag, findNamedServerTiming, sendCustomEvent, dispatchEvent, createCustomDomEvent, fieldRedaction -} from "./JavaScriptSDK/EnvUtils"; -export { - getGlobal, - strShimPrototype as strPrototype, - strShimFunction as strFunction, - strShimUndefined as strUndefined, - strShimObject as strObject -} from "@microsoft/applicationinsights-shims"; -export { NotificationManager } from "./JavaScriptSDK/NotificationManager"; -export { INotificationManager } from "./JavaScriptSDK.Interfaces/INotificationManager"; -export { IPerfEvent } from "./JavaScriptSDK.Interfaces/IPerfEvent"; -export { IPerfManager, IPerfManagerProvider } from "./JavaScriptSDK.Interfaces/IPerfManager"; -export { PerfEvent, PerfManager, doPerf, getGblPerfMgr, setGblPerfMgr } from "./JavaScriptSDK/PerfManager"; -export { IFeatureOptInDetails, IFeatureOptIn } from "./JavaScriptSDK.Interfaces/IFeatureOptIn"; -export { FeatureOptInMode, CdnFeatureMode } from "./JavaScriptSDK.Enums/FeatureOptInEnums" -export { safeGetLogger, DiagnosticLogger, _InternalLogMessage, _throwInternal, _warnToConsole, _logInternalMessage } from "./JavaScriptSDK/DiagnosticLogger"; -export { - createProcessTelemetryContext - // Explicitly NOT exporting createProcessTelemetryUnloadContext() and createProcessTelemetryUpdateContext() as these should only be created internally -} from "./JavaScriptSDK/ProcessTelemetryContext"; -export { initializePlugins, sortPlugins, unloadComponents, createDistributedTraceContext, isDistributedTraceContext } from "./JavaScriptSDK/TelemetryHelpers"; -export { _eInternalMessageId, _InternalMessageId, LoggingSeverity, eLoggingSeverity } from "./JavaScriptSDK.Enums/LoggingEnums"; -export { InstrumentProto, InstrumentProtos, InstrumentFunc, InstrumentFuncs, InstrumentEvent } from "./JavaScriptSDK/InstrumentHooks"; -export { ICookieMgr, ICookieMgrConfig } from "./JavaScriptSDK.Interfaces/ICookieMgr"; -export { - createCookieMgr, safeGetCookieMgr, uaDisallowsSameSiteNone, areCookiesSupported -} from "./JavaScriptSDK/CookieMgr"; -export { IDbgExtension } from "./JavaScriptSDK.Interfaces/IDbgExtension"; -export { getDebugListener, getDebugExt } from "./JavaScriptSDK/DbgExtensionUtils" -export { TelemetryInitializerFunction, ITelemetryInitializerHandler, ITelemetryInitializerContainer } from "./JavaScriptSDK.Interfaces/ITelemetryInitializers"; -export { createUniqueNamespace } from "./JavaScriptSDK/DataCacheHelper"; -export { UnloadHandler, IUnloadHandlerContainer, createUnloadHandlerContainer } from "./JavaScriptSDK/UnloadHandlerContainer"; -export { IUnloadHookContainer, createUnloadHookContainer, _testHookMaxUnloadHooksCb } from "./JavaScriptSDK/UnloadHookContainer"; -export { ITelemetryUpdateState } from "./JavaScriptSDK.Interfaces/ITelemetryUpdateState"; -export { ITelemetryUnloadState } from "./JavaScriptSDK.Interfaces/ITelemetryUnloadState"; -export { IDistributedTraceContext, IDistributedTraceInit } from "./JavaScriptSDK.Interfaces/IDistributedTraceContext"; -export { ITraceParent } from "./JavaScriptSDK.Interfaces/ITraceParent"; -export { - createTraceParent, parseTraceParent, isValidTraceId, isValidSpanId, isValidTraceParent, isSampledFlag, formatTraceParent, findW3cTraceParent, - findAllScripts -} from "./JavaScriptSDK/W3cTraceParent"; - -// Dynamic Config definitions -export { IConfigCheckFn, IConfigDefaultCheck, IConfigDefaults, IConfigSetFn } from "./Config/IConfigDefaults"; -export { IDynamicConfigHandler } from "./Config/IDynamicConfigHandler"; -export { IDynamicPropertyHandler } from "./Config/IDynamicPropertyHandler"; -export { IWatchDetails, IWatcherHandler, WatcherFunction } from "./Config/IDynamicWatcher"; -export { createDynamicConfig, onConfigChange } from "./Config/DynamicConfig"; -export { getDynamicConfigHandler, blockDynamicConversion, forceDynamicConversion } from "./Config/DynamicSupport"; -export { cfgDfValidate, cfgDfMerge, cfgDfBoolean, cfgDfFunc, cfgDfString, cfgDfSet, cfgDfBlockPropValue } from "./Config/ConfigDefaultHelpers"; - -// W3c TraceState support -export { eW3CTraceFlags } from "./JavaScriptSDK.Enums/W3CTraceFlags"; -export { IW3cTraceState } from "./JavaScriptSDK.Interfaces/IW3cTraceState"; -export { createW3cTraceState, findW3cTraceState, isW3cTraceState, snapshotW3cTraceState } from "./JavaScriptSDK/W3cTraceState"; - -// OpenTelemetry Trace support -export { IOTelTraceState } from "./OpenTelemetry/interfaces/trace/IOTelTraceState"; -export { IOTelSpan } from "./OpenTelemetry/interfaces/trace/IOTelSpan"; -export { IOTelTracer } from "./OpenTelemetry/interfaces/trace/IOTelTracer"; -export { IOTelTracerProvider, IOTelTracerOptions } from "./OpenTelemetry/interfaces/trace/IOTelTracerProvider"; -export { ITraceProvider, ITraceHost, ISpanScope } from "./JavaScriptSDK.Interfaces/ITraceProvider"; -export { IOTelSpanOptions } from "./OpenTelemetry/interfaces/trace/IOTelSpanOptions"; -export { createOTelTraceState } from "./OpenTelemetry/trace/traceState"; -export { createSpan } from "./OpenTelemetry/trace/span"; -export { createTraceProvider } from "./OpenTelemetry/trace/traceProvider"; -export { isSpanContextValid, wrapSpanContext, isReadableSpan, suppressTracing, unsuppressTracing, isTracingSuppressed, useSpan, withSpan, startActiveSpan } from "./OpenTelemetry/trace/utils"; - -export { - AzureMonitorSampleRate, ApplicationInsightsCustomEventName, MicrosoftClientIp, ApplicationInsightsMessageName, - ApplicationInsightsExceptionName, ApplicationInsightsPageViewName, ApplicationInsightsAvailabilityName, - ApplicationInsightsEventName, ApplicationInsightsBaseType, ApplicationInsightsMessageBaseType, - ApplicationInsightsExceptionBaseType, ApplicationInsightsPageViewBaseType, ApplicationInsightsAvailabilityBaseType, - ApplicationInsightsEventBaseType, ATTR_ENDUSER_ID, ATTR_ENDUSER_PSEUDO_ID, ATTR_HTTP_ROUTE, SEMATTRS_NET_PEER_IP, - SEMATTRS_NET_PEER_NAME, SEMATTRS_NET_HOST_IP, SEMATTRS_PEER_SERVICE, SEMATTRS_HTTP_USER_AGENT, SEMATTRS_HTTP_METHOD, - SEMATTRS_HTTP_URL, SEMATTRS_HTTP_STATUS_CODE, SEMATTRS_HTTP_ROUTE, SEMATTRS_HTTP_HOST, SEMATTRS_DB_SYSTEM, - SEMATTRS_DB_STATEMENT, SEMATTRS_DB_OPERATION, SEMATTRS_DB_NAME, SEMATTRS_RPC_SYSTEM, SEMATTRS_RPC_GRPC_STATUS_CODE, - SEMATTRS_EXCEPTION_TYPE, SEMATTRS_EXCEPTION_MESSAGE, SEMATTRS_EXCEPTION_STACKTRACE, SEMATTRS_HTTP_SCHEME, - SEMATTRS_HTTP_TARGET, SEMATTRS_HTTP_FLAVOR, SEMATTRS_NET_TRANSPORT, SEMATTRS_NET_HOST_NAME, SEMATTRS_NET_HOST_PORT, - SEMATTRS_NET_PEER_PORT, SEMATTRS_HTTP_CLIENT_IP, SEMATTRS_ENDUSER_ID, ATTR_CLIENT_ADDRESS, ATTR_CLIENT_PORT, - ATTR_SERVER_ADDRESS, ATTR_SERVER_PORT, ATTR_URL_FULL, ATTR_URL_PATH, ATTR_URL_QUERY, ATTR_URL_SCHEME, - ATTR_ERROR_TYPE, ATTR_NETWORK_LOCAL_ADDRESS, ATTR_NETWORK_LOCAL_PORT, ATTR_NETWORK_PROTOCOL_NAME, - ATTR_NETWORK_PEER_ADDRESS, ATTR_NETWORK_PEER_PORT, ATTR_NETWORK_PROTOCOL_VERSION, ATTR_NETWORK_TRANSPORT, - ATTR_USER_AGENT_ORIGINAL, ATTR_HTTP_REQUEST_METHOD, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_EXCEPTION_TYPE, - ATTR_EXCEPTION_MESSAGE, ATTR_EXCEPTION_STACKTRACE, EXP_ATTR_ENDUSER_ID, EXP_ATTR_ENDUSER_PSEUDO_ID, - EXP_ATTR_SYNTHETIC_TYPE, DBSYSTEMVALUES_MONGODB, DBSYSTEMVALUES_COSMOSDB, DBSYSTEMVALUES_MYSQL, - DBSYSTEMVALUES_POSTGRESQL, DBSYSTEMVALUES_REDIS, DBSYSTEMVALUES_DB2, DBSYSTEMVALUES_DERBY, DBSYSTEMVALUES_MARIADB, - DBSYSTEMVALUES_MSSQL, DBSYSTEMVALUES_ORACLE, DBSYSTEMVALUES_SQLITE, DBSYSTEMVALUES_OTHER_SQL, DBSYSTEMVALUES_HSQLDB, - DBSYSTEMVALUES_H2 -} from "./OpenTelemetry/attribute/SemanticConventions" - -// OpenTelemetry Core API Interfaces -export { IOTelApi } from "./OpenTelemetry/interfaces/IOTelApi"; -export { IOTelApiCtx } from "./OpenTelemetry/interfaces/IOTelApiCtx"; -export { IOTelAttributes, OTelAttributeValue, ExtendedOTelAttributeValue } from "./OpenTelemetry/interfaces/IOTelAttributes"; -export { OTelException } from "./OpenTelemetry/interfaces/IOTelException"; -export { IOTelHrTime, OTelTimeInput } from "./OpenTelemetry/interfaces/IOTelHrTime"; -export { createOTelApi } from "./OpenTelemetry/otelApi"; - -// OpenTelemetry Trace Interfaces -export { ITraceApi } from "./OpenTelemetry/interfaces/trace/ITraceApi"; -export { IOTelSpanCtx } from "./OpenTelemetry/interfaces/trace/IOTelSpanCtx"; -export { IOTelSpanStatus } from "./OpenTelemetry/interfaces/trace/IOTelSpanStatus"; -export { IReadableSpan } from "./OpenTelemetry/interfaces/trace/IReadableSpan"; - -// OpenTelemetry Configuration Interfaces -export { IOTelConfig } from "./OpenTelemetry/interfaces/config/IOTelConfig"; -export { IOTelAttributeLimits } from "./OpenTelemetry/interfaces/config/IOTelAttributeLimits"; -export { IOTelErrorHandlers } from "./OpenTelemetry/interfaces/config/IOTelErrorHandlers"; -export { ITraceCfg } from "./OpenTelemetry/interfaces/config/ITraceCfg"; - -// OpenTelemetry Attribute Support -export { IAttributeContainer, IAttributeChangeInfo } from "./OpenTelemetry/attribute/IAttributeContainer"; -export { eAttributeChangeOp, AttributeChangeOp } from "./OpenTelemetry/enums/eAttributeChangeOp"; -export { createAttributeContainer, addAttributes, isAttributeContainer, createAttributeSnapshot } from "./OpenTelemetry/attribute/attributeContainer"; -export { eAttributeFilter, AttributeFilter } from "./OpenTelemetry/attribute/IAttributeContainer"; - -// OpenTelemetry Enums -export { eOTelSpanKind, OTelSpanKind } from "./OpenTelemetry/enums/trace/OTelSpanKind"; -export { eOTelSpanStatusCode, OTelSpanStatusCode } from "./OpenTelemetry/enums/trace/OTelSpanStatus"; - -// OpenTelemetry Helper Utilities -export { - hrTime, hrTimeToTimeStamp, hrTimeDuration, hrTimeToMilliseconds, timeInputToHrTime, millisToHrTime, hrTimeToNanoseconds, - addHrTimes, hrTimeToMicroseconds, zeroHrTime, nanosToHrTime, isTimeInput, isTimeInputHrTime, isTimeSpan -} from "./OpenTelemetry/helpers/timeHelpers"; -export { isAttributeValue, isAttributeKey, sanitizeAttributes } from "./OpenTelemetry/helpers/attributeHelpers"; -export { - getSyntheticType, isSyntheticSource, serializeAttribute, getUrl, getPeerIp, getHttpMethod, getHttpUrl, getHttpHost, getHttpScheme, - getHttpTarget, getNetPeerName, getNetPeerPort, getUserAgent, getLocationIp, getHttpStatusCode, getHttpClientIp, - getDependencyTarget, isSqlDB -} from "./OpenTelemetry/helpers/common"; - -// OpenTelemetry Error Handlers -export { - handleAttribError, handleSpanError, handleDebug, handleWarn, handleError, handleNotImplemented -} from "./OpenTelemetry/helpers/handleErrors"; - -// OpenTelemetry Error Classes -export { OpenTelemetryError, OpenTelemetryErrorConstructor, getOpenTelemetryError, throwOTelError } from "./OpenTelemetry/errors/OTelError"; -export { OTelInvalidAttributeError, throwOTelInvalidAttributeError } from "./OpenTelemetry/errors/OTelInvalidAttributeError"; -export { OTelSpanError, throwOTelSpanError } from "./OpenTelemetry/errors/OTelSpanError"; diff --git a/shared/AppInsightsCore/src/Config/ConfigDefaultHelpers.ts b/shared/AppInsightsCore/src/config/ConfigDefaultHelpers.ts similarity index 96% rename from shared/AppInsightsCore/src/Config/ConfigDefaultHelpers.ts rename to shared/AppInsightsCore/src/config/ConfigDefaultHelpers.ts index eec2688e8..5ef7fa72d 100644 --- a/shared/AppInsightsCore/src/Config/ConfigDefaultHelpers.ts +++ b/shared/AppInsightsCore/src/config/ConfigDefaultHelpers.ts @@ -2,9 +2,9 @@ // Licensed under the MIT License. import { asString, isBoolean, isFunction, isNullOrUndefined, isString } from "@nevware21/ts-utils"; -import { STR_EMPTY } from "../JavaScriptSDK/InternalConstants"; -import { IConfiguration } from "../applicationinsights-core-js"; -import { IConfigCheckFn, IConfigDefaultCheck, IConfigDefaults, IConfigSetFn } from "./IConfigDefaults"; +import { STR_EMPTY } from "../constants/InternalConstants"; +import { IConfiguration } from "../interfaces/ai/IConfiguration"; +import { IConfigCheckFn, IConfigDefaultCheck, IConfigDefaults, IConfigSetFn } from "../interfaces/config/IConfigDefaults"; /** * @internal diff --git a/shared/AppInsightsCore/src/Config/ConfigDefaults.ts b/shared/AppInsightsCore/src/config/ConfigDefaults.ts similarity index 98% rename from shared/AppInsightsCore/src/Config/ConfigDefaults.ts rename to shared/AppInsightsCore/src/config/ConfigDefaults.ts index be8e6621d..1586917b0 100644 --- a/shared/AppInsightsCore/src/Config/ConfigDefaults.ts +++ b/shared/AppInsightsCore/src/config/ConfigDefaults.ts @@ -4,8 +4,8 @@ import { asString, isArray, isDefined, isNullOrUndefined, isObject, isPlainObject, isUndefined, objForEachKey, objHasOwn } from "@nevware21/ts-utils"; -import { IConfigCheckFn, IConfigDefaultCheck, IConfigDefaults, IConfigSetFn } from "./IConfigDefaults"; -import { IDynamicConfigHandler } from "./IDynamicConfigHandler"; +import { IConfigCheckFn, IConfigDefaultCheck, IConfigDefaults, IConfigSetFn } from "../interfaces/config/IConfigDefaults"; +import { IDynamicConfigHandler } from "../interfaces/config/IDynamicConfigHandler"; function _isConfigDefaults(value: any): value is IConfigDefaultCheck { return (value && isObject(value) && !isArray(value) && (value.isVal || value.fb || objHasOwn(value, "v") || objHasOwn(value, "mrg") || objHasOwn(value, "ref") || value.set)); diff --git a/shared/AppInsightsCore/src/Config/DynamicConfig.ts b/shared/AppInsightsCore/src/config/DynamicConfig.ts similarity index 91% rename from shared/AppInsightsCore/src/Config/DynamicConfig.ts rename to shared/AppInsightsCore/src/config/DynamicConfig.ts index eb7a15c41..e8856cc95 100644 --- a/shared/AppInsightsCore/src/Config/DynamicConfig.ts +++ b/shared/AppInsightsCore/src/config/DynamicConfig.ts @@ -2,21 +2,21 @@ // Licensed under the MIT License. import { dumpObj, isUndefined, objDefine, objForEachKey } from "@nevware21/ts-utils"; -import { _eInternalMessageId, eLoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums"; -import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration"; -import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger"; -import { createUniqueNamespace } from "../JavaScriptSDK/DataCacheHelper"; -import { STR_NOT_DYNAMIC_ERROR } from "../JavaScriptSDK/InternalConstants"; +import { STR_NOT_DYNAMIC_ERROR } from "../constants/InternalConstants"; +import { _eInternalMessageId, eLoggingSeverity } from "../enums/ai/LoggingEnums"; +import { IConfiguration } from "../interfaces/ai/IConfiguration"; +import { IDiagnosticLogger } from "../interfaces/ai/IDiagnosticLogger"; +import { IConfigDefaults } from "../interfaces/config/IConfigDefaults"; +import { IDynamicConfigHandler, _IInternalDynamicConfigHandler } from "../interfaces/config/IDynamicConfigHandler"; +import { IWatcherHandler, WatcherFunction } from "../interfaces/config/IDynamicWatcher"; +import { _IDynamicConfigHandlerState } from "../interfaces/config/_IDynamicConfigHandlerState"; +import { createUniqueNamespace } from "../utils/DataCacheHelper"; import { _applyDefaultValue } from "./ConfigDefaults"; import { _eSetDynamicPropertyFlags, _makeDynamicObject, _setDynamicProperty, _setDynamicPropertyState, _throwDynamicError } from "./DynamicProperty"; import { _createState } from "./DynamicState"; import { CFG_HANDLER_LINK, _cfgDeepCopy, getDynamicConfigHandler, throwInvalidAccess } from "./DynamicSupport"; -import { IConfigDefaults } from "./IConfigDefaults"; -import { IDynamicConfigHandler, _IInternalDynamicConfigHandler } from "./IDynamicConfigHandler"; -import { IWatcherHandler, WatcherFunction } from "./IDynamicWatcher"; -import { _IDynamicConfigHandlerState } from "./_IDynamicConfigHandlerState"; /** * Identifies a function which will be re-called whenever any of it's accessed configuration values diff --git a/shared/AppInsightsCore/src/Config/DynamicProperty.ts b/shared/AppInsightsCore/src/config/DynamicProperty.ts similarity index 96% rename from shared/AppInsightsCore/src/Config/DynamicProperty.ts rename to shared/AppInsightsCore/src/config/DynamicProperty.ts index 826a79029..2aee68895 100644 --- a/shared/AppInsightsCore/src/Config/DynamicProperty.ts +++ b/shared/AppInsightsCore/src/config/DynamicProperty.ts @@ -4,12 +4,12 @@ import { arrForEach, arrIndexOf, dumpObj, isArray, objDefine, objDefineProp, objForEachKey, objGetOwnPropertyDescriptor } from "@nevware21/ts-utils"; -import { _eInternalMessageId, eLoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums"; -import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger"; -import { UNDEFINED_VALUE } from "../JavaScriptSDK/InternalConstants"; +import { UNDEFINED_VALUE } from "../constants/InternalConstants"; +import { _eInternalMessageId, eLoggingSeverity } from "../enums/ai/LoggingEnums"; +import { IDiagnosticLogger } from "../interfaces/ai/IDiagnosticLogger"; +import { IWatcherHandler, _IDynamicDetail } from "../interfaces/config/IDynamicWatcher"; +import { _IDynamicConfigHandlerState, _IDynamicGetter } from "../interfaces/config/_IDynamicConfigHandlerState"; import { CFG_HANDLER_LINK, _canMakeDynamic, blockDynamicConversion, throwInvalidAccess } from "./DynamicSupport"; -import { IWatcherHandler, _IDynamicDetail } from "./IDynamicWatcher"; -import { _IDynamicConfigHandlerState, _IDynamicGetter } from "./_IDynamicConfigHandlerState"; export const enum _eSetDynamicPropertyFlags { inPlace = 0, diff --git a/shared/AppInsightsCore/src/Config/DynamicState.ts b/shared/AppInsightsCore/src/config/DynamicState.ts similarity index 94% rename from shared/AppInsightsCore/src/Config/DynamicState.ts rename to shared/AppInsightsCore/src/config/DynamicState.ts index 60851283b..1109d7505 100644 --- a/shared/AppInsightsCore/src/Config/DynamicState.ts +++ b/shared/AppInsightsCore/src/config/DynamicState.ts @@ -2,11 +2,11 @@ // Licensed under the MIT License. import { ITimerHandler, arrForEach, arrIndexOf, dumpObj, newSymbol, scheduleTimeout } from "@nevware21/ts-utils"; -import { _eInternalMessageId, eLoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums"; -import { throwAggregationError } from "../JavaScriptSDK/AggregationError"; -import { _IInternalDynamicConfigHandler } from "./IDynamicConfigHandler"; -import { IWatcherHandler, WatcherFunction, _IDynamicDetail } from "./IDynamicWatcher"; -import { _IDynamicConfigHandlerState } from "./_IDynamicConfigHandlerState"; +import { throwAggregationError } from "../core/AggregationError"; +import { _eInternalMessageId, eLoggingSeverity } from "../enums/ai/LoggingEnums"; +import { _IInternalDynamicConfigHandler } from "../interfaces/config/IDynamicConfigHandler"; +import { IWatcherHandler, WatcherFunction, _IDynamicDetail } from "../interfaces/config/IDynamicWatcher"; +import { _IDynamicConfigHandlerState } from "../interfaces/config/_IDynamicConfigHandlerState"; const symPrefix = "[[ai_"; const symPostfix = "]]"; diff --git a/shared/AppInsightsCore/src/Config/DynamicSupport.ts b/shared/AppInsightsCore/src/config/DynamicSupport.ts similarity index 96% rename from shared/AppInsightsCore/src/Config/DynamicSupport.ts rename to shared/AppInsightsCore/src/config/DynamicSupport.ts index 44cb41d0f..127473d5f 100644 --- a/shared/AppInsightsCore/src/Config/DynamicSupport.ts +++ b/shared/AppInsightsCore/src/config/DynamicSupport.ts @@ -2,9 +2,9 @@ // Licensed under the MIT License. import { isArray, isPlainObject, objForEachKey, symbolFor, throwTypeError } from "@nevware21/ts-utils"; -import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration"; -import { IDynamicConfigHandler } from "./IDynamicConfigHandler"; -import { _IDynamicConfigHandlerState } from "./_IDynamicConfigHandlerState"; +import { IConfiguration } from "../interfaces/ai/IConfiguration"; +import { IDynamicConfigHandler } from "../interfaces/config/IDynamicConfigHandler"; +import { _IDynamicConfigHandlerState } from "../interfaces/config/_IDynamicConfigHandlerState"; // Using Symbol.for so that if the same symbol was already created it would be returned // To handle multiple instances using potentially different versions we are not using diff --git a/shared/AppInsightsCommon/src/Constants.ts b/shared/AppInsightsCore/src/constants/Constants.ts similarity index 95% rename from shared/AppInsightsCommon/src/Constants.ts rename to shared/AppInsightsCore/src/constants/Constants.ts index fefde7f7b..f78f707bc 100644 --- a/shared/AppInsightsCommon/src/Constants.ts +++ b/shared/AppInsightsCore/src/constants/Constants.ts @@ -9,6 +9,9 @@ * @ignore */ export const DisabledPropertyName: string = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation"; + +export const ChannelControllerPriority = 500; + export const SampleRate = "sampleRate"; export const ProcessLegacy = "ProcessLegacy"; export const HttpMethod = "http.method"; @@ -16,3 +19,4 @@ export const DEFAULT_BREEZE_ENDPOINT = "https://dc.services.visualstudio.com"; export const DEFAULT_BREEZE_PATH = "/v2/track"; export const strNotSpecified = "not_specified"; export const strIkey = "iKey"; + diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/InternalConstants.ts b/shared/AppInsightsCore/src/constants/InternalConstants.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK/InternalConstants.ts rename to shared/AppInsightsCore/src/constants/InternalConstants.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/AggregationError.ts b/shared/AppInsightsCore/src/core/AggregationError.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK/AggregationError.ts rename to shared/AppInsightsCore/src/core/AggregationError.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/AppInsightsCore.ts b/shared/AppInsightsCore/src/core/AppInsightsCore.ts similarity index 96% rename from shared/AppInsightsCore/src/JavaScriptSDK/AppInsightsCore.ts rename to shared/AppInsightsCore/src/core/AppInsightsCore.ts index af399fec1..fb120e136 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK/AppInsightsCore.ts +++ b/shared/AppInsightsCore/src/core/AppInsightsCore.ts @@ -7,51 +7,52 @@ import { ICachedValue, ITimerHandler, arrAppend, arrForEach, arrIndexOf, createTimeout, deepExtend, hasDocument, isFunction, isNullOrUndefined, isPlainObject, isPromiseLike, objAssign, objDeepFreeze, objDefine, objForEachKey, objFreeze, objHasOwn, scheduleTimeout, throwError } from "@nevware21/ts-utils"; -import { cfgDfMerge } from "../Config/ConfigDefaultHelpers"; -import { createDynamicConfig, onConfigChange } from "../Config/DynamicConfig"; -import { IConfigDefaults } from "../Config/IConfigDefaults"; -import { IDynamicConfigHandler, _IInternalDynamicConfigHandler } from "../Config/IDynamicConfigHandler"; -import { IWatchDetails, WatcherFunction } from "../Config/IDynamicWatcher"; -import { eEventsDiscardedReason } from "../JavaScriptSDK.Enums/EventsDiscardedReason"; -import { ActiveStatus, eActiveStatus } from "../JavaScriptSDK.Enums/InitActiveStatusEnum"; -import { _eInternalMessageId, eLoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums"; -import { SendRequestReason } from "../JavaScriptSDK.Enums/SendRequestReason"; -import { TelemetryUnloadReason } from "../JavaScriptSDK.Enums/TelemetryUnloadReason"; -import { TelemetryUpdateReason } from "../JavaScriptSDK.Enums/TelemetryUpdateReason"; -import { eTraceHeadersMode } from "../JavaScriptSDK.Enums/TraceHeadersMode"; -import { IAppInsightsCore, ILoadedPlugin } from "../JavaScriptSDK.Interfaces/IAppInsightsCore"; -import { IChannelControls } from "../JavaScriptSDK.Interfaces/IChannelControls"; -import { IChannelControlsHost } from "../JavaScriptSDK.Interfaces/IChannelControlsHost"; -import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration"; -import { ICookieMgr } from "../JavaScriptSDK.Interfaces/ICookieMgr"; -import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger"; -import { IDistributedTraceContext } from "../JavaScriptSDK.Interfaces/IDistributedTraceContext"; -import { INotificationListener } from "../JavaScriptSDK.Interfaces/INotificationListener"; -import { INotificationManager } from "../JavaScriptSDK.Interfaces/INotificationManager"; -import { IPerfManager } from "../JavaScriptSDK.Interfaces/IPerfManager"; -import { IProcessTelemetryContext, IProcessTelemetryUpdateContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext"; -import { ITelemetryInitializerHandler, TelemetryInitializerFunction } from "../JavaScriptSDK.Interfaces/ITelemetryInitializers"; -import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem"; -import { IPlugin, ITelemetryPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin"; -import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPluginChain"; -import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState"; -import { ITelemetryUpdateState } from "../JavaScriptSDK.Interfaces/ITelemetryUpdateState"; -import { ITraceProvider } from "../JavaScriptSDK.Interfaces/ITraceProvider"; -import { ILegacyUnloadHook, IUnloadHook } from "../JavaScriptSDK.Interfaces/IUnloadHook"; -import { ITraceCfg } from "../OpenTelemetry/interfaces/config/ITraceCfg"; -import { IOTelSpanOptions } from "../OpenTelemetry/interfaces/trace/IOTelSpanOptions"; -import { IReadableSpan } from "../OpenTelemetry/interfaces/trace/IReadableSpan"; -import { ISpanScope } from "../applicationinsights-core-js"; +import { cfgDfMerge } from "../config/ConfigDefaultHelpers"; +import { createDynamicConfig, onConfigChange } from "../config/DynamicConfig"; +import { ChannelControllerPriority } from "../constants/Constants"; +import { + STR_CHANNELS, STR_CREATE_PERF_MGR, STR_DISABLED, STR_EMPTY, STR_EXTENSIONS, STR_EXTENSION_CONFIG, UNDEFINED_VALUE +} from "../constants/InternalConstants"; +import { DiagnosticLogger, _InternalLogMessage, _throwInternal, _warnToConsole } from "../diagnostics/DiagnosticLogger"; +import { eEventsDiscardedReason } from "../enums/ai/EventsDiscardedReason"; +import { ActiveStatus, eActiveStatus } from "../enums/ai/InitActiveStatusEnum"; +import { _eInternalMessageId, eLoggingSeverity } from "../enums/ai/LoggingEnums"; +import { SendRequestReason } from "../enums/ai/SendRequestReason"; +import { TelemetryUnloadReason } from "../enums/ai/TelemetryUnloadReason"; +import { TelemetryUpdateReason } from "../enums/ai/TelemetryUpdateReason"; +import { eTraceHeadersMode } from "../enums/ai/TraceHeadersMode"; +import { IAppInsightsCore, ILoadedPlugin } from "../interfaces/ai/IAppInsightsCore"; +import { IChannelControls } from "../interfaces/ai/IChannelControls"; +import { IChannelControlsHost } from "../interfaces/ai/IChannelControlsHost"; +import { IConfiguration } from "../interfaces/ai/IConfiguration"; +import { ICookieMgr } from "../interfaces/ai/ICookieMgr"; +import { IDiagnosticLogger } from "../interfaces/ai/IDiagnosticLogger"; +import { IDistributedTraceContext } from "../interfaces/ai/IDistributedTraceContext"; +import { INotificationListener } from "../interfaces/ai/INotificationListener"; +import { INotificationManager } from "../interfaces/ai/INotificationManager"; +import { IPerfManager } from "../interfaces/ai/IPerfManager"; +import { IProcessTelemetryContext, IProcessTelemetryUpdateContext } from "../interfaces/ai/IProcessTelemetryContext"; +import { ITelemetryInitializerHandler, TelemetryInitializerFunction } from "../interfaces/ai/ITelemetryInitializers"; +import { ITelemetryItem } from "../interfaces/ai/ITelemetryItem"; +import { IPlugin, ITelemetryPlugin } from "../interfaces/ai/ITelemetryPlugin"; +import { ITelemetryPluginChain } from "../interfaces/ai/ITelemetryPluginChain"; +import { ITelemetryUnloadState } from "../interfaces/ai/ITelemetryUnloadState"; +import { ITelemetryUpdateState } from "../interfaces/ai/ITelemetryUpdateState"; +import { ISpanScope, ITraceProvider } from "../interfaces/ai/ITraceProvider"; +import { ILegacyUnloadHook, IUnloadHook } from "../interfaces/ai/IUnloadHook"; +import { IConfigDefaults } from "../interfaces/config/IConfigDefaults"; +import { IDynamicConfigHandler, _IInternalDynamicConfigHandler } from "../interfaces/config/IDynamicConfigHandler"; +import { IWatchDetails, WatcherFunction } from "../interfaces/config/IDynamicWatcher"; +import { ITraceCfg } from "../interfaces/otel/config/IOTelTraceCfg"; +import { IOTelSpanOptions } from "../interfaces/otel/trace/IOTelSpanOptions"; +import { IReadableSpan } from "../interfaces/otel/trace/IReadableSpan"; +import { findW3cTraceState } from "../telemetry/W3cTraceState"; +import { createUniqueNamespace } from "../utils/DataCacheHelper"; +import { getSetValue, isNotNullOrUndefined, proxyFunctionAs, proxyFunctions, toISOString } from "../utils/HelperFuncs"; +import { findW3cTraceParent } from "../utils/TraceParent"; import { doUnloadAll, runTargetUnload } from "./AsyncUtils"; -import { ChannelControllerPriority } from "./Constants"; import { createCookieMgr } from "./CookieMgr"; -import { createUniqueNamespace } from "./DataCacheHelper"; import { getDebugListener } from "./DbgExtensionUtils"; -import { DiagnosticLogger, _InternalLogMessage, _throwInternal, _warnToConsole } from "./DiagnosticLogger"; -import { getSetValue, isNotNullOrUndefined, proxyFunctionAs, proxyFunctions, toISOString } from "./HelperFuncs"; -import { - STR_CHANNELS, STR_CREATE_PERF_MGR, STR_DISABLED, STR_EMPTY, STR_EXTENSIONS, STR_EXTENSION_CONFIG, UNDEFINED_VALUE -} from "./InternalConstants"; import { NotificationManager } from "./NotificationManager"; import { PerfManager, doPerf, getGblPerfMgr } from "./PerfManager"; import { @@ -63,11 +64,9 @@ import { import { TelemetryInitializerPlugin } from "./TelemetryInitializerPlugin"; import { IUnloadHandlerContainer, UnloadHandler, createUnloadHandlerContainer } from "./UnloadHandlerContainer"; import { IUnloadHookContainer, createUnloadHookContainer } from "./UnloadHookContainer"; -import { findW3cTraceParent } from "./W3cTraceParent"; -import { findW3cTraceState } from "./W3cTraceState"; -// import { IStatsBeat, IStatsBeatConfig, IStatsBeatState } from "../JavaScriptSDK.Interfaces/IStatsBeat"; -// import { IStatsMgr } from "../JavaScriptSDK.Interfaces/IStatsMgr"; +// import { IStatsBeat, IStatsBeatConfig, IStatsBeatState } from "../interfaces/ai/IStatsBeat"; +// import { IStatsMgr } from "../interfaces/ai/IStatsMgr"; const strValidationError = "Plugins must provide initialize method"; const strNotificationManager = "_notificationManager"; const strSdkUnloadingError = "SDK is still unloading..."; @@ -166,10 +165,12 @@ function _getDefaultConfig(core: IAppInsightsCore): IConfigDefaults, target: any, n } } +/*#__NO_SIDE_EFFECTS__*/ function _findWatcher(listeners: { rm: () => void, w: WatcherFunction}[], newWatcher: WatcherFunction) { let theListener: { rm: () => void, w: WatcherFunction} = null; let idx: number = -1; @@ -314,6 +317,7 @@ function _initDebugListener(configHandler: IDynamicConfigHandler } // Moved this outside of the closure to reduce the retained memory footprint +/*#__NO_SIDE_EFFECTS__*/ function _createUnloadHook(unloadHook: IUnloadHook): IUnloadHook { return objDefine({ rm: () => { @@ -322,6 +326,7 @@ function _createUnloadHook(unloadHook: IUnloadHook): IUnloadHook { }, "toJSON", { v: () => "aicore::onCfgChange<" + JSON.stringify(unloadHook) + ">" }); } +/*#__NO_SIDE_EFFECTS__*/ function _getParentTraceCtx(mode: eTraceHeadersMode): IDistributedTraceContext | null { let spanContext: IDistributedTraceContext | null = null; const parentTrace = (mode & eTraceHeadersMode.TraceParent) ? findW3cTraceParent() : null; @@ -340,6 +345,7 @@ function _getParentTraceCtx(mode: eTraceHeadersMode): IDistributedTraceContext | return spanContext; } +/*#__NO_SIDE_EFFECTS__*/ function _noOpFunc() { // No-op function } diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/AsyncUtils.ts b/shared/AppInsightsCore/src/core/AsyncUtils.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK/AsyncUtils.ts rename to shared/AppInsightsCore/src/core/AsyncUtils.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/BaseTelemetryPlugin.ts b/shared/AppInsightsCore/src/core/BaseTelemetryPlugin.ts similarity index 92% rename from shared/AppInsightsCore/src/JavaScriptSDK/BaseTelemetryPlugin.ts rename to shared/AppInsightsCore/src/core/BaseTelemetryPlugin.ts index f13197054..73ae606ae 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK/BaseTelemetryPlugin.ts +++ b/shared/AppInsightsCore/src/core/BaseTelemetryPlugin.ts @@ -4,25 +4,25 @@ import dynamicProto from "@microsoft/dynamicproto-js"; import { isFunction, objDefine } from "@nevware21/ts-utils"; -import { createDynamicConfig } from "../Config/DynamicConfig"; -import { IConfigDefaults } from "../Config/IConfigDefaults"; -import { TelemetryUnloadReason } from "../JavaScriptSDK.Enums/TelemetryUnloadReason"; -import { TelemetryUpdateReason } from "../JavaScriptSDK.Enums/TelemetryUpdateReason"; -import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore"; -import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration"; -import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger"; +import { createDynamicConfig } from "../config/DynamicConfig"; +import { STR_EXTENSION_CONFIG } from "../constants/InternalConstants"; +import { safeGetLogger } from "../diagnostics/DiagnosticLogger"; +import { TelemetryUnloadReason } from "../enums/ai/TelemetryUnloadReason"; +import { TelemetryUpdateReason } from "../enums/ai/TelemetryUpdateReason"; +import { IAppInsightsCore } from "../interfaces/ai/IAppInsightsCore"; +import { IConfiguration } from "../interfaces/ai/IConfiguration"; +import { IDiagnosticLogger } from "../interfaces/ai/IDiagnosticLogger"; import { IProcessTelemetryContext, IProcessTelemetryUnloadContext, IProcessTelemetryUpdateContext -} from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext"; -import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem"; -import { IPlugin, ITelemetryPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin"; -import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPluginChain"; -import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState"; -import { ITelemetryUpdateState } from "../JavaScriptSDK.Interfaces/ITelemetryUpdateState"; -import { ILegacyUnloadHook, IUnloadHook } from "../JavaScriptSDK.Interfaces/IUnloadHook"; -import { safeGetLogger } from "./DiagnosticLogger"; -import { isNotNullOrUndefined, proxyFunctionAs } from "./HelperFuncs"; -import { STR_EXTENSION_CONFIG } from "./InternalConstants"; +} from "../interfaces/ai/IProcessTelemetryContext"; +import { ITelemetryItem } from "../interfaces/ai/ITelemetryItem"; +import { IPlugin, ITelemetryPlugin } from "../interfaces/ai/ITelemetryPlugin"; +import { ITelemetryPluginChain } from "../interfaces/ai/ITelemetryPluginChain"; +import { ITelemetryUnloadState } from "../interfaces/ai/ITelemetryUnloadState"; +import { ITelemetryUpdateState } from "../interfaces/ai/ITelemetryUpdateState"; +import { ILegacyUnloadHook, IUnloadHook } from "../interfaces/ai/IUnloadHook"; +import { IConfigDefaults } from "../interfaces/config/IConfigDefaults"; +import { isNotNullOrUndefined, proxyFunctionAs } from "../utils/HelperFuncs"; import { createProcessTelemetryContext, createProcessTelemetryUnloadContext, createProcessTelemetryUpdateContext } from "./ProcessTelemetryContext"; diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/CookieMgr.ts b/shared/AppInsightsCore/src/core/CookieMgr.ts similarity index 95% rename from shared/AppInsightsCore/src/JavaScriptSDK/CookieMgr.ts rename to shared/AppInsightsCore/src/core/CookieMgr.ts index b5f057723..8f8915490 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK/CookieMgr.ts +++ b/shared/AppInsightsCore/src/core/CookieMgr.ts @@ -2,22 +2,22 @@ // Licensed under the MIT License. import { IPromise } from "@nevware21/ts-async"; import { - ILazyValue, arrForEach, arrIndexOf, dumpObj, getDocument, getLazy, getNavigator, isArray, isFunction, isNullOrUndefined, isString, - isTruthy, isUndefined, objForEachKey, strEndsWith, strIndexOf, strLeft, strSubstring, strTrim, utcNow + ILazyValue, arrForEach, arrIndexOf, dumpObj, getDocument, getLazy, isArray, isFunction, isNullOrUndefined, isString, isTruthy, + isUndefined, objForEachKey, strEndsWith, strIndexOf, strLeft, strSubstring, strTrim, utcNow } from "@nevware21/ts-utils"; -import { cfgDfMerge } from "../Config/ConfigDefaultHelpers"; -import { createDynamicConfig, onConfigChange } from "../Config/DynamicConfig"; -import { IConfigDefaults } from "../Config/IConfigDefaults"; -import { _eInternalMessageId, eLoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums"; -import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore"; -import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration"; -import { ICookieMgr, ICookieMgrConfig } from "../JavaScriptSDK.Interfaces/ICookieMgr"; -import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger"; -import { IUnloadHook } from "../JavaScriptSDK.Interfaces/IUnloadHook"; -import { _throwInternal } from "./DiagnosticLogger"; -import { getLocation, isIE } from "./EnvUtils"; -import { getExceptionName, isNotNullOrUndefined, setValue, strContains } from "./HelperFuncs"; -import { STR_DOMAIN, STR_EMPTY, STR_PATH, UNDEFINED_VALUE } from "./InternalConstants"; +import { cfgDfMerge } from "../config/ConfigDefaultHelpers"; +import { createDynamicConfig, onConfigChange } from "../config/DynamicConfig"; +import { STR_DOMAIN, STR_EMPTY, STR_PATH, UNDEFINED_VALUE } from "../constants/InternalConstants"; +import { _throwInternal } from "../diagnostics/DiagnosticLogger"; +import { _eInternalMessageId, eLoggingSeverity } from "../enums/ai/LoggingEnums"; +import { IAppInsightsCore } from "../interfaces/ai/IAppInsightsCore"; +import { IConfiguration } from "../interfaces/ai/IConfiguration"; +import { ICookieMgr, ICookieMgrConfig } from "../interfaces/ai/ICookieMgr"; +import { IDiagnosticLogger } from "../interfaces/ai/IDiagnosticLogger"; +import { IUnloadHook } from "../interfaces/ai/IUnloadHook"; +import { IConfigDefaults } from "../interfaces/config/IConfigDefaults"; +import { getLocation, getUserAgentString, isIE } from "../utils/EnvUtils"; +import { getExceptionName, isNotNullOrUndefined, setValue, strContains } from "../utils/HelperFuncs"; const strToGMTString = "toGMTString"; const strToUTCString = "toUTCString"; @@ -242,7 +242,7 @@ export function createCookieMgr(rootConfig?: IConfiguration, logger?: IDiagnosti // Only set same site if not also secure if (_allowUaSameSite === null) { - _allowUaSameSite = !uaDisallowsSameSiteNone((getNavigator() || {} as Navigator).userAgent); + _allowUaSameSite = !uaDisallowsSameSiteNone(getUserAgentString()); } if (_allowUaSameSite) { diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/DbgExtensionUtils.ts b/shared/AppInsightsCore/src/core/DbgExtensionUtils.ts similarity index 84% rename from shared/AppInsightsCore/src/JavaScriptSDK/DbgExtensionUtils.ts rename to shared/AppInsightsCore/src/core/DbgExtensionUtils.ts index e900b32ea..e3de89323 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK/DbgExtensionUtils.ts +++ b/shared/AppInsightsCore/src/core/DbgExtensionUtils.ts @@ -2,10 +2,10 @@ // Licensed under the MIT License. import { getInst } from "@nevware21/ts-utils"; -import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration"; -import { IDbgExtension } from "../JavaScriptSDK.Interfaces/IDbgExtension"; -import { INotificationListener } from "../JavaScriptSDK.Interfaces/INotificationListener"; -import { STR_EVENTS_DISCARDED, STR_EVENTS_SEND_REQUEST, STR_EVENTS_SENT, STR_PERF_EVENT } from "./InternalConstants"; +import { STR_EVENTS_DISCARDED, STR_EVENTS_SEND_REQUEST, STR_EVENTS_SENT, STR_PERF_EVENT } from "../constants/InternalConstants"; +import { IConfiguration } from "../interfaces/ai/IConfiguration"; +import { IDbgExtension } from "../interfaces/ai/IDbgExtension"; +import { INotificationListener } from "../interfaces/ai/INotificationListener"; const listenerFuncs = [ STR_EVENTS_SENT, STR_EVENTS_DISCARDED, STR_EVENTS_SEND_REQUEST, STR_PERF_EVENT ]; diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/InstrumentHooks.ts b/shared/AppInsightsCore/src/core/InstrumentHooks.ts similarity index 99% rename from shared/AppInsightsCore/src/JavaScriptSDK/InstrumentHooks.ts rename to shared/AppInsightsCore/src/core/InstrumentHooks.ts index ee050b64f..a14fcbde7 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK/InstrumentHooks.ts +++ b/shared/AppInsightsCore/src/core/InstrumentHooks.ts @@ -5,8 +5,8 @@ import { strShimFunction, strShimPrototype } from "@microsoft/applicationinsight import { getInst, objHasOwnProperty } from "@nevware21/ts-utils"; import { IInstrumentCallDetails, IInstrumentHook, IInstrumentHooks, IInstrumentHooksCallbacks, InstrumentorHooksCallback -} from "../JavaScriptSDK.Interfaces/IInstrumentHooks"; -import { _getObjProto } from "./HelperFuncs"; +} from "../interfaces/ai/IInstrumentHooks"; +import { _getObjProto } from "../utils/HelperFuncs"; const aiInstrumentHooks = "_aiHooks"; diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/NotificationManager.ts b/shared/AppInsightsCore/src/core/NotificationManager.ts similarity index 95% rename from shared/AppInsightsCore/src/JavaScriptSDK/NotificationManager.ts rename to shared/AppInsightsCore/src/core/NotificationManager.ts index dba9e53ce..d2a2834a5 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK/NotificationManager.ts +++ b/shared/AppInsightsCore/src/core/NotificationManager.ts @@ -3,16 +3,17 @@ import dynamicProto from "@microsoft/dynamicproto-js"; import { IPromise, createAllPromise, createPromise, doAwaitResponse } from "@nevware21/ts-async"; import { ITimerHandler, arrForEach, arrIndexOf, objDefine, safe, scheduleTimeout } from "@nevware21/ts-utils"; -import { createDynamicConfig } from "../Config/DynamicConfig"; -import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration"; -import { INotificationListener } from "../JavaScriptSDK.Interfaces/INotificationListener"; -import { INotificationManager } from "../JavaScriptSDK.Interfaces/INotificationManager"; -import { IPerfEvent } from "../JavaScriptSDK.Interfaces/IPerfEvent"; -import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem"; -import { IPayloadData, IUnloadHook } from "../applicationinsights-core-js"; +import { createDynamicConfig } from "../config/DynamicConfig"; import { STR_EVENTS_DISCARDED, STR_EVENTS_SEND_REQUEST, STR_EVENTS_SENT, STR_OFFLINE_DROP, STR_OFFLINE_SENT, STR_OFFLINE_STORE, STR_PERF_EVENT -} from "./InternalConstants"; +} from "../constants/InternalConstants"; +import { IConfiguration } from "../interfaces/ai/IConfiguration"; +import { INotificationListener } from "../interfaces/ai/INotificationListener"; +import { INotificationManager } from "../interfaces/ai/INotificationManager"; +import { IPerfEvent } from "../interfaces/ai/IPerfEvent"; +import { ITelemetryItem } from "../interfaces/ai/ITelemetryItem"; +import { IUnloadHook } from "../interfaces/ai/IUnloadHook"; +import { IPayloadData } from "../interfaces/ai/IXHROverride"; const defaultValues = { perfEvtsSendAll: false diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/PerfManager.ts b/shared/AppInsightsCore/src/core/PerfManager.ts similarity index 96% rename from shared/AppInsightsCore/src/JavaScriptSDK/PerfManager.ts rename to shared/AppInsightsCore/src/core/PerfManager.ts index 19e43a795..a934dd86f 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK/PerfManager.ts +++ b/shared/AppInsightsCore/src/core/PerfManager.ts @@ -2,11 +2,11 @@ // Licensed under the MIT License. import dynamicProto from "@microsoft/dynamicproto-js"; import { isArray, isFunction, objDefine, utcNow } from "@nevware21/ts-utils"; -import { INotificationManager } from "../JavaScriptSDK.Interfaces/INotificationManager"; -import { IPerfEvent } from "../JavaScriptSDK.Interfaces/IPerfEvent"; -import { IPerfManager, IPerfManagerProvider } from "../JavaScriptSDK.Interfaces/IPerfManager"; -import { _noopVoid } from "../OpenTelemetry/noop/noopHelpers"; -import { STR_GET_PERF_MGR } from "./InternalConstants"; +import { STR_GET_PERF_MGR } from "../constants/InternalConstants"; +import { INotificationManager } from "../interfaces/ai/INotificationManager"; +import { IPerfEvent } from "../interfaces/ai/IPerfEvent"; +import { IPerfManager, IPerfManagerProvider } from "../interfaces/ai/IPerfManager"; +import { _noopVoid } from "../internal/noopHelpers"; const strExecutionContextKey = "ctx"; const strParentContextKey = "ParentContextKey"; diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/ProcessTelemetryContext.ts b/shared/AppInsightsCore/src/core/ProcessTelemetryContext.ts similarity index 95% rename from shared/AppInsightsCore/src/JavaScriptSDK/ProcessTelemetryContext.ts rename to shared/AppInsightsCore/src/core/ProcessTelemetryContext.ts index 2a1bd9cec..2a1b8f38e 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK/ProcessTelemetryContext.ts +++ b/shared/AppInsightsCore/src/core/ProcessTelemetryContext.ts @@ -3,24 +3,24 @@ "use strict"; import { arrForEach, dumpObj, isArray, isFunction, isNullOrUndefined, isUndefined, objForEachKey, objFreeze } from "@nevware21/ts-utils"; -import { _applyDefaultValue } from "../Config/ConfigDefaults"; -import { createDynamicConfig } from "../Config/DynamicConfig"; -import { IConfigDefaults } from "../Config/IConfigDefaults"; -import { IDynamicConfigHandler } from "../Config/IDynamicConfigHandler"; -import { _eInternalMessageId, eLoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums"; -import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore"; -import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration"; +import { _applyDefaultValue } from "../config/ConfigDefaults"; +import { createDynamicConfig } from "../config/DynamicConfig"; +import { STR_CORE, STR_DISABLED, STR_EMPTY } from "../constants/InternalConstants"; +import { _throwInternal, safeGetLogger } from "../diagnostics/DiagnosticLogger"; +import { _eInternalMessageId, eLoggingSeverity } from "../enums/ai/LoggingEnums"; +import { IAppInsightsCore } from "../interfaces/ai/IAppInsightsCore"; +import { IConfiguration } from "../interfaces/ai/IConfiguration"; import { IBaseProcessingContext, IProcessTelemetryContext, IProcessTelemetryUnloadContext, IProcessTelemetryUpdateContext -} from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext"; -import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem"; -import { IPlugin, ITelemetryPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin"; -import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPluginChain"; -import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState"; -import { ITelemetryUpdateState } from "../JavaScriptSDK.Interfaces/ITelemetryUpdateState"; -import { _noopVoid } from "../OpenTelemetry/noop/noopHelpers"; -import { _throwInternal, safeGetLogger } from "./DiagnosticLogger"; -import { STR_CORE, STR_DISABLED, STR_EMPTY } from "./InternalConstants"; +} from "../interfaces/ai/IProcessTelemetryContext"; +import { ITelemetryItem } from "../interfaces/ai/ITelemetryItem"; +import { IPlugin, ITelemetryPlugin } from "../interfaces/ai/ITelemetryPlugin"; +import { ITelemetryPluginChain } from "../interfaces/ai/ITelemetryPluginChain"; +import { ITelemetryUnloadState } from "../interfaces/ai/ITelemetryUnloadState"; +import { ITelemetryUpdateState } from "../interfaces/ai/ITelemetryUpdateState"; +import { IConfigDefaults } from "../interfaces/config/IConfigDefaults"; +import { IDynamicConfigHandler } from "../interfaces/config/IDynamicConfigHandler"; +import { _noopVoid } from "../internal/noopHelpers"; import { doPerf } from "./PerfManager"; import { _getPluginState } from "./TelemetryHelpers"; diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/ResponseHelpers.ts b/shared/AppInsightsCore/src/core/ResponseHelpers.ts similarity index 74% rename from shared/AppInsightsCore/src/JavaScriptSDK/ResponseHelpers.ts rename to shared/AppInsightsCore/src/core/ResponseHelpers.ts index 46190deda..f645124ac 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK/ResponseHelpers.ts +++ b/shared/AppInsightsCore/src/core/ResponseHelpers.ts @@ -2,11 +2,11 @@ // Licensed under the MIT License. import { dumpObj } from "@nevware21/ts-utils"; -import { _eInternalMessageId, eLoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums"; -import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger"; -import { IBackendResponse } from "../JavaScriptSDK.Interfaces/IXDomainRequest"; -import { _throwInternal } from "./DiagnosticLogger"; -import { getJSON } from "./EnvUtils"; +import { _throwInternal } from "../diagnostics/DiagnosticLogger"; +import { _eInternalMessageId, eLoggingSeverity } from "../enums/ai/LoggingEnums"; +import { IDiagnosticLogger } from "../interfaces/ai/IDiagnosticLogger"; +import { IBackendResponse } from "../interfaces/ai/IXDomainRequest"; +import { getJSON } from "../utils/EnvUtils"; /** * Parses the response from the backend. diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/SenderPostManager.ts b/shared/AppInsightsCore/src/core/SenderPostManager.ts similarity index 97% rename from shared/AppInsightsCore/src/JavaScriptSDK/SenderPostManager.ts rename to shared/AppInsightsCore/src/core/SenderPostManager.ts index 1a619423c..01538fb83 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK/SenderPostManager.ts +++ b/shared/AppInsightsCore/src/core/SenderPostManager.ts @@ -4,21 +4,21 @@ import dynamicProto from "@microsoft/dynamicproto-js"; import { AwaitResponse, IPromise, createPromise, doAwaitResponse } from "@nevware21/ts-async"; import { arrForEach, dumpObj, getInst, getNavigator, getWindow, isFunction, isString, objKeys } from "@nevware21/ts-utils"; -import { _eInternalMessageId, eLoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums"; -import { SendRequestReason, TransportType } from "../JavaScriptSDK.Enums/SendRequestReason"; -import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger"; -import { IProcessTelemetryUnloadContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext"; +import { DisabledPropertyName } from "../constants/Constants"; +import { _throwInternal, _warnToConsole } from "../diagnostics/DiagnosticLogger"; +import { _eInternalMessageId, eLoggingSeverity } from "../enums/ai/LoggingEnums"; +import { SendRequestReason, TransportType } from "../enums/ai/SendRequestReason"; +import { IDiagnosticLogger } from "../interfaces/ai/IDiagnosticLogger"; +import { IProcessTelemetryUnloadContext } from "../interfaces/ai/IProcessTelemetryContext"; import { _IInternalXhrOverride, _ISendPostMgrConfig, _ISenderOnComplete, _ITimeoutOverrideWrapper -} from "../JavaScriptSDK.Interfaces/ISenderPostManager"; -import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState"; -import { IXDomainRequest } from "../JavaScriptSDK.Interfaces/IXDomainRequest"; -import { IPayloadData, IXHROverride, OnCompleteCallback, SendPOSTFunction } from "../JavaScriptSDK.Interfaces/IXHROverride"; -import { _noopVoid } from "../OpenTelemetry/noop/noopHelpers"; -import { DisabledPropertyName } from "./Constants"; -import { _throwInternal, _warnToConsole } from "./DiagnosticLogger"; -import { getLocation, isBeaconsSupported, isFetchSupported, isXhrSupported, useXDomainRequest } from "./EnvUtils"; -import { _getAllResponseHeaders, formatErrorMessageXdr, formatErrorMessageXhr, getResponseText, openXhr } from "./HelperFuncs"; +} from "../interfaces/ai/ISenderPostManager"; +import { ITelemetryUnloadState } from "../interfaces/ai/ITelemetryUnloadState"; +import { IXDomainRequest } from "../interfaces/ai/IXDomainRequest"; +import { IPayloadData, IXHROverride, OnCompleteCallback, SendPOSTFunction } from "../interfaces/ai/IXHROverride"; +import { _noopVoid } from "../internal/noopHelpers"; +import { getLocation, isBeaconsSupported, isFetchSupported, isXhrSupported, useXDomainRequest } from "../utils/EnvUtils"; +import { _getAllResponseHeaders, formatErrorMessageXdr, formatErrorMessageXhr, getResponseText, openXhr } from "../utils/HelperFuncs"; const STR_EMPTY = ""; const STR_NO_RESPONSE_BODY = "NoResponseBody"; diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/StatsBeat.ts b/shared/AppInsightsCore/src/core/StatsBeat.ts similarity index 94% rename from shared/AppInsightsCore/src/JavaScriptSDK/StatsBeat.ts rename to shared/AppInsightsCore/src/core/StatsBeat.ts index 1834903dc..ef0578302 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK/StatsBeat.ts +++ b/shared/AppInsightsCore/src/core/StatsBeat.ts @@ -4,19 +4,19 @@ import { ITimerHandler, arrForEach, isNumber, makeGlobRegex, objDefineProps, scheduleTimeout, strIndexOf, strLower, utcNow } from "@nevware21/ts-utils"; -import { onConfigChange } from "../Config/DynamicConfig"; -import { _eInternalMessageId, eLoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums"; -import { eStatsType } from "../JavaScriptSDK.Enums/StatsType"; -import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore"; -import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration"; -import { INetworkStatsbeat } from "../JavaScriptSDK.Interfaces/INetworkStatsbeat"; -import { IStatsBeat, IStatsBeatConfig, IStatsBeatState, IStatsEndpointConfig } from "../JavaScriptSDK.Interfaces/IStatsBeat"; -import { IStatsMgr, IStatsMgrConfig } from "../JavaScriptSDK.Interfaces/IStatsMgr"; -import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem"; -import { IPayloadData } from "../JavaScriptSDK.Interfaces/IXHROverride"; -import { _throwInternal, safeGetLogger } from "./DiagnosticLogger"; -import { isFeatureEnabled } from "./HelperFuncs"; -import { STR_EMPTY } from "./InternalConstants"; +import { onConfigChange } from "../config/DynamicConfig"; +import { STR_EMPTY } from "../constants/InternalConstants"; +import { _throwInternal, safeGetLogger } from "../diagnostics/DiagnosticLogger"; +import { _eInternalMessageId, eLoggingSeverity } from "../enums/ai/LoggingEnums"; +import { eStatsType } from "../enums/ai/StatsType"; +import { IAppInsightsCore } from "../interfaces/ai/IAppInsightsCore"; +import { IConfiguration } from "../interfaces/ai/IConfiguration"; +import { INetworkStatsbeat } from "../interfaces/ai/INetworkStatsbeat"; +import { IStatsBeat, IStatsBeatConfig, IStatsBeatState, IStatsEndpointConfig } from "../interfaces/ai/IStatsBeat"; +import { IStatsMgr, IStatsMgrConfig } from "../interfaces/ai/IStatsMgr"; +import { ITelemetryItem } from "../interfaces/ai/ITelemetryItem"; +import { IPayloadData } from "../interfaces/ai/IXHROverride"; +import { isFeatureEnabled } from "../utils/HelperFuncs"; const STATS_COLLECTION_SHORT_INTERVAL: number = 900000; // 15 minutes const STATS_MIN_INTERVAL_SECONDS = 60; // 1 minute diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/TelemetryHelpers.ts b/shared/AppInsightsCore/src/core/TelemetryHelpers.ts similarity index 91% rename from shared/AppInsightsCore/src/JavaScriptSDK/TelemetryHelpers.ts rename to shared/AppInsightsCore/src/core/TelemetryHelpers.ts index 7d1383bbb..7b6c43166 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK/TelemetryHelpers.ts +++ b/shared/AppInsightsCore/src/core/TelemetryHelpers.ts @@ -2,21 +2,21 @@ // Licensed under the MIT License. import { arrForEach, isFunction, objDefineProps } from "@nevware21/ts-utils"; -import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore"; -import { IDistributedTraceContext, IDistributedTraceInit } from "../JavaScriptSDK.Interfaces/IDistributedTraceContext"; -import { IProcessTelemetryContext, IProcessTelemetryUnloadContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext"; -import { IPlugin, ITelemetryPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin"; -import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPluginChain"; -import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState"; -import { IUnloadableComponent } from "../JavaScriptSDK.Interfaces/IUnloadableComponent"; -import { IW3cTraceState } from "../JavaScriptSDK.Interfaces/IW3cTraceState"; -import { generateW3CId } from "./CoreUtils"; -import { createElmNodeData } from "./DataCacheHelper"; -import { getLocation } from "./EnvUtils"; -import { setProtoTypeName } from "./HelperFuncs"; -import { STR_CORE, STR_EMPTY, STR_PRIORITY, STR_PROCESS_TELEMETRY, UNDEFINED_VALUE } from "./InternalConstants"; -import { isValidSpanId, isValidTraceId } from "./W3cTraceParent"; -import { createW3cTraceState } from "./W3cTraceState"; +import { STR_CORE, STR_EMPTY, STR_PRIORITY, STR_PROCESS_TELEMETRY, UNDEFINED_VALUE } from "../constants/InternalConstants"; +import { IAppInsightsCore } from "../interfaces/ai/IAppInsightsCore"; +import { IDistributedTraceContext, IDistributedTraceInit } from "../interfaces/ai/IDistributedTraceContext"; +import { IProcessTelemetryContext, IProcessTelemetryUnloadContext } from "../interfaces/ai/IProcessTelemetryContext"; +import { IPlugin, ITelemetryPlugin } from "../interfaces/ai/ITelemetryPlugin"; +import { ITelemetryPluginChain } from "../interfaces/ai/ITelemetryPluginChain"; +import { ITelemetryUnloadState } from "../interfaces/ai/ITelemetryUnloadState"; +import { IUnloadableComponent } from "../interfaces/ai/IUnloadableComponent"; +import { IW3cTraceState } from "../interfaces/ai/IW3cTraceState"; +import { createW3cTraceState } from "../telemetry/W3cTraceState"; +import { generateW3CId } from "../utils/CoreUtils"; +import { createElmNodeData } from "../utils/DataCacheHelper"; +import { getLocation } from "../utils/EnvUtils"; +import { setProtoTypeName } from "../utils/HelperFuncs"; +import { isValidSpanId, isValidTraceId } from "../utils/TraceParent"; export interface IPluginState { core?: IAppInsightsCore; @@ -141,6 +141,7 @@ export function unloadComponents(components: any | IUnloadableComponent[], unloa return _doUnload(); } +/*#__NO_SIDE_EFFECTS__*/ export function isDistributedTraceContext(obj: any): obj is IDistributedTraceContext { return obj && isFunction(obj.getName) && @@ -175,6 +176,7 @@ export function isDistributedTraceContext(obj: any): obj is IDistributedTraceCon * specific span is created, which is normal behavior for trace contexts. * */ +/*#__NO_SIDE_EFFECTS__*/ export function createDistributedTraceContext(parent?: IDistributedTraceContext | IDistributedTraceInit | undefined | null): IDistributedTraceContext { let parentCtx: IDistributedTraceContext = null; let initCtx: IDistributedTraceInit = null; diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/TelemetryInitializerPlugin.ts b/shared/AppInsightsCore/src/core/TelemetryInitializerPlugin.ts similarity index 89% rename from shared/AppInsightsCore/src/JavaScriptSDK/TelemetryInitializerPlugin.ts rename to shared/AppInsightsCore/src/core/TelemetryInitializerPlugin.ts index 5001682f4..d40df7182 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK/TelemetryInitializerPlugin.ts +++ b/shared/AppInsightsCore/src/core/TelemetryInitializerPlugin.ts @@ -3,16 +3,16 @@ import dynamicProto from "@microsoft/dynamicproto-js"; import { arrAppend, arrForEach, dumpObj } from "@nevware21/ts-utils"; -import { _eInternalMessageId, eLoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums"; -import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger"; -import { IProcessTelemetryContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext"; +import { _throwInternal } from "../diagnostics/DiagnosticLogger"; +import { _eInternalMessageId, eLoggingSeverity } from "../enums/ai/LoggingEnums"; +import { IDiagnosticLogger } from "../interfaces/ai/IDiagnosticLogger"; +import { IProcessTelemetryContext } from "../interfaces/ai/IProcessTelemetryContext"; import { ITelemetryInitializerContainer, ITelemetryInitializerHandler, TelemetryInitializerFunction -} from "../JavaScriptSDK.Interfaces/ITelemetryInitializers"; -import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem"; +} from "../interfaces/ai/ITelemetryInitializers"; +import { ITelemetryItem } from "../interfaces/ai/ITelemetryItem"; +import { getExceptionName } from "../utils/HelperFuncs"; import { BaseTelemetryPlugin } from "./BaseTelemetryPlugin"; -import { _throwInternal } from "./DiagnosticLogger"; -import { getExceptionName } from "./HelperFuncs"; interface _IInternalTelemetryInitializerHandler { id: number; diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/UnloadHandlerContainer.ts b/shared/AppInsightsCore/src/core/UnloadHandlerContainer.ts similarity index 79% rename from shared/AppInsightsCore/src/JavaScriptSDK/UnloadHandlerContainer.ts rename to shared/AppInsightsCore/src/core/UnloadHandlerContainer.ts index 565b73d54..d272ea41e 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK/UnloadHandlerContainer.ts +++ b/shared/AppInsightsCore/src/core/UnloadHandlerContainer.ts @@ -2,10 +2,10 @@ // Licensed under the MIT License. import { arrForEach, dumpObj } from "@nevware21/ts-utils"; -import { _eInternalMessageId, eLoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums"; -import { IProcessTelemetryUnloadContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext"; -import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState"; -import { _throwInternal } from "./DiagnosticLogger"; +import { _throwInternal } from "../diagnostics/DiagnosticLogger"; +import { _eInternalMessageId, eLoggingSeverity } from "../enums/ai/LoggingEnums"; +import { IProcessTelemetryUnloadContext } from "../interfaces/ai/IProcessTelemetryContext"; +import { ITelemetryUnloadState } from "../interfaces/ai/ITelemetryUnloadState"; export type UnloadHandler = (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void; @@ -14,6 +14,7 @@ export interface IUnloadHandlerContainer { run: (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void } +/*#__NO_SIDE_EFFECTS__*/ export function createUnloadHandlerContainer(): IUnloadHandlerContainer { let handlers: UnloadHandler[] = []; diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/UnloadHookContainer.ts b/shared/AppInsightsCore/src/core/UnloadHookContainer.ts similarity index 90% rename from shared/AppInsightsCore/src/JavaScriptSDK/UnloadHookContainer.ts rename to shared/AppInsightsCore/src/core/UnloadHookContainer.ts index 32895ed0f..a433c3f84 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK/UnloadHookContainer.ts +++ b/shared/AppInsightsCore/src/core/UnloadHookContainer.ts @@ -2,10 +2,10 @@ // Licensed under the MIT License. import { arrAppend, arrForEach, dumpObj } from "@nevware21/ts-utils"; -import { _eInternalMessageId, eLoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums"; -import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger"; -import { ILegacyUnloadHook, IUnloadHook } from "../JavaScriptSDK.Interfaces/IUnloadHook"; -import { _throwInternal } from "./DiagnosticLogger"; +import { _throwInternal } from "../diagnostics/DiagnosticLogger"; +import { _eInternalMessageId, eLoggingSeverity } from "../enums/ai/LoggingEnums"; +import { IDiagnosticLogger } from "../interfaces/ai/IDiagnosticLogger"; +import { ILegacyUnloadHook, IUnloadHook } from "../interfaces/ai/IUnloadHook"; let _maxHooks: number | undefined; let _hookAddMonitor: (state: string, hooks: Array) => void | undefined; diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/DiagnosticLogger.ts b/shared/AppInsightsCore/src/diagnostics/DiagnosticLogger.ts similarity index 95% rename from shared/AppInsightsCore/src/JavaScriptSDK/DiagnosticLogger.ts rename to shared/AppInsightsCore/src/diagnostics/DiagnosticLogger.ts index c5ca62bc9..0c604c49a 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK/DiagnosticLogger.ts +++ b/shared/AppInsightsCore/src/diagnostics/DiagnosticLogger.ts @@ -4,15 +4,16 @@ import dynamicProto from "@microsoft/dynamicproto-js"; import { IPromise } from "@nevware21/ts-async"; import { dumpObj, isFunction, isUndefined, objDefine } from "@nevware21/ts-utils"; -import { createDynamicConfig, onConfigChange } from "../Config/DynamicConfig"; -import { LoggingSeverity, _InternalMessageId, _eInternalMessageId, eLoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums"; -import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore"; -import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration"; -import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger"; -import { IConfigDefaults, IUnloadHook } from "../applicationinsights-core-js"; -import { getDebugExt } from "./DbgExtensionUtils"; -import { getConsole, getJSON, hasJSON } from "./EnvUtils"; -import { STR_EMPTY } from "./InternalConstants"; +import { createDynamicConfig, onConfigChange } from "../config/DynamicConfig"; +import { STR_EMPTY } from "../constants/InternalConstants"; +import { getDebugExt } from "../core/DbgExtensionUtils"; +import { LoggingSeverity, _InternalMessageId, _eInternalMessageId, eLoggingSeverity } from "../enums/ai/LoggingEnums"; +import { IAppInsightsCore } from "../interfaces/ai/IAppInsightsCore"; +import { IConfiguration } from "../interfaces/ai/IConfiguration"; +import { IDiagnosticLogger } from "../interfaces/ai/IDiagnosticLogger"; +import { IUnloadHook } from "../interfaces/ai/IUnloadHook"; +import { IConfigDefaults } from "../interfaces/config/IConfigDefaults"; +import { getConsole, getJSON, hasJSON } from "../utils/EnvUtils"; const STR_WARN_TO_CONSOLE = "warnToConsole"; @@ -36,7 +37,7 @@ const defaultValues: IConfigDefaults = { loggingLevelTelemetry: 1, maxMessageLimit: 25, enableDebug: false -} +}; const _logFuncs: { [key in eLoggingSeverity]: keyof IDiagnosticLogger} = { [eLoggingSeverity.DISABLED]: null, @@ -94,6 +95,7 @@ export class _InternalLogMessage{ } } +/*#__NO_SIDE_EFFECTS__*/ export function safeGetLogger(core: IAppInsightsCore, config?: IConfiguration): IDiagnosticLogger { return (core || {} as any).logger || new DiagnosticLogger(config); } diff --git a/shared/AppInsightsCommon/src/ThrottleMgr.ts b/shared/AppInsightsCore/src/diagnostics/ThrottleMgr.ts similarity index 94% rename from shared/AppInsightsCommon/src/ThrottleMgr.ts rename to shared/AppInsightsCore/src/diagnostics/ThrottleMgr.ts index 83e8ccada..179e7a779 100644 --- a/shared/AppInsightsCommon/src/ThrottleMgr.ts +++ b/shared/AppInsightsCore/src/diagnostics/ThrottleMgr.ts @@ -1,11 +1,14 @@ -import { - IAppInsightsCore, IConfiguration, IDiagnosticLogger, _eInternalMessageId, _throwInternal, arrIndexOf, eLoggingSeverity, - isNotNullOrUndefined, isNullOrUndefined, onConfigChange, randomValue, safeGetLogger, strTrim -} from "@microsoft/applicationinsights-core-js"; -import { arrForEach, mathFloor, mathMin, objForEachKey } from "@nevware21/ts-utils"; -import { IThrottleInterval, IThrottleLocalStorageObj, IThrottleMgrConfig, IThrottleResult } from "./Interfaces/IThrottleMgr"; -import { utlCanUseLocalStorage, utlGetLocalStorage, utlSetLocalStorage } from "./StorageHelperFuncs"; -import { IConfig } from "./applicationinsights-common"; +import { arrForEach, arrIndexOf, isNullOrUndefined, mathFloor, mathMin, objForEachKey, strTrim } from "@nevware21/ts-utils"; +import { onConfigChange } from "../config/DynamicConfig"; +import { _throwInternal, safeGetLogger } from "../diagnostics/DiagnosticLogger"; +import { _eInternalMessageId, eLoggingSeverity } from "../enums/ai/LoggingEnums"; +import { IAppInsightsCore } from "../interfaces/ai/IAppInsightsCore"; +import { IConfig } from "../interfaces/ai/IConfig"; +import { IConfiguration } from "../interfaces/ai/IConfiguration"; +import { IDiagnosticLogger } from "../interfaces/ai/IDiagnosticLogger"; +import { IThrottleInterval, IThrottleLocalStorageObj, IThrottleMgrConfig, IThrottleResult } from "../interfaces/ai/IThrottleMgr"; +import { randomValue } from "../utils/RandomHelper"; +import { utlCanUseLocalStorage, utlGetLocalStorage, utlSetLocalStorage } from "../utils/StorageHelperFuncs"; const THROTTLE_STORAGE_PREFIX = "appInsightsThrottle"; @@ -197,7 +200,7 @@ export class ThrottleMgr { _queue = {}; _config = {}; _setCfgByKey(_eInternalMessageId.DefaultThrottleMsgKey); - _namePrefix = isNotNullOrUndefined(namePrefix)? namePrefix : ""; + _namePrefix = !isNullOrUndefined(namePrefix)? namePrefix : ""; core.addUnloadHook(onConfigChange(core.config, (details) => { let coreConfig = details.cfg; @@ -260,7 +263,7 @@ export class ThrottleMgr { } function _canThrottle(config: IThrottleMgrConfig, canUseLocalStorage: boolean, localStorageObj: IThrottleLocalStorageObj) { - if (config && !config.disabled && canUseLocalStorage && isNotNullOrUndefined(localStorageObj)) { + if (config && !config.disabled && canUseLocalStorage && !isNullOrUndefined(localStorageObj)) { let curDate = _getThrottleDate(); let date = localStorageObj.date; let interval = config.interval; @@ -284,7 +287,7 @@ export class ThrottleMgr { } function _getLocalStorageName(msgKey: _eInternalMessageId | number, prefix?: string) { - let fix = isNotNullOrUndefined(prefix)? prefix : ""; + let fix = !isNullOrUndefined(prefix)? prefix : ""; if (msgKey) { return THROTTLE_STORAGE_PREFIX + fix + "-" + msgKey; } diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Enums/EnumHelperFuncs.ts b/shared/AppInsightsCore/src/enums/EnumHelperFuncs.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Enums/EnumHelperFuncs.ts rename to shared/AppInsightsCore/src/enums/EnumHelperFuncs.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Enums/W3CTraceFlags.ts b/shared/AppInsightsCore/src/enums/W3CTraceFlags.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Enums/W3CTraceFlags.ts rename to shared/AppInsightsCore/src/enums/W3CTraceFlags.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Enums/DependencyTypes.ts b/shared/AppInsightsCore/src/enums/ai/DependencyTypes.ts similarity index 94% rename from shared/AppInsightsCore/src/JavaScriptSDK.Enums/DependencyTypes.ts rename to shared/AppInsightsCore/src/enums/ai/DependencyTypes.ts index b38711dcb..0b943cef4 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK.Enums/DependencyTypes.ts +++ b/shared/AppInsightsCore/src/enums/ai/DependencyTypes.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { createEnumStyle } from "./EnumHelperFuncs"; +import { createEnumStyle } from "../EnumHelperFuncs"; export const enum eDependencyTypes { InProc = "InProc", diff --git a/shared/AppInsightsCommon/src/Enums.ts b/shared/AppInsightsCore/src/enums/ai/Enums.ts similarity index 98% rename from shared/AppInsightsCommon/src/Enums.ts rename to shared/AppInsightsCore/src/enums/ai/Enums.ts index 64d10c71d..6ac091dbe 100644 --- a/shared/AppInsightsCommon/src/Enums.ts +++ b/shared/AppInsightsCore/src/enums/ai/Enums.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { createEnumStyle } from "@microsoft/applicationinsights-core-js"; +import { createEnumStyle } from "../EnumHelperFuncs"; /** * Type of storage to differentiate between local storage and session storage diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Enums/EventsDiscardedReason.ts b/shared/AppInsightsCore/src/enums/ai/EventsDiscardedReason.ts similarity index 97% rename from shared/AppInsightsCore/src/JavaScriptSDK.Enums/EventsDiscardedReason.ts rename to shared/AppInsightsCore/src/enums/ai/EventsDiscardedReason.ts index 5a7775307..a83463ab2 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK.Enums/EventsDiscardedReason.ts +++ b/shared/AppInsightsCore/src/enums/ai/EventsDiscardedReason.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { createEnumStyle } from "../JavaScriptSDK.Enums/EnumHelperFuncs"; +import { createEnumStyle } from "../EnumHelperFuncs"; /** * The eEventsDiscardedReason enumeration contains a set of values that specify the reason for discarding an event. diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Enums/FeatureOptInEnums.ts b/shared/AppInsightsCore/src/enums/ai/FeatureOptInEnums.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Enums/FeatureOptInEnums.ts rename to shared/AppInsightsCore/src/enums/ai/FeatureOptInEnums.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Enums/InitActiveStatusEnum.ts b/shared/AppInsightsCore/src/enums/ai/InitActiveStatusEnum.ts similarity index 93% rename from shared/AppInsightsCore/src/JavaScriptSDK.Enums/InitActiveStatusEnum.ts rename to shared/AppInsightsCore/src/enums/ai/InitActiveStatusEnum.ts index 4b3789867..cdaa5353d 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK.Enums/InitActiveStatusEnum.ts +++ b/shared/AppInsightsCore/src/enums/ai/InitActiveStatusEnum.ts @@ -1,4 +1,4 @@ -import { createEnumStyle } from "./EnumHelperFuncs"; +import { createEnumStyle } from "../EnumHelperFuncs"; export const enum eActiveStatus { diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Enums/LoggingEnums.ts b/shared/AppInsightsCore/src/enums/ai/LoggingEnums.ts similarity index 98% rename from shared/AppInsightsCore/src/JavaScriptSDK.Enums/LoggingEnums.ts rename to shared/AppInsightsCore/src/enums/ai/LoggingEnums.ts index 3e3f76145..5a727601a 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK.Enums/LoggingEnums.ts +++ b/shared/AppInsightsCore/src/enums/ai/LoggingEnums.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. // @skip-file-minify -import { createEnumStyle } from "../JavaScriptSDK.Enums/EnumHelperFuncs"; +import { createEnumStyle } from "../EnumHelperFuncs"; export const enum eLoggingSeverity { /** diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Enums/SendRequestReason.ts b/shared/AppInsightsCore/src/enums/ai/SendRequestReason.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Enums/SendRequestReason.ts rename to shared/AppInsightsCore/src/enums/ai/SendRequestReason.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Enums/StatsType.ts b/shared/AppInsightsCore/src/enums/ai/StatsType.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Enums/StatsType.ts rename to shared/AppInsightsCore/src/enums/ai/StatsType.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Enums/TelemetryUnloadReason.ts b/shared/AppInsightsCore/src/enums/ai/TelemetryUnloadReason.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Enums/TelemetryUnloadReason.ts rename to shared/AppInsightsCore/src/enums/ai/TelemetryUnloadReason.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Enums/TelemetryUpdateReason.ts b/shared/AppInsightsCore/src/enums/ai/TelemetryUpdateReason.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Enums/TelemetryUpdateReason.ts rename to shared/AppInsightsCore/src/enums/ai/TelemetryUpdateReason.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Enums/TraceHeadersMode.ts b/shared/AppInsightsCore/src/enums/ai/TraceHeadersMode.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Enums/TraceHeadersMode.ts rename to shared/AppInsightsCore/src/enums/ai/TraceHeadersMode.ts diff --git a/shared/AppInsightsCore/src/OpenTelemetry/enums/trace/OTelSamplingDecision.ts b/shared/AppInsightsCore/src/enums/otel/OTelSamplingDecision.ts similarity index 92% rename from shared/AppInsightsCore/src/OpenTelemetry/enums/trace/OTelSamplingDecision.ts rename to shared/AppInsightsCore/src/enums/otel/OTelSamplingDecision.ts index 752adb2a1..a400b76b3 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/enums/trace/OTelSamplingDecision.ts +++ b/shared/AppInsightsCore/src/enums/otel/OTelSamplingDecision.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { createEnumStyle } from "../../../JavaScriptSDK.Enums/EnumHelperFuncs"; +import { createEnumStyle } from "../EnumHelperFuncs"; /** * A sampling decision that determines how a {@link IOTelSpan} will be recorded diff --git a/shared/AppInsightsCore/src/OpenTelemetry/enums/trace/OTelSpanKind.ts b/shared/AppInsightsCore/src/enums/otel/OTelSpanKind.ts similarity index 95% rename from shared/AppInsightsCore/src/OpenTelemetry/enums/trace/OTelSpanKind.ts rename to shared/AppInsightsCore/src/enums/otel/OTelSpanKind.ts index 11b39bb2c..d76042aa0 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/enums/trace/OTelSpanKind.ts +++ b/shared/AppInsightsCore/src/enums/otel/OTelSpanKind.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { createEnumStyle } from "../../../JavaScriptSDK.Enums/EnumHelperFuncs"; +import { createEnumStyle } from "../EnumHelperFuncs"; /** * The defined set of Span Kinds as defined by the OpenTelemetry. diff --git a/shared/AppInsightsCore/src/OpenTelemetry/enums/trace/OTelSpanStatus.ts b/shared/AppInsightsCore/src/enums/otel/OTelSpanStatus.ts similarity index 90% rename from shared/AppInsightsCore/src/OpenTelemetry/enums/trace/OTelSpanStatus.ts rename to shared/AppInsightsCore/src/enums/otel/OTelSpanStatus.ts index cf7116b60..ae9c1c2fd 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/enums/trace/OTelSpanStatus.ts +++ b/shared/AppInsightsCore/src/enums/otel/OTelSpanStatus.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { createEnumStyle } from "../../../JavaScriptSDK.Enums/EnumHelperFuncs"; +import { createEnumStyle } from "../EnumHelperFuncs"; /** * An enumeration of status codes, matching the OpenTelemetry specification. diff --git a/shared/AppInsightsCore/src/OpenTelemetry/enums/eAttributeChangeOp.ts b/shared/AppInsightsCore/src/enums/otel/eAttributeChangeOp.ts similarity index 92% rename from shared/AppInsightsCore/src/OpenTelemetry/enums/eAttributeChangeOp.ts rename to shared/AppInsightsCore/src/enums/otel/eAttributeChangeOp.ts index 66bfc2a59..efe0a33b9 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/enums/eAttributeChangeOp.ts +++ b/shared/AppInsightsCore/src/enums/otel/eAttributeChangeOp.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { createEnumStyle } from "../../JavaScriptSDK.Enums/EnumHelperFuncs"; +import { createEnumStyle } from "../EnumHelperFuncs"; /** * Const enum for attribute change operation types diff --git a/shared/AppInsightsCore/src/index.ts b/shared/AppInsightsCore/src/index.ts new file mode 100644 index 000000000..cc0749698 --- /dev/null +++ b/shared/AppInsightsCore/src/index.ts @@ -0,0 +1,359 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +export { IConfiguration } from "./interfaces/ai/IConfiguration"; +export { IChannelControls, MinChannelPriorty, IInternalOfflineSupport } from "./interfaces/ai/IChannelControls"; +export { IChannelControlsHost } from "./interfaces/ai/IChannelControlsHost"; +export { ITelemetryPlugin, IPlugin } from "./interfaces/ai/ITelemetryPlugin"; +export { IExceptionConfig } from "./interfaces/ai/IExceptionConfig"; +export { IAppInsightsCore, ILoadedPlugin } from "./interfaces/ai/IAppInsightsCore"; +export { ITelemetryItem, ICustomProperties, Tags } from "./interfaces/ai/ITelemetryItem"; +export { IBaseProcessingContext, IProcessTelemetryContext, IProcessTelemetryUnloadContext, IProcessTelemetryUpdateContext } from "./interfaces/ai/IProcessTelemetryContext"; +export { INotificationListener } from "./interfaces/ai/INotificationListener"; +export { ITelemetryPluginChain } from "./interfaces/ai/ITelemetryPluginChain"; +export { IDiagnosticLogger } from "./interfaces/ai/IDiagnosticLogger"; +export { InstrumentorHooksCallback, IInstrumentHooksCallbacks, IInstrumentHooks, IInstrumentHook, IInstrumentCallDetails } from "./interfaces/ai/IInstrumentHooks"; +export { IUnloadableComponent } from "./interfaces/ai/IUnloadableComponent"; +export { IPayloadData, SendPOSTFunction, IXHROverride, OnCompleteCallback } from "./interfaces/ai/IXHROverride" +export { IUnloadHook, ILegacyUnloadHook } from "./interfaces/ai/IUnloadHook"; +export { eEventsDiscardedReason, EventsDiscardedReason, eBatchDiscardedReason, BatchDiscardedReason } from "./enums/ai/EventsDiscardedReason"; +export { eDependencyTypes, DependencyTypes } from "./enums/ai/DependencyTypes"; +export { SendRequestReason, TransportType } from "./enums/ai/SendRequestReason"; +//export { StatsType, eStatsType } from "./enums/ai/StatsType"; +export { TelemetryUpdateReason } from "./enums/ai/TelemetryUpdateReason"; +export { TelemetryUnloadReason } from "./enums/ai/TelemetryUnloadReason"; +export { eActiveStatus, ActiveStatus } from "./enums/ai/InitActiveStatusEnum" +export { throwAggregationError } from "./core/AggregationError"; +export { AppInsightsCore } from "./core/AppInsightsCore"; +export { BaseTelemetryPlugin } from "./core/BaseTelemetryPlugin"; +export { randomValue, random32, mwcRandomSeed, mwcRandom32, newId } from "./utils/RandomHelper"; +export { Undefined, newGuid, generateW3CId } from "./utils/CoreUtils"; +export { runTargetUnload, doUnloadAll } from "./core/AsyncUtils"; +export { + normalizeJsName, toISOString, getExceptionName, strContains, setValue, getSetValue, + proxyAssign, proxyFunctions, proxyFunctionAs, createClassFromInterface, optimizeObject, + isNotUndefined, isNotNullOrUndefined, objExtend, isFeatureEnabled, getResponseText, formatErrorMessageXdr, formatErrorMessageXhr, prependTransports, + openXhr, _appendHeader, _getAllResponseHeaders, setObjStringTag, setProtoTypeName +} from "./utils/HelperFuncs"; +export { parseResponse } from "./core/ResponseHelpers"; +export { IXDomainRequest, IBackendResponse } from "./interfaces/ai/IXDomainRequest"; +export { _ISenderOnComplete, _ISendPostMgrConfig, _ITimeoutOverrideWrapper, _IInternalXhrOverride } from "./interfaces/ai/ISenderPostManager"; +export { SenderPostManager } from "./core/SenderPostManager"; +//export { IStatsBeat, IStatsBeatConfig, IStatsBeatKeyMap as IStatsBeatEndpoints, IStatsBeatState} from "./interfaces/ai/IStatsBeat"; +//export { IStatsEventData } from "./interfaces/ai/IStatsEventData"; +//export { IStatsMgr, IStatsMgrConfig } from "./interfaces/ai/IStatsMgr"; +//export { createStatsMgr } from "./core/StatsBeat"; +export { + isArray, isTypeof, isUndefined, isNullOrUndefined, isStrictUndefined, objHasOwnProperty as hasOwnProperty, isObject, isFunction, + strEndsWith, strStartsWith, isDate, isError, isString, isNumber, isBoolean, arrForEach, arrIndexOf, + arrReduce, arrMap, strTrim, objKeys, objCreate, objDefine, objDefineProp, objDefineAccessors, throwError, isSymbol, + isNotTruthy, isTruthy, objFreeze, objSeal, objToString, objDeepFreeze as deepFreeze, + getInst as getGlobalInst, hasWindow, getWindow, hasDocument, getDocument, hasNavigator, getNavigator, hasHistory, + getHistory, dumpObj, asString, objForEachKey, getPerformance, utcNow as dateNow, perfNow, + ObjDefinePropDescriptor +} from "@nevware21/ts-utils"; +export { EnumValue, createEnumStyle, createValueMap } from "./enums/EnumHelperFuncs"; +export { + attachEvent, detachEvent, addEventHandler, addEventListeners, addPageUnloadEventListener, addPageHideEventListener, addPageShowEventListener, + removeEventHandler, removeEventListeners, removePageUnloadEventListener, removePageHideEventListener, removePageShowEventListener, eventOn, eventOff, + mergeEvtNamespace, _IRegisteredEvents, __getRegisteredEvents +} from "./internal/EventHelpers"; + +export { + getCrypto, getMsCrypto, getLocation, hasJSON, getJSON, + isReactNative, getConsole, isIE, getIEVersion, isSafari, + setEnableEnvMocks, isBeaconsSupported, isFetchSupported, useXDomainRequest, isXhrSupported, + findMetaTag, findNamedServerTiming, sendCustomEvent, dispatchEvent, createCustomDomEvent, fieldRedaction +} from "./utils/EnvUtils"; +export { + getGlobal, + strShimPrototype as strPrototype, + strShimFunction as strFunction, + strShimUndefined as strUndefined, + strShimObject as strObject +} from "@microsoft/applicationinsights-shims"; +export { NotificationManager } from "./core/NotificationManager"; +export { INotificationManager } from "./interfaces/ai/INotificationManager"; +export { IPerfEvent } from "./interfaces/ai/IPerfEvent"; +export { IPerfManager, IPerfManagerProvider } from "./interfaces/ai/IPerfManager"; +export { PerfEvent, PerfManager, doPerf, getGblPerfMgr, setGblPerfMgr } from "./core/PerfManager"; +export { IFeatureOptInDetails, IFeatureOptIn } from "./interfaces/ai/IFeatureOptIn"; +export { FeatureOptInMode, CdnFeatureMode } from "./enums/ai/FeatureOptInEnums" +export { safeGetLogger, DiagnosticLogger, _InternalLogMessage, _throwInternal, _warnToConsole, _logInternalMessage } from "./diagnostics/DiagnosticLogger"; +export { + createProcessTelemetryContext + // Explicitly NOT exporting createProcessTelemetryUnloadContext() and createProcessTelemetryUpdateContext() as these should only be created internally +} from "./core/ProcessTelemetryContext"; +export { initializePlugins, sortPlugins, unloadComponents, createDistributedTraceContext, isDistributedTraceContext } from "./core/TelemetryHelpers"; +export { _eInternalMessageId, _InternalMessageId, LoggingSeverity, eLoggingSeverity } from "./enums/ai/LoggingEnums"; +export { InstrumentProto, InstrumentProtos, InstrumentFunc, InstrumentFuncs, InstrumentEvent } from "./core/InstrumentHooks"; +export { ICookieMgr, ICookieMgrConfig } from "./interfaces/ai/ICookieMgr"; +export { + createCookieMgr, safeGetCookieMgr, uaDisallowsSameSiteNone, areCookiesSupported +} from "./core/CookieMgr"; +export { IDbgExtension } from "./interfaces/ai/IDbgExtension"; +export { getDebugListener, getDebugExt } from "./core/DbgExtensionUtils" +export { TelemetryInitializerFunction, ITelemetryInitializerHandler, ITelemetryInitializerContainer } from "./interfaces/ai/ITelemetryInitializers"; +export { createUniqueNamespace } from "./utils/DataCacheHelper"; +export { UnloadHandler, IUnloadHandlerContainer, createUnloadHandlerContainer } from "./core/UnloadHandlerContainer"; +export { IUnloadHookContainer, createUnloadHookContainer, _testHookMaxUnloadHooksCb } from "./core/UnloadHookContainer"; +export { ITelemetryUpdateState } from "./interfaces/ai/ITelemetryUpdateState"; +export { ITelemetryUnloadState } from "./interfaces/ai/ITelemetryUnloadState"; +export { IDistributedTraceContext, IDistributedTraceInit } from "./interfaces/ai/IDistributedTraceContext"; +export { ITraceParent } from "./interfaces/ai/ITraceParent"; +export { + createTraceParent, parseTraceParent, isValidTraceId, isValidSpanId, isValidTraceParent, isSampledFlag, formatTraceParent, findW3cTraceParent, + findAllScripts +} from "./utils/TraceParent"; + +// Dynamic Config definitions +export { IConfigCheckFn, IConfigDefaultCheck, IConfigDefaults, IConfigSetFn } from "./interfaces/config/IConfigDefaults"; +export { IDynamicConfigHandler } from "./interfaces/config/IDynamicConfigHandler"; +export { IDynamicPropertyHandler } from "./interfaces/config/IDynamicPropertyHandler"; +export { IWatchDetails, IWatcherHandler, WatcherFunction } from "./interfaces/config/IDynamicWatcher"; +export { createDynamicConfig, onConfigChange } from "./config/DynamicConfig"; +export { getDynamicConfigHandler, blockDynamicConversion, forceDynamicConversion } from "./config/DynamicSupport"; +export { cfgDfValidate, cfgDfMerge, cfgDfBoolean, cfgDfFunc, cfgDfString, cfgDfSet, cfgDfBlockPropValue } from "./config/ConfigDefaultHelpers"; + +// W3c TraceState support +export { eW3CTraceFlags } from "./enums/W3CTraceFlags"; +export { IW3cTraceState } from "./interfaces/ai/IW3cTraceState"; +export { createW3cTraceState, findW3cTraceState, isW3cTraceState, snapshotW3cTraceState } from "./telemetry/W3cTraceState"; + +// OpenTelemetry Trace support +export { IOTelTraceState } from "./interfaces/otel/trace/IOTelTraceState"; +export { IOTelSpan } from "./interfaces/otel/trace/IOTelSpan"; +export { IOTelTracer } from "./interfaces/otel/trace/IOTelTracer"; +export { IOTelTracerProvider, IOTelTracerOptions } from "./interfaces/otel/trace/IOTelTracerProvider"; +export { ITraceProvider, ITraceHost, ISpanScope } from "./interfaces/ai/ITraceProvider"; +export { IOTelSpanOptions } from "./interfaces/otel/trace/IOTelSpanOptions"; +export { createOTelTraceState } from "./otel/api/trace/traceState"; +export { createSpan } from "./otel/api/trace/span"; +export { createTraceProvider } from "./otel/api/trace/traceProvider"; +export { isSpanContextValid, wrapSpanContext, isReadableSpan, suppressTracing, unsuppressTracing, isTracingSuppressed, useSpan, withSpan, startActiveSpan } from "./otel/api/trace/utils"; + +export { + AzureMonitorSampleRate, ApplicationInsightsCustomEventName, MicrosoftClientIp, ApplicationInsightsMessageName, + ApplicationInsightsExceptionName, ApplicationInsightsPageViewName, ApplicationInsightsAvailabilityName, + ApplicationInsightsEventName, ApplicationInsightsBaseType, ApplicationInsightsMessageBaseType, + ApplicationInsightsExceptionBaseType, ApplicationInsightsPageViewBaseType, ApplicationInsightsAvailabilityBaseType, + ApplicationInsightsEventBaseType, ATTR_ENDUSER_ID, ATTR_ENDUSER_PSEUDO_ID, ATTR_HTTP_ROUTE, SEMATTRS_NET_PEER_IP, + SEMATTRS_NET_PEER_NAME, SEMATTRS_NET_HOST_IP, SEMATTRS_PEER_SERVICE, SEMATTRS_HTTP_USER_AGENT, SEMATTRS_HTTP_METHOD, + SEMATTRS_HTTP_URL, SEMATTRS_HTTP_STATUS_CODE, SEMATTRS_HTTP_ROUTE, SEMATTRS_HTTP_HOST, SEMATTRS_DB_SYSTEM, + SEMATTRS_DB_STATEMENT, SEMATTRS_DB_OPERATION, SEMATTRS_DB_NAME, SEMATTRS_RPC_SYSTEM, SEMATTRS_RPC_GRPC_STATUS_CODE, + SEMATTRS_EXCEPTION_TYPE, SEMATTRS_EXCEPTION_MESSAGE, SEMATTRS_EXCEPTION_STACKTRACE, SEMATTRS_HTTP_SCHEME, + SEMATTRS_HTTP_TARGET, SEMATTRS_HTTP_FLAVOR, SEMATTRS_NET_TRANSPORT, SEMATTRS_NET_HOST_NAME, SEMATTRS_NET_HOST_PORT, + SEMATTRS_NET_PEER_PORT, SEMATTRS_HTTP_CLIENT_IP, SEMATTRS_ENDUSER_ID, ATTR_CLIENT_ADDRESS, ATTR_CLIENT_PORT, + ATTR_SERVER_ADDRESS, ATTR_SERVER_PORT, ATTR_URL_FULL, ATTR_URL_PATH, ATTR_URL_QUERY, ATTR_URL_SCHEME, + ATTR_ERROR_TYPE, ATTR_NETWORK_LOCAL_ADDRESS, ATTR_NETWORK_LOCAL_PORT, ATTR_NETWORK_PROTOCOL_NAME, + ATTR_NETWORK_PEER_ADDRESS, ATTR_NETWORK_PEER_PORT, ATTR_NETWORK_PROTOCOL_VERSION, ATTR_NETWORK_TRANSPORT, + ATTR_USER_AGENT_ORIGINAL, ATTR_HTTP_REQUEST_METHOD, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_EXCEPTION_TYPE, + ATTR_EXCEPTION_MESSAGE, ATTR_EXCEPTION_STACKTRACE, EXP_ATTR_ENDUSER_ID, EXP_ATTR_ENDUSER_PSEUDO_ID, + EXP_ATTR_SYNTHETIC_TYPE, DBSYSTEMVALUES_MONGODB, DBSYSTEMVALUES_COSMOSDB, DBSYSTEMVALUES_MYSQL, + DBSYSTEMVALUES_POSTGRESQL, DBSYSTEMVALUES_REDIS, DBSYSTEMVALUES_DB2, DBSYSTEMVALUES_DERBY, DBSYSTEMVALUES_MARIADB, + DBSYSTEMVALUES_MSSQL, DBSYSTEMVALUES_ORACLE, DBSYSTEMVALUES_SQLITE, DBSYSTEMVALUES_OTHER_SQL, DBSYSTEMVALUES_HSQLDB, + DBSYSTEMVALUES_H2 +} from "./otel/attribute/SemanticConventions" + +// OpenTelemetry Core API Interfaces +export { IOTelApi } from "./interfaces/otel/IOTelApi"; +export { IOTelApiCtx } from "./interfaces/otel/IOTelApiCtx"; +export { IOTelAttributes, OTelAttributeValue, ExtendedOTelAttributeValue } from "./interfaces/otel/IOTelAttributes"; +export { OTelException } from "./interfaces/otel/IOTelException"; +export { IOTelHrTime, OTelTimeInput } from "./interfaces/IOTelHrTime"; +export { createOTelApi } from "./otel/api/OTelApi"; + +// OpenTelemetry Trace Interfaces +export { ITraceApi } from "./interfaces/otel/trace/IOTelTraceApi"; +export { IOTelSpanCtx } from "./interfaces/otel/trace/IOTelSpanCtx"; +export { IOTelSpanStatus } from "./interfaces/otel/trace/IOTelSpanStatus"; +export { IReadableSpan } from "./interfaces/otel/trace/IReadableSpan"; + +// OpenTelemetry Configuration Interfaces +export { IOTelConfig } from "./interfaces/otel/config/IOTelConfig"; +export { IOTelAttributeLimits } from "./interfaces/otel/config/IOTelAttributeLimits"; +export { IOTelErrorHandlers } from "./interfaces/otel/config/IOTelErrorHandlers"; +export { ITraceCfg } from "./interfaces/otel/config/IOTelTraceCfg"; + +// OpenTelemetry Attribute Support +export { IAttributeContainer, IAttributeChangeInfo } from "./interfaces/otel/attribute/IAttributeContainer"; +export { eAttributeChangeOp, AttributeChangeOp } from "./enums/otel/eAttributeChangeOp"; +export { createAttributeContainer, addAttributes, isAttributeContainer, createAttributeSnapshot } from "./otel/attribute/attributeContainer"; +export { eAttributeFilter, AttributeFilter } from "./interfaces/otel/attribute/IAttributeContainer"; + +// OpenTelemetry Enums +export { eOTelSpanKind, OTelSpanKind } from "./enums/otel/OTelSpanKind"; +export { eOTelSpanStatusCode, OTelSpanStatusCode } from "./enums/otel/OTelSpanStatus"; + +// OpenTelemetry Helper Utilities +export { + hrTime, hrTimeToTimeStamp, hrTimeDuration, hrTimeToMilliseconds, timeInputToHrTime, millisToHrTime, hrTimeToNanoseconds, + addHrTimes, hrTimeToMicroseconds, zeroHrTime, nanosToHrTime, isTimeInput, isTimeInputHrTime, isTimeSpan +} from "./internal/timeHelpers"; +export { isAttributeValue, isAttributeKey, sanitizeAttributes } from "./internal/attributeHelpers"; +export { + getSyntheticType, isSyntheticSource, serializeAttribute, getUrl, getPeerIp, getHttpMethod, getHttpUrl, getHttpHost, getHttpScheme, + getHttpTarget, getNetPeerName, getNetPeerPort, getUserAgent, getLocationIp, getHttpStatusCode, getHttpClientIp, + getDependencyTarget, isSqlDB +} from "./internal/commonUtils"; + +// OpenTelemetry Error Handlers +export { + handleAttribError, handleSpanError, handleDebug, handleWarn, handleError, handleNotImplemented +} from "./internal/handleErrors"; + +// OpenTelemetry Error Classes +export { OpenTelemetryError, OpenTelemetryErrorConstructor, getOpenTelemetryError, throwOTelError } from "./otel/api/errors/OTelError"; +export { OTelInvalidAttributeError, throwOTelInvalidAttributeError } from "./otel/api/errors/OTelInvalidAttributeError"; +export { OTelSpanError, throwOTelSpanError } from "./otel/api/errors/OTelSpanError"; + +// ======================================== +// Application Insights Common Exports +// ======================================== + +// Utility functions +export { + correlationIdSetPrefix, correlationIdGetPrefix, correlationIdCanIncludeCorrelationHeader, + correlationIdGetCorrelationContext, correlationIdGetCorrelationContextValue, + dateTimeUtilsNow, dateTimeUtilsDuration, isInternalApplicationInsightsEndpoint, + createDistributedTraceContextFromTrace +} from "./utils/Util"; + +export { ThrottleMgr } from "./diagnostics/ThrottleMgr"; +export { parseConnectionString, ConnectionStringParser } from "./telemetry/ConnectionStringParser"; +export type { ConnectionString } from "./interfaces/ai/ConnectionString"; +export { FieldType } from "./enums/ai/Enums"; +export { IRequestHeaders, RequestHeaders, eRequestHeaders } from "./telemetry/RequestResponseHeaders"; +export { + DisabledPropertyName, ProcessLegacy, SampleRate, HttpMethod, + DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH, strNotSpecified, + ChannelControllerPriority +} from "./constants/Constants"; + +// Contracts +export { IData as AIData } from "./interfaces/ai/contracts/IData"; +export { IBase as AIBase } from "./interfaces/ai/contracts/IBase"; +export { IDomain } from "./interfaces/ai/contracts/IDomain"; +export { ISerializable } from "./interfaces/ai/telemetry/ISerializable"; +export { IEnvelope } from "./interfaces/ai/telemetry/IEnvelope"; +export { IStackFrame } from "./interfaces/ai/contracts/IStackFrame"; +export { IExceptionDetails } from "./interfaces/ai/contracts/IExceptionDetails"; +export { IExceptionData } from "./interfaces/ai/contracts/IExceptionData"; +export { IEventData } from "./interfaces/ai/contracts/IEventData"; +export { IMessageData } from "./interfaces/ai/contracts/IMessageData"; +export { IMetricData } from "./interfaces/ai/contracts/IMetricData"; +export { IDataPoint } from "./interfaces/ai/contracts/IDataPoint"; +export { DataPointType } from "./interfaces/ai/contracts/DataPointType"; +export { IPageViewPerfData } from "./interfaces/ai/contracts/IPageViewPerfData"; + +// Telemetry classes +export { Envelope } from "./telemetry/ai/Common/Envelope"; +export { Event } from "./telemetry/ai/Event"; +export { Exception } from "./telemetry/ai/Exception"; +export { Metric } from "./telemetry/ai/Metric"; +export { PageView } from "./telemetry/ai/PageView"; +export { IPageViewData } from "./interfaces/ai/contracts/IPageViewData"; +export { RemoteDependencyData } from "./telemetry/ai/RemoteDependencyData"; +export { IRemoteDependencyData } from "./interfaces/ai/contracts/IRemoteDependencyData"; +export { Trace } from "./telemetry/ai/Trace"; +export { PageViewPerformance } from "./telemetry/ai/PageViewPerformance"; +export { Data } from "./telemetry/ai/Common/Data"; +export { DataPoint } from "./telemetry/ai/Common/DataPoint"; + +// Telemetry interfaces +export { IEventTelemetry } from "./interfaces/ai/IEventTelemetry"; +export { ITraceTelemetry } from "./interfaces/ai/ITraceTelemetry"; +export { IMetricTelemetry } from "./interfaces/ai/IMetricTelemetry"; +export { IDependencyTelemetry } from "./interfaces/ai/IDependencyTelemetry"; +export { IExceptionTelemetry, IAutoExceptionTelemetry, IExceptionInternal } from "./interfaces/ai/IExceptionTelemetry"; +export { IPageViewTelemetry, IPageViewTelemetryInternal } from "./interfaces/ai/IPageViewTelemetry"; +export { IPageViewPerformanceTelemetry, IPageViewPerformanceTelemetryInternal } from "./interfaces/ai/IPageViewPerformanceTelemetry"; +export { IRequestTelemetry } from "./interfaces/ai/IRequestTelemetry"; + +// Severity level +export { eSeverityLevel, SeverityLevel } from "./interfaces/ai/contracts/SeverityLevel"; + +// Configuration +export { IConfig, ConfigurationManager } from "./interfaces/ai/IConfig"; +export { IStorageBuffer } from "./interfaces/ai/IStorageBuffer"; +export { ICorrelationConfig } from "./interfaces/ai/ICorrelationConfig"; + +// Context tags and keys +export { IContextTagKeys, ContextTagKeys } from "./interfaces/ai/contracts/ContextTagKeys"; +export { CtxTagKeys, Extensions } from "./interfaces/ai/PartAExtensions"; + +// Data types and envelope types +export { + EventDataType, ExceptionDataType, MetricDataType, PageViewDataType, + PageViewPerformanceDataType, RemoteDependencyDataType, RequestDataType, TraceDataType +} from "./telemetry/ai/DataTypes"; + +export { + EventEnvelopeType, ExceptionEnvelopeType, MetricEnvelopeType, PageViewEnvelopeType, + PageViewPerformanceEnvelopeType, RemoteDependencyEnvelopeType, RequestEnvelopeType, TraceEnvelopeType +} from "./telemetry/ai/EnvelopeTypes"; + +// Data sanitization +export { + DataSanitizerValues, dataSanitizeKeyAndAddUniqueness, dataSanitizeKey, dataSanitizeString, + dataSanitizeUrl, dataSanitizeMessage, dataSanitizeException, dataSanitizeProperties, + dataSanitizeMeasurements, dataSanitizeId, dataSanitizeInput, dsPadNumber +} from "./telemetry/ai/Common/DataSanitizer"; + +// Telemetry item creator +export { TelemetryItemCreator, createTelemetryItem } from "./telemetry/TelemetryItemCreator"; + +// Application Insights interfaces +export { IAppInsights } from "./interfaces/ai/IAppInsights"; +export { ITelemetryContext } from "./interfaces/ai/ITelemetryContext"; +export { IPropertiesPlugin } from "./interfaces/ai/IPropertiesPlugin"; +export { IRequestContext } from "./interfaces/ai/IRequestContext"; + +// Context interfaces +export { IWeb } from "./interfaces/ai/context/IWeb"; +export { ISession } from "./interfaces/ai/context/ISession"; +export { ISessionManager } from "./interfaces/ai/context/ISessionManager"; +export { IApplication } from "./interfaces/ai/context/IApplication"; +export { IDevice } from "./interfaces/ai/context/IDevice"; +export { IInternal } from "./interfaces/ai/context/IInternal"; +export { ILocation } from "./interfaces/ai/context/ILocation"; +export { ISample } from "./interfaces/ai/context/ISample"; +export { IOperatingSystem } from "./interfaces/ai/context/IOperatingSystem"; +export { IUser, IUserContext } from "./interfaces/ai/context/IUser"; +export { ITelemetryTrace } from "./interfaces/ai/context/ITelemetryTrace"; + +// Enums +export { eDistributedTracingModes, DistributedTracingModes, EventPersistence } from "./enums/ai/Enums"; + +// Helper functions +export { stringToBoolOrDefault, msToTimeSpan, getExtensionByName, isCrossOriginError } from "./utils/HelperFuncsCore"; +export { createDomEvent } from "./utils/DomHelperFuncs"; + +// Storage helpers +export { + utlDisableStorage, utlEnableStorage, utlCanUseLocalStorage, utlGetLocalStorage, + utlSetLocalStorage, utlRemoveStorage, utlCanUseSessionStorage, utlGetSessionStorageKeys, + utlGetSessionStorage, utlSetSessionStorage, utlRemoveSessionStorage, utlSetStoragePrefix +} from "./utils/StorageHelperFuncs"; + +// URL helpers +export { + urlParseUrl, urlGetAbsoluteUrl, urlGetPathName, urlGetCompleteUrl, + urlParseHost, urlParseFullHost +} from "./utils/UrlHelperFuncs"; + +// Throttle manager interfaces +export { + IThrottleLimit, IThrottleInterval, IThrottleMgrConfig, + IThrottleLocalStorageObj, IThrottleResult +} from "./interfaces/ai/IThrottleMgr"; + +// Offline support +export { + IOfflineListener, createOfflineListener, IOfflineState, + eOfflineValue, OfflineCallback +} from "./utils/Offline"; + +// Plugin identifiers +export const PropertiesPluginIdentifier = "AppInsightsPropertiesPlugin"; +export const BreezeChannelIdentifier = "AppInsightsChannelPlugin"; +export const AnalyticsPluginIdentifier = "ApplicationInsightsAnalytics"; diff --git a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/IOTelHrTime.ts b/shared/AppInsightsCore/src/interfaces/IOTelHrTime.ts similarity index 98% rename from shared/AppInsightsCore/src/OpenTelemetry/interfaces/IOTelHrTime.ts rename to shared/AppInsightsCore/src/interfaces/IOTelHrTime.ts index 2316786cd..e1a3da855 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/IOTelHrTime.ts +++ b/shared/AppInsightsCore/src/interfaces/IOTelHrTime.ts @@ -2,16 +2,16 @@ /** * High-resolution time represented as a tuple of [seconds, nanoseconds]. * This is the base type for all OpenTelemetry high-resolution time values. - * + * * @remarks * The first element represents seconds since Unix epoch, and the second element * represents nanoseconds (0-999,999,999) within that second. - * + * * @example * ```typescript * const hrTime: OTelHrTimeBase = [1609459200, 500000000]; // 2021-01-01 00:00:00.5 UTC * ``` - * + * * @since 3.4.0 */ export type OTelHrTimeBase = [number, number]; @@ -19,7 +19,7 @@ export type OTelHrTimeBase = [number, number]; /** * Enhanced high-resolution time interface that extends the base tuple with additional properties. * Provides a more structured way to work with high-resolution timestamps. - * + * * @example * ```typescript * const hrTime: IOTelHrTime = { @@ -27,7 +27,7 @@ export type OTelHrTimeBase = [number, number]; * 1: 500000000, // nanoseconds (0-999,999,999) * }; * ``` - * + * * @since 3.4.0 */ export interface IOTelHrTime extends OTelHrTimeBase { @@ -56,24 +56,24 @@ export interface IOTelHrTime extends OTelHrTimeBase { /** * Union type representing all valid time input formats accepted by OpenTelemetry APIs. - * + * * @remarks * - `IOTelHrTime`: High-resolution time with nanosecond precision * - `number`: Milliseconds since Unix epoch (JavaScript Date.now() format) * - `Date`: JavaScript Date object - * + * * @example * ```typescript * // All of these are valid time inputs: * const hrTime: OTelTimeInput = [1609459200, 500000000]; * const msTime: OTelTimeInput = Date.now(); * const dateTime: OTelTimeInput = new Date(); - * + * * span.addEvent("event", {}, hrTime); * span.addEvent("event", {}, msTime); * span.addEvent("event", {}, dateTime); * ``` - * + * * @since 3.4.0 */ export type OTelTimeInput = IOTelHrTime | number | Date; diff --git a/shared/AppInsightsCommon/src/Interfaces/ConnectionString.ts b/shared/AppInsightsCore/src/interfaces/ai/ConnectionString.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/ConnectionString.ts rename to shared/AppInsightsCore/src/interfaces/ai/ConnectionString.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/IAppInsights.ts b/shared/AppInsightsCore/src/interfaces/ai/IAppInsights.ts similarity index 94% rename from shared/AppInsightsCommon/src/Interfaces/IAppInsights.ts rename to shared/AppInsightsCore/src/interfaces/ai/IAppInsights.ts index 711dafe09..149f49f56 100644 --- a/shared/AppInsightsCommon/src/Interfaces/IAppInsights.ts +++ b/shared/AppInsightsCore/src/interfaces/ai/IAppInsights.ts @@ -1,12 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { ICookieMgr, ITelemetryItem } from "@microsoft/applicationinsights-core-js"; +import { ICookieMgr } from "./ICookieMgr"; import { IEventTelemetry } from "./IEventTelemetry"; import { IAutoExceptionTelemetry, IExceptionTelemetry } from "./IExceptionTelemetry"; import { IMetricTelemetry } from "./IMetricTelemetry"; import { IPageViewPerformanceTelemetry } from "./IPageViewPerformanceTelemetry"; import { IPageViewTelemetry } from "./IPageViewTelemetry"; +import { ITelemetryItem } from "./ITelemetryItem"; import { ITraceTelemetry } from "./ITraceTelemetry"; export interface IAppInsights { diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IAppInsightsCore.ts b/shared/AppInsightsCore/src/interfaces/ai/IAppInsightsCore.ts similarity index 97% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IAppInsightsCore.ts rename to shared/AppInsightsCore/src/interfaces/ai/IAppInsightsCore.ts index d271715fa..198b6ee0e 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IAppInsightsCore.ts +++ b/shared/AppInsightsCore/src/interfaces/ai/IAppInsightsCore.ts @@ -3,10 +3,10 @@ import { IPromise } from "@nevware21/ts-async"; import { ICachedValue, ITimerHandler } from "@nevware21/ts-utils"; -import { WatcherFunction } from "../Config/IDynamicWatcher"; -import { eActiveStatus } from "../JavaScriptSDK.Enums/InitActiveStatusEnum"; -import { SendRequestReason } from "../JavaScriptSDK.Enums/SendRequestReason"; -import { UnloadHandler } from "../JavaScriptSDK/UnloadHandlerContainer"; +import { UnloadHandler } from "../../core/UnloadHandlerContainer"; +import { eActiveStatus } from "../../enums/ai/InitActiveStatusEnum"; +import { SendRequestReason } from "../../enums/ai/SendRequestReason"; +import { WatcherFunction } from "../config/IDynamicWatcher"; import { IChannelControls } from "./IChannelControls"; import { IConfiguration } from "./IConfiguration"; import { ICookieMgr } from "./ICookieMgr"; diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IChannelControls.ts b/shared/AppInsightsCore/src/interfaces/ai/IChannelControls.ts similarity index 98% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IChannelControls.ts rename to shared/AppInsightsCore/src/interfaces/ai/IChannelControls.ts index 038874ba5..1c8b940b4 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IChannelControls.ts +++ b/shared/AppInsightsCore/src/interfaces/ai/IChannelControls.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. import { IPromise } from "@nevware21/ts-async"; -import { SendRequestReason } from "../JavaScriptSDK.Enums/SendRequestReason"; +import { SendRequestReason } from "../../enums/ai/SendRequestReason"; import { IProcessTelemetryUnloadContext } from "./IProcessTelemetryContext"; import { ITelemetryItem } from "./ITelemetryItem"; import { ITelemetryPlugin } from "./ITelemetryPlugin"; diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IChannelControlsHost.ts b/shared/AppInsightsCore/src/interfaces/ai/IChannelControlsHost.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IChannelControlsHost.ts rename to shared/AppInsightsCore/src/interfaces/ai/IChannelControlsHost.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/IConfig.ts b/shared/AppInsightsCore/src/interfaces/ai/IConfig.ts similarity index 98% rename from shared/AppInsightsCommon/src/Interfaces/IConfig.ts rename to shared/AppInsightsCore/src/interfaces/ai/IConfig.ts index a30f31ba3..3e643f147 100644 --- a/shared/AppInsightsCommon/src/Interfaces/IConfig.ts +++ b/shared/AppInsightsCore/src/interfaces/ai/IConfig.ts @@ -1,9 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { IConfiguration, ICustomProperties, isNullOrUndefined } from "@microsoft/applicationinsights-core-js"; -import { DistributedTracingModes } from "../Enums"; +import { isNullOrUndefined } from "@nevware21/ts-utils"; +import { DistributedTracingModes } from "../../enums/ai/Enums"; +import { IConfiguration } from "./IConfiguration"; import { IRequestContext } from "./IRequestContext"; import { IStorageBuffer } from "./IStorageBuffer"; +import { ICustomProperties } from "./ITelemetryItem"; import { IThrottleMgrConfig } from "./IThrottleMgr"; /** diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IConfiguration.ts b/shared/AppInsightsCore/src/interfaces/ai/IConfiguration.ts similarity index 98% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IConfiguration.ts rename to shared/AppInsightsCore/src/interfaces/ai/IConfiguration.ts index 69f80d50c..c3db75b74 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IConfiguration.ts +++ b/shared/AppInsightsCore/src/interfaces/ai/IConfiguration.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. import { IPromise } from "@nevware21/ts-async"; -import { eTraceHeadersMode } from "../JavaScriptSDK.Enums/TraceHeadersMode"; -import { IOTelConfig } from "../OpenTelemetry/interfaces/config/IOTelConfig"; +import { eTraceHeadersMode } from "../../enums/ai/TraceHeadersMode"; +import { IOTelConfig } from "../otel/config/IOTelConfig"; import { IAppInsightsCore } from "./IAppInsightsCore"; import { IChannelControls } from "./IChannelControls"; import { ICookieMgrConfig } from "./ICookieMgr"; diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/ICookieMgr.ts b/shared/AppInsightsCore/src/interfaces/ai/ICookieMgr.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/ICookieMgr.ts rename to shared/AppInsightsCore/src/interfaces/ai/ICookieMgr.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/ICorrelationConfig.ts b/shared/AppInsightsCore/src/interfaces/ai/ICorrelationConfig.ts similarity index 98% rename from shared/AppInsightsCommon/src/Interfaces/ICorrelationConfig.ts rename to shared/AppInsightsCore/src/interfaces/ai/ICorrelationConfig.ts index 34a382725..4d6d2b337 100644 --- a/shared/AppInsightsCommon/src/Interfaces/ICorrelationConfig.ts +++ b/shared/AppInsightsCore/src/interfaces/ai/ICorrelationConfig.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { ICustomProperties } from "@microsoft/applicationinsights-core-js"; -import { DistributedTracingModes } from "../Enums"; +import { DistributedTracingModes } from "../../enums/ai/Enums"; import { IRequestContext } from "./IRequestContext"; +import { ICustomProperties } from "./ITelemetryItem"; export interface ICorrelationConfig { enableCorsCorrelation: boolean; @@ -189,4 +189,4 @@ export interface ICorrelationConfig { * should not be excluded. */ addIntEndpoints?: boolean; -} \ No newline at end of file +} diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IDbgExtension.ts b/shared/AppInsightsCore/src/interfaces/ai/IDbgExtension.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IDbgExtension.ts rename to shared/AppInsightsCore/src/interfaces/ai/IDbgExtension.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/IDependencyTelemetry.ts b/shared/AppInsightsCore/src/interfaces/ai/IDependencyTelemetry.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/IDependencyTelemetry.ts rename to shared/AppInsightsCore/src/interfaces/ai/IDependencyTelemetry.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IDiagnosticLogger.ts b/shared/AppInsightsCore/src/interfaces/ai/IDiagnosticLogger.ts similarity index 94% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IDiagnosticLogger.ts rename to shared/AppInsightsCore/src/interfaces/ai/IDiagnosticLogger.ts index 619c810c9..32a93593f 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IDiagnosticLogger.ts +++ b/shared/AppInsightsCore/src/interfaces/ai/IDiagnosticLogger.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. import { IPromise } from "@nevware21/ts-async"; -import { LoggingSeverity, _InternalMessageId } from "../JavaScriptSDK.Enums/LoggingEnums"; -import { _InternalLogMessage } from "../JavaScriptSDK/DiagnosticLogger"; +import { _InternalLogMessage } from "../../diagnostics/DiagnosticLogger"; +import { LoggingSeverity, _InternalMessageId } from "../../enums/ai/LoggingEnums"; import { ITelemetryUpdateState } from "./ITelemetryUpdateState"; export interface IDiagnosticLogger { diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IDistributedTraceContext.ts b/shared/AppInsightsCore/src/interfaces/ai/IDistributedTraceContext.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IDistributedTraceContext.ts rename to shared/AppInsightsCore/src/interfaces/ai/IDistributedTraceContext.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/IEventTelemetry.ts b/shared/AppInsightsCore/src/interfaces/ai/IEventTelemetry.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/IEventTelemetry.ts rename to shared/AppInsightsCore/src/interfaces/ai/IEventTelemetry.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IExceptionConfig.ts b/shared/AppInsightsCore/src/interfaces/ai/IExceptionConfig.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IExceptionConfig.ts rename to shared/AppInsightsCore/src/interfaces/ai/IExceptionConfig.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/IExceptionTelemetry.ts b/shared/AppInsightsCore/src/interfaces/ai/IExceptionTelemetry.ts similarity index 97% rename from shared/AppInsightsCommon/src/Interfaces/IExceptionTelemetry.ts rename to shared/AppInsightsCore/src/interfaces/ai/IExceptionTelemetry.ts index ff60cc640..c9e845a76 100644 --- a/shared/AppInsightsCommon/src/Interfaces/IExceptionTelemetry.ts +++ b/shared/AppInsightsCore/src/interfaces/ai/IExceptionTelemetry.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { SeverityLevel } from "./Contracts/SeverityLevel"; import { IPartC } from "./IPartC"; +import { SeverityLevel } from "./contracts/SeverityLevel"; /** * @export diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IFeatureOptIn.ts b/shared/AppInsightsCore/src/interfaces/ai/IFeatureOptIn.ts similarity index 94% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IFeatureOptIn.ts rename to shared/AppInsightsCore/src/interfaces/ai/IFeatureOptIn.ts index b6e8c537f..c78147735 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IFeatureOptIn.ts +++ b/shared/AppInsightsCore/src/interfaces/ai/IFeatureOptIn.ts @@ -1,4 +1,4 @@ -import { FeatureOptInMode } from "../JavaScriptSDK.Enums/FeatureOptInEnums"; +import { FeatureOptInMode } from "../../enums/ai/FeatureOptInEnums"; export interface IFeatureOptInDetails { /** diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IInstrumentHooks.ts b/shared/AppInsightsCore/src/interfaces/ai/IInstrumentHooks.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IInstrumentHooks.ts rename to shared/AppInsightsCore/src/interfaces/ai/IInstrumentHooks.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/IMetricTelemetry.ts b/shared/AppInsightsCore/src/interfaces/ai/IMetricTelemetry.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/IMetricTelemetry.ts rename to shared/AppInsightsCore/src/interfaces/ai/IMetricTelemetry.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/INetworkStatsbeat.ts b/shared/AppInsightsCore/src/interfaces/ai/INetworkStatsbeat.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/INetworkStatsbeat.ts rename to shared/AppInsightsCore/src/interfaces/ai/INetworkStatsbeat.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/INotificationListener.ts b/shared/AppInsightsCore/src/interfaces/ai/INotificationListener.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/INotificationListener.ts rename to shared/AppInsightsCore/src/interfaces/ai/INotificationListener.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/INotificationManager.ts b/shared/AppInsightsCore/src/interfaces/ai/INotificationManager.ts similarity index 95% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/INotificationManager.ts rename to shared/AppInsightsCore/src/interfaces/ai/INotificationManager.ts index 54149d50a..4457d643a 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/INotificationManager.ts +++ b/shared/AppInsightsCore/src/interfaces/ai/INotificationManager.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. import { IPromise } from "@nevware21/ts-async"; -import { INotificationListener } from "../JavaScriptSDK.Interfaces/INotificationListener"; -import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem"; +import { INotificationListener } from "./INotificationListener"; import { IPerfEvent } from "./IPerfEvent"; +import { ITelemetryItem } from "./ITelemetryItem"; import { IPayloadData } from "./IXHROverride"; /** diff --git a/shared/AppInsightsCommon/src/Interfaces/IPageViewPerformanceTelemetry.ts b/shared/AppInsightsCore/src/interfaces/ai/IPageViewPerformanceTelemetry.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/IPageViewPerformanceTelemetry.ts rename to shared/AppInsightsCore/src/interfaces/ai/IPageViewPerformanceTelemetry.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/IPageViewTelemetry.ts b/shared/AppInsightsCore/src/interfaces/ai/IPageViewTelemetry.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/IPageViewTelemetry.ts rename to shared/AppInsightsCore/src/interfaces/ai/IPageViewTelemetry.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/IPartC.ts b/shared/AppInsightsCore/src/interfaces/ai/IPartC.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/IPartC.ts rename to shared/AppInsightsCore/src/interfaces/ai/IPartC.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IPerfEvent.ts b/shared/AppInsightsCore/src/interfaces/ai/IPerfEvent.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IPerfEvent.ts rename to shared/AppInsightsCore/src/interfaces/ai/IPerfEvent.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IPerfManager.ts b/shared/AppInsightsCore/src/interfaces/ai/IPerfManager.ts similarity index 95% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IPerfManager.ts rename to shared/AppInsightsCore/src/interfaces/ai/IPerfManager.ts index a8d34ed31..d23a30581 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IPerfManager.ts +++ b/shared/AppInsightsCore/src/interfaces/ai/IPerfManager.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { IPerfEvent } from "./../JavaScriptSDK.Interfaces/IPerfEvent"; +import { IPerfEvent } from "./IPerfEvent"; /** * Identifies an interface to a host that can provide an IPerfManager implementation diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IProcessTelemetryContext.ts b/shared/AppInsightsCore/src/interfaces/ai/IProcessTelemetryContext.ts similarity index 99% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IProcessTelemetryContext.ts rename to shared/AppInsightsCore/src/interfaces/ai/IProcessTelemetryContext.ts index 3873be386..a58cd0671 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IProcessTelemetryContext.ts +++ b/shared/AppInsightsCore/src/interfaces/ai/IProcessTelemetryContext.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. "use strict"; -import { IConfigDefaults } from "../Config/IConfigDefaults"; +import { IConfigDefaults } from "../config/IConfigDefaults"; import { IAppInsightsCore } from "./IAppInsightsCore"; import { IConfiguration } from "./IConfiguration"; import { IDiagnosticLogger } from "./IDiagnosticLogger"; diff --git a/shared/AppInsightsCommon/src/Interfaces/IPropertiesPlugin.ts b/shared/AppInsightsCore/src/interfaces/ai/IPropertiesPlugin.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/IPropertiesPlugin.ts rename to shared/AppInsightsCore/src/interfaces/ai/IPropertiesPlugin.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/IRequestContext.ts b/shared/AppInsightsCore/src/interfaces/ai/IRequestContext.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/IRequestContext.ts rename to shared/AppInsightsCore/src/interfaces/ai/IRequestContext.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/IRequestTelemetry.ts b/shared/AppInsightsCore/src/interfaces/ai/IRequestTelemetry.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/IRequestTelemetry.ts rename to shared/AppInsightsCore/src/interfaces/ai/IRequestTelemetry.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/ISenderPostManager.ts b/shared/AppInsightsCore/src/interfaces/ai/ISenderPostManager.ts similarity index 98% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/ISenderPostManager.ts rename to shared/AppInsightsCore/src/interfaces/ai/ISenderPostManager.ts index c98011931..aeb9b4bbf 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/ISenderPostManager.ts +++ b/shared/AppInsightsCore/src/interfaces/ai/ISenderPostManager.ts @@ -1,5 +1,5 @@ import { ITimerHandler } from "@nevware21/ts-utils"; -import { TransportType } from "../JavaScriptSDK.Enums/SendRequestReason"; +import { TransportType } from "../../enums/ai/SendRequestReason"; import { IXDomainRequest } from "./IXDomainRequest"; import { IPayloadData, IXHROverride, OnCompleteCallback } from "./IXHROverride"; diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IStatsBeat.ts b/shared/AppInsightsCore/src/interfaces/ai/IStatsBeat.ts similarity index 98% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IStatsBeat.ts rename to shared/AppInsightsCore/src/interfaces/ai/IStatsBeat.ts index ee91549bb..09468efab 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IStatsBeat.ts +++ b/shared/AppInsightsCore/src/interfaces/ai/IStatsBeat.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { StatsType } from "../JavaScriptSDK.Enums/StatsType"; +import { StatsType } from "../../enums/ai/StatsType"; import { IPayloadData } from "./IXHROverride"; /** diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IStatsEventData.ts b/shared/AppInsightsCore/src/interfaces/ai/IStatsEventData.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IStatsEventData.ts rename to shared/AppInsightsCore/src/interfaces/ai/IStatsEventData.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IStatsMgr.ts b/shared/AppInsightsCore/src/interfaces/ai/IStatsMgr.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IStatsMgr.ts rename to shared/AppInsightsCore/src/interfaces/ai/IStatsMgr.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/IStorageBuffer.ts b/shared/AppInsightsCore/src/interfaces/ai/IStorageBuffer.ts similarity index 87% rename from shared/AppInsightsCommon/src/Interfaces/IStorageBuffer.ts rename to shared/AppInsightsCore/src/interfaces/ai/IStorageBuffer.ts index c65cb1e85..e7aaa1281 100644 --- a/shared/AppInsightsCommon/src/Interfaces/IStorageBuffer.ts +++ b/shared/AppInsightsCore/src/interfaces/ai/IStorageBuffer.ts @@ -1,4 +1,4 @@ -import { IDiagnosticLogger } from "@microsoft/applicationinsights-core-js"; +import { IDiagnosticLogger } from "./IDiagnosticLogger"; /** * Identifies a simple interface to allow you to override the storage mechanism used diff --git a/shared/AppInsightsCommon/src/Interfaces/ITelemetryContext.ts b/shared/AppInsightsCore/src/interfaces/ai/ITelemetryContext.ts similarity index 77% rename from shared/AppInsightsCommon/src/Interfaces/ITelemetryContext.ts rename to shared/AppInsightsCore/src/interfaces/ai/ITelemetryContext.ts index 658ff114e..3b2c65cb6 100644 --- a/shared/AppInsightsCommon/src/Interfaces/ITelemetryContext.ts +++ b/shared/AppInsightsCore/src/interfaces/ai/ITelemetryContext.ts @@ -1,16 +1,16 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { IApplication } from "./Context/IApplication"; -import { IDevice } from "./Context/IDevice"; -import { IInternal } from "./Context/IInternal"; -import { ILocation } from "./Context/ILocation"; -import { IOperatingSystem } from "./Context/IOperatingSystem"; -import { ISession } from "./Context/ISession"; -import { ISessionManager } from "./Context/ISessionManager"; -import { ITelemetryTrace } from "./Context/ITelemetryTrace"; -import { IUserContext } from "./Context/IUser"; -import { IWeb } from "./Context/IWeb"; +import { IApplication } from "./context/IApplication"; +import { IDevice } from "./context/IDevice"; +import { IInternal } from "./context/IInternal"; +import { ILocation } from "./context/ILocation"; +import { IOperatingSystem } from "./context/IOperatingSystem"; +import { ISession } from "./context/ISession"; +import { ISessionManager } from "./context/ISessionManager"; +import { ITelemetryTrace } from "./context/ITelemetryTrace"; +import { IUserContext } from "./context/IUser"; +import { IWeb } from "./context/IWeb"; export interface ITelemetryContext { /** diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/ITelemetryInitializers.ts b/shared/AppInsightsCore/src/interfaces/ai/ITelemetryInitializers.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/ITelemetryInitializers.ts rename to shared/AppInsightsCore/src/interfaces/ai/ITelemetryInitializers.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/ITelemetryItem.ts b/shared/AppInsightsCore/src/interfaces/ai/ITelemetryItem.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/ITelemetryItem.ts rename to shared/AppInsightsCore/src/interfaces/ai/ITelemetryItem.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/ITelemetryPlugin.ts b/shared/AppInsightsCore/src/interfaces/ai/ITelemetryPlugin.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/ITelemetryPlugin.ts rename to shared/AppInsightsCore/src/interfaces/ai/ITelemetryPlugin.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/ITelemetryPluginChain.ts b/shared/AppInsightsCore/src/interfaces/ai/ITelemetryPluginChain.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/ITelemetryPluginChain.ts rename to shared/AppInsightsCore/src/interfaces/ai/ITelemetryPluginChain.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/ITelemetryUnloadState.ts b/shared/AppInsightsCore/src/interfaces/ai/ITelemetryUnloadState.ts similarity index 72% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/ITelemetryUnloadState.ts rename to shared/AppInsightsCore/src/interfaces/ai/ITelemetryUnloadState.ts index cf3640591..4ae741734 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/ITelemetryUnloadState.ts +++ b/shared/AppInsightsCore/src/interfaces/ai/ITelemetryUnloadState.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { TelemetryUnloadReason } from "../JavaScriptSDK.Enums/TelemetryUnloadReason"; +import { TelemetryUnloadReason } from "../../enums/ai/TelemetryUnloadReason"; export interface ITelemetryUnloadState { reason: TelemetryUnloadReason; diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/ITelemetryUpdateState.ts b/shared/AppInsightsCore/src/interfaces/ai/ITelemetryUpdateState.ts similarity index 93% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/ITelemetryUpdateState.ts rename to shared/AppInsightsCore/src/interfaces/ai/ITelemetryUpdateState.ts index dc621366a..1cab0e568 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/ITelemetryUpdateState.ts +++ b/shared/AppInsightsCore/src/interfaces/ai/ITelemetryUpdateState.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { TelemetryUpdateReason } from "../JavaScriptSDK.Enums/TelemetryUpdateReason"; +import { TelemetryUpdateReason } from "../../enums/ai/TelemetryUpdateReason"; import { IConfiguration } from "./IConfiguration"; import { IPlugin } from "./ITelemetryPlugin"; diff --git a/shared/AppInsightsCommon/src/Interfaces/IThrottleMgr.ts b/shared/AppInsightsCore/src/interfaces/ai/IThrottleMgr.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/IThrottleMgr.ts rename to shared/AppInsightsCore/src/interfaces/ai/IThrottleMgr.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/ITraceParent.ts b/shared/AppInsightsCore/src/interfaces/ai/ITraceParent.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/ITraceParent.ts rename to shared/AppInsightsCore/src/interfaces/ai/ITraceParent.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/ITraceProvider.ts b/shared/AppInsightsCore/src/interfaces/ai/ITraceProvider.ts similarity index 96% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/ITraceProvider.ts rename to shared/AppInsightsCore/src/interfaces/ai/ITraceProvider.ts index 655bc355d..80ccb630d 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/ITraceProvider.ts +++ b/shared/AppInsightsCore/src/interfaces/ai/ITraceProvider.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { IOTelApi } from "../OpenTelemetry/interfaces/IOTelApi"; -import { IOTelSpanOptions } from "../OpenTelemetry/interfaces/trace/IOTelSpanOptions"; -import { IReadableSpan } from "../OpenTelemetry/interfaces/trace/IReadableSpan"; +import { IOTelApi } from "../otel/IOTelApi"; +import { IOTelSpanOptions } from "../otel/trace/IOTelSpanOptions"; +import { IReadableSpan } from "../otel/trace/IReadableSpan"; import { IConfiguration } from "./IConfiguration"; import { IDistributedTraceContext } from "./IDistributedTraceContext"; diff --git a/shared/AppInsightsCommon/src/Interfaces/ITraceTelemetry.ts b/shared/AppInsightsCore/src/interfaces/ai/ITraceTelemetry.ts similarity index 89% rename from shared/AppInsightsCommon/src/Interfaces/ITraceTelemetry.ts rename to shared/AppInsightsCore/src/interfaces/ai/ITraceTelemetry.ts index 2c188d8e1..d4e2e38ef 100644 --- a/shared/AppInsightsCommon/src/Interfaces/ITraceTelemetry.ts +++ b/shared/AppInsightsCore/src/interfaces/ai/ITraceTelemetry.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { SeverityLevel } from "./Contracts/SeverityLevel"; import { IPartC } from "./IPartC"; +import { SeverityLevel } from "./contracts/SeverityLevel"; export interface ITraceTelemetry extends IPartC { /** diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IUnloadHook.ts b/shared/AppInsightsCore/src/interfaces/ai/IUnloadHook.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IUnloadHook.ts rename to shared/AppInsightsCore/src/interfaces/ai/IUnloadHook.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IUnloadableComponent.ts b/shared/AppInsightsCore/src/interfaces/ai/IUnloadableComponent.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IUnloadableComponent.ts rename to shared/AppInsightsCore/src/interfaces/ai/IUnloadableComponent.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IW3cTraceState.ts b/shared/AppInsightsCore/src/interfaces/ai/IW3cTraceState.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IW3cTraceState.ts rename to shared/AppInsightsCore/src/interfaces/ai/IW3cTraceState.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IXDomainRequest.ts b/shared/AppInsightsCore/src/interfaces/ai/IXDomainRequest.ts similarity index 100% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IXDomainRequest.ts rename to shared/AppInsightsCore/src/interfaces/ai/IXDomainRequest.ts diff --git a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IXHROverride.ts b/shared/AppInsightsCore/src/interfaces/ai/IXHROverride.ts similarity index 94% rename from shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IXHROverride.ts rename to shared/AppInsightsCore/src/interfaces/ai/IXHROverride.ts index 4d34a9d49..e8946434d 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IXHROverride.ts +++ b/shared/AppInsightsCore/src/interfaces/ai/IXHROverride.ts @@ -1,5 +1,5 @@ import { IPromise } from "@nevware21/ts-async"; -import { SendRequestReason } from "../applicationinsights-core-js"; +import { SendRequestReason } from "../../enums/ai/SendRequestReason"; /** IPayloadData describes interface of payload sent via POST channel */ export interface IPayloadData { diff --git a/shared/AppInsightsCommon/src/Interfaces/PartAExtensions.ts b/shared/AppInsightsCore/src/interfaces/ai/PartAExtensions.ts similarity index 81% rename from shared/AppInsightsCommon/src/Interfaces/PartAExtensions.ts rename to shared/AppInsightsCore/src/interfaces/ai/PartAExtensions.ts index 361ea70fe..771cd4eb5 100644 --- a/shared/AppInsightsCommon/src/Interfaces/PartAExtensions.ts +++ b/shared/AppInsightsCore/src/interfaces/ai/PartAExtensions.ts @@ -1,4 +1,4 @@ -import { ContextTagKeys } from "./Contracts/ContextTagKeys"; +import { ContextTagKeys } from "./contracts/ContextTagKeys"; export const Extensions = { UserExt: "user", diff --git a/shared/AppInsightsCommon/src/Interfaces/Context/IApplication.ts b/shared/AppInsightsCore/src/interfaces/ai/context/IApplication.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Context/IApplication.ts rename to shared/AppInsightsCore/src/interfaces/ai/context/IApplication.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Context/IDevice.ts b/shared/AppInsightsCore/src/interfaces/ai/context/IDevice.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Context/IDevice.ts rename to shared/AppInsightsCore/src/interfaces/ai/context/IDevice.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Context/IInternal.ts b/shared/AppInsightsCore/src/interfaces/ai/context/IInternal.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Context/IInternal.ts rename to shared/AppInsightsCore/src/interfaces/ai/context/IInternal.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Context/ILocation.ts b/shared/AppInsightsCore/src/interfaces/ai/context/ILocation.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Context/ILocation.ts rename to shared/AppInsightsCore/src/interfaces/ai/context/ILocation.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Context/IOperatingSystem.ts b/shared/AppInsightsCore/src/interfaces/ai/context/IOperatingSystem.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Context/IOperatingSystem.ts rename to shared/AppInsightsCore/src/interfaces/ai/context/IOperatingSystem.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Context/ISample.ts b/shared/AppInsightsCore/src/interfaces/ai/context/ISample.ts similarity index 76% rename from shared/AppInsightsCommon/src/Interfaces/Context/ISample.ts rename to shared/AppInsightsCore/src/interfaces/ai/context/ISample.ts index 2b60dad23..e322fbdae 100644 --- a/shared/AppInsightsCommon/src/Interfaces/Context/ISample.ts +++ b/shared/AppInsightsCore/src/interfaces/ai/context/ISample.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { ITelemetryItem } from "@microsoft/applicationinsights-core-js"; +import { ITelemetryItem } from "../ITelemetryItem"; export interface ISample { /** diff --git a/shared/AppInsightsCommon/src/Interfaces/Context/ISession.ts b/shared/AppInsightsCore/src/interfaces/ai/context/ISession.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Context/ISession.ts rename to shared/AppInsightsCore/src/interfaces/ai/context/ISession.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Context/ISessionManager.ts b/shared/AppInsightsCore/src/interfaces/ai/context/ISessionManager.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Context/ISessionManager.ts rename to shared/AppInsightsCore/src/interfaces/ai/context/ISessionManager.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Context/ITelemetryTrace.ts b/shared/AppInsightsCore/src/interfaces/ai/context/ITelemetryTrace.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Context/ITelemetryTrace.ts rename to shared/AppInsightsCore/src/interfaces/ai/context/ITelemetryTrace.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Context/IUser.ts b/shared/AppInsightsCore/src/interfaces/ai/context/IUser.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Context/IUser.ts rename to shared/AppInsightsCore/src/interfaces/ai/context/IUser.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Context/IWeb.ts b/shared/AppInsightsCore/src/interfaces/ai/context/IWeb.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Context/IWeb.ts rename to shared/AppInsightsCore/src/interfaces/ai/context/IWeb.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Contracts/AvailabilityData.ts b/shared/AppInsightsCore/src/interfaces/ai/contracts/AvailabilityData.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Contracts/AvailabilityData.ts rename to shared/AppInsightsCore/src/interfaces/ai/contracts/AvailabilityData.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Contracts/ContextTagKeys.ts b/shared/AppInsightsCore/src/interfaces/ai/contracts/ContextTagKeys.ts similarity index 99% rename from shared/AppInsightsCommon/src/Interfaces/Contracts/ContextTagKeys.ts rename to shared/AppInsightsCore/src/interfaces/ai/contracts/ContextTagKeys.ts index 76c0d766b..4576d2d54 100644 --- a/shared/AppInsightsCommon/src/Interfaces/Contracts/ContextTagKeys.ts +++ b/shared/AppInsightsCore/src/interfaces/ai/contracts/ContextTagKeys.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { createClassFromInterface } from "@microsoft/applicationinsights-core-js"; +import { createClassFromInterface } from "../../../utils/HelperFuncs"; function _aiNameFunc(baseName: string) { let aiName = "ai." + baseName + "."; @@ -227,7 +227,6 @@ export interface IContextTagKeys { readonly internalSdkSrc: string; } -/*#__NO_SIDE_EFFECTS__*/ export class ContextTagKeys extends createClassFromInterface({ applicationVersion: _aiApplication("ver"), applicationBuild: _aiApplication("build"), diff --git a/shared/AppInsightsCommon/src/Interfaces/Contracts/DataPointType.ts b/shared/AppInsightsCore/src/interfaces/ai/contracts/DataPointType.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Contracts/DataPointType.ts rename to shared/AppInsightsCore/src/interfaces/ai/contracts/DataPointType.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Contracts/DependencyKind.ts b/shared/AppInsightsCore/src/interfaces/ai/contracts/DependencyKind.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Contracts/DependencyKind.ts rename to shared/AppInsightsCore/src/interfaces/ai/contracts/DependencyKind.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Contracts/DependencySourceType.ts b/shared/AppInsightsCore/src/interfaces/ai/contracts/DependencySourceType.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Contracts/DependencySourceType.ts rename to shared/AppInsightsCore/src/interfaces/ai/contracts/DependencySourceType.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Contracts/IBase.ts b/shared/AppInsightsCore/src/interfaces/ai/contracts/IBase.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Contracts/IBase.ts rename to shared/AppInsightsCore/src/interfaces/ai/contracts/IBase.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Contracts/IData.ts b/shared/AppInsightsCore/src/interfaces/ai/contracts/IData.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Contracts/IData.ts rename to shared/AppInsightsCore/src/interfaces/ai/contracts/IData.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Contracts/IDataPoint.ts b/shared/AppInsightsCore/src/interfaces/ai/contracts/IDataPoint.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Contracts/IDataPoint.ts rename to shared/AppInsightsCore/src/interfaces/ai/contracts/IDataPoint.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Contracts/IDomain.ts b/shared/AppInsightsCore/src/interfaces/ai/contracts/IDomain.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Contracts/IDomain.ts rename to shared/AppInsightsCore/src/interfaces/ai/contracts/IDomain.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Contracts/IEnvelope.ts b/shared/AppInsightsCore/src/interfaces/ai/contracts/IEnvelope.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Contracts/IEnvelope.ts rename to shared/AppInsightsCore/src/interfaces/ai/contracts/IEnvelope.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Contracts/IEventData.ts b/shared/AppInsightsCore/src/interfaces/ai/contracts/IEventData.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Contracts/IEventData.ts rename to shared/AppInsightsCore/src/interfaces/ai/contracts/IEventData.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Contracts/IExceptionData.ts b/shared/AppInsightsCore/src/interfaces/ai/contracts/IExceptionData.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Contracts/IExceptionData.ts rename to shared/AppInsightsCore/src/interfaces/ai/contracts/IExceptionData.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Contracts/IExceptionDetails.ts b/shared/AppInsightsCore/src/interfaces/ai/contracts/IExceptionDetails.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Contracts/IExceptionDetails.ts rename to shared/AppInsightsCore/src/interfaces/ai/contracts/IExceptionDetails.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Contracts/IMessageData.ts b/shared/AppInsightsCore/src/interfaces/ai/contracts/IMessageData.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Contracts/IMessageData.ts rename to shared/AppInsightsCore/src/interfaces/ai/contracts/IMessageData.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Contracts/IMetricData.ts b/shared/AppInsightsCore/src/interfaces/ai/contracts/IMetricData.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Contracts/IMetricData.ts rename to shared/AppInsightsCore/src/interfaces/ai/contracts/IMetricData.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Contracts/IPageViewData.ts b/shared/AppInsightsCore/src/interfaces/ai/contracts/IPageViewData.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Contracts/IPageViewData.ts rename to shared/AppInsightsCore/src/interfaces/ai/contracts/IPageViewData.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Contracts/IPageViewPerfData.ts b/shared/AppInsightsCore/src/interfaces/ai/contracts/IPageViewPerfData.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Contracts/IPageViewPerfData.ts rename to shared/AppInsightsCore/src/interfaces/ai/contracts/IPageViewPerfData.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Contracts/IRemoteDependencyData.ts b/shared/AppInsightsCore/src/interfaces/ai/contracts/IRemoteDependencyData.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Contracts/IRemoteDependencyData.ts rename to shared/AppInsightsCore/src/interfaces/ai/contracts/IRemoteDependencyData.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Contracts/IStackFrame.ts b/shared/AppInsightsCore/src/interfaces/ai/contracts/IStackFrame.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Contracts/IStackFrame.ts rename to shared/AppInsightsCore/src/interfaces/ai/contracts/IStackFrame.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Contracts/SeverityLevel.ts b/shared/AppInsightsCore/src/interfaces/ai/contracts/SeverityLevel.ts similarity index 90% rename from shared/AppInsightsCommon/src/Interfaces/Contracts/SeverityLevel.ts rename to shared/AppInsightsCore/src/interfaces/ai/contracts/SeverityLevel.ts index fba12fca0..f9b2dc795 100644 --- a/shared/AppInsightsCommon/src/Interfaces/Contracts/SeverityLevel.ts +++ b/shared/AppInsightsCore/src/interfaces/ai/contracts/SeverityLevel.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { createEnumStyle } from "@microsoft/applicationinsights-core-js"; +import { createEnumStyle } from "../../../enums/EnumHelperFuncs"; /** * Defines the level of severity for the event. diff --git a/shared/AppInsightsCommon/src/Interfaces/Telemetry/IEnvelope.ts b/shared/AppInsightsCore/src/interfaces/ai/telemetry/IEnvelope.ts similarity index 100% rename from shared/AppInsightsCommon/src/Interfaces/Telemetry/IEnvelope.ts rename to shared/AppInsightsCore/src/interfaces/ai/telemetry/IEnvelope.ts diff --git a/shared/AppInsightsCommon/src/Interfaces/Telemetry/ISerializable.ts b/shared/AppInsightsCore/src/interfaces/ai/telemetry/ISerializable.ts similarity index 88% rename from shared/AppInsightsCommon/src/Interfaces/Telemetry/ISerializable.ts rename to shared/AppInsightsCore/src/interfaces/ai/telemetry/ISerializable.ts index 36f6b61ce..a203e5ebb 100644 --- a/shared/AppInsightsCommon/src/Interfaces/Telemetry/ISerializable.ts +++ b/shared/AppInsightsCore/src/interfaces/ai/telemetry/ISerializable.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { FieldType } from "../../Enums"; +import { FieldType } from "../../../enums/ai/Enums"; export interface ISerializable { /** diff --git a/shared/AppInsightsCore/src/Config/IConfigDefaults.ts b/shared/AppInsightsCore/src/interfaces/config/IConfigDefaults.ts similarity index 97% rename from shared/AppInsightsCore/src/Config/IConfigDefaults.ts rename to shared/AppInsightsCore/src/interfaces/config/IConfigDefaults.ts index be5eba12f..d9a9b5240 100644 --- a/shared/AppInsightsCore/src/Config/IConfigDefaults.ts +++ b/shared/AppInsightsCore/src/interfaces/config/IConfigDefaults.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration"; +import { IConfiguration } from "../ai/IConfiguration"; /** * The type to identify whether the default value should be applied in preference to the provided value. diff --git a/shared/AppInsightsCore/src/Config/IDynamicConfigHandler.ts b/shared/AppInsightsCore/src/interfaces/config/IDynamicConfigHandler.ts similarity index 96% rename from shared/AppInsightsCore/src/Config/IDynamicConfigHandler.ts rename to shared/AppInsightsCore/src/interfaces/config/IDynamicConfigHandler.ts index 4c98979fa..878fdbb01 100644 --- a/shared/AppInsightsCore/src/Config/IDynamicConfigHandler.ts +++ b/shared/AppInsightsCore/src/interfaces/config/IDynamicConfigHandler.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration"; -import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger"; +import { IConfiguration } from "../ai/IConfiguration"; +import { IDiagnosticLogger } from "../ai/IDiagnosticLogger"; import { IConfigDefaults } from "./IConfigDefaults"; import { IWatcherHandler, WatcherFunction } from "./IDynamicWatcher"; @@ -109,4 +109,4 @@ export interface _IInternalDynamicConfigHandler extends IDyn * @param allowUpdate - An optional flag to enable updating config properties marked as readonly */ _block: (configHandler: WatcherFunction, allowUpdate?: boolean) => void; -} \ No newline at end of file +} diff --git a/shared/AppInsightsCore/src/Config/IDynamicPropertyHandler.ts b/shared/AppInsightsCore/src/interfaces/config/IDynamicPropertyHandler.ts similarity index 85% rename from shared/AppInsightsCore/src/Config/IDynamicPropertyHandler.ts rename to shared/AppInsightsCore/src/interfaces/config/IDynamicPropertyHandler.ts index 9195c41c2..1aa61d2ae 100644 --- a/shared/AppInsightsCore/src/Config/IDynamicPropertyHandler.ts +++ b/shared/AppInsightsCore/src/interfaces/config/IDynamicPropertyHandler.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration"; +import { IConfiguration } from "../ai/IConfiguration"; import { IWatcherHandler } from "./IDynamicWatcher"; export interface IDynamicPropertyHandler { @@ -14,4 +14,4 @@ export interface IDynamicPropertyHandler { * The current collection is watcher handlers which should be called if the value changes */ h: IWatcherHandler[]; -} \ No newline at end of file +} diff --git a/shared/AppInsightsCore/src/Config/IDynamicWatcher.ts b/shared/AppInsightsCore/src/interfaces/config/IDynamicWatcher.ts similarity index 94% rename from shared/AppInsightsCore/src/Config/IDynamicWatcher.ts rename to shared/AppInsightsCore/src/interfaces/config/IDynamicWatcher.ts index 88c458467..2392c3e42 100644 --- a/shared/AppInsightsCore/src/Config/IDynamicWatcher.ts +++ b/shared/AppInsightsCore/src/interfaces/config/IDynamicWatcher.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration"; -import { IUnloadHook } from "../JavaScriptSDK.Interfaces/IUnloadHook"; +import { IConfiguration } from "../ai/IConfiguration"; +import { IUnloadHook } from "../ai/IUnloadHook"; import { IConfigDefaults } from "./IConfigDefaults"; import { IDynamicPropertyHandler } from "./IDynamicPropertyHandler"; diff --git a/shared/AppInsightsCore/src/Config/_IDynamicConfigHandlerState.ts b/shared/AppInsightsCore/src/interfaces/config/_IDynamicConfigHandlerState.ts similarity index 100% rename from shared/AppInsightsCore/src/Config/_IDynamicConfigHandlerState.ts rename to shared/AppInsightsCore/src/interfaces/config/_IDynamicConfigHandlerState.ts diff --git a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/IOTelApi.ts b/shared/AppInsightsCore/src/interfaces/otel/IOTelApi.ts similarity index 92% rename from shared/AppInsightsCore/src/OpenTelemetry/interfaces/IOTelApi.ts rename to shared/AppInsightsCore/src/interfaces/otel/IOTelApi.ts index 26c0cd1f1..95055cef5 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/IOTelApi.ts +++ b/shared/AppInsightsCore/src/interfaces/otel/IOTelApi.ts @@ -1,34 +1,34 @@ -import { ITraceHost } from "../../applicationinsights-core-js"; +import { ITraceHost } from "../ai/ITraceProvider"; import { IOTelConfig } from "./config/IOTelConfig"; +import { ITraceApi } from "./trace/IOTelTraceApi"; import { IOTelTracerProvider } from "./trace/IOTelTracerProvider"; -import { ITraceApi } from "./trace/ITraceApi"; /** * The main OpenTelemetry API interface that provides access to all OpenTelemetry functionality. * This interface extends the IOTelTracerProvider and serves as the entry point for OpenTelemetry operations. - * + * * @example * ```typescript * // Get a tracer from the API instance * const tracer = otelApi.getTracer("my-component"); - * + * * // Create a span * const span = tracer.startSpan("operation"); - * + * * // Access context manager * const currentContext = otelApi.context.active(); - * + * * // Access trace API * const activeSpan = otelApi.trace.getActiveSpan(); * ``` - * + * * @since 3.4.0 */ export interface IOTelApi extends IOTelTracerProvider { /** * The configuration object that contains all OpenTelemetry-specific settings. * This includes tracing configuration, error handlers, and other OpenTelemetry options. - * + * * @remarks * Changes to this configuration after initialization may not take effect until * the next telemetry operation, depending on the implementation. diff --git a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/IOTelApiCtx.ts b/shared/AppInsightsCore/src/interfaces/otel/IOTelApiCtx.ts similarity index 85% rename from shared/AppInsightsCore/src/OpenTelemetry/interfaces/IOTelApiCtx.ts rename to shared/AppInsightsCore/src/interfaces/otel/IOTelApiCtx.ts index fae0cbc6a..07f2d4b55 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/IOTelApiCtx.ts +++ b/shared/AppInsightsCore/src/interfaces/otel/IOTelApiCtx.ts @@ -1,4 +1,4 @@ -import { ITraceHost } from "../../JavaScriptSDK.Interfaces/ITraceProvider"; +import { ITraceHost } from "../ai/ITraceProvider"; /** * The context for the current IOTelApi instance linking it to the core SDK instance, diff --git a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/IOTelAttributes.ts b/shared/AppInsightsCore/src/interfaces/otel/IOTelAttributes.ts similarity index 100% rename from shared/AppInsightsCore/src/OpenTelemetry/interfaces/IOTelAttributes.ts rename to shared/AppInsightsCore/src/interfaces/otel/IOTelAttributes.ts diff --git a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/IOTelException.ts b/shared/AppInsightsCore/src/interfaces/otel/IOTelException.ts similarity index 100% rename from shared/AppInsightsCore/src/OpenTelemetry/interfaces/IOTelException.ts rename to shared/AppInsightsCore/src/interfaces/otel/IOTelException.ts diff --git a/shared/AppInsightsCore/src/OpenTelemetry/attribute/IAttributeContainer.ts b/shared/AppInsightsCore/src/interfaces/otel/attribute/IAttributeContainer.ts similarity index 97% rename from shared/AppInsightsCore/src/OpenTelemetry/attribute/IAttributeContainer.ts rename to shared/AppInsightsCore/src/interfaces/otel/attribute/IAttributeContainer.ts index 9cbd6eaf3..06a17d3e4 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/attribute/IAttributeContainer.ts +++ b/shared/AppInsightsCore/src/interfaces/otel/attribute/IAttributeContainer.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { IUnloadHook } from "../../JavaScriptSDK.Interfaces/IUnloadHook"; -import { eAttributeChangeOp } from "../enums/eAttributeChangeOp"; -import { IOTelAttributes, OTelAttributeValue } from "../interfaces/IOTelAttributes"; +import { eAttributeChangeOp } from "../../../enums/otel/eAttributeChangeOp"; +import { IUnloadHook } from "../../ai/IUnloadHook"; +import { IOTelAttributes, OTelAttributeValue } from "../IOTelAttributes"; /** * Identifies the source of an attribute value in iterator operations diff --git a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/config/IOTelAttributeLimits.ts b/shared/AppInsightsCore/src/interfaces/otel/config/IOTelAttributeLimits.ts similarity index 97% rename from shared/AppInsightsCore/src/OpenTelemetry/interfaces/config/IOTelAttributeLimits.ts rename to shared/AppInsightsCore/src/interfaces/otel/config/IOTelAttributeLimits.ts index a2392d696..702315f97 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/config/IOTelAttributeLimits.ts +++ b/shared/AppInsightsCore/src/interfaces/otel/config/IOTelAttributeLimits.ts @@ -4,7 +4,7 @@ * Configuration interface for OpenTelemetry attribute limits. * These limits help control the size and number of attributes to prevent * excessive memory usage and ensure consistent performance. - * + * * @example * ```typescript * const limits: IOTelAttributeLimits = { @@ -12,27 +12,27 @@ * attributeValueLengthLimit: 4096 // Maximum 4KB per attribute value * }; * ``` - * + * * @remarks * When limits are exceeded: * - Additional attributes beyond `attributeCountLimit` are dropped * - Attribute values longer than `attributeValueLengthLimit` are truncated * - The behavior may vary based on the specific implementation - * + * * @since 3.4.0 */ export interface IOTelAttributeLimits { /** * Maximum allowed length for attribute values in characters. - * + * * @remarks * - Values longer than this limit will be truncated * - Applies to string attribute values only * - Numeric and boolean values are not affected by this limit * - Array values have this limit applied to each individual element - * + * * @defaultValue 4096 - * + * * @example * ```typescript * // If attributeValueLengthLimit is 100: @@ -45,15 +45,15 @@ export interface IOTelAttributeLimits { /** * Maximum number of attributes allowed per telemetry item. - * + * * @remarks * - Attributes added beyond this limit will be dropped * - The order of attributes matters; earlier attributes take precedence * - This limit applies to the total count of attributes, regardless of their type * - Inherited or default attributes count toward this limit - * + * * @defaultValue 128 - * + * * @example * ```typescript * // If attributeCountLimit is 5: diff --git a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/config/IOTelConfig.ts b/shared/AppInsightsCore/src/interfaces/otel/config/IOTelConfig.ts similarity index 97% rename from shared/AppInsightsCore/src/OpenTelemetry/interfaces/config/IOTelConfig.ts rename to shared/AppInsightsCore/src/interfaces/otel/config/IOTelConfig.ts index ce6269f1d..f264d7215 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/config/IOTelConfig.ts +++ b/shared/AppInsightsCore/src/interfaces/otel/config/IOTelConfig.ts @@ -1,5 +1,5 @@ import { IOTelErrorHandlers } from "./IOTelErrorHandlers"; -import { ITraceCfg } from "./ITraceCfg"; +import { ITraceCfg } from "./IOTelTraceCfg"; /** * OpenTelemetry configuration interface diff --git a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/config/IOTelErrorHandlers.ts b/shared/AppInsightsCore/src/interfaces/otel/config/IOTelErrorHandlers.ts similarity index 96% rename from shared/AppInsightsCore/src/OpenTelemetry/interfaces/config/IOTelErrorHandlers.ts rename to shared/AppInsightsCore/src/interfaces/otel/config/IOTelErrorHandlers.ts index 0d8a72d52..6688c287a 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/config/IOTelErrorHandlers.ts +++ b/shared/AppInsightsCore/src/interfaces/otel/config/IOTelErrorHandlers.ts @@ -4,7 +4,7 @@ * Configuration interface for OpenTelemetry error handling callbacks. * Provides hooks to customize how different types of errors and diagnostic * messages are handled within the OpenTelemetry system. - * + * * @example * ```typescript * const errorHandlers: IOTelErrorHandlers = { @@ -22,7 +22,7 @@ * } * }; * ``` - * + * * @remarks * If handlers are not provided, default behavior will be used: * - `attribError`: Throws an `OTelInvalidAttributeError` @@ -31,27 +31,27 @@ * - `warn`: Logs to console.warn * - `error`: Logs to console.error * - `notImplemented`: Logs to console.error - * + * * @since 3.4.0 */ export interface IOTelErrorHandlers { /** * Handles attribute-related errors, such as invalid attribute values or keys. * Called when an attribute operation fails validation or processing. - * + * * @param message - Descriptive error message explaining what went wrong * @param key - The attribute key that caused the error * @param value - The attribute value that caused the error (may be of any type) - * + * * @remarks * Common scenarios that trigger this handler: * - Invalid attribute key format * - Attribute value exceeds length limits * - Unsupported attribute value type * - Attribute count exceeds limits - * + * * @default Throws an `OTelInvalidAttributeError` - * + * * @example * ```typescript * attribError: (message, key, value) => { @@ -65,19 +65,19 @@ export interface IOTelErrorHandlers { /** * Handles span-related errors that occur during span operations. * Called when a span operation fails or encounters an unexpected condition. - * + * * @param message - Descriptive error message explaining the span error * @param spanName - The name of the span that encountered the error - * + * * @remarks * Common scenarios that trigger this handler: * - Span operation called on an ended span * - Invalid span configuration * - Span processor errors * - Context propagation failures - * + * * @default Logs to console or calls the warn handler - * + * * @example * ```typescript * spanError: (message, spanName) => { @@ -92,18 +92,18 @@ export interface IOTelErrorHandlers { * Handles debug-level diagnostic messages. * Used for detailed troubleshooting information that is typically * only relevant during development or when diagnosing issues. - * + * * @param message - Debug message to be handled - * + * * @remarks * Debug messages are typically: * - Verbose operational details * - Internal state information * - Performance metrics * - Development-time diagnostics - * + * * @default Logs to console.log - * + * * @example * ```typescript * debug: (message) => { @@ -118,18 +118,18 @@ export interface IOTelErrorHandlers { /** * Handles warning-level messages for non-fatal issues. * Used for conditions that are unusual but don't prevent continued operation. - * + * * @param message - Warning message to be handled - * + * * @remarks * Warning scenarios include: * - Configuration issues that fall back to defaults * - Performance degradation * - Deprecated API usage * - Resource limit approaches - * + * * @default Logs to console.warn - * + * * @example * ```typescript * warn: (message) => { @@ -143,18 +143,18 @@ export interface IOTelErrorHandlers { /** * Handles general error conditions that may affect functionality. * Used for significant errors that should be investigated but may not be fatal. - * + * * @param message - Error message to be handled - * + * * @remarks * Error scenarios include: * - Failed network requests * - Configuration validation failures * - Resource allocation failures * - Unexpected runtime conditions - * + * * @default Logs to console.error - * + * * @example * ```typescript * error: (message) => { @@ -169,18 +169,18 @@ export interface IOTelErrorHandlers { * Handles errors related to unimplemented functionality. * Called when a method or feature is not yet implemented or is intentionally * disabled in the current configuration. - * + * * @param message - Message describing the unimplemented functionality - * + * * @remarks * Common scenarios: * - Placeholder methods that haven't been implemented * - Features disabled in the current build * - Platform-specific functionality not available * - Optional features not included in the configuration - * + * * @default Logs to console.error - * + * * @example * ```typescript * notImplemented: (message) => { diff --git a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/config/IOTelSpanLimits.ts b/shared/AppInsightsCore/src/interfaces/otel/config/IOTelSpanLimits.ts similarity index 95% rename from shared/AppInsightsCore/src/OpenTelemetry/interfaces/config/IOTelSpanLimits.ts rename to shared/AppInsightsCore/src/interfaces/otel/config/IOTelSpanLimits.ts index 38abb2b97..14e189630 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/config/IOTelSpanLimits.ts +++ b/shared/AppInsightsCore/src/interfaces/otel/config/IOTelSpanLimits.ts @@ -4,14 +4,14 @@ // * Configuration interface for OpenTelemetry span-specific limits. // * Extends the general attribute limits with additional constraints specific to spans, // * including limits on events, links, and their associated attributes. -// * +// * // * @example // * ```typescript // * const spanLimits: IOTelSpanLimits = { // * // Inherited from IOTelAttributeLimits // * attributeCountLimit: 128, // * attributeValueLengthLimit: 4096, -// * +// * // * // Span-specific limits // * linkCountLimit: 128, // * eventCountLimit: 128, @@ -19,27 +19,27 @@ // * attributePerLinkCountLimit: 32 // * }; // * ``` -// * +// * // * @remarks // * These limits help prevent spans from consuming excessive memory and ensure // * consistent performance even when dealing with complex traces that have many // * events, links, or attributes. -// * +// * // * @since 3.4.0 // */ // export interface IOTelSpanLimits extends IOTelAttributeLimits { // /** // * Maximum number of links allowed per span. -// * +// * // * @remarks // * - Links added beyond this limit will be dropped // * - Links are typically added at span creation time // * - Each link represents a causal relationship with another span // * - Links added after creation may be subject to additional restrictions -// * +// * // * @defaultValue 128 -// * +// * // * @example // * ```typescript // * const span = tracer.startSpan("operation", { @@ -55,20 +55,20 @@ // /** // * Maximum number of events allowed per span. -// * +// * // * @remarks // * - Events added beyond this limit will be dropped // * - Events are typically used to mark significant points during span execution // * - Each event can have its own set of attributes (limited by attributePerEventCountLimit) // * - Events are ordered chronologically within the span -// * +// * // * @defaultValue 128 -// * +// * // * @example // * ```typescript // * // If eventCountLimit is 3: // * span.addEvent("started"); // Kept -// * span.addEvent("processing"); // Kept +// * span.addEvent("processing"); // Kept // * span.addEvent("validation"); // Kept // * span.addEvent("completed"); // Dropped (exceeds limit) // * ``` @@ -77,15 +77,15 @@ // /** // * Maximum number of attributes allowed per span event. -// * +// * // * @remarks // * - This limit applies to each individual event within a span // * - Attributes added to events beyond this limit will be dropped // * - This is separate from the span's own attribute limits // * - Event attributes are useful for providing context about what happened at that point in time -// * +// * // * @defaultValue 32 -// * +// * // * @example // * ```typescript // * // If attributePerEventCountLimit is 2: @@ -100,15 +100,15 @@ // /** // * Maximum number of attributes allowed per span link. -// * +// * // * @remarks // * - This limit applies to each individual link within a span // * - Attributes added to links beyond this limit will be dropped // * - This is separate from the span's own attribute limits // * - Link attributes provide additional context about the relationship between spans -// * +// * // * @defaultValue 32 -// * +// * // * @example // * ```typescript // * // If attributePerLinkCountLimit is 2: diff --git a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/config/ITraceCfg.ts b/shared/AppInsightsCore/src/interfaces/otel/config/IOTelTraceCfg.ts similarity index 98% rename from shared/AppInsightsCore/src/OpenTelemetry/interfaces/config/ITraceCfg.ts rename to shared/AppInsightsCore/src/interfaces/otel/config/IOTelTraceCfg.ts index c1e3a8a9b..7f6b96ea8 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/config/ITraceCfg.ts +++ b/shared/AppInsightsCore/src/interfaces/otel/config/IOTelTraceCfg.ts @@ -4,7 +4,7 @@ import { IOTelAttributeLimits } from "./IOTelAttributeLimits"; * Configuration interface for OpenTelemetry compatible tracing functionality. * This interface contains all the settings that control how traces are created, * processed, and managed within the OpenTelemetry system. - * + * * @example * ```typescript * const traceCfg: ITraceCfg = { @@ -20,7 +20,7 @@ import { IOTelAttributeLimits } from "./IOTelAttributeLimits"; * } * }; * ``` - * + * * @since 3.4.0 */ export interface ITraceCfg { @@ -28,7 +28,7 @@ export interface ITraceCfg { * Global attribute limits that apply to all telemetry items. * These limits help prevent excessive memory usage and ensure consistent * behavior across different telemetry types. - * + * * @remarks * These limits are inherited by more specific configurations unless overridden. * For example, spans will use these limits unless `spanLimits` specifies different values. @@ -38,7 +38,7 @@ export interface ITraceCfg { // /** // * Specific limits that apply only to spans. // * These limits override the general limits for span-specific properties. - // * + // * // * @remarks // * Includes limits for attributes, events, links, and their associated attributes. // * This allows for fine-tuned control over span size and complexity. @@ -57,12 +57,12 @@ export interface ITraceCfg { /** * The name of the service generating telemetry data. * This name will be included in all telemetry items as a resource attribute. - * + * * @remarks * The service name is crucial for identifying and filtering telemetry data * in observability systems. It should be consistent across all instances * of the same service. - * + * * @example * ```typescript * serviceName: "user-authentication-service" diff --git a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/trace/IOTelSpan.ts b/shared/AppInsightsCore/src/interfaces/otel/trace/IOTelSpan.ts similarity index 92% rename from shared/AppInsightsCore/src/OpenTelemetry/interfaces/trace/IOTelSpan.ts rename to shared/AppInsightsCore/src/interfaces/otel/trace/IOTelSpan.ts index 468f30ce7..250a3314c 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/trace/IOTelSpan.ts +++ b/shared/AppInsightsCore/src/interfaces/otel/trace/IOTelSpan.ts @@ -1,47 +1,48 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { IAttributeContainer, IDistributedTraceContext } from "../../../applicationinsights-core-js"; +import { OTelTimeInput } from "../../IOTelHrTime"; +import { IDistributedTraceContext } from "../../ai/IDistributedTraceContext"; import { IOTelAttributes, OTelAttributeValue } from "../IOTelAttributes"; import { OTelException } from "../IOTelException"; -import { OTelTimeInput } from "../IOTelHrTime"; +import { IAttributeContainer } from "../attribute/IAttributeContainer"; import { IOTelSpanStatus } from "./IOTelSpanStatus"; /** * Provides an OpenTelemetry compatible interface for spans conforming to the OpenTelemetry API specification (v1.9.0). - * + * * A span represents an operation within a trace and is the fundamental unit of work in distributed tracing. * Spans can be thought of as a grouping mechanism for a set of operations that are executed as part of * a single logical unit of work, providing timing information and contextual data about the operation. - * + * * Spans form a tree structure within a trace, with a single root span that may have zero or more child spans, * which in turn may have their own children. This hierarchical structure allows for detailed analysis of * complex, multi-step operations across distributed systems. - * + * * @since 3.4.0 - * + * * @remarks * - All spans created by this library implement the ISpan interface and extend the IReadableSpan interface * - Spans should be ended by calling `end()` when the operation completes * - Once ended, spans should generally not be used for further operations * - Spans automatically track timing information from creation to end - * + * * @example * ```typescript * // Basic span usage * const span = tracer.startSpan('user-authentication'); * span.setAttribute('user.id', '12345'); * span.setAttribute('auth.method', 'oauth2'); - * + * * try { * const result = await authenticateUser(); * span.setStatus({ code: SpanStatusCode.OK }); * span.setAttribute('auth.success', true); * } catch (error) { * span.recordException(error); - * span.setStatus({ - * code: SpanStatusCode.ERROR, - * message: 'Authentication failed' + * span.setStatus({ + * code: SpanStatusCode.ERROR, + * message: 'Authentication failed' * }); * } finally { * span.end(); @@ -85,26 +86,26 @@ export interface IOTelSpan { /** * Sets a single attribute on the span with the specified key and value. - * + * * Attributes provide contextual information about the operation represented by the span. * They are key-value pairs that help with filtering, grouping, and understanding spans * in trace analysis tools. Attributes should represent meaningful properties of the operation. - * + * * @param key - The attribute key, should be descriptive and follow naming conventions * @param value - The attribute value; null or undefined values are invalid and result in undefined behavior - * + * * @returns This span instance for method chaining - * + * * @remarks * - Attribute keys should follow semantic conventions when available * - Common attributes include service.name, http.method, db.statement, etc. * - Setting null or undefined values is invalid and may cause unexpected behavior * - Attributes set after span creation don't affect sampling decisions - * + * * @example * ```typescript * const span = tracer.startSpan('http-request'); - * + * * // Set individual attributes with descriptive keys * span.setAttribute('http.method', 'POST') * .setAttribute('http.url', 'https://api.example.com/users') @@ -117,24 +118,24 @@ export interface IOTelSpan { /** * Sets multiple attributes on the span at once using an attributes object. - * + * * This method allows efficient batch setting of multiple attributes in a single call. * All attributes in the provided object will be added to the span, supplementing any * existing attributes (duplicate keys will be overwritten). - * + * * @param attributes - An object containing key-value pairs to set as span attributes - * + * * @returns This span instance for method chaining - * + * * @remarks * - Null or undefined attribute values are invalid and will result in undefined behavior * - More efficient than multiple `setAttribute` calls for bulk operations * - Existing attributes with the same keys will be overwritten - * + * * @example * ```typescript * const span = tracer.startSpan('database-query'); - * + * * // Set multiple attributes efficiently * span.setAttributes({ * 'db.system': 'postgresql', @@ -161,34 +162,34 @@ export interface IOTelSpan { // /** // * Adds an event to the span with optional attributes and timestamp. - // * + // * // * **Note: This method is currently not implemented and events will be dropped.** - // * + // * // * Events represent significant points in time during the span's execution. // * They provide additional context about what happened during the operation, // * such as cache hits/misses, validation steps, or other notable occurrences. - // * + // * // * @param name - The name of the event, should be descriptive of what occurred // * @param attributesOrStartTime - Event attributes object, or start time if third parameter is undefined // * @param startTime - Optional start time of the event; if not provided, current time is used - // * + // * // * @returns This span instance for method chaining - // * + // * // * @remarks // * - **Current implementation drops events - not yet supported** // * - Events are timestamped occurrences within a span's lifecycle // * - Useful for marking significant points like cache hits, retries, or validation steps // * - Should not be used for high-frequency events due to performance impact - // * + // * // * @example // * ```typescript // * const span = tracer.startSpan('user-registration'); - // * + // * // * // Add events to mark significant points // * span.addEvent('validation.started') - // * .addEvent('validation.completed', { + // * .addEvent('validation.completed', { // * 'validation.result': 'success', - // * 'validation.duration_ms': 23 + // * 'validation.duration_ms': 23 // * }) // * .addEvent('database.save.started') // * .addEvent('database.save.completed', { @@ -200,27 +201,27 @@ export interface IOTelSpan { // /** // * Adds a single link to the span connecting it to another span. - // * + // * // * **Note: This method is currently not implemented and links will be dropped.** - // * + // * // * Links establish relationships between spans that are not in a typical parent-child // * relationship. They are useful for connecting spans across different traces or // * for representing batch operations where multiple spans are related but not nested. - // * + // * // * @param link - The link object containing span context and optional attributes - // * + // * // * @returns This span instance for method chaining - // * + // * // * @remarks // * - **Current implementation drops links - not yet supported** // * - Links added after span creation do not affect sampling decisions // * - Prefer adding links during span creation when possible // * - Useful for batch operations, fan-out scenarios, or cross-trace relationships - // * + // * // * @example // * ```typescript // * const span = tracer.startSpan('batch-processor'); - // * + // * // * // Link to related spans from a batch operation // * span.addLink({ // * context: relatedSpan.spanContext(), @@ -235,27 +236,27 @@ export interface IOTelSpan { // /** // * Adds multiple links to the span in a single operation. - // * + // * // * **Note: This method is currently not implemented and links will be dropped.** - // * + // * // * This is an efficient way to establish multiple relationships between this span // * and other spans. Particularly useful for batch operations, fan-out scenarios, // * or when a single operation needs to reference multiple related operations. - // * + // * // * @param links - An array of link objects to add to the span - // * + // * // * @returns This span instance for method chaining - // * + // * // * @remarks // * - **Current implementation drops links - not yet supported** // * - More efficient than multiple `addLink` calls for bulk operations // * - Links added after span creation do not affect sampling decisions // * - Consider span creation time linking for sampling-sensitive scenarios - // * + // * // * @example // * ```typescript // * const span = tracer.startSpan('aggregate-results'); - // * + // * // * // Link to multiple related spans from parallel operations // * span.addLinks([ // * { @@ -263,7 +264,7 @@ export interface IOTelSpan { // * attributes: { 'operation.type': 'data_fetch', 'source': 'database' } // * }, // * { - // * context: span2.spanContext(), + // * context: span2.spanContext(), // * attributes: { 'operation.type': 'data_fetch', 'source': 'cache' } // * }, // * { @@ -277,41 +278,41 @@ export interface IOTelSpan { /** * Sets the status of the span to indicate the success or failure of the operation. - * + * * The span status provides a standardized way to indicate whether the operation * completed successfully, encountered an error, or is in an unknown state. * This status is used by observability tools to provide meaningful insights * about system health and operation outcomes. - * + * * @param status - The status object containing code and optional message - * + * * @returns This span instance for method chaining - * + * * @remarks * - Default status is UNSET until explicitly set * - Setting status overrides any previous status values * - ERROR status should be accompanied by a descriptive message when possible * - Status should reflect the final outcome of the operation - * + * * @example * ```typescript * const span = tracer.startSpan('payment-processing'); - * + * * try { * const result = await processPayment(paymentData); - * + * * // Indicate successful completion - * span.setStatus({ - * code: SpanStatusCode.OK + * span.setStatus({ + * code: SpanStatusCode.OK * }); - * + * * } catch (error) { * // Indicate operation failed - * span.setStatus({ - * code: SpanStatusCode.ERROR, - * message: 'Payment processing failed: ' + error.message + * span.setStatus({ + * code: SpanStatusCode.ERROR, + * message: 'Payment processing failed: ' + error.message * }); - * + * * span.recordException(error); * } * ``` @@ -320,26 +321,26 @@ export interface IOTelSpan { /** * Updates the name of the span, overriding the name provided during creation. - * + * * Span names should be descriptive and represent the operation being performed. * Updating the name can be useful when the operation's scope becomes clearer * during execution, or when implementing generic spans that need specific naming * based on runtime conditions. - * + * * @param name - The new name for the span, should be descriptive of the operation - * + * * @returns This span instance for method chaining - * + * * @remarks * - Name updates may affect sampling behavior depending on implementation * - Choose names that are meaningful but not too specific to avoid cardinality issues * - Follow naming conventions consistent with your observability strategy * - Consider the impact on existing traces and dashboards when changing names - * + * * @example * ```typescript * const span = tracer.startSpan('generic-operation'); - * + * * // Update name based on runtime determination * if (operationType === 'user-registration') { * span.updateName('user-registration'); @@ -354,44 +355,44 @@ export interface IOTelSpan { /** * Marks the end of the span's execution and records the end timestamp. - * + * * This method finalizes the span and makes it available for export to tracing systems. * Once ended, the span should not be used for further operations. The span's duration * is calculated from its start time to the end time provided or current time. - * + * * @param endTime - Optional end time; if not provided, current time is used - * + * * @remarks * - This method does NOT return `this` to discourage chaining after span completion * - Ending a span has no effect on child spans, which may continue running * - Child spans can be ended independently after their parent has ended * - The span becomes eligible for export once ended * - Calling end() multiple times has no additional effect - * + * * @example * ```typescript * const span = tracer.startSpan('file-processing'); - * + * * try { * // Perform the operation * const result = await processFile(filePath); - * + * * // Record success * span.setStatus({ code: SpanStatusCode.OK }); * span.setAttribute('file.size', result.size); - * + * * } catch (error) { * span.recordException(error); - * span.setStatus({ - * code: SpanStatusCode.ERROR, - * message: error.message + * span.setStatus({ + * code: SpanStatusCode.ERROR, + * message: error.message * }); * } finally { * // Always end the span * span.end(); * // Don't use span after this point * } - * + * * // Custom end time example * const customEndTime = Date.now() * 1000000; // nanoseconds * span.end(customEndTime); @@ -401,24 +402,24 @@ export interface IOTelSpan { /** * Returns whether this span is actively recording information. - * + * * A recording span accepts and stores attributes, events, status, and other span data. * Non-recording spans (typically due to sampling decisions) may ignore operations * like setAttribute() to optimize performance. This method allows conditional * logic to avoid expensive operations on non-recording spans. - * + * * @returns True if the span is actively recording information, false otherwise - * + * * @remarks * - Recording status is typically determined at span creation time * - Non-recording spans still provide valid span context for propagation * - Use this check to avoid expensive attribute calculations for non-recording spans * - Recording status remains constant throughout the span's lifetime - * + * * @example * ```typescript * const span = tracer.startSpan('data-processing'); - * + * * // Only perform expensive operations if span is recording * if (span.isRecording()) { * const metadata = await expensiveMetadataCalculation(); @@ -428,7 +429,7 @@ export interface IOTelSpan { * 'process.estimated_duration': metadata.estimatedMs * }); * } - * + * * // Always safe to set basic attributes * span.setAttribute('process.started', true); * ``` @@ -437,47 +438,47 @@ export interface IOTelSpan { /** * Records an exception as a span event with automatic error status handling. - * + * * This method captures exception information and automatically creates a span event * with standardized exception attributes. It's the recommended way to handle errors * within spans, providing consistent error reporting across the application. - * + * * @param exception - The exception to record; accepts string messages or Error objects * @param time - Optional timestamp for when the exception occurred; defaults to current time - * + * * @remarks * - Automatically extracts exception type, message, and stack trace when available * - Creates a standardized span event with exception details * - Does NOT automatically set span status to ERROR - call setStatus() explicitly if needed * - Exception events are useful for debugging and error analysis - * + * * @example * ```typescript * const span = tracer.startSpan('risky-operation'); - * + * * try { * await performRiskyOperation(); * span.setStatus({ code: SpanStatusCode.OK }); - * + * * } catch (error) { * // Record the exception details * span.recordException(error); - * + * * // Explicitly set error status - * span.setStatus({ - * code: SpanStatusCode.ERROR, - * message: 'Operation failed due to: ' + error.message + * span.setStatus({ + * code: SpanStatusCode.ERROR, + * message: 'Operation failed due to: ' + error.message * }); - * + * * // Re-throw if needed * throw error; * } finally { * span.end(); * } - * + * * // Recording string exceptions * span.recordException('Custom error message occurred'); - * + * * // Recording with custom timestamp * const errorTime = Date.now() * 1000000; // nanoseconds * span.recordException(error, errorTime); diff --git a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/trace/IOTelSpanCtx.ts b/shared/AppInsightsCore/src/interfaces/otel/trace/IOTelSpanCtx.ts similarity index 93% rename from shared/AppInsightsCore/src/OpenTelemetry/interfaces/trace/IOTelSpanCtx.ts rename to shared/AppInsightsCore/src/interfaces/otel/trace/IOTelSpanCtx.ts index 3969ca846..7826093d9 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/trace/IOTelSpanCtx.ts +++ b/shared/AppInsightsCore/src/interfaces/otel/trace/IOTelSpanCtx.ts @@ -1,8 +1,8 @@ -import { IDistributedTraceContext } from "../../../JavaScriptSDK.Interfaces/IDistributedTraceContext"; +import { OTelTimeInput } from "../../IOTelHrTime"; +import { IDistributedTraceContext } from "../../ai/IDistributedTraceContext"; import { IOTelApi } from "../IOTelApi"; import { IOTelAttributes } from "../IOTelAttributes"; import { OTelException } from "../IOTelException"; -import { OTelTimeInput } from "../IOTelHrTime"; import { IReadableSpan } from "./IReadableSpan"; /** diff --git a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/trace/IOTelSpanOptions.ts b/shared/AppInsightsCore/src/interfaces/otel/trace/IOTelSpanOptions.ts similarity index 88% rename from shared/AppInsightsCore/src/OpenTelemetry/interfaces/trace/IOTelSpanOptions.ts rename to shared/AppInsightsCore/src/interfaces/otel/trace/IOTelSpanOptions.ts index 03ab43fca..b88ff46a5 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/trace/IOTelSpanOptions.ts +++ b/shared/AppInsightsCore/src/interfaces/otel/trace/IOTelSpanOptions.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { OTelSpanKind } from "../../enums/trace/OTelSpanKind"; +import { OTelSpanKind } from "../../../enums/otel/OTelSpanKind"; +import { OTelTimeInput } from "../../IOTelHrTime"; import { IOTelAttributes } from "../IOTelAttributes"; -import { OTelTimeInput } from "../IOTelHrTime"; /** * Options for creating a span. diff --git a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/trace/IOTelSpanStatus.ts b/shared/AppInsightsCore/src/interfaces/otel/trace/IOTelSpanStatus.ts similarity index 73% rename from shared/AppInsightsCore/src/OpenTelemetry/interfaces/trace/IOTelSpanStatus.ts rename to shared/AppInsightsCore/src/interfaces/otel/trace/IOTelSpanStatus.ts index be5a628ee..c48080a91 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/trace/IOTelSpanStatus.ts +++ b/shared/AppInsightsCore/src/interfaces/otel/trace/IOTelSpanStatus.ts @@ -1,4 +1,4 @@ -import { eOTelSpanStatusCode } from "../../enums/trace/OTelSpanStatus"; +import { eOTelSpanStatusCode } from "../../../enums/otel/OTelSpanStatus"; export interface IOTelSpanStatus { /** diff --git a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/trace/ITraceApi.ts b/shared/AppInsightsCore/src/interfaces/otel/trace/IOTelTraceApi.ts similarity index 91% rename from shared/AppInsightsCore/src/OpenTelemetry/interfaces/trace/ITraceApi.ts rename to shared/AppInsightsCore/src/interfaces/otel/trace/IOTelTraceApi.ts index ab4afff50..c6813ec5b 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/trace/ITraceApi.ts +++ b/shared/AppInsightsCore/src/interfaces/otel/trace/IOTelTraceApi.ts @@ -1,5 +1,5 @@ -import { IDistributedTraceContext } from "../../../JavaScriptSDK.Interfaces/IDistributedTraceContext"; -import { ISpanScope } from "../../../JavaScriptSDK.Interfaces/ITraceProvider"; +import { IDistributedTraceContext } from "../../ai/IDistributedTraceContext"; +import { ISpanScope } from "../../ai/ITraceProvider"; import { IOTelTracer } from "./IOTelTracer"; import { IOTelTracerOptions } from "./IOTelTracerProvider"; import { IReadableSpan } from "./IReadableSpan"; diff --git a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/trace/IOTelTraceState.ts b/shared/AppInsightsCore/src/interfaces/otel/trace/IOTelTraceState.ts similarity index 100% rename from shared/AppInsightsCore/src/OpenTelemetry/interfaces/trace/IOTelTraceState.ts rename to shared/AppInsightsCore/src/interfaces/otel/trace/IOTelTraceState.ts diff --git a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/trace/IOTelTracer.ts b/shared/AppInsightsCore/src/interfaces/otel/trace/IOTelTracer.ts similarity index 96% rename from shared/AppInsightsCore/src/OpenTelemetry/interfaces/trace/IOTelTracer.ts rename to shared/AppInsightsCore/src/interfaces/otel/trace/IOTelTracer.ts index acb5cfc38..ff2d4207c 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/trace/IOTelTracer.ts +++ b/shared/AppInsightsCore/src/interfaces/otel/trace/IOTelTracer.ts @@ -31,10 +31,10 @@ import { IReadableSpan } from "./IReadableSpan"; * span.end(); * }); * ``` - * + * * @see {@link IReadableSpan} - Interface for individual spans * @see {@link IOTelSpanOptions} - Configuration options for span creation - * + * * @since 3.4.0 */ export interface IOTelTracer { @@ -92,20 +92,20 @@ export interface IOTelTracer { * This method creates a span, makes it active during the execution of the provided * function, and automatically ends the span when the function completes (or throws). * This provides automatic span lifecycle management and context propagation. - * + * * @param name - The name of the span, should be descriptive of the operation being traced * @param options - Optional configuration for span creation (parent context, attributes, etc.) * @param fn - The function to execute within the span's active context - * + * * @returns The result of executing the provided function - * + * * @remarks * - The span is automatically ended when the function completes or throws an exception * - The span becomes the active parent for any spans created within the function * - If the function throws an error, the span status is automatically set to ERROR * - This is the recommended method for most tracing scenarios due to automatic lifecycle management * - Multiple overloads available for different parameter combinations - * + * * @example * ```typescript * // Synchronous operation with just name and function @@ -113,18 +113,18 @@ export interface IOTelTracer { * span.setAttribute('operation', 'get-user-details'); * return { user: getUserData(), timestamp: new Date().toISOString() }; * }); - * + * * // With options - * const result2 = tracer.startActiveSpan('database-query', - * { attributes: { 'db.table': 'users' } }, + * const result2 = tracer.startActiveSpan('database-query', + * { attributes: { 'db.table': 'users' } }, * (span) => { * span.setAttribute('db.operation', 'SELECT'); * return database.getUser('123'); * } * ); - * + * * // With full context control - * const result3 = tracer.startActiveSpan('external-api', + * const result3 = tracer.startActiveSpan('external-api', * { attributes: { 'service.name': 'payment-api' } }, * currentContext, * async (span) => { diff --git a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/trace/IOTelTracerProvider.ts b/shared/AppInsightsCore/src/interfaces/otel/trace/IOTelTracerProvider.ts similarity index 100% rename from shared/AppInsightsCore/src/OpenTelemetry/interfaces/trace/IOTelTracerProvider.ts rename to shared/AppInsightsCore/src/interfaces/otel/trace/IOTelTracerProvider.ts diff --git a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/trace/IReadableSpan.ts b/shared/AppInsightsCore/src/interfaces/otel/trace/IReadableSpan.ts similarity index 90% rename from shared/AppInsightsCore/src/OpenTelemetry/interfaces/trace/IReadableSpan.ts rename to shared/AppInsightsCore/src/interfaces/otel/trace/IReadableSpan.ts index 020b57f52..1c9a0810d 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/interfaces/trace/IReadableSpan.ts +++ b/shared/AppInsightsCore/src/interfaces/otel/trace/IReadableSpan.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { IDistributedTraceContext } from "../../../JavaScriptSDK.Interfaces/IDistributedTraceContext"; -import { OTelSpanKind } from "../../enums/trace/OTelSpanKind"; +import { OTelSpanKind } from "../../../enums/otel/OTelSpanKind"; +import { IOTelHrTime } from "../../IOTelHrTime"; +import { IDistributedTraceContext } from "../../ai/IDistributedTraceContext"; import { IOTelAttributes } from "../IOTelAttributes"; -import { IOTelHrTime } from "../IOTelHrTime"; import { IOTelSpan } from "./IOTelSpan"; import { IOTelSpanStatus } from "./IOTelSpanStatus"; diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/EventHelpers.ts b/shared/AppInsightsCore/src/internal/EventHelpers.ts similarity index 89% rename from shared/AppInsightsCore/src/JavaScriptSDK/EventHelpers.ts rename to shared/AppInsightsCore/src/internal/EventHelpers.ts index 1c58ab99c..19af8c335 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK/EventHelpers.ts +++ b/shared/AppInsightsCore/src/internal/EventHelpers.ts @@ -1,8 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { arrForEach, arrIndexOf, getDocument, getWindow, isArray, objForEachKey, objKeys } from "@nevware21/ts-utils"; -import { createElmNodeData, createUniqueNamespace } from "./DataCacheHelper"; -import { STR_EMPTY } from "./InternalConstants"; +import { + ICachedValue, arrForEach, arrIndexOf, createCachedValue, getDocument, getWindow, isArray, objForEachKey, objKeys +} from "@nevware21/ts-utils"; +import { STR_EMPTY } from "../constants/InternalConstants"; +import { createElmNodeData, createUniqueNamespace } from "../utils/DataCacheHelper"; // Added to help with minfication const strOnPrefix = "on"; @@ -10,15 +12,33 @@ const strAttachEvent = "attachEvent"; const strAddEventHelper = "addEventListener"; const strDetachEvent = "detachEvent"; const strRemoveEventListener = "removeEventListener"; -const strEvents = "events" +const strEvents = "events"; const strVisibilityChangeEvt: string = "visibilitychange"; const strPageHide: string = "pagehide"; const strPageShow: string = "pageshow"; const strUnload: string = "unload"; const strBeforeUnload: string = "beforeunload"; -const strPageHideNamespace = createUniqueNamespace("aiEvtPageHide"); -const strPageShowNamespace = createUniqueNamespace("aiEvtPageShow"); +let _strPageHideNamespace: ICachedValue; +let _strPageShowNamespace: ICachedValue; + +/*#__NO_SIDE_EFFECTS__*/ +function _getPageHideNamespace() { + // Note: Using a cached value instead of a lazy value as we want to ensure that the namespace is consistent + // across multiple calls as the `getLazy()` supports runtime invalidation via `setBypassLazyCache()` which would + // result in different namespaces being returned. + !_strPageHideNamespace && (_strPageHideNamespace = createCachedValue(createUniqueNamespace("aiEvtPageHide"))); + return _strPageHideNamespace.v; +} + +/*#__NO_SIDE_EFFECTS__*/ +function _getPageShowNamespace() { + // Note: Using a cached value instead of a lazy value as we want to ensure that the namespace is consistent + // across multiple calls as the `getLazy()` supports runtime invalidation via `setBypassLazyCache()` which would + // result in different namespaces being returned. + !_strPageShowNamespace && (_strPageShowNamespace = createCachedValue(createUniqueNamespace("aiEvtPageShow"))); + return _strPageShowNamespace.v; +} const rRemoveEmptyNs = /\.[\.]+/g; const rRemoveTrailingEmptyNs = /[\.]+$/; @@ -41,9 +61,20 @@ interface IAiEvents { [name: string]: IRegisteredEvent[] } -const elmNodeData = createElmNodeData("events"); -const eventNamespace = /^([^.]*)(?:\.(.+)|)/ +let _elmNodeData: ICachedValue>; + +/*#__NO_SIDE_EFFECTS__*/ +function _getElmNodeData() { + // Note: Using a cached value instead of a lazy value as we want to ensure that the namespace is consistent + // across multiple calls as the `getLazy()` supports runtime invalidation via `setBypassLazyCache()` which would + // result in different namespaces being returned. + !_elmNodeData && (_elmNodeData = createCachedValue(createElmNodeData("events"))); + return _elmNodeData.v; +} + +const eventNamespace = /^([^.]*)(?:\.(.+)|)/; +/*#__NO_SIDE_EFFECTS__*/ function _normalizeNamespace(name: string) { if (name && name.replace) { return name.replace(/^[\s\.]+|(?=[\s\.])[\.\s]+$/g, STR_EMPTY); @@ -52,6 +83,7 @@ function _normalizeNamespace(name: string) { return name; } +/*#__NO_SIDE_EFFECTS__*/ function _getEvtNamespace(eventName: string | undefined, evtNamespace?: string | string[] | null): IEventDetails { if (evtNamespace) { let theNamespace: string = STR_EMPTY; @@ -103,9 +135,10 @@ export interface _IRegisteredEvents { * @param evtNamespace - [Optional] Additional namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace, * if the eventName also includes a namespace the namespace(s) are merged into a single namespace */ +/*#__NO_SIDE_EFFECTS__*/ export function __getRegisteredEvents(target: any, eventName?: string, evtNamespace?: string | string[]): _IRegisteredEvents[] { let theEvents: _IRegisteredEvents[] = []; - let eventCache = elmNodeData.get(target, strEvents, {}, false); + let eventCache = _getElmNodeData().get(target, strEvents, {}, false); let evtName = _getEvtNamespace(eventName, evtNamespace); objForEachKey(eventCache, (evtType, registeredEvents) => { @@ -125,8 +158,9 @@ export function __getRegisteredEvents(target: any, eventName?: string, evtNamesp } // Exported for internal unit testing only +/*#__NO_SIDE_EFFECTS__*/ function _getRegisteredEvents(target: any, evtName: string, addDefault: boolean = true): IRegisteredEvent[] { - let aiEvts = elmNodeData.get(target, strEvents, {}, addDefault); + let aiEvts = _getElmNodeData().get(target, strEvents, {}, addDefault); let registeredEvents = aiEvts[evtName]; if (!registeredEvents) { registeredEvents = aiEvts[evtName] = []; @@ -183,18 +217,19 @@ function _unregisterEvents(target: any, evtName: IEventDetails, unRegFn: (regEve if (evtName.type) { _doUnregister(target, _getRegisteredEvents(target, evtName.type), evtName, unRegFn); } else { - let eventCache = elmNodeData.get(target, strEvents, {}); + let eventCache = _getElmNodeData().get(target, strEvents, {}); objForEachKey(eventCache, (evtType, events) => { _doUnregister(target, events, evtName, unRegFn); }); // Cleanup if (objKeys(eventCache).length === 0) { - elmNodeData.kill(target, strEvents); + _getElmNodeData().kill(target, strEvents); } } } +/*#__NO_SIDE_EFFECTS__*/ export function mergeEvtNamespace(theNamespace: string, namespaces?: string | string[] | null): string | string[] { let newNamespaces: string | string[]; @@ -233,7 +268,7 @@ export function eventOn(target: T, eventName: string, handlerRef: any, evtNam let evtName = _getEvtNamespace(eventName, evtNamespace); result = _doAttach(target, evtName, handlerRef, useCapture); - if (result && elmNodeData.accept(target)) { + if (result && _getElmNodeData().accept(target)) { let registeredEvent: IRegisteredEvent = { guid: _guid++, evtName: evtName, @@ -472,7 +507,7 @@ export function addPageHideEventListener(listener: any, excludeEvents?: string[] } // add the unique page show namespace to any provided namespace so we can only remove the ones added by "pagehide" - let newNamespaces = mergeEvtNamespace(strPageHideNamespace, evtNamespace); + let newNamespaces = mergeEvtNamespace(_getPageHideNamespace(), evtNamespace); let pageUnloadAdded = _addEventListeners([strPageHide], listener, excludeEvents, newNamespaces); if (!excludeEvents || arrIndexOf(excludeEvents, strVisibilityChangeEvt) === -1) { @@ -497,7 +532,7 @@ export function addPageHideEventListener(listener: any, excludeEvents?: string[] export function removePageHideEventListener(listener: any, evtNamespace?: string | string[] | null) { // add the unique page show namespace to any provided namespace so we only remove the ones added by "pagehide" - let newNamespaces = mergeEvtNamespace(strPageHideNamespace, evtNamespace); + let newNamespaces = mergeEvtNamespace(_getPageHideNamespace(), evtNamespace); removeEventListeners([strPageHide], listener, newNamespaces); removeEventListeners([strVisibilityChangeEvt], null, newNamespaces); } @@ -523,7 +558,7 @@ export function addPageShowEventListener(listener: any, excludeEvents?: string[] } // add the unique page show namespace to any provided namespace so we can only remove the ones added by "pageshow" - let newNamespaces = mergeEvtNamespace(strPageShowNamespace, evtNamespace); + let newNamespaces = mergeEvtNamespace(_getPageShowNamespace(), evtNamespace); let pageShowAdded = _addEventListeners([strPageShow], listener, excludeEvents, newNamespaces); pageShowAdded = _addEventListeners([strVisibilityChangeEvt], _handlePageVisibility, excludeEvents, newNamespaces) || pageShowAdded; @@ -544,7 +579,7 @@ export function addPageShowEventListener(listener: any, excludeEvents?: string[] */ export function removePageShowEventListener(listener: any, evtNamespace?: string | string[] | null) { // add the unique page show namespace to any provided namespace so we only remove the ones added by "pageshow" - let newNamespaces = mergeEvtNamespace(strPageShowNamespace, evtNamespace); + let newNamespaces = mergeEvtNamespace(_getPageShowNamespace(), evtNamespace); removeEventListeners([strPageShow], listener, newNamespaces); removeEventListeners([strVisibilityChangeEvt], null, newNamespaces); } diff --git a/shared/AppInsightsCore/src/OpenTelemetry/helpers/attributeHelpers.ts b/shared/AppInsightsCore/src/internal/attributeHelpers.ts similarity index 89% rename from shared/AppInsightsCore/src/OpenTelemetry/helpers/attributeHelpers.ts rename to shared/AppInsightsCore/src/internal/attributeHelpers.ts index 9949b1020..0ff7326e1 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/helpers/attributeHelpers.ts +++ b/shared/AppInsightsCore/src/internal/attributeHelpers.ts @@ -1,13 +1,15 @@ import { arrForEach, arrSlice, isArray, isObject, isString, objForEachKey } from "@nevware21/ts-utils"; -import { createAttributeContainer } from "../attribute/attributeContainer"; -import { IOTelApi } from "../interfaces/IOTelApi"; -import { IOTelAttributes, OTelAttributeValue } from "../interfaces/IOTelAttributes"; +import { IOTelApi } from "../interfaces/otel/IOTelApi"; +import { IOTelAttributes, OTelAttributeValue } from "../interfaces/otel/IOTelAttributes"; +import { createAttributeContainer } from "../otel/attribute/attributeContainer"; import { handleWarn } from "./handleErrors"; +/*#__NO_SIDE_EFFECTS__*/ function _isSupportedType(theType: string): boolean { return theType === "number" || theType === "boolean" || theType === "string"; } +/*#__NO_SIDE_EFFECTS__*/ function _isHomogeneousArray(arr: unknown[]): boolean { let type: string | undefined; let result = true; @@ -33,11 +35,12 @@ function _isHomogeneousArray(arr: unknown[]): boolean { return result; } - /** +/** * Helper to determine if the provided key is a valid attribute key * @param key - The key to check * @returns true if the key is a valid attribute key */ +/*#__NO_SIDE_EFFECTS__*/ export function isAttributeKey(key: unknown): key is string { return isString(key) && !!key; } @@ -47,6 +50,7 @@ export function isAttributeKey(key: unknown): key is string { * @param val - The value to check * @returns true if the value is a valid attribute value */ +/*#__NO_SIDE_EFFECTS__*/ export function isAttributeValue(val: unknown): val is OTelAttributeValue { let result = (val === null || _isSupportedType(typeof val)); if (val && isArray(val)) { @@ -62,6 +66,7 @@ export function isAttributeValue(val: unknown): val is OTelAttributeValue { * @param attributes - The attributes to sanitize * @returns The sanitized attributes */ +/*#__NO_SIDE_EFFECTS__*/ export function sanitizeAttributes(otelApi: IOTelApi, attributes: unknown): IOTelAttributes { let container = createAttributeContainer(otelApi.cfg); diff --git a/shared/AppInsightsCore/src/OpenTelemetry/helpers/common.ts b/shared/AppInsightsCore/src/internal/commonUtils.ts similarity index 80% rename from shared/AppInsightsCore/src/OpenTelemetry/helpers/common.ts rename to shared/AppInsightsCore/src/internal/commonUtils.ts index 1bcaac71f..898ad9543 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/helpers/common.ts +++ b/shared/AppInsightsCore/src/internal/commonUtils.ts @@ -2,47 +2,46 @@ // Licensed under the MIT License. import { ILazyValue, asString, dumpObj, isError, isObject, isPrimitive, safe, safeGetLazy } from "@nevware21/ts-utils"; -import { getJSON } from "../../JavaScriptSDK/EnvUtils"; -import { STR_EMPTY } from "../../JavaScriptSDK/InternalConstants"; -import { IAttributeContainer } from "../attribute/IAttributeContainer"; +import { STR_EMPTY } from "../constants/InternalConstants"; +import { OTelAttributeValue } from "../interfaces/otel/IOTelAttributes"; +import { IAttributeContainer } from "../interfaces/otel/attribute/IAttributeContainer"; import { DBSYSTEMVALUES_DB2, DBSYSTEMVALUES_DERBY, DBSYSTEMVALUES_H2, DBSYSTEMVALUES_HSQLDB, DBSYSTEMVALUES_MARIADB, DBSYSTEMVALUES_MSSQL, DBSYSTEMVALUES_ORACLE, DBSYSTEMVALUES_OTHER_SQL, DBSYSTEMVALUES_SQLITE -} from "../attribute/SemanticConventions"; -import { OTelAttributeValue } from "../interfaces/IOTelAttributes"; +} from "../otel/attribute/SemanticConventions"; +import { getJSON } from "../utils/EnvUtils"; const _hasJsonStringify: ILazyValue = (/*#__PURE__*/ safeGetLazy(() => !!getJSON().stringify, null)); -const SYNTHETIC_TYPE = (/*#__PURE__*/ "user_agent.synthetic.type"); -const CLIENT_DOT = (/*#__PURE__*/ "client."); -const HTTP_DOT = (/*#__PURE__*/ "http."); -const NET_DOT = (/*#__PURE__*/ "net."); -const PEER_DOT = (/*#__PURE__*/ "peer."); - -const ATTR_NETWORK_PEER_ADDRESS = (/*#__PURE__*/ "network.peer.address"); -const SEMATTRS_NET_PEER_IP = (/*#__PURE__*/ NET_DOT + PEER_DOT + "ip"); -const ATTR_CLIENT_ADDRESS = (/*#__PURE__*/ CLIENT_DOT + "address"); -const SEMATTRS_HTTP_CLIENT_IP = (/*#__PURE__*/ HTTP_DOT + "client_ip"); -const ATTR_USER_AGENT_ORIGINAL = (/*#__PURE__*/ "user_agent.original"); -const SEMATTRS_HTTP_USER_AGENT = (/*#__PURE__*/ HTTP_DOT + "user_agent"); -const ATTR_URL_FULL = (/*#__PURE__*/ "url.full"); -const SEMATTRS_HTTP_URL = (/*#__PURE__*/ HTTP_DOT + "url"); -const ATTR_HTTP_REQUEST_METHOD = (/*#__PURE__*/ HTTP_DOT + "request.method"); -const SEMATTRS_HTTP_METHOD = (/*#__PURE__*/ HTTP_DOT + "method"); -const ATTR_HTTP_RESPONSE_STATUS_CODE = (/*#__PURE__*/ HTTP_DOT + "response.status_code"); -const SEMATTRS_HTTP_STATUS_CODE = (/*#__PURE__*/ HTTP_DOT + "status_code"); -const ATTR_URL_SCHEME = (/*#__PURE__*/ "url.scheme"); -const SEMATTRS_HTTP_SCHEME = (/*#__PURE__*/ HTTP_DOT + "scheme"); -const ATTR_URL_PATH = (/*#__PURE__*/ "url.path"); -const ATTR_URL_QUERY = (/*#__PURE__*/ "url.query"); -const SEMATTRS_HTTP_TARGET = (/*#__PURE__*/ HTTP_DOT + "target"); -const ATTR_SERVER_ADDRESS = (/*#__PURE__*/ "server.address"); -const SEMATTRS_HTTP_HOST = (/*#__PURE__*/ HTTP_DOT + "host"); -const SEMATTRS_NET_PEER_NAME = (/*#__PURE__*/ NET_DOT + PEER_DOT + "name"); -const ATTR_CLIENT_PORT = (/*#__PURE__*/ CLIENT_DOT + "port"); -const ATTR_SERVER_PORT = (/*#__PURE__*/ "server.port"); -const SEMATTRS_NET_PEER_PORT = (/*#__PURE__*/ NET_DOT + PEER_DOT + "port"); -const SEMATTRS_PEER_SERVICE = (/*#__PURE__*/ PEER_DOT + "service"); +const SYNTHETIC_TYPE = "user_agent.synthetic.type"; +const CLIENT_DOT = "client."; +const HTTP_DOT = "http."; +const NET_DOT = "net."; +const PEER_DOT = "peer."; +const ATTR_NETWORK_PEER_ADDRESS = "network.peer.address"; +const SEMATTRS_NET_PEER_IP = NET_DOT + PEER_DOT + "ip"; +const ATTR_CLIENT_ADDRESS = CLIENT_DOT + "address"; +const SEMATTRS_HTTP_CLIENT_IP = HTTP_DOT + "client_ip"; +const ATTR_USER_AGENT_ORIGINAL = "user_agent.original"; +const SEMATTRS_HTTP_USER_AGENT = HTTP_DOT + "user_agent"; +const ATTR_URL_FULL = "url.full"; +const SEMATTRS_HTTP_URL = HTTP_DOT + "url"; +const ATTR_HTTP_REQUEST_METHOD = HTTP_DOT + "request.method"; +const SEMATTRS_HTTP_METHOD = HTTP_DOT + "method"; +const ATTR_HTTP_RESPONSE_STATUS_CODE = HTTP_DOT + "response.status_code"; +const SEMATTRS_HTTP_STATUS_CODE = HTTP_DOT + "status_code"; +const ATTR_URL_SCHEME = "url.scheme"; +const SEMATTRS_HTTP_SCHEME = HTTP_DOT + "scheme"; +const ATTR_URL_PATH = "url.path"; +const ATTR_URL_QUERY = "url.query"; +const SEMATTRS_HTTP_TARGET = HTTP_DOT + "target"; +const ATTR_SERVER_ADDRESS = "server.address"; +const SEMATTRS_HTTP_HOST = HTTP_DOT + "host"; +const SEMATTRS_NET_PEER_NAME = NET_DOT + PEER_DOT + "name"; +const ATTR_CLIENT_PORT = CLIENT_DOT + "port"; +const ATTR_SERVER_PORT = "server.port"; +const SEMATTRS_NET_PEER_PORT = NET_DOT + PEER_DOT + "port"; +const SEMATTRS_PEER_SERVICE = PEER_DOT + "service"; /** * Get the URL from the attribute container diff --git a/shared/AppInsightsCore/src/OpenTelemetry/helpers/handleErrors.ts b/shared/AppInsightsCore/src/internal/handleErrors.ts similarity index 97% rename from shared/AppInsightsCore/src/OpenTelemetry/helpers/handleErrors.ts rename to shared/AppInsightsCore/src/internal/handleErrors.ts index 73db07a4e..89f0707d5 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/helpers/handleErrors.ts +++ b/shared/AppInsightsCore/src/internal/handleErrors.ts @@ -1,5 +1,5 @@ import { dumpObj, fnApply } from "@nevware21/ts-utils"; -import { IOTelErrorHandlers } from "../interfaces/config/IOTelErrorHandlers"; +import { IOTelErrorHandlers } from "../interfaces/otel/config/IOTelErrorHandlers"; /** * Handle / report an error. diff --git a/shared/AppInsightsCore/src/OpenTelemetry/noop/noopHelpers.ts b/shared/AppInsightsCore/src/internal/noopHelpers.ts similarity index 100% rename from shared/AppInsightsCore/src/OpenTelemetry/noop/noopHelpers.ts rename to shared/AppInsightsCore/src/internal/noopHelpers.ts diff --git a/shared/AppInsightsCore/src/OpenTelemetry/helpers/timeHelpers.ts b/shared/AppInsightsCore/src/internal/timeHelpers.ts similarity index 90% rename from shared/AppInsightsCore/src/OpenTelemetry/helpers/timeHelpers.ts rename to shared/AppInsightsCore/src/internal/timeHelpers.ts index 35566663c..b0e98123e 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/helpers/timeHelpers.ts +++ b/shared/AppInsightsCore/src/internal/timeHelpers.ts @@ -1,20 +1,19 @@ import { ICachedValue, ObjDefinePropDescriptor, createCachedValue, getDeferred, getPerformance, isArray, isDate, isNullOrUndefined, isNumber, - isString, mathFloor, mathRound, objDefine, objDefineProps, objFreeze, perfNow, strLeft, strRight, strSplit, throwTypeError + isString, mathFloor, mathRound, objDefineProps, objFreeze, perfNow, strLeft, strRight, strSplit, throwTypeError } from "@nevware21/ts-utils"; -import { setObjStringTag, toISOString } from "../../JavaScriptSDK/HelperFuncs"; -import { INVALID_TRACE_ID } from "../../JavaScriptSDK/W3cTraceParent"; import { IOTelHrTime, OTelTimeInput } from "../interfaces/IOTelHrTime"; +import { setObjStringTag, toISOString } from "../utils/HelperFuncs"; +import { INVALID_TRACE_ID } from "../utils/TraceParent"; const NANOSECOND_DIGITS = 9; // Constants for time unit conversions and manipulation -const NANOS_IN_MILLIS = /*#__PURE__*/ 1000000; // Number of nanoseconds in a millisecond -const NANOS_IN_SECOND = /*#__PURE__*/ 1000000000; // Number of nanoseconds in a second -const MICROS_IN_SECOND = /*#__PURE__*/ 1000000; // Number of microseconds in a second -const MICROS_IN_MILLIS = /*#__PURE__*/ 1000; // Number of microseconds in a millisecond -const MILLIS_IN_SECOND = /*#__PURE__*/ 1000; // Number of milliseconds in a second - +const NANOS_IN_MILLIS = 1000000; // Number of nanoseconds in a millisecond +const NANOS_IN_SECOND = 1000000000; // Number of nanoseconds in a second +const MICROS_IN_SECOND = 1000000; // Number of microseconds in a second +const MICROS_IN_MILLIS = 1000; // Number of microseconds in a millisecond +const MILLIS_IN_SECOND = 1000; // Number of milliseconds in a second interface IOriginHrTime { to: number; hr: IOTelHrTime @@ -32,7 +31,7 @@ function _notMutable() { * Initialize the cached value for converting milliseconds to nanoseconds. * @returns */ -/*#__PURE__*/ +/*#__NO_SIDE_EFFECTS__*/ function _initSecondsToNanos(): ICachedValue { if (!cSecondsToNanos) { cSecondsToNanos = createCachedValue(NANOS_IN_SECOND); @@ -44,7 +43,7 @@ function _initSecondsToNanos(): ICachedValue { * Initialize the time origin. * @returns */ -/*#__PURE__*/ +/*#__NO_SIDE_EFFECTS__*/ function _initTimeOrigin(): ICachedValue { if (!cTimeOrigin) { let timeOrigin = 0; @@ -68,7 +67,7 @@ function _initTimeOrigin(): ICachedValue { return cTimeOrigin; } -/*#__PURE__*/ +/*#__NO_SIDE_EFFECTS__*/ function _finalizeHrTime(hrTime: IOTelHrTime) { function _toString() { return "[" + hrTime[0] + ", " + hrTime[1] + "]"; @@ -79,7 +78,7 @@ function _finalizeHrTime(hrTime: IOTelHrTime) { return objFreeze(hrTime); } -/*#__PURE__*/ +/*#__NO_SIDE_EFFECTS__*/ function _createUnixNanoHrTime(unixNano: number): IOTelHrTime { // Create array with initial length of 2 const hrTime = [0, 0] as any as IOTelHrTime; @@ -113,7 +112,7 @@ function _createUnixNanoHrTime(unixNano: number): IOTelHrTime { return _finalizeHrTime(hrTime); } -/*#__PURE__*/ +/*#__NO_SIDE_EFFECTS__*/ function _createHrTime(seconds: number, nanoseconds: number): IOTelHrTime { const hrTime = [seconds, nanoseconds] as IOTelHrTime; @@ -130,7 +129,7 @@ function _createHrTime(seconds: number, nanoseconds: number): IOTelHrTime { * Returns a new HrTime object with zero values for seconds and nanoseconds. * @returns A HrTime object representing zero time. */ -/*#__PURE__*/ /*@__NO_SIDE_EFFECTS__*/ +/*#__NO_SIDE_EFFECTS__*/ export function zeroHrTime(): IOTelHrTime { return _createUnixNanoHrTime(0); } @@ -140,7 +139,7 @@ export function zeroHrTime(): IOTelHrTime { * @param epochMillis - The number of milliseconds since the epoch (January 1, 1970). * @returns A HrTime object representing the converted time. */ -/*#__PURE__*/ /*@__NO_SIDE_EFFECTS__*/ +/*#__NO_SIDE_EFFECTS__*/ export function millisToHrTime(epochMillis: number): IOTelHrTime { let result: IOTelHrTime; @@ -179,7 +178,7 @@ export function millisToHrTime(epochMillis: number): IOTelHrTime { * @param nanos - The number of nanoseconds since the epoch (January 1, 1970). * @returns A HrTime object representing the converted time. */ -/*#__PURE__*/ /*@__NO_SIDE_EFFECTS__*/ +/*#__NO_SIDE_EFFECTS__*/ export function nanosToHrTime(nanos: number): IOTelHrTime { let result: IOTelHrTime; if (nanos > 0) { @@ -196,7 +195,6 @@ export function nanosToHrTime(nanos: number): IOTelHrTime { // * @param hrTime - The HrTime object to convert. // * @returns The number of nanoseconds represented by the HrTime object. // */ -// /*#__PURE__*/ /*@__NO_SIDE_EFFECTS__*/ // export function hrTimeToUnixNanos(hrTime: IOTelHrTime): number { // let value = hrTime.unixNano; // if (isNullOrUndefined(value)) { @@ -205,13 +203,13 @@ export function nanosToHrTime(nanos: number): IOTelHrTime { // const secondsInNanos = hrTime[0] * NANOS_IN_MILLIS; // // Add the additional nanoseconds // value = secondsInNanos + hrTime[1]; - +// // // // Add warning if we're approaching number precision limits // // if (Math.abs(value) > Number.MAX_SAFE_INTEGER) { // // console.warn("Time value exceeds safe integer limits, precision may be lost"); // // } // } - +// // return value; // } @@ -219,7 +217,7 @@ export function nanosToHrTime(nanos: number): IOTelHrTime { * Returns an hrtime calculated via performance component. * @param performanceNow - The current time in milliseconds since the epoch. */ -/*#__PURE__*/ +/*#__NO_SIDE_EFFECTS__*/ export function hrTime(performanceNow?: number): IOTelHrTime { let result = millisToHrTime(isNumber(performanceNow) ? performanceNow : perfNow()); const perf = getPerformance(); @@ -235,7 +233,7 @@ export function hrTime(performanceNow?: number): IOTelHrTime { * Converts a TimeInput to an HrTime, defaults to _hrtime(). * @param time - The time input to convert. */ -/*#__PURE__*/ +/*#__NO_SIDE_EFFECTS__*/ export function timeInputToHrTime(time: OTelTimeInput): IOTelHrTime { let result: IOTelHrTime; @@ -263,7 +261,7 @@ export function timeInputToHrTime(time: OTelTimeInput): IOTelHrTime { * @param endTime - The end time of the duration * @returns The duration between startTime and endTime as an IOTelHrTime */ -/*#__PURE__*/ /*@__NO_SIDE_EFFECTS__*/ +/*#__NO_SIDE_EFFECTS__*/ export function hrTimeDuration(startTime: IOTelHrTime, endTime: IOTelHrTime): IOTelHrTime { const seconds = endTime[0] - startTime[0]; let nanos = endTime[1] - startTime[1]; @@ -284,7 +282,7 @@ export function hrTimeDuration(startTime: IOTelHrTime, endTime: IOTelHrTime): IO * Convert hrTime to timestamp, for example "2019-05-14T17:00:00.000123456Z" * @param time - The hrTime to convert. */ -/*#__PURE__*/ /*@__NO_SIDE_EFFECTS__*/ +/*#__NO_SIDE_EFFECTS__*/ export function hrTimeToTimeStamp(time: IOTelHrTime): string { if (!cNanoPadding) { cNanoPadding = createCachedValue(strLeft(INVALID_TRACE_ID, NANOSECOND_DIGITS)); @@ -298,7 +296,7 @@ export function hrTimeToTimeStamp(time: IOTelHrTime): string { * Convert hrTime to nanoseconds. * @param time - The hrTime to convert. */ -/*#__PURE__*/ /*@__NO_SIDE_EFFECTS__*/ +/*#__NO_SIDE_EFFECTS__*/ export function hrTimeToNanoseconds(time: IOTelHrTime): number { let nanoSeconds = cSecondsToNanos || _initSecondsToNanos(); return time[0] * nanoSeconds.v + time[1]; @@ -308,7 +306,7 @@ export function hrTimeToNanoseconds(time: IOTelHrTime): number { * Convert hrTime to milliseconds. * @param time - The hrTime to convert. */ -/*#__PURE__*/ /*@__NO_SIDE_EFFECTS__*/ +/*#__NO_SIDE_EFFECTS__*/ export function hrTimeToMilliseconds(time: IOTelHrTime): number { // Use integer math for the seconds part to avoid floating point precision loss const millisFromSeconds = time[0] * MILLIS_IN_SECOND; @@ -321,7 +319,7 @@ export function hrTimeToMilliseconds(time: IOTelHrTime): number { * Convert hrTime to microseconds. * @param time - The hrTime to convert. */ -/*#__PURE__*/ /*@__NO_SIDE_EFFECTS__*/ +/*#__NO_SIDE_EFFECTS__*/ export function hrTimeToMicroseconds(time: IOTelHrTime): number { // Use integer math for the seconds part to avoid floating point precision loss const microsFromSeconds = time[0] * MICROS_IN_SECOND; @@ -334,7 +332,7 @@ export function hrTimeToMicroseconds(time: IOTelHrTime): number { * check if time is HrTime * @param value - The value to check. */ -/*#__PURE__*/ /*@__NO_SIDE_EFFECTS__*/ +/*#__NO_SIDE_EFFECTS__*/ export function isTimeInputHrTime(value: unknown): value is IOTelHrTime { return isArray(value) && value.length === 2 && isNumber(value[0]) && isNumber(value[1]); } @@ -343,7 +341,7 @@ export function isTimeInputHrTime(value: unknown): value is IOTelHrTime { * check if input value is a correct types.TimeInput * @param value - The value to check. */ -/*#__PURE__*/ /*@__NO_SIDE_EFFECTS__*/ +/*#__NO_SIDE_EFFECTS__*/ export function isTimeInput(value: unknown): value is OTelTimeInput { return !isNullOrUndefined(value) && (isTimeInputHrTime(value) || isNumber(value) || isDate(value)); } @@ -353,6 +351,7 @@ export function isTimeInput(value: unknown): value is OTelTimeInput { * @param value - The value to check * @returns True if the value is in a time span format; false otherwise */ +/*#__NO_SIDE_EFFECTS__*/ export function isTimeSpan(value: any): value is string { let result = false; @@ -388,7 +387,7 @@ export function isTimeSpan(value: any): value is string { * @param time2 - The second HrTime to add * @returns The sum of the two HrTime values as an IOTelHrTime */ -/*#__PURE__*/ /*@__NO_SIDE_EFFECTS__*/ +/*#__NO_SIDE_EFFECTS__*/ export function addHrTimes(time1: IOTelHrTime, time2: IOTelHrTime): IOTelHrTime { const seconds = time1[0] + time2[0]; let nanos = time1[1] + time2[1]; diff --git a/shared/AppInsightsCore/src/OpenTelemetry/otelApi.ts b/shared/AppInsightsCore/src/otel/api/OTelApi.ts similarity index 69% rename from shared/AppInsightsCore/src/OpenTelemetry/otelApi.ts rename to shared/AppInsightsCore/src/otel/api/OTelApi.ts index fec209d87..dd694da5f 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/otelApi.ts +++ b/shared/AppInsightsCore/src/otel/api/OTelApi.ts @@ -1,11 +1,12 @@ import { ILazyValue, objDefineProps } from "@nevware21/ts-utils"; -import { setProtoTypeName } from "../JavaScriptSDK/HelperFuncs"; -import { IOTelApi } from "./interfaces/IOTelApi"; -import { IOTelApiCtx } from "./interfaces/IOTelApiCtx"; -import { ITraceApi } from "./interfaces/trace/ITraceApi"; +import { IOTelApi } from "../../interfaces/otel/IOTelApi"; +import { IOTelApiCtx } from "../../interfaces/otel/IOTelApiCtx"; +import { ITraceApi } from "../../interfaces/otel/trace/IOTelTraceApi"; +import { setProtoTypeName } from "../../utils/HelperFuncs"; import { _createTraceApi } from "./trace/traceApi"; import { _createTracerProvider } from "./trace/tracerProvider"; +/*#__NO_SIDE_EFFECTS__*/ export function createOTelApi(otelApiCtx: IOTelApiCtx): IOTelApi { let _traceApi: ILazyValue; diff --git a/shared/AppInsightsCore/src/OpenTelemetry/errors/OTelError.ts b/shared/AppInsightsCore/src/otel/api/errors/OTelError.ts similarity index 96% rename from shared/AppInsightsCore/src/OpenTelemetry/errors/OTelError.ts rename to shared/AppInsightsCore/src/otel/api/errors/OTelError.ts index 08cdc2970..e6a5b6e61 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/errors/OTelError.ts +++ b/shared/AppInsightsCore/src/otel/api/errors/OTelError.ts @@ -14,6 +14,7 @@ export interface OpenTelemetryErrorConstructor("OpenTelemetryError", function (self, args) { diff --git a/shared/AppInsightsCore/src/OpenTelemetry/errors/OTelInvalidAttributeError.ts b/shared/AppInsightsCore/src/otel/api/errors/OTelInvalidAttributeError.ts similarity index 94% rename from shared/AppInsightsCore/src/OpenTelemetry/errors/OTelInvalidAttributeError.ts rename to shared/AppInsightsCore/src/otel/api/errors/OTelInvalidAttributeError.ts index f77ceed5c..3339db753 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/errors/OTelInvalidAttributeError.ts +++ b/shared/AppInsightsCore/src/otel/api/errors/OTelInvalidAttributeError.ts @@ -1,5 +1,5 @@ import { createCustomError } from "@nevware21/ts-utils"; -import { STR_EMPTY } from "../../JavaScriptSDK/InternalConstants"; +import { STR_EMPTY } from "../../../constants/InternalConstants"; import { OpenTelemetryError, OpenTelemetryErrorConstructor, getOpenTelemetryError } from "./OTelError"; let otelInvalidAttributeErrorType: OTelInvalidAttributeErrorConstructor; diff --git a/shared/AppInsightsCore/src/OpenTelemetry/errors/OTelSpanError.ts b/shared/AppInsightsCore/src/otel/api/errors/OTelSpanError.ts similarity index 93% rename from shared/AppInsightsCore/src/OpenTelemetry/errors/OTelSpanError.ts rename to shared/AppInsightsCore/src/otel/api/errors/OTelSpanError.ts index fbadededa..13fa48408 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/errors/OTelSpanError.ts +++ b/shared/AppInsightsCore/src/otel/api/errors/OTelSpanError.ts @@ -1,5 +1,5 @@ import { createCustomError } from "@nevware21/ts-utils"; -import { STR_EMPTY } from "../../JavaScriptSDK/InternalConstants"; +import { STR_EMPTY } from "../../../constants/InternalConstants"; import { OpenTelemetryError, OpenTelemetryErrorConstructor, getOpenTelemetryError } from "./OTelError"; let otelSpanErrorType: OTelSpanErrorConstructor; diff --git a/shared/AppInsightsCore/src/OpenTelemetry/trace/span.ts b/shared/AppInsightsCore/src/otel/api/trace/span.ts similarity index 88% rename from shared/AppInsightsCore/src/OpenTelemetry/trace/span.ts rename to shared/AppInsightsCore/src/otel/api/trace/span.ts index f3ea4ba54..6d66c5afc 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/trace/span.ts +++ b/shared/AppInsightsCore/src/otel/api/trace/span.ts @@ -4,21 +4,23 @@ import { ILazyValue, dumpObj, getDeferred, isNullOrUndefined, isString, objDefineProps, objFreeze, objIs, objKeys, perfNow } from "@nevware21/ts-utils"; -import { setProtoTypeName, updateProtoTypeName } from "../../JavaScriptSDK/HelperFuncs"; -import { STR_EMPTY, UNDEFINED_VALUE } from "../../JavaScriptSDK/InternalConstants"; -import { IAttributeContainer } from "../attribute/IAttributeContainer"; -import { addAttributes, createAttributeContainer } from "../attribute/attributeContainer"; -import { OTelSpanKind, eOTelSpanKind } from "../enums/trace/OTelSpanKind"; -import { eOTelSpanStatusCode } from "../enums/trace/OTelSpanStatus"; -import { isAttributeValue } from "../helpers/attributeHelpers"; -import { handleAttribError, handleNotImplemented, handleSpanError, handleWarn } from "../helpers/handleErrors"; -import { hrTime, hrTimeDuration, hrTimeToMilliseconds, millisToHrTime, timeInputToHrTime, zeroHrTime } from "../helpers/timeHelpers"; -import { IOTelAttributes } from "../interfaces/IOTelAttributes"; -import { OTelException } from "../interfaces/IOTelException"; -import { IOTelHrTime, OTelTimeInput } from "../interfaces/IOTelHrTime"; -import { IOTelSpanCtx } from "../interfaces/trace/IOTelSpanCtx"; -import { IOTelSpanStatus } from "../interfaces/trace/IOTelSpanStatus"; -import { IReadableSpan } from "../interfaces/trace/IReadableSpan"; +import { STR_EMPTY, UNDEFINED_VALUE } from "../../../constants/InternalConstants"; +import { OTelSpanKind, eOTelSpanKind } from "../../../enums/otel/OTelSpanKind"; +import { eOTelSpanStatusCode } from "../../../enums/otel/OTelSpanStatus"; +import { IOTelHrTime, OTelTimeInput } from "../../../interfaces/IOTelHrTime"; +import { IOTelAttributes } from "../../../interfaces/otel/IOTelAttributes"; +import { OTelException } from "../../../interfaces/otel/IOTelException"; +import { IAttributeContainer } from "../../../interfaces/otel/attribute/IAttributeContainer"; +import { IOTelSpanCtx } from "../../../interfaces/otel/trace/IOTelSpanCtx"; +import { IOTelSpanStatus } from "../../../interfaces/otel/trace/IOTelSpanStatus"; +import { IReadableSpan } from "../../../interfaces/otel/trace/IReadableSpan"; +import { isAttributeValue } from "../../../internal/attributeHelpers"; +import { handleAttribError, handleNotImplemented, handleSpanError, handleWarn } from "../../../internal/handleErrors"; +import { + hrTime, hrTimeDuration, hrTimeToMilliseconds, millisToHrTime, timeInputToHrTime, zeroHrTime +} from "../../../internal/timeHelpers"; +import { setProtoTypeName, updateProtoTypeName } from "../../../utils/HelperFuncs"; +import { addAttributes, createAttributeContainer } from "../../attribute/attributeContainer"; export function createSpan(spanCtx: IOTelSpanCtx, orgName: string, kind: OTelSpanKind): IReadableSpan { let otelCfg = spanCtx.api.cfg; @@ -40,7 +42,7 @@ export function createSpan(spanCtx: IOTelSpanCtx, orgName: string, kind: OTelSpa // let links: IOTelLink[] = []; // let events: IOTelTimedEvent[] = []; let localDroppedAttributes = 0; - let localContainer: IAttributeContainer = null;; + let localContainer: IAttributeContainer = null; // let droppedEvents = 0; // let droppedLinks = 0; let isRecording = spanCtx.isRecording !== false; @@ -80,7 +82,7 @@ export function createSpan(spanCtx: IOTelSpanCtx, orgName: string, kind: OTelSpa if (message) { handleAttribError(errorHandlers, message, key, value); localDroppedAttributes++; - } else if (isRecording && attributes){ + } else if (attributes){ attributes.v.set(key, value); } else { localDroppedAttributes++; diff --git a/shared/AppInsightsCore/src/OpenTelemetry/trace/traceApi.ts b/shared/AppInsightsCore/src/otel/api/trace/traceApi.ts similarity index 75% rename from shared/AppInsightsCore/src/OpenTelemetry/trace/traceApi.ts rename to shared/AppInsightsCore/src/otel/api/trace/traceApi.ts index d33edfaec..657ed142e 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/trace/traceApi.ts +++ b/shared/AppInsightsCore/src/otel/api/trace/traceApi.ts @@ -1,12 +1,12 @@ import { ICachedValue, fnBind, getDeferred } from "@nevware21/ts-utils"; -import { IDistributedTraceContext } from "../../JavaScriptSDK.Interfaces/IDistributedTraceContext"; -import { setProtoTypeName } from "../../JavaScriptSDK/HelperFuncs"; -import { UNDEFINED_VALUE } from "../../JavaScriptSDK/InternalConstants"; +import { UNDEFINED_VALUE } from "../../../constants/InternalConstants"; +import { IDistributedTraceContext } from "../../../interfaces/ai/IDistributedTraceContext"; +import { IOTelApi } from "../../../interfaces/otel/IOTelApi"; +import { ITraceApi } from "../../../interfaces/otel/trace/IOTelTraceApi"; +import { IOTelTracerProvider } from "../../../interfaces/otel/trace/IOTelTracerProvider"; +import { IReadableSpan } from "../../../interfaces/otel/trace/IReadableSpan"; +import { setProtoTypeName } from "../../../utils/HelperFuncs"; import { throwOTelError } from "../errors/OTelError"; -import { IOTelApi } from "../interfaces/IOTelApi"; -import { IOTelTracerProvider } from "../interfaces/trace/IOTelTracerProvider"; -import { IReadableSpan } from "../interfaces/trace/IReadableSpan"; -import { ITraceApi } from "../interfaces/trace/ITraceApi"; import { isSpanContextValid, wrapSpanContext } from "./utils"; /** diff --git a/shared/AppInsightsCore/src/OpenTelemetry/trace/traceProvider.ts b/shared/AppInsightsCore/src/otel/api/trace/traceProvider.ts similarity index 76% rename from shared/AppInsightsCore/src/OpenTelemetry/trace/traceProvider.ts rename to shared/AppInsightsCore/src/otel/api/trace/traceProvider.ts index 4b0d7d46a..fc3e258f0 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/trace/traceProvider.ts +++ b/shared/AppInsightsCore/src/otel/api/trace/traceProvider.ts @@ -2,16 +2,16 @@ // Licensed under the MIT License. import { objDefine, strSubstr } from "@nevware21/ts-utils"; -import { IDistributedTraceContext } from "../../JavaScriptSDK.Interfaces/IDistributedTraceContext"; -import { ITraceHost, ITraceProvider } from "../../JavaScriptSDK.Interfaces/ITraceProvider"; -import { generateW3CId } from "../../JavaScriptSDK/CoreUtils"; -import { createDistributedTraceContext } from "../../JavaScriptSDK/TelemetryHelpers"; -import { OTelTimeInput } from "../../applicationinsights-core-js"; -import { eOTelSpanKind } from "../enums/trace/OTelSpanKind"; -import { IOTelApi } from "../interfaces/IOTelApi"; -import { IOTelSpanCtx } from "../interfaces/trace/IOTelSpanCtx"; -import { IOTelSpanOptions } from "../interfaces/trace/IOTelSpanOptions"; -import { IReadableSpan } from "../interfaces/trace/IReadableSpan"; +import { createDistributedTraceContext } from "../../../core/TelemetryHelpers"; +import { eOTelSpanKind } from "../../../enums/otel/OTelSpanKind"; +import { OTelTimeInput } from "../../../interfaces/IOTelHrTime"; +import { IDistributedTraceContext } from "../../../interfaces/ai/IDistributedTraceContext"; +import { ITraceHost, ITraceProvider } from "../../../interfaces/ai/ITraceProvider"; +import { IOTelApi } from "../../../interfaces/otel/IOTelApi"; +import { IOTelSpanCtx } from "../../../interfaces/otel/trace/IOTelSpanCtx"; +import { IOTelSpanOptions } from "../../../interfaces/otel/trace/IOTelSpanOptions"; +import { IReadableSpan } from "../../../interfaces/otel/trace/IReadableSpan"; +import { generateW3CId } from "../../../utils/CoreUtils"; import { createSpan } from "./span"; /** @@ -24,6 +24,7 @@ import { createSpan } from "./span"; * @param onException - Optional callback to be invoked when an exception is recorded on a span. * @returns The created trace provider. */ +/*#__NO_SIDE_EFFECTS__*/ export function createTraceProvider(host: ITraceHost, traceName: string, api: IOTelApi, onEnd?: (span: IReadableSpan) => void, onException?: (span: IReadableSpan, exception: any, time?: OTelTimeInput) => void): ITraceProvider { let provider: ITraceProvider = { api: null, diff --git a/shared/AppInsightsCore/src/OpenTelemetry/trace/traceState.ts b/shared/AppInsightsCore/src/otel/api/trace/traceState.ts similarity index 90% rename from shared/AppInsightsCore/src/OpenTelemetry/trace/traceState.ts rename to shared/AppInsightsCore/src/otel/api/trace/traceState.ts index a4586a8b3..a9d5d05e1 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/trace/traceState.ts +++ b/shared/AppInsightsCore/src/otel/api/trace/traceState.ts @@ -1,8 +1,8 @@ import { ICachedValue, createCachedValue, isFunction, isString, objDefine, symbolFor } from "@nevware21/ts-utils"; -import { IW3cTraceState } from "../../JavaScriptSDK.Interfaces/IW3cTraceState"; -import { STR_EMPTY } from "../../JavaScriptSDK/InternalConstants"; -import { createW3cTraceState, isW3cTraceState } from "../../JavaScriptSDK/W3cTraceState"; -import { IOTelTraceState } from "../interfaces/trace/IOTelTraceState"; +import { STR_EMPTY } from "../../../constants/InternalConstants"; +import { IW3cTraceState } from "../../../interfaces/ai/IW3cTraceState"; +import { IOTelTraceState } from "../../../interfaces/otel/trace/IOTelTraceState"; +import { createW3cTraceState, isW3cTraceState } from "../../../telemetry/W3cTraceState"; let _otelTraceState: ICachedValue; @@ -14,6 +14,7 @@ function _initOTelTraceStateSymbol() { return _otelTraceState; } +/*#__NO_SIDE_EFFECTS__*/ function _createOTelTraceState(traceState: IW3cTraceState): IOTelTraceState { if (!_otelTraceState) { _otelTraceState = _initOTelTraceStateSymbol(); @@ -55,6 +56,7 @@ function _createOTelTraceState(traceState: IW3cTraceState): IOTelTraceState { * @remarks The OpenTelemetry TraceState is an immutable object, meaning that any changes made to the trace state will * @since 3.4.0 */ +/*#__NO_SIDE_EFFECTS__*/ export function isOTelTraceState(value: any): value is IOTelTraceState { if (!_otelTraceState) { _otelTraceState = _initOTelTraceStateSymbol(); @@ -77,6 +79,7 @@ export function isOTelTraceState(value: any): value is IOTelTraceState { * @remarks The OpenTelemetry TraceState is an immutable object, meaning that any changes made to the trace state will * @since 3.4.0 */ +/*#__NO_SIDE_EFFECTS__*/ export function createOTelTraceState(value?: string | IW3cTraceState | IOTelTraceState | null): IOTelTraceState { let traceState: IW3cTraceState | null = null; if (isOTelTraceState(value)) { diff --git a/shared/AppInsightsCore/src/OpenTelemetry/trace/tracer.ts b/shared/AppInsightsCore/src/otel/api/trace/tracer.ts similarity index 81% rename from shared/AppInsightsCore/src/OpenTelemetry/trace/tracer.ts rename to shared/AppInsightsCore/src/otel/api/trace/tracer.ts index 571ae7f66..1fdd313a2 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/trace/tracer.ts +++ b/shared/AppInsightsCore/src/otel/api/trace/tracer.ts @@ -2,12 +2,12 @@ // Licensed under the MIT License. import { fnApply, isFunction } from "@nevware21/ts-utils"; -import { ISpanScope, ITraceHost } from "../../JavaScriptSDK.Interfaces/ITraceProvider"; -import { setProtoTypeName } from "../../JavaScriptSDK/HelperFuncs"; -import { STR_EMPTY } from "../../JavaScriptSDK/InternalConstants"; -import { IOTelSpanOptions } from "../interfaces/trace/IOTelSpanOptions"; -import { IOTelTracer } from "../interfaces/trace/IOTelTracer"; -import { IReadableSpan } from "../interfaces/trace/IReadableSpan"; +import { STR_EMPTY } from "../../../constants/InternalConstants"; +import { ISpanScope, ITraceHost } from "../../../interfaces/ai/ITraceProvider"; +import { IOTelSpanOptions } from "../../../interfaces/otel/trace/IOTelSpanOptions"; +import { IOTelTracer } from "../../../interfaces/otel/trace/IOTelTracer"; +import { IReadableSpan } from "../../../interfaces/otel/trace/IReadableSpan"; +import { setProtoTypeName } from "../../../utils/HelperFuncs"; import { startActiveSpan } from "./utils"; /** diff --git a/shared/AppInsightsCore/src/OpenTelemetry/trace/tracerProvider.ts b/shared/AppInsightsCore/src/otel/api/trace/tracerProvider.ts similarity index 83% rename from shared/AppInsightsCore/src/OpenTelemetry/trace/tracerProvider.ts rename to shared/AppInsightsCore/src/otel/api/trace/tracerProvider.ts index 9e9984fd4..25993f8e4 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/trace/tracerProvider.ts +++ b/shared/AppInsightsCore/src/otel/api/trace/tracerProvider.ts @@ -2,9 +2,9 @@ // Licensed under the MIT License. import { IPromise } from "@nevware21/ts-async"; -import { ITraceHost } from "../../JavaScriptSDK.Interfaces/ITraceProvider"; -import { IOTelTracer } from "../interfaces/trace/IOTelTracer"; -import { IOTelTracerProvider } from "../interfaces/trace/IOTelTracerProvider"; +import { ITraceHost } from "../../../interfaces/ai/ITraceProvider"; +import { IOTelTracer } from "../../../interfaces/otel/trace/IOTelTracer"; +import { IOTelTracerProvider } from "../../../interfaces/otel/trace/IOTelTracerProvider"; import { _createTracer } from "./tracer"; /** diff --git a/shared/AppInsightsCore/src/OpenTelemetry/trace/utils.ts b/shared/AppInsightsCore/src/otel/api/trace/utils.ts similarity index 95% rename from shared/AppInsightsCore/src/OpenTelemetry/trace/utils.ts rename to shared/AppInsightsCore/src/otel/api/trace/utils.ts index 051590bc4..ecac13be1 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/trace/utils.ts +++ b/shared/AppInsightsCore/src/otel/api/trace/utils.ts @@ -1,18 +1,18 @@ import { doAwait, doFinally } from "@nevware21/ts-async"; import { arrSlice, fnApply, isFunction, isObject, isPromiseLike } from "@nevware21/ts-utils"; -import { IAppInsightsCore } from "../../JavaScriptSDK.Interfaces/IAppInsightsCore"; -import { IConfiguration } from "../../JavaScriptSDK.Interfaces/IConfiguration"; -import { IDistributedTraceContext, IDistributedTraceInit } from "../../JavaScriptSDK.Interfaces/IDistributedTraceContext"; -import { ISpanScope, ITraceHost } from "../../JavaScriptSDK.Interfaces/ITraceProvider"; -import { createDistributedTraceContext, isDistributedTraceContext } from "../../JavaScriptSDK/TelemetryHelpers"; -import { isValidSpanId, isValidTraceId } from "../../JavaScriptSDK/W3cTraceParent"; -import { eOTelSpanKind } from "../enums/trace/OTelSpanKind"; -import { eOTelSpanStatusCode } from "../enums/trace/OTelSpanStatus"; -import { IOTelApi } from "../interfaces/IOTelApi"; -import { ITraceCfg } from "../interfaces/config/ITraceCfg"; -import { IOTelSpanCtx } from "../interfaces/trace/IOTelSpanCtx"; -import { IOTelSpanOptions } from "../interfaces/trace/IOTelSpanOptions"; -import { IReadableSpan } from "../interfaces/trace/IReadableSpan"; +import { createDistributedTraceContext, isDistributedTraceContext } from "../../../core/TelemetryHelpers"; +import { eOTelSpanKind } from "../../../enums/otel/OTelSpanKind"; +import { eOTelSpanStatusCode } from "../../../enums/otel/OTelSpanStatus"; +import { IAppInsightsCore } from "../../../interfaces/ai/IAppInsightsCore"; +import { IConfiguration } from "../../../interfaces/ai/IConfiguration"; +import { IDistributedTraceContext, IDistributedTraceInit } from "../../../interfaces/ai/IDistributedTraceContext"; +import { ISpanScope, ITraceHost } from "../../../interfaces/ai/ITraceProvider"; +import { IOTelApi } from "../../../interfaces/otel/IOTelApi"; +import { ITraceCfg } from "../../../interfaces/otel/config/IOTelTraceCfg"; +import { IOTelSpanCtx } from "../../../interfaces/otel/trace/IOTelSpanCtx"; +import { IOTelSpanOptions } from "../../../interfaces/otel/trace/IOTelSpanOptions"; +import { IReadableSpan } from "../../../interfaces/otel/trace/IReadableSpan"; +import { isValidSpanId, isValidTraceId } from "../../../utils/TraceParent"; import { createSpan } from "./span"; /** diff --git a/shared/AppInsightsCore/src/otel/attribute/SemanticConventions.ts b/shared/AppInsightsCore/src/otel/attribute/SemanticConventions.ts new file mode 100644 index 000000000..c81afe16d --- /dev/null +++ b/shared/AppInsightsCore/src/otel/attribute/SemanticConventions.ts @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +const MICROSOFT_APPLICATIONINSIGHTS_NAME = "Microsoft.ApplicationInsights."; +const MICROSOFT_DOT = "microsoft."; +const CLIENT_DOT = "client."; +const HTTP_DOT = "http."; +const NET_DOT = "net."; +const PEER_DOT = "peer."; +const EXCEPTION_DOT = "exception."; +const ENDUSER_DOT = "enduser."; +const URL_DOT = "url."; +const DB_DOT = "db."; +const NETWORK_DOT = "network."; + +export const AzureMonitorSampleRate = MICROSOFT_DOT + "sample_rate"; +export const ApplicationInsightsCustomEventName = MICROSOFT_DOT + "custom_event.name"; +export const MicrosoftClientIp = MICROSOFT_DOT + CLIENT_DOT + "ip"; + +export const ApplicationInsightsMessageName = MICROSOFT_APPLICATIONINSIGHTS_NAME + "Message"; +export const ApplicationInsightsExceptionName = MICROSOFT_APPLICATIONINSIGHTS_NAME + "Exception"; +export const ApplicationInsightsPageViewName = MICROSOFT_APPLICATIONINSIGHTS_NAME + "PageView"; +export const ApplicationInsightsAvailabilityName = MICROSOFT_APPLICATIONINSIGHTS_NAME + "Availability"; +export const ApplicationInsightsEventName = MICROSOFT_APPLICATIONINSIGHTS_NAME + "Event"; + +export const ApplicationInsightsBaseType = "_MS.baseType"; +export const ApplicationInsightsMessageBaseType = "MessageData"; +export const ApplicationInsightsExceptionBaseType = "ExceptionData"; +export const ApplicationInsightsPageViewBaseType = "PageViewData"; +export const ApplicationInsightsAvailabilityBaseType = "AvailabilityData"; +export const ApplicationInsightsEventBaseType = "EventData"; + +export const ATTR_ENDUSER_ID = ENDUSER_DOT + "id"; +export const ATTR_ENDUSER_PSEUDO_ID = ENDUSER_DOT + "pseudo_id"; +export const ATTR_HTTP_ROUTE = HTTP_DOT + "route"; + +export const SEMATTRS_NET_PEER_IP = NET_DOT + PEER_DOT + "ip"; +export const SEMATTRS_NET_PEER_NAME = NET_DOT + PEER_DOT + "name"; +export const SEMATTRS_NET_HOST_IP = NET_DOT + "host.ip"; +export const SEMATTRS_PEER_SERVICE = PEER_DOT + "service"; +export const SEMATTRS_HTTP_USER_AGENT = HTTP_DOT + "user_agent"; +export const SEMATTRS_HTTP_METHOD = HTTP_DOT + "method"; +export const SEMATTRS_HTTP_URL = HTTP_DOT + "url"; +export const SEMATTRS_HTTP_STATUS_CODE = HTTP_DOT + "status_code"; +export const SEMATTRS_HTTP_ROUTE = HTTP_DOT + "route"; +export const SEMATTRS_HTTP_HOST = HTTP_DOT + "host"; +export const SEMATTRS_DB_SYSTEM = DB_DOT + "system"; +export const SEMATTRS_DB_STATEMENT = DB_DOT + "statement"; +export const SEMATTRS_DB_OPERATION = DB_DOT + "operation"; +export const SEMATTRS_DB_NAME = DB_DOT + "name"; +export const SEMATTRS_RPC_SYSTEM = "rpc.system"; +export const SEMATTRS_RPC_GRPC_STATUS_CODE = "rpc.grpc.status_code"; +export const SEMATTRS_EXCEPTION_TYPE = EXCEPTION_DOT + "type"; +export const SEMATTRS_EXCEPTION_MESSAGE = EXCEPTION_DOT + "message"; +export const SEMATTRS_EXCEPTION_STACKTRACE = EXCEPTION_DOT + "stacktrace"; +export const SEMATTRS_HTTP_SCHEME = HTTP_DOT + "scheme"; +export const SEMATTRS_HTTP_TARGET = HTTP_DOT + "target"; +export const SEMATTRS_HTTP_FLAVOR = HTTP_DOT + "flavor"; +export const SEMATTRS_NET_TRANSPORT = NET_DOT + "transport"; +export const SEMATTRS_NET_HOST_NAME = NET_DOT + "host.name"; +export const SEMATTRS_NET_HOST_PORT = NET_DOT + "host.port"; +export const SEMATTRS_NET_PEER_PORT = NET_DOT + PEER_DOT + "port"; +export const SEMATTRS_HTTP_CLIENT_IP = HTTP_DOT + "client_ip"; +export const SEMATTRS_ENDUSER_ID = ENDUSER_DOT + "id"; + +export const ATTR_CLIENT_ADDRESS = CLIENT_DOT + "address"; +export const ATTR_CLIENT_PORT = CLIENT_DOT + "port"; +export const ATTR_SERVER_ADDRESS = "server.address"; +export const ATTR_SERVER_PORT = "server.port"; +export const ATTR_URL_FULL = URL_DOT + "full"; +export const ATTR_URL_PATH = URL_DOT + "path"; +export const ATTR_URL_QUERY = URL_DOT + "query"; +export const ATTR_URL_SCHEME = URL_DOT + "scheme"; +export const ATTR_ERROR_TYPE = "error.type"; +export const ATTR_NETWORK_LOCAL_ADDRESS = NETWORK_DOT + "local.address"; +export const ATTR_NETWORK_LOCAL_PORT = NETWORK_DOT + "local.port"; +export const ATTR_NETWORK_PROTOCOL_NAME = NETWORK_DOT + "protocol.name"; +export const ATTR_NETWORK_PEER_ADDRESS = NETWORK_DOT + PEER_DOT + "address"; +export const ATTR_NETWORK_PEER_PORT = NETWORK_DOT + PEER_DOT + "port"; +export const ATTR_NETWORK_PROTOCOL_VERSION = NETWORK_DOT + "protocol.version"; +export const ATTR_NETWORK_TRANSPORT = NETWORK_DOT + "transport"; +export const ATTR_USER_AGENT_ORIGINAL = "user_agent.original"; +export const ATTR_HTTP_REQUEST_METHOD = HTTP_DOT + "request.method"; +export const ATTR_HTTP_RESPONSE_STATUS_CODE = HTTP_DOT + "response.status_code"; +export const ATTR_EXCEPTION_TYPE = EXCEPTION_DOT + "type"; +export const ATTR_EXCEPTION_MESSAGE = EXCEPTION_DOT + "message"; +export const ATTR_EXCEPTION_STACKTRACE = EXCEPTION_DOT + "stacktrace"; +export const EXP_ATTR_ENDUSER_ID = ENDUSER_DOT + "id"; +export const EXP_ATTR_ENDUSER_PSEUDO_ID = ENDUSER_DOT + "pseudo_id"; +export const EXP_ATTR_SYNTHETIC_TYPE = "synthetic.type"; + + +export const DBSYSTEMVALUES_MONGODB = "mongodb"; +export const DBSYSTEMVALUES_COSMOSDB = "cosmosdb"; +export const DBSYSTEMVALUES_MYSQL = "mysql"; +export const DBSYSTEMVALUES_POSTGRESQL = "postgresql"; +export const DBSYSTEMVALUES_REDIS = "redis"; +export const DBSYSTEMVALUES_DB2 = "db2"; +export const DBSYSTEMVALUES_DERBY = "derby"; +export const DBSYSTEMVALUES_MARIADB = "mariadb"; +export const DBSYSTEMVALUES_MSSQL = "mssql"; +export const DBSYSTEMVALUES_ORACLE = "oracle"; +export const DBSYSTEMVALUES_SQLITE = "sqlite"; +export const DBSYSTEMVALUES_OTHER_SQL = "other_sql"; +export const DBSYSTEMVALUES_HSQLDB = "hsqldb"; +export const DBSYSTEMVALUES_H2 = "h2"; diff --git a/shared/AppInsightsCore/src/OpenTelemetry/attribute/attributeContainer.ts b/shared/AppInsightsCore/src/otel/attribute/attributeContainer.ts similarity index 98% rename from shared/AppInsightsCore/src/OpenTelemetry/attribute/attributeContainer.ts rename to shared/AppInsightsCore/src/otel/attribute/attributeContainer.ts index b6101bd37..c77d303b2 100644 --- a/shared/AppInsightsCore/src/OpenTelemetry/attribute/attributeContainer.ts +++ b/shared/AppInsightsCore/src/otel/attribute/attributeContainer.ts @@ -5,18 +5,18 @@ import { CreateIteratorContext, ICachedValue, arrForEach, arrIndexOf, createCachedValue, createIterator, getLength, isFunction, isObject, isUndefined, iterForOf, objCreate, objDefine, objDefineProps, objForEachKey, objIs, objKeys, safe, strSplit } from "@nevware21/ts-utils"; -import { IUnloadHook } from "../../JavaScriptSDK.Interfaces/IUnloadHook"; -import { STR_EMPTY, UNDEFINED_VALUE } from "../../JavaScriptSDK/InternalConstants"; -import { eAttributeChangeOp } from "../enums/eAttributeChangeOp"; -import { handleAttribError } from "../helpers/handleErrors"; -import { IOTelAttributes, OTelAttributeValue } from "../interfaces/IOTelAttributes"; -import { IOTelAttributeLimits } from "../interfaces/config/IOTelAttributeLimits"; -import { IOTelConfig } from "../interfaces/config/IOTelConfig"; -import { ITraceCfg } from "../interfaces/config/ITraceCfg"; -import { IAttributeChangeInfo, IAttributeContainer, eAttributeFilter } from "./IAttributeContainer"; - -let _inheritedKey = "~[[inherited]]"; -let _deletedKey = "~[[deleted]]"; +import { STR_EMPTY, UNDEFINED_VALUE } from "../../constants/InternalConstants"; +import { eAttributeChangeOp } from "../../enums/otel/eAttributeChangeOp"; +import { IUnloadHook } from "../../interfaces/ai/IUnloadHook"; +import { IOTelAttributes, OTelAttributeValue } from "../../interfaces/otel/IOTelAttributes"; +import { IAttributeChangeInfo, IAttributeContainer, eAttributeFilter } from "../../interfaces/otel/attribute/IAttributeContainer"; +import { IOTelAttributeLimits } from "../../interfaces/otel/config/IOTelAttributeLimits"; +import { IOTelConfig } from "../../interfaces/otel/config/IOTelConfig"; +import { ITraceCfg } from "../../interfaces/otel/config/IOTelTraceCfg"; +import { handleAttribError } from "../../internal/handleErrors"; + +const _inheritedKey = "~[[inherited]]"; +const _deletedKey = "~[[deleted]]"; let _containerId = 0; type IAttributeBranch = { [key: string]: IAttributeNode }; @@ -573,14 +573,14 @@ function _createUnloadHook(listeners: { cb: (chang unloadHook.rm = _noOpFunc; } } - }; + }; return unloadHook; } /** * Creates a new attribute container with only configuration. - * + * * @param otelCfg - The OpenTelemetry configuration containing trace configuration and limits * @returns A new IAttributeContainer instance with auto-generated container ID * @since 3.4.0 @@ -595,7 +595,7 @@ export function createAttributeContainer(otelCfg: /** * Creates a new attribute container with configuration and a name. - * + * * @param otelCfg - The OpenTelemetry configuration containing trace configuration and limits * @param name - The name for the container (used in the container ID) * @returns A new IAttributeContainer instance with the specified name @@ -612,7 +612,7 @@ export function createAttributeContainer(otelCfg: /** * Creates a new attribute container with configuration, name, and inheritance. - * + * * @param otelCfg - The OpenTelemetry configuration containing trace configuration and limits * @param name - The name for the container (used in the container ID) * @param inheritAttrib - Parent attributes or container to inherit from @@ -631,7 +631,7 @@ export function createAttributeContainer(otelCfg: /** * Creates a new attribute container with full configuration options. - * + * * @param otelCfg - The OpenTelemetry configuration containing trace configuration and limits * @param name - The name for the container (used in the container ID) * @param inheritAttrib - Parent attributes or container to inherit from @@ -652,10 +652,10 @@ export function createAttributeContainer(otelCfg: /** * Creates a new attribute container that provides an efficient, observable key-value storage * for OpenTelemetry attributes with support for inheritance, limits, and change notifications. - * + * * The container supports inherited attributes from parent containers or plain objects, * enforces attribute count and value size limits, and provides efficient iteration and access patterns. - * + * * @param otelCfg - The OpenTelemetry configuration containing trace configuration and limits * @param name - Optional name for the container (used in the container ID) * @param inheritAttrib - Optional parent attributes or container to inherit from @@ -667,7 +667,7 @@ export function createAttributeContainer(otelCfg: * const config = { traceCfg: { generalLimits: { attributeCountLimit: 64 } } }; * const container = createAttributeContainer(config, "my-container"); * container.set("service.name", "my-service"); - * + * * // With inheritance * const parent = { "environment": "production" }; * const child = createAttributeContainer(config, "child-container", parent); @@ -734,7 +734,7 @@ export function createAttributeContainer(otelCfg: droppedAttribs = 0; inheritSrc = null; // Clear the inherited attributes inheritContainer = null; // Clear inherited container as well - inheritAttribObj = null; // Clear inherited attributes as well + inheritAttribObj = null; // Clear inherited attributes as well }, get: (key: string, source?: eAttributeFilter) => { return _findDetail(container, key, source, (detail) => { @@ -963,7 +963,7 @@ export function createAttributeContainer(otelCfg: * This function has performance and memory implications as it immediately copies all key-value pairs * from the source to the target container, handling both plain attribute objects and other attribute * containers. - * + * * @param container - The target container to add attributes to * @param attributes - The source attributes or container to copy from * @since 3.4.0 @@ -972,7 +972,7 @@ export function createAttributeContainer(otelCfg: * const target = createAttributeContainer(config, "target"); * const source = { key1: "value1", key2: "value2" }; * addAttributes(target, source); - * + * * // Or from another container * const sourceContainer = createAttributeContainer(config, "source"); * sourceContainer.set("key3", "value3"); @@ -1043,7 +1043,7 @@ function _createSnapshotContainer(otelCfg: IOTelConfig, name: string | undefined * may still add / update existing attributes without affecting the original source. And changes to the source * attributes / container will not be reflected from the new snapshot container, only changes made to the returned * container itself. - * + * * Note: It implements this in a lazy manner, so changes made to the original source after the snapshot is taken will * cause the changed attributes to be copied into this snapshot container with it's original value and cause a local * version of the changed key (if not already been present) to be added, so when using the {@link IAttributeContainer#has} or @@ -1054,7 +1054,7 @@ function _createSnapshotContainer(otelCfg: IOTelConfig, name: string | undefined * It is recommended that you always use {@link IAttributeContainer} instances for better memory and performance overheads, * for this specific function when you pass a {@link IOTelAttributes} instance it will create a copy of all present attributes * at the point of creation (not lazily). - * + * * @param otelCfg - The OpenTelemetry configuration to use for the snapshot container * @param source - The source attributes or container to create a snapshot view from * @param attribLimits - Optional attribute limits to apply to the snapshot container @@ -1077,6 +1077,7 @@ function _createSnapshotContainer(otelCfg: IOTelConfig, name: string | undefined * container.set("key1", "changed"); // snapshot2.get("key1") remains "value1" (previous value copied) * ``` */ +/*#__NO_SIDE_EFFECTS__*/ export function createAttributeSnapshot(otelCfg: IOTelConfig, name: string, source: IOTelAttributes | IAttributeContainer, attribLimits?: IOTelAttributeLimits): IAttributeContainer { let newContainer: IAttributeContainer; @@ -1103,7 +1104,7 @@ export function createAttributeSnapshot(otelCfg: IOTelConfig, name: string, sour * console.log(container.size); * container.set("key", "value"); * } - * + * * // Check unknown object * function processContainer(obj: unknown) { * if (isAttributeContainer(obj)) { @@ -1112,8 +1113,9 @@ export function createAttributeSnapshot(otelCfg: IOTelConfig, name: string, sour * } * ``` */ +/*#__NO_SIDE_EFFECTS__*/ export function isAttributeContainer(value: any): value is IAttributeContainer { - return value && + return value && isFunction(value.clear) && isFunction(value.get) && isFunction(value.has) && diff --git a/shared/AppInsightsCommon/src/ConnectionStringParser.ts b/shared/AppInsightsCore/src/telemetry/ConnectionStringParser.ts similarity index 87% rename from shared/AppInsightsCommon/src/ConnectionStringParser.ts rename to shared/AppInsightsCore/src/telemetry/ConnectionStringParser.ts index 4170f9d5c..3f277a841 100644 --- a/shared/AppInsightsCommon/src/ConnectionStringParser.ts +++ b/shared/AppInsightsCore/src/telemetry/ConnectionStringParser.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { arrReduce, objKeys, strEndsWith } from "@microsoft/applicationinsights-core-js"; -import { DEFAULT_BREEZE_ENDPOINT } from "./Constants"; -import { ConnectionString, ConnectionStringKey } from "./Interfaces/ConnectionString"; +import { arrReduce, objKeys, strEndsWith } from "@nevware21/ts-utils"; +import { DEFAULT_BREEZE_ENDPOINT } from "../constants/Constants"; +import { ConnectionString, ConnectionStringKey } from "../interfaces/ai/ConnectionString"; const _FIELDS_SEPARATOR = ";"; const _FIELD_KEY_VALUE_SEPARATOR = "="; diff --git a/shared/AppInsightsCommon/src/RequestResponseHeaders.ts b/shared/AppInsightsCore/src/telemetry/RequestResponseHeaders.ts similarity index 97% rename from shared/AppInsightsCommon/src/RequestResponseHeaders.ts rename to shared/AppInsightsCore/src/telemetry/RequestResponseHeaders.ts index 2118386ac..b2e40faec 100644 --- a/shared/AppInsightsCommon/src/RequestResponseHeaders.ts +++ b/shared/AppInsightsCore/src/telemetry/RequestResponseHeaders.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { createValueMap } from "@microsoft/applicationinsights-core-js"; +import { createValueMap } from "../enums/EnumHelperFuncs"; export interface IRequestHeaders { /** diff --git a/shared/AppInsightsCommon/src/TelemetryItemCreator.ts b/shared/AppInsightsCore/src/telemetry/TelemetryItemCreator.ts similarity index 85% rename from shared/AppInsightsCommon/src/TelemetryItemCreator.ts rename to shared/AppInsightsCore/src/telemetry/TelemetryItemCreator.ts index 3e9c4b7d0..9f6b07188 100644 --- a/shared/AppInsightsCommon/src/TelemetryItemCreator.ts +++ b/shared/AppInsightsCore/src/telemetry/TelemetryItemCreator.ts @@ -1,11 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { - IDiagnosticLogger, ITelemetryItem, isNullOrUndefined, objForEachKey, throwError, toISOString -} from "@microsoft/applicationinsights-core-js"; -import { strIkey, strNotSpecified } from "./Constants"; -import { dataSanitizeString } from "./Telemetry/Common/DataSanitizer"; +import { isNullOrUndefined, objForEachKey, throwError } from "@nevware21/ts-utils"; +import { strIkey, strNotSpecified } from "../constants/Constants"; +import { IDiagnosticLogger } from "../interfaces/ai/IDiagnosticLogger"; +import { ITelemetryItem } from "../interfaces/ai/ITelemetryItem"; +import { toISOString } from "../utils/HelperFuncs"; +import { dataSanitizeString } from "./ai/Common/DataSanitizer"; /** * Create a telemetry item that the 1DS channel understands diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/W3cTraceState.ts b/shared/AppInsightsCore/src/telemetry/W3cTraceState.ts similarity index 96% rename from shared/AppInsightsCore/src/JavaScriptSDK/W3cTraceState.ts rename to shared/AppInsightsCore/src/telemetry/W3cTraceState.ts index dc70a29f0..02546ac63 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK/W3cTraceState.ts +++ b/shared/AppInsightsCore/src/telemetry/W3cTraceState.ts @@ -5,10 +5,10 @@ import { ICachedValue, arrForEach, arrIndexOf, createCachedValue, isArray, isFunction, isNullOrUndefined, isString, objDefineProps, safeGetDeferred, strSplit } from "@nevware21/ts-utils"; -import { IW3cTraceState } from "../JavaScriptSDK.Interfaces/IW3cTraceState"; -import { findMetaTags, findNamedServerTimings } from "./EnvUtils"; -import { setObjStringTag } from "./HelperFuncs"; -import { STR_EMPTY } from "./InternalConstants"; +import { STR_EMPTY } from "../constants/InternalConstants"; +import { IW3cTraceState } from "../interfaces/ai/IW3cTraceState"; +import { findMetaTags, findNamedServerTimings } from "../utils/EnvUtils"; +import { setObjStringTag } from "../utils/HelperFuncs"; const MAX_TRACE_STATE_MEMBERS = 32; const MAX_TRACE_STATE_LEN = 512; @@ -27,7 +27,7 @@ const NBLK_CHAR = "\x21-\x2B\\--\x3C\x3E-\x7E"; const TRACESTATE_VALUE = "[\x20" + NBLK_CHAR + "]{0,255}[" + NBLK_CHAR + "]"; // https://www.w3.org/TR/trace-context-1/#tracestate-header -const TRACESTATE_KVP_REGEX = new RegExp("^\\s*((?:" + SIMPLE_KEY + "|" + MULTI_TENANT_KEY + ")=(" + TRACESTATE_VALUE + "))\\s*$"); +const TRACESTATE_KVP_REGEX = (/*#__PURE__*/ new RegExp("^\\s*((?:" + SIMPLE_KEY + "|" + MULTI_TENANT_KEY + ")=(" + TRACESTATE_VALUE + "))\\s*$")); /** * @internal @@ -189,6 +189,7 @@ function _keys(items: ITraceStateMember[], parent?: IW3cTraceState | null): stri * @param parent - The parent trace state to check for keys * @returns true if the items are empty, false otherwise */ +/*#__NO_SIDE_EFFECTS__*/ function _isEmpty(items: ITraceStateMember[], parent?: IW3cTraceState | null): boolean { let delKeys: string[]; let isEmpty = true; @@ -230,6 +231,7 @@ function _isEmpty(items: ITraceStateMember[], parent?: IW3cTraceState | null): b * @param value - The value to check * @returns - True if the value looks like a distributed trace state instance */ +/*#__NO_SIDE_EFFECTS__*/ export function isW3cTraceState(value: any): value is IW3cTraceState { return !!(value && isArray(value.keys) && isFunction(value.get) && isFunction(value.set) && isFunction(value.del) && isFunction(value.hdrs)); } @@ -245,6 +247,7 @@ export function isW3cTraceState(value: any): value is IW3cTraceState { * @param parent - The parent trace state to inherit any existing keys from. * @returns - A new distributed trace state instance */ +/*#__NO_SIDE_EFFECTS__*/ export function createW3cTraceState(value?: string | null, parent?: IW3cTraceState | null): IW3cTraceState { let cachedItems: ICachedValue = safeGetDeferred(_parseTraceStateList, [], [value || STR_EMPTY]); @@ -403,6 +406,7 @@ export function createW3cTraceState(value?: string | null, parent?: IW3cTraceSta * @param traceState - The trace state instance to snapshot * @returns A new independent instance of IW3cTraceState with all current key/value pairs captured */ +/*#__NO_SIDE_EFFECTS__*/ export function snapshotW3cTraceState(traceState: IW3cTraceState): IW3cTraceState { // Create a new independent instance with no parent // This ensures the returned instance is completely independent from future changes @@ -434,6 +438,7 @@ export function snapshotW3cTraceState(traceState: IW3cTraceState): IW3cTraceStat * @param selectIdx - If the found value is comma separated which is the preferred entry to select, defaults to the first * @returns */ +/*#__NO_SIDE_EFFECTS__*/ export function findW3cTraceState(): IW3cTraceState { const name = "tracestate"; let traceState: IW3cTraceState = null; diff --git a/shared/AppInsightsCommon/src/Telemetry/Common/Data.ts b/shared/AppInsightsCore/src/telemetry/ai/Common/Data.ts similarity index 82% rename from shared/AppInsightsCommon/src/Telemetry/Common/Data.ts rename to shared/AppInsightsCore/src/telemetry/ai/Common/Data.ts index ad7e91d7e..3049f0131 100644 --- a/shared/AppInsightsCommon/src/Telemetry/Common/Data.ts +++ b/shared/AppInsightsCore/src/telemetry/ai/Common/Data.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { FieldType } from "../../Enums"; -import { IData } from "../../Interfaces/Contracts/IData"; -import { ISerializable } from "../../Interfaces/Telemetry/ISerializable"; +import { FieldType } from "../../../enums/ai/Enums"; +import { IData } from "../../../interfaces/ai/contracts/IData"; +import { ISerializable } from "../../../interfaces/ai/telemetry/ISerializable"; /** * @deprecated - will be removed in future releases as this was only used by the applicationinsights-channel-js package. diff --git a/shared/AppInsightsCommon/src/Telemetry/Common/DataPoint.ts b/shared/AppInsightsCore/src/telemetry/ai/Common/DataPoint.ts similarity index 82% rename from shared/AppInsightsCommon/src/Telemetry/Common/DataPoint.ts rename to shared/AppInsightsCore/src/telemetry/ai/Common/DataPoint.ts index ca2233792..93268ee4b 100644 --- a/shared/AppInsightsCommon/src/Telemetry/Common/DataPoint.ts +++ b/shared/AppInsightsCore/src/telemetry/ai/Common/DataPoint.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { FieldType } from "../../Enums"; -import { DataPointType } from "../../Interfaces/Contracts/DataPointType"; -import { IDataPoint } from "../../Interfaces/Contracts/IDataPoint"; -import { ISerializable } from "../../Interfaces/Telemetry/ISerializable"; +import { FieldType } from "../../../enums/ai/Enums"; +import { DataPointType } from "../../../interfaces/ai/contracts/DataPointType"; +import { IDataPoint } from "../../../interfaces/ai/contracts/IDataPoint"; +import { ISerializable } from "../../../interfaces/ai/telemetry/ISerializable"; export class DataPoint implements IDataPoint, ISerializable { diff --git a/shared/AppInsightsCommon/src/Telemetry/Common/DataSanitizer.ts b/shared/AppInsightsCore/src/telemetry/ai/Common/DataSanitizer.ts similarity index 89% rename from shared/AppInsightsCommon/src/Telemetry/Common/DataSanitizer.ts rename to shared/AppInsightsCore/src/telemetry/ai/Common/DataSanitizer.ts index daae63b91..ef9f34001 100644 --- a/shared/AppInsightsCommon/src/Telemetry/Common/DataSanitizer.ts +++ b/shared/AppInsightsCore/src/telemetry/ai/Common/DataSanitizer.ts @@ -1,11 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { - IConfiguration, IDiagnosticLogger, _eInternalMessageId, _throwInternal, eLoggingSeverity, fieldRedaction, getJSON, hasJSON, isObject, - objForEachKey, strTrim -} from "@microsoft/applicationinsights-core-js"; -import { asString, isString, strSubstr, strSubstring } from "@nevware21/ts-utils"; +import { asString, isObject, isString, objForEachKey, strSubstr, strSubstring, strTrim } from "@nevware21/ts-utils"; +import { _throwInternal } from "../../../diagnostics/DiagnosticLogger"; +import { _eInternalMessageId, eLoggingSeverity } from "../../../enums/ai/LoggingEnums"; +import { IConfiguration } from "../../../interfaces/ai/IConfiguration"; +import { IDiagnosticLogger } from "../../../interfaces/ai/IDiagnosticLogger"; +import { fieldRedaction, getJSON, hasJSON } from "../../../utils/EnvUtils"; export const enum DataSanitizerValues { /** @@ -44,6 +45,7 @@ export const enum DataSanitizerValues { MAX_EXCEPTION_LENGTH = 32768 } +/*#__NO_SIDE_EFFECTS__*/ export function dataSanitizeKeyAndAddUniqueness(logger: IDiagnosticLogger, key: any, map: any) { const origLength = key.length; let field = dataSanitizeKey(logger, key); @@ -61,6 +63,7 @@ export function dataSanitizeKeyAndAddUniqueness(logger: IDiagnosticLogger, key: return field; } +/*#__NO_SIDE_EFFECTS__*/ export function dataSanitizeKey(logger: IDiagnosticLogger, name: any) { let nameTrunc: String; if (name) { @@ -81,6 +84,7 @@ export function dataSanitizeKey(logger: IDiagnosticLogger, name: any) { return nameTrunc || name; } +/*#__NO_SIDE_EFFECTS__*/ export function dataSanitizeString(logger: IDiagnosticLogger, value: any, maxLength: number = DataSanitizerValues.MAX_STRING_LENGTH) { let valueTrunc : String; if (value) { @@ -99,6 +103,7 @@ export function dataSanitizeString(logger: IDiagnosticLogger, value: any, maxLen return valueTrunc || value; } +/*#__NO_SIDE_EFFECTS__*/ export function dataSanitizeUrl(logger: IDiagnosticLogger, url: any, config?: IConfiguration) { if (isString(url)) { url = fieldRedaction(url, config); @@ -106,6 +111,7 @@ export function dataSanitizeUrl(logger: IDiagnosticLogger, url: any, config?: IC return dataSanitizeInput(logger, url, DataSanitizerValues.MAX_URL_LENGTH, _eInternalMessageId.UrlTooLong); } +/*#__NO_SIDE_EFFECTS__*/ export function dataSanitizeMessage(logger: IDiagnosticLogger, message: any) { let messageTrunc : String; if (message) { @@ -122,6 +128,7 @@ export function dataSanitizeMessage(logger: IDiagnosticLogger, message: any) { return messageTrunc || message; } +/*#__NO_SIDE_EFFECTS__*/ export function dataSanitizeException(logger: IDiagnosticLogger, exception: any) { let exceptionTrunc : String; if (exception) { @@ -138,6 +145,7 @@ export function dataSanitizeException(logger: IDiagnosticLogger, exception: any) return exceptionTrunc || exception; } +/*#__NO_SIDE_EFFECTS__*/ export function dataSanitizeProperties(logger: IDiagnosticLogger, properties: any) { if (properties) { const tempProps = {}; @@ -160,6 +168,7 @@ export function dataSanitizeProperties(logger: IDiagnosticLogger, properties: an return properties; } +/*#__NO_SIDE_EFFECTS__*/ export function dataSanitizeMeasurements(logger: IDiagnosticLogger, measurements: any) { if (measurements) { const tempMeasurements = {}; @@ -174,10 +183,12 @@ export function dataSanitizeMeasurements(logger: IDiagnosticLogger, measurements return measurements; } +/*#__NO_SIDE_EFFECTS__*/ export function dataSanitizeId(logger: IDiagnosticLogger, id: string): string { return id ? dataSanitizeInput(logger, id, DataSanitizerValues.MAX_ID_LENGTH, _eInternalMessageId.IdTooLong).toString() : id; } +/*#__NO_SIDE_EFFECTS__*/ export function dataSanitizeInput(logger: IDiagnosticLogger, input: any, maxLength: number, _msgId: _eInternalMessageId) { let inputTrunc : String; if (input) { @@ -196,6 +207,7 @@ export function dataSanitizeInput(logger: IDiagnosticLogger, input: any, maxLeng return inputTrunc || input; } +/*#__NO_SIDE_EFFECTS__*/ export function dsPadNumber(num: number) { const s = "00" + num; return strSubstr(s, s.length - 3); diff --git a/shared/AppInsightsCommon/src/Telemetry/Common/Envelope.ts b/shared/AppInsightsCore/src/telemetry/ai/Common/Envelope.ts similarity index 87% rename from shared/AppInsightsCommon/src/Telemetry/Common/Envelope.ts rename to shared/AppInsightsCore/src/telemetry/ai/Common/Envelope.ts index 3918904a9..c08e68abe 100644 --- a/shared/AppInsightsCommon/src/Telemetry/Common/Envelope.ts +++ b/shared/AppInsightsCore/src/telemetry/ai/Common/Envelope.ts @@ -1,11 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { IDiagnosticLogger, toISOString } from "@microsoft/applicationinsights-core-js"; -import { strNotSpecified } from "../../Constants"; -import { FieldType } from "../../Enums"; -import { IBase } from "../../Interfaces/Contracts/IBase"; -import { IEnvelope } from "../../Interfaces/Telemetry/IEnvelope"; +import { strNotSpecified } from "../../../constants/Constants"; +import { FieldType } from "../../../enums/ai/Enums"; +import { IDiagnosticLogger } from "../../../interfaces/ai/IDiagnosticLogger"; +import { IBase } from "../../../interfaces/ai/contracts/IBase"; +import { IEnvelope } from "../../../interfaces/ai/telemetry/IEnvelope"; +import { toISOString } from "../../../utils/HelperFuncs"; import { dataSanitizeString } from "./DataSanitizer"; export class Envelope implements IEnvelope { diff --git a/shared/AppInsightsCommon/src/Telemetry/DataTypes.ts b/shared/AppInsightsCore/src/telemetry/ai/DataTypes.ts similarity index 100% rename from shared/AppInsightsCommon/src/Telemetry/DataTypes.ts rename to shared/AppInsightsCore/src/telemetry/ai/DataTypes.ts diff --git a/shared/AppInsightsCore/src/telemetry/ai/EnvelopeTypes.ts b/shared/AppInsightsCore/src/telemetry/ai/EnvelopeTypes.ts new file mode 100644 index 000000000..f13a3a5fc --- /dev/null +++ b/shared/AppInsightsCore/src/telemetry/ai/EnvelopeTypes.ts @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/* #__NO_SIDE_EFFECTS__# */ +function _AddPrefix(name: string) { + return "Microsoft.ApplicationInsights.{0}." + name; +} + +export const EventEnvelopeType = (/*#__PURE__*/ _AddPrefix("Event")); +export const ExceptionEnvelopeType = (/*#__PURE__*/ _AddPrefix("Exception")); +export const MetricEnvelopeType = (/*#__PURE__*/ _AddPrefix("Metric")); +export const PageViewEnvelopeType = (/*#__PURE__*/ _AddPrefix("Pageview")); +export const PageViewPerformanceEnvelopeType = (/*#__PURE__*/ _AddPrefix("PageviewPerformance")); +export const RemoteDependencyEnvelopeType = (/*#__PURE__*/ _AddPrefix("RemoteDependency")); +export const RequestEnvelopeType = (/*#__PURE__*/ _AddPrefix("Request")); +export const TraceEnvelopeType = (/*#__PURE__*/ _AddPrefix("Message")); \ No newline at end of file diff --git a/shared/AppInsightsCommon/src/Telemetry/Event.ts b/shared/AppInsightsCore/src/telemetry/ai/Event.ts similarity index 83% rename from shared/AppInsightsCommon/src/Telemetry/Event.ts rename to shared/AppInsightsCore/src/telemetry/ai/Event.ts index 9cb6af568..769fa3e39 100644 --- a/shared/AppInsightsCommon/src/Telemetry/Event.ts +++ b/shared/AppInsightsCore/src/telemetry/ai/Event.ts @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { IDiagnosticLogger } from "@microsoft/applicationinsights-core-js"; -import { strNotSpecified } from "../Constants"; -import { FieldType } from "../Enums"; -import { IEventData } from "../Interfaces/Contracts/IEventData"; -import { ISerializable } from "../Interfaces/Telemetry/ISerializable"; +import { strNotSpecified } from "../../constants/Constants"; +import { FieldType } from "../../enums/ai/Enums"; +import { IDiagnosticLogger } from "../../interfaces/ai/IDiagnosticLogger"; +import { IEventData } from "../../interfaces/ai/contracts/IEventData"; +import { ISerializable } from "../../interfaces/ai/telemetry/ISerializable"; import { dataSanitizeMeasurements, dataSanitizeProperties, dataSanitizeString } from "./Common/DataSanitizer"; import { EventDataType } from "./DataTypes"; import { EventEnvelopeType } from "./EnvelopeTypes"; diff --git a/shared/AppInsightsCommon/src/Telemetry/Exception.ts b/shared/AppInsightsCore/src/telemetry/ai/Exception.ts similarity index 96% rename from shared/AppInsightsCommon/src/Telemetry/Exception.ts rename to shared/AppInsightsCore/src/telemetry/ai/Exception.ts index 6abc5f8f0..2b4f9d02e 100644 --- a/shared/AppInsightsCommon/src/Telemetry/Exception.ts +++ b/shared/AppInsightsCore/src/telemetry/ai/Exception.ts @@ -2,17 +2,20 @@ // Licensed under the MIT License. import { - IDiagnosticLogger, arrForEach, arrMap, isArray, isError, isFunction, isNullOrUndefined, isObject, isString, strTrim -} from "@microsoft/applicationinsights-core-js"; -import { asString, getWindow, objFreeze, strIndexOf } from "@nevware21/ts-utils"; -import { strNotSpecified } from "../Constants"; -import { FieldType } from "../Enums"; -import { IExceptionData } from "../Interfaces/Contracts/IExceptionData"; -import { IExceptionDetails } from "../Interfaces/Contracts/IExceptionDetails"; -import { IStackFrame } from "../Interfaces/Contracts/IStackFrame"; -import { SeverityLevel } from "../Interfaces/Contracts/SeverityLevel"; -import { IAutoExceptionTelemetry, IExceptionDetailsInternal, IExceptionInternal, IStackDetails } from "../Interfaces/IExceptionTelemetry"; -import { ISerializable } from "../Interfaces/Telemetry/ISerializable"; + arrForEach, arrMap, asString, getWindow, isArray, isError, isFunction, isNullOrUndefined, isObject, isString, objFreeze, strIndexOf, + strTrim +} from "@nevware21/ts-utils"; +import { strNotSpecified } from "../../constants/Constants"; +import { FieldType } from "../../enums/ai/Enums"; +import { IDiagnosticLogger } from "../../interfaces/ai/IDiagnosticLogger"; +import { + IAutoExceptionTelemetry, IExceptionDetailsInternal, IExceptionInternal, IStackDetails +} from "../../interfaces/ai/IExceptionTelemetry"; +import { IExceptionData } from "../../interfaces/ai/contracts/IExceptionData"; +import { IExceptionDetails } from "../../interfaces/ai/contracts/IExceptionDetails"; +import { IStackFrame } from "../../interfaces/ai/contracts/IStackFrame"; +import { SeverityLevel } from "../../interfaces/ai/contracts/SeverityLevel"; +import { ISerializable } from "../../interfaces/ai/telemetry/ISerializable"; import { dataSanitizeException, dataSanitizeMeasurements, dataSanitizeMessage, dataSanitizeProperties, dataSanitizeString } from "./Common/DataSanitizer"; @@ -702,7 +705,7 @@ export class Exception implements IExceptionData, ISerializable { public static formatError = _formatErrorCode; } -const exDetailsAiDataContract = objFreeze({ +const exDetailsAiDataContract = (/*#__PURE__*/ objFreeze({ id: FieldType.Default, outerId: FieldType.Default, typeName: FieldType.Required, @@ -710,7 +713,7 @@ const exDetailsAiDataContract = objFreeze({ hasFullStack: FieldType.Default, stack: FieldType.Default, parsedStack: FieldType.Array -}); +})); interface _IExceptionDetails extends IExceptionDetails, ISerializable { toInterface: () => IExceptionDetailsInternal; @@ -850,13 +853,13 @@ export interface _IParsedStackFrame extends IStackFrame, ISerializable { sizeInBytes: number; } -const stackFrameAiDataContract = objFreeze({ +const stackFrameAiDataContract = (/*#__PURE__*/ objFreeze({ level: FieldType.Required, method: FieldType.Required, assembly: FieldType.Default, fileName: FieldType.Default, line: FieldType.Default -}); +})); export function _extractStackFrame(frame: string, level: number): _IParsedStackFrame | undefined { let theFrame: _IParsedStackFrame; diff --git a/shared/AppInsightsCommon/src/Telemetry/Metric.ts b/shared/AppInsightsCore/src/telemetry/ai/Metric.ts similarity index 87% rename from shared/AppInsightsCommon/src/Telemetry/Metric.ts rename to shared/AppInsightsCore/src/telemetry/ai/Metric.ts index a2b955eab..a302e5b22 100644 --- a/shared/AppInsightsCommon/src/Telemetry/Metric.ts +++ b/shared/AppInsightsCore/src/telemetry/ai/Metric.ts @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { IDiagnosticLogger } from "@microsoft/applicationinsights-core-js"; -import { strNotSpecified } from "../Constants"; -import { FieldType } from "../Enums"; -import { IMetricData } from "../Interfaces/Contracts/IMetricData"; -import { ISerializable } from "../Interfaces/Telemetry/ISerializable"; +import { strNotSpecified } from "../../constants/Constants"; +import { FieldType } from "../../enums/ai/Enums"; +import { IDiagnosticLogger } from "../../interfaces/ai/IDiagnosticLogger"; +import { IMetricData } from "../../interfaces/ai/contracts/IMetricData"; +import { ISerializable } from "../../interfaces/ai/telemetry/ISerializable"; import { DataPoint } from "./Common/DataPoint"; import { dataSanitizeMeasurements, dataSanitizeProperties, dataSanitizeString } from "./Common/DataSanitizer"; import { MetricDataType } from "./DataTypes"; diff --git a/shared/AppInsightsCommon/src/Telemetry/PageView.ts b/shared/AppInsightsCore/src/telemetry/ai/PageView.ts similarity index 86% rename from shared/AppInsightsCommon/src/Telemetry/PageView.ts rename to shared/AppInsightsCore/src/telemetry/ai/PageView.ts index feaa39993..279c3fde7 100644 --- a/shared/AppInsightsCommon/src/Telemetry/PageView.ts +++ b/shared/AppInsightsCore/src/telemetry/ai/PageView.ts @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { IDiagnosticLogger } from "@microsoft/applicationinsights-core-js"; -import { strNotSpecified } from "../Constants"; -import { FieldType } from "../Enums"; -import { msToTimeSpan } from "../HelperFuncs"; -import { IPageViewData } from "../Interfaces/Contracts/IPageViewData"; -import { ISerializable } from "../Interfaces/Telemetry/ISerializable"; +import { strNotSpecified } from "../../constants/Constants"; +import { FieldType } from "../../enums/ai/Enums"; +import { IDiagnosticLogger } from "../../interfaces/ai/IDiagnosticLogger"; +import { IPageViewData } from "../../interfaces/ai/contracts/IPageViewData"; +import { ISerializable } from "../../interfaces/ai/telemetry/ISerializable"; +import { msToTimeSpan } from "../../utils/HelperFuncsCore"; import { dataSanitizeId, dataSanitizeMeasurements, dataSanitizeProperties, dataSanitizeString, dataSanitizeUrl } from "./Common/DataSanitizer"; diff --git a/shared/AppInsightsCommon/src/Telemetry/PageViewPerformance.ts b/shared/AppInsightsCore/src/telemetry/ai/PageViewPerformance.ts similarity index 89% rename from shared/AppInsightsCommon/src/Telemetry/PageViewPerformance.ts rename to shared/AppInsightsCore/src/telemetry/ai/PageViewPerformance.ts index 8f13eb350..0b11d83ca 100644 --- a/shared/AppInsightsCommon/src/Telemetry/PageViewPerformance.ts +++ b/shared/AppInsightsCore/src/telemetry/ai/PageViewPerformance.ts @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { IDiagnosticLogger } from "@microsoft/applicationinsights-core-js"; -import { strNotSpecified } from "../Constants"; -import { FieldType } from "../Enums"; -import { IPageViewPerfData } from "../Interfaces/Contracts/IPageViewPerfData"; -import { IPageViewPerformanceTelemetry } from "../Interfaces/IPageViewPerformanceTelemetry"; -import { ISerializable } from "../Interfaces/Telemetry/ISerializable"; +import { strNotSpecified } from "../../constants/Constants"; +import { FieldType } from "../../enums/ai/Enums"; +import { IDiagnosticLogger } from "../../interfaces/ai/IDiagnosticLogger"; +import { IPageViewPerformanceTelemetry } from "../../interfaces/ai/IPageViewPerformanceTelemetry"; +import { IPageViewPerfData } from "../../interfaces/ai/contracts/IPageViewPerfData"; +import { ISerializable } from "../../interfaces/ai/telemetry/ISerializable"; import { dataSanitizeMeasurements, dataSanitizeProperties, dataSanitizeString, dataSanitizeUrl } from "./Common/DataSanitizer"; import { PageViewPerformanceDataType } from "./DataTypes"; import { PageViewPerformanceEnvelopeType } from "./EnvelopeTypes"; diff --git a/shared/AppInsightsCommon/src/Telemetry/RemoteDependencyData.ts b/shared/AppInsightsCore/src/telemetry/ai/RemoteDependencyData.ts similarity index 91% rename from shared/AppInsightsCommon/src/Telemetry/RemoteDependencyData.ts rename to shared/AppInsightsCore/src/telemetry/ai/RemoteDependencyData.ts index 5b6492053..bf9e337d7 100644 --- a/shared/AppInsightsCommon/src/Telemetry/RemoteDependencyData.ts +++ b/shared/AppInsightsCore/src/telemetry/ai/RemoteDependencyData.ts @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { IDiagnosticLogger } from "@microsoft/applicationinsights-core-js"; -import { FieldType } from "../Enums"; -import { msToTimeSpan } from "../HelperFuncs"; -import { IRemoteDependencyData } from "../Interfaces/Contracts/IRemoteDependencyData"; -import { ISerializable } from "../Interfaces/Telemetry/ISerializable"; -import { AjaxHelperParseDependencyPath } from "../Util"; +import { FieldType } from "../../enums/ai/Enums"; +import { IDiagnosticLogger } from "../../interfaces/ai/IDiagnosticLogger"; +import { IRemoteDependencyData } from "../../interfaces/ai/contracts/IRemoteDependencyData"; +import { ISerializable } from "../../interfaces/ai/telemetry/ISerializable"; +import { msToTimeSpan } from "../../utils/HelperFuncsCore"; +import { AjaxHelperParseDependencyPath } from "../../utils/Util"; import { dataSanitizeMeasurements, dataSanitizeProperties, dataSanitizeString, dataSanitizeUrl } from "./Common/DataSanitizer"; import { RemoteDependencyDataType } from "./DataTypes"; import { RemoteDependencyEnvelopeType } from "./EnvelopeTypes"; diff --git a/shared/AppInsightsCommon/src/Telemetry/Trace.ts b/shared/AppInsightsCore/src/telemetry/ai/Trace.ts similarity index 81% rename from shared/AppInsightsCommon/src/Telemetry/Trace.ts rename to shared/AppInsightsCore/src/telemetry/ai/Trace.ts index b4316ed58..f04bfb890 100644 --- a/shared/AppInsightsCommon/src/Telemetry/Trace.ts +++ b/shared/AppInsightsCore/src/telemetry/ai/Trace.ts @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { IDiagnosticLogger } from "@microsoft/applicationinsights-core-js"; -import { strNotSpecified } from "../Constants"; -import { FieldType } from "../Enums"; -import { IMessageData } from "../Interfaces/Contracts/IMessageData"; -import { SeverityLevel } from "../Interfaces/Contracts/SeverityLevel"; -import { ISerializable } from "../Interfaces/Telemetry/ISerializable"; +import { strNotSpecified } from "../../constants/Constants"; +import { FieldType } from "../../enums/ai/Enums"; +import { IDiagnosticLogger } from "../../interfaces/ai/IDiagnosticLogger"; +import { IMessageData } from "../../interfaces/ai/contracts/IMessageData"; +import { SeverityLevel } from "../../interfaces/ai/contracts/SeverityLevel"; +import { ISerializable } from "../../interfaces/ai/telemetry/ISerializable"; import { dataSanitizeMeasurements, dataSanitizeMessage, dataSanitizeProperties } from "./Common/DataSanitizer"; import { TraceDataType } from "./DataTypes"; import { TraceEnvelopeType } from "./EnvelopeTypes"; diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/CoreUtils.ts b/shared/AppInsightsCore/src/utils/CoreUtils.ts similarity index 97% rename from shared/AppInsightsCore/src/JavaScriptSDK/CoreUtils.ts rename to shared/AppInsightsCore/src/utils/CoreUtils.ts index 78d3b4c64..856fdda23 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK/CoreUtils.ts +++ b/shared/AppInsightsCore/src/utils/CoreUtils.ts @@ -3,7 +3,7 @@ "use strict"; import { strShimUndefined } from "@microsoft/applicationinsights-shims"; import { strSubstr, strSubstring } from "@nevware21/ts-utils"; -import { STR_EMPTY } from "./InternalConstants"; +import { STR_EMPTY } from "../constants/InternalConstants"; import { random32 } from "./RandomHelper"; // Added to help with minfication diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/DataCacheHelper.ts b/shared/AppInsightsCore/src/utils/DataCacheHelper.ts similarity index 97% rename from shared/AppInsightsCore/src/JavaScriptSDK/DataCacheHelper.ts rename to shared/AppInsightsCore/src/utils/DataCacheHelper.ts index 79f2e2bac..cd02749a2 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK/DataCacheHelper.ts +++ b/shared/AppInsightsCore/src/utils/DataCacheHelper.ts @@ -2,8 +2,8 @@ // Licensed under the MIT License. import { objDefine } from "@nevware21/ts-utils"; +import { STR_EMPTY } from "../constants/InternalConstants"; import { normalizeJsName } from "./HelperFuncs"; -import { STR_EMPTY } from "./InternalConstants"; import { newId } from "./RandomHelper"; const version = "#version#"; diff --git a/shared/AppInsightsCommon/src/DomHelperFuncs.ts b/shared/AppInsightsCore/src/utils/DomHelperFuncs.ts similarity index 86% rename from shared/AppInsightsCommon/src/DomHelperFuncs.ts rename to shared/AppInsightsCore/src/utils/DomHelperFuncs.ts index d13b28267..d5f323ec3 100644 --- a/shared/AppInsightsCommon/src/DomHelperFuncs.ts +++ b/shared/AppInsightsCore/src/utils/DomHelperFuncs.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { getDocument, isFunction } from "@microsoft/applicationinsights-core-js"; +import { getDocument, isFunction } from "@nevware21/ts-utils"; export function createDomEvent(eventName: string): Event { let event: Event = null; diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/EnvUtils.ts b/shared/AppInsightsCore/src/utils/EnvUtils.ts similarity index 84% rename from shared/AppInsightsCore/src/JavaScriptSDK/EnvUtils.ts rename to shared/AppInsightsCore/src/utils/EnvUtils.ts index 01c6481ff..ed2382901 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK/EnvUtils.ts +++ b/shared/AppInsightsCore/src/utils/EnvUtils.ts @@ -4,12 +4,12 @@ import { getGlobal, strShimObject, strShimPrototype, strShimUndefined } from "@microsoft/applicationinsights-shims"; import { - arrForEach, getDocument, getInst, getNavigator, getPerformance, hasNavigator, isFunction, isNullOrUndefined, isString, isUndefined, - mathMax, strIndexOf, strSubstring + ICachedValue, arrForEach, createCachedValue, getDeferred, getDocument, getInst, getLazy, getNavigator, getPerformance, hasNavigator, + isFunction, isNullOrUndefined, isString, isUndefined, mathMax, strIndexOf, strSubstring } from "@nevware21/ts-utils"; -import { IConfiguration } from "../applicationinsights-core-js"; +import { DEFAULT_SENSITIVE_PARAMS, STR_EMPTY, STR_REDACTED } from "../constants/InternalConstants"; +import { IConfiguration } from "../interfaces/ai/IConfiguration"; import { strContains } from "./HelperFuncs"; -import { DEFAULT_SENSITIVE_PARAMS, STR_EMPTY, STR_REDACTED } from "./InternalConstants"; // TypeScript removed this interface so we need to declare the global so we can check for it's existence. declare var XDomainRequest: any; @@ -32,11 +32,13 @@ const strMsie = "msie"; const strTrident = "trident/"; const strXMLHttpRequest = "XMLHttpRequest"; -let _isTrident: boolean = null; -let _navUserAgentCheck: string = null; +// Local cached properties which are used to avoid multiple checks within the module +let _isTrident: ICachedValue; +let _navUserAgentCheck: string; let _enableMocks = false; -let _useXDomainRequest: boolean | null = null; -let _beaconsSupported: boolean | null = null; +let _useXDomainRequest: ICachedValue; +let _beaconsSupported: ICachedValue; +let _userAgent: ICachedValue; function _hasProperty(theClass: any, property: string) { let supported = false; @@ -66,6 +68,19 @@ function _hasProperty(theClass: any, property: string) { return supported; } +/*#__NO_SIDE_EFFECTS__*/ +export function getUserAgentString(): string { + if (!_userAgent) { + // Use lazy to allow mocking + _userAgent = getLazy(() => { + let nav = getNavigator() || {} as Navigator; + return nav.userAgent || STR_EMPTY; + }); + } + + return _userAgent.v; +} + /** * Enable the lookup of test mock objects if requested * @param enabled - A flag to enable or disable the mock @@ -79,6 +94,7 @@ export function setEnableEnvMocks(enabled: boolean) { * This helper is used to access the location object without causing an exception * "Uncaught ReferenceError: location is not defined" */ +/*#__NO_SIDE_EFFECTS__*/ export function getLocation(checkForMock?: boolean): Location | null { if (checkForMock && _enableMocks) { let mockLocation = getInst("__mockLocation") as Location; @@ -97,6 +113,7 @@ export function getLocation(checkForMock?: boolean): Location | null { /** * Returns the global console object */ +/*#__NO_SIDE_EFFECTS__*/ export function getConsole(): Console | null { if (typeof console !== strShimUndefined) { return console; @@ -112,6 +129,7 @@ export function getConsole(): Console | null { * exception will be thrown. * Defined as a function to support lazy / late binding environments. */ +/*#__NO_SIDE_EFFECTS__*/ export function hasJSON(): boolean { return Boolean((typeof JSON === strShimObject && JSON) || getInst(strJSON) !== null); } @@ -121,6 +139,7 @@ export function hasJSON(): boolean { * This helper is used to access the JSON object without causing an exception * "Uncaught ReferenceError: JSON is not defined" */ +/*#__NO_SIDE_EFFECTS__*/ export function getJSON(): JSON | null { if (hasJSON()) { return JSON || getInst(strJSON); @@ -134,6 +153,7 @@ export function getJSON(): JSON | null { * This helper is used to access the crypto object from the current * global instance which could be window or globalThis for a web worker */ +/*#__NO_SIDE_EFFECTS__*/ export function getCrypto(): Crypto | null { return getInst(strCrypto); } @@ -143,6 +163,7 @@ export function getCrypto(): Crypto | null { * This helper is used to access the crypto object from the current * global instance which could be window or globalThis for a web worker */ +/*#__NO_SIDE_EFFECTS__*/ export function getMsCrypto(): Crypto | null { return getInst(strMsCrypto); } @@ -150,6 +171,7 @@ export function getMsCrypto(): Crypto | null { /** * Returns whether the environment is reporting that we are running in a React Native Environment */ +/*#__NO_SIDE_EFFECTS__*/ export function isReactNative(): boolean { // If running in React Native, navigator.product will be populated var nav = getNavigator(); @@ -163,25 +185,26 @@ export function isReactNative(): boolean { /** * Identifies whether the current environment appears to be IE */ +/*#__NO_SIDE_EFFECTS__*/ export function isIE() { - let nav = getNavigator(); - if (nav && (nav.userAgent !== _navUserAgentCheck || _isTrident === null)) { + let userAgent = getUserAgentString(); + if (!_isTrident || userAgent !== _navUserAgentCheck) { // Added to support test mocking of the user agent - _navUserAgentCheck = nav.userAgent; - let userAgent = (_navUserAgentCheck || STR_EMPTY).toLowerCase(); - _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident)); + _navUserAgentCheck = userAgent; + let lwrUserAgent = _navUserAgentCheck.toLowerCase(); + _isTrident = createCachedValue( strContains(lwrUserAgent, strMsie) || strContains(lwrUserAgent, strTrident)); } - return _isTrident; + return _isTrident.v; } /** * Gets IE version returning the document emulation mode if we are running on IE, or null otherwise */ +/*#__NO_SIDE_EFFECTS__*/ export function getIEVersion(userAgentStr: string = null): number { if (!userAgentStr) { - let navigator = getNavigator() || ({} as Navigator); - userAgentStr = navigator ? (navigator.userAgent || STR_EMPTY).toLowerCase() : STR_EMPTY; + userAgentStr = getUserAgentString(); } var ua = (userAgentStr || STR_EMPTY).toLowerCase(); @@ -199,10 +222,10 @@ export function getIEVersion(userAgentStr: string = null): number { return null; } +/*#__NO_SIDE_EFFECTS__*/ export function isSafari(userAgentStr ?: string) { if (!userAgentStr || !isString(userAgentStr)) { - let navigator = getNavigator() || ({} as Navigator); - userAgentStr = navigator ? (navigator.userAgent || STR_EMPTY).toLowerCase() : STR_EMPTY; + userAgentStr = getUserAgentString().toLowerCase(); } var ua = (userAgentStr || STR_EMPTY).toLowerCase(); @@ -210,17 +233,19 @@ export function isSafari(userAgentStr ?: string) { } /** - * Checks if HTML5 Beacons are supported in the current environment. + * Checks if HTML5 Beacons are supported in the current environment. There is a side effect (for testing) + * when `useCached` is set to `false`, it will reset the cached value causing all future calls to + * use the new re-evaluated value for all future calls. * @param useCached - [Optional] used for testing to bypass the cached lookup, when `true` this will * cause the cached global to be reset. * @returns True if supported, false otherwise. */ export function isBeaconsSupported(useCached?: boolean): boolean { - if (_beaconsSupported === null || useCached === false) { - _beaconsSupported = hasNavigator() && Boolean(getNavigator().sendBeacon); + if (!_beaconsSupported || useCached === false) { + _beaconsSupported = createCachedValue(hasNavigator() && !!(getNavigator().sendBeacon)); } - return _beaconsSupported; + return _beaconsSupported.v; } /** @@ -228,6 +253,7 @@ export function isBeaconsSupported(useCached?: boolean): boolean { * @param withKeepAlive - [Optional] If True, check if fetch is available and it supports the keepalive feature, otherwise only check if fetch is supported * @returns True if supported, otherwise false */ +/*#__NO_SIDE_EFFECTS__*/ export function isFetchSupported(withKeepAlive?: boolean): boolean { let isSupported = false; try { @@ -243,21 +269,27 @@ export function isFetchSupported(withKeepAlive?: boolean): boolean { return isSupported; } +/*#__NO_SIDE_EFFECTS__*/ export function useXDomainRequest(): boolean | undefined { - if (_useXDomainRequest === null) { - _useXDomainRequest = (typeof XDomainRequest !== strShimUndefined); - if (_useXDomainRequest && isXhrSupported()) { - _useXDomainRequest = _useXDomainRequest && !_hasProperty(getInst(strXMLHttpRequest), "withCredentials"); - } + if (!_useXDomainRequest) { + _useXDomainRequest = getDeferred(() => { + let useXDomainRequest = (typeof XDomainRequest !== strShimUndefined); + if (useXDomainRequest && isXhrSupported()) { + useXDomainRequest = useXDomainRequest && !_hasProperty(getInst(strXMLHttpRequest), "withCredentials"); + } + + return !!useXDomainRequest; + }); } - return _useXDomainRequest; + return _useXDomainRequest.v; } /** * Checks if XMLHttpRequest is supported * @returns True if supported, otherwise false */ +/*#__NO_SIDE_EFFECTS__*/ export function isXhrSupported(): boolean { let isSupported = false; try { @@ -270,7 +302,7 @@ export function isXhrSupported(): boolean { return isSupported; } - +/*#__NO_SIDE_EFFECTS__*/ function _getNamedValue(values: any, name: string): T[] { let items: T[] = []; if (values) { @@ -290,6 +322,7 @@ function _getNamedValue(values: any, name: string): T[] { * Helper function to fetch the named meta-tag from the page. * @param name - The name of the meta-tag to find. */ +/*#__NO_SIDE_EFFECTS__*/ export function findMetaTag(name: string): any { let tags = findMetaTags(name); if (tags.length > 0) { @@ -305,6 +338,7 @@ export function findMetaTag(name: string): any { * @param name - The name of the meta-tag to find. * @returns - An array of meta-tag values. */ +/*#__NO_SIDE_EFFECTS__*/ export function findMetaTags(name: string): string[] { let tags: string[] = []; let doc = getDocument(); @@ -322,6 +356,7 @@ export function findMetaTags(name: string): string[] { * Helper function to fetch the named server timing value from the page response (first navigation event). * @param name - The name of the server timing value to find. */ +/*#__NO_SIDE_EFFECTS__*/ export function findNamedServerTiming(name: string): any { let value: any; let serverTimings = findNamedServerTimings(name); @@ -338,6 +373,7 @@ export function findNamedServerTiming(name: string): any { * @param name - The name of the server timing value to find. * @returns - An array of server timing values. */ +/*#__NO_SIDE_EFFECTS__*/ export function findNamedServerTimings(name: string): string[] { let values: string[] = []; let perf = getPerformance(); @@ -366,6 +402,7 @@ export function dispatchEvent(target:EventTarget, evnt: Event | CustomEvent): bo } +/*#__NO_SIDE_EFFECTS__*/ export function createCustomDomEvent(eventName: string, details?: any): CustomEvent { let event: CustomEvent = null; let detail = {detail: details || null } as CustomEventInit; @@ -382,8 +419,6 @@ export function createCustomDomEvent(eventName: string, details?: any): CustomEv return event; } - - export function sendCustomEvent(evtName: string, cfg?: any, customDetails?: any): boolean { let global = getGlobal(); if (global && (global as any).CustomEvent) { @@ -402,6 +437,7 @@ export function sendCustomEvent(evtName: string, cfg?: any, customDetails?: any) * @param url - The URL string to redact * @returns The URL with user information redacted */ +/*#__NO_SIDE_EFFECTS__*/ function redactUserInfo(url: string): string { return url.replace(/^([a-zA-Z][a-zA-Z0-9+.-]*:\/\/)([^:@]{1,200}):([^@]{1,200})@(.*)$/, "$1REDACTED:REDACTED@$4"); } @@ -411,6 +447,7 @@ function redactUserInfo(url: string): string { * @param url - The URL string to redact * @returns The URL with sensitive query parameters redacted */ +/*#__NO_SIDE_EFFECTS__*/ function redactQueryParameters(url: string, config?: IConfiguration): string { let sensitiveParams: string[]; const questionMarkIndex = strIndexOf(url, "?"); @@ -501,8 +538,9 @@ function redactQueryParameters(url: string, config?: IConfiguration): string { * @param config - Configuration object that contain redactUrls setting. * @returns The redacted URL string or the original string if no redaction was needed or possible. */ +/*#__NO_SIDE_EFFECTS__*/ export function fieldRedaction(input: string, config: IConfiguration): string { - if (!input || !isString(input) || input.indexOf(" ") !== -1) { + if (!input || !isString(input) || strIndexOf(input, " ") !== -1) { return input; } const isRedactionDisabled = config && config.redactUrls === false; diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/HelperFuncs.ts b/shared/AppInsightsCore/src/utils/HelperFuncs.ts similarity index 95% rename from shared/AppInsightsCore/src/JavaScriptSDK/HelperFuncs.ts rename to shared/AppInsightsCore/src/utils/HelperFuncs.ts index 52993a836..650741089 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK/HelperFuncs.ts +++ b/shared/AppInsightsCore/src/utils/HelperFuncs.ts @@ -6,11 +6,11 @@ import { isFunction, isNullOrUndefined, isNumber, isObject, isPlainObject, isString, isUndefined, newSymbol, objCreate, objDeepFreeze, objDefine, objForEachKey, objGetPrototypeOf, objHasOwn, objSetPrototypeOf, safe, strIndexOf, strTrim } from "@nevware21/ts-utils"; -import { FeatureOptInMode } from "../JavaScriptSDK.Enums/FeatureOptInEnums"; -import { TransportType } from "../JavaScriptSDK.Enums/SendRequestReason"; -import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration"; -import { IXDomainRequest } from "../JavaScriptSDK.Interfaces/IXDomainRequest"; -import { STR_EMPTY } from "./InternalConstants"; +import { STR_EMPTY } from "../constants/InternalConstants"; +import { FeatureOptInMode } from "../enums/ai/FeatureOptInEnums"; +import { TransportType } from "../enums/ai/SendRequestReason"; +import { IConfiguration } from "../interfaces/ai/IConfiguration"; +import { IXDomainRequest } from "../interfaces/ai/IXDomainRequest"; // RESTRICT and AVOID circular dependencies you should not import other contained modules or export the contents of this file directly @@ -25,10 +25,12 @@ let _ProtoNameTag: ICachedValue; export let _getObjProto = Object[strGetPrototypeOf]; +/*#__NO_SIDE_EFFECTS__*/ export function isNotUndefined(value: T): value is T { return !isUndefined(value); } +/*#__NO_SIDE_EFFECTS__*/ export function isNotNullOrUndefined(value: T): value is T { return !isNullOrUndefined(value); } @@ -40,6 +42,7 @@ export function isNotNullOrUndefined(value: T): value is T { * This is a simplified version * @param name - The name to validate */ +/*#__NO_SIDE_EFFECTS__*/ export function normalizeJsName(name: string): string { let value = name; @@ -63,6 +66,7 @@ export function normalizeJsName(name: string): string { * @param value - The string value to check for the existence of the search value * @param search - The value search within the value */ +/*#__NO_SIDE_EFFECTS__*/ export function strContains(value: string, search: string): boolean { if (value && search) { return strIndexOf(value, search) !== -1; @@ -74,6 +78,7 @@ export function strContains(value: string, search: string): boolean { /** * Convert a date to I.S.O. format in IE8 */ +/*#__NO_SIDE_EFFECTS__*/ export function toISOString(date: Date) { return date && date.toISOString() || STR_EMPTY; } @@ -83,6 +88,7 @@ export const deepFreeze: (obj: T) => T = objDeepFreeze; /** * Returns the name of object if it's an Error. Otherwise, returns empty string. */ +/*#__NO_SIDE_EFFECTS__*/ export function getExceptionName(object: any): string { if (isError(object)) { return object.name; @@ -249,6 +255,7 @@ export function proxyFunctions(target: T, source: S | (() => S), functions * Only instance properties (hasOwnProperty) values are copied from the defaults to the new instance * @param defaults - Simple helper */ +/*#__NO_SIDE_EFFECTS__*/ export function createClassFromInterface(defaults?: T) { return class { constructor() { @@ -296,6 +303,9 @@ export function setProtoTypeName(target: T, name: string): T { // Create a new intermediate prototype that extends the current prototype let newProto = setObjStringTag(objCreate(proto), name); if (!_ProtoNameTag) { + // Note: Using a cached value instead of a lazy value as we want to ensure that the namespace is consistent + // across multiple calls as the `getLazy()` supports runtime invalidation via `setBypassLazyCache()` which would + // result in different namespaces being returned. _ProtoNameTag = createCachedValue(newSymbol("ai$ProtoName")); } @@ -355,6 +365,7 @@ export function updateProtoTypeName(target: T, name: string): T { * This helps when iterating using for..in, objKeys() and objForEach() * @param theObject - The object to be optimized if possible */ +/*#__NO_SIDE_EFFECTS__*/ export function optimizeObject(theObject: T): T { // V8 Optimization to cause the JIT compiler to create a new optimized object for looking up the own properties // primarily for object with <= 19 properties for >= 20 the effect is reduced or non-existent @@ -450,6 +461,7 @@ export const asString = asString21; * @param sdkDefaultState - Optional default state to return if the feature is not defined * @returns True if the feature is enabled, false if the feature is disabled, or undefined if the feature is not defined and no default state is provided. */ +/*#__NO_SIDE_EFFECTS__*/ export function isFeatureEnabled(feature?: string, cfg?: T, sdkDefaultState?: boolean): boolean | undefined { let ft = cfg && cfg.featureOptIn && cfg.featureOptIn[feature]; if (feature && ft) { @@ -466,6 +478,7 @@ export function isFeatureEnabled(feat return sdkDefaultState; } +/*#__NO_SIDE_EFFECTS__*/ export function getResponseText(xhr: XMLHttpRequest | IXDomainRequest) { try { return xhr.responseText; @@ -476,6 +489,7 @@ export function getResponseText(xhr: XMLHttpRequest | IXDomainRequest) { return null; } +/*#__NO_SIDE_EFFECTS__*/ export function formatErrorMessageXdr(xdr: IXDomainRequest, message?: string): string { if (xdr) { return "XDomainRequest,Response:" + getResponseText(xdr) || STR_EMPTY; @@ -484,6 +498,7 @@ export function formatErrorMessageXdr(xdr: IXDomainRequest, message?: string): s return message; } +/*#__NO_SIDE_EFFECTS__*/ export function formatErrorMessageXhr(xhr: XMLHttpRequest, message?: string): string { if (xhr) { return "XMLHttpRequest,Status:" + xhr.status + ",Response:" + getResponseText(xhr) || xhr.response || STR_EMPTY; @@ -492,6 +507,7 @@ export function formatErrorMessageXhr(xhr: XMLHttpRequest, message?: string): st return message; } +/*#__NO_SIDE_EFFECTS__*/ export function prependTransports(theTransports: TransportType[], newTransports: TransportType | TransportType[]) { if (newTransports) { if (isNumber(newTransports)) { @@ -565,13 +581,14 @@ export function openXhr(method: string, urlString: string, withCredentials?: boo * @internal */ // tslint:disable-next-line: align +/*#__NO_SIDE_EFFECTS__*/ export function convertAllHeadersToMap(headersString: string): { [headerName: string]: string } { - let headers = {}; + let headers:any = {}; if (isString(headersString)) { let headersArray = strTrim(headersString).split(/[\r\n]+/); arrForEach(headersArray, (headerEntry) => { if (headerEntry) { - let idx = headerEntry.indexOf(": "); + let idx = strIndexOf(headerEntry, ": "); if (idx !== -1) { // The new spec has the headers returning all as lowercase -- but not all browsers do this yet let header = strTrim(headerEntry.substring(0, idx)).toLowerCase(); diff --git a/shared/AppInsightsCommon/src/HelperFuncs.ts b/shared/AppInsightsCore/src/utils/HelperFuncsCore.ts similarity index 68% rename from shared/AppInsightsCommon/src/HelperFuncs.ts rename to shared/AppInsightsCore/src/utils/HelperFuncsCore.ts index ab153a723..ae356c75b 100644 --- a/shared/AppInsightsCommon/src/HelperFuncs.ts +++ b/shared/AppInsightsCore/src/utils/HelperFuncsCore.ts @@ -1,11 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { IPlugin, arrForEach, isString, isTimeSpan } from "@microsoft/applicationinsights-core-js"; -import { mathFloor, mathRound } from "@nevware21/ts-utils"; - -const strEmpty = ""; +import { arrForEach, isString, mathFloor, mathRound } from "@nevware21/ts-utils"; +import { STR_EMPTY } from "../constants/InternalConstants"; +import { IPlugin } from "../interfaces/ai/ITelemetryPlugin"; +import { isTimeSpan } from "../internal/timeHelpers"; +/*#__NO_SIDE_EFFECTS__*/ export function stringToBoolOrDefault(str: any, defaultValue = false): boolean { if (str === undefined || str === null) { return defaultValue; @@ -17,6 +18,7 @@ export function stringToBoolOrDefault(str: any, defaultValue = false): boolean { /** * Convert ms to c# time span format */ +/*#__NO_SIDE_EFFECTS__*/ export function msToTimeSpan(totalms: number | string): string { if (isTimeSpan(totalms)) { // Already in time span format @@ -29,10 +31,10 @@ export function msToTimeSpan(totalms: number | string): string { totalms = mathRound(totalms); - let ms = strEmpty + totalms % 1000; - let sec = strEmpty + mathFloor(totalms / 1000) % 60; - let min = strEmpty + mathFloor(totalms / (1000 * 60)) % 60; - let hour = strEmpty + mathFloor(totalms / (1000 * 60 * 60)) % 24; + let ms = STR_EMPTY + totalms % 1000; + let sec = STR_EMPTY + mathFloor(totalms / 1000) % 60; + let min = STR_EMPTY + mathFloor(totalms / (1000 * 60)) % 60; + let hour = STR_EMPTY + mathFloor(totalms / (1000 * 60 * 60)) % 24; const days = mathFloor(totalms / (1000 * 60 * 60 * 24)); ms = ms.length === 1 ? "00" + ms : ms.length === 2 ? "0" + ms : ms; @@ -40,9 +42,10 @@ export function msToTimeSpan(totalms: number | string): string { min = min.length < 2 ? "0" + min : min; hour = hour.length < 2 ? "0" + hour : hour; - return (days > 0 ? days + "." : strEmpty) + hour + ":" + min + ":" + sec + "." + ms; + return (days > 0 ? days + "." : STR_EMPTY) + hour + ":" + min + ":" + sec + "." + ms; } +/*#__NO_SIDE_EFFECTS__*/ export function getExtensionByName(extensions: IPlugin[], identifier: string): IPlugin | null { let extension: IPlugin = null; arrForEach(extensions, (value) => { @@ -55,6 +58,7 @@ export function getExtensionByName(extensions: IPlugin[], identifier: string): I return extension; } +/*#__NO_SIDE_EFFECTS__*/ export function isCrossOriginError(message: string|Event, url: string, lineNumber: number, columnNumber: number, error: Error | Event): boolean { return !error && isString(message) && (message === "Script error." || message === "Script error"); } diff --git a/shared/AppInsightsCommon/src/Offline.ts b/shared/AppInsightsCore/src/utils/Offline.ts similarity index 93% rename from shared/AppInsightsCommon/src/Offline.ts rename to shared/AppInsightsCore/src/utils/Offline.ts index b52a61a6a..c08279793 100644 --- a/shared/AppInsightsCommon/src/Offline.ts +++ b/shared/AppInsightsCore/src/utils/Offline.ts @@ -1,7 +1,7 @@ -import { - IUnloadHook, arrForEach, createUniqueNamespace, eventOff, eventOn, getDocument, getNavigator, getWindow, isNullOrUndefined, isUndefined, - mergeEvtNamespace -} from "@microsoft/applicationinsights-core-js"; +import { arrForEach, arrIndexOf, getDocument, getNavigator, getWindow, isNullOrUndefined, isUndefined } from "@nevware21/ts-utils"; +import { IUnloadHook } from "../interfaces/ai/IUnloadHook"; +import { eventOff, eventOn, mergeEvtNamespace } from "../internal/EventHelpers"; +import { createUniqueNamespace } from "../utils/DataCacheHelper"; /** * this is the callback that will be called when the network status changes @@ -164,7 +164,7 @@ export function createOfflineListener(parentEvtNamespace?: string | string[]): I // Define rm as an instance of IUnloadHook return { rm: () => { - let index = listenerList.indexOf(callback); + let index = arrIndexOf(listenerList, callback); if (index > -1){ return listenerList.splice(index, 1); } else { diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/RandomHelper.ts b/shared/AppInsightsCore/src/utils/RandomHelper.ts similarity index 94% rename from shared/AppInsightsCore/src/JavaScriptSDK/RandomHelper.ts rename to shared/AppInsightsCore/src/utils/RandomHelper.ts index 4661d4547..8a0124117 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK/RandomHelper.ts +++ b/shared/AppInsightsCore/src/utils/RandomHelper.ts @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { mathFloor, utcNow } from "@nevware21/ts-utils"; +import { mathFloor, mathRandom, utcNow } from "@nevware21/ts-utils"; +import { STR_EMPTY } from "../constants/InternalConstants"; import { getCrypto, getMsCrypto, isIE } from "./EnvUtils"; -import { STR_EMPTY } from "./InternalConstants"; const UInt32Mask = 0x100000000; const MaxUInt32 = 0xffffffff; -const SEED1 = 123456789 -const SEED2 = 987654321 +const SEED1 = 123456789; +const SEED2 = 987654321; // MWC based Random generator (for IE) let _mwcSeeded = false; @@ -31,7 +31,7 @@ function _autoSeedMwc() { // and bitwise XOR with the current milliseconds try { const now = utcNow() & 0x7fffffff; - _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now); + _mwcSeed(((mathRandom() * UInt32Mask) ^ now) + now); } catch (e) { // Don't crash if something goes wrong } @@ -76,7 +76,7 @@ export function random32(signed?: boolean) { if (value === 0) { // Make sure the number is converted into the specified range (-0x80000000..0x7FFFFFFF) - value = mathFloor((UInt32Mask * Math.random()) | 0); + value = mathFloor((UInt32Mask * mathRandom()) | 0); } if (!signed) { diff --git a/shared/AppInsightsCommon/src/StorageHelperFuncs.ts b/shared/AppInsightsCore/src/utils/StorageHelperFuncs.ts similarity index 92% rename from shared/AppInsightsCommon/src/StorageHelperFuncs.ts rename to shared/AppInsightsCore/src/utils/StorageHelperFuncs.ts index 0399de91c..6e51aa5b9 100644 --- a/shared/AppInsightsCommon/src/StorageHelperFuncs.ts +++ b/shared/AppInsightsCore/src/utils/StorageHelperFuncs.ts @@ -1,15 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { - IDiagnosticLogger, _eInternalMessageId, _throwInternal, dumpObj, eLoggingSeverity, getExceptionName, getGlobal, getGlobalInst, - isNullOrUndefined, objForEachKey -} from "@microsoft/applicationinsights-core-js"; -import { StorageType } from "./Enums"; +import { dumpObj, getGlobal, getInst as getGlobalInst, isNullOrUndefined, objForEachKey } from "@nevware21/ts-utils"; +import { STR_EMPTY } from "../constants/InternalConstants"; +import { _throwInternal } from "../diagnostics/DiagnosticLogger"; +import { StorageType } from "../enums/ai/Enums"; +import { _eInternalMessageId, eLoggingSeverity } from "../enums/ai/LoggingEnums"; +import { IDiagnosticLogger } from "../interfaces/ai/IDiagnosticLogger"; +import { getExceptionName } from "../utils/HelperFuncs"; let _canUseLocalStorage: boolean = undefined; let _canUseSessionStorage: boolean = undefined; -let _storagePrefix: string = ""; +let _storagePrefix: string = STR_EMPTY; /** * Gets the localStorage object if available @@ -71,7 +73,7 @@ export function utlDisableStorage() { } export function utlSetStoragePrefix(storagePrefix: string) { - _storagePrefix = storagePrefix || ""; + _storagePrefix = storagePrefix || STR_EMPTY; } /** diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/W3cTraceParent.ts b/shared/AppInsightsCore/src/utils/TraceParent.ts similarity index 94% rename from shared/AppInsightsCore/src/JavaScriptSDK/W3cTraceParent.ts rename to shared/AppInsightsCore/src/utils/TraceParent.ts index 465cfc73e..28d6ce6ae 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK/W3cTraceParent.ts +++ b/shared/AppInsightsCore/src/utils/TraceParent.ts @@ -1,9 +1,9 @@ -import { arrForEach, isArray, isNullOrUndefined, isString, strLeft, strTrim } from "@nevware21/ts-utils"; -import { eW3CTraceFlags } from "../JavaScriptSDK.Enums/W3CTraceFlags"; -import { ITraceParent } from "../JavaScriptSDK.Interfaces/ITraceParent"; +import { arrForEach, isArray, isNullOrUndefined, isString, strIndexOf, strLeft, strTrim } from "@nevware21/ts-utils"; +import { STR_EMPTY } from "../constants/InternalConstants"; +import { eW3CTraceFlags } from "../enums/W3CTraceFlags"; +import { ITraceParent } from "../interfaces/ai/ITraceParent"; import { generateW3CId } from "./CoreUtils"; import { findMetaTag, findNamedServerTiming } from "./EnvUtils"; -import { STR_EMPTY } from "./InternalConstants"; // using {0,16} for leading and trailing whitespace just to constrain the possible runtime of a random string const TRACE_PARENT_REGEX = /^([\da-f]{2})-([\da-f]{32})-([\da-f]{16})-([\da-f]{2})(-[^\s]{1,64})?$/i; @@ -50,6 +50,7 @@ function _formatFlags(value: number): string { * @param version - The version to used, defaults to version "01" if not supplied or invalid. * @returns */ +/*#__NO_SIDE_EFFECTS__*/ export function createTraceParent(traceId?: string, spanId?: string, flags?: number, version?: string): ITraceParent { return { @@ -67,6 +68,7 @@ export function createTraceParent(traceId?: string, spanId?: string, flags?: num * @param selectIdx - If the found value is comma separated which is the preferred entry to select, defaults to the first * @returns */ +/*#__NO_SIDE_EFFECTS__*/ export function parseTraceParent(value: string, selectIdx?: number): ITraceParent { if (!value) { // Don't pass a null/undefined or empty string @@ -83,7 +85,7 @@ export function parseTraceParent(value: string, selectIdx?: number): ITraceParen return null; } - if (value.indexOf(",") !== -1) { + if (strIndexOf(value, ",") !== -1) { let values = value.split(","); value = values[selectIdx > 0 && values.length > selectIdx ? selectIdx : 0]; } @@ -113,6 +115,7 @@ export function parseTraceParent(value: string, selectIdx?: number): ITraceParen * @param value - The W3c trace Id to be validated * @returns true if valid otherwise false */ +/*#__NO_SIDE_EFFECTS__*/ export function isValidTraceId(value: string): boolean { return _isValid(value, 32, INVALID_TRACE_ID); } @@ -124,6 +127,7 @@ export function isValidTraceId(value: string): boolean { * @param value - The W3c span id to be validated * @returns true if valid otherwise false */ +/*#__NO_SIDE_EFFECTS__*/ export function isValidSpanId(value: string): boolean { return _isValid(value, 16, INVALID_SPAN_ID); } @@ -133,6 +137,7 @@ export function isValidSpanId(value: string): boolean { * @param value - The parsed traceParent value * @returns */ +/*#__NO_SIDE_EFFECTS__*/ export function isValidTraceParent(value: ITraceParent) { if (!value || !_isValid(value.version, 2, INVALID_VERSION) || @@ -152,6 +157,7 @@ export function isValidTraceParent(value: ITraceParent) { * @param value - The parsed traceParent value * @returns */ +/*#__NO_SIDE_EFFECTS__*/ export function isSampledFlag(value: ITraceParent) { if (isValidTraceParent(value)) { return (value.traceFlags & SAMPLED_FLAG) === SAMPLED_FLAG; @@ -168,6 +174,7 @@ export function isSampledFlag(value: ITraceParent) { * @param value - The parsed traceParent value * @returns */ +/*#__NO_SIDE_EFFECTS__*/ export function formatTraceParent(value: ITraceParent) { if (value) { // Special Note: This only supports formatting as version 00, future versions should encode any known supported version diff --git a/shared/AppInsightsCommon/src/UrlHelperFuncs.ts b/shared/AppInsightsCore/src/utils/UrlHelperFuncs.ts similarity index 85% rename from shared/AppInsightsCommon/src/UrlHelperFuncs.ts rename to shared/AppInsightsCore/src/utils/UrlHelperFuncs.ts index c0b9e838c..e76ef62e1 100644 --- a/shared/AppInsightsCommon/src/UrlHelperFuncs.ts +++ b/shared/AppInsightsCore/src/utils/UrlHelperFuncs.ts @@ -1,7 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { getDocument, isString } from "@microsoft/applicationinsights-core-js"; +import { getDocument, isString } from "@nevware21/ts-utils"; +import { STR_EMPTY } from "../constants/InternalConstants"; let _document: any = getDocument() || {}; @@ -65,11 +66,11 @@ export function urlGetCompleteUrl(method: string, absoluteUrl: string) { // Fallback method to grab host from url if document.createElement method is not available export function urlParseHost(url: string, inclPort?: boolean) { - let fullHost = urlParseFullHost(url, inclPort) || ""; + let fullHost = urlParseFullHost(url, inclPort) || STR_EMPTY; if (fullHost) { const match = fullHost.match(/(www\d{0,5}\.)?([^\/:]{1,256})(:\d{1,20})?/i); if (match != null && match.length > 3 && isString(match[2]) && match[2].length > 0) { - return match[2] + (match[3] || ""); + return match[2] + (match[3] || STR_EMPTY); } } @@ -81,15 +82,15 @@ export function urlParseFullHost(url: string, inclPort?: boolean) { if (url) { const match = url.match(/(\w{1,150}):\/\/([^\/:]{1,256})(:\d{1,20})?/i); if (match != null && match.length > 2 && isString(match[2]) && match[2].length > 0) { - result = match[2] || ""; + result = match[2] || STR_EMPTY; if (inclPort && match.length > 2) { - const protocol = (match[1] || "").toLowerCase(); - let port = match[3] || ""; + const protocol = (match[1] || STR_EMPTY).toLowerCase(); + let port = match[3] || STR_EMPTY; // IE includes the standard port so pass it off if it's the same as the protocol if (protocol === "http" && port === ":80") { - port = ""; + port = STR_EMPTY; } else if (protocol === "https" && port === ":443") { - port = ""; + port = STR_EMPTY; } result += port; diff --git a/shared/AppInsightsCommon/src/Util.ts b/shared/AppInsightsCore/src/utils/Util.ts similarity index 88% rename from shared/AppInsightsCommon/src/Util.ts rename to shared/AppInsightsCore/src/utils/Util.ts index a7daa9028..02fa5a641 100644 --- a/shared/AppInsightsCommon/src/Util.ts +++ b/shared/AppInsightsCore/src/utils/Util.ts @@ -1,16 +1,16 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { - IDiagnosticLogger, IDistributedTraceContext, arrForEach, arrIndexOf, createDistributedTraceContext, dateNow, getPerformance, - isNullOrUndefined -} from "@microsoft/applicationinsights-core-js"; -import { strIndexOf } from "@nevware21/ts-utils"; -import { DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH } from "./Constants"; -import { ITelemetryTrace } from "./Interfaces/Context/ITelemetryTrace"; -import { ICorrelationConfig } from "./Interfaces/ICorrelationConfig"; -import { RequestHeaders, eRequestHeaders } from "./RequestResponseHeaders"; -import { dataSanitizeString } from "./Telemetry/Common/DataSanitizer"; +import { arrForEach, arrIndexOf, getPerformance, isNullOrUndefined, strIndexOf, utcNow as dateNow } from "@nevware21/ts-utils"; +import { DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH } from "../constants/Constants"; +import { STR_EMPTY } from "../constants/InternalConstants"; +import { createDistributedTraceContext } from "../core/TelemetryHelpers"; +import { ICorrelationConfig } from "../interfaces/ai/ICorrelationConfig"; +import { IDiagnosticLogger } from "../interfaces/ai/IDiagnosticLogger"; +import { IDistributedTraceContext } from "../interfaces/ai/IDistributedTraceContext"; +import { ITelemetryTrace } from "../interfaces/ai/context/ITelemetryTrace"; +import { RequestHeaders, eRequestHeaders } from "../telemetry/RequestResponseHeaders"; +import { dataSanitizeString } from "../telemetry/ai/Common/DataSanitizer"; import { urlParseFullHost, urlParseUrl } from "./UrlHelperFuncs"; // listing only non-geo specific locations @@ -186,9 +186,9 @@ export function dateTimeUtilsDuration(start: number, end: number): number { export function createDistributedTraceContextFromTrace(telemetryTrace?: ITelemetryTrace, parentCtx?: IDistributedTraceContext): IDistributedTraceContext { let traceCtx: IDistributedTraceContext = createDistributedTraceContext(parentCtx); if (telemetryTrace) { - traceCtx.pageName = telemetryTrace.name || traceCtx.pageName || ""; // The name of the page - traceCtx.traceId = telemetryTrace.traceID || traceCtx.traceId || ""; // 16 byte hex string - traceCtx.spanId = telemetryTrace.parentID || traceCtx.spanId || ""; // 8 byte hex string + traceCtx.pageName = telemetryTrace.name || traceCtx.pageName || STR_EMPTY; // The name of the page + traceCtx.traceId = telemetryTrace.traceID || traceCtx.traceId || STR_EMPTY; // 16 byte hex string + traceCtx.spanId = telemetryTrace.parentID || traceCtx.spanId || STR_EMPTY; // 8 byte hex string traceCtx.traceFlags = (!isNullOrUndefined(telemetryTrace.traceFlags) ? telemetryTrace.traceFlags : traceCtx.traceFlags) || 0; // 1 byte hex string } diff --git a/shared/AppInsightsCore/tsc-errors.txt b/shared/AppInsightsCore/tsc-errors.txt new file mode 100644 index 000000000..73c321f75 --- /dev/null +++ b/shared/AppInsightsCore/tsc-errors.txt @@ -0,0 +1,17 @@ +src/core/AppInsightsCore.ts(4,26): error TS2307: Cannot find module '@microsoft/dynamicproto-js' or its corresponding type declarations. +src/core/AppInsightsCore.ts(421,46): error TS7006: Parameter '_self' implicitly has an 'any' type. +src/core/BaseTelemetryPlugin.ts(5,26): error TS2307: Cannot find module '@microsoft/dynamicproto-js' or its corresponding type declarations. +src/core/BaseTelemetryPlugin.ts(135,51): error TS7006: Parameter '_self' implicitly has an 'any' type. +src/core/NotificationManager.ts(3,26): error TS2307: Cannot find module '@microsoft/dynamicproto-js' or its corresponding type declarations. +src/core/NotificationManager.ts(78,50): error TS7006: Parameter '_self' implicitly has an 'any' type. +src/core/NotificationManager.ts(203,29): error TS2554: Expected 1 arguments, but got 0. +src/core/PerfManager.ts(3,26): error TS2307: Cannot find module '@microsoft/dynamicproto-js' or its corresponding type declarations. +src/core/PerfManager.ts(148,42): error TS7006: Parameter '_self' implicitly has an 'any' type. +src/core/SenderPostManager.ts(4,26): error TS2307: Cannot find module '@microsoft/dynamicproto-js' or its corresponding type declarations. +src/core/SenderPostManager.ts(58,48): error TS7006: Parameter '_self' implicitly has an 'any' type. +src/core/SenderPostManager.ts(58,55): error TS7006: Parameter '_base' implicitly has an 'any' type. +src/core/TelemetryInitializerPlugin.ts(4,26): error TS2307: Cannot find module '@microsoft/dynamicproto-js' or its corresponding type declarations. +src/core/TelemetryInitializerPlugin.ts(85,57): error TS7006: Parameter '_self' implicitly has an 'any' type. +src/core/TelemetryInitializerPlugin.ts(85,64): error TS7006: Parameter '_base' implicitly has an 'any' type. +src/diagnostics/DiagnosticLogger.ts(4,26): error TS2307: Cannot find module '@microsoft/dynamicproto-js' or its corresponding type declarations. +src/diagnostics/DiagnosticLogger.ts(128,47): error TS7006: Parameter '_self' implicitly has an 'any' type. diff --git a/shared/AppInsightsCore/tsconfig.json b/shared/AppInsightsCore/tsconfig.json index fa0e78410..abfefa5e0 100644 --- a/shared/AppInsightsCore/tsconfig.json +++ b/shared/AppInsightsCore/tsconfig.json @@ -21,11 +21,9 @@ "removeComments": false }, "include": [ - "./src/applicationinsights-core-js.ts", - "./src/Config/**/*.ts", - "./src/JavaScriptSDK/**/*.ts", - "./src/JavaScriptSDK.Enums/**/*.ts", - "./src/JavaScriptSDK.Interfaces/**/*.ts" + "./src/**/*.ts" ], - "exclude": ["node_modules/"] + "exclude": [ + "node_modules/" + ] } diff --git a/tools/applicationinsights-web-snippet/package.json b/tools/applicationinsights-web-snippet/package.json index 70bb6e189..019eebfc7 100644 --- a/tools/applicationinsights-web-snippet/package.json +++ b/tools/applicationinsights-web-snippet/package.json @@ -35,7 +35,7 @@ "@types/qunit": "^2.19.3", "@microsoft/ai-test-framework": "0.0.1", "@microsoft/applicationinsights-web": "3.3.11", - "@microsoft/applicationinsights-common": "3.3.11", + "@microsoft/applicationinsights-core-js": "3.3.11", "@microsoft/applicationinsights-rollup-plugin-uglify3-js": "1.0.0", "@microsoft/applicationinsights-rollup-es5": "1.0.2", "@microsoft/dynamicproto-js": "^2.0.3", diff --git a/tools/applicationinsights-web-snippet/src/aiSupport.ts b/tools/applicationinsights-web-snippet/src/aiSupport.ts index b43e30fb8..71bb811a9 100644 --- a/tools/applicationinsights-web-snippet/src/aiSupport.ts +++ b/tools/applicationinsights-web-snippet/src/aiSupport.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { IEnvelope } from "@microsoft/applicationinsights-common"; +import { IEnvelope } from "@microsoft/applicationinsights-core-js"; import { _getTime } from "./support"; let strEmpty = ""; diff --git a/tools/applicationinsights-web-snippet/src/snippet.ts b/tools/applicationinsights-web-snippet/src/snippet.ts index 5fa812f17..059e8bff0 100644 --- a/tools/applicationinsights-web-snippet/src/snippet.ts +++ b/tools/applicationinsights-web-snippet/src/snippet.ts @@ -3,7 +3,7 @@ /* eslint-disable no-constant-condition */ import { Fields, ISnippetConfig } from "./type"; -import { IConfig, IEnvelope } from "@microsoft/applicationinsights-common"; +import { IConfig, IEnvelope } from "@microsoft/applicationinsights-core-js"; import { IConfiguration, Snippet } from "@microsoft/applicationinsights-web"; import { oneDsEnvelope } from "./1dsType"; import { _createAiEnvelope, aiMethod } from "./aiSupport"; diff --git a/tools/chrome-debug-extension/package.json b/tools/chrome-debug-extension/package.json index 09b3bd0d8..afc31fe79 100644 --- a/tools/chrome-debug-extension/package.json +++ b/tools/chrome-debug-extension/package.json @@ -44,7 +44,6 @@ "sideEffects": false, "dependencies": { "@microsoft/applicationinsights-core-js": "3.3.11", - "@microsoft/applicationinsights-common": "3.3.11", "@microsoft/applicationinsights-shims": "3.0.1", "@microsoft/dynamicproto-js": "^2.0.3", "@nevware21/ts-async": ">= 0.5.4 < 2.x", diff --git a/tools/grunt-tasks/minifyNames.js b/tools/grunt-tasks/minifyNames.js index 2e8cd6104..af153003f 100644 --- a/tools/grunt-tasks/minifyNames.js +++ b/tools/grunt-tasks/minifyNames.js @@ -167,9 +167,9 @@ function readSourceValueMap(theReplacements, src, from) { } } - function readInternalConstants(theReplacements, src, from) { - const getConstStrings = /export\sconst\s(\w+)\s=\s(["\w \t\+]*as\s)?\"(\w*)";/gm + // eslint-disable-next-line security/detect-unsafe-regex + const getConstStrings = /export\sconst\s(\w+)\s=\s(?:\(?\/\*\s*[#@]__PURE__\s*\*\/\s*){0,1}(["\w \t\+]*as\s)?\"(\w*)\"\)?;/gm var matches = getConstStrings.exec(src); while (matches != null) {