@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
@@ -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.
@@ -1957,278 +1957,33 @@ const PROCESS_ENDPOINTS = {
1957
1957
  };
1958
1958
 
1959
1959
  /**
1960
- * SDK Telemetry constants
1961
- */
1962
- // Connection string placeholder that will be replaced during build
1963
- 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";
1964
- // SDK Version placeholder
1965
- const SDK_VERSION = "1.3.8";
1966
- const VERSION = "Version";
1967
- const SERVICE = "Service";
1968
- const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
1969
- const CLOUD_TENANT_NAME = "CloudTenantName";
1970
- const CLOUD_URL = "CloudUrl";
1971
- const CLOUD_CLIENT_ID = "CloudClientId";
1972
- const CLOUD_REDIRECT_URI = "CloudRedirectUri";
1973
- const APP_NAME = "ApplicationName";
1974
- const CLOUD_ROLE_NAME = "uipath-ts-sdk";
1975
- // Service and logger names
1976
- const SDK_SERVICE_NAME = "UiPath.TypeScript.Sdk";
1977
- const SDK_LOGGER_NAME = "uipath-ts-sdk-telemetry";
1978
- // Event names
1979
- const SDK_RUN_EVENT = "Sdk.Run";
1980
- // Default value for unknown/empty attributes
1981
- const UNKNOWN = "";
1982
-
1983
- /**
1984
- * Log exporter that sends ALL logs as Application Insights custom events
1985
- */
1986
- class ApplicationInsightsEventExporter {
1987
- constructor(connectionString) {
1988
- this.connectionString = connectionString;
1989
- }
1990
- export(logs, resultCallback) {
1991
- try {
1992
- logs.forEach(logRecord => {
1993
- this.sendAsCustomEvent(logRecord);
1994
- });
1995
- resultCallback({ code: 0 });
1996
- }
1997
- catch (error) {
1998
- console.debug('Failed to export logs to Application Insights:', error);
1999
- resultCallback({ code: 2, error });
2000
- }
2001
- }
2002
- shutdown() {
2003
- return Promise.resolve();
2004
- }
2005
- sendAsCustomEvent(logRecord) {
2006
- // Get event name from body or attributes
2007
- const eventName = logRecord.body || SDK_RUN_EVENT;
2008
- const payload = {
2009
- name: 'Microsoft.ApplicationInsights.Event',
2010
- time: new Date().toISOString(),
2011
- iKey: this.extractInstrumentationKey(),
2012
- data: {
2013
- baseType: 'EventData',
2014
- baseData: {
2015
- ver: 2,
2016
- name: eventName,
2017
- properties: this.convertAttributesToProperties(logRecord.attributes || {})
2018
- }
2019
- },
2020
- tags: {
2021
- 'ai.cloud.role': CLOUD_ROLE_NAME,
2022
- 'ai.cloud.roleInstance': SDK_VERSION
2023
- }
2024
- };
2025
- this.sendToApplicationInsights(payload);
2026
- }
2027
- extractInstrumentationKey() {
2028
- const match = this.connectionString.match(/InstrumentationKey=([^;]+)/);
2029
- return match ? match[1] : '';
2030
- }
2031
- convertAttributesToProperties(attributes) {
2032
- const properties = {};
2033
- Object.entries(attributes || {}).forEach(([key, value]) => {
2034
- properties[key] = String(value);
2035
- });
2036
- return properties;
2037
- }
2038
- async sendToApplicationInsights(payload) {
2039
- try {
2040
- const ingestionEndpoint = this.extractIngestionEndpoint();
2041
- if (!ingestionEndpoint) {
2042
- console.debug('No ingestion endpoint found in connection string');
2043
- return;
2044
- }
2045
- const url = `${ingestionEndpoint}/v2/track`;
2046
- const response = await fetch(url, {
2047
- method: 'POST',
2048
- headers: {
2049
- 'Content-Type': 'application/json',
2050
- },
2051
- body: JSON.stringify(payload)
2052
- });
2053
- if (!response.ok) {
2054
- console.debug(`Failed to send event telemetry: ${response.status} ${response.statusText}`);
2055
- }
2056
- }
2057
- catch (error) {
2058
- console.debug('Error sending event telemetry to Application Insights:', error);
2059
- }
2060
- }
2061
- extractIngestionEndpoint() {
2062
- const match = this.connectionString.match(/IngestionEndpoint=([^;]+)/);
2063
- return match ? match[1] : '';
2064
- }
2065
- }
2066
- /**
2067
- * Singleton telemetry client
2068
- */
2069
- class TelemetryClient {
2070
- constructor() {
2071
- this.isInitialized = false;
2072
- }
2073
- static getInstance() {
2074
- if (!TelemetryClient.instance) {
2075
- TelemetryClient.instance = new TelemetryClient();
2076
- }
2077
- return TelemetryClient.instance;
2078
- }
2079
- /**
2080
- * Initialize telemetry
2081
- */
2082
- initialize(config) {
2083
- if (this.isInitialized) {
2084
- return;
2085
- }
2086
- this.isInitialized = true;
2087
- if (config) {
2088
- this.telemetryContext = config;
2089
- }
2090
- try {
2091
- const connectionString = this.getConnectionString();
2092
- if (!connectionString) {
2093
- return;
2094
- }
2095
- this.setupTelemetryProvider(connectionString);
2096
- }
2097
- catch (error) {
2098
- // Silent failure - telemetry errors shouldn't break functionality
2099
- console.debug('Failed to initialize OpenTelemetry:', error);
2100
- }
2101
- }
2102
- getConnectionString() {
2103
- const connectionString = CONNECTION_STRING;
2104
- return connectionString;
2105
- }
2106
- setupTelemetryProvider(connectionString) {
2107
- const exporter = new ApplicationInsightsEventExporter(connectionString);
2108
- const processor = new sdkLogs.BatchLogRecordProcessor(exporter);
2109
- this.logProvider = new sdkLogs.LoggerProvider({
2110
- processors: [processor]
2111
- });
2112
- this.logger = this.logProvider.getLogger(SDK_LOGGER_NAME);
2113
- }
2114
- /**
2115
- * Track a telemetry event
2116
- */
2117
- track(eventName, name, extraAttributes = {}) {
2118
- try {
2119
- // Skip if logger not initialized
2120
- if (!this.logger) {
2121
- return;
2122
- }
2123
- const finalDisplayName = name || eventName;
2124
- const attributes = this.getEnrichedAttributes(extraAttributes, eventName);
2125
- // Emit as log
2126
- this.logger.emit({
2127
- body: finalDisplayName,
2128
- attributes: attributes,
2129
- timestamp: Date.now(),
2130
- });
2131
- }
2132
- catch (error) {
2133
- // Silent failure
2134
- console.debug('Failed to track telemetry event:', error);
2135
- }
2136
- }
2137
- /**
2138
- * Get enriched attributes for telemetry events
2139
- */
2140
- getEnrichedAttributes(extraAttributes, eventName) {
2141
- const attributes = {
2142
- [APP_NAME]: SDK_SERVICE_NAME,
2143
- [VERSION]: SDK_VERSION,
2144
- [SERVICE]: eventName,
2145
- [CLOUD_URL]: this.createCloudUrl(),
2146
- [CLOUD_ORGANIZATION_NAME]: this.telemetryContext?.orgName || UNKNOWN,
2147
- [CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN,
2148
- [CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN,
2149
- [CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN,
2150
- ...extraAttributes,
2151
- };
2152
- return attributes;
2153
- }
2154
- /**
2155
- * Create cloud URL from base URL, organization ID, and tenant ID
2156
- */
2157
- createCloudUrl() {
2158
- const baseUrl = this.telemetryContext?.baseUrl;
2159
- const orgId = this.telemetryContext?.orgName;
2160
- const tenantId = this.telemetryContext?.tenantName;
2161
- if (!baseUrl || !orgId || !tenantId) {
2162
- return UNKNOWN;
2163
- }
2164
- return `${baseUrl}/${orgId}/${tenantId}`;
2165
- }
2166
- }
2167
- // Export singleton instance
2168
- const telemetryClient = TelemetryClient.getInstance();
1960
+ * SDK Telemetry constants.
1961
+ *
1962
+ * Only the SDK's identity (version, service name, role name, …) lives
1963
+ * here. The Application Insights connection string is injected into
1964
+ * `@uipath/core-telemetry` itself at publish time, and the generic attribute
1965
+ * keys (`Version`, `Service`, `CloudOrganizationName`, …) are owned by
1966
+ * `@uipath/core-telemetry` and consumed there — they are not part of the
1967
+ * SDK's public API.
1968
+ */
1969
+ /** SDK version placeholder — patched by the SDK publish workflow. */
1970
+ const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
2169
1971
 
2170
1972
  /**
2171
- * SDK Track decorator and function for telemetry
2172
- */
2173
- /**
2174
- * Common tracking logic shared between method and function decorators
2175
- */
2176
- function createTrackedFunction(originalFunction, nameOrOptions, fallbackName, opts) {
2177
- return function (...args) {
2178
- // Determine if we should track this call
2179
- let shouldTrack = true;
2180
- if (opts.condition !== undefined) {
2181
- if (typeof opts.condition === 'function') {
2182
- shouldTrack = opts.condition.apply(this, args);
2183
- }
2184
- else {
2185
- shouldTrack = opts.condition;
2186
- }
2187
- }
2188
- // Track the event if enabled
2189
- if (shouldTrack) {
2190
- // Use the full name provided in the decorator (e.g., "Queue.GetAll")
2191
- const serviceMethod = typeof nameOrOptions === 'string'
2192
- ? nameOrOptions
2193
- : fallbackName;
2194
- // Use 'Sdk.Run' as the name and serviceMethod as the service
2195
- telemetryClient.track(serviceMethod, SDK_RUN_EVENT, opts.attributes);
2196
- }
2197
- // Execute the original function
2198
- return originalFunction.apply(this, args);
2199
- };
2200
- }
2201
- /**
2202
- * Track decorator that can be used to automatically track function calls
2203
- *
2204
- * Usage:
2205
- * @track("Service.Method")
2206
- * function myFunction() { ... }
1973
+ * UiPath TypeScript SDK Telemetry
2207
1974
  *
2208
- * @track("Queue.GetAll")
2209
- * async getAll() { ... }
2210
- *
2211
- * @track("Tasks.Create")
2212
- * async create() { ... }
2213
- *
2214
- * @track("Assets.Update", { condition: false })
2215
- * function myFunction() { ... }
2216
- *
2217
- * @track("Processes.Start", { attributes: { customProp: "value" } })
2218
- * function myFunction() { ... }
2219
- */
2220
- function track(nameOrOptions, options) {
2221
- return function decorator(_target, propertyKey, descriptor) {
2222
- const opts = typeof nameOrOptions === 'object' ? nameOrOptions : {};
2223
- if (descriptor && typeof descriptor.value === 'function') {
2224
- // Method decorator
2225
- descriptor.value = createTrackedFunction(descriptor.value, nameOrOptions, propertyKey || 'unknown_method', opts);
2226
- return descriptor;
2227
- }
2228
- // Function decorator
2229
- return (originalFunction) => createTrackedFunction(originalFunction, nameOrOptions, originalFunction.name || 'unknown_function', opts);
2230
- };
2231
- }
1975
+ * Constructs the SDK's own `TelemetryClient` and binds the SDK-local
1976
+ * `track` / `trackEvent` to it. Each consumer of `@uipath/core-telemetry`
1977
+ * does this independently, so events carry their own consumer's identity
1978
+ * and tenant context.
1979
+ */
1980
+ // Keyed by `CLOUD_ROLE_NAME` so every SDK subpath bundle resolves to the
1981
+ // same `TelemetryClient` instance at runtime. A single `initialize(...)`
1982
+ // from the `UiPath` constructor therefore wires up `@track` decorators
1983
+ // across every subpath bundle (`assets`, `feedback`, `tasks`, …).
1984
+ const sdkClient = coreTelemetry.getOrCreateClient(CLOUD_ROLE_NAME);
1985
+ const track = coreTelemetry.createTrack(sdkClient);
1986
+ coreTelemetry.createTrackEvent(sdkClient);
2232
1987
 
2233
1988
  /**
2234
1989
  * Service for interacting with UiPath Orchestrator Processes 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.
@@ -1955,278 +1955,33 @@ const PROCESS_ENDPOINTS = {
1955
1955
  };
1956
1956
 
1957
1957
  /**
1958
- * SDK Telemetry constants
1959
- */
1960
- // Connection string placeholder that will be replaced during build
1961
- 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";
1962
- // SDK Version placeholder
1963
- const SDK_VERSION = "1.3.8";
1964
- const VERSION = "Version";
1965
- const SERVICE = "Service";
1966
- const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
1967
- const CLOUD_TENANT_NAME = "CloudTenantName";
1968
- const CLOUD_URL = "CloudUrl";
1969
- const CLOUD_CLIENT_ID = "CloudClientId";
1970
- const CLOUD_REDIRECT_URI = "CloudRedirectUri";
1971
- const APP_NAME = "ApplicationName";
1972
- const CLOUD_ROLE_NAME = "uipath-ts-sdk";
1973
- // Service and logger names
1974
- const SDK_SERVICE_NAME = "UiPath.TypeScript.Sdk";
1975
- const SDK_LOGGER_NAME = "uipath-ts-sdk-telemetry";
1976
- // Event names
1977
- const SDK_RUN_EVENT = "Sdk.Run";
1978
- // Default value for unknown/empty attributes
1979
- const UNKNOWN = "";
1980
-
1981
- /**
1982
- * Log exporter that sends ALL logs as Application Insights custom events
1983
- */
1984
- class ApplicationInsightsEventExporter {
1985
- constructor(connectionString) {
1986
- this.connectionString = connectionString;
1987
- }
1988
- export(logs, resultCallback) {
1989
- try {
1990
- logs.forEach(logRecord => {
1991
- this.sendAsCustomEvent(logRecord);
1992
- });
1993
- resultCallback({ code: 0 });
1994
- }
1995
- catch (error) {
1996
- console.debug('Failed to export logs to Application Insights:', error);
1997
- resultCallback({ code: 2, error });
1998
- }
1999
- }
2000
- shutdown() {
2001
- return Promise.resolve();
2002
- }
2003
- sendAsCustomEvent(logRecord) {
2004
- // Get event name from body or attributes
2005
- const eventName = logRecord.body || SDK_RUN_EVENT;
2006
- const payload = {
2007
- name: 'Microsoft.ApplicationInsights.Event',
2008
- time: new Date().toISOString(),
2009
- iKey: this.extractInstrumentationKey(),
2010
- data: {
2011
- baseType: 'EventData',
2012
- baseData: {
2013
- ver: 2,
2014
- name: eventName,
2015
- properties: this.convertAttributesToProperties(logRecord.attributes || {})
2016
- }
2017
- },
2018
- tags: {
2019
- 'ai.cloud.role': CLOUD_ROLE_NAME,
2020
- 'ai.cloud.roleInstance': SDK_VERSION
2021
- }
2022
- };
2023
- this.sendToApplicationInsights(payload);
2024
- }
2025
- extractInstrumentationKey() {
2026
- const match = this.connectionString.match(/InstrumentationKey=([^;]+)/);
2027
- return match ? match[1] : '';
2028
- }
2029
- convertAttributesToProperties(attributes) {
2030
- const properties = {};
2031
- Object.entries(attributes || {}).forEach(([key, value]) => {
2032
- properties[key] = String(value);
2033
- });
2034
- return properties;
2035
- }
2036
- async sendToApplicationInsights(payload) {
2037
- try {
2038
- const ingestionEndpoint = this.extractIngestionEndpoint();
2039
- if (!ingestionEndpoint) {
2040
- console.debug('No ingestion endpoint found in connection string');
2041
- return;
2042
- }
2043
- const url = `${ingestionEndpoint}/v2/track`;
2044
- const response = await fetch(url, {
2045
- method: 'POST',
2046
- headers: {
2047
- 'Content-Type': 'application/json',
2048
- },
2049
- body: JSON.stringify(payload)
2050
- });
2051
- if (!response.ok) {
2052
- console.debug(`Failed to send event telemetry: ${response.status} ${response.statusText}`);
2053
- }
2054
- }
2055
- catch (error) {
2056
- console.debug('Error sending event telemetry to Application Insights:', error);
2057
- }
2058
- }
2059
- extractIngestionEndpoint() {
2060
- const match = this.connectionString.match(/IngestionEndpoint=([^;]+)/);
2061
- return match ? match[1] : '';
2062
- }
2063
- }
2064
- /**
2065
- * Singleton telemetry client
2066
- */
2067
- class TelemetryClient {
2068
- constructor() {
2069
- this.isInitialized = false;
2070
- }
2071
- static getInstance() {
2072
- if (!TelemetryClient.instance) {
2073
- TelemetryClient.instance = new TelemetryClient();
2074
- }
2075
- return TelemetryClient.instance;
2076
- }
2077
- /**
2078
- * Initialize telemetry
2079
- */
2080
- initialize(config) {
2081
- if (this.isInitialized) {
2082
- return;
2083
- }
2084
- this.isInitialized = true;
2085
- if (config) {
2086
- this.telemetryContext = config;
2087
- }
2088
- try {
2089
- const connectionString = this.getConnectionString();
2090
- if (!connectionString) {
2091
- return;
2092
- }
2093
- this.setupTelemetryProvider(connectionString);
2094
- }
2095
- catch (error) {
2096
- // Silent failure - telemetry errors shouldn't break functionality
2097
- console.debug('Failed to initialize OpenTelemetry:', error);
2098
- }
2099
- }
2100
- getConnectionString() {
2101
- const connectionString = CONNECTION_STRING;
2102
- return connectionString;
2103
- }
2104
- setupTelemetryProvider(connectionString) {
2105
- const exporter = new ApplicationInsightsEventExporter(connectionString);
2106
- const processor = new BatchLogRecordProcessor(exporter);
2107
- this.logProvider = new LoggerProvider({
2108
- processors: [processor]
2109
- });
2110
- this.logger = this.logProvider.getLogger(SDK_LOGGER_NAME);
2111
- }
2112
- /**
2113
- * Track a telemetry event
2114
- */
2115
- track(eventName, name, extraAttributes = {}) {
2116
- try {
2117
- // Skip if logger not initialized
2118
- if (!this.logger) {
2119
- return;
2120
- }
2121
- const finalDisplayName = name || eventName;
2122
- const attributes = this.getEnrichedAttributes(extraAttributes, eventName);
2123
- // Emit as log
2124
- this.logger.emit({
2125
- body: finalDisplayName,
2126
- attributes: attributes,
2127
- timestamp: Date.now(),
2128
- });
2129
- }
2130
- catch (error) {
2131
- // Silent failure
2132
- console.debug('Failed to track telemetry event:', error);
2133
- }
2134
- }
2135
- /**
2136
- * Get enriched attributes for telemetry events
2137
- */
2138
- getEnrichedAttributes(extraAttributes, eventName) {
2139
- const attributes = {
2140
- [APP_NAME]: SDK_SERVICE_NAME,
2141
- [VERSION]: SDK_VERSION,
2142
- [SERVICE]: eventName,
2143
- [CLOUD_URL]: this.createCloudUrl(),
2144
- [CLOUD_ORGANIZATION_NAME]: this.telemetryContext?.orgName || UNKNOWN,
2145
- [CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN,
2146
- [CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN,
2147
- [CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN,
2148
- ...extraAttributes,
2149
- };
2150
- return attributes;
2151
- }
2152
- /**
2153
- * Create cloud URL from base URL, organization ID, and tenant ID
2154
- */
2155
- createCloudUrl() {
2156
- const baseUrl = this.telemetryContext?.baseUrl;
2157
- const orgId = this.telemetryContext?.orgName;
2158
- const tenantId = this.telemetryContext?.tenantName;
2159
- if (!baseUrl || !orgId || !tenantId) {
2160
- return UNKNOWN;
2161
- }
2162
- return `${baseUrl}/${orgId}/${tenantId}`;
2163
- }
2164
- }
2165
- // Export singleton instance
2166
- const telemetryClient = TelemetryClient.getInstance();
1958
+ * SDK Telemetry constants.
1959
+ *
1960
+ * Only the SDK's identity (version, service name, role name, …) lives
1961
+ * here. The Application Insights connection string is injected into
1962
+ * `@uipath/core-telemetry` itself at publish time, and the generic attribute
1963
+ * keys (`Version`, `Service`, `CloudOrganizationName`, …) are owned by
1964
+ * `@uipath/core-telemetry` and consumed there — they are not part of the
1965
+ * SDK's public API.
1966
+ */
1967
+ /** SDK version placeholder — patched by the SDK publish workflow. */
1968
+ const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
2167
1969
 
2168
1970
  /**
2169
- * SDK Track decorator and function for telemetry
2170
- */
2171
- /**
2172
- * Common tracking logic shared between method and function decorators
2173
- */
2174
- function createTrackedFunction(originalFunction, nameOrOptions, fallbackName, opts) {
2175
- return function (...args) {
2176
- // Determine if we should track this call
2177
- let shouldTrack = true;
2178
- if (opts.condition !== undefined) {
2179
- if (typeof opts.condition === 'function') {
2180
- shouldTrack = opts.condition.apply(this, args);
2181
- }
2182
- else {
2183
- shouldTrack = opts.condition;
2184
- }
2185
- }
2186
- // Track the event if enabled
2187
- if (shouldTrack) {
2188
- // Use the full name provided in the decorator (e.g., "Queue.GetAll")
2189
- const serviceMethod = typeof nameOrOptions === 'string'
2190
- ? nameOrOptions
2191
- : fallbackName;
2192
- // Use 'Sdk.Run' as the name and serviceMethod as the service
2193
- telemetryClient.track(serviceMethod, SDK_RUN_EVENT, opts.attributes);
2194
- }
2195
- // Execute the original function
2196
- return originalFunction.apply(this, args);
2197
- };
2198
- }
2199
- /**
2200
- * Track decorator that can be used to automatically track function calls
2201
- *
2202
- * Usage:
2203
- * @track("Service.Method")
2204
- * function myFunction() { ... }
1971
+ * UiPath TypeScript SDK Telemetry
2205
1972
  *
2206
- * @track("Queue.GetAll")
2207
- * async getAll() { ... }
2208
- *
2209
- * @track("Tasks.Create")
2210
- * async create() { ... }
2211
- *
2212
- * @track("Assets.Update", { condition: false })
2213
- * function myFunction() { ... }
2214
- *
2215
- * @track("Processes.Start", { attributes: { customProp: "value" } })
2216
- * function myFunction() { ... }
2217
- */
2218
- function track(nameOrOptions, options) {
2219
- return function decorator(_target, propertyKey, descriptor) {
2220
- const opts = typeof nameOrOptions === 'object' ? nameOrOptions : {};
2221
- if (descriptor && typeof descriptor.value === 'function') {
2222
- // Method decorator
2223
- descriptor.value = createTrackedFunction(descriptor.value, nameOrOptions, propertyKey || 'unknown_method', opts);
2224
- return descriptor;
2225
- }
2226
- // Function decorator
2227
- return (originalFunction) => createTrackedFunction(originalFunction, nameOrOptions, originalFunction.name || 'unknown_function', opts);
2228
- };
2229
- }
1973
+ * Constructs the SDK's own `TelemetryClient` and binds the SDK-local
1974
+ * `track` / `trackEvent` to it. Each consumer of `@uipath/core-telemetry`
1975
+ * does this independently, so events carry their own consumer's identity
1976
+ * and tenant context.
1977
+ */
1978
+ // Keyed by `CLOUD_ROLE_NAME` so every SDK subpath bundle resolves to the
1979
+ // same `TelemetryClient` instance at runtime. A single `initialize(...)`
1980
+ // from the `UiPath` constructor therefore wires up `@track` decorators
1981
+ // across every subpath bundle (`assets`, `feedback`, `tasks`, …).
1982
+ const sdkClient = getOrCreateClient(CLOUD_ROLE_NAME);
1983
+ const track = createTrack(sdkClient);
1984
+ createTrackEvent(sdkClient);
2230
1985
 
2231
1986
  /**
2232
1987
  * Service for interacting with UiPath Orchestrator Processes API