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