@sap-ux/telemetry 1.0.13 → 1.0.14

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.
@@ -19,6 +19,7 @@ declare class ClientFactory {
19
19
  * @returns Subclass of telemetry Client class
20
20
  */
21
21
  static getTelemetryClientByClass<T extends Client>(clientConstructor: new (appKey: string, extensionName: string, extensionVersion: string) => T): T;
22
+ private static buildConnectionString;
22
23
  }
23
24
  export { ClientFactory };
24
25
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,6 @@
1
1
  import { ToolsSuiteTelemetryClient } from '../../tooling-telemetry/index.js';
2
2
  import { TelemetrySettings } from '../config-state.js';
3
+ const instrumentationKeyPlaceholder = 'ApplicationInsightsInstrumentationKeyPLACEH0LDER';
3
4
  /**
4
5
  * Factory to get telemetry client instance.
5
6
  */
@@ -25,11 +26,19 @@ class ClientFactory {
25
26
  if (client) {
26
27
  return client;
27
28
  }
28
- const ClientConstructor = clientConstructor;
29
- client = new ClientConstructor(TelemetrySettings.azureInstrumentationKey, TelemetrySettings.consumerModuleName, TelemetrySettings.consumerModuleVersion);
29
+ const connectionString = ClientFactory.buildConnectionString(TelemetrySettings.azureInstrumentationKey);
30
+ client = new clientConstructor(connectionString, TelemetrySettings.consumerModuleName, TelemetrySettings.consumerModuleVersion);
30
31
  ClientFactory.clientMap.set(clientConstructor.name, client);
31
32
  return client;
32
33
  }
34
+ static buildConnectionString(key) {
35
+ if (!key) {
36
+ return '';
37
+ }
38
+ // ApplicationInsights v3+ requires InstrumentationKey=<uuid> format
39
+ const instrumentationKey = key === instrumentationKeyPlaceholder ? '00000000-0000-0000-0000-000000000000' : key;
40
+ return `InstrumentationKey=${instrumentationKey}`;
41
+ }
33
42
  }
34
43
  export { ClientFactory };
35
44
  //# sourceMappingURL=index.js.map
@@ -7,7 +7,12 @@
7
7
  */
8
8
  export function configAzureTelemetryClient(client) {
9
9
  if (client.setUseDiskRetryCaching) {
10
- client.setUseDiskRetryCaching(true);
10
+ try {
11
+ client.setUseDiskRetryCaching(true);
12
+ }
13
+ catch {
14
+ // setUseDiskRetryCaching may throw "Not implemented"
15
+ }
11
16
  }
12
17
  client.addTelemetryProcessor((envelope /* TelemetryItem */) => {
13
18
  envelope.tags ??= {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap-ux/telemetry",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "Library for sending usage telemetry data",
5
5
  "type": "module",
6
6
  "repository": {