@uipath/uipath-typescript 1.3.8 → 1.3.9

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.
Files changed (39) hide show
  1. package/dist/assets/index.cjs +25 -270
  2. package/dist/assets/index.mjs +25 -270
  3. package/dist/attachments/index.cjs +23 -267
  4. package/dist/attachments/index.mjs +23 -267
  5. package/dist/buckets/index.cjs +54 -270
  6. package/dist/buckets/index.d.ts +50 -1
  7. package/dist/buckets/index.mjs +54 -270
  8. package/dist/cases/index.cjs +408 -337
  9. package/dist/cases/index.d.ts +534 -2
  10. package/dist/cases/index.mjs +409 -338
  11. package/dist/conversational-agent/index.cjs +71 -281
  12. package/dist/conversational-agent/index.d.ts +62 -12
  13. package/dist/conversational-agent/index.mjs +71 -282
  14. package/dist/core/index.cjs +39 -289
  15. package/dist/core/index.d.ts +9 -98
  16. package/dist/core/index.mjs +40 -275
  17. package/dist/document-understanding/index.cjs +18 -1
  18. package/dist/document-understanding/index.d.ts +636 -610
  19. package/dist/document-understanding/index.mjs +18 -1
  20. package/dist/entities/index.cjs +25 -270
  21. package/dist/entities/index.mjs +25 -270
  22. package/dist/feedback/index.cjs +23 -268
  23. package/dist/feedback/index.mjs +23 -268
  24. package/dist/index.cjs +600 -293
  25. package/dist/index.d.ts +1603 -722
  26. package/dist/index.mjs +600 -279
  27. package/dist/index.umd.js +789 -158
  28. package/dist/jobs/index.cjs +25 -270
  29. package/dist/jobs/index.mjs +25 -270
  30. package/dist/maestro-processes/index.cjs +1751 -1720
  31. package/dist/maestro-processes/index.d.ts +430 -2
  32. package/dist/maestro-processes/index.mjs +1752 -1721
  33. package/dist/processes/index.cjs +25 -270
  34. package/dist/processes/index.mjs +25 -270
  35. package/dist/queues/index.cjs +25 -270
  36. package/dist/queues/index.mjs +25 -270
  37. package/dist/tasks/index.cjs +25 -270
  38. package/dist/tasks/index.mjs +25 -270
  39. package/package.json +8 -10
@@ -112,8 +112,8 @@ var WordGroupType;
112
112
  // Auto-generated from the OpenAPI spec — do not edit manually.
113
113
  var ModelKind;
114
114
  (function (ModelKind) {
115
- ModelKind["Classifier"] = "Classifier";
116
115
  ModelKind["Extractor"] = "Extractor";
116
+ ModelKind["Classifier"] = "Classifier";
117
117
  })(ModelKind || (ModelKind = {}));
118
118
  var ModelType;
119
119
  (function (ModelType) {
@@ -122,6 +122,14 @@ var ModelType;
122
122
  ModelType["Predefined"] = "Predefined";
123
123
  })(ModelType || (ModelType = {}));
124
124
 
125
+ // Auto-generated from the OpenAPI spec — do not edit manually.
126
+ var ErrorSeverity;
127
+ (function (ErrorSeverity) {
128
+ ErrorSeverity["Info"] = "Info";
129
+ ErrorSeverity["Warning"] = "Warning";
130
+ ErrorSeverity["Error"] = "Error";
131
+ })(ErrorSeverity || (ErrorSeverity = {}));
132
+
125
133
  // Auto-generated from the OpenAPI spec — do not edit manually.
126
134
  var ClassifierDocumentTypeType;
127
135
  (function (ClassifierDocumentTypeType) {
@@ -146,6 +154,13 @@ var GptFieldType;
146
154
  GptFieldType["Number"] = "Number";
147
155
  GptFieldType["Text"] = "Text";
148
156
  })(GptFieldType || (GptFieldType = {}));
157
+ var JobStatus;
158
+ (function (JobStatus) {
159
+ JobStatus["Succeeded"] = "Succeeded";
160
+ JobStatus["Failed"] = "Failed";
161
+ JobStatus["Running"] = "Running";
162
+ JobStatus["NotStarted"] = "NotStarted";
163
+ })(JobStatus || (JobStatus = {}));
149
164
  var ValidationDisplayMode;
150
165
  (function (ValidationDisplayMode) {
151
166
  ValidationDisplayMode["Classic"] = "Classic";
@@ -232,8 +247,10 @@ var index = /*#__PURE__*/Object.freeze({
232
247
  get DocumentActionPriority () { return DocumentActionPriority; },
233
248
  get DocumentActionStatus () { return DocumentActionStatus; },
234
249
  get DocumentActionType () { return DocumentActionType; },
250
+ get ErrorSeverity () { return ErrorSeverity; },
235
251
  get FieldType () { return FieldType; },
236
252
  get GptFieldType () { return GptFieldType; },
253
+ get JobStatus () { return JobStatus; },
237
254
  get LogicalOperator () { return LogicalOperator; },
238
255
  get MarkupType () { return MarkupType; },
239
256
  get ModelKind () { return ModelKind; },
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var sdkLogs = require('@opentelemetry/sdk-logs');
3
+ var coreTelemetry = require('@uipath/core-telemetry');
4
4
 
5
5
  /******************************************************************************
6
6
  Copyright (c) Microsoft Corporation.
@@ -2135,278 +2135,33 @@ const EntityFieldTypeMap = {
2135
2135
  };
2136
2136
 
2137
2137
  /**
2138
- * SDK Telemetry constants
2139
- */
2140
- // Connection string placeholder that will be replaced during build
2141
- const CONNECTION_STRING = "InstrumentationKey=a6efa11d-1feb-4508-9738-e13e12dcae5e;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/;ApplicationId=7c58eb1c-9581-4ba6-839e-11725848a037";
2142
- // SDK Version placeholder
2143
- const SDK_VERSION = "1.3.8";
2144
- const VERSION = "Version";
2145
- const SERVICE = "Service";
2146
- const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
2147
- const CLOUD_TENANT_NAME = "CloudTenantName";
2148
- const CLOUD_URL = "CloudUrl";
2149
- const CLOUD_CLIENT_ID = "CloudClientId";
2150
- const CLOUD_REDIRECT_URI = "CloudRedirectUri";
2151
- const APP_NAME = "ApplicationName";
2152
- const CLOUD_ROLE_NAME = "uipath-ts-sdk";
2153
- // Service and logger names
2154
- const SDK_SERVICE_NAME = "UiPath.TypeScript.Sdk";
2155
- const SDK_LOGGER_NAME = "uipath-ts-sdk-telemetry";
2156
- // Event names
2157
- const SDK_RUN_EVENT = "Sdk.Run";
2158
- // Default value for unknown/empty attributes
2159
- const UNKNOWN = "";
2160
-
2161
- /**
2162
- * Log exporter that sends ALL logs as Application Insights custom events
2163
- */
2164
- class ApplicationInsightsEventExporter {
2165
- constructor(connectionString) {
2166
- this.connectionString = connectionString;
2167
- }
2168
- export(logs, resultCallback) {
2169
- try {
2170
- logs.forEach(logRecord => {
2171
- this.sendAsCustomEvent(logRecord);
2172
- });
2173
- resultCallback({ code: 0 });
2174
- }
2175
- catch (error) {
2176
- console.debug('Failed to export logs to Application Insights:', error);
2177
- resultCallback({ code: 2, error });
2178
- }
2179
- }
2180
- shutdown() {
2181
- return Promise.resolve();
2182
- }
2183
- sendAsCustomEvent(logRecord) {
2184
- // Get event name from body or attributes
2185
- const eventName = logRecord.body || SDK_RUN_EVENT;
2186
- const payload = {
2187
- name: 'Microsoft.ApplicationInsights.Event',
2188
- time: new Date().toISOString(),
2189
- iKey: this.extractInstrumentationKey(),
2190
- data: {
2191
- baseType: 'EventData',
2192
- baseData: {
2193
- ver: 2,
2194
- name: eventName,
2195
- properties: this.convertAttributesToProperties(logRecord.attributes || {})
2196
- }
2197
- },
2198
- tags: {
2199
- 'ai.cloud.role': CLOUD_ROLE_NAME,
2200
- 'ai.cloud.roleInstance': SDK_VERSION
2201
- }
2202
- };
2203
- this.sendToApplicationInsights(payload);
2204
- }
2205
- extractInstrumentationKey() {
2206
- const match = this.connectionString.match(/InstrumentationKey=([^;]+)/);
2207
- return match ? match[1] : '';
2208
- }
2209
- convertAttributesToProperties(attributes) {
2210
- const properties = {};
2211
- Object.entries(attributes || {}).forEach(([key, value]) => {
2212
- properties[key] = String(value);
2213
- });
2214
- return properties;
2215
- }
2216
- async sendToApplicationInsights(payload) {
2217
- try {
2218
- const ingestionEndpoint = this.extractIngestionEndpoint();
2219
- if (!ingestionEndpoint) {
2220
- console.debug('No ingestion endpoint found in connection string');
2221
- return;
2222
- }
2223
- const url = `${ingestionEndpoint}/v2/track`;
2224
- const response = await fetch(url, {
2225
- method: 'POST',
2226
- headers: {
2227
- 'Content-Type': 'application/json',
2228
- },
2229
- body: JSON.stringify(payload)
2230
- });
2231
- if (!response.ok) {
2232
- console.debug(`Failed to send event telemetry: ${response.status} ${response.statusText}`);
2233
- }
2234
- }
2235
- catch (error) {
2236
- console.debug('Error sending event telemetry to Application Insights:', error);
2237
- }
2238
- }
2239
- extractIngestionEndpoint() {
2240
- const match = this.connectionString.match(/IngestionEndpoint=([^;]+)/);
2241
- return match ? match[1] : '';
2242
- }
2243
- }
2244
- /**
2245
- * Singleton telemetry client
2246
- */
2247
- class TelemetryClient {
2248
- constructor() {
2249
- this.isInitialized = false;
2250
- }
2251
- static getInstance() {
2252
- if (!TelemetryClient.instance) {
2253
- TelemetryClient.instance = new TelemetryClient();
2254
- }
2255
- return TelemetryClient.instance;
2256
- }
2257
- /**
2258
- * Initialize telemetry
2259
- */
2260
- initialize(config) {
2261
- if (this.isInitialized) {
2262
- return;
2263
- }
2264
- this.isInitialized = true;
2265
- if (config) {
2266
- this.telemetryContext = config;
2267
- }
2268
- try {
2269
- const connectionString = this.getConnectionString();
2270
- if (!connectionString) {
2271
- return;
2272
- }
2273
- this.setupTelemetryProvider(connectionString);
2274
- }
2275
- catch (error) {
2276
- // Silent failure - telemetry errors shouldn't break functionality
2277
- console.debug('Failed to initialize OpenTelemetry:', error);
2278
- }
2279
- }
2280
- getConnectionString() {
2281
- const connectionString = CONNECTION_STRING;
2282
- return connectionString;
2283
- }
2284
- setupTelemetryProvider(connectionString) {
2285
- const exporter = new ApplicationInsightsEventExporter(connectionString);
2286
- const processor = new sdkLogs.BatchLogRecordProcessor(exporter);
2287
- this.logProvider = new sdkLogs.LoggerProvider({
2288
- processors: [processor]
2289
- });
2290
- this.logger = this.logProvider.getLogger(SDK_LOGGER_NAME);
2291
- }
2292
- /**
2293
- * Track a telemetry event
2294
- */
2295
- track(eventName, name, extraAttributes = {}) {
2296
- try {
2297
- // Skip if logger not initialized
2298
- if (!this.logger) {
2299
- return;
2300
- }
2301
- const finalDisplayName = name || eventName;
2302
- const attributes = this.getEnrichedAttributes(extraAttributes, eventName);
2303
- // Emit as log
2304
- this.logger.emit({
2305
- body: finalDisplayName,
2306
- attributes: attributes,
2307
- timestamp: Date.now(),
2308
- });
2309
- }
2310
- catch (error) {
2311
- // Silent failure
2312
- console.debug('Failed to track telemetry event:', error);
2313
- }
2314
- }
2315
- /**
2316
- * Get enriched attributes for telemetry events
2317
- */
2318
- getEnrichedAttributes(extraAttributes, eventName) {
2319
- const attributes = {
2320
- [APP_NAME]: SDK_SERVICE_NAME,
2321
- [VERSION]: SDK_VERSION,
2322
- [SERVICE]: eventName,
2323
- [CLOUD_URL]: this.createCloudUrl(),
2324
- [CLOUD_ORGANIZATION_NAME]: this.telemetryContext?.orgName || UNKNOWN,
2325
- [CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN,
2326
- [CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN,
2327
- [CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN,
2328
- ...extraAttributes,
2329
- };
2330
- return attributes;
2331
- }
2332
- /**
2333
- * Create cloud URL from base URL, organization ID, and tenant ID
2334
- */
2335
- createCloudUrl() {
2336
- const baseUrl = this.telemetryContext?.baseUrl;
2337
- const orgId = this.telemetryContext?.orgName;
2338
- const tenantId = this.telemetryContext?.tenantName;
2339
- if (!baseUrl || !orgId || !tenantId) {
2340
- return UNKNOWN;
2341
- }
2342
- return `${baseUrl}/${orgId}/${tenantId}`;
2343
- }
2344
- }
2345
- // Export singleton instance
2346
- const telemetryClient = TelemetryClient.getInstance();
2138
+ * SDK Telemetry constants.
2139
+ *
2140
+ * Only the SDK's identity (version, service name, role name, …) lives
2141
+ * here. The Application Insights connection string is injected into
2142
+ * `@uipath/core-telemetry` itself at publish time, and the generic attribute
2143
+ * keys (`Version`, `Service`, `CloudOrganizationName`, …) are owned by
2144
+ * `@uipath/core-telemetry` and consumed there — they are not part of the
2145
+ * SDK's public API.
2146
+ */
2147
+ /** SDK version placeholder — patched by the SDK publish workflow. */
2148
+ const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
2347
2149
 
2348
2150
  /**
2349
- * SDK Track decorator and function for telemetry
2350
- */
2351
- /**
2352
- * Common tracking logic shared between method and function decorators
2353
- */
2354
- function createTrackedFunction(originalFunction, nameOrOptions, fallbackName, opts) {
2355
- return function (...args) {
2356
- // Determine if we should track this call
2357
- let shouldTrack = true;
2358
- if (opts.condition !== undefined) {
2359
- if (typeof opts.condition === 'function') {
2360
- shouldTrack = opts.condition.apply(this, args);
2361
- }
2362
- else {
2363
- shouldTrack = opts.condition;
2364
- }
2365
- }
2366
- // Track the event if enabled
2367
- if (shouldTrack) {
2368
- // Use the full name provided in the decorator (e.g., "Queue.GetAll")
2369
- const serviceMethod = typeof nameOrOptions === 'string'
2370
- ? nameOrOptions
2371
- : fallbackName;
2372
- // Use 'Sdk.Run' as the name and serviceMethod as the service
2373
- telemetryClient.track(serviceMethod, SDK_RUN_EVENT, opts.attributes);
2374
- }
2375
- // Execute the original function
2376
- return originalFunction.apply(this, args);
2377
- };
2378
- }
2379
- /**
2380
- * Track decorator that can be used to automatically track function calls
2381
- *
2382
- * Usage:
2383
- * @track("Service.Method")
2384
- * function myFunction() { ... }
2151
+ * UiPath TypeScript SDK Telemetry
2385
2152
  *
2386
- * @track("Queue.GetAll")
2387
- * async getAll() { ... }
2388
- *
2389
- * @track("Tasks.Create")
2390
- * async create() { ... }
2391
- *
2392
- * @track("Assets.Update", { condition: false })
2393
- * function myFunction() { ... }
2394
- *
2395
- * @track("Processes.Start", { attributes: { customProp: "value" } })
2396
- * function myFunction() { ... }
2397
- */
2398
- function track(nameOrOptions, options) {
2399
- return function decorator(_target, propertyKey, descriptor) {
2400
- const opts = typeof nameOrOptions === 'object' ? nameOrOptions : {};
2401
- if (descriptor && typeof descriptor.value === 'function') {
2402
- // Method decorator
2403
- descriptor.value = createTrackedFunction(descriptor.value, nameOrOptions, propertyKey || 'unknown_method', opts);
2404
- return descriptor;
2405
- }
2406
- // Function decorator
2407
- return (originalFunction) => createTrackedFunction(originalFunction, nameOrOptions, originalFunction.name || 'unknown_function', opts);
2408
- };
2409
- }
2153
+ * Constructs the SDK's own `TelemetryClient` and binds the SDK-local
2154
+ * `track` / `trackEvent` to it. Each consumer of `@uipath/core-telemetry`
2155
+ * does this independently, so events carry their own consumer's identity
2156
+ * and tenant context.
2157
+ */
2158
+ // Keyed by `CLOUD_ROLE_NAME` so every SDK subpath bundle resolves to the
2159
+ // same `TelemetryClient` instance at runtime. A single `initialize(...)`
2160
+ // from the `UiPath` constructor therefore wires up `@track` decorators
2161
+ // across every subpath bundle (`assets`, `feedback`, `tasks`, …).
2162
+ const sdkClient = coreTelemetry.getOrCreateClient(CLOUD_ROLE_NAME);
2163
+ const track = coreTelemetry.createTrack(sdkClient);
2164
+ coreTelemetry.createTrackEvent(sdkClient);
2410
2165
 
2411
2166
  /**
2412
2167
  * Service for interacting with the Data Fabric Entity API
@@ -1,4 +1,4 @@
1
- import { BatchLogRecordProcessor, LoggerProvider } from '@opentelemetry/sdk-logs';
1
+ import { getOrCreateClient, createTrack, createTrackEvent } from '@uipath/core-telemetry';
2
2
 
3
3
  /******************************************************************************
4
4
  Copyright (c) Microsoft Corporation.
@@ -2133,278 +2133,33 @@ const EntityFieldTypeMap = {
2133
2133
  };
2134
2134
 
2135
2135
  /**
2136
- * SDK Telemetry constants
2137
- */
2138
- // Connection string placeholder that will be replaced during build
2139
- const CONNECTION_STRING = "InstrumentationKey=a6efa11d-1feb-4508-9738-e13e12dcae5e;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/;ApplicationId=7c58eb1c-9581-4ba6-839e-11725848a037";
2140
- // SDK Version placeholder
2141
- const SDK_VERSION = "1.3.8";
2142
- const VERSION = "Version";
2143
- const SERVICE = "Service";
2144
- const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
2145
- const CLOUD_TENANT_NAME = "CloudTenantName";
2146
- const CLOUD_URL = "CloudUrl";
2147
- const CLOUD_CLIENT_ID = "CloudClientId";
2148
- const CLOUD_REDIRECT_URI = "CloudRedirectUri";
2149
- const APP_NAME = "ApplicationName";
2150
- const CLOUD_ROLE_NAME = "uipath-ts-sdk";
2151
- // Service and logger names
2152
- const SDK_SERVICE_NAME = "UiPath.TypeScript.Sdk";
2153
- const SDK_LOGGER_NAME = "uipath-ts-sdk-telemetry";
2154
- // Event names
2155
- const SDK_RUN_EVENT = "Sdk.Run";
2156
- // Default value for unknown/empty attributes
2157
- const UNKNOWN = "";
2158
-
2159
- /**
2160
- * Log exporter that sends ALL logs as Application Insights custom events
2161
- */
2162
- class ApplicationInsightsEventExporter {
2163
- constructor(connectionString) {
2164
- this.connectionString = connectionString;
2165
- }
2166
- export(logs, resultCallback) {
2167
- try {
2168
- logs.forEach(logRecord => {
2169
- this.sendAsCustomEvent(logRecord);
2170
- });
2171
- resultCallback({ code: 0 });
2172
- }
2173
- catch (error) {
2174
- console.debug('Failed to export logs to Application Insights:', error);
2175
- resultCallback({ code: 2, error });
2176
- }
2177
- }
2178
- shutdown() {
2179
- return Promise.resolve();
2180
- }
2181
- sendAsCustomEvent(logRecord) {
2182
- // Get event name from body or attributes
2183
- const eventName = logRecord.body || SDK_RUN_EVENT;
2184
- const payload = {
2185
- name: 'Microsoft.ApplicationInsights.Event',
2186
- time: new Date().toISOString(),
2187
- iKey: this.extractInstrumentationKey(),
2188
- data: {
2189
- baseType: 'EventData',
2190
- baseData: {
2191
- ver: 2,
2192
- name: eventName,
2193
- properties: this.convertAttributesToProperties(logRecord.attributes || {})
2194
- }
2195
- },
2196
- tags: {
2197
- 'ai.cloud.role': CLOUD_ROLE_NAME,
2198
- 'ai.cloud.roleInstance': SDK_VERSION
2199
- }
2200
- };
2201
- this.sendToApplicationInsights(payload);
2202
- }
2203
- extractInstrumentationKey() {
2204
- const match = this.connectionString.match(/InstrumentationKey=([^;]+)/);
2205
- return match ? match[1] : '';
2206
- }
2207
- convertAttributesToProperties(attributes) {
2208
- const properties = {};
2209
- Object.entries(attributes || {}).forEach(([key, value]) => {
2210
- properties[key] = String(value);
2211
- });
2212
- return properties;
2213
- }
2214
- async sendToApplicationInsights(payload) {
2215
- try {
2216
- const ingestionEndpoint = this.extractIngestionEndpoint();
2217
- if (!ingestionEndpoint) {
2218
- console.debug('No ingestion endpoint found in connection string');
2219
- return;
2220
- }
2221
- const url = `${ingestionEndpoint}/v2/track`;
2222
- const response = await fetch(url, {
2223
- method: 'POST',
2224
- headers: {
2225
- 'Content-Type': 'application/json',
2226
- },
2227
- body: JSON.stringify(payload)
2228
- });
2229
- if (!response.ok) {
2230
- console.debug(`Failed to send event telemetry: ${response.status} ${response.statusText}`);
2231
- }
2232
- }
2233
- catch (error) {
2234
- console.debug('Error sending event telemetry to Application Insights:', error);
2235
- }
2236
- }
2237
- extractIngestionEndpoint() {
2238
- const match = this.connectionString.match(/IngestionEndpoint=([^;]+)/);
2239
- return match ? match[1] : '';
2240
- }
2241
- }
2242
- /**
2243
- * Singleton telemetry client
2244
- */
2245
- class TelemetryClient {
2246
- constructor() {
2247
- this.isInitialized = false;
2248
- }
2249
- static getInstance() {
2250
- if (!TelemetryClient.instance) {
2251
- TelemetryClient.instance = new TelemetryClient();
2252
- }
2253
- return TelemetryClient.instance;
2254
- }
2255
- /**
2256
- * Initialize telemetry
2257
- */
2258
- initialize(config) {
2259
- if (this.isInitialized) {
2260
- return;
2261
- }
2262
- this.isInitialized = true;
2263
- if (config) {
2264
- this.telemetryContext = config;
2265
- }
2266
- try {
2267
- const connectionString = this.getConnectionString();
2268
- if (!connectionString) {
2269
- return;
2270
- }
2271
- this.setupTelemetryProvider(connectionString);
2272
- }
2273
- catch (error) {
2274
- // Silent failure - telemetry errors shouldn't break functionality
2275
- console.debug('Failed to initialize OpenTelemetry:', error);
2276
- }
2277
- }
2278
- getConnectionString() {
2279
- const connectionString = CONNECTION_STRING;
2280
- return connectionString;
2281
- }
2282
- setupTelemetryProvider(connectionString) {
2283
- const exporter = new ApplicationInsightsEventExporter(connectionString);
2284
- const processor = new BatchLogRecordProcessor(exporter);
2285
- this.logProvider = new LoggerProvider({
2286
- processors: [processor]
2287
- });
2288
- this.logger = this.logProvider.getLogger(SDK_LOGGER_NAME);
2289
- }
2290
- /**
2291
- * Track a telemetry event
2292
- */
2293
- track(eventName, name, extraAttributes = {}) {
2294
- try {
2295
- // Skip if logger not initialized
2296
- if (!this.logger) {
2297
- return;
2298
- }
2299
- const finalDisplayName = name || eventName;
2300
- const attributes = this.getEnrichedAttributes(extraAttributes, eventName);
2301
- // Emit as log
2302
- this.logger.emit({
2303
- body: finalDisplayName,
2304
- attributes: attributes,
2305
- timestamp: Date.now(),
2306
- });
2307
- }
2308
- catch (error) {
2309
- // Silent failure
2310
- console.debug('Failed to track telemetry event:', error);
2311
- }
2312
- }
2313
- /**
2314
- * Get enriched attributes for telemetry events
2315
- */
2316
- getEnrichedAttributes(extraAttributes, eventName) {
2317
- const attributes = {
2318
- [APP_NAME]: SDK_SERVICE_NAME,
2319
- [VERSION]: SDK_VERSION,
2320
- [SERVICE]: eventName,
2321
- [CLOUD_URL]: this.createCloudUrl(),
2322
- [CLOUD_ORGANIZATION_NAME]: this.telemetryContext?.orgName || UNKNOWN,
2323
- [CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN,
2324
- [CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN,
2325
- [CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN,
2326
- ...extraAttributes,
2327
- };
2328
- return attributes;
2329
- }
2330
- /**
2331
- * Create cloud URL from base URL, organization ID, and tenant ID
2332
- */
2333
- createCloudUrl() {
2334
- const baseUrl = this.telemetryContext?.baseUrl;
2335
- const orgId = this.telemetryContext?.orgName;
2336
- const tenantId = this.telemetryContext?.tenantName;
2337
- if (!baseUrl || !orgId || !tenantId) {
2338
- return UNKNOWN;
2339
- }
2340
- return `${baseUrl}/${orgId}/${tenantId}`;
2341
- }
2342
- }
2343
- // Export singleton instance
2344
- const telemetryClient = TelemetryClient.getInstance();
2136
+ * SDK Telemetry constants.
2137
+ *
2138
+ * Only the SDK's identity (version, service name, role name, …) lives
2139
+ * here. The Application Insights connection string is injected into
2140
+ * `@uipath/core-telemetry` itself at publish time, and the generic attribute
2141
+ * keys (`Version`, `Service`, `CloudOrganizationName`, …) are owned by
2142
+ * `@uipath/core-telemetry` and consumed there — they are not part of the
2143
+ * SDK's public API.
2144
+ */
2145
+ /** SDK version placeholder — patched by the SDK publish workflow. */
2146
+ const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
2345
2147
 
2346
2148
  /**
2347
- * SDK Track decorator and function for telemetry
2348
- */
2349
- /**
2350
- * Common tracking logic shared between method and function decorators
2351
- */
2352
- function createTrackedFunction(originalFunction, nameOrOptions, fallbackName, opts) {
2353
- return function (...args) {
2354
- // Determine if we should track this call
2355
- let shouldTrack = true;
2356
- if (opts.condition !== undefined) {
2357
- if (typeof opts.condition === 'function') {
2358
- shouldTrack = opts.condition.apply(this, args);
2359
- }
2360
- else {
2361
- shouldTrack = opts.condition;
2362
- }
2363
- }
2364
- // Track the event if enabled
2365
- if (shouldTrack) {
2366
- // Use the full name provided in the decorator (e.g., "Queue.GetAll")
2367
- const serviceMethod = typeof nameOrOptions === 'string'
2368
- ? nameOrOptions
2369
- : fallbackName;
2370
- // Use 'Sdk.Run' as the name and serviceMethod as the service
2371
- telemetryClient.track(serviceMethod, SDK_RUN_EVENT, opts.attributes);
2372
- }
2373
- // Execute the original function
2374
- return originalFunction.apply(this, args);
2375
- };
2376
- }
2377
- /**
2378
- * Track decorator that can be used to automatically track function calls
2379
- *
2380
- * Usage:
2381
- * @track("Service.Method")
2382
- * function myFunction() { ... }
2149
+ * UiPath TypeScript SDK Telemetry
2383
2150
  *
2384
- * @track("Queue.GetAll")
2385
- * async getAll() { ... }
2386
- *
2387
- * @track("Tasks.Create")
2388
- * async create() { ... }
2389
- *
2390
- * @track("Assets.Update", { condition: false })
2391
- * function myFunction() { ... }
2392
- *
2393
- * @track("Processes.Start", { attributes: { customProp: "value" } })
2394
- * function myFunction() { ... }
2395
- */
2396
- function track(nameOrOptions, options) {
2397
- return function decorator(_target, propertyKey, descriptor) {
2398
- const opts = typeof nameOrOptions === 'object' ? nameOrOptions : {};
2399
- if (descriptor && typeof descriptor.value === 'function') {
2400
- // Method decorator
2401
- descriptor.value = createTrackedFunction(descriptor.value, nameOrOptions, propertyKey || 'unknown_method', opts);
2402
- return descriptor;
2403
- }
2404
- // Function decorator
2405
- return (originalFunction) => createTrackedFunction(originalFunction, nameOrOptions, originalFunction.name || 'unknown_function', opts);
2406
- };
2407
- }
2151
+ * Constructs the SDK's own `TelemetryClient` and binds the SDK-local
2152
+ * `track` / `trackEvent` to it. Each consumer of `@uipath/core-telemetry`
2153
+ * does this independently, so events carry their own consumer's identity
2154
+ * and tenant context.
2155
+ */
2156
+ // Keyed by `CLOUD_ROLE_NAME` so every SDK subpath bundle resolves to the
2157
+ // same `TelemetryClient` instance at runtime. A single `initialize(...)`
2158
+ // from the `UiPath` constructor therefore wires up `@track` decorators
2159
+ // across every subpath bundle (`assets`, `feedback`, `tasks`, …).
2160
+ const sdkClient = getOrCreateClient(CLOUD_ROLE_NAME);
2161
+ const track = createTrack(sdkClient);
2162
+ createTrackEvent(sdkClient);
2408
2163
 
2409
2164
  /**
2410
2165
  * Service for interacting with the Data Fabric Entity API