@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.
@@ -1615,278 +1615,33 @@ const FEEDBACK_ENDPOINTS = {
1615
1615
  };
1616
1616
 
1617
1617
  /**
1618
- * SDK Telemetry constants
1618
+ * SDK Telemetry constants.
1619
+ *
1620
+ * Only the SDK's identity (version, service name, role name, …) lives
1621
+ * here. The Application Insights connection string is injected into
1622
+ * `@uipath/core-telemetry` itself at publish time, and the generic attribute
1623
+ * keys (`Version`, `Service`, `CloudOrganizationName`, …) are owned by
1624
+ * `@uipath/core-telemetry` and consumed there — they are not part of the
1625
+ * SDK's public API.
1619
1626
  */
1620
- // Connection string placeholder that will be replaced during build
1621
- 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";
1622
- // SDK Version placeholder
1623
- const SDK_VERSION = "1.3.8";
1624
- const VERSION = "Version";
1625
- const SERVICE = "Service";
1626
- const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
1627
- const CLOUD_TENANT_NAME = "CloudTenantName";
1628
- const CLOUD_URL = "CloudUrl";
1629
- const CLOUD_CLIENT_ID = "CloudClientId";
1630
- const CLOUD_REDIRECT_URI = "CloudRedirectUri";
1631
- const APP_NAME = "ApplicationName";
1632
- const CLOUD_ROLE_NAME = "uipath-ts-sdk";
1633
- // Service and logger names
1634
- const SDK_SERVICE_NAME = "UiPath.TypeScript.Sdk";
1635
- const SDK_LOGGER_NAME = "uipath-ts-sdk-telemetry";
1636
- // Event names
1637
- const SDK_RUN_EVENT = "Sdk.Run";
1638
- // Default value for unknown/empty attributes
1639
- const UNKNOWN = "";
1627
+ /** SDK version placeholder patched by the SDK publish workflow. */
1628
+ const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
1640
1629
 
1641
1630
  /**
1642
- * Log exporter that sends ALL logs as Application Insights custom events
1643
- */
1644
- class ApplicationInsightsEventExporter {
1645
- constructor(connectionString) {
1646
- this.connectionString = connectionString;
1647
- }
1648
- export(logs, resultCallback) {
1649
- try {
1650
- logs.forEach(logRecord => {
1651
- this.sendAsCustomEvent(logRecord);
1652
- });
1653
- resultCallback({ code: 0 });
1654
- }
1655
- catch (error) {
1656
- console.debug('Failed to export logs to Application Insights:', error);
1657
- resultCallback({ code: 2, error });
1658
- }
1659
- }
1660
- shutdown() {
1661
- return Promise.resolve();
1662
- }
1663
- sendAsCustomEvent(logRecord) {
1664
- // Get event name from body or attributes
1665
- const eventName = logRecord.body || SDK_RUN_EVENT;
1666
- const payload = {
1667
- name: 'Microsoft.ApplicationInsights.Event',
1668
- time: new Date().toISOString(),
1669
- iKey: this.extractInstrumentationKey(),
1670
- data: {
1671
- baseType: 'EventData',
1672
- baseData: {
1673
- ver: 2,
1674
- name: eventName,
1675
- properties: this.convertAttributesToProperties(logRecord.attributes || {})
1676
- }
1677
- },
1678
- tags: {
1679
- 'ai.cloud.role': CLOUD_ROLE_NAME,
1680
- 'ai.cloud.roleInstance': SDK_VERSION
1681
- }
1682
- };
1683
- this.sendToApplicationInsights(payload);
1684
- }
1685
- extractInstrumentationKey() {
1686
- const match = this.connectionString.match(/InstrumentationKey=([^;]+)/);
1687
- return match ? match[1] : '';
1688
- }
1689
- convertAttributesToProperties(attributes) {
1690
- const properties = {};
1691
- Object.entries(attributes || {}).forEach(([key, value]) => {
1692
- properties[key] = String(value);
1693
- });
1694
- return properties;
1695
- }
1696
- async sendToApplicationInsights(payload) {
1697
- try {
1698
- const ingestionEndpoint = this.extractIngestionEndpoint();
1699
- if (!ingestionEndpoint) {
1700
- console.debug('No ingestion endpoint found in connection string');
1701
- return;
1702
- }
1703
- const url = `${ingestionEndpoint}/v2/track`;
1704
- const response = await fetch(url, {
1705
- method: 'POST',
1706
- headers: {
1707
- 'Content-Type': 'application/json',
1708
- },
1709
- body: JSON.stringify(payload)
1710
- });
1711
- if (!response.ok) {
1712
- console.debug(`Failed to send event telemetry: ${response.status} ${response.statusText}`);
1713
- }
1714
- }
1715
- catch (error) {
1716
- console.debug('Error sending event telemetry to Application Insights:', error);
1717
- }
1718
- }
1719
- extractIngestionEndpoint() {
1720
- const match = this.connectionString.match(/IngestionEndpoint=([^;]+)/);
1721
- return match ? match[1] : '';
1722
- }
1723
- }
1724
- /**
1725
- * Singleton telemetry client
1726
- */
1727
- class TelemetryClient {
1728
- constructor() {
1729
- this.isInitialized = false;
1730
- }
1731
- static getInstance() {
1732
- if (!TelemetryClient.instance) {
1733
- TelemetryClient.instance = new TelemetryClient();
1734
- }
1735
- return TelemetryClient.instance;
1736
- }
1737
- /**
1738
- * Initialize telemetry
1739
- */
1740
- initialize(config) {
1741
- if (this.isInitialized) {
1742
- return;
1743
- }
1744
- this.isInitialized = true;
1745
- if (config) {
1746
- this.telemetryContext = config;
1747
- }
1748
- try {
1749
- const connectionString = this.getConnectionString();
1750
- if (!connectionString) {
1751
- return;
1752
- }
1753
- this.setupTelemetryProvider(connectionString);
1754
- }
1755
- catch (error) {
1756
- // Silent failure - telemetry errors shouldn't break functionality
1757
- console.debug('Failed to initialize OpenTelemetry:', error);
1758
- }
1759
- }
1760
- getConnectionString() {
1761
- const connectionString = CONNECTION_STRING;
1762
- return connectionString;
1763
- }
1764
- setupTelemetryProvider(connectionString) {
1765
- const exporter = new ApplicationInsightsEventExporter(connectionString);
1766
- const processor = new sdkLogs.BatchLogRecordProcessor(exporter);
1767
- this.logProvider = new sdkLogs.LoggerProvider({
1768
- processors: [processor]
1769
- });
1770
- this.logger = this.logProvider.getLogger(SDK_LOGGER_NAME);
1771
- }
1772
- /**
1773
- * Track a telemetry event
1774
- */
1775
- track(eventName, name, extraAttributes = {}) {
1776
- try {
1777
- // Skip if logger not initialized
1778
- if (!this.logger) {
1779
- return;
1780
- }
1781
- const finalDisplayName = name || eventName;
1782
- const attributes = this.getEnrichedAttributes(extraAttributes, eventName);
1783
- // Emit as log
1784
- this.logger.emit({
1785
- body: finalDisplayName,
1786
- attributes: attributes,
1787
- timestamp: Date.now(),
1788
- });
1789
- }
1790
- catch (error) {
1791
- // Silent failure
1792
- console.debug('Failed to track telemetry event:', error);
1793
- }
1794
- }
1795
- /**
1796
- * Get enriched attributes for telemetry events
1797
- */
1798
- getEnrichedAttributes(extraAttributes, eventName) {
1799
- const attributes = {
1800
- [APP_NAME]: SDK_SERVICE_NAME,
1801
- [VERSION]: SDK_VERSION,
1802
- [SERVICE]: eventName,
1803
- [CLOUD_URL]: this.createCloudUrl(),
1804
- [CLOUD_ORGANIZATION_NAME]: this.telemetryContext?.orgName || UNKNOWN,
1805
- [CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN,
1806
- [CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN,
1807
- [CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN,
1808
- ...extraAttributes,
1809
- };
1810
- return attributes;
1811
- }
1812
- /**
1813
- * Create cloud URL from base URL, organization ID, and tenant ID
1814
- */
1815
- createCloudUrl() {
1816
- const baseUrl = this.telemetryContext?.baseUrl;
1817
- const orgId = this.telemetryContext?.orgName;
1818
- const tenantId = this.telemetryContext?.tenantName;
1819
- if (!baseUrl || !orgId || !tenantId) {
1820
- return UNKNOWN;
1821
- }
1822
- return `${baseUrl}/${orgId}/${tenantId}`;
1823
- }
1824
- }
1825
- // Export singleton instance
1826
- const telemetryClient = TelemetryClient.getInstance();
1827
-
1828
- /**
1829
- * SDK Track decorator and function for telemetry
1830
- */
1831
- /**
1832
- * Common tracking logic shared between method and function decorators
1833
- */
1834
- function createTrackedFunction(originalFunction, nameOrOptions, fallbackName, opts) {
1835
- return function (...args) {
1836
- // Determine if we should track this call
1837
- let shouldTrack = true;
1838
- if (opts.condition !== undefined) {
1839
- if (typeof opts.condition === 'function') {
1840
- shouldTrack = opts.condition.apply(this, args);
1841
- }
1842
- else {
1843
- shouldTrack = opts.condition;
1844
- }
1845
- }
1846
- // Track the event if enabled
1847
- if (shouldTrack) {
1848
- // Use the full name provided in the decorator (e.g., "Queue.GetAll")
1849
- const serviceMethod = typeof nameOrOptions === 'string'
1850
- ? nameOrOptions
1851
- : fallbackName;
1852
- // Use 'Sdk.Run' as the name and serviceMethod as the service
1853
- telemetryClient.track(serviceMethod, SDK_RUN_EVENT, opts.attributes);
1854
- }
1855
- // Execute the original function
1856
- return originalFunction.apply(this, args);
1857
- };
1858
- }
1859
- /**
1860
- * Track decorator that can be used to automatically track function calls
1861
- *
1862
- * Usage:
1863
- * @track("Service.Method")
1864
- * function myFunction() { ... }
1631
+ * UiPath TypeScript SDK Telemetry
1865
1632
  *
1866
- * @track("Queue.GetAll")
1867
- * async getAll() { ... }
1868
- *
1869
- * @track("Tasks.Create")
1870
- * async create() { ... }
1871
- *
1872
- * @track("Assets.Update", { condition: false })
1873
- * function myFunction() { ... }
1874
- *
1875
- * @track("Processes.Start", { attributes: { customProp: "value" } })
1876
- * function myFunction() { ... }
1633
+ * Constructs the SDK's own `TelemetryClient` and binds the SDK-local
1634
+ * `track` / `trackEvent` to it. Each consumer of `@uipath/core-telemetry`
1635
+ * does this independently, so events carry their own consumer's identity
1636
+ * and tenant context.
1877
1637
  */
1878
- function track(nameOrOptions, options) {
1879
- return function decorator(_target, propertyKey, descriptor) {
1880
- const opts = typeof nameOrOptions === 'object' ? nameOrOptions : {};
1881
- if (descriptor && typeof descriptor.value === 'function') {
1882
- // Method decorator
1883
- descriptor.value = createTrackedFunction(descriptor.value, nameOrOptions, propertyKey || 'unknown_method', opts);
1884
- return descriptor;
1885
- }
1886
- // Function decorator
1887
- return (originalFunction) => createTrackedFunction(originalFunction, nameOrOptions, originalFunction.name || 'unknown_function', opts);
1888
- };
1889
- }
1638
+ // Keyed by `CLOUD_ROLE_NAME` so every SDK subpath bundle resolves to the
1639
+ // same `TelemetryClient` instance at runtime. A single `initialize(...)`
1640
+ // from the `UiPath` constructor therefore wires up `@track` decorators
1641
+ // across every subpath bundle (`assets`, `feedback`, `tasks`, …).
1642
+ const sdkClient = coreTelemetry.getOrCreateClient(CLOUD_ROLE_NAME);
1643
+ const track = coreTelemetry.createTrack(sdkClient);
1644
+ coreTelemetry.createTrackEvent(sdkClient);
1890
1645
 
1891
1646
  /**
1892
1647
  * Service for interacting with UiPath Agent Feedback 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.
@@ -1613,278 +1613,33 @@ const FEEDBACK_ENDPOINTS = {
1613
1613
  };
1614
1614
 
1615
1615
  /**
1616
- * SDK Telemetry constants
1616
+ * SDK Telemetry constants.
1617
+ *
1618
+ * Only the SDK's identity (version, service name, role name, …) lives
1619
+ * here. The Application Insights connection string is injected into
1620
+ * `@uipath/core-telemetry` itself at publish time, and the generic attribute
1621
+ * keys (`Version`, `Service`, `CloudOrganizationName`, …) are owned by
1622
+ * `@uipath/core-telemetry` and consumed there — they are not part of the
1623
+ * SDK's public API.
1617
1624
  */
1618
- // Connection string placeholder that will be replaced during build
1619
- 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";
1620
- // SDK Version placeholder
1621
- const SDK_VERSION = "1.3.8";
1622
- const VERSION = "Version";
1623
- const SERVICE = "Service";
1624
- const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
1625
- const CLOUD_TENANT_NAME = "CloudTenantName";
1626
- const CLOUD_URL = "CloudUrl";
1627
- const CLOUD_CLIENT_ID = "CloudClientId";
1628
- const CLOUD_REDIRECT_URI = "CloudRedirectUri";
1629
- const APP_NAME = "ApplicationName";
1630
- const CLOUD_ROLE_NAME = "uipath-ts-sdk";
1631
- // Service and logger names
1632
- const SDK_SERVICE_NAME = "UiPath.TypeScript.Sdk";
1633
- const SDK_LOGGER_NAME = "uipath-ts-sdk-telemetry";
1634
- // Event names
1635
- const SDK_RUN_EVENT = "Sdk.Run";
1636
- // Default value for unknown/empty attributes
1637
- const UNKNOWN = "";
1625
+ /** SDK version placeholder patched by the SDK publish workflow. */
1626
+ const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
1638
1627
 
1639
1628
  /**
1640
- * Log exporter that sends ALL logs as Application Insights custom events
1641
- */
1642
- class ApplicationInsightsEventExporter {
1643
- constructor(connectionString) {
1644
- this.connectionString = connectionString;
1645
- }
1646
- export(logs, resultCallback) {
1647
- try {
1648
- logs.forEach(logRecord => {
1649
- this.sendAsCustomEvent(logRecord);
1650
- });
1651
- resultCallback({ code: 0 });
1652
- }
1653
- catch (error) {
1654
- console.debug('Failed to export logs to Application Insights:', error);
1655
- resultCallback({ code: 2, error });
1656
- }
1657
- }
1658
- shutdown() {
1659
- return Promise.resolve();
1660
- }
1661
- sendAsCustomEvent(logRecord) {
1662
- // Get event name from body or attributes
1663
- const eventName = logRecord.body || SDK_RUN_EVENT;
1664
- const payload = {
1665
- name: 'Microsoft.ApplicationInsights.Event',
1666
- time: new Date().toISOString(),
1667
- iKey: this.extractInstrumentationKey(),
1668
- data: {
1669
- baseType: 'EventData',
1670
- baseData: {
1671
- ver: 2,
1672
- name: eventName,
1673
- properties: this.convertAttributesToProperties(logRecord.attributes || {})
1674
- }
1675
- },
1676
- tags: {
1677
- 'ai.cloud.role': CLOUD_ROLE_NAME,
1678
- 'ai.cloud.roleInstance': SDK_VERSION
1679
- }
1680
- };
1681
- this.sendToApplicationInsights(payload);
1682
- }
1683
- extractInstrumentationKey() {
1684
- const match = this.connectionString.match(/InstrumentationKey=([^;]+)/);
1685
- return match ? match[1] : '';
1686
- }
1687
- convertAttributesToProperties(attributes) {
1688
- const properties = {};
1689
- Object.entries(attributes || {}).forEach(([key, value]) => {
1690
- properties[key] = String(value);
1691
- });
1692
- return properties;
1693
- }
1694
- async sendToApplicationInsights(payload) {
1695
- try {
1696
- const ingestionEndpoint = this.extractIngestionEndpoint();
1697
- if (!ingestionEndpoint) {
1698
- console.debug('No ingestion endpoint found in connection string');
1699
- return;
1700
- }
1701
- const url = `${ingestionEndpoint}/v2/track`;
1702
- const response = await fetch(url, {
1703
- method: 'POST',
1704
- headers: {
1705
- 'Content-Type': 'application/json',
1706
- },
1707
- body: JSON.stringify(payload)
1708
- });
1709
- if (!response.ok) {
1710
- console.debug(`Failed to send event telemetry: ${response.status} ${response.statusText}`);
1711
- }
1712
- }
1713
- catch (error) {
1714
- console.debug('Error sending event telemetry to Application Insights:', error);
1715
- }
1716
- }
1717
- extractIngestionEndpoint() {
1718
- const match = this.connectionString.match(/IngestionEndpoint=([^;]+)/);
1719
- return match ? match[1] : '';
1720
- }
1721
- }
1722
- /**
1723
- * Singleton telemetry client
1724
- */
1725
- class TelemetryClient {
1726
- constructor() {
1727
- this.isInitialized = false;
1728
- }
1729
- static getInstance() {
1730
- if (!TelemetryClient.instance) {
1731
- TelemetryClient.instance = new TelemetryClient();
1732
- }
1733
- return TelemetryClient.instance;
1734
- }
1735
- /**
1736
- * Initialize telemetry
1737
- */
1738
- initialize(config) {
1739
- if (this.isInitialized) {
1740
- return;
1741
- }
1742
- this.isInitialized = true;
1743
- if (config) {
1744
- this.telemetryContext = config;
1745
- }
1746
- try {
1747
- const connectionString = this.getConnectionString();
1748
- if (!connectionString) {
1749
- return;
1750
- }
1751
- this.setupTelemetryProvider(connectionString);
1752
- }
1753
- catch (error) {
1754
- // Silent failure - telemetry errors shouldn't break functionality
1755
- console.debug('Failed to initialize OpenTelemetry:', error);
1756
- }
1757
- }
1758
- getConnectionString() {
1759
- const connectionString = CONNECTION_STRING;
1760
- return connectionString;
1761
- }
1762
- setupTelemetryProvider(connectionString) {
1763
- const exporter = new ApplicationInsightsEventExporter(connectionString);
1764
- const processor = new BatchLogRecordProcessor(exporter);
1765
- this.logProvider = new LoggerProvider({
1766
- processors: [processor]
1767
- });
1768
- this.logger = this.logProvider.getLogger(SDK_LOGGER_NAME);
1769
- }
1770
- /**
1771
- * Track a telemetry event
1772
- */
1773
- track(eventName, name, extraAttributes = {}) {
1774
- try {
1775
- // Skip if logger not initialized
1776
- if (!this.logger) {
1777
- return;
1778
- }
1779
- const finalDisplayName = name || eventName;
1780
- const attributes = this.getEnrichedAttributes(extraAttributes, eventName);
1781
- // Emit as log
1782
- this.logger.emit({
1783
- body: finalDisplayName,
1784
- attributes: attributes,
1785
- timestamp: Date.now(),
1786
- });
1787
- }
1788
- catch (error) {
1789
- // Silent failure
1790
- console.debug('Failed to track telemetry event:', error);
1791
- }
1792
- }
1793
- /**
1794
- * Get enriched attributes for telemetry events
1795
- */
1796
- getEnrichedAttributes(extraAttributes, eventName) {
1797
- const attributes = {
1798
- [APP_NAME]: SDK_SERVICE_NAME,
1799
- [VERSION]: SDK_VERSION,
1800
- [SERVICE]: eventName,
1801
- [CLOUD_URL]: this.createCloudUrl(),
1802
- [CLOUD_ORGANIZATION_NAME]: this.telemetryContext?.orgName || UNKNOWN,
1803
- [CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN,
1804
- [CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN,
1805
- [CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN,
1806
- ...extraAttributes,
1807
- };
1808
- return attributes;
1809
- }
1810
- /**
1811
- * Create cloud URL from base URL, organization ID, and tenant ID
1812
- */
1813
- createCloudUrl() {
1814
- const baseUrl = this.telemetryContext?.baseUrl;
1815
- const orgId = this.telemetryContext?.orgName;
1816
- const tenantId = this.telemetryContext?.tenantName;
1817
- if (!baseUrl || !orgId || !tenantId) {
1818
- return UNKNOWN;
1819
- }
1820
- return `${baseUrl}/${orgId}/${tenantId}`;
1821
- }
1822
- }
1823
- // Export singleton instance
1824
- const telemetryClient = TelemetryClient.getInstance();
1825
-
1826
- /**
1827
- * SDK Track decorator and function for telemetry
1828
- */
1829
- /**
1830
- * Common tracking logic shared between method and function decorators
1831
- */
1832
- function createTrackedFunction(originalFunction, nameOrOptions, fallbackName, opts) {
1833
- return function (...args) {
1834
- // Determine if we should track this call
1835
- let shouldTrack = true;
1836
- if (opts.condition !== undefined) {
1837
- if (typeof opts.condition === 'function') {
1838
- shouldTrack = opts.condition.apply(this, args);
1839
- }
1840
- else {
1841
- shouldTrack = opts.condition;
1842
- }
1843
- }
1844
- // Track the event if enabled
1845
- if (shouldTrack) {
1846
- // Use the full name provided in the decorator (e.g., "Queue.GetAll")
1847
- const serviceMethod = typeof nameOrOptions === 'string'
1848
- ? nameOrOptions
1849
- : fallbackName;
1850
- // Use 'Sdk.Run' as the name and serviceMethod as the service
1851
- telemetryClient.track(serviceMethod, SDK_RUN_EVENT, opts.attributes);
1852
- }
1853
- // Execute the original function
1854
- return originalFunction.apply(this, args);
1855
- };
1856
- }
1857
- /**
1858
- * Track decorator that can be used to automatically track function calls
1859
- *
1860
- * Usage:
1861
- * @track("Service.Method")
1862
- * function myFunction() { ... }
1629
+ * UiPath TypeScript SDK Telemetry
1863
1630
  *
1864
- * @track("Queue.GetAll")
1865
- * async getAll() { ... }
1866
- *
1867
- * @track("Tasks.Create")
1868
- * async create() { ... }
1869
- *
1870
- * @track("Assets.Update", { condition: false })
1871
- * function myFunction() { ... }
1872
- *
1873
- * @track("Processes.Start", { attributes: { customProp: "value" } })
1874
- * function myFunction() { ... }
1631
+ * Constructs the SDK's own `TelemetryClient` and binds the SDK-local
1632
+ * `track` / `trackEvent` to it. Each consumer of `@uipath/core-telemetry`
1633
+ * does this independently, so events carry their own consumer's identity
1634
+ * and tenant context.
1875
1635
  */
1876
- function track(nameOrOptions, options) {
1877
- return function decorator(_target, propertyKey, descriptor) {
1878
- const opts = typeof nameOrOptions === 'object' ? nameOrOptions : {};
1879
- if (descriptor && typeof descriptor.value === 'function') {
1880
- // Method decorator
1881
- descriptor.value = createTrackedFunction(descriptor.value, nameOrOptions, propertyKey || 'unknown_method', opts);
1882
- return descriptor;
1883
- }
1884
- // Function decorator
1885
- return (originalFunction) => createTrackedFunction(originalFunction, nameOrOptions, originalFunction.name || 'unknown_function', opts);
1886
- };
1887
- }
1636
+ // Keyed by `CLOUD_ROLE_NAME` so every SDK subpath bundle resolves to the
1637
+ // same `TelemetryClient` instance at runtime. A single `initialize(...)`
1638
+ // from the `UiPath` constructor therefore wires up `@track` decorators
1639
+ // across every subpath bundle (`assets`, `feedback`, `tasks`, …).
1640
+ const sdkClient = getOrCreateClient(CLOUD_ROLE_NAME);
1641
+ const track = createTrack(sdkClient);
1642
+ createTrackEvent(sdkClient);
1888
1643
 
1889
1644
  /**
1890
1645
  * Service for interacting with UiPath Agent Feedback API