@sap-ux/telemetry 0.7.3 → 1.0.0

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 (46) hide show
  1. package/dist/base/client/azure-appinsight-client.d.ts +3 -3
  2. package/dist/base/client/azure-appinsight-client.js +22 -58
  3. package/dist/base/client/client.d.ts +1 -1
  4. package/dist/base/client/client.js +1 -4
  5. package/dist/base/client/index.d.ts +2 -2
  6. package/dist/base/client/index.js +5 -8
  7. package/dist/base/config-state.js +4 -10
  8. package/dist/base/decorator/index.d.ts +2 -2
  9. package/dist/base/decorator/index.js +4 -9
  10. package/dist/base/interceptor/config.js +4 -41
  11. package/dist/base/interceptor/index.d.ts +3 -3
  12. package/dist/base/interceptor/index.js +25 -34
  13. package/dist/base/performance/api.d.ts +2 -2
  14. package/dist/base/performance/api.js +14 -16
  15. package/dist/base/performance/entries.d.ts +2 -2
  16. package/dist/base/performance/entries.js +3 -7
  17. package/dist/base/performance/types.d.ts +2 -1
  18. package/dist/base/performance/types.js +2 -5
  19. package/dist/base/types/event-header.js +1 -4
  20. package/dist/base/types/event-name.js +2 -5
  21. package/dist/base/types/event.js +1 -2
  22. package/dist/base/types/index.d.ts +5 -5
  23. package/dist/base/types/index.js +5 -21
  24. package/dist/base/types/project-info.js +1 -2
  25. package/dist/base/types/sample-rate.js +2 -5
  26. package/dist/base/utils/azure-client-config.js +1 -4
  27. package/dist/base/utils/date.js +1 -5
  28. package/dist/base/utils/index.d.ts +5 -5
  29. package/dist/base/utils/index.js +5 -23
  30. package/dist/base/utils/logger.js +2 -6
  31. package/dist/base/utils/param-processing.js +10 -19
  32. package/dist/base/utils/reporting.js +10 -48
  33. package/dist/index.d.ts +14 -12
  34. package/dist/index.js +12 -32
  35. package/dist/tooling-telemetry/config-state.js +1 -4
  36. package/dist/tooling-telemetry/data-processor.d.ts +1 -1
  37. package/dist/tooling-telemetry/data-processor.js +73 -81
  38. package/dist/tooling-telemetry/index.d.ts +4 -4
  39. package/dist/tooling-telemetry/index.js +4 -23
  40. package/dist/tooling-telemetry/telemetry-client.d.ts +3 -3
  41. package/dist/tooling-telemetry/telemetry-client.js +9 -12
  42. package/dist/tooling-telemetry/telemetry-settings.d.ts +1 -1
  43. package/dist/tooling-telemetry/telemetry-settings.js +34 -43
  44. package/dist/tooling-telemetry/types.d.ts +1 -1
  45. package/dist/tooling-telemetry/types.js +8 -11
  46. package/package.json +11 -9
@@ -1,6 +1,6 @@
1
- import { Client } from './client';
2
- import { SampleRate } from '../types/sample-rate';
3
- import type { TelemetryMeasurements, TelemetryProperties } from '../types';
1
+ import { Client } from './client.js';
2
+ import { SampleRate } from '../types/sample-rate.js';
3
+ import type { TelemetryMeasurements, TelemetryProperties } from '../types/index.js';
4
4
  /**
5
5
  *
6
6
  */
@@ -1,49 +1,13 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ApplicationInsightClient = void 0;
37
- const client_1 = require("./client");
38
- const appInsights = __importStar(require("applicationinsights"));
39
- const event_header_1 = require("../types/event-header");
40
- const sample_rate_1 = require("../types/sample-rate");
41
- const azure_client_config_1 = require("../utils/azure-client-config");
42
- const config_state_1 = require("../config-state");
1
+ import { Client } from './client.js';
2
+ import * as appInsights from 'applicationinsights';
3
+ import { EventHeader } from '../types/event-header.js';
4
+ import { SampleRate } from '../types/sample-rate.js';
5
+ import { configAzureTelemetryClient } from '../utils/azure-client-config.js';
6
+ import { TelemetrySettings } from '../config-state.js';
43
7
  /**
44
8
  *
45
9
  */
46
- class ApplicationInsightClient extends client_1.Client {
10
+ class ApplicationInsightClient extends Client {
47
11
  clients;
48
12
  /**
49
13
  *
@@ -57,12 +21,12 @@ class ApplicationInsightClient extends client_1.Client {
57
21
  this.applicationKey = applicationKey;
58
22
  this.extensionVersion = extensionVersion;
59
23
  this.extensionName = extensionName;
60
- const clientOnePercent = this.createTelemetryClient(sample_rate_1.SampleRate.OnePercent);
61
- const clientTenPercent = this.createTelemetryClient(sample_rate_1.SampleRate.TenPercent);
62
- const clientNoSampling = this.createTelemetryClient(sample_rate_1.SampleRate.NoSampling);
63
- this.clients.set(sample_rate_1.SampleRate.OnePercent, clientOnePercent);
64
- this.clients.set(sample_rate_1.SampleRate.TenPercent, clientTenPercent);
65
- this.clients.set(sample_rate_1.SampleRate.NoSampling, clientNoSampling);
24
+ const clientOnePercent = this.createTelemetryClient(SampleRate.OnePercent);
25
+ const clientTenPercent = this.createTelemetryClient(SampleRate.TenPercent);
26
+ const clientNoSampling = this.createTelemetryClient(SampleRate.NoSampling);
27
+ this.clients.set(SampleRate.OnePercent, clientOnePercent);
28
+ this.clients.set(SampleRate.TenPercent, clientTenPercent);
29
+ this.clients.set(SampleRate.NoSampling, clientNoSampling);
66
30
  }
67
31
  /**
68
32
  * Send a telemetry event to Azure Application Insights. This API makes sure the telemetry event
@@ -78,7 +42,7 @@ class ApplicationInsightClient extends client_1.Client {
78
42
  * @returns Promise<void>
79
43
  */
80
44
  reportBlocking(eventName, properties, measurements, sampleRate, ignoreSettings = false) {
81
- if (!ignoreSettings || config_state_1.TelemetrySettings.telemetryEnabled) {
45
+ if (!ignoreSettings || TelemetrySettings.telemetryEnabled) {
82
46
  const { client, event } = this.prepareClientAndEvent(eventName, properties, measurements, sampleRate);
83
47
  return this.trackEventBlocking(client, event);
84
48
  }
@@ -97,7 +61,7 @@ class ApplicationInsightClient extends client_1.Client {
97
61
  * @param ignoreSettings Ignore telemetryEnabled settings and skip submitting telemetry data
98
62
  */
99
63
  async report(eventName, properties, measurements, sampleRate, telemetryHelperProperties, ignoreSettings) {
100
- if ((ignoreSettings !== undefined && !ignoreSettings) || !config_state_1.TelemetrySettings.telemetryEnabled) {
64
+ if ((ignoreSettings !== undefined && !ignoreSettings) || !TelemetrySettings.telemetryEnabled) {
101
65
  return;
102
66
  }
103
67
  const { client, event } = this.prepareClientAndEvent(eventName, properties, measurements, sampleRate);
@@ -112,9 +76,9 @@ class ApplicationInsightClient extends client_1.Client {
112
76
  * @param sampleRate Sampling the event to be sent
113
77
  * @returns TelemetryClient instance and telemetry event
114
78
  */
115
- prepareClientAndEvent(eventName, properties, measurements, sampleRate = sample_rate_1.SampleRate.NoSampling) {
79
+ prepareClientAndEvent(eventName, properties, measurements, sampleRate = SampleRate.NoSampling) {
116
80
  const client = this.clients.get(sampleRate);
117
- const eventHeader = new event_header_1.EventHeader(this.extensionName, eventName);
81
+ const eventHeader = new EventHeader(this.extensionName, eventName);
118
82
  const event = {
119
83
  name: eventHeader.toString(),
120
84
  properties: properties,
@@ -172,22 +136,22 @@ class ApplicationInsightClient extends client_1.Client {
172
136
  createTelemetryClient(sampleRate) {
173
137
  let sampleRateNumer;
174
138
  switch (sampleRate) {
175
- case sample_rate_1.SampleRate.OnePercent:
139
+ case SampleRate.OnePercent:
176
140
  sampleRateNumer = 1;
177
141
  break;
178
- case sample_rate_1.SampleRate.TenPercent:
142
+ case SampleRate.TenPercent:
179
143
  sampleRateNumer = 10;
180
144
  break;
181
- case sample_rate_1.SampleRate.NoSampling:
145
+ case SampleRate.NoSampling:
182
146
  default:
183
147
  sampleRateNumer = 100;
184
148
  break;
185
149
  }
186
150
  const client = new appInsights.TelemetryClient(this.applicationKey);
187
151
  client.config.samplingPercentage = sampleRateNumer;
188
- (0, azure_client_config_1.configAzureTelemetryClient)(client);
152
+ configAzureTelemetryClient(client);
189
153
  return client;
190
154
  }
191
155
  }
192
- exports.ApplicationInsightClient = ApplicationInsightClient;
156
+ export { ApplicationInsightClient };
193
157
  //# sourceMappingURL=azure-appinsight-client.js.map
@@ -1,4 +1,4 @@
1
- import type { SampleRate } from '../types/sample-rate';
1
+ import type { SampleRate } from '../types/sample-rate.js';
2
2
  /**
3
3
  *
4
4
  */
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Client = void 0;
4
1
  /**
5
2
  *
6
3
  */
@@ -27,5 +24,5 @@ class Client {
27
24
  return this.extensionName;
28
25
  }
29
26
  }
30
- exports.Client = Client;
27
+ export { Client };
31
28
  //# sourceMappingURL=client.js.map
@@ -1,5 +1,5 @@
1
- import type { Client } from './client';
2
- import { ToolsSuiteTelemetryClient } from '../../tooling-telemetry';
1
+ import type { Client } from './client.js';
2
+ import { ToolsSuiteTelemetryClient } from '../../tooling-telemetry/index.js';
3
3
  /**
4
4
  * Factory to get telemetry client instance.
5
5
  */
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ClientFactory = void 0;
4
- const tooling_telemetry_1 = require("../../tooling-telemetry");
5
- const config_state_1 = require("../config-state");
1
+ import { ToolsSuiteTelemetryClient } from '../../tooling-telemetry/index.js';
2
+ import { TelemetrySettings } from '../config-state.js';
6
3
  /**
7
4
  * Factory to get telemetry client instance.
8
5
  */
@@ -14,7 +11,7 @@ class ClientFactory {
14
11
  * @returns Telemetry client for Azure app insights
15
12
  */
16
13
  static getTelemetryClient() {
17
- return ClientFactory.getTelemetryClientByClass(tooling_telemetry_1.ToolsSuiteTelemetryClient);
14
+ return ClientFactory.getTelemetryClientByClass(ToolsSuiteTelemetryClient);
18
15
  }
19
16
  /**
20
17
  * Get singleton instance of telemetry client based on the generics type. Currently, we only support
@@ -29,10 +26,10 @@ class ClientFactory {
29
26
  return client;
30
27
  }
31
28
  const ClientConstructor = clientConstructor;
32
- client = new ClientConstructor(config_state_1.TelemetrySettings.azureInstrumentationKey, config_state_1.TelemetrySettings.consumerModuleName, config_state_1.TelemetrySettings.consumerModuleVersion);
29
+ client = new ClientConstructor(TelemetrySettings.azureInstrumentationKey, TelemetrySettings.consumerModuleName, TelemetrySettings.consumerModuleVersion);
33
30
  ClientFactory.clientMap.set(clientConstructor.name, client);
34
31
  return client;
35
32
  }
36
33
  }
37
- exports.ClientFactory = ClientFactory;
34
+ export { ClientFactory };
38
35
  //# sourceMappingURL=index.js.map
@@ -1,22 +1,16 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.TelemetrySettings = void 0;
7
- const package_json_1 = __importDefault(require("../../package.json"));
1
+ import packageJson from '../../package.json' with { type: 'json' };
8
2
  /**
9
3
  * Runtime telemetry settings
10
4
  */
11
- exports.TelemetrySettings = {
5
+ export const TelemetrySettings = {
12
6
  // Target Azure apps insight destination
13
7
  azureInstrumentationKey: '',
14
8
  // Allow user to opt out from telemetry collection
15
9
  telemetryEnabled: true,
16
10
  // Module name in telemetry/pacakge.json
17
- telemetryLibName: package_json_1.default.name,
11
+ telemetryLibName: packageJson.name,
18
12
  // Version in telemetry/pacakge.json
19
- telemetryLibVersion: package_json_1.default.version,
13
+ telemetryLibVersion: packageJson.version,
20
14
  // Name of module that uses telemetry library
21
15
  consumerModuleName: '',
22
16
  // Version of module that uses telemetry library
@@ -1,5 +1,5 @@
1
- import type { SampleRate } from '../types/sample-rate';
2
- import type { ParamRecordConfig } from '../utils/param-processing';
1
+ import type { SampleRate } from '../types/sample-rate.js';
2
+ import type { ParamRecordConfig } from '../utils/param-processing.js';
3
3
  /**
4
4
  * Decorator used to log a telemetry event.
5
5
  *
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.logTelemetryAsync = exports.logTelemetry = void 0;
4
- const config_1 = require("../interceptor/config");
1
+ import { interceptorTypesMapping, asyncInterceptorTypesMapping } from '../interceptor/config.js';
5
2
  const decorCommon = (isAsync, target, descriptor, evtName, interceptorType, sampleRate, paramsCapturingInstructions) => {
6
3
  const originalMethod = descriptor.value;
7
- const interceptorTypesMap = isAsync ? config_1.asyncInterceptorTypesMapping : config_1.interceptorTypesMapping;
4
+ const interceptorTypesMap = isAsync ? asyncInterceptorTypesMapping : interceptorTypesMapping;
8
5
  const interceptor = interceptorTypesMap.get(interceptorType);
9
6
  descriptor.value = interceptor(target, originalMethod, evtName, sampleRate, paramsCapturingInstructions);
10
7
  };
@@ -17,12 +14,11 @@ const decorCommon = (isAsync, target, descriptor, evtName, interceptorType, samp
17
14
  * @param paramsCapturingInstructions - Optional param, Should be passed when interceptor of type CAPTURE_PARAM being used. As single instance or array of instances (when multiple params should be captured or some additional sumbission data should be predefined). Allows predefine property name, value or specify paths to value to be captured (if it's element of array or nested in object)
18
15
  * @returns function
19
16
  */
20
- const logTelemetry = (evtName, interceptorType, sampleRate, paramsCapturingInstructions) => {
17
+ export const logTelemetry = (evtName, interceptorType, sampleRate, paramsCapturingInstructions) => {
21
18
  return (target, functionName, descriptor) => {
22
19
  decorCommon(false, target, descriptor, evtName, interceptorType, sampleRate, paramsCapturingInstructions);
23
20
  };
24
21
  };
25
- exports.logTelemetry = logTelemetry;
26
22
  /**
27
23
  * Decorator to log telemetry asynchronously.
28
24
  *
@@ -32,10 +28,9 @@ exports.logTelemetry = logTelemetry;
32
28
  * @param paramsCapturingInstructions - Optional param, Should be passed when interceptor of type CAPTURE_PARAM being used. As single instance or array of instances (when multiple params should be captured or some additional sumbission data should be predefined). Allows predefine property name, value or specify paths to value to be captured (if it's element of array or nested in object)
33
29
  * @returns function
34
30
  */
35
- const logTelemetryAsync = (evtName, interceptorType, sampleRate, paramsCapturingInstructions) => {
31
+ export const logTelemetryAsync = (evtName, interceptorType, sampleRate, paramsCapturingInstructions) => {
36
32
  return (target, functionName, descriptor) => {
37
33
  decorCommon(true, target, descriptor, evtName, interceptorType, sampleRate, paramsCapturingInstructions);
38
34
  };
39
35
  };
40
- exports.logTelemetryAsync = logTelemetryAsync;
41
36
  //# sourceMappingURL=index.js.map
@@ -1,41 +1,5 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.asyncInterceptorTypesMapping = exports.interceptorTypesMapping = exports.InterceptorTypes = void 0;
37
- const interceptors = __importStar(require("./index"));
38
- var InterceptorTypes;
1
+ import * as interceptors from './index.js';
2
+ export var InterceptorTypes;
39
3
  (function (InterceptorTypes) {
40
4
  /**
41
5
  * Simple notification interceptor, reports certain event
@@ -50,15 +14,14 @@ var InterceptorTypes;
50
14
  * Captures specified in paramCaptureConfig parameter of decorated method.
51
15
  */
52
16
  InterceptorTypes["CAPTURE_PARAM"] = "captureParam";
53
- })(InterceptorTypes || (exports.InterceptorTypes = InterceptorTypes = {}));
17
+ })(InterceptorTypes || (InterceptorTypes = {}));
54
18
  const interceptorTypesMapping = new Map();
55
- exports.interceptorTypesMapping = interceptorTypesMapping;
56
19
  interceptorTypesMapping.set(InterceptorTypes.NOTIFICATION, interceptors.notify);
57
20
  interceptorTypesMapping.set(InterceptorTypes.DURATION, interceptors.duration);
58
21
  interceptorTypesMapping.set(InterceptorTypes.CAPTURE_PARAM, interceptors.captureParam);
59
22
  const asyncInterceptorTypesMapping = new Map();
60
- exports.asyncInterceptorTypesMapping = asyncInterceptorTypesMapping;
61
23
  asyncInterceptorTypesMapping.set(InterceptorTypes.NOTIFICATION, interceptors.notifyAsync);
62
24
  asyncInterceptorTypesMapping.set(InterceptorTypes.DURATION, interceptors.durationAsync);
63
25
  asyncInterceptorTypesMapping.set(InterceptorTypes.CAPTURE_PARAM, interceptors.captureParamAsync);
26
+ export { interceptorTypesMapping, asyncInterceptorTypesMapping };
64
27
  //# sourceMappingURL=config.js.map
@@ -1,6 +1,6 @@
1
- import type { EventName } from '../types/event-name';
2
- import type { SampleRate } from '../types/sample-rate';
3
- import type { ParamRecordConfig } from '../utils/param-processing';
1
+ import type { EventName } from '../types/event-name.js';
2
+ import type { SampleRate } from '../types/sample-rate.js';
3
+ import type { ParamRecordConfig } from '../utils/param-processing.js';
4
4
  export declare const notify: (target: Record<string, object>, originalFn: Function, evtName: EventName, sampleRate: SampleRate) => Function;
5
5
  export declare const notifyAsync: (target: Record<string, object>, originalFn: Function, evtName: EventName, sampleRate: SampleRate) => Function;
6
6
  export declare const duration: (target: Record<string, object>, originalFn: Function, evtName: EventName, sampleRate: SampleRate) => Function;
@@ -1,77 +1,68 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.captureParamAsync = exports.captureParam = exports.durationAsync = exports.duration = exports.notifyAsync = exports.notify = void 0;
4
- const client_1 = require("../client");
5
- const api_1 = require("../performance/api");
6
- const param_processing_1 = require("../utils/param-processing");
7
- const notify = (target, originalFn, evtName, sampleRate) => {
1
+ import { ClientFactory } from '../client/index.js';
2
+ import { PerformanceMeasurementAPI as performance } from '../performance/api.js';
3
+ import { getParamsData } from '../utils/param-processing.js';
4
+ export const notify = (target, originalFn, evtName, sampleRate) => {
8
5
  return (...args) => {
9
6
  const result = originalFn.apply(target, args);
10
- const appinsightClient = client_1.ClientFactory.getTelemetryClient();
7
+ const appinsightClient = ClientFactory.getTelemetryClient();
11
8
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
12
9
  appinsightClient.report(evtName, {}, {}, sampleRate);
13
10
  return result;
14
11
  };
15
12
  };
16
- exports.notify = notify;
17
- const notifyAsync = (target, originalFn, evtName, sampleRate) => {
13
+ export const notifyAsync = (target, originalFn, evtName, sampleRate) => {
18
14
  return async (...args) => {
19
15
  const result = await originalFn.apply(target, args);
20
- const appinsightClient = client_1.ClientFactory.getTelemetryClient();
16
+ const appinsightClient = ClientFactory.getTelemetryClient();
21
17
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
22
18
  appinsightClient.report(evtName, {}, {}, sampleRate);
23
19
  return result;
24
20
  };
25
21
  };
26
- exports.notifyAsync = notifyAsync;
27
- const duration = (target, originalFn, evtName, sampleRate) => {
22
+ export const duration = (target, originalFn, evtName, sampleRate) => {
28
23
  return (...args) => {
29
- const markName = api_1.PerformanceMeasurementAPI.startMark('mark');
24
+ const markName = performance.startMark('mark');
30
25
  const result = originalFn.apply(target, args);
31
- api_1.PerformanceMeasurementAPI.endMark(markName);
32
- api_1.PerformanceMeasurementAPI.measure(markName);
33
- const duration = api_1.PerformanceMeasurementAPI.getMeasurementDuration(markName);
34
- const appinsightClient = client_1.ClientFactory.getTelemetryClient();
26
+ performance.endMark(markName);
27
+ performance.measure(markName);
28
+ const duration = performance.getMeasurementDuration(markName);
29
+ const appinsightClient = ClientFactory.getTelemetryClient();
35
30
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
36
31
  appinsightClient.report(evtName, {}, { ms: duration }, sampleRate);
37
32
  return result;
38
33
  };
39
34
  };
40
- exports.duration = duration;
41
- const durationAsync = (target, originalFn, evtName, sampleRate) => {
35
+ export const durationAsync = (target, originalFn, evtName, sampleRate) => {
42
36
  return async (...args) => {
43
- const markName = api_1.PerformanceMeasurementAPI.startMark('mark');
37
+ const markName = performance.startMark('mark');
44
38
  const result = await originalFn.apply(target, args);
45
- api_1.PerformanceMeasurementAPI.endMark(markName);
46
- api_1.PerformanceMeasurementAPI.measure(markName);
47
- const duration = api_1.PerformanceMeasurementAPI.getMeasurementDuration(markName);
48
- const appinsightClient = client_1.ClientFactory.getTelemetryClient();
39
+ performance.endMark(markName);
40
+ performance.measure(markName);
41
+ const duration = performance.getMeasurementDuration(markName);
42
+ const appinsightClient = ClientFactory.getTelemetryClient();
49
43
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
50
44
  appinsightClient.report(evtName, {}, { ms: duration }, sampleRate);
51
45
  return result;
52
46
  };
53
47
  };
54
- exports.durationAsync = durationAsync;
55
- const captureParam = (target, originalFn, evtName, sampleRate, instructions) => {
48
+ export const captureParam = (target, originalFn, evtName, sampleRate, instructions) => {
56
49
  return (...args) => {
57
50
  const result = originalFn.apply(target, args);
58
- const [customDimensions, customMeasurements] = (0, param_processing_1.getParamsData)(args, instructions);
59
- const appinsightClient = client_1.ClientFactory.getTelemetryClient();
51
+ const [customDimensions, customMeasurements] = getParamsData(args, instructions);
52
+ const appinsightClient = ClientFactory.getTelemetryClient();
60
53
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
61
54
  appinsightClient.report(evtName, customDimensions, customMeasurements, sampleRate);
62
55
  return result;
63
56
  };
64
57
  };
65
- exports.captureParam = captureParam;
66
- const captureParamAsync = (target, originalFn, evtName, sampleRate, instructions) => {
58
+ export const captureParamAsync = (target, originalFn, evtName, sampleRate, instructions) => {
67
59
  return async (...args) => {
68
60
  const result = await originalFn.apply(target, args);
69
- const [customDimensions, customMeasurements] = (0, param_processing_1.getParamsData)(args, instructions);
70
- const appinsightClient = client_1.ClientFactory.getTelemetryClient();
61
+ const [customDimensions, customMeasurements] = getParamsData(args, instructions);
62
+ const appinsightClient = ClientFactory.getTelemetryClient();
71
63
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
72
64
  appinsightClient.report(evtName, customDimensions, customMeasurements, sampleRate);
73
65
  return result;
74
66
  };
75
67
  };
76
- exports.captureParamAsync = captureParamAsync;
77
68
  //# sourceMappingURL=index.js.map
@@ -1,5 +1,5 @@
1
- import type { EntriesArray } from './types';
2
- import { EntryType, PerformanceMeasurement } from './types';
1
+ import type { EntriesArray } from './types.js';
2
+ import { EntryType, PerformanceMeasurement } from './types.js';
3
3
  /**
4
4
  *
5
5
  */
@@ -1,13 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PerformanceMeasurementAPI = void 0;
4
- const entries_1 = require("./entries");
5
- const types_1 = require("./types");
6
- const performanceNow = require("performance-now");
1
+ import { Mark, Measurement } from './entries.js';
2
+ import { EntryType, PerformanceMeasurement } from './types.js';
3
+ import { performance } from 'node:perf_hooks';
4
+ const performanceNow = () => performance.now();
7
5
  /**
8
6
  *
9
7
  */
10
- class PerformanceMeasurementAPI extends types_1.PerformanceMeasurement {
8
+ class PerformanceMeasurementAPI extends PerformanceMeasurement {
11
9
  static initTiming;
12
10
  static now = performanceNow;
13
11
  static entries = [];
@@ -23,7 +21,7 @@ class PerformanceMeasurementAPI extends types_1.PerformanceMeasurement {
23
21
  * @param timing Timestamp when mark is created, measured in ms
24
22
  */
25
23
  static mark(name, type, timing) {
26
- const entry = new entries_1.Mark(name, type, timing);
24
+ const entry = new Mark(name, type, timing);
27
25
  PerformanceMeasurementAPI.entries.push(entry);
28
26
  }
29
27
  /**
@@ -35,7 +33,7 @@ class PerformanceMeasurementAPI extends types_1.PerformanceMeasurement {
35
33
  static startMark(name) {
36
34
  const timing = PerformanceMeasurementAPI.now();
37
35
  const extendedName = name + timing;
38
- PerformanceMeasurementAPI.mark(extendedName, types_1.EntryType.START_MARK, timing);
36
+ PerformanceMeasurementAPI.mark(extendedName, EntryType.START_MARK, timing);
39
37
  return extendedName;
40
38
  }
41
39
  /**
@@ -45,7 +43,7 @@ class PerformanceMeasurementAPI extends types_1.PerformanceMeasurement {
45
43
  */
46
44
  static endMark(name) {
47
45
  const timing = PerformanceMeasurementAPI.now();
48
- PerformanceMeasurementAPI.mark(name, types_1.EntryType.END_MARK, timing);
46
+ PerformanceMeasurementAPI.mark(name, EntryType.END_MARK, timing);
49
47
  }
50
48
  /**
51
49
  * Measure execution time lenght of a given mark name.
@@ -53,19 +51,19 @@ class PerformanceMeasurementAPI extends types_1.PerformanceMeasurement {
53
51
  * @param markName Name of mark
54
52
  */
55
53
  static measure(markName) {
56
- const startMark = PerformanceMeasurementAPI.getEntriesByNameType(markName, types_1.EntryType.START_MARK).slice(-1)[0];
57
- const endMark = PerformanceMeasurementAPI.getEntriesByNameType(markName, types_1.EntryType.END_MARK).slice(-1)[0];
54
+ const startMark = PerformanceMeasurementAPI.getEntriesByNameType(markName, EntryType.START_MARK).slice(-1)[0];
55
+ const endMark = PerformanceMeasurementAPI.getEntriesByNameType(markName, EntryType.END_MARK).slice(-1)[0];
58
56
  if (!startMark && !endMark) {
59
57
  throw new Error(`Failed to execute 'measure': mark '${markName}' doesn't exist.`);
60
58
  }
61
59
  else if (!startMark || !endMark) {
62
- const errMarkType = startMark ? types_1.EntryType.END_MARK : types_1.EntryType.START_MARK;
60
+ const errMarkType = startMark ? EntryType.END_MARK : EntryType.START_MARK;
63
61
  throw new Error(`Failed to execute 'measure': mark '${markName}'of type '${errMarkType}' doesn't exist.`);
64
62
  }
65
63
  const startTime = startMark.getStartTime();
66
64
  const endTime = endMark.getStartTime();
67
65
  const duration = endTime - startTime;
68
- const measurement = new entries_1.Measurement(`${markName}`, PerformanceMeasurementAPI.now(), duration);
66
+ const measurement = new Measurement(`${markName}`, PerformanceMeasurementAPI.now(), duration);
69
67
  PerformanceMeasurementAPI.entries.push(measurement);
70
68
  }
71
69
  /**
@@ -109,13 +107,13 @@ class PerformanceMeasurementAPI extends types_1.PerformanceMeasurement {
109
107
  * @returns time length in ms
110
108
  */
111
109
  static getMeasurementDuration(name) {
112
- const entry = PerformanceMeasurementAPI.getEntriesByNameType(name, types_1.EntryType.MEASUREMENT).slice(-1)[0];
110
+ const entry = PerformanceMeasurementAPI.getEntriesByNameType(name, EntryType.MEASUREMENT).slice(-1)[0];
113
111
  return entry.getDurationTime();
114
112
  }
115
113
  static clearEntries() {
116
114
  PerformanceMeasurementAPI.entries = [];
117
115
  }
118
116
  }
119
- exports.PerformanceMeasurementAPI = PerformanceMeasurementAPI;
120
117
  PerformanceMeasurementAPI.initialize();
118
+ export { PerformanceMeasurementAPI };
121
119
  //# sourceMappingURL=api.js.map
@@ -1,5 +1,5 @@
1
- import type { Measurement as IMeasurement, Mark as IMark } from './types';
2
- import { EntryType } from './types';
1
+ import type { Measurement as IMeasurement, Mark as IMark } from './types.js';
2
+ import { EntryType } from './types.js';
3
3
  /**
4
4
  * Repreeents a mark during a performance measurement.
5
5
  */
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Measurement = exports.Mark = void 0;
4
- const types_1 = require("./types");
1
+ import { EntryType } from './types.js';
5
2
  /**
6
3
  * Repreeents a mark during a performance measurement.
7
4
  */
@@ -28,7 +25,6 @@ class Mark {
28
25
  this.type = type;
29
26
  }
30
27
  }
31
- exports.Mark = Mark;
32
28
  /**
33
29
  * Measurement of execution time length
34
30
  */
@@ -42,7 +38,7 @@ class Measurement extends Mark {
42
38
  * @param duration time in millieseconds
43
39
  */
44
40
  constructor(name, startTime, duration) {
45
- super(name, types_1.EntryType.MEASUREMENT, startTime);
41
+ super(name, EntryType.MEASUREMENT, startTime);
46
42
  this.startTime = startTime;
47
43
  this.duration = duration;
48
44
  this.duration = duration;
@@ -54,5 +50,5 @@ class Measurement extends Mark {
54
50
  return this.duration;
55
51
  }
56
52
  }
57
- exports.Measurement = Measurement;
53
+ export { Mark, Measurement };
58
54
  //# sourceMappingURL=entries.js.map
@@ -31,5 +31,6 @@ declare abstract class PerformanceMeasurement {
31
31
  static getMeasurementDuration: (name: string) => number;
32
32
  static clearEntries: () => void;
33
33
  }
34
- export { EntryType, Mark, Measurement, EntriesArray, PerformanceMeasurement };
34
+ export { EntryType, PerformanceMeasurement };
35
+ export type { Mark, Measurement, EntriesArray };
35
36
  //# sourceMappingURL=types.d.ts.map
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PerformanceMeasurement = exports.EntryType = void 0;
4
1
  var EntryType;
5
2
  (function (EntryType) {
6
3
  EntryType["START_MARK"] = "START_MARK";
7
4
  EntryType["END_MARK"] = "END_MARK";
8
5
  EntryType["MEASUREMENT"] = "MEASUREMENT";
9
- })(EntryType || (exports.EntryType = EntryType = {}));
6
+ })(EntryType || (EntryType = {}));
10
7
  /**
11
8
  *
12
9
  */
@@ -24,5 +21,5 @@ class PerformanceMeasurement {
24
21
  static getMeasurementDuration;
25
22
  static clearEntries;
26
23
  }
27
- exports.PerformanceMeasurement = PerformanceMeasurement;
24
+ export { EntryType, PerformanceMeasurement };
28
25
  //# sourceMappingURL=types.js.map
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EventHeader = void 0;
4
1
  /**
5
2
  * Hierarchical event name for a telemetry event submitted to Auzre Application Insights.
6
3
  */
@@ -36,5 +33,5 @@ class EventHeader {
36
33
  return `${this.extensionName}/${this.eventName}`;
37
34
  }
38
35
  }
39
- exports.EventHeader = EventHeader;
36
+ export { EventHeader };
40
37
  //# sourceMappingURL=event-header.js.map