@sap-ux/telemetry 0.7.5 → 1.0.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.
- package/dist/base/client/azure-appinsight-client.d.ts +3 -3
- package/dist/base/client/azure-appinsight-client.js +22 -58
- package/dist/base/client/client.d.ts +1 -1
- package/dist/base/client/client.js +1 -4
- package/dist/base/client/index.d.ts +2 -2
- package/dist/base/client/index.js +5 -8
- package/dist/base/config-state.js +4 -10
- package/dist/base/decorator/index.d.ts +2 -2
- package/dist/base/decorator/index.js +4 -9
- package/dist/base/interceptor/config.js +4 -41
- package/dist/base/interceptor/index.d.ts +3 -3
- package/dist/base/interceptor/index.js +25 -34
- package/dist/base/performance/api.d.ts +2 -2
- package/dist/base/performance/api.js +14 -16
- package/dist/base/performance/entries.d.ts +2 -2
- package/dist/base/performance/entries.js +3 -7
- package/dist/base/performance/types.d.ts +2 -1
- package/dist/base/performance/types.js +2 -5
- package/dist/base/types/event-header.js +1 -4
- package/dist/base/types/event-name.js +2 -5
- package/dist/base/types/event.js +1 -2
- package/dist/base/types/index.d.ts +5 -5
- package/dist/base/types/index.js +5 -21
- package/dist/base/types/project-info.js +1 -2
- package/dist/base/types/sample-rate.js +2 -5
- package/dist/base/utils/azure-client-config.js +1 -4
- package/dist/base/utils/date.js +1 -5
- package/dist/base/utils/index.d.ts +5 -5
- package/dist/base/utils/index.js +5 -23
- package/dist/base/utils/logger.js +2 -6
- package/dist/base/utils/param-processing.js +10 -19
- package/dist/base/utils/reporting.js +10 -48
- package/dist/index.d.ts +14 -12
- package/dist/index.js +12 -32
- package/dist/tooling-telemetry/config-state.js +1 -4
- package/dist/tooling-telemetry/data-processor.d.ts +1 -1
- package/dist/tooling-telemetry/data-processor.js +73 -81
- package/dist/tooling-telemetry/index.d.ts +4 -4
- package/dist/tooling-telemetry/index.js +4 -23
- package/dist/tooling-telemetry/telemetry-client.d.ts +3 -3
- package/dist/tooling-telemetry/telemetry-client.js +9 -12
- package/dist/tooling-telemetry/telemetry-settings.d.ts +1 -1
- package/dist/tooling-telemetry/telemetry-settings.js +34 -43
- package/dist/tooling-telemetry/types.d.ts +1 -1
- package/dist/tooling-telemetry/types.js +8 -11
- package/package.json +11 -9
|
@@ -1,28 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const ui5_config_1 = require("@sap-ux/ui5-config");
|
|
12
|
-
const axios_1 = __importDefault(require("axios"));
|
|
13
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
14
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
15
|
-
const yaml_1 = __importDefault(require("yaml"));
|
|
16
|
-
const project_access_1 = require("@sap-ux/project-access");
|
|
17
|
-
const config_state_1 = require("./config-state");
|
|
18
|
-
const types_1 = require("./types");
|
|
1
|
+
import { isAppStudio } from '@sap-ux/btp-utils';
|
|
2
|
+
import { CommandRunner } from '@sap-ux/nodejs-utils';
|
|
3
|
+
import { UI5Config } from '@sap-ux/ui5-config';
|
|
4
|
+
import axios from 'axios';
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import yaml from 'yaml';
|
|
8
|
+
import { findProjectRoot, getAppProgrammingLanguage, getAppType, getProjectType, getWebappPath, isCapJavaProject } from '@sap-ux/project-access';
|
|
9
|
+
import { ToolingTelemetrySettings } from './config-state.js';
|
|
10
|
+
import { CommonProperties, DeployTarget, ODataSource, ToolsId } from './types.js';
|
|
19
11
|
/**
|
|
20
12
|
* Collect commone properties that needs to be added to telemetry event.
|
|
21
13
|
*
|
|
22
14
|
* @param telemetryHelperProperties Pass to report ApplicationInsightClient.report()
|
|
23
15
|
* @returns Common Fiori project properties
|
|
24
16
|
*/
|
|
25
|
-
async function processToolsSuiteTelemetry(telemetryHelperProperties) {
|
|
17
|
+
export async function processToolsSuiteTelemetry(telemetryHelperProperties) {
|
|
26
18
|
const commonProperties = await getCommonProperties();
|
|
27
19
|
let appProperties = {};
|
|
28
20
|
if (telemetryHelperProperties) {
|
|
@@ -35,16 +27,16 @@ async function processToolsSuiteTelemetry(telemetryHelperProperties) {
|
|
|
35
27
|
*
|
|
36
28
|
* @returns Common properties
|
|
37
29
|
*/
|
|
38
|
-
async function getCommonProperties() {
|
|
30
|
+
export async function getCommonProperties() {
|
|
39
31
|
const commonProperties = {};
|
|
40
|
-
commonProperties[
|
|
41
|
-
commonProperties[
|
|
42
|
-
commonProperties[
|
|
43
|
-
commonProperties[
|
|
44
|
-
commonProperties[
|
|
45
|
-
commonProperties[
|
|
46
|
-
commonProperties[
|
|
47
|
-
commonProperties[
|
|
32
|
+
commonProperties[CommonProperties.DevSpace] = await getSbasDevspace();
|
|
33
|
+
commonProperties[CommonProperties.AppStudio] = isAppStudio();
|
|
34
|
+
commonProperties[CommonProperties.AppStudioBackwardCompatible] = commonProperties[CommonProperties.AppStudio];
|
|
35
|
+
commonProperties[CommonProperties.InternlVsExternal] = getInternalVsExternal();
|
|
36
|
+
commonProperties[CommonProperties.InternlVsExternalBackwardCompatible] =
|
|
37
|
+
commonProperties[CommonProperties.InternlVsExternal];
|
|
38
|
+
commonProperties[CommonProperties.NodeVersion] = await getOSNodeVersion();
|
|
39
|
+
commonProperties[CommonProperties.IdeType] = getIdeType();
|
|
48
40
|
return commonProperties;
|
|
49
41
|
}
|
|
50
42
|
/**
|
|
@@ -53,7 +45,7 @@ async function getCommonProperties() {
|
|
|
53
45
|
* @returns SBAS Dev Space Name. Empty string is returned if unable to fetch workspace type or the environment is not SBAS
|
|
54
46
|
*/
|
|
55
47
|
async function getSbasDevspace() {
|
|
56
|
-
if (
|
|
48
|
+
if (isAppStudio()) {
|
|
57
49
|
try {
|
|
58
50
|
if (!process.env.H2O_URL || !process.env.WORKSPACE_ID) {
|
|
59
51
|
return '';
|
|
@@ -61,7 +53,7 @@ async function getSbasDevspace() {
|
|
|
61
53
|
const h20Url = process.env.H2O_URL;
|
|
62
54
|
const workspaceId = process.env.WORKSPACE_ID.replace('workspaces-', '');
|
|
63
55
|
const url = `${h20Url}/ws-manager/api/v1/workspace/${workspaceId}`;
|
|
64
|
-
const response = await
|
|
56
|
+
const response = await axios.get(url);
|
|
65
57
|
if (response.data) {
|
|
66
58
|
const workspaceConfig = response.data;
|
|
67
59
|
// devspace stored in this path
|
|
@@ -86,23 +78,23 @@ async function getAppProperties(appPath) {
|
|
|
86
78
|
}
|
|
87
79
|
const templateType = await getTemplateType(appPath);
|
|
88
80
|
const deployTarget = await getDeployTarget(appPath);
|
|
89
|
-
const applicationType = await
|
|
81
|
+
const applicationType = await getAppType(appPath);
|
|
90
82
|
let odataSource = await getODataSource(appPath);
|
|
91
83
|
// Correct logic in getAppType() implementation, if it's reuse lib type, odata source should be unknown
|
|
92
84
|
if (applicationType === 'Fiori Reuse') {
|
|
93
|
-
odataSource =
|
|
85
|
+
odataSource = ODataSource.UNKNOWN;
|
|
94
86
|
}
|
|
95
87
|
const sourceTemplate = await getSourceTemplate(appPath);
|
|
96
|
-
const appProgrammingLanguage = await
|
|
88
|
+
const appProgrammingLanguage = await getAppProgrammingLanguage(appPath);
|
|
97
89
|
const output = {};
|
|
98
|
-
output[
|
|
99
|
-
output[
|
|
100
|
-
output[
|
|
101
|
-
output[
|
|
102
|
-
output[
|
|
103
|
-
output[
|
|
104
|
-
output[
|
|
105
|
-
output[
|
|
90
|
+
output[CommonProperties.TemplateType] = templateType;
|
|
91
|
+
output[CommonProperties.DeployTargetType] = deployTarget;
|
|
92
|
+
output[CommonProperties.ODataSourceType] = odataSource;
|
|
93
|
+
output[CommonProperties.AppToolsId] = sourceTemplate.toolsId ?? '';
|
|
94
|
+
output[CommonProperties.AppProgrammingLanguage] = appProgrammingLanguage;
|
|
95
|
+
output[CommonProperties.TemplateId] = sourceTemplate.id ?? '';
|
|
96
|
+
output[CommonProperties.TemplateVersion] = sourceTemplate.version ?? '';
|
|
97
|
+
output[CommonProperties.ApplicationType] = applicationType ?? '';
|
|
106
98
|
return output;
|
|
107
99
|
}
|
|
108
100
|
/**
|
|
@@ -112,18 +104,18 @@ async function getAppProperties(appPath) {
|
|
|
112
104
|
* @returns Template type used in the Fiori app
|
|
113
105
|
*/
|
|
114
106
|
async function getTemplateType(appPath) {
|
|
115
|
-
const readmeFilePath =
|
|
116
|
-
const appGenInfoPath =
|
|
107
|
+
const readmeFilePath = path.join(appPath, 'README.md');
|
|
108
|
+
const appGenInfoPath = path.join(appPath, '.appGenInfo.json');
|
|
117
109
|
// N.B.: Keep this order i.e .appGenInfo.json file is read first, then README.md.
|
|
118
|
-
if (
|
|
119
|
-
const appGenInfo = await
|
|
110
|
+
if (fs.existsSync(appGenInfoPath)) {
|
|
111
|
+
const appGenInfo = await fs.promises.readFile(appGenInfoPath, 'utf-8');
|
|
120
112
|
const appGenInfoParsed = JSON.parse(appGenInfo);
|
|
121
113
|
if (appGenInfoParsed?.generationParameters?.template) {
|
|
122
114
|
return appGenInfoParsed.generationParameters.template.trim();
|
|
123
115
|
}
|
|
124
116
|
}
|
|
125
|
-
if (
|
|
126
|
-
const readmeContent = await
|
|
117
|
+
if (fs.existsSync(readmeFilePath)) {
|
|
118
|
+
const readmeContent = await fs.promises.readFile(readmeFilePath, 'utf-8');
|
|
127
119
|
if (readmeContent) {
|
|
128
120
|
let templateType = '';
|
|
129
121
|
const lines = readmeContent.split(/\r?\n/);
|
|
@@ -155,7 +147,7 @@ async function getODataSource(appPath) {
|
|
|
155
147
|
// is ABAP.
|
|
156
148
|
let projectRoot;
|
|
157
149
|
try {
|
|
158
|
-
projectRoot = await
|
|
150
|
+
projectRoot = await findProjectRoot(appPath);
|
|
159
151
|
}
|
|
160
152
|
catch {
|
|
161
153
|
// No project root can be found
|
|
@@ -165,8 +157,8 @@ async function getODataSource(appPath) {
|
|
|
165
157
|
// use appPath as project root.
|
|
166
158
|
if (!projectRoot) {
|
|
167
159
|
try {
|
|
168
|
-
const appParentFolder =
|
|
169
|
-
projectRoot = await
|
|
160
|
+
const appParentFolder = path.dirname(appPath);
|
|
161
|
+
projectRoot = await findProjectRoot(appParentFolder, false);
|
|
170
162
|
}
|
|
171
163
|
catch (e) {
|
|
172
164
|
// No project root can be found at parent folder.
|
|
@@ -178,19 +170,19 @@ async function getODataSource(appPath) {
|
|
|
178
170
|
// a better solution
|
|
179
171
|
let isCapJavaWithoutPackageJson = false;
|
|
180
172
|
if (!projectRoot) {
|
|
181
|
-
const directParentFolder =
|
|
182
|
-
const twoLevelUpParentFolder =
|
|
183
|
-
isCapJavaWithoutPackageJson = await
|
|
173
|
+
const directParentFolder = path.dirname(appPath);
|
|
174
|
+
const twoLevelUpParentFolder = path.dirname(directParentFolder);
|
|
175
|
+
isCapJavaWithoutPackageJson = await isCapJavaProject(twoLevelUpParentFolder);
|
|
184
176
|
projectRoot = isCapJavaWithoutPackageJson ? twoLevelUpParentFolder : appPath;
|
|
185
177
|
}
|
|
186
178
|
if (isCapJavaWithoutPackageJson) {
|
|
187
|
-
return
|
|
179
|
+
return ODataSource.CAPJava;
|
|
188
180
|
}
|
|
189
|
-
const projectType = await
|
|
181
|
+
const projectType = await getProjectType(projectRoot);
|
|
190
182
|
return getProjectTypeForTelemetry(projectType);
|
|
191
183
|
}
|
|
192
184
|
catch (e) {
|
|
193
|
-
return
|
|
185
|
+
return ODataSource.UNKNOWN;
|
|
194
186
|
}
|
|
195
187
|
}
|
|
196
188
|
/**
|
|
@@ -201,16 +193,16 @@ async function getODataSource(appPath) {
|
|
|
201
193
|
*/
|
|
202
194
|
function getProjectTypeForTelemetry(projectType) {
|
|
203
195
|
if (projectType === 'EDMXBackend') {
|
|
204
|
-
return
|
|
196
|
+
return ODataSource.ABAP;
|
|
205
197
|
}
|
|
206
198
|
else if (projectType === 'CAPNodejs') {
|
|
207
|
-
return
|
|
199
|
+
return ODataSource.CAPNode;
|
|
208
200
|
}
|
|
209
201
|
else if (projectType === 'CAPJava') {
|
|
210
|
-
return
|
|
202
|
+
return ODataSource.CAPJava;
|
|
211
203
|
}
|
|
212
204
|
else {
|
|
213
|
-
return
|
|
205
|
+
return ODataSource.UNKNOWN;
|
|
214
206
|
}
|
|
215
207
|
}
|
|
216
208
|
/**
|
|
@@ -220,19 +212,19 @@ function getProjectTypeForTelemetry(projectType) {
|
|
|
220
212
|
* @returns CF | ABAP | NO_DEPLOY_CONFIG | UNKNOWN_DEPLOY_CONFIG
|
|
221
213
|
*/
|
|
222
214
|
async function getDeployTarget(appPath) {
|
|
223
|
-
let deployTarget =
|
|
224
|
-
const deployConfigPath =
|
|
215
|
+
let deployTarget = DeployTarget.NO_DEPLOY_CONFIG;
|
|
216
|
+
const deployConfigPath = path.join(appPath, 'ui5-deploy.yaml');
|
|
225
217
|
try {
|
|
226
|
-
await
|
|
227
|
-
const deployConfigContent = await
|
|
228
|
-
const deployConfig =
|
|
218
|
+
await fs.promises.access(deployConfigPath);
|
|
219
|
+
const deployConfigContent = await fs.promises.readFile(deployConfigPath, 'utf-8');
|
|
220
|
+
const deployConfig = yaml.parse(deployConfigContent);
|
|
229
221
|
const customTasks = deployConfig?.builder?.customTasks;
|
|
230
222
|
if (customTasks) {
|
|
231
223
|
const isAbapDeployTarget = customTasks.some((task) => task.name === 'deploy-to-abap');
|
|
232
|
-
deployTarget = isAbapDeployTarget ?
|
|
224
|
+
deployTarget = isAbapDeployTarget ? DeployTarget.ABAP : DeployTarget.CF;
|
|
233
225
|
}
|
|
234
226
|
else {
|
|
235
|
-
deployTarget =
|
|
227
|
+
deployTarget = DeployTarget.UNKNOWN_DEPLOY_CONFIG;
|
|
236
228
|
}
|
|
237
229
|
}
|
|
238
230
|
catch {
|
|
@@ -246,7 +238,7 @@ async function getDeployTarget(appPath) {
|
|
|
246
238
|
* @returns String value 'internal' | 'external' to be backward compatible with existing telemetry data format.
|
|
247
239
|
*/
|
|
248
240
|
function getInternalVsExternal() {
|
|
249
|
-
return
|
|
241
|
+
return ToolingTelemetrySettings.internalFeature ? 'internal' : 'external';
|
|
250
242
|
}
|
|
251
243
|
/**
|
|
252
244
|
* Retrieves the source template configuration from either the standard manifest.json or
|
|
@@ -256,21 +248,21 @@ function getInternalVsExternal() {
|
|
|
256
248
|
* @returns {Promise<SourceTemplate>} A promise that resolves to the source template configuration object.
|
|
257
249
|
*/
|
|
258
250
|
async function getSourceTemplate(appPath) {
|
|
259
|
-
const webappPath = await
|
|
251
|
+
const webappPath = await getWebappPath(appPath);
|
|
260
252
|
const paths = {
|
|
261
|
-
manifest:
|
|
262
|
-
appdescr:
|
|
263
|
-
ui5Yaml:
|
|
253
|
+
manifest: path.join(webappPath, 'manifest.json'),
|
|
254
|
+
appdescr: path.join(webappPath, 'manifest.appdescr_variant'),
|
|
255
|
+
ui5Yaml: path.join(appPath, 'ui5.yaml')
|
|
264
256
|
};
|
|
265
257
|
try {
|
|
266
|
-
if (
|
|
267
|
-
const manifestStr = await
|
|
258
|
+
if (fs.existsSync(paths.manifest)) {
|
|
259
|
+
const manifestStr = await fs.promises.readFile(paths.manifest, 'utf-8');
|
|
268
260
|
const manifest = JSON.parse(manifestStr);
|
|
269
261
|
return populateSourceTemplate(manifest['sap.app']?.sourceTemplate ?? {});
|
|
270
262
|
}
|
|
271
|
-
if (
|
|
272
|
-
const baseUi5ConfigContent = await
|
|
273
|
-
const ui5Config = await
|
|
263
|
+
if (fs.existsSync(paths.appdescr) && fs.existsSync(paths.ui5Yaml)) {
|
|
264
|
+
const baseUi5ConfigContent = await fs.promises.readFile(paths.ui5Yaml, 'utf-8');
|
|
265
|
+
const ui5Config = await UI5Config.newInstance(baseUi5ConfigContent);
|
|
274
266
|
const adp = ui5Config.getCustomConfiguration('adp');
|
|
275
267
|
return populateSourceTemplate(adp?.support ?? {});
|
|
276
268
|
}
|
|
@@ -290,7 +282,7 @@ function populateSourceTemplate(sourceTemplate) {
|
|
|
290
282
|
return {
|
|
291
283
|
id: sourceTemplate.id ?? '',
|
|
292
284
|
version: sourceTemplate.version ?? '',
|
|
293
|
-
toolsId: sourceTemplate.toolsId ??
|
|
285
|
+
toolsId: sourceTemplate.toolsId ?? ToolsId.NO_TOOLS_ID
|
|
294
286
|
};
|
|
295
287
|
}
|
|
296
288
|
/**
|
|
@@ -300,7 +292,7 @@ function populateSourceTemplate(sourceTemplate) {
|
|
|
300
292
|
*/
|
|
301
293
|
async function getOSNodeVersion() {
|
|
302
294
|
try {
|
|
303
|
-
const nodeVer = (await new
|
|
295
|
+
const nodeVer = (await new CommandRunner().run('node', ['-v'])) ?? 'unknown';
|
|
304
296
|
return nodeVer.replaceAll(/(?:^v)|([\r\n]{1,100})/g, '');
|
|
305
297
|
}
|
|
306
298
|
catch {
|
|
@@ -323,9 +315,9 @@ async function getOSNodeVersion() {
|
|
|
323
315
|
*
|
|
324
316
|
* @returns The detected IDE type
|
|
325
317
|
*/
|
|
326
|
-
function getIdeType() {
|
|
318
|
+
export function getIdeType() {
|
|
327
319
|
// AppStudio is a VS Code fork that sets VSCODE_PID — check first to avoid misdetection as 'vscode'
|
|
328
|
-
if (
|
|
320
|
+
if (isAppStudio()) {
|
|
329
321
|
return 'appstudio';
|
|
330
322
|
}
|
|
331
323
|
const vscodeCwd = process.env.VSCODE_CWD?.toLowerCase() ?? '';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './telemetry-client';
|
|
2
|
-
export { processToolsSuiteTelemetry, getIdeType } from './data-processor';
|
|
3
|
-
export * from './telemetry-settings';
|
|
4
|
-
export * from './types';
|
|
1
|
+
export * from './telemetry-client.js';
|
|
2
|
+
export { processToolsSuiteTelemetry, getIdeType } from './data-processor.js';
|
|
3
|
+
export * from './telemetry-settings.js';
|
|
4
|
+
export * from './types.js';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,24 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.getIdeType = exports.processToolsSuiteTelemetry = void 0;
|
|
18
|
-
__exportStar(require("./telemetry-client"), exports);
|
|
19
|
-
var data_processor_1 = require("./data-processor");
|
|
20
|
-
Object.defineProperty(exports, "processToolsSuiteTelemetry", { enumerable: true, get: function () { return data_processor_1.processToolsSuiteTelemetry; } });
|
|
21
|
-
Object.defineProperty(exports, "getIdeType", { enumerable: true, get: function () { return data_processor_1.getIdeType; } });
|
|
22
|
-
__exportStar(require("./telemetry-settings"), exports);
|
|
23
|
-
__exportStar(require("./types"), exports);
|
|
1
|
+
export * from './telemetry-client.js';
|
|
2
|
+
export { processToolsSuiteTelemetry, getIdeType } from './data-processor.js';
|
|
3
|
+
export * from './telemetry-settings.js';
|
|
4
|
+
export * from './types.js';
|
|
24
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ApplicationInsightClient } from '../base/client/azure-appinsight-client';
|
|
2
|
-
import type { SampleRate, TelemetryMeasurements, TelemetryProperties } from '../base/types';
|
|
3
|
-
import type { TelemetryHelperProperties, TelemetryEvent } from './types';
|
|
1
|
+
import { ApplicationInsightClient } from '../base/client/azure-appinsight-client.js';
|
|
2
|
+
import type { SampleRate, TelemetryMeasurements, TelemetryProperties } from '../base/types/index.js';
|
|
3
|
+
import type { TelemetryHelperProperties, TelemetryEvent } from './types.js';
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const azure_appinsight_client_1 = require("../base/client/azure-appinsight-client");
|
|
5
|
-
const _1 = require(".");
|
|
6
|
-
const date_1 = require("../base/utils/date");
|
|
1
|
+
import { ApplicationInsightClient } from '../base/client/azure-appinsight-client.js';
|
|
2
|
+
import { processToolsSuiteTelemetry } from './index.js';
|
|
3
|
+
import { localDatetimeToUTC } from '../base/utils/date.js';
|
|
7
4
|
/**
|
|
8
5
|
*
|
|
9
6
|
*/
|
|
10
|
-
class ToolsSuiteTelemetryClient extends
|
|
7
|
+
class ToolsSuiteTelemetryClient extends ApplicationInsightClient {
|
|
11
8
|
/**
|
|
12
9
|
*
|
|
13
10
|
* @param applicationKey Application key to identify the Azure Application Insight resource
|
|
@@ -30,10 +27,10 @@ class ToolsSuiteTelemetryClient extends azure_appinsight_client_1.ApplicationIns
|
|
|
30
27
|
* @returns Promise<void>
|
|
31
28
|
*/
|
|
32
29
|
async report(eventName, properties, measurements, sampleRate, telemetryHelperProperties, ignoreSettings) {
|
|
33
|
-
const fioriProjectCommonProperties = await
|
|
30
|
+
const fioriProjectCommonProperties = await processToolsSuiteTelemetry(telemetryHelperProperties);
|
|
34
31
|
const commonProperties = {
|
|
35
32
|
v: this.extensionVersion,
|
|
36
|
-
datetime:
|
|
33
|
+
datetime: localDatetimeToUTC()
|
|
37
34
|
};
|
|
38
35
|
const finalProperties = {
|
|
39
36
|
...properties,
|
|
@@ -79,10 +76,10 @@ class ToolsSuiteTelemetryClient extends azure_appinsight_client_1.ApplicationIns
|
|
|
79
76
|
* @returns Telemetry properties and measurements
|
|
80
77
|
*/
|
|
81
78
|
async collectToolsSuiteTelemetry(event, telemetryHelperProperties) {
|
|
82
|
-
const fioriProjectCommonProperties = await
|
|
79
|
+
const fioriProjectCommonProperties = await processToolsSuiteTelemetry(telemetryHelperProperties);
|
|
83
80
|
const telemetryEventCommonProperties = {
|
|
84
81
|
v: this.extensionVersion,
|
|
85
|
-
datetime:
|
|
82
|
+
datetime: localDatetimeToUTC()
|
|
86
83
|
};
|
|
87
84
|
const finalProperties = {
|
|
88
85
|
...event.properties,
|
|
@@ -98,5 +95,5 @@ class ToolsSuiteTelemetryClient extends azure_appinsight_client_1.ApplicationIns
|
|
|
98
95
|
};
|
|
99
96
|
}
|
|
100
97
|
}
|
|
101
|
-
|
|
98
|
+
export { ToolsSuiteTelemetryClient };
|
|
102
99
|
//# sourceMappingURL=telemetry-client.js.map
|
|
@@ -1,20 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const store_1 = require("@sap-ux/store");
|
|
11
|
-
const btp_utils_1 = require("@sap-ux/btp-utils");
|
|
12
|
-
const node_os_1 = __importDefault(require("node:os"));
|
|
13
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
14
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
15
|
-
const data_processor_1 = require("./data-processor");
|
|
16
|
-
const config_state_1 = require("../base/config-state");
|
|
17
|
-
const config_state_2 = require("./config-state");
|
|
1
|
+
import { reportRuntimeError, reportEnableTelemetryOnOff } from '../base/utils/reporting.js';
|
|
2
|
+
import { getService, Entity, TelemetrySetting, TelemetrySettingKey, getFilesystemWatcherFor } from '@sap-ux/store';
|
|
3
|
+
import { isAppStudio } from '@sap-ux/btp-utils';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import fs from 'node:fs';
|
|
7
|
+
import { getCommonProperties } from './data-processor.js';
|
|
8
|
+
import { TelemetrySettings } from '../base/config-state.js';
|
|
9
|
+
import { ToolingTelemetrySettings } from './config-state.js';
|
|
18
10
|
const deprecatedSettingPaths = {
|
|
19
11
|
win32: '\\AppData\\Roaming\\Code\\User\\settings.json',
|
|
20
12
|
darwin: '/Library/Application Support/Code/User/settings.json',
|
|
@@ -30,15 +22,15 @@ const deprecatedExtensionPropKeys = [
|
|
|
30
22
|
const definePath = (paths) => {
|
|
31
23
|
const platform = process.platform;
|
|
32
24
|
let settingsPath = paths[platform];
|
|
33
|
-
if (
|
|
25
|
+
if (isAppStudio()) {
|
|
34
26
|
settingsPath = paths.theia;
|
|
35
27
|
}
|
|
36
28
|
if (!settingsPath) {
|
|
37
29
|
// no path for unknown platform settings path
|
|
38
30
|
return null;
|
|
39
31
|
}
|
|
40
|
-
const homedir =
|
|
41
|
-
return
|
|
32
|
+
const homedir = os.homedir();
|
|
33
|
+
return path.join(homedir, settingsPath);
|
|
42
34
|
};
|
|
43
35
|
/**
|
|
44
36
|
* Read telemetry settings from file store.
|
|
@@ -48,7 +40,7 @@ const definePath = (paths) => {
|
|
|
48
40
|
async function readEnableTelemetry(storeService) {
|
|
49
41
|
let setting;
|
|
50
42
|
try {
|
|
51
|
-
setting = await storeService.read(new
|
|
43
|
+
setting = await storeService.read(new TelemetrySettingKey());
|
|
52
44
|
}
|
|
53
45
|
catch {
|
|
54
46
|
// ignore read failure, assume file doens't exist and thus setting is undefined
|
|
@@ -65,7 +57,7 @@ async function readEnableTelemetry(storeService) {
|
|
|
65
57
|
// If deprecated vscode setting exists, set central telemetry setting to false if any of vscode setting was false
|
|
66
58
|
let content;
|
|
67
59
|
try {
|
|
68
|
-
content = await
|
|
60
|
+
content = await fs.promises.readFile(deprecatedSettingPath, 'utf-8');
|
|
69
61
|
const deprecatedSetting = JSON.parse(content);
|
|
70
62
|
const propValues = deprecatedExtensionPropKeys.map((propKey) => (deprecatedSetting[propKey] ?? true));
|
|
71
63
|
const deprecatedEnableTelemetrySetting = propValues.reduce((prevValue, currentValue) => prevValue && currentValue, true);
|
|
@@ -78,7 +70,7 @@ async function readEnableTelemetry(storeService) {
|
|
|
78
70
|
}
|
|
79
71
|
}
|
|
80
72
|
else {
|
|
81
|
-
|
|
73
|
+
TelemetrySettings.telemetryEnabled = setting.enableTelemetry;
|
|
82
74
|
}
|
|
83
75
|
}
|
|
84
76
|
/**
|
|
@@ -87,12 +79,12 @@ async function readEnableTelemetry(storeService) {
|
|
|
87
79
|
* @param storeService Store service that is used for read/write telemetry settings
|
|
88
80
|
*/
|
|
89
81
|
function watchTelemetrySettingStore(storeService) {
|
|
90
|
-
|
|
82
|
+
getFilesystemWatcherFor(Entity.TelemetrySetting, () => {
|
|
91
83
|
storeService
|
|
92
|
-
.read(new
|
|
84
|
+
.read(new TelemetrySettingKey())
|
|
93
85
|
.then((watchedSetting) => {
|
|
94
86
|
if (watchedSetting) {
|
|
95
|
-
|
|
87
|
+
TelemetrySettings.telemetryEnabled = watchedSetting.enableTelemetry;
|
|
96
88
|
}
|
|
97
89
|
})
|
|
98
90
|
.catch(() => {
|
|
@@ -105,15 +97,15 @@ function watchTelemetrySettingStore(storeService) {
|
|
|
105
97
|
*
|
|
106
98
|
* @param options Settings pass from the consumer module.
|
|
107
99
|
*/
|
|
108
|
-
const initTelemetrySettings = async (options) => {
|
|
100
|
+
export const initTelemetrySettings = async (options) => {
|
|
109
101
|
try {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
102
|
+
TelemetrySettings.consumerModuleName = options.consumerModule.name;
|
|
103
|
+
TelemetrySettings.consumerModuleVersion = options.consumerModule.version;
|
|
104
|
+
ToolingTelemetrySettings.internalFeature = options.internalFeature ?? false;
|
|
113
105
|
if (options.resourceId) {
|
|
114
|
-
|
|
106
|
+
TelemetrySettings.azureInstrumentationKey = options.resourceId;
|
|
115
107
|
}
|
|
116
|
-
const storeService = await
|
|
108
|
+
const storeService = await getService({
|
|
117
109
|
entityName: 'telemetrySetting'
|
|
118
110
|
});
|
|
119
111
|
await readEnableTelemetry(storeService);
|
|
@@ -122,43 +114,42 @@ const initTelemetrySettings = async (options) => {
|
|
|
122
114
|
}
|
|
123
115
|
}
|
|
124
116
|
catch (err) {
|
|
125
|
-
|
|
117
|
+
reportRuntimeError(err);
|
|
126
118
|
}
|
|
127
119
|
};
|
|
128
|
-
exports.initTelemetrySettings = initTelemetrySettings;
|
|
129
120
|
/**
|
|
130
121
|
* Toggle on/off enable telemetry setting. This will update telemetry settings file
|
|
131
122
|
* and the runtime setting.
|
|
132
123
|
*
|
|
133
124
|
* @param enableTelemetry Telemetry is enabled or not
|
|
134
125
|
*/
|
|
135
|
-
async function setEnableTelemetry(enableTelemetry) {
|
|
126
|
+
export async function setEnableTelemetry(enableTelemetry) {
|
|
136
127
|
try {
|
|
137
|
-
const storeService = await
|
|
128
|
+
const storeService = await getService({
|
|
138
129
|
entityName: 'telemetrySetting'
|
|
139
130
|
});
|
|
140
|
-
const setting = new
|
|
131
|
+
const setting = new TelemetrySetting({ enableTelemetry });
|
|
141
132
|
await storeService.write(setting);
|
|
142
|
-
|
|
133
|
+
TelemetrySettings.telemetryEnabled = enableTelemetry;
|
|
143
134
|
}
|
|
144
135
|
catch {
|
|
145
136
|
// Telemetry settings could not be written
|
|
146
137
|
}
|
|
147
|
-
const commonProperties = await
|
|
148
|
-
|
|
138
|
+
const commonProperties = await getCommonProperties();
|
|
139
|
+
reportEnableTelemetryOnOff(enableTelemetry, commonProperties);
|
|
149
140
|
}
|
|
150
141
|
/**
|
|
151
142
|
* Get telemetry settings.
|
|
152
143
|
*
|
|
153
144
|
* @returns Telemetry settings of context module that consumes telemetry library
|
|
154
145
|
*/
|
|
155
|
-
async function getTelemetrySetting() {
|
|
146
|
+
export async function getTelemetrySetting() {
|
|
156
147
|
let setting;
|
|
157
148
|
try {
|
|
158
|
-
const storeService = await
|
|
149
|
+
const storeService = await getService({
|
|
159
150
|
entityName: 'telemetrySetting'
|
|
160
151
|
});
|
|
161
|
-
setting = await storeService.read(new
|
|
152
|
+
setting = await storeService.read(new TelemetrySettingKey());
|
|
162
153
|
}
|
|
163
154
|
catch {
|
|
164
155
|
// ignore if settings could not be read, return undefined
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ProjectInfo, TelemetryMeasurements, TelemetryProperties } from '../base/types';
|
|
1
|
+
import type { ProjectInfo, TelemetryMeasurements, TelemetryProperties } from '../base/types/index.js';
|
|
2
2
|
import type { AppType } from '@sap-ux/project-access';
|
|
3
3
|
export type TelemetryHelperProperties = {
|
|
4
4
|
appPath: string;
|
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CommonProperties = exports.DeployTarget = exports.ODataSource = exports.ToolsId = void 0;
|
|
4
|
-
var ToolsId;
|
|
1
|
+
export var ToolsId;
|
|
5
2
|
(function (ToolsId) {
|
|
6
3
|
ToolsId["UNKNOWN"] = "UNKNOWN";
|
|
7
4
|
ToolsId["NO_TOOLS_ID"] = "NO_TOOLS_ID";
|
|
8
|
-
})(ToolsId || (
|
|
9
|
-
var ODataSource;
|
|
5
|
+
})(ToolsId || (ToolsId = {}));
|
|
6
|
+
export var ODataSource;
|
|
10
7
|
(function (ODataSource) {
|
|
11
8
|
ODataSource["CAPJava"] = "CAPJava";
|
|
12
9
|
ODataSource["CAPNode"] = "CAPNode";
|
|
13
10
|
ODataSource["ABAP"] = "ABAP";
|
|
14
11
|
ODataSource["UNKNOWN"] = "UNKNOWN";
|
|
15
|
-
})(ODataSource || (
|
|
16
|
-
var DeployTarget;
|
|
12
|
+
})(ODataSource || (ODataSource = {}));
|
|
13
|
+
export var DeployTarget;
|
|
17
14
|
(function (DeployTarget) {
|
|
18
15
|
DeployTarget["CF"] = "CF";
|
|
19
16
|
DeployTarget["ABAP"] = "ABAP";
|
|
20
17
|
DeployTarget["UNKNOWN_DEPLOY_CONFIG"] = "UNKNOWN_DEPLOY_CONFIG";
|
|
21
18
|
DeployTarget["NO_DEPLOY_CONFIG"] = "NO_DEPLOY_CONFIG";
|
|
22
|
-
})(DeployTarget || (
|
|
23
|
-
var CommonProperties;
|
|
19
|
+
})(DeployTarget || (DeployTarget = {}));
|
|
20
|
+
export var CommonProperties;
|
|
24
21
|
(function (CommonProperties) {
|
|
25
22
|
CommonProperties["DevSpace"] = "cmn.devspace";
|
|
26
23
|
CommonProperties["AppStudio"] = "cmn.appstudio";
|
|
@@ -37,5 +34,5 @@ var CommonProperties;
|
|
|
37
34
|
CommonProperties["TemplateVersion"] = "cmn.templateVersion";
|
|
38
35
|
CommonProperties["ApplicationType"] = "cmn.applicationType";
|
|
39
36
|
CommonProperties["IdeType"] = "cmn.ideType";
|
|
40
|
-
})(CommonProperties || (
|
|
37
|
+
})(CommonProperties || (CommonProperties = {}));
|
|
41
38
|
//# sourceMappingURL=types.js.map
|