Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
af220a3
Enable SDK Stats and route to the SDK Stats ingestion endpoint
JacksonWeber Jun 17, 2026
689e26d
Make SDK Stats destination configurable via dynamic/CDN config
JacksonWeber Jun 17, 2026
82dc7e7
Optimize repeated property access in SDK Stats endpoint detection
JacksonWeber Jun 17, 2026
dee400d
Re-enable SDK Stats unit tests with updated terminology
JacksonWeber Jun 17, 2026
bb2515c
Merge remote-tracking branch 'upstream/main' into jacksonweber/enable…
JacksonWeber Jun 18, 2026
a56505d
test: address SDK Stats unit test review feedback
JacksonWeber Jun 18, 2026
c9fb76b
test: read SDK Stats config from top-level config.stats
JacksonWeber Jun 18, 2026
adce17f
test: fix SDK Stats timer ticks, none/null opt-in expectations, core …
JacksonWeber Jun 18, 2026
515494d
test: wire stats manager to core in channel init test
JacksonWeber Jun 18, 2026
bf53f68
test: bump AISKU size budget for SDK Stats enablement
JacksonWeber Jun 18, 2026
3fff536
Merge remote-tracking branch 'upstream/main' into jacksonweber/enable…
JacksonWeber Jun 26, 2026
5fd01d9
test: bump core and AISKU bundle-size budgets for SDK Stats
JacksonWeber Jun 26, 2026
04410c8
fix: seed SDK Stats defaults into the global config for dynamic confi…
JacksonWeber Jun 29, 2026
5f9c780
test: bump core and AISKU deflate budgets for SDK Stats dynamic-confi…
JacksonWeber Jun 29, 2026
ff5f5fa
refactor(stats): remove createSdkStatsMgrConfig, read SDK Stats confi…
JacksonWeber Jul 8, 2026
68b9226
Merge remote-tracking branch 'upstream/main' into jacksonweber/enable…
JacksonWeber Jul 17, 2026
1a3fbb0
Read SDK Stats config from cfg/v1.json and gate on the enabled flag
JacksonWeber Jul 18, 2026
2a5a430
Rename internal StatsBeat to Internal SDK Stats
JacksonWeber Jul 18, 2026
ad93383
Use cfg/v1.json as sole authority for SDK Stats enabled state and des…
JacksonWeber Jul 20, 2026
f45b3b3
Refactor SDK Stats config handling to use local vars instead of store…
JacksonWeber Jul 20, 2026
d40a558
Remove IConfigDefaults cast by pinning onConfigChange to IConfiguration
JacksonWeber Jul 20, 2026
7ba04a4
Remove leftover commented-out _sdk/IInternalSdkConfiguration scaffolding
JacksonWeber Jul 21, 2026
9bd13ac
Remove unused StatsType/eStatsType from SDK Stats
JacksonWeber Jul 21, 2026
ed3ca0e
Reduce Internal SDK Stats minified size (-377 bytes raw, -127 bytes g…
JacksonWeber Jul 21, 2026
1adb831
Unload core in InternalSdkStats test cleanup to prevent hook leaks
JacksonWeber Jul 21, 2026
44e6681
Fix CodeQL prototype-pollution alert in SDK stats counters
JacksonWeber Jul 21, 2026
dbb7b7b
Address Copilot review feedback on SDK Stats
JacksonWeber Aug 4, 2026
769c93a
Source SDK Stats config url from dynamic config instead of hardcoding
JacksonWeber Aug 4, 2026
ae02d60
Persist SDK Stats across page loads
JacksonWeber Aug 5, 2026
c054410
Reduce SDK Stats EU region literals
JacksonWeber Aug 6, 2026
aa1c074
Cache SDK Stats endpoint resolution
JacksonWeber Aug 6, 2026
d7e823c
Report snippet version in SDK Stats version
JacksonWeber Aug 6, 2026
0792aba
Isolate SDK Stats from customer pipeline
JacksonWeber Aug 6, 2026
9ebe2b7
test: update core bundle size budget
JacksonWeber Aug 7, 2026
27e737b
test: provide config on SDK Stats core mock
JacksonWeber Aug 7, 2026
cfafa53
test: update AISKU bundle size budget
JacksonWeber Aug 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .aiAutoMinify.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"eLoggingSeverity",
"_eInternalMessageId",
"SendRequestReason",
"eStatsType",
"TelemetryUnloadReason",
"TelemetryUpdateReason",
"eTraceHeadersMode",
Expand Down
2 changes: 1 addition & 1 deletion AISKU/Tests/Manual/testVersionConflict.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// onInit: null, // Once the application insights instance has loaded and initialized this callback function will be called with 1 argument -- the sdk instance (DO NOT ADD anything to the sdk.queue -- As they won't get called)
sri: true, // Custom optional value to specify whether fetching the snippet from integrity file and do integrity check
cfg: { // Application Insights Configuration
disableStatsBeat: false,
disableInternalSdkStats: false,
connectionString: "YOUR_INSTRUMENTATION_KEY",
}
});
Expand Down
8 changes: 4 additions & 4 deletions AISKU/Tests/Unit/src/AISKUSize.Tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ function _checkSize(checkType: string, maxSize: number, size: number, isNightly:
}

export class AISKUSizeCheck extends AITestClass {
private readonly MAX_RAW_SIZE = 177;
private readonly MAX_BUNDLE_SIZE = 177;
private readonly MAX_RAW_DEFLATE_SIZE = 71;
private readonly MAX_BUNDLE_DEFLATE_SIZE = 71;
private readonly MAX_RAW_SIZE = 181;
private readonly MAX_BUNDLE_SIZE = 182;
private readonly MAX_RAW_DEFLATE_SIZE = 74;
private readonly MAX_BUNDLE_DEFLATE_SIZE = 74;
private readonly rawFilePath = "../dist/es5/applicationinsights-web.min.js";
// Automatically updated by version scripts
private readonly currentVer = "3.4.3";
Expand Down
27 changes: 27 additions & 0 deletions AISKU/Tests/Unit/src/SdkStatsFeature.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class SdkStatsFeatureTests extends AITestClass {
this._testSdkStatsDynamicEnableDisable();
this._testSdkStatsConfigDefaults();
this._testSdkStatsDynamicConfigChanges();
this._testSnippetSdkVersion();
}

private _createAi(configOverrides?: Partial<IConfiguration & IConfig>): AppInsightsSku {
Expand Down Expand Up @@ -303,4 +304,30 @@ export class SdkStatsFeatureTests extends AITestClass {
}
});
}

private _testSnippetSdkVersion() {
this.testCase({
name: "SdkStatsFeature: snippet version is included in the SDK Stats version",
useFakeTimers: true,
test: () => {
let config = {
connectionString: TestConnectionString,
stats: {},
extensionConfig: {
["AppInsightsCfgSyncPlugin"]: {
syncMode: ICfgSyncMode.Receive,
cfgUrl: ""
}
}
} as IConfiguration & IConfig;
let ai = new AppInsightsSku({ config: config, sv: "6", queue: [] } as any);
ai.loadAppInsights();
this._ai = ai;
this.clock.tick(1);

Assert.equal("6", ai.config.stats.snp, "SDK Stats config should contain snippet version 6");
}
});
}

}
37 changes: 33 additions & 4 deletions AISKU/src/AISku.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import {
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, createSdkStatsNotifCbk, createTraceProvider,
createUniqueNamespace, doPerf, eLoggingSeverity, hasDocument, hasWindow, isArray, isFeatureEnabled, isFunction, isNullOrUndefined,
isReactNative, isString, mergeEvtNamespace, onConfigChange, parseConnectionString, proxyAssign, proxyFunctions,
cfgDfValidate, createDynamicConfig, createOTelApi, createProcessTelemetryContext, createSdkStatsNotifCbk, createStatsMgr,
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 {
Expand Down Expand Up @@ -66,7 +66,7 @@ const CDN_USAGE = "CdnUsage";
const SDK_LOADER_VER = "SdkLoaderVer";
const ZIP_PAYLOAD = "zipPayload";
const SDK_STATS = "SdkStats";
var _sdkVersion = "#version#";
var _sdkVersion = '3.4.3';

const default_limit = {
samplingRate: 100,
Expand Down Expand Up @@ -398,6 +398,31 @@ export class AppInsightsSku implements IApplicationInsights<IConfiguration & ICo
// initialize core
_core.initialize(_config, [ _sender, properties, dependencies, _analyticsPlugin, _cfgSyncPlugin], logger, notificationManager);

// Enable SDK Stats collection. The manager reads its configuration directly from the
// single global config (config.stats) and gates itself behind the SDK Stats feature
// flag, routing the resulting events to the distro-owned SDK Stats ingestion endpoint.
// The config url and iKey are supplied by config.stats, until both are present no
// SDK Stats are sent. Opt-out via featureOptIn "sdkStats".
if (_core.setStatsMgr) {
let statsMgr = createStatsMgr();
_core.setStatsMgr(statsMgr);
let statsHook = statsMgr.init<IConfiguration & IConfig>(_core, (statsConfig) => {
try {
let statsCore = new AppInsightsCore();
(statsConfig as IConfiguration & IConfig).maxBatchInterval = 1;
statsCore.initialize(statsConfig as IConfiguration & IConfig, [new Sender()]);
return statsCore;
} catch (e) {
_throwInternal(_core.logger, eLoggingSeverity.WARNING,
_eInternalMessageId.InternalSdkStatsManagerException, "Failed to create SDK Stats core");
return null;
}
});
if (statsHook) {
_core.addUnloadHook(statsHook);
}
}

// Initialize the initial OTel API
_otelApi = _initOTel(_self, "aisku", _onEnd, _onException);

Expand All @@ -413,6 +438,10 @@ export class AppInsightsSku implements IApplicationInsights<IConfiguration & ICo
_self.context.internal.sdkSrc = sdkSrc;
}
_updateSnippetProperties(_self.snippet);

if (_config.stats) {
_config.stats.snp = _snippetVersion;
}

// Empty queue of all api calls logged prior to sdk download
_self.emptyQueue();
Expand Down
Loading
Loading