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