[Beta] Restructure folders to match new OTel-Sdk and sync changes#2697
Merged
[Beta] Restructure folders to match new OTel-Sdk and sync changes#2697
Conversation
Summary: - Update Rush to 5.167.0 and @nevware21 grunt plugins to 0.5.1 - Reorganize AppInsightsCore test structure with proper folder organization - Add missing copyright headers across multiple files - Code cleanup and TypeScript strict mode fixes Changes: Dependency Updates: - Rush: 5.166.0 → 5.167.0 - @nevware21/grunt-ts-plugin: 0.4.3 → 0.5.1 - @nevware21/grunt-eslint-ts: 0.2.2 → 0.5.1 Test Reorganization: - Update test imports to use new folder structure (ai/, config/, trace/, attribute/) - Remove duplicate test runner file (appinsights-common.tests.ts) - Fix relative import paths from ../../../src/ to ../../../../src/ OpenTelemetry Enhancements: - Add IOTelSpanContext interface for OTel span context support - Add createOTelSpanContext() utility function - Update IDistributedTraceContext to support IOTelSpanContext parents - Export new INVALID_TRACE_ID and INVALID_SPAN_ID constants Code Cleanup: - Remove unused _trackAjaxAttempts variable from AnalyticsPlugin - Consolidate isTimeSpan function into HelperFuncs.ts - Delete empty/obsolete files (HelperFuncsCore.ts, IEnvelope.ts, tsc-errors.txt) - Fix whitespace and formatting inconsistencies - Add proper TypeScript type casts for strict mode compliance
Contributor
There was a problem hiding this comment.
Pull request overview
This PR appears to align the repo’s folder/layout and Core APIs with an updated OpenTelemetry SDK shape, while also syncing build tooling versions and reorganizing/expanding unit tests for the refactor.
Changes:
- Bump Rush and multiple dev/build dependencies (notably
@nevware21/grunt-*) across packages. - Refactor and extend AppInsightsCore OTel tracing surface area (new
IOTelSpanContext, moved tracer options, updated exports, added helpers likecallWithTimeout). - Restructure and expand unit tests (new/moved test files and updated import paths) to match the new layout and behavior.
Reviewed changes
Copilot reviewed 126 out of 140 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/shims/package.json | Bumps @nevware21/grunt-* dev dependencies. |
| tools/rollup-plugin-uglify3-js/package.json | Bumps @nevware21/grunt-* dev dependencies. |
| tools/rollup-es5/package.json | Bumps @nevware21/grunt-* dev dependencies. |
| tools/chrome-debug-extension/package.json | Bumps @nevware21/grunt-* dev dependencies. |
| tools/applicationinsights-web-snippet/package.json | Bumps @nevware21/grunt-* dev dependencies. |
| shared/AppInsightsCore/tsc-errors.txt | Removes checked-in TypeScript error output file. |
| shared/AppInsightsCore/src/utils/TraceParent.ts | Adds headers/types/formatting; improves typings (e.g., findAllScripts return type) and exports. |
| shared/AppInsightsCore/src/utils/StorageHelperFuncs.ts | Fixes local import path to HelperFuncs. |
| shared/AppInsightsCore/src/utils/Offline.ts | Adds headers; fixes local import path to DataCacheHelper. |
| shared/AppInsightsCore/src/utils/HelperFuncsCore.ts | Removes legacy helper module (functions migrated). |
| shared/AppInsightsCore/src/utils/HelperFuncs.ts | Adds migrated helpers (msToTimeSpan, stringToBoolOrDefault, etc.) plus isTimeSpan. |
| shared/AppInsightsCore/src/utils/DomHelperFuncs.ts | Minor header/formatting adjustment. |
| shared/AppInsightsCore/src/telemetry/ai/RemoteDependencyData.ts | Updates import to use moved msToTimeSpan. |
| shared/AppInsightsCore/src/telemetry/ai/PageView.ts | Updates import to use moved msToTimeSpan. |
| shared/AppInsightsCore/src/telemetry/ai/Exception.ts | Tightens typings via (… as any) in a few legacy/interop spots. |
| shared/AppInsightsCore/src/telemetry/ai/Common/DataSanitizer.ts | Adds explicit any typings for temp maps. |
| shared/AppInsightsCore/src/telemetry/TelemetryItemCreator.ts | Uses (item as any)[…] for indexed access and delete. |
| shared/AppInsightsCore/src/otel/api/trace/utils.ts | Adds OTel span-context support to helper signatures and logic. |
| shared/AppInsightsCore/src/otel/api/trace/traceState.ts | Adds headers/formatting; supports immutable OTel TraceState wrapper creation. |
| shared/AppInsightsCore/src/otel/api/trace/traceApi.ts | Adds headers. |
| shared/AppInsightsCore/src/otel/api/trace/spanContext.ts | Introduces OTel SpanContext wrapper/creator utilities. |
| shared/AppInsightsCore/src/otel/api/trace/span.ts | Adjusts exception type import and minor formatting. |
| shared/AppInsightsCore/src/otel/api/errors/OTelSpanError.ts | Adds headers. |
| shared/AppInsightsCore/src/otel/api/errors/OTelInvalidAttributeError.ts | Adds headers. |
| shared/AppInsightsCore/src/otel/api/errors/OTelError.ts | Adds headers. |
| shared/AppInsightsCore/src/otel/api/OTelApi.ts | Adds headers. |
| shared/AppInsightsCore/src/internal/timeHelpers.ts | Adds headers; removes isTimeSpan (moved elsewhere). |
| shared/AppInsightsCore/src/internal/noopHelpers.ts | Adds copyright/license header. |
| shared/AppInsightsCore/src/internal/handleErrors.ts | Adds headers. |
| shared/AppInsightsCore/src/internal/commonUtils.ts | Adds callWithTimeout() helper and related imports. |
| shared/AppInsightsCore/src/internal/attributeHelpers.ts | Adds headers. |
| shared/AppInsightsCore/src/interfaces/otel/trace/IOTelTracerProvider.ts | Moves tracer options to a dedicated file and imports it. |
| shared/AppInsightsCore/src/interfaces/otel/trace/IOTelTracerOptions.ts | Adds new tracer options interface file. |
| shared/AppInsightsCore/src/interfaces/otel/trace/IOTelTracer.ts | Removes an outdated/incorrect doc line. |
| shared/AppInsightsCore/src/interfaces/otel/trace/IOTelTraceApi.ts | Adds headers; updates types to accept IDistributedTraceInit/IOTelSpanContext; fixes tracer options import. |
| shared/AppInsightsCore/src/interfaces/otel/trace/IOTelSpanStatus.ts | Adds headers. |
| shared/AppInsightsCore/src/interfaces/otel/trace/IOTelSpanOptions.ts | Updates docstring to clarify OTel alignment. |
| shared/AppInsightsCore/src/interfaces/otel/trace/IOTelSpanCtx.ts | Adds headers; adjusts exception import and commented optional fields. |
| shared/AppInsightsCore/src/interfaces/otel/trace/IOTelSpanContext.ts | Adds new OTel span context interface. |
| shared/AppInsightsCore/src/interfaces/otel/trace/IOTelSpan.ts | Adjusts exception import. |
| shared/AppInsightsCore/src/interfaces/otel/config/IOTelTraceCfg.ts | Adds headers. |
| shared/AppInsightsCore/src/interfaces/otel/config/IOTelSpanLimits.ts | Adds headers. |
| shared/AppInsightsCore/src/interfaces/otel/config/IOTelErrorHandlers.ts | Adds copyright/license header. |
| shared/AppInsightsCore/src/interfaces/otel/config/IOTelConfig.ts | Adds headers. |
| shared/AppInsightsCore/src/interfaces/otel/config/IOTelAttributeLimits.ts | Adds copyright/license header. |
| shared/AppInsightsCore/src/interfaces/otel/IOTelAttributes.ts | Adds headers. |
| shared/AppInsightsCore/src/interfaces/otel/IOTelApiCtx.ts | Adds headers. |
| shared/AppInsightsCore/src/interfaces/otel/IOTelApi.ts | Adds headers. |
| shared/AppInsightsCore/src/interfaces/config/_IDynamicConfigHandlerState.ts | Adds headers. |
| shared/AppInsightsCore/src/interfaces/ai/contracts/IEnvelope.ts | Removes commented-out unused interface file content. |
| shared/AppInsightsCore/src/interfaces/ai/contracts/AvailabilityData.ts | Fixes commented header to real header. |
| shared/AppInsightsCore/src/interfaces/ai/context/ISample.ts | Minor formatting/newline. |
| shared/AppInsightsCore/src/interfaces/ai/PartAExtensions.ts | Adds headers. |
| shared/AppInsightsCore/src/interfaces/ai/IXHROverride.ts | Extends OnCompleteCallback signature to include optional payload. |
| shared/AppInsightsCore/src/interfaces/ai/IXDomainRequest.ts | Adds headers. |
| shared/AppInsightsCore/src/interfaces/ai/IThrottleMgr.ts | Adds headers. |
| shared/AppInsightsCore/src/interfaces/ai/ITelemetryInitializers.ts | Adds headers. |
| shared/AppInsightsCore/src/interfaces/ai/IStorageBuffer.ts | Adds headers. |
| shared/AppInsightsCore/src/interfaces/ai/ISenderPostManager.ts | Adds headers. |
| shared/AppInsightsCore/src/interfaces/ai/IRequestContext.ts | Adds headers. |
| shared/AppInsightsCore/src/interfaces/ai/IPageViewTelemetry.ts | Adds headers. |
| shared/AppInsightsCore/src/interfaces/ai/IPageViewPerformanceTelemetry.ts | Reorders header/import. |
| shared/AppInsightsCore/src/interfaces/ai/IMetricTelemetry.ts | Adds headers. |
| shared/AppInsightsCore/src/interfaces/ai/IFeatureOptIn.ts | Adds headers. |
| shared/AppInsightsCore/src/interfaces/ai/IEventTelemetry.ts | Reorders header/import. |
| shared/AppInsightsCore/src/interfaces/ai/IDistributedTraceContext.ts | Expands traceState typing to include OTel; makes traceFlags optional; improves docs. |
| shared/AppInsightsCore/src/interfaces/ai/IDiagnosticLogger.ts | Removes dependency on diagnostics module type; introduces local IInternalLogMessage. |
| shared/AppInsightsCore/src/interfaces/ai/ConnectionString.ts | Adds headers. |
| shared/AppInsightsCore/src/interfaces/IOTelHrTime.ts | Adds headers. |
| shared/AppInsightsCore/src/interfaces/IException.ts | Adds headers. |
| shared/AppInsightsCore/src/index.ts | Large export surface sync: formatting, new exports, moved helpers, added OTel exports. |
| shared/AppInsightsCore/src/enums/ai/LoggingEnums.ts | Adds new internal message id VersionMismatch. |
| shared/AppInsightsCore/src/enums/ai/InitActiveStatusEnum.ts | Adds headers. |
| shared/AppInsightsCore/src/enums/ai/FeatureOptInEnums.ts | Adds headers. |
| shared/AppInsightsCore/src/diagnostics/ThrottleMgr.ts | Adds headers. |
| shared/AppInsightsCore/src/core/TelemetryInitializerPlugin.ts | Fixes commented header to real header. |
| shared/AppInsightsCore/src/core/TelemetryHelpers.ts | Extends distributed trace context creation to accept OTel span contexts; adds OTel span-context accessor. |
| shared/AppInsightsCore/src/core/SenderPostManager.ts | Import cleanup; uses shared STR_EMPTY; adds casts for indexed properties; minor doc/comment edits. |
| shared/AppInsightsCore/src/core/ResponseHelpers.ts | Uses shared STR_EMPTY constant. |
| shared/AppInsightsCore/src/core/CookieMgr.ts | Uses indexed access with casts for config lookup. |
| shared/AppInsightsCore/src/core/AppInsightsCore.ts | Formatting, removes local no-op, uses _noopVoid, adds OTel span-context typing. |
| shared/AppInsightsCore/src/config/DynamicSupport.ts | Adds @internal tag to comment. |
| shared/AppInsightsCore/src/config/DynamicConfig.ts | Uses STR_EMPTY constant in toJSON label. |
| shared/AppInsightsCore/rollup.config.js | Formatting + adjusts config call args for core bundling. |
| shared/AppInsightsCore/package.json | Bumps @nevware21/grunt-* dev dependencies. |
| shared/AppInsightsCore/Tests/Unit/src/trace/traceUtils.Tests.ts | Updates imports after test restructuring. |
| shared/AppInsightsCore/Tests/Unit/src/trace/traceState.Tests.ts | Adds new OTel trace-state unit tests. |
| shared/AppInsightsCore/Tests/Unit/src/trace/span.Tests.ts | Updates tests to use safer optional chaining/casts. |
| shared/AppInsightsCore/Tests/Unit/src/trace/W3cTraceState.Tests.ts | Fixes relative import path. |
| shared/AppInsightsCore/Tests/Unit/src/trace/W3cTraceParentTests.ts | Fixes relative import paths. |
| shared/AppInsightsCore/Tests/Unit/src/trace/W3CTraceStateModes.tests.ts | Adds new tests for distributed tracing mode bitmasks. |
| shared/AppInsightsCore/Tests/Unit/src/config/DynamicConfig.Tests.ts | Updates imports and relocates TestPlugins reference. |
| shared/AppInsightsCore/Tests/Unit/src/config/Dynamic.Tests.ts | Updates imports and relocates TestPlugins reference. |
| shared/AppInsightsCore/Tests/Unit/src/aiunittests.ts | Restructures unit test entrypoint imports to new folder layout. |
| shared/AppInsightsCore/Tests/Unit/src/ai/UpdateConfig.Tests.ts | Fixes relative import paths. |
| shared/AppInsightsCore/Tests/Unit/src/ai/TestPlugins.ts | Fixes relative import paths. |
| shared/AppInsightsCore/Tests/Unit/src/ai/StatsBeat.Tests.ts | Fixes commented-out relative import paths. |
| shared/AppInsightsCore/Tests/Unit/src/ai/SeverityLevel.tests.ts | Adds new tests for severity enum mappings. |
| shared/AppInsightsCore/Tests/Unit/src/ai/SendPostManager.Tests.ts | Fixes relative import paths. |
| shared/AppInsightsCore/Tests/Unit/src/ai/RequestHeaders.tests.ts | Adds new tests for request headers enum/map. |
| shared/AppInsightsCore/Tests/Unit/src/ai/LoggingEnum.Tests.ts | Fixes relative import paths. |
| shared/AppInsightsCore/Tests/Unit/src/ai/HelperFunc.Tests.ts | Fixes relative import paths. |
| shared/AppInsightsCore/Tests/Unit/src/ai/GlobalTestHooks.Test.ts | Fixes relative import paths. |
| shared/AppInsightsCore/Tests/Unit/src/ai/Exception.tests.ts | Adds new exception parsing/sanitization tests. |
| shared/AppInsightsCore/Tests/Unit/src/ai/EventsDiscardedReason.Tests.ts | Fixes relative import paths. |
| shared/AppInsightsCore/Tests/Unit/src/ai/EventHelper.Tests.ts | Fixes relative import paths. |
| shared/AppInsightsCore/Tests/Unit/src/ai/CookieManager.Tests.ts | Fixes relative import paths. |
| shared/AppInsightsCore/Tests/Unit/src/ai/ConnectionStringParser.tests.ts | Adds new connection string parser tests. |
| shared/AppInsightsCore/Tests/Unit/src/ai/ApplicationInsightsCore.Tests.ts | Fixes import paths and removes some unused imports. |
| shared/AppInsightsCore/Tests/Unit/src/ai/AppInsightsCoreSize.Tests.ts | Adds new size/deflate budget test. |
| shared/AppInsightsCore/Tests/Unit/src/ai/AppInsightsCommon.tests.ts | Adds new “Common” sanitizer-related tests under Core test tree. |
| shared/AppInsightsCore/Tests/Unit/src/Common/appinsights-common.tests.ts | Removes old combined common test runner file. |
| shared/AppInsightsCore/StartSpan_Implementation.md | Present (no diff shown). |
| shared/AppInsightsCommon/package.json | Bumps @nevware21/grunt-* dev dependencies. |
| rush.json | Bumps Rush version to 5.167.0. |
| package.json | Bumps @microsoft/rush and @nevware21/grunt-* dev dependencies. |
| extensions/applicationinsights-properties-js/package.json | Bumps @nevware21/grunt-* dev dependencies. |
| extensions/applicationinsights-perfmarkmeasure-js/package.json | Bumps @nevware21/grunt-* dev dependencies. |
| extensions/applicationinsights-dependencies-js/src/ajax.ts | Minor string formatting change. |
| extensions/applicationinsights-dependencies-js/package.json | Bumps @nevware21/grunt-* dev dependencies. |
| extensions/applicationinsights-debugplugin-js/package.json | Bumps @nevware21/grunt-* dev dependencies. |
| extensions/applicationinsights-clickanalytics-js/package.json | Bumps @nevware21/grunt-* dev dependencies. |
| extensions/applicationinsights-cfgsync-js/package.json | Bumps @nevware21/grunt-* dev dependencies. |
| extensions/applicationinsights-analytics-js/src/JavaScriptSDK/AnalyticsPlugin.ts | Removes unused counter; formatting adjustments; minor typing spacing. |
| extensions/applicationinsights-analytics-js/package.json | Bumps @nevware21/grunt-* dev dependencies. |
| examples/shared-worker/package.json | Bumps @nevware21/grunt-* dev dependencies. |
| examples/cfgSync/package.json | Bumps @nevware21/grunt-* dev dependencies. |
| common/scripts/install-run.js | Updates generated Rush helper script (currently appears malformed). |
| common/scripts/install-run-rush.js | Updates generated Rush helper script (currently appears malformed). |
| common/Tests/Framework/package.json | Bumps @nevware21/grunt-ts-plugin. |
| channels/tee-channel-js/package.json | Bumps @nevware21/grunt-* dev dependencies. |
| channels/offline-channel-js/package.json | Bumps @nevware21/grunt-* dev dependencies. |
| channels/applicationinsights-channel-js/package.json | Bumps @nevware21/grunt-* dev dependencies. |
| channels/applicationinsights-channel-js/Tests/Unit/src/Sender.tests.ts | Adds tests for gzip payload encoding feature opt-in. |
| AISKULight/package.json | Bumps @nevware21/grunt-* dev dependencies. |
| AISKU/package.json | Bumps @nevware21/grunt-* dev dependencies. |
Files not reviewed (1)
- common/config/rush/npm-shrinkwrap.json: Language not supported
Comment on lines
+307
to
+320
| export function callWithTimeout<T>( | ||
| handlers: IOTelErrorHandlers, | ||
| promise: Promise<T>, | ||
| timeout: number | ||
| ): IPromise<T> { | ||
| const timeoutMessage = "Operation timed out."; | ||
| const timeoutError = new Error(timeoutMessage); | ||
| timeoutError.name = "TimeoutError"; | ||
| (timeoutError as { __otelTimeout?: boolean }).__otelTimeout = true; | ||
|
|
||
| const racedPromise = createRacePromise<T>([ | ||
| promise, | ||
| createTimeoutPromise<Error>(timeout, false, timeoutError) as unknown as PromiseLike<T> | ||
| ]); |
There was a problem hiding this comment.
callWithTimeout currently only accepts a native Promise<T>, but this codebase frequently uses IPromise / PromiseLike for IE-compatible async. Accepting PromiseLike<T> (or IPromise<T> | PromiseLike<T>) would avoid forcing callers to convert types and would let you drop the as unknown as PromiseLike<T> cast for the timeout branch.
MSNev
commented
Feb 7, 2026
MSNev
commented
Feb 7, 2026
| } | ||
|
|
||
| /** | ||
| * A helper method to determine whether the provided value is in a ISO time span format (DD.HH:MM:SS.MMMMMM) |
JacksonWeber
approved these changes
Feb 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
chore: Update build dependencies and refactor AppInsightsCore tests
Summary:
Changes:
Dependency Updates:
Test Reorganization:
OpenTelemetry Enhancements:
Code Cleanup: