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