@uipath/common 1.199.0-preview.107 → 1.199.0-preview.108
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.d.ts +1 -1
- package/dist/index.browser.js +46 -24
- package/dist/index.js +46 -36
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/telemetry/index.js +46 -24
- package/dist/telemetry/node-appinsights-telemetry-provider.d.ts +0 -12
- package/dist/telemetry/node.d.ts +1 -1
- package/dist/telemetry/session-id.d.ts +54 -9
- package/package.json +2 -2
package/dist/index.browser.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export * from "./telemetry/command-attribution.js";
|
|
|
26
26
|
export * from "./telemetry/command-terminal.js";
|
|
27
27
|
export { ConsoleTelemetryProvider } from "./telemetry/console-telemetry-provider.js";
|
|
28
28
|
export type { IContextStorage } from "./telemetry/context-storage.js";
|
|
29
|
-
export { getConfiguredTelemetrySessionId, getTelemetrySessionId,
|
|
29
|
+
export { getConfiguredTelemetrySessionId, getTelemetrySessionId, getTelemetrySessionSource, TELEMETRY_SESSION_ID_ENV, TELEMETRY_SESSION_SOURCE_PROPERTY, } from "./telemetry/session-id.js";
|
|
30
30
|
export * from "./telemetry/telemetry-events.js";
|
|
31
31
|
export type { ITelemetryProvider } from "./telemetry/telemetry-provider.js";
|
|
32
32
|
export type { ITelemetryService, TelemetryContext, TelemetryProperties, } from "./telemetry/telemetry-service.js";
|
package/dist/index.browser.js
CHANGED
|
@@ -22842,8 +22842,18 @@ function getInboundTraceContext() {
|
|
|
22842
22842
|
|
|
22843
22843
|
// src/telemetry/session-id.ts
|
|
22844
22844
|
var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
|
|
22845
|
-
var
|
|
22846
|
-
var
|
|
22845
|
+
var SESSION_ID_MAX_LENGTH = 64;
|
|
22846
|
+
var RANDOM_SESSION_ID_LENGTH = 32;
|
|
22847
|
+
var TELEMETRY_SESSION_SOURCE_PROPERTY = "session_id_source";
|
|
22848
|
+
var CONTROL_CHARACTERS = /\p{Cc}/gu;
|
|
22849
|
+
var INHERITED_SESSION_SOURCES = [
|
|
22850
|
+
{ envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
|
|
22851
|
+
{ envVar: "CODEX_THREAD_ID", source: "codex" },
|
|
22852
|
+
{ envVar: "ANTIGRAVITY_TRAJECTORY_ID", source: "antigravity" },
|
|
22853
|
+
{ envVar: "TERM_SESSION_ID", source: "terminal" },
|
|
22854
|
+
{ envVar: "WT_SESSION", source: "terminal" }
|
|
22855
|
+
];
|
|
22856
|
+
var telemetrySessionSlot = singleton("TelemetrySession");
|
|
22847
22857
|
var telemetryOperationIdSlot = singleton("TelemetryOperationId");
|
|
22848
22858
|
function getProcessEnv2() {
|
|
22849
22859
|
return globalThis.process?.env;
|
|
@@ -22852,27 +22862,45 @@ function normalizeSessionId(value) {
|
|
|
22852
22862
|
if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
|
|
22853
22863
|
return;
|
|
22854
22864
|
}
|
|
22855
|
-
const
|
|
22856
|
-
return
|
|
22865
|
+
const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
|
|
22866
|
+
return cleaned || undefined;
|
|
22857
22867
|
}
|
|
22858
22868
|
function getConfiguredTelemetrySessionId() {
|
|
22859
22869
|
return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
|
|
22860
22870
|
}
|
|
22861
|
-
function
|
|
22862
|
-
const
|
|
22863
|
-
|
|
22864
|
-
|
|
22871
|
+
function getInheritedSession(env2) {
|
|
22872
|
+
for (const candidate of INHERITED_SESSION_SOURCES) {
|
|
22873
|
+
const handle = normalizeSessionId(env2[candidate.envVar]);
|
|
22874
|
+
if (handle) {
|
|
22875
|
+
return { id: handle, source: candidate.source };
|
|
22876
|
+
}
|
|
22877
|
+
}
|
|
22878
|
+
return;
|
|
22879
|
+
}
|
|
22880
|
+
function generateRandomSession() {
|
|
22881
|
+
const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
|
|
22882
|
+
crypto.getRandomValues(bytes);
|
|
22883
|
+
let hex = "";
|
|
22884
|
+
for (const byte of bytes) {
|
|
22885
|
+
hex += byte.toString(16).padStart(2, "0");
|
|
22865
22886
|
}
|
|
22866
|
-
|
|
22887
|
+
return { id: hex, source: "random" };
|
|
22888
|
+
}
|
|
22889
|
+
function resolveTelemetrySession() {
|
|
22890
|
+
const existing = telemetrySessionSlot.get();
|
|
22867
22891
|
if (existing) {
|
|
22868
22892
|
return existing;
|
|
22869
22893
|
}
|
|
22870
|
-
const
|
|
22871
|
-
|
|
22872
|
-
|
|
22894
|
+
const declaredHandle = getConfiguredTelemetrySessionId();
|
|
22895
|
+
const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
|
|
22896
|
+
telemetrySessionSlot.set(resolved);
|
|
22897
|
+
return resolved;
|
|
22898
|
+
}
|
|
22899
|
+
function getTelemetrySessionId() {
|
|
22900
|
+
return resolveTelemetrySession().id;
|
|
22873
22901
|
}
|
|
22874
|
-
function
|
|
22875
|
-
return
|
|
22902
|
+
function getTelemetrySessionSource() {
|
|
22903
|
+
return resolveTelemetrySession().source;
|
|
22876
22904
|
}
|
|
22877
22905
|
function getTelemetryOperationId() {
|
|
22878
22906
|
const existing = telemetryOperationIdSlot.get();
|
|
@@ -23278,24 +23306,18 @@ class TelemetryService {
|
|
|
23278
23306
|
}
|
|
23279
23307
|
enrichPropertiesWithContext(properties, context) {
|
|
23280
23308
|
const globalProperties = getGlobalTelemetryProperties();
|
|
23281
|
-
const existingSessionId = properties?.[TELEMETRY_SESSION_ID_PROPERTY] ?? this.defaultProperties?.[TELEMETRY_SESSION_ID_PROPERTY] ?? globalProperties?.[TELEMETRY_SESSION_ID_PROPERTY];
|
|
23282
|
-
const sessionId = resolveTelemetrySessionId(existingSessionId);
|
|
23283
23309
|
const enriched = {
|
|
23284
23310
|
...getExecutionContextTelemetryProperties(),
|
|
23285
23311
|
...globalProperties,
|
|
23286
23312
|
...this.defaultProperties,
|
|
23287
23313
|
...redactProperties(properties ?? {}),
|
|
23314
|
+
[TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource(),
|
|
23288
23315
|
...context ? {
|
|
23289
23316
|
[TELEMETRY_OPERATION_ID_PROPERTY]: context.operationId,
|
|
23290
23317
|
...context.parentId !== undefined ? { [TELEMETRY_PARENT_ID_PROPERTY]: context.parentId } : {},
|
|
23291
23318
|
[TELEMETRY_SPAN_ID_PROPERTY]: context.id
|
|
23292
23319
|
} : {}
|
|
23293
23320
|
};
|
|
23294
|
-
if (sessionId === undefined) {
|
|
23295
|
-
delete enriched[TELEMETRY_SESSION_ID_PROPERTY];
|
|
23296
|
-
} else {
|
|
23297
|
-
enriched[TELEMETRY_SESSION_ID_PROPERTY] = sessionId;
|
|
23298
|
-
}
|
|
23299
23321
|
return enriched;
|
|
23300
23322
|
}
|
|
23301
23323
|
generateId() {
|
|
@@ -23337,7 +23359,6 @@ export {
|
|
|
23337
23359
|
setGlobalLogFilePath,
|
|
23338
23360
|
runWithSink,
|
|
23339
23361
|
restoreConsole,
|
|
23340
|
-
resolveTelemetrySessionId,
|
|
23341
23362
|
resolveEnvReference,
|
|
23342
23363
|
resetLoggerInstance,
|
|
23343
23364
|
registerPackageMetadataOptions,
|
|
@@ -23363,6 +23384,7 @@ export {
|
|
|
23363
23384
|
installSdkCodingAgentHeader,
|
|
23364
23385
|
installConsoleGuard,
|
|
23365
23386
|
hashContent,
|
|
23387
|
+
getTelemetrySessionSource,
|
|
23366
23388
|
getTelemetrySessionId,
|
|
23367
23389
|
getSdkUserAgentToken,
|
|
23368
23390
|
getRecordedCommandFailureTelemetry,
|
|
@@ -23399,7 +23421,7 @@ export {
|
|
|
23399
23421
|
addSdkCodingAgentHeader,
|
|
23400
23422
|
UIPATH_HOME_DIR,
|
|
23401
23423
|
TelemetryService,
|
|
23402
|
-
|
|
23424
|
+
TELEMETRY_SESSION_SOURCE_PROPERTY,
|
|
23403
23425
|
TELEMETRY_SESSION_ID_ENV,
|
|
23404
23426
|
ScreenLogger,
|
|
23405
23427
|
PollOutcome,
|
|
@@ -23421,4 +23443,4 @@ export {
|
|
|
23421
23443
|
AUTH_FILENAME
|
|
23422
23444
|
};
|
|
23423
23445
|
|
|
23424
|
-
//# debugId=
|
|
23446
|
+
//# debugId=04886234C3E93F8264756E2164756E21
|
package/dist/index.js
CHANGED
|
@@ -9476,8 +9476,18 @@ function getInboundTraceContext() {
|
|
|
9476
9476
|
|
|
9477
9477
|
// src/telemetry/session-id.ts
|
|
9478
9478
|
var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
|
|
9479
|
-
var
|
|
9480
|
-
var
|
|
9479
|
+
var SESSION_ID_MAX_LENGTH = 64;
|
|
9480
|
+
var RANDOM_SESSION_ID_LENGTH = 32;
|
|
9481
|
+
var TELEMETRY_SESSION_SOURCE_PROPERTY = "session_id_source";
|
|
9482
|
+
var CONTROL_CHARACTERS = /\p{Cc}/gu;
|
|
9483
|
+
var INHERITED_SESSION_SOURCES = [
|
|
9484
|
+
{ envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
|
|
9485
|
+
{ envVar: "CODEX_THREAD_ID", source: "codex" },
|
|
9486
|
+
{ envVar: "ANTIGRAVITY_TRAJECTORY_ID", source: "antigravity" },
|
|
9487
|
+
{ envVar: "TERM_SESSION_ID", source: "terminal" },
|
|
9488
|
+
{ envVar: "WT_SESSION", source: "terminal" }
|
|
9489
|
+
];
|
|
9490
|
+
var telemetrySessionSlot = singleton("TelemetrySession");
|
|
9481
9491
|
var telemetryOperationIdSlot = singleton("TelemetryOperationId");
|
|
9482
9492
|
function getProcessEnv2() {
|
|
9483
9493
|
return globalThis.process?.env;
|
|
@@ -9486,27 +9496,45 @@ function normalizeSessionId(value) {
|
|
|
9486
9496
|
if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
|
|
9487
9497
|
return;
|
|
9488
9498
|
}
|
|
9489
|
-
const
|
|
9490
|
-
return
|
|
9499
|
+
const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
|
|
9500
|
+
return cleaned || undefined;
|
|
9491
9501
|
}
|
|
9492
9502
|
function getConfiguredTelemetrySessionId() {
|
|
9493
9503
|
return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
|
|
9494
9504
|
}
|
|
9495
|
-
function
|
|
9496
|
-
const
|
|
9497
|
-
|
|
9498
|
-
|
|
9505
|
+
function getInheritedSession(env) {
|
|
9506
|
+
for (const candidate of INHERITED_SESSION_SOURCES) {
|
|
9507
|
+
const handle = normalizeSessionId(env[candidate.envVar]);
|
|
9508
|
+
if (handle) {
|
|
9509
|
+
return { id: handle, source: candidate.source };
|
|
9510
|
+
}
|
|
9511
|
+
}
|
|
9512
|
+
return;
|
|
9513
|
+
}
|
|
9514
|
+
function generateRandomSession() {
|
|
9515
|
+
const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
|
|
9516
|
+
crypto.getRandomValues(bytes);
|
|
9517
|
+
let hex = "";
|
|
9518
|
+
for (const byte of bytes) {
|
|
9519
|
+
hex += byte.toString(16).padStart(2, "0");
|
|
9499
9520
|
}
|
|
9500
|
-
|
|
9521
|
+
return { id: hex, source: "random" };
|
|
9522
|
+
}
|
|
9523
|
+
function resolveTelemetrySession() {
|
|
9524
|
+
const existing = telemetrySessionSlot.get();
|
|
9501
9525
|
if (existing) {
|
|
9502
9526
|
return existing;
|
|
9503
9527
|
}
|
|
9504
|
-
const
|
|
9505
|
-
|
|
9506
|
-
|
|
9528
|
+
const declaredHandle = getConfiguredTelemetrySessionId();
|
|
9529
|
+
const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
|
|
9530
|
+
telemetrySessionSlot.set(resolved);
|
|
9531
|
+
return resolved;
|
|
9507
9532
|
}
|
|
9508
|
-
function
|
|
9509
|
-
return
|
|
9533
|
+
function getTelemetrySessionId() {
|
|
9534
|
+
return resolveTelemetrySession().id;
|
|
9535
|
+
}
|
|
9536
|
+
function getTelemetrySessionSource() {
|
|
9537
|
+
return resolveTelemetrySession().source;
|
|
9510
9538
|
}
|
|
9511
9539
|
function getTelemetryOperationId() {
|
|
9512
9540
|
const existing = telemetryOperationIdSlot.get();
|
|
@@ -9787,24 +9815,18 @@ class TelemetryService {
|
|
|
9787
9815
|
}
|
|
9788
9816
|
enrichPropertiesWithContext(properties, context) {
|
|
9789
9817
|
const globalProperties = getGlobalTelemetryProperties();
|
|
9790
|
-
const existingSessionId = properties?.[TELEMETRY_SESSION_ID_PROPERTY] ?? this.defaultProperties?.[TELEMETRY_SESSION_ID_PROPERTY] ?? globalProperties?.[TELEMETRY_SESSION_ID_PROPERTY];
|
|
9791
|
-
const sessionId = resolveTelemetrySessionId(existingSessionId);
|
|
9792
9818
|
const enriched = {
|
|
9793
9819
|
...getExecutionContextTelemetryProperties(),
|
|
9794
9820
|
...globalProperties,
|
|
9795
9821
|
...this.defaultProperties,
|
|
9796
9822
|
...redactProperties(properties ?? {}),
|
|
9823
|
+
[TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource(),
|
|
9797
9824
|
...context ? {
|
|
9798
9825
|
[TELEMETRY_OPERATION_ID_PROPERTY]: context.operationId,
|
|
9799
9826
|
...context.parentId !== undefined ? { [TELEMETRY_PARENT_ID_PROPERTY]: context.parentId } : {},
|
|
9800
9827
|
[TELEMETRY_SPAN_ID_PROPERTY]: context.id
|
|
9801
9828
|
} : {}
|
|
9802
9829
|
};
|
|
9803
|
-
if (sessionId === undefined) {
|
|
9804
|
-
delete enriched[TELEMETRY_SESSION_ID_PROPERTY];
|
|
9805
|
-
} else {
|
|
9806
|
-
enriched[TELEMETRY_SESSION_ID_PROPERTY] = sessionId;
|
|
9807
|
-
}
|
|
9808
9830
|
return enriched;
|
|
9809
9831
|
}
|
|
9810
9832
|
generateId() {
|
|
@@ -10042,16 +10064,6 @@ class NodeAppInsightsTelemetryProvider {
|
|
|
10042
10064
|
}
|
|
10043
10065
|
return { operationId, parentId, spanId };
|
|
10044
10066
|
}
|
|
10045
|
-
promoteSessionTag(merged, tags) {
|
|
10046
|
-
const client = this.client;
|
|
10047
|
-
if (!client || !merged)
|
|
10048
|
-
return;
|
|
10049
|
-
const sessionId = merged[TELEMETRY_SESSION_ID_PROPERTY];
|
|
10050
|
-
delete merged[TELEMETRY_SESSION_ID_PROPERTY];
|
|
10051
|
-
if (sessionId) {
|
|
10052
|
-
tags[client.context.keys.sessionId] = sessionId;
|
|
10053
|
-
}
|
|
10054
|
-
}
|
|
10055
10067
|
leafTagOverrides(properties) {
|
|
10056
10068
|
const client = this.client;
|
|
10057
10069
|
if (!client)
|
|
@@ -10064,7 +10076,6 @@ class NodeAppInsightsTelemetryProvider {
|
|
|
10064
10076
|
if (spanId) {
|
|
10065
10077
|
tags[keys.operationParentId] = spanId;
|
|
10066
10078
|
}
|
|
10067
|
-
this.promoteSessionTag(properties, tags);
|
|
10068
10079
|
return tags;
|
|
10069
10080
|
}
|
|
10070
10081
|
operationCorrelation(properties) {
|
|
@@ -10079,7 +10090,6 @@ class NodeAppInsightsTelemetryProvider {
|
|
|
10079
10090
|
if (parentId) {
|
|
10080
10091
|
tagOverrides[keys.operationParentId] = parentId;
|
|
10081
10092
|
}
|
|
10082
|
-
this.promoteSessionTag(properties, tagOverrides);
|
|
10083
10093
|
return { tagOverrides, id: spanId };
|
|
10084
10094
|
}
|
|
10085
10095
|
async trackEvent(eventName, properties) {
|
|
@@ -12346,7 +12356,6 @@ export {
|
|
|
12346
12356
|
runValidators,
|
|
12347
12357
|
runChecks,
|
|
12348
12358
|
restoreConsole,
|
|
12349
|
-
resolveTelemetrySessionId,
|
|
12350
12359
|
resolveEnvReference,
|
|
12351
12360
|
resolveDeprecatedOptionAlias,
|
|
12352
12361
|
resolveAttachmentInputs,
|
|
@@ -12391,6 +12400,7 @@ export {
|
|
|
12391
12400
|
installSdkCodingAgentHeader,
|
|
12392
12401
|
installConsoleGuard,
|
|
12393
12402
|
hashContent,
|
|
12403
|
+
getTelemetrySessionSource,
|
|
12394
12404
|
getTelemetrySessionId,
|
|
12395
12405
|
getSdkUserAgentToken,
|
|
12396
12406
|
getRecordedCommandFailureTelemetry,
|
|
@@ -12444,7 +12454,7 @@ export {
|
|
|
12444
12454
|
TelemetryService,
|
|
12445
12455
|
TELEMETRY_TRACEPARENT_ENV,
|
|
12446
12456
|
TELEMETRY_SPAN_ID_PROPERTY,
|
|
12447
|
-
|
|
12457
|
+
TELEMETRY_SESSION_SOURCE_PROPERTY,
|
|
12448
12458
|
TELEMETRY_SESSION_ID_ENV,
|
|
12449
12459
|
TELEMETRY_PARENT_ID_PROPERTY,
|
|
12450
12460
|
TELEMETRY_OPERATION_ID_PROPERTY,
|
|
@@ -12483,4 +12493,4 @@ export {
|
|
|
12483
12493
|
ATTACHMENT_INSTRUCTIONS
|
|
12484
12494
|
};
|
|
12485
12495
|
|
|
12486
|
-
//# debugId=
|
|
12496
|
+
//# debugId=6E7A3372F0CCF5B264756E2164756E21
|
|
@@ -5,7 +5,7 @@ export type { IContextStorage } from "./context-storage.js";
|
|
|
5
5
|
export { buildEnvironmentProperties, type NormalizedEnvironment, normalizeBaseUrl, normalizeEnvironment, } from "./environment-info.js";
|
|
6
6
|
export { type CiProvider, detectExecutionContext, EXECUTION_CONTEXT_VALUES, type ExecutionContext, type ExecutionContextDetection, type ExecutionContextDetectionOptions, getExecutionContextTelemetryProperties, setExecutionContextAuthSignal, } from "./execution-context.js";
|
|
7
7
|
export { redactError, redactProperties, redactProperty, redactValue, } from "./pii-redactor.js";
|
|
8
|
-
export { getConfiguredTelemetrySessionId, getTelemetrySessionId,
|
|
8
|
+
export { getConfiguredTelemetrySessionId, getTelemetrySessionId, getTelemetrySessionSource, TELEMETRY_SESSION_ID_ENV, TELEMETRY_SESSION_SOURCE_PROPERTY, } from "./session-id.js";
|
|
9
9
|
export type { ITelemetryProvider } from "./telemetry-provider.js";
|
|
10
10
|
export type { ITelemetryService, TelemetryContext, TelemetryProperties, } from "./telemetry-service.js";
|
|
11
11
|
export { TELEMETRY_OPERATION_ID_PROPERTY, TELEMETRY_PARENT_ID_PROPERTY, TELEMETRY_SPAN_ID_PROPERTY, TelemetryService, } from "./telemetry-service.js";
|
package/dist/telemetry/index.js
CHANGED
|
@@ -588,8 +588,18 @@ function getInboundTraceContext() {
|
|
|
588
588
|
|
|
589
589
|
// src/telemetry/session-id.ts
|
|
590
590
|
var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
|
|
591
|
-
var
|
|
592
|
-
var
|
|
591
|
+
var SESSION_ID_MAX_LENGTH = 64;
|
|
592
|
+
var RANDOM_SESSION_ID_LENGTH = 32;
|
|
593
|
+
var TELEMETRY_SESSION_SOURCE_PROPERTY = "session_id_source";
|
|
594
|
+
var CONTROL_CHARACTERS = /\p{Cc}/gu;
|
|
595
|
+
var INHERITED_SESSION_SOURCES = [
|
|
596
|
+
{ envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
|
|
597
|
+
{ envVar: "CODEX_THREAD_ID", source: "codex" },
|
|
598
|
+
{ envVar: "ANTIGRAVITY_TRAJECTORY_ID", source: "antigravity" },
|
|
599
|
+
{ envVar: "TERM_SESSION_ID", source: "terminal" },
|
|
600
|
+
{ envVar: "WT_SESSION", source: "terminal" }
|
|
601
|
+
];
|
|
602
|
+
var telemetrySessionSlot = singleton("TelemetrySession");
|
|
593
603
|
var telemetryOperationIdSlot = singleton("TelemetryOperationId");
|
|
594
604
|
function getProcessEnv2() {
|
|
595
605
|
return globalThis.process?.env;
|
|
@@ -598,27 +608,45 @@ function normalizeSessionId(value) {
|
|
|
598
608
|
if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
|
|
599
609
|
return;
|
|
600
610
|
}
|
|
601
|
-
const
|
|
602
|
-
return
|
|
611
|
+
const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
|
|
612
|
+
return cleaned || undefined;
|
|
603
613
|
}
|
|
604
614
|
function getConfiguredTelemetrySessionId() {
|
|
605
615
|
return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
|
|
606
616
|
}
|
|
607
|
-
function
|
|
608
|
-
const
|
|
609
|
-
|
|
610
|
-
|
|
617
|
+
function getInheritedSession(env) {
|
|
618
|
+
for (const candidate of INHERITED_SESSION_SOURCES) {
|
|
619
|
+
const handle = normalizeSessionId(env[candidate.envVar]);
|
|
620
|
+
if (handle) {
|
|
621
|
+
return { id: handle, source: candidate.source };
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
function generateRandomSession() {
|
|
627
|
+
const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
|
|
628
|
+
crypto.getRandomValues(bytes);
|
|
629
|
+
let hex = "";
|
|
630
|
+
for (const byte of bytes) {
|
|
631
|
+
hex += byte.toString(16).padStart(2, "0");
|
|
611
632
|
}
|
|
612
|
-
|
|
633
|
+
return { id: hex, source: "random" };
|
|
634
|
+
}
|
|
635
|
+
function resolveTelemetrySession() {
|
|
636
|
+
const existing = telemetrySessionSlot.get();
|
|
613
637
|
if (existing) {
|
|
614
638
|
return existing;
|
|
615
639
|
}
|
|
616
|
-
const
|
|
617
|
-
|
|
618
|
-
|
|
640
|
+
const declaredHandle = getConfiguredTelemetrySessionId();
|
|
641
|
+
const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
|
|
642
|
+
telemetrySessionSlot.set(resolved);
|
|
643
|
+
return resolved;
|
|
644
|
+
}
|
|
645
|
+
function getTelemetrySessionId() {
|
|
646
|
+
return resolveTelemetrySession().id;
|
|
619
647
|
}
|
|
620
|
-
function
|
|
621
|
-
return
|
|
648
|
+
function getTelemetrySessionSource() {
|
|
649
|
+
return resolveTelemetrySession().source;
|
|
622
650
|
}
|
|
623
651
|
function getTelemetryOperationId() {
|
|
624
652
|
const existing = telemetryOperationIdSlot.get();
|
|
@@ -762,24 +790,18 @@ class TelemetryService {
|
|
|
762
790
|
}
|
|
763
791
|
enrichPropertiesWithContext(properties, context) {
|
|
764
792
|
const globalProperties = getGlobalTelemetryProperties();
|
|
765
|
-
const existingSessionId = properties?.[TELEMETRY_SESSION_ID_PROPERTY] ?? this.defaultProperties?.[TELEMETRY_SESSION_ID_PROPERTY] ?? globalProperties?.[TELEMETRY_SESSION_ID_PROPERTY];
|
|
766
|
-
const sessionId = resolveTelemetrySessionId(existingSessionId);
|
|
767
793
|
const enriched = {
|
|
768
794
|
...getExecutionContextTelemetryProperties(),
|
|
769
795
|
...globalProperties,
|
|
770
796
|
...this.defaultProperties,
|
|
771
797
|
...redactProperties(properties ?? {}),
|
|
798
|
+
[TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource(),
|
|
772
799
|
...context ? {
|
|
773
800
|
[TELEMETRY_OPERATION_ID_PROPERTY]: context.operationId,
|
|
774
801
|
...context.parentId !== undefined ? { [TELEMETRY_PARENT_ID_PROPERTY]: context.parentId } : {},
|
|
775
802
|
[TELEMETRY_SPAN_ID_PROPERTY]: context.id
|
|
776
803
|
} : {}
|
|
777
804
|
};
|
|
778
|
-
if (sessionId === undefined) {
|
|
779
|
-
delete enriched[TELEMETRY_SESSION_ID_PROPERTY];
|
|
780
|
-
} else {
|
|
781
|
-
enriched[TELEMETRY_SESSION_ID_PROPERTY] = sessionId;
|
|
782
|
-
}
|
|
783
805
|
return enriched;
|
|
784
806
|
}
|
|
785
807
|
generateId() {
|
|
@@ -797,7 +819,6 @@ class TelemetryService {
|
|
|
797
819
|
}
|
|
798
820
|
export {
|
|
799
821
|
setExecutionContextAuthSignal,
|
|
800
|
-
resolveTelemetrySessionId,
|
|
801
822
|
redactValue,
|
|
802
823
|
redactProperty,
|
|
803
824
|
redactProperties,
|
|
@@ -805,6 +826,7 @@ export {
|
|
|
805
826
|
normalizeSkillName,
|
|
806
827
|
normalizeEnvironment,
|
|
807
828
|
normalizeBaseUrl,
|
|
829
|
+
getTelemetrySessionSource,
|
|
808
830
|
getTelemetrySessionId,
|
|
809
831
|
getExecutionContextTelemetryProperties,
|
|
810
832
|
getConfiguredTelemetrySessionId,
|
|
@@ -814,7 +836,7 @@ export {
|
|
|
814
836
|
buildCommandTelemetryAttribution,
|
|
815
837
|
TelemetryService,
|
|
816
838
|
TELEMETRY_SPAN_ID_PROPERTY,
|
|
817
|
-
|
|
839
|
+
TELEMETRY_SESSION_SOURCE_PROPERTY,
|
|
818
840
|
TELEMETRY_SESSION_ID_ENV,
|
|
819
841
|
TELEMETRY_PARENT_ID_PROPERTY,
|
|
820
842
|
TELEMETRY_OPERATION_ID_PROPERTY,
|
|
@@ -823,4 +845,4 @@ export {
|
|
|
823
845
|
BrowserContextStorage
|
|
824
846
|
};
|
|
825
847
|
|
|
826
|
-
//# debugId=
|
|
848
|
+
//# debugId=F57500BAC82BA8E664756E2164756E21
|
|
@@ -43,18 +43,6 @@ export declare class NodeAppInsightsTelemetryProvider implements ITelemetryProvi
|
|
|
43
43
|
* inside a scope.
|
|
44
44
|
*/
|
|
45
45
|
private consumeCorrelation;
|
|
46
|
-
/**
|
|
47
|
-
* Promote a `session_id` custom dimension onto the native `ai.session.id`
|
|
48
|
-
* context tag and strip it from the dimension bag. Session belongs in the
|
|
49
|
-
* native session tag — the App Insights Sessions blade reads it there — so
|
|
50
|
-
* shipping it as a custom dimension too is redundant and drifts (the raw
|
|
51
|
-
* tag vs. a redactor-hashed dimension). Only the AppInsights provider does
|
|
52
|
-
* this; fallback providers (logger/console) keep `session_id` as a
|
|
53
|
-
* dimension, since they have no native session field.
|
|
54
|
-
*
|
|
55
|
-
* `merged` is a fresh per-call object, so deleting in place is safe.
|
|
56
|
-
*/
|
|
57
|
-
private promoteSessionTag;
|
|
58
46
|
/**
|
|
59
47
|
* Native correlation tags for a LEAF item (event/exception). It has no item
|
|
60
48
|
* id of its own, so it nests under the current operation: `operation_Id` is
|
package/dist/telemetry/node.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { detectAgent, detectAgentVersion } from "./detect-agent.js";
|
|
|
4
4
|
export { buildEnvironmentProperties, type NormalizedEnvironment, normalizeBaseUrl, normalizeEnvironment, } from "./environment-info.js";
|
|
5
5
|
export { type CiProvider, detectExecutionContext, EXECUTION_CONTEXT_VALUES, type ExecutionContext, type ExecutionContextDetection, type ExecutionContextDetectionOptions, getExecutionContextTelemetryProperties, setExecutionContextAuthSignal, } from "./execution-context.js";
|
|
6
6
|
export { NodeContextStorage } from "./node-context-storage.js";
|
|
7
|
-
export { getConfiguredTelemetrySessionId, getTelemetrySessionId,
|
|
7
|
+
export { getConfiguredTelemetrySessionId, getTelemetrySessionId, getTelemetrySessionSource, TELEMETRY_SESSION_ID_ENV, TELEMETRY_SESSION_SOURCE_PROPERTY, } from "./session-id.js";
|
|
8
8
|
export type { ITelemetryProvider } from "./telemetry-provider.js";
|
|
9
9
|
export type { ITelemetryService, TelemetryContext, TelemetryProperties, } from "./telemetry-service.js";
|
|
10
10
|
export { TELEMETRY_OPERATION_ID_PROPERTY, TELEMETRY_PARENT_ID_PROPERTY, TELEMETRY_SPAN_ID_PROPERTY, TelemetryService, } from "./telemetry-service.js";
|
|
@@ -1,15 +1,61 @@
|
|
|
1
1
|
export declare const TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Hard ceiling on the emitted session id. App Insights caps `ai.session.id` at
|
|
4
|
+
* 64 characters and truncates past it silently, so the CLI cuts to the same
|
|
5
|
+
* limit itself rather than shipping a value the backend will quietly reshape.
|
|
6
|
+
*
|
|
7
|
+
* Two handles that share their first 64 characters therefore collapse into one
|
|
8
|
+
* session. Accepted: no observed host exports a handle anywhere near this long
|
|
9
|
+
* (every one of them is a UUID or shorter), and hashing to dodge it would make
|
|
10
|
+
* every id opaque — a host could no longer find its own `UIPATH_SESSION_ID` in
|
|
11
|
+
* the data.
|
|
12
|
+
*/
|
|
13
|
+
export declare const SESSION_ID_MAX_LENGTH = 64;
|
|
14
|
+
/** Width of the minted fallback id when no host handle exists. */
|
|
15
|
+
export declare const RANDOM_SESSION_ID_LENGTH = 32;
|
|
16
|
+
/**
|
|
17
|
+
* Custom dimension naming which handle the session id came from. A `terminal`
|
|
18
|
+
* session is not comparable to a `claude-code` one (see the Session Id section
|
|
19
|
+
* of TELEMETRY_GUIDE.md), and the id alone does not say which it is — the
|
|
20
|
+
* handles pass through as the host exported them, with no source marker. Low
|
|
21
|
+
* cardinality by construction: one of {@link TelemetrySessionSource}.
|
|
22
|
+
*/
|
|
23
|
+
export declare const TELEMETRY_SESSION_SOURCE_PROPERTY = "session_id_source";
|
|
24
|
+
/**
|
|
25
|
+
* Where a session id came from — the value of the
|
|
26
|
+
* {@link TELEMETRY_SESSION_SOURCE_PROPERTY} dimension.
|
|
27
|
+
*
|
|
28
|
+
* - `declared`: the host set `UIPATH_SESSION_ID` on purpose. The only boundary
|
|
29
|
+
* someone chose; everything else is inferred.
|
|
30
|
+
* - `claude-code` / `codex` / `antigravity`: one agent conversation.
|
|
31
|
+
* - `terminal`: a terminal tab or pane, which can stay open for weeks and
|
|
32
|
+
* splits when the user splits a pane.
|
|
33
|
+
* - `random`: no host handle at all, so one CLI process.
|
|
34
|
+
*/
|
|
35
|
+
export type TelemetrySessionSource = "declared" | "claude-code" | "codex" | "antigravity" | "terminal" | "random";
|
|
36
|
+
/**
|
|
37
|
+
* The `UIPATH_SESSION_ID` handle as the host exported it (trimmed, control
|
|
38
|
+
* characters stripped, cut to {@link SESSION_ID_MAX_LENGTH}), or undefined when
|
|
39
|
+
* unset. Same value {@link getTelemetrySessionId} emits when it is set.
|
|
40
|
+
*/
|
|
3
41
|
export declare function getConfiguredTelemetrySessionId(): string | undefined;
|
|
4
42
|
/**
|
|
5
|
-
* Resolve the
|
|
43
|
+
* Resolve the session id for App Insights' native `ai.session.id` tag. Session
|
|
44
|
+
* lives on that tag and nowhere else — no custom dimension mirrors it.
|
|
6
45
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
46
|
+
* The id is the host's handle verbatim, so a host that exports
|
|
47
|
+
* `UIPATH_SESSION_ID` can find its own sessions by that literal value. Which
|
|
48
|
+
* handle produced it rides the {@link TELEMETRY_SESSION_SOURCE_PROPERTY}
|
|
49
|
+
* dimension, since the id itself carries no source marker — the same string
|
|
50
|
+
* exported as `TERM_SESSION_ID` and as `UIPATH_SESSION_ID` is one id on two
|
|
51
|
+
* sources.
|
|
10
52
|
*/
|
|
11
53
|
export declare function getTelemetrySessionId(): string;
|
|
12
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Which handle this process's session id came from — emitted on every telemetry
|
|
56
|
+
* item as {@link TELEMETRY_SESSION_SOURCE_PROPERTY}.
|
|
57
|
+
*/
|
|
58
|
+
export declare function getTelemetrySessionSource(): TelemetrySessionSource;
|
|
13
59
|
/**
|
|
14
60
|
* Resolve the per-invocation operation id used for App Insights' native
|
|
15
61
|
* `operation_Id` tag.
|
|
@@ -24,8 +70,7 @@ export declare function resolveTelemetrySessionId(existingSessionId: unknown): s
|
|
|
24
70
|
* transaction and with the API telemetry it triggers.
|
|
25
71
|
*
|
|
26
72
|
* The value is a 32-hex string (a UUID with dashes stripped). That is the shape
|
|
27
|
-
* App Insights expects for `operation_Id`, and
|
|
28
|
-
*
|
|
29
|
-
* raw on every path.
|
|
73
|
+
* App Insights expects for `operation_Id`, and it is left untouched by the PII
|
|
74
|
+
* redactor, so the emitted value matches raw on every path.
|
|
30
75
|
*/
|
|
31
76
|
export declare function getTelemetryOperationId(): string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/common",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "1.199.0-preview.
|
|
4
|
+
"version": "1.199.0-preview.108",
|
|
5
5
|
"description": "Common infrastructure needed by uip tools.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"mihaigirleanu",
|
|
68
68
|
"vlad-uipath"
|
|
69
69
|
],
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "171f68daab68809916e8df10ea198c259f688ede"
|
|
71
71
|
}
|