@sap-ux/telemetry 0.4.37 → 0.5.1

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.
@@ -22,15 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
25
  Object.defineProperty(exports, "__esModule", { value: true });
35
26
  exports.ApplicationInsightClient = void 0;
36
27
  const client_1 = require("./client");
@@ -43,6 +34,7 @@ const config_state_1 = require("../config-state");
43
34
  *
44
35
  */
45
36
  class ApplicationInsightClient extends client_1.Client {
37
+ clients;
46
38
  /**
47
39
  *
48
40
  * @param applicationKey Application key to identify the Azure Application Insight resource
@@ -94,14 +86,12 @@ class ApplicationInsightClient extends client_1.Client {
94
86
  * @param telemetryHelperProperties Properties that are passed to specific TelemetryClient for generating specific properties (E.g. ToolsSuiteTelemetryClient)
95
87
  * @param ignoreSettings Ignore telemetryEnabled settings and skip submitting telemetry data
96
88
  */
97
- report(eventName, properties, measurements, sampleRate, telemetryHelperProperties, ignoreSettings) {
98
- return __awaiter(this, void 0, void 0, function* () {
99
- if ((ignoreSettings !== undefined && !ignoreSettings) || !config_state_1.TelemetrySettings.telemetryEnabled) {
100
- return;
101
- }
102
- const { client, event } = this.prepareClientAndEvent(eventName, properties, measurements, sampleRate);
103
- this.trackEvent(client, event);
104
- });
89
+ async report(eventName, properties, measurements, sampleRate, telemetryHelperProperties, ignoreSettings) {
90
+ if ((ignoreSettings !== undefined && !ignoreSettings) || !config_state_1.TelemetrySettings.telemetryEnabled) {
91
+ return;
92
+ }
93
+ const { client, event } = this.prepareClientAndEvent(eventName, properties, measurements, sampleRate);
94
+ this.trackEvent(client, event);
105
95
  }
106
96
  /**
107
97
  * Provide specification of telemetry event to be sent.
@@ -133,22 +123,20 @@ class ApplicationInsightClient extends client_1.Client {
133
123
  * @param event Telemetry event
134
124
  * @returns Promise<void>
135
125
  */
136
- trackEventBlocking(client, event) {
137
- return __awaiter(this, void 0, void 0, function* () {
138
- if (process.env.SAP_UX_FIORI_TOOLS_DISABLE_TELEMETRY === 'true') {
139
- return Promise.resolve();
126
+ async trackEventBlocking(client, event) {
127
+ if (process.env.SAP_UX_FIORI_TOOLS_DISABLE_TELEMETRY === 'true') {
128
+ return Promise.resolve();
129
+ }
130
+ return new Promise((resolve, reject) => {
131
+ try {
132
+ client.trackEvent(event);
133
+ client.flush({
134
+ callback: () => resolve()
135
+ });
136
+ }
137
+ catch (error) {
138
+ reject(error);
140
139
  }
141
- return new Promise((resolve, reject) => {
142
- try {
143
- client.trackEvent(event);
144
- client.flush({
145
- callback: () => resolve()
146
- });
147
- }
148
- catch (error) {
149
- reject(error);
150
- }
151
- });
152
140
  });
153
141
  }
154
142
  /**
@@ -5,11 +5,9 @@ exports.Client = void 0;
5
5
  *
6
6
  */
7
7
  class Client {
8
- constructor() {
9
- this.applicationKey = '';
10
- this.extensionName = '';
11
- this.extensionVersion = '';
12
- }
8
+ applicationKey = '';
9
+ extensionName = '';
10
+ extensionVersion = '';
13
11
  /**
14
12
  * @returns Target Azure application insights resource Id
15
13
  */
@@ -7,6 +7,7 @@ const config_state_1 = require("../config-state");
7
7
  * Factory to get telemetry client instance.
8
8
  */
9
9
  class ClientFactory {
10
+ static clientMap = new Map();
10
11
  /**
11
12
  * Get singleton instance of default telemetry client for Azure app insights.
12
13
  *
@@ -34,5 +35,4 @@ class ClientFactory {
34
35
  }
35
36
  }
36
37
  exports.ClientFactory = ClientFactory;
37
- ClientFactory.clientMap = new Map();
38
38
  //# sourceMappingURL=index.js.map
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.captureParamAsync = exports.captureParam = exports.durationAsync = exports.duration = exports.notifyAsync = exports.notify = void 0;
13
4
  const client_1 = require("../client");
@@ -24,13 +15,13 @@ const notify = (target, originalFn, evtName, sampleRate) => {
24
15
  };
25
16
  exports.notify = notify;
26
17
  const notifyAsync = (target, originalFn, evtName, sampleRate) => {
27
- return (...args) => __awaiter(void 0, void 0, void 0, function* () {
28
- const result = yield originalFn.apply(target, args);
18
+ return async (...args) => {
19
+ const result = await originalFn.apply(target, args);
29
20
  const appinsightClient = client_1.ClientFactory.getTelemetryClient();
30
21
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
31
22
  appinsightClient.report(evtName, {}, {}, sampleRate);
32
23
  return result;
33
- });
24
+ };
34
25
  };
35
26
  exports.notifyAsync = notifyAsync;
36
27
  const duration = (target, originalFn, evtName, sampleRate) => {
@@ -50,9 +41,9 @@ const duration = (target, originalFn, evtName, sampleRate) => {
50
41
  exports.duration = duration;
51
42
  const durationAsync = (target, originalFn, evtName, sampleRate) => {
52
43
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
- return (...args) => __awaiter(void 0, void 0, void 0, function* () {
44
+ return async (...args) => {
54
45
  const markName = api_1.PerformanceMeasurementAPI.startMark('mark');
55
- const result = yield originalFn.apply(target, args);
46
+ const result = await originalFn.apply(target, args);
56
47
  api_1.PerformanceMeasurementAPI.endMark(markName);
57
48
  api_1.PerformanceMeasurementAPI.measure(markName);
58
49
  const duration = api_1.PerformanceMeasurementAPI.getMeasurementDuration(markName);
@@ -60,7 +51,7 @@ const durationAsync = (target, originalFn, evtName, sampleRate) => {
60
51
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
61
52
  appinsightClient.report(evtName, {}, { ms: duration }, sampleRate);
62
53
  return result;
63
- });
54
+ };
64
55
  };
65
56
  exports.durationAsync = durationAsync;
66
57
  const captureParam = (target, originalFn, evtName, sampleRate, instructions) => {
@@ -77,14 +68,14 @@ const captureParam = (target, originalFn, evtName, sampleRate, instructions) =>
77
68
  exports.captureParam = captureParam;
78
69
  const captureParamAsync = (target, originalFn, evtName, sampleRate, instructions) => {
79
70
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
80
- return (...args) => __awaiter(void 0, void 0, void 0, function* () {
81
- const result = yield originalFn.apply(target, args);
71
+ return async (...args) => {
72
+ const result = await originalFn.apply(target, args);
82
73
  const [customDimensions, customMeasurements] = (0, param_processing_1.getParamsData)(args, instructions);
83
74
  const appinsightClient = client_1.ClientFactory.getTelemetryClient();
84
75
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
85
76
  appinsightClient.report(evtName, customDimensions, customMeasurements, sampleRate);
86
77
  return result;
87
- });
78
+ };
88
79
  };
89
80
  exports.captureParamAsync = captureParamAsync;
90
81
  //# sourceMappingURL=index.js.map
@@ -8,6 +8,9 @@ const performanceNow = require("performance-now");
8
8
  *
9
9
  */
10
10
  class PerformanceMeasurementAPI extends types_1.PerformanceMeasurement {
11
+ static initTiming;
12
+ static now = performanceNow;
13
+ static entries = [];
11
14
  // reported time is relative to the time the current Node process has started (inferred from process.uptime())
12
15
  static initialize() {
13
16
  PerformanceMeasurementAPI.initTiming = PerformanceMeasurementAPI.now();
@@ -114,7 +117,5 @@ class PerformanceMeasurementAPI extends types_1.PerformanceMeasurement {
114
117
  }
115
118
  }
116
119
  exports.PerformanceMeasurementAPI = PerformanceMeasurementAPI;
117
- PerformanceMeasurementAPI.now = performanceNow;
118
- PerformanceMeasurementAPI.entries = [];
119
120
  PerformanceMeasurementAPI.initialize();
120
121
  //# sourceMappingURL=api.js.map
@@ -6,6 +6,9 @@ const types_1 = require("./types");
6
6
  * Repreeents a mark during a performance measurement.
7
7
  */
8
8
  class Mark {
9
+ startTime;
10
+ name;
11
+ type;
9
12
  /**
10
13
  * @returns start time in millieseconds
11
14
  */
@@ -30,6 +33,8 @@ exports.Mark = Mark;
30
33
  * Measurement of execution time length
31
34
  */
32
35
  class Measurement extends Mark {
36
+ startTime;
37
+ duration;
33
38
  /**
34
39
  *
35
40
  * @param name Name of a mark
@@ -11,6 +11,18 @@ var EntryType;
11
11
  *
12
12
  */
13
13
  class PerformanceMeasurement {
14
+ static initTiming;
15
+ static enteries;
16
+ static initialize;
17
+ static startMark;
18
+ static endMark;
19
+ static measure;
20
+ static getEntries;
21
+ static getEntriesByName;
22
+ static getEntriesByType;
23
+ static getEntriesByNameType;
24
+ static getMeasurementDuration;
25
+ static clearEntries;
14
26
  }
15
27
  exports.PerformanceMeasurement = PerformanceMeasurement;
16
28
  //# sourceMappingURL=types.js.map
@@ -5,6 +5,8 @@ exports.EventHeader = void 0;
5
5
  * Hierarchical event name for a telemetry event submitted to Auzre Application Insights.
6
6
  */
7
7
  class EventHeader {
8
+ extensionName;
9
+ eventName;
8
10
  /**
9
11
  * Event header that is composed of two parts.
10
12
  *
@@ -5,6 +5,7 @@ exports.getParamsData = exports.paramsProcessing = exports.getValue = exports.wr
5
5
  * ParamRecordConfigField
6
6
  */
7
7
  class ParamRecordConfigField {
8
+ path;
8
9
  /**
9
10
  *
10
11
  * @param path input path
@@ -18,6 +19,9 @@ exports.ParamRecordConfigField = ParamRecordConfigField;
18
19
  *
19
20
  */
20
21
  class ParamRecordConfig {
22
+ key;
23
+ value;
24
+ paramIndex;
21
25
  /**
22
26
  *
23
27
  * @param key - string or undefined;
@@ -90,8 +94,14 @@ instructions) => {
90
94
  if (Array.isArray(instructions)) {
91
95
  for (const instruction of instructions) {
92
96
  [processedDimensions, processedMeasurements] = (0, exports.paramsProcessing)(params, instruction);
93
- customDimensions = Object.assign(Object.assign({}, customDimensions), processedDimensions);
94
- customMeasurements = Object.assign(Object.assign({}, customMeasurements), processedMeasurements);
97
+ customDimensions = {
98
+ ...customDimensions,
99
+ ...processedDimensions
100
+ };
101
+ customMeasurements = {
102
+ ...customMeasurements,
103
+ ...processedMeasurements
104
+ };
95
105
  }
96
106
  }
97
107
  else {
@@ -65,8 +65,7 @@ const parseErrorStack = (errorStack) => {
65
65
  };
66
66
  let reportingTelemetryClient;
67
67
  const reportRuntimeError = (error) => {
68
- var _a;
69
- if (((_a = process.env.SAP_UX_FIORI_TOOLS_DISABLE_TELEMETRY) === null || _a === void 0 ? void 0 : _a.trim()) !== 'true') {
68
+ if (process.env.SAP_UX_FIORI_TOOLS_DISABLE_TELEMETRY?.trim() !== 'true') {
70
69
  reportingTelemetryClient = new appInsights.TelemetryClient(config_state_1.TelemetrySettings.azureInstrumentationKey);
71
70
  (0, azure_client_config_1.configAzureTelemetryClient)(reportingTelemetryClient);
72
71
  }
@@ -90,7 +89,10 @@ exports.reportRuntimeError = reportRuntimeError;
90
89
  const reportEnableTelemetryOnOff = (enableTelemetry, commonProperties) => {
91
90
  const telemetryEvent = {
92
91
  name: types_1.EventName.DISABLE_TELEMETRY,
93
- properties: Object.assign({ disableTelemetry: `${!enableTelemetry}` }, commonProperties),
92
+ properties: {
93
+ disableTelemetry: `${!enableTelemetry}`,
94
+ ...commonProperties
95
+ },
94
96
  measurements: {}
95
97
  };
96
98
  if (process.env.SAP_UX_FIORI_TOOLS_DISABLE_TELEMETRY !== 'true') {
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -41,15 +32,13 @@ const config_state_1 = require("./config-state");
41
32
  * @param telemetryHelperProperties Pass to report ApplicationInsightClient.report()
42
33
  * @returns Common Fiori project properties
43
34
  */
44
- function processToolsSuiteTelemetry(telemetryHelperProperties) {
45
- return __awaiter(this, void 0, void 0, function* () {
46
- const commonProperties = yield getCommonProperties();
47
- let appProperties = {};
48
- if (telemetryHelperProperties) {
49
- appProperties = yield getAppProperties(telemetryHelperProperties['appPath']);
50
- }
51
- return Object.assign(Object.assign({}, commonProperties), appProperties);
52
- });
35
+ async function processToolsSuiteTelemetry(telemetryHelperProperties) {
36
+ const commonProperties = await getCommonProperties();
37
+ let appProperties = {};
38
+ if (telemetryHelperProperties) {
39
+ appProperties = await getAppProperties(telemetryHelperProperties['appPath']);
40
+ }
41
+ return { ...commonProperties, ...appProperties };
53
42
  }
54
43
  exports.processToolsSuiteTelemetry = processToolsSuiteTelemetry;
55
44
  /**
@@ -57,18 +46,16 @@ exports.processToolsSuiteTelemetry = processToolsSuiteTelemetry;
57
46
  *
58
47
  * @returns Common properties
59
48
  */
60
- function getCommonProperties() {
61
- return __awaiter(this, void 0, void 0, function* () {
62
- const commonProperties = {};
63
- commonProperties[types_1.CommonProperties.DevSpace] = yield getSbasDevspace();
64
- commonProperties[types_1.CommonProperties.AppStudio] = (0, btp_utils_1.isAppStudio)();
65
- commonProperties[types_1.CommonProperties.AppStudioBackwardCompatible] = commonProperties[types_1.CommonProperties.AppStudio];
66
- commonProperties[types_1.CommonProperties.InternlVsExternal] = getInternalVsExternal();
67
- commonProperties[types_1.CommonProperties.InternlVsExternalBackwardCompatible] =
68
- commonProperties[types_1.CommonProperties.InternlVsExternal];
69
- commonProperties[types_1.CommonProperties.NodeVersion] = (yield getProcessVersions()).node;
70
- return commonProperties;
71
- });
49
+ async function getCommonProperties() {
50
+ const commonProperties = {};
51
+ commonProperties[types_1.CommonProperties.DevSpace] = await getSbasDevspace();
52
+ commonProperties[types_1.CommonProperties.AppStudio] = (0, btp_utils_1.isAppStudio)();
53
+ commonProperties[types_1.CommonProperties.AppStudioBackwardCompatible] = commonProperties[types_1.CommonProperties.AppStudio];
54
+ commonProperties[types_1.CommonProperties.InternlVsExternal] = getInternalVsExternal();
55
+ commonProperties[types_1.CommonProperties.InternlVsExternalBackwardCompatible] =
56
+ commonProperties[types_1.CommonProperties.InternlVsExternal];
57
+ commonProperties[types_1.CommonProperties.NodeVersion] = (await getProcessVersions()).node;
58
+ return commonProperties;
72
59
  }
73
60
  exports.getCommonProperties = getCommonProperties;
74
61
  /**
@@ -76,30 +63,27 @@ exports.getCommonProperties = getCommonProperties;
76
63
  *
77
64
  * @returns SBAS Dev Space Name. Empty string is returned if unable to fetch workspace type or the environment is not SBAS
78
65
  */
79
- function getSbasDevspace() {
80
- var _a, _b;
81
- return __awaiter(this, void 0, void 0, function* () {
82
- if ((0, btp_utils_1.isAppStudio)()) {
83
- try {
84
- if (!process.env.H2O_URL || !process.env.WORKSPACE_ID) {
85
- return '';
86
- }
87
- const h20Url = process.env.H2O_URL;
88
- const workspaceId = process.env.WORKSPACE_ID.replace('workspaces-', '');
89
- const url = `${h20Url}/ws-manager/api/v1/workspace/${workspaceId}`;
90
- const response = yield axios_1.default.get(url);
91
- if (response.data) {
92
- const workspaceConfig = response.data;
93
- // devspace stored in this path
94
- return (_b = (_a = workspaceConfig === null || workspaceConfig === void 0 ? void 0 : workspaceConfig.config) === null || _a === void 0 ? void 0 : _a.annotations) === null || _b === void 0 ? void 0 : _b.pack;
95
- }
66
+ async function getSbasDevspace() {
67
+ if ((0, btp_utils_1.isAppStudio)()) {
68
+ try {
69
+ if (!process.env.H2O_URL || !process.env.WORKSPACE_ID) {
70
+ return '';
96
71
  }
97
- catch (error) {
98
- // handling error
72
+ const h20Url = process.env.H2O_URL;
73
+ const workspaceId = process.env.WORKSPACE_ID.replace('workspaces-', '');
74
+ const url = `${h20Url}/ws-manager/api/v1/workspace/${workspaceId}`;
75
+ const response = await axios_1.default.get(url);
76
+ if (response.data) {
77
+ const workspaceConfig = response.data;
78
+ // devspace stored in this path
79
+ return workspaceConfig?.config?.annotations?.pack;
99
80
  }
100
81
  }
101
- return '';
102
- });
82
+ catch (error) {
83
+ // handling error
84
+ }
85
+ }
86
+ return '';
103
87
  }
104
88
  /**
105
89
  * Get common properties from a give Fiori project path.
@@ -107,33 +91,30 @@ function getSbasDevspace() {
107
91
  * @param appPath Fiori project path.
108
92
  * @returns Properties to be append to properties in telemetry event
109
93
  */
110
- function getAppProperties(appPath) {
111
- var _a, _b, _c;
112
- return __awaiter(this, void 0, void 0, function* () {
113
- if (!appPath) {
114
- return {};
115
- }
116
- const templateType = yield getTemplateType(appPath);
117
- const deployTarget = yield getDeployTarget(appPath);
118
- const applicationType = yield (0, info_1.getAppType)(appPath);
119
- let odataSource = yield getODataSource(appPath);
120
- // Correct logic in getAppType() implementation, if it's reuse lib type, odata source should be unknown
121
- if (applicationType === 'Fiori Reuse') {
122
- odataSource = types_1.ODataSource.UNKNOWN;
123
- }
124
- const sourceTemplate = yield getSourceTemplate(appPath);
125
- const appProgrammingLanguage = yield (0, info_1.getAppProgrammingLanguage)(appPath);
126
- const output = {};
127
- output[types_1.CommonProperties.TemplateType] = templateType;
128
- output[types_1.CommonProperties.DeployTargetType] = deployTarget;
129
- output[types_1.CommonProperties.ODataSourceType] = odataSource;
130
- output[types_1.CommonProperties.AppToolsId] = (_a = sourceTemplate.toolsId) !== null && _a !== void 0 ? _a : '';
131
- output[types_1.CommonProperties.AppProgrammingLanguage] = appProgrammingLanguage;
132
- output[types_1.CommonProperties.TemplateId] = (_b = sourceTemplate.id) !== null && _b !== void 0 ? _b : '';
133
- output[types_1.CommonProperties.TemplateVersion] = (_c = sourceTemplate.version) !== null && _c !== void 0 ? _c : '';
134
- output[types_1.CommonProperties.ApplicationType] = applicationType !== null && applicationType !== void 0 ? applicationType : '';
135
- return output;
136
- });
94
+ async function getAppProperties(appPath) {
95
+ if (!appPath) {
96
+ return {};
97
+ }
98
+ const templateType = await getTemplateType(appPath);
99
+ const deployTarget = await getDeployTarget(appPath);
100
+ const applicationType = await (0, info_1.getAppType)(appPath);
101
+ let odataSource = await getODataSource(appPath);
102
+ // Correct logic in getAppType() implementation, if it's reuse lib type, odata source should be unknown
103
+ if (applicationType === 'Fiori Reuse') {
104
+ odataSource = types_1.ODataSource.UNKNOWN;
105
+ }
106
+ const sourceTemplate = await getSourceTemplate(appPath);
107
+ const appProgrammingLanguage = await (0, info_1.getAppProgrammingLanguage)(appPath);
108
+ const output = {};
109
+ output[types_1.CommonProperties.TemplateType] = templateType;
110
+ output[types_1.CommonProperties.DeployTargetType] = deployTarget;
111
+ output[types_1.CommonProperties.ODataSourceType] = odataSource;
112
+ output[types_1.CommonProperties.AppToolsId] = sourceTemplate.toolsId ?? '';
113
+ output[types_1.CommonProperties.AppProgrammingLanguage] = appProgrammingLanguage;
114
+ output[types_1.CommonProperties.TemplateId] = sourceTemplate.id ?? '';
115
+ output[types_1.CommonProperties.TemplateVersion] = sourceTemplate.version ?? '';
116
+ output[types_1.CommonProperties.ApplicationType] = applicationType ?? '';
117
+ return output;
137
118
  }
138
119
  /**
139
120
  * Read template type from README.md of an Fiori app. This will be improved once we have the floor
@@ -142,29 +123,27 @@ function getAppProperties(appPath) {
142
123
  * @param appPath Root folder path of Fiori app
143
124
  * @returns Template type used in the Fiori app
144
125
  */
145
- function getTemplateType(appPath) {
146
- return __awaiter(this, void 0, void 0, function* () {
147
- const readmeFilePath = path_1.default.join(appPath, 'README.md');
148
- if (fs_1.default.existsSync(readmeFilePath)) {
149
- const readmeContent = yield fs_1.default.promises.readFile(readmeFilePath, 'utf-8');
150
- if (readmeContent) {
151
- let templateType = '';
152
- const lines = readmeContent.split(/\r?\n/);
153
- for (const line of lines) {
154
- // Check if the line matches the pattern |**Template Used**<br>{{TemplateType}}|
155
- const regex = /\|\*\*Template Used\*\*<br>(.*?)\|/;
156
- const match = regex.exec(line);
157
- if (match && match.length >= 2) {
158
- // Extract {{TemplateType}} from the matching pattern
159
- templateType = match[1].trim();
160
- break;
161
- }
126
+ async function getTemplateType(appPath) {
127
+ const readmeFilePath = path_1.default.join(appPath, 'README.md');
128
+ if (fs_1.default.existsSync(readmeFilePath)) {
129
+ const readmeContent = await fs_1.default.promises.readFile(readmeFilePath, 'utf-8');
130
+ if (readmeContent) {
131
+ let templateType = '';
132
+ const lines = readmeContent.split(/\r?\n/);
133
+ for (const line of lines) {
134
+ // Check if the line matches the pattern |**Template Used**<br>{{TemplateType}}|
135
+ const regex = /\|\*\*Template Used\*\*<br>(.*?)\|/;
136
+ const match = regex.exec(line);
137
+ if (match && match.length >= 2) {
138
+ // Extract {{TemplateType}} from the matching pattern
139
+ templateType = match[1].trim();
140
+ break;
162
141
  }
163
- return templateType;
164
142
  }
143
+ return templateType;
165
144
  }
166
- return '';
167
- });
145
+ }
146
+ return '';
168
147
  }
169
148
  /**
170
149
  * Find OData Source type of a given app folder path.
@@ -172,52 +151,50 @@ function getTemplateType(appPath) {
172
151
  * @param appPath Root folder path of Fiori app
173
152
  * @returns Project Type ABAP | CAPJava | CAPNode | UNKNOWN
174
153
  */
175
- function getODataSource(appPath) {
176
- return __awaiter(this, void 0, void 0, function* () {
154
+ async function getODataSource(appPath) {
155
+ try {
156
+ // First attempt: Loop up a folder that contain a pacakge.json that has sapux property as project root
157
+ // If appPath has package.json that contains sapux, it is EDMX project type and we derive odata source
158
+ // is ABAP.
159
+ let projectRoot;
177
160
  try {
178
- // First attempt: Loop up a folder that contain a pacakge.json that has sapux property as project root
179
- // If appPath has package.json that contains sapux, it is EDMX project type and we derive odata source
180
- // is ABAP.
181
- let projectRoot;
161
+ projectRoot = await (0, search_1.findProjectRoot)(appPath);
162
+ }
163
+ catch {
164
+ // No project root can be found
165
+ }
166
+ // Second attempt: For FF app, package.json does not have sapux property. Try to find the
167
+ // first parent folder that contain pacakge.json as CAP root. If no such folder exists,
168
+ // use appPath as project root.
169
+ if (!projectRoot) {
182
170
  try {
183
- projectRoot = yield (0, search_1.findProjectRoot)(appPath);
184
- }
185
- catch (_a) {
186
- // No project root can be found
187
- }
188
- // Second attempt: For FF app, package.json does not have sapux property. Try to find the
189
- // first parent folder that contain pacakge.json as CAP root. If no such folder exists,
190
- // use appPath as project root.
191
- if (!projectRoot) {
192
- try {
193
- const appParentFolder = path_1.default.dirname(appPath);
194
- projectRoot = yield (0, search_1.findProjectRoot)(appParentFolder, false);
195
- }
196
- catch (e) {
197
- // No project root can be found at parent folder.
198
- }
171
+ const appParentFolder = path_1.default.dirname(appPath);
172
+ projectRoot = await (0, search_1.findProjectRoot)(appParentFolder, false);
199
173
  }
200
- // Third attempt: CAPJava that doesn't have package.json at project root. We assume
201
- // the project has default structure <projectRoot>/app/<appPath>, and use parent folder
202
- // path two levels above appPath as projectRoot. This should cover most cases until we have
203
- // a better solution
204
- let isCapJavaWithoutPackageJson = false;
205
- if (!projectRoot) {
206
- const directParentFolder = path_1.default.dirname(appPath);
207
- const twoLevelUpParentFolder = path_1.default.dirname(directParentFolder);
208
- isCapJavaWithoutPackageJson = yield (0, cap_1.isCapJavaProject)(twoLevelUpParentFolder);
209
- projectRoot = isCapJavaWithoutPackageJson ? twoLevelUpParentFolder : appPath;
174
+ catch (e) {
175
+ // No project root can be found at parent folder.
210
176
  }
211
- if (isCapJavaWithoutPackageJson) {
212
- return types_1.ODataSource.CAPJava;
213
- }
214
- const projectType = yield (0, info_1.getProjectType)(projectRoot);
215
- return getProjectTypeForTelemetry(projectType);
216
177
  }
217
- catch (e) {
218
- return types_1.ODataSource.UNKNOWN;
178
+ // Third attempt: CAPJava that doesn't have package.json at project root. We assume
179
+ // the project has default structure <projectRoot>/app/<appPath>, and use parent folder
180
+ // path two levels above appPath as projectRoot. This should cover most cases until we have
181
+ // a better solution
182
+ let isCapJavaWithoutPackageJson = false;
183
+ if (!projectRoot) {
184
+ const directParentFolder = path_1.default.dirname(appPath);
185
+ const twoLevelUpParentFolder = path_1.default.dirname(directParentFolder);
186
+ isCapJavaWithoutPackageJson = await (0, cap_1.isCapJavaProject)(twoLevelUpParentFolder);
187
+ projectRoot = isCapJavaWithoutPackageJson ? twoLevelUpParentFolder : appPath;
219
188
  }
220
- });
189
+ if (isCapJavaWithoutPackageJson) {
190
+ return types_1.ODataSource.CAPJava;
191
+ }
192
+ const projectType = await (0, info_1.getProjectType)(projectRoot);
193
+ return getProjectTypeForTelemetry(projectType);
194
+ }
195
+ catch (e) {
196
+ return types_1.ODataSource.UNKNOWN;
197
+ }
221
198
  }
222
199
  /**
223
200
  * Map ProjectType to values used for telemetry reporting.
@@ -245,29 +222,26 @@ function getProjectTypeForTelemetry(projectType) {
245
222
  * @param appPath appPath Root folder path of Fiori app
246
223
  * @returns CF | ABAP | NO_DEPLOY_CONFIG | UNKNOWN_DEPLOY_CONFIG
247
224
  */
248
- function getDeployTarget(appPath) {
249
- var _a;
250
- return __awaiter(this, void 0, void 0, function* () {
251
- let deployTarget = types_1.DeployTarget.NO_DEPLOY_CONFIG;
252
- const deployConfigPath = path_1.default.join(appPath, 'ui5-deploy.yaml');
253
- try {
254
- yield fs_1.default.promises.access(deployConfigPath);
255
- const deployConfigContent = yield fs_1.default.promises.readFile(deployConfigPath, 'utf-8');
256
- const deployConfig = yaml_1.default.parse(deployConfigContent);
257
- const customTasks = (_a = deployConfig === null || deployConfig === void 0 ? void 0 : deployConfig.builder) === null || _a === void 0 ? void 0 : _a.customTasks;
258
- if (customTasks) {
259
- const isAbapDeployTarget = customTasks.some((task) => task.name === 'deploy-to-abap');
260
- deployTarget = isAbapDeployTarget ? types_1.DeployTarget.ABAP : types_1.DeployTarget.CF;
261
- }
262
- else {
263
- deployTarget = types_1.DeployTarget.UNKNOWN_DEPLOY_CONFIG;
264
- }
225
+ async function getDeployTarget(appPath) {
226
+ let deployTarget = types_1.DeployTarget.NO_DEPLOY_CONFIG;
227
+ const deployConfigPath = path_1.default.join(appPath, 'ui5-deploy.yaml');
228
+ try {
229
+ await fs_1.default.promises.access(deployConfigPath);
230
+ const deployConfigContent = await fs_1.default.promises.readFile(deployConfigPath, 'utf-8');
231
+ const deployConfig = yaml_1.default.parse(deployConfigContent);
232
+ const customTasks = deployConfig?.builder?.customTasks;
233
+ if (customTasks) {
234
+ const isAbapDeployTarget = customTasks.some((task) => task.name === 'deploy-to-abap');
235
+ deployTarget = isAbapDeployTarget ? types_1.DeployTarget.ABAP : types_1.DeployTarget.CF;
265
236
  }
266
- catch (_b) {
267
- // cannot determine deploy target, use default DeployTarget.NO_DEPLOY_CONFIG
237
+ else {
238
+ deployTarget = types_1.DeployTarget.UNKNOWN_DEPLOY_CONFIG;
268
239
  }
269
- return deployTarget;
270
- });
240
+ }
241
+ catch {
242
+ // cannot determine deploy target, use default DeployTarget.NO_DEPLOY_CONFIG
243
+ }
244
+ return deployTarget;
271
245
  }
272
246
  /**
273
247
  * Convert init setting property internalFeaturesEnabled to string value.
@@ -284,32 +258,29 @@ function getInternalVsExternal() {
284
258
  * @param {string} appPath - The file system path to the application directory.
285
259
  * @returns {Promise<SourceTemplate>} A promise that resolves to the source template configuration object.
286
260
  */
287
- function getSourceTemplate(appPath) {
288
- var _a, _b, _c;
289
- return __awaiter(this, void 0, void 0, function* () {
290
- const paths = {
291
- manifest: path_1.default.join(appPath, 'webapp', 'manifest.json'),
292
- appdescr: path_1.default.join(appPath, 'webapp', 'manifest.appdescr_variant'),
293
- ui5Yaml: path_1.default.join(appPath, 'ui5.yaml')
294
- };
295
- try {
296
- if (fs_1.default.existsSync(paths.manifest)) {
297
- const manifestStr = yield fs_1.default.promises.readFile(paths.manifest, 'utf-8');
298
- const manifest = JSON.parse(manifestStr);
299
- return populateSourceTemplate((_b = (_a = manifest['sap.app']) === null || _a === void 0 ? void 0 : _a.sourceTemplate) !== null && _b !== void 0 ? _b : {});
300
- }
301
- if (fs_1.default.existsSync(paths.appdescr) && fs_1.default.existsSync(paths.ui5Yaml)) {
302
- const baseUi5ConfigContent = yield fs_1.default.promises.readFile(paths.ui5Yaml, 'utf-8');
303
- const ui5Config = yield ui5_config_1.UI5Config.newInstance(baseUi5ConfigContent);
304
- const adp = ui5Config.getCustomConfiguration('adp');
305
- return populateSourceTemplate((_c = adp === null || adp === void 0 ? void 0 : adp.support) !== null && _c !== void 0 ? _c : {});
306
- }
261
+ async function getSourceTemplate(appPath) {
262
+ const paths = {
263
+ manifest: path_1.default.join(appPath, 'webapp', 'manifest.json'),
264
+ appdescr: path_1.default.join(appPath, 'webapp', 'manifest.appdescr_variant'),
265
+ ui5Yaml: path_1.default.join(appPath, 'ui5.yaml')
266
+ };
267
+ try {
268
+ if (fs_1.default.existsSync(paths.manifest)) {
269
+ const manifestStr = await fs_1.default.promises.readFile(paths.manifest, 'utf-8');
270
+ const manifest = JSON.parse(manifestStr);
271
+ return populateSourceTemplate(manifest['sap.app']?.sourceTemplate ?? {});
307
272
  }
308
- catch (_d) {
309
- // Failed to read manifest.json or manifest.appdescr_variant
273
+ if (fs_1.default.existsSync(paths.appdescr) && fs_1.default.existsSync(paths.ui5Yaml)) {
274
+ const baseUi5ConfigContent = await fs_1.default.promises.readFile(paths.ui5Yaml, 'utf-8');
275
+ const ui5Config = await ui5_config_1.UI5Config.newInstance(baseUi5ConfigContent);
276
+ const adp = ui5Config.getCustomConfiguration('adp');
277
+ return populateSourceTemplate(adp?.support ?? {});
310
278
  }
311
- return populateSourceTemplate({});
312
- });
279
+ }
280
+ catch {
281
+ // Failed to read manifest.json or manifest.appdescr_variant
282
+ }
283
+ return populateSourceTemplate({});
313
284
  }
314
285
  /**
315
286
  * Populates default values for the source template if not specified.
@@ -318,11 +289,10 @@ function getSourceTemplate(appPath) {
318
289
  * @returns {SourceTemplate} Source template with defaults populated.
319
290
  */
320
291
  function populateSourceTemplate(sourceTemplate) {
321
- var _a, _b, _c;
322
292
  return {
323
- id: (_a = sourceTemplate.id) !== null && _a !== void 0 ? _a : '',
324
- version: (_b = sourceTemplate.version) !== null && _b !== void 0 ? _b : '',
325
- toolsId: (_c = sourceTemplate.toolsId) !== null && _c !== void 0 ? _c : types_1.ToolsId.NO_TOOLS_ID
293
+ id: sourceTemplate.id ?? '',
294
+ version: sourceTemplate.version ?? '',
295
+ toolsId: sourceTemplate.toolsId ?? types_1.ToolsId.NO_TOOLS_ID
326
296
  };
327
297
  }
328
298
  /**
@@ -330,16 +300,14 @@ function populateSourceTemplate(sourceTemplate) {
330
300
  *
331
301
  * @returns Node.js version
332
302
  */
333
- function getProcessVersions() {
334
- return __awaiter(this, void 0, void 0, function* () {
335
- try {
336
- const output = yield spawnCommand('node', ['-p', 'JSON.stringify(process.versions)']);
337
- return JSON.parse(output);
338
- }
339
- catch (_a) {
340
- return {};
341
- }
342
- });
303
+ async function getProcessVersions() {
304
+ try {
305
+ const output = await spawnCommand('node', ['-p', 'JSON.stringify(process.versions)']);
306
+ return JSON.parse(output);
307
+ }
308
+ catch {
309
+ return {};
310
+ }
343
311
  }
344
312
  /**
345
313
  * Spawn a command to find out node.js version used for the runtime.
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.ToolsSuiteTelemetryClient = void 0;
13
4
  const azure_appinsight_client_1 = require("../base/client/azure-appinsight-client");
@@ -38,19 +29,18 @@ class ToolsSuiteTelemetryClient extends azure_appinsight_client_1.ApplicationIns
38
29
  * @param ignoreSettings Ignore telemetryEnabled settings and skip submitting telemetry data
39
30
  * @returns Promise<void>
40
31
  */
41
- report(eventName, properties, measurements, sampleRate, telemetryHelperProperties, ignoreSettings) {
42
- const _super = Object.create(null, {
43
- report: { get: () => super.report }
44
- });
45
- return __awaiter(this, void 0, void 0, function* () {
46
- const fioriProjectCommonProperties = yield (0, _1.processToolsSuiteTelemetry)(telemetryHelperProperties);
47
- const commonProperties = {
48
- v: this.extensionVersion,
49
- datetime: (0, date_1.localDatetimeToUTC)()
50
- };
51
- const finalProperties = Object.assign(Object.assign(Object.assign({}, properties), fioriProjectCommonProperties), commonProperties);
52
- yield _super.report.call(this, eventName, finalProperties, measurements, sampleRate, telemetryHelperProperties, ignoreSettings);
53
- });
32
+ async report(eventName, properties, measurements, sampleRate, telemetryHelperProperties, ignoreSettings) {
33
+ const fioriProjectCommonProperties = await (0, _1.processToolsSuiteTelemetry)(telemetryHelperProperties);
34
+ const commonProperties = {
35
+ v: this.extensionVersion,
36
+ datetime: (0, date_1.localDatetimeToUTC)()
37
+ };
38
+ const finalProperties = {
39
+ ...properties,
40
+ ...fioriProjectCommonProperties,
41
+ ...commonProperties
42
+ };
43
+ await super.report(eventName, finalProperties, measurements, sampleRate, telemetryHelperProperties, ignoreSettings);
54
44
  }
55
45
  /**
56
46
  * Send a telemetry event to Azure Application Insights.
@@ -61,14 +51,9 @@ class ToolsSuiteTelemetryClient extends azure_appinsight_client_1.ApplicationIns
61
51
  * @param ignoreSettings Ignore telemetryEnabled settings and skip submitting telemetry data
62
52
  * @returns Promise<void>
63
53
  */
64
- reportEvent(event, sampleRate, telemetryHelperProperties, ignoreSettings) {
65
- const _super = Object.create(null, {
66
- report: { get: () => super.report }
67
- });
68
- return __awaiter(this, void 0, void 0, function* () {
69
- const { finalProperties, finalMeasurements } = yield this.collectToolsSuiteTelemetry(event, telemetryHelperProperties);
70
- return _super.report.call(this, event.eventName, finalProperties, finalMeasurements, sampleRate, telemetryHelperProperties, ignoreSettings);
71
- });
54
+ async reportEvent(event, sampleRate, telemetryHelperProperties, ignoreSettings) {
55
+ const { finalProperties, finalMeasurements } = await this.collectToolsSuiteTelemetry(event, telemetryHelperProperties);
56
+ return super.report(event.eventName, finalProperties, finalMeasurements, sampleRate, telemetryHelperProperties, ignoreSettings);
72
57
  }
73
58
  /**
74
59
  * Send a telemetry event to Azure Application Insights. This API makes sure the telemetry event
@@ -82,14 +67,9 @@ class ToolsSuiteTelemetryClient extends azure_appinsight_client_1.ApplicationIns
82
67
  * @param ignoreSettings Ignore telemetryEnabled settings and skip submitting telemetry data
83
68
  * @returns Promise<void>
84
69
  */
85
- reportEventBlocking(event, sampleRate, telemetryHelperProperties, ignoreSettings) {
86
- const _super = Object.create(null, {
87
- reportBlocking: { get: () => super.reportBlocking }
88
- });
89
- return __awaiter(this, void 0, void 0, function* () {
90
- const { finalProperties, finalMeasurements } = yield this.collectToolsSuiteTelemetry(event, telemetryHelperProperties);
91
- return _super.reportBlocking.call(this, event.eventName, finalProperties, finalMeasurements, sampleRate, ignoreSettings);
92
- });
70
+ async reportEventBlocking(event, sampleRate, telemetryHelperProperties, ignoreSettings) {
71
+ const { finalProperties, finalMeasurements } = await this.collectToolsSuiteTelemetry(event, telemetryHelperProperties);
72
+ return super.reportBlocking(event.eventName, finalProperties, finalMeasurements, sampleRate, ignoreSettings);
93
73
  }
94
74
  /**
95
75
  * Add common properties to properties and measurements of consumer's telemetry event.
@@ -98,20 +78,24 @@ class ToolsSuiteTelemetryClient extends azure_appinsight_client_1.ApplicationIns
98
78
  * @param telemetryHelperProperties Additional properties that can be undefined
99
79
  * @returns Telemetry properties and measurements
100
80
  */
101
- collectToolsSuiteTelemetry(event, telemetryHelperProperties) {
102
- return __awaiter(this, void 0, void 0, function* () {
103
- const fioriProjectCommonProperties = yield (0, _1.processToolsSuiteTelemetry)(telemetryHelperProperties);
104
- const telemetryEventCommonProperties = {
105
- v: this.extensionVersion,
106
- datetime: (0, date_1.localDatetimeToUTC)()
107
- };
108
- const finalProperties = Object.assign(Object.assign(Object.assign({}, event.properties), fioriProjectCommonProperties), telemetryEventCommonProperties);
109
- const finalMeasurements = Object.assign({}, event.measurements);
110
- return {
111
- finalProperties,
112
- finalMeasurements
113
- };
114
- });
81
+ async collectToolsSuiteTelemetry(event, telemetryHelperProperties) {
82
+ const fioriProjectCommonProperties = await (0, _1.processToolsSuiteTelemetry)(telemetryHelperProperties);
83
+ const telemetryEventCommonProperties = {
84
+ v: this.extensionVersion,
85
+ datetime: (0, date_1.localDatetimeToUTC)()
86
+ };
87
+ const finalProperties = {
88
+ ...event.properties,
89
+ ...fioriProjectCommonProperties,
90
+ ...telemetryEventCommonProperties
91
+ };
92
+ const finalMeasurements = {
93
+ ...event.measurements
94
+ };
95
+ return {
96
+ finalProperties,
97
+ finalMeasurements
98
+ };
115
99
  }
116
100
  }
117
101
  exports.ToolsSuiteTelemetryClient = ToolsSuiteTelemetryClient;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -52,43 +43,41 @@ const definePath = (paths) => {
52
43
  *
53
44
  * @param storeService Store service that is used for read/write telemetry settings
54
45
  */
55
- function readEnableTelemetry(storeService) {
56
- return __awaiter(this, void 0, void 0, function* () {
57
- let setting;
58
- try {
59
- setting = yield storeService.read(new store_1.TelemetrySettingKey());
60
- }
61
- catch (_a) {
62
- // ignore read failure, assume file doens't exist and thus setting is undefined
46
+ async function readEnableTelemetry(storeService) {
47
+ let setting;
48
+ try {
49
+ setting = await storeService.read(new store_1.TelemetrySettingKey());
50
+ }
51
+ catch {
52
+ // ignore read failure, assume file doens't exist and thus setting is undefined
53
+ }
54
+ if (!setting) {
55
+ // If no telemetry setting found in .fioritools folder,
56
+ // check telemetry setting in vscode settings for extensions
57
+ const deprecatedSettingPath = definePath(deprecatedSettingPaths);
58
+ if (!deprecatedSettingPath) {
59
+ // If no vscode setting found, default central telemetry setting to true
60
+ await setEnableTelemetry(true);
63
61
  }
64
- if (!setting) {
65
- // If no telemetry setting found in .fioritools folder,
66
- // check telemetry setting in vscode settings for extensions
67
- const deprecatedSettingPath = definePath(deprecatedSettingPaths);
68
- if (!deprecatedSettingPath) {
69
- // If no vscode setting found, default central telemetry setting to true
70
- yield setEnableTelemetry(true);
62
+ else {
63
+ // If deprecated vscode setting exists, set central telemetry setting to false if any of vscode setting was false
64
+ let content;
65
+ try {
66
+ content = await fs_1.default.promises.readFile(deprecatedSettingPath, 'utf-8');
67
+ const deprecatedSetting = JSON.parse(content);
68
+ const propValues = deprecatedExtensionPropKeys.map((propKey) => (deprecatedSetting[propKey] ?? true));
69
+ const deprecatedEnableTelemetrySetting = propValues.reduce((prevValue, currentValue) => prevValue && currentValue, true);
70
+ await setEnableTelemetry(deprecatedEnableTelemetrySetting);
71
71
  }
72
- else {
73
- // If deprecated vscode setting exists, set central telemetry setting to false if any of vscode setting was false
74
- let content;
75
- try {
76
- content = yield fs_1.default.promises.readFile(deprecatedSettingPath, 'utf-8');
77
- const deprecatedSetting = JSON.parse(content);
78
- const propValues = deprecatedExtensionPropKeys.map((propKey) => { var _a; return ((_a = deprecatedSetting[propKey]) !== null && _a !== void 0 ? _a : true); });
79
- const deprecatedEnableTelemetrySetting = propValues.reduce((prevValue, currentValue) => prevValue && currentValue, true);
80
- yield setEnableTelemetry(deprecatedEnableTelemetrySetting);
81
- }
82
- catch (_b) {
83
- // ignore read failure and content is undefined
84
- yield setEnableTelemetry(true);
85
- }
72
+ catch {
73
+ // ignore read failure and content is undefined
74
+ await setEnableTelemetry(true);
86
75
  }
87
76
  }
88
- else {
89
- config_state_1.TelemetrySettings.telemetryEnabled = setting.enableTelemetry;
90
- }
91
- });
77
+ }
78
+ else {
79
+ config_state_1.TelemetrySettings.telemetryEnabled = setting.enableTelemetry;
80
+ }
92
81
  }
93
82
  /**
94
83
  * Watch changes to telemetry setting in the store and update runtime settings accordingly.
@@ -114,19 +103,18 @@ function watchTelemetrySettingStore(storeService) {
114
103
  *
115
104
  * @param options Settings pass from the consumer module.
116
105
  */
117
- const initTelemetrySettings = (options) => __awaiter(void 0, void 0, void 0, function* () {
118
- var _a;
106
+ const initTelemetrySettings = async (options) => {
119
107
  try {
120
108
  config_state_1.TelemetrySettings.consumerModuleName = options.consumerModule.name;
121
109
  config_state_1.TelemetrySettings.consumerModuleVersion = options.consumerModule.version;
122
- config_state_2.ToolingTelemetrySettings.internalFeature = (_a = options.internalFeature) !== null && _a !== void 0 ? _a : false;
110
+ config_state_2.ToolingTelemetrySettings.internalFeature = options.internalFeature ?? false;
123
111
  if (options.resourceId) {
124
112
  config_state_1.TelemetrySettings.azureInstrumentationKey = options.resourceId;
125
113
  }
126
- const storeService = yield (0, store_1.getService)({
114
+ const storeService = await (0, store_1.getService)({
127
115
  entityName: 'telemetrySetting'
128
116
  });
129
- yield readEnableTelemetry(storeService);
117
+ await readEnableTelemetry(storeService);
130
118
  if (options.watchTelemetrySettingStore) {
131
119
  watchTelemetrySettingStore(storeService);
132
120
  }
@@ -134,7 +122,7 @@ const initTelemetrySettings = (options) => __awaiter(void 0, void 0, void 0, fun
134
122
  catch (err) {
135
123
  (0, reporting_1.reportRuntimeError)(err);
136
124
  }
137
- });
125
+ };
138
126
  exports.initTelemetrySettings = initTelemetrySettings;
139
127
  /**
140
128
  * Toggle on/off enable telemetry setting. This will update telemetry settings file
@@ -142,22 +130,20 @@ exports.initTelemetrySettings = initTelemetrySettings;
142
130
  *
143
131
  * @param enableTelemetry Telemetry is enabled or not
144
132
  */
145
- function setEnableTelemetry(enableTelemetry) {
146
- return __awaiter(this, void 0, void 0, function* () {
147
- try {
148
- const storeService = yield (0, store_1.getService)({
149
- entityName: 'telemetrySetting'
150
- });
151
- const setting = new store_1.TelemetrySetting({ enableTelemetry });
152
- yield storeService.write(setting);
153
- config_state_1.TelemetrySettings.telemetryEnabled = enableTelemetry;
154
- }
155
- catch (_a) {
156
- // Telemetry settings could not be written
157
- }
158
- const commonProperties = yield (0, data_processor_1.getCommonProperties)();
159
- (0, reporting_1.reportEnableTelemetryOnOff)(enableTelemetry, commonProperties);
160
- });
133
+ async function setEnableTelemetry(enableTelemetry) {
134
+ try {
135
+ const storeService = await (0, store_1.getService)({
136
+ entityName: 'telemetrySetting'
137
+ });
138
+ const setting = new store_1.TelemetrySetting({ enableTelemetry });
139
+ await storeService.write(setting);
140
+ config_state_1.TelemetrySettings.telemetryEnabled = enableTelemetry;
141
+ }
142
+ catch {
143
+ // Telemetry settings could not be written
144
+ }
145
+ const commonProperties = await (0, data_processor_1.getCommonProperties)();
146
+ (0, reporting_1.reportEnableTelemetryOnOff)(enableTelemetry, commonProperties);
161
147
  }
162
148
  exports.setEnableTelemetry = setEnableTelemetry;
163
149
  /**
@@ -165,20 +151,18 @@ exports.setEnableTelemetry = setEnableTelemetry;
165
151
  *
166
152
  * @returns Telemetry settings of context module that consumes telemetry library
167
153
  */
168
- function getTelemetrySetting() {
169
- return __awaiter(this, void 0, void 0, function* () {
170
- let setting;
171
- try {
172
- const storeService = yield (0, store_1.getService)({
173
- entityName: 'telemetrySetting'
174
- });
175
- setting = yield storeService.read(new store_1.TelemetrySettingKey());
176
- }
177
- catch (_a) {
178
- // ignore if settings could not be read, return undefined
179
- }
180
- return setting;
181
- });
154
+ async function getTelemetrySetting() {
155
+ let setting;
156
+ try {
157
+ const storeService = await (0, store_1.getService)({
158
+ entityName: 'telemetrySetting'
159
+ });
160
+ setting = await storeService.read(new store_1.TelemetrySettingKey());
161
+ }
162
+ catch {
163
+ // ignore if settings could not be read, return undefined
164
+ }
165
+ return setting;
182
166
  }
183
167
  exports.getTelemetrySetting = getTelemetrySetting;
184
168
  //# sourceMappingURL=telemetry-settings.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap-ux/telemetry",
3
- "version": "0.4.37",
3
+ "version": "0.5.1",
4
4
  "description": "Library for sending usage telemetry data",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,11 +18,11 @@
18
18
  "axios": "1.6.8",
19
19
  "performance-now": "2.1.0",
20
20
  "yaml": "2.3.3",
21
- "@sap-ux/store": "0.6.0",
22
- "@sap-ux/project-access": "1.22.4",
23
- "@sap-ux/btp-utils": "0.14.4",
24
- "@sap-ux/ui5-config": "0.22.10",
25
- "@sap-ux/logger": "0.5.1"
21
+ "@sap-ux/store": "0.7.0",
22
+ "@sap-ux/project-access": "1.24.0",
23
+ "@sap-ux/btp-utils": "0.15.0",
24
+ "@sap-ux/ui5-config": "0.23.0",
25
+ "@sap-ux/logger": "0.6.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "jest-extended": "4.0.2",