@uipath/common 1.198.0-preview.95 → 1.198.0
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.js +236 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.js +402 -157
- package/dist/telemetry/index.d.ts +2 -2
- package/dist/telemetry/index.js +118 -9
- package/dist/telemetry/node-appinsights-telemetry-provider.d.ts +45 -2
- package/dist/telemetry/node.d.ts +3 -1
- package/dist/telemetry/pii-redactor.d.ts +16 -0
- package/dist/telemetry/session-id.d.ts +19 -0
- package/dist/telemetry/telemetry-provider.d.ts +7 -1
- package/dist/telemetry/telemetry-service.d.ts +105 -1
- package/dist/telemetry/trace-context.d.ts +49 -0
- package/dist/telemetry/tracked-fetch.d.ts +33 -0
- package/dist/trackedAction.d.ts +15 -0
- package/package.json +2 -2
package/dist/index.browser.js
CHANGED
|
@@ -22809,11 +22809,36 @@ class ConsoleTelemetryProvider {
|
|
|
22809
22809
|
console.debug(`[Telemetry] Dependency: ${name} [${type}] (${duration}ms, ${success ? "ok" : "fail"})`);
|
|
22810
22810
|
}
|
|
22811
22811
|
}
|
|
22812
|
+
// src/telemetry/trace-context.ts
|
|
22813
|
+
var TELEMETRY_TRACEPARENT_ENV = "TRACEPARENT";
|
|
22814
|
+
var TRACEPARENT_PATTERN = /^00-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}$/;
|
|
22815
|
+
function getProcessEnv() {
|
|
22816
|
+
return globalThis.process?.env;
|
|
22817
|
+
}
|
|
22818
|
+
function parseInboundTraceparent(value) {
|
|
22819
|
+
if (!value) {
|
|
22820
|
+
return;
|
|
22821
|
+
}
|
|
22822
|
+
const match = TRACEPARENT_PATTERN.exec(value.trim().toLowerCase());
|
|
22823
|
+
if (!match) {
|
|
22824
|
+
return;
|
|
22825
|
+
}
|
|
22826
|
+
const [, traceId, parentSpanId] = match;
|
|
22827
|
+
if (/^0+$/.test(traceId) || /^0+$/.test(parentSpanId)) {
|
|
22828
|
+
return;
|
|
22829
|
+
}
|
|
22830
|
+
return { traceId, parentSpanId };
|
|
22831
|
+
}
|
|
22832
|
+
function getInboundTraceContext() {
|
|
22833
|
+
return parseInboundTraceparent(getProcessEnv()?.[TELEMETRY_TRACEPARENT_ENV]);
|
|
22834
|
+
}
|
|
22835
|
+
|
|
22812
22836
|
// src/telemetry/session-id.ts
|
|
22813
22837
|
var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
|
|
22814
22838
|
var TELEMETRY_SESSION_ID_PROPERTY = "session_id";
|
|
22815
22839
|
var telemetrySessionIdSlot = singleton("TelemetrySessionId");
|
|
22816
|
-
|
|
22840
|
+
var telemetryOperationIdSlot = singleton("TelemetryOperationId");
|
|
22841
|
+
function getProcessEnv2() {
|
|
22817
22842
|
return globalThis.process?.env;
|
|
22818
22843
|
}
|
|
22819
22844
|
function normalizeSessionId(value) {
|
|
@@ -22824,7 +22849,7 @@ function normalizeSessionId(value) {
|
|
|
22824
22849
|
return trimmed || undefined;
|
|
22825
22850
|
}
|
|
22826
22851
|
function getConfiguredTelemetrySessionId() {
|
|
22827
|
-
return normalizeSessionId(
|
|
22852
|
+
return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
|
|
22828
22853
|
}
|
|
22829
22854
|
function getTelemetrySessionId() {
|
|
22830
22855
|
const envSessionId = getConfiguredTelemetrySessionId();
|
|
@@ -22842,6 +22867,16 @@ function getTelemetrySessionId() {
|
|
|
22842
22867
|
function resolveTelemetrySessionId(existingSessionId) {
|
|
22843
22868
|
return getConfiguredTelemetrySessionId() ?? normalizeSessionId(existingSessionId);
|
|
22844
22869
|
}
|
|
22870
|
+
function getTelemetryOperationId() {
|
|
22871
|
+
const existing = telemetryOperationIdSlot.get();
|
|
22872
|
+
if (existing) {
|
|
22873
|
+
return existing;
|
|
22874
|
+
}
|
|
22875
|
+
const inboundTraceId = getInboundTraceContext()?.traceId;
|
|
22876
|
+
const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
|
|
22877
|
+
telemetryOperationIdSlot.set(generated);
|
|
22878
|
+
return generated;
|
|
22879
|
+
}
|
|
22845
22880
|
// src/telemetry/telemetry-events.ts
|
|
22846
22881
|
var CommonTelemetryEvents = {
|
|
22847
22882
|
Error: "uip.error",
|
|
@@ -22977,7 +23012,144 @@ function getExecutionContextTelemetryProperties() {
|
|
|
22977
23012
|
};
|
|
22978
23013
|
}
|
|
22979
23014
|
|
|
23015
|
+
// src/telemetry/pii-redactor.ts
|
|
23016
|
+
var REDACTED = "[REDACTED]";
|
|
23017
|
+
var MAX_VALUE_LENGTH = 200;
|
|
23018
|
+
var SENSITIVE_NAME_TOKENS = new Set([
|
|
23019
|
+
"token",
|
|
23020
|
+
"tokens",
|
|
23021
|
+
"secret",
|
|
23022
|
+
"secrets",
|
|
23023
|
+
"password",
|
|
23024
|
+
"passwords",
|
|
23025
|
+
"pwd",
|
|
23026
|
+
"credential",
|
|
23027
|
+
"credentials",
|
|
23028
|
+
"auth",
|
|
23029
|
+
"authentication",
|
|
23030
|
+
"authorization",
|
|
23031
|
+
"authority",
|
|
23032
|
+
"cert",
|
|
23033
|
+
"certificate",
|
|
23034
|
+
"certificates"
|
|
23035
|
+
]);
|
|
23036
|
+
var SENSITIVE_KEY_PREFIXES = new Set([
|
|
23037
|
+
"api",
|
|
23038
|
+
"access",
|
|
23039
|
+
"client",
|
|
23040
|
+
"private",
|
|
23041
|
+
"public",
|
|
23042
|
+
"signing",
|
|
23043
|
+
"encryption",
|
|
23044
|
+
"session",
|
|
23045
|
+
"master",
|
|
23046
|
+
"shared",
|
|
23047
|
+
"root",
|
|
23048
|
+
"ssh",
|
|
23049
|
+
"rsa",
|
|
23050
|
+
"aes",
|
|
23051
|
+
"hmac",
|
|
23052
|
+
"oauth"
|
|
23053
|
+
]);
|
|
23054
|
+
var UUID_PATTERN = /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi;
|
|
23055
|
+
var EMAIL_PATTERN = /\b[^\s@]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
|
|
23056
|
+
var JWT_PATTERN = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
|
|
23057
|
+
var LONG_TOKEN_PATTERN = /\b[A-Za-z0-9_-]{40,}\b/g;
|
|
23058
|
+
var USER_HOME_PATTERN = /([/\\])(Users|home)([/\\])([^/\\]+)/gi;
|
|
23059
|
+
var URL_PATTERN = /\bhttps?:\/\/[^\s,;]+/gi;
|
|
23060
|
+
var URL_TRAILING_PUNCT = /[.,;:!?)\]}>'"]+$/;
|
|
23061
|
+
function shortHash(input) {
|
|
23062
|
+
let hash = 2166136261;
|
|
23063
|
+
for (let i2 = 0;i2 < input.length; i2++) {
|
|
23064
|
+
hash ^= input.charCodeAt(i2);
|
|
23065
|
+
hash = Math.imul(hash, 16777619);
|
|
23066
|
+
}
|
|
23067
|
+
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
23068
|
+
}
|
|
23069
|
+
function redactUrl(raw) {
|
|
23070
|
+
try {
|
|
23071
|
+
const url = new URL(raw);
|
|
23072
|
+
return `${url.protocol}//${url.host}`;
|
|
23073
|
+
} catch {
|
|
23074
|
+
return `url#${shortHash(raw)}`;
|
|
23075
|
+
}
|
|
23076
|
+
}
|
|
23077
|
+
function redactValueDetectors(value) {
|
|
23078
|
+
let out = value;
|
|
23079
|
+
out = out.replace(JWT_PATTERN, () => REDACTED);
|
|
23080
|
+
out = out.replace(URL_PATTERN, (match) => {
|
|
23081
|
+
const trailing = match.match(URL_TRAILING_PUNCT)?.[0] ?? "";
|
|
23082
|
+
const core = trailing ? match.slice(0, -trailing.length) : match;
|
|
23083
|
+
return `${redactUrl(core)}${trailing}`;
|
|
23084
|
+
});
|
|
23085
|
+
out = out.replace(USER_HOME_PATTERN, (_match, sep1, folder, sep2) => `${sep1}${folder}${sep2}<user>`);
|
|
23086
|
+
out = out.replace(EMAIL_PATTERN, (match) => `email#${shortHash(match)}`);
|
|
23087
|
+
out = out.replace(UUID_PATTERN, (match) => `uuid#${shortHash(match)}`);
|
|
23088
|
+
out = out.replace(LONG_TOKEN_PATTERN, () => REDACTED);
|
|
23089
|
+
if (out.length > MAX_VALUE_LENGTH) {
|
|
23090
|
+
out = `${out.slice(0, MAX_VALUE_LENGTH)}…`;
|
|
23091
|
+
}
|
|
23092
|
+
return out;
|
|
23093
|
+
}
|
|
23094
|
+
function redactValue(value) {
|
|
23095
|
+
return redactValueDetectors(value);
|
|
23096
|
+
}
|
|
23097
|
+
function redactError(error) {
|
|
23098
|
+
const safe = new Error(redactValueDetectors(error.message ?? ""));
|
|
23099
|
+
safe.name = error.name;
|
|
23100
|
+
safe.stack = typeof error.stack === "string" ? redactValueDetectors(error.stack) : undefined;
|
|
23101
|
+
return safe;
|
|
23102
|
+
}
|
|
23103
|
+
function nameTokens(name) {
|
|
23104
|
+
return name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").split(/[\s._-]+/).map((t) => t.toLowerCase()).filter(Boolean);
|
|
23105
|
+
}
|
|
23106
|
+
function isSensitiveName(name) {
|
|
23107
|
+
const tokens = nameTokens(name);
|
|
23108
|
+
for (let i2 = 0;i2 < tokens.length; i2++) {
|
|
23109
|
+
const token = tokens[i2];
|
|
23110
|
+
if (SENSITIVE_NAME_TOKENS.has(token)) {
|
|
23111
|
+
return true;
|
|
23112
|
+
}
|
|
23113
|
+
if (token === "key" || token === "keys") {
|
|
23114
|
+
const prev = tokens[i2 - 1];
|
|
23115
|
+
if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
|
|
23116
|
+
return true;
|
|
23117
|
+
}
|
|
23118
|
+
}
|
|
23119
|
+
}
|
|
23120
|
+
return false;
|
|
23121
|
+
}
|
|
23122
|
+
function redactProperty(name, value) {
|
|
23123
|
+
if (value === undefined || value === null) {
|
|
23124
|
+
return;
|
|
23125
|
+
}
|
|
23126
|
+
if (isSensitiveName(name)) {
|
|
23127
|
+
return REDACTED;
|
|
23128
|
+
}
|
|
23129
|
+
if (typeof value === "boolean" || typeof value === "number") {
|
|
23130
|
+
return value;
|
|
23131
|
+
}
|
|
23132
|
+
if (typeof value !== "string") {
|
|
23133
|
+
return "[OBJECT]";
|
|
23134
|
+
}
|
|
23135
|
+
return redactValueDetectors(value);
|
|
23136
|
+
}
|
|
23137
|
+
function redactProperties(properties) {
|
|
23138
|
+
const out = {};
|
|
23139
|
+
for (const [name, value] of Object.entries(properties)) {
|
|
23140
|
+
const redacted = redactProperty(name, value);
|
|
23141
|
+
if (redacted !== undefined) {
|
|
23142
|
+
out[name] = redacted;
|
|
23143
|
+
}
|
|
23144
|
+
}
|
|
23145
|
+
return out;
|
|
23146
|
+
}
|
|
23147
|
+
|
|
22980
23148
|
// src/telemetry/telemetry-service.ts
|
|
23149
|
+
var TELEMETRY_OPERATION_ID_PROPERTY = "uip.trace.operation_id";
|
|
23150
|
+
var TELEMETRY_PARENT_ID_PROPERTY = "uip.trace.parent_id";
|
|
23151
|
+
var TELEMETRY_SPAN_ID_PROPERTY = "uip.trace.span_id";
|
|
23152
|
+
|
|
22981
23153
|
class TelemetryService {
|
|
22982
23154
|
telemetryProvider;
|
|
22983
23155
|
contextStorage;
|
|
@@ -23004,11 +23176,15 @@ class TelemetryService {
|
|
|
23004
23176
|
trackException(error, properties) {
|
|
23005
23177
|
const context = this.getCurrentContext();
|
|
23006
23178
|
const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
|
|
23007
|
-
this.telemetryProvider.trackException(error, enrichedProperties);
|
|
23179
|
+
this.telemetryProvider.trackException(redactError(error), enrichedProperties);
|
|
23008
23180
|
}
|
|
23009
23181
|
async trackRequest(name, fn, properties) {
|
|
23182
|
+
const parentContext = this.getCurrentContext();
|
|
23183
|
+
const operationId = parentContext?.operationId ?? this.operationId ?? getTelemetryOperationId();
|
|
23184
|
+
const parentId = parentContext ? parentContext.id : this.inboundParentIdFor(operationId);
|
|
23010
23185
|
const context = {
|
|
23011
|
-
operationId
|
|
23186
|
+
operationId,
|
|
23187
|
+
...parentId !== undefined ? { parentId } : {},
|
|
23012
23188
|
id: this.generateId()
|
|
23013
23189
|
};
|
|
23014
23190
|
const startTime = performance.now();
|
|
@@ -23026,6 +23202,45 @@ class TelemetryService {
|
|
|
23026
23202
|
throw error;
|
|
23027
23203
|
}
|
|
23028
23204
|
}
|
|
23205
|
+
trackRequestResult(name, durationMs, success, properties, context) {
|
|
23206
|
+
const requestContext = context ?? {
|
|
23207
|
+
operationId: this.operationId ?? getTelemetryOperationId(),
|
|
23208
|
+
id: this.generateId()
|
|
23209
|
+
};
|
|
23210
|
+
const enrichedProperties = this.enrichPropertiesWithContext(properties, requestContext);
|
|
23211
|
+
this.telemetryProvider.trackRequest(name, durationMs, success, enrichedProperties);
|
|
23212
|
+
}
|
|
23213
|
+
createRequestContext() {
|
|
23214
|
+
const operationId = this.operationId ?? getTelemetryOperationId();
|
|
23215
|
+
const parentId = this.inboundParentIdFor(operationId);
|
|
23216
|
+
return {
|
|
23217
|
+
operationId,
|
|
23218
|
+
...parentId !== undefined ? { parentId } : {},
|
|
23219
|
+
id: this.generateId()
|
|
23220
|
+
};
|
|
23221
|
+
}
|
|
23222
|
+
inboundParentIdFor(operationId) {
|
|
23223
|
+
const inbound = getInboundTraceContext();
|
|
23224
|
+
return inbound && inbound.traceId === operationId ? inbound.parentSpanId : undefined;
|
|
23225
|
+
}
|
|
23226
|
+
runWithContext(context, fn) {
|
|
23227
|
+
return this.contextStorage.run(context, fn);
|
|
23228
|
+
}
|
|
23229
|
+
createDependencyContext() {
|
|
23230
|
+
const parentContext = this.getCurrentContext();
|
|
23231
|
+
if (!parentContext) {
|
|
23232
|
+
return;
|
|
23233
|
+
}
|
|
23234
|
+
return {
|
|
23235
|
+
operationId: parentContext.operationId,
|
|
23236
|
+
parentId: parentContext.id,
|
|
23237
|
+
id: this.generateId()
|
|
23238
|
+
};
|
|
23239
|
+
}
|
|
23240
|
+
trackDependencyResult(name, type, durationMs, success, properties, context, resultCode) {
|
|
23241
|
+
const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
|
|
23242
|
+
this.telemetryProvider.trackDependency(redactValue(name), type, durationMs, success, enrichedProperties, resultCode);
|
|
23243
|
+
}
|
|
23029
23244
|
async trackDependencyOperation(name, type, fn, properties) {
|
|
23030
23245
|
const parentContext = this.getCurrentContext();
|
|
23031
23246
|
if (!parentContext) {
|
|
@@ -23062,8 +23277,12 @@ class TelemetryService {
|
|
|
23062
23277
|
...getExecutionContextTelemetryProperties(),
|
|
23063
23278
|
...globalProperties,
|
|
23064
23279
|
...this.defaultProperties,
|
|
23065
|
-
...properties,
|
|
23066
|
-
...context
|
|
23280
|
+
...redactProperties(properties ?? {}),
|
|
23281
|
+
...context ? {
|
|
23282
|
+
[TELEMETRY_OPERATION_ID_PROPERTY]: context.operationId,
|
|
23283
|
+
...context.parentId !== undefined ? { [TELEMETRY_PARENT_ID_PROPERTY]: context.parentId } : {},
|
|
23284
|
+
[TELEMETRY_SPAN_ID_PROPERTY]: context.id
|
|
23285
|
+
} : {}
|
|
23067
23286
|
};
|
|
23068
23287
|
if (sessionId === undefined) {
|
|
23069
23288
|
delete enriched[TELEMETRY_SESSION_ID_PROPERTY];
|
|
@@ -23073,7 +23292,16 @@ class TelemetryService {
|
|
|
23073
23292
|
return enriched;
|
|
23074
23293
|
}
|
|
23075
23294
|
generateId() {
|
|
23076
|
-
|
|
23295
|
+
const bytes = new Uint8Array(8);
|
|
23296
|
+
let hex = "";
|
|
23297
|
+
do {
|
|
23298
|
+
crypto.getRandomValues(bytes);
|
|
23299
|
+
hex = "";
|
|
23300
|
+
for (const byte of bytes) {
|
|
23301
|
+
hex += byte.toString(16).padStart(2, "0");
|
|
23302
|
+
}
|
|
23303
|
+
} while (/^0+$/.test(hex));
|
|
23304
|
+
return hex;
|
|
23077
23305
|
}
|
|
23078
23306
|
}
|
|
23079
23307
|
// src/tool-provider.ts
|
|
@@ -23186,4 +23414,4 @@ export {
|
|
|
23186
23414
|
AUTH_FILENAME
|
|
23187
23415
|
};
|
|
23188
23416
|
|
|
23189
|
-
//# debugId=
|
|
23417
|
+
//# debugId=A8F9E8E6B48366FF64756E2164756E21
|
package/dist/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export * from "./telemetry/command-terminal.js";
|
|
|
35
35
|
export { ConsoleTelemetryProvider } from "./telemetry/console-telemetry-provider.js";
|
|
36
36
|
export * from "./telemetry/node.js";
|
|
37
37
|
export { setGlobalTelemetryProperties } from "./telemetry/node-appinsights-telemetry-provider.js";
|
|
38
|
-
export { redactProperties, redactProperty } from "./telemetry/pii-redactor.js";
|
|
38
|
+
export { redactError, redactProperties, redactProperty, redactValue, } from "./telemetry/pii-redactor.js";
|
|
39
39
|
export { type ShipSucceededTelemetryPayload, trackShipSucceeded, } from "./telemetry/ship-succeeded.js";
|
|
40
40
|
export * from "./telemetry/telemetry-events.js";
|
|
41
41
|
export * from "./telemetry/telemetry-init.js";
|