@sap-ux/telemetry 0.2.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.
- package/LICENSE +201 -0
- package/README.md +27 -0
- package/dist/base/client/azure-appinsight-client.d.ts +88 -0
- package/dist/base/client/azure-appinsight-client.js +195 -0
- package/dist/base/client/client.d.ts +24 -0
- package/dist/base/client/client.js +33 -0
- package/dist/base/client/index.d.ts +24 -0
- package/dist/base/client/index.js +38 -0
- package/dist/base/config-state.d.ts +12 -0
- package/dist/base/config-state.js +26 -0
- package/dist/base/decorator/index.d.ts +23 -0
- package/dist/base/decorator/index.js +41 -0
- package/dist/base/interceptor/config.d.ts +19 -0
- package/dist/base/interceptor/config.js +54 -0
- package/dist/base/interceptor/index.d.ts +10 -0
- package/dist/base/interceptor/index.js +90 -0
- package/dist/base/performance/api.d.ts +74 -0
- package/dist/base/performance/api.js +120 -0
- package/dist/base/performance/entries.d.ts +42 -0
- package/dist/base/performance/entries.js +53 -0
- package/dist/base/performance/types.d.ts +35 -0
- package/dist/base/performance/types.js +17 -0
- package/dist/base/types/event-header.d.ts +28 -0
- package/dist/base/types/event-header.js +38 -0
- package/dist/base/types/event-name.d.ts +6 -0
- package/dist/base/types/event-name.js +10 -0
- package/dist/base/types/index.d.ts +5 -0
- package/dist/base/types/index.js +21 -0
- package/dist/base/types/project-info.d.ts +5 -0
- package/dist/base/types/project-info.js +3 -0
- package/dist/base/types/sample-rate.d.ts +6 -0
- package/dist/base/types/sample-rate.js +10 -0
- package/dist/base/utils/azure-client-config.d.ts +9 -0
- package/dist/base/utils/azure-client-config.js +21 -0
- package/dist/base/utils/date.d.ts +2 -0
- package/dist/base/utils/date.js +9 -0
- package/dist/base/utils/index.d.ts +6 -0
- package/dist/base/utils/index.js +24 -0
- package/dist/base/utils/logger.d.ts +6 -0
- package/dist/base/utils/logger.js +10 -0
- package/dist/base/utils/param-processing.d.ts +46 -0
- package/dist/base/utils/param-processing.js +103 -0
- package/dist/base/utils/reporting.d.ts +3 -0
- package/dist/base/utils/reporting.js +101 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +35 -0
- package/dist/tooling-telemetry/config-state.d.ts +4 -0
- package/dist/tooling-telemetry/config-state.js +7 -0
- package/dist/tooling-telemetry/data-processor.d.ts +23 -0
- package/dist/tooling-telemetry/data-processor.js +354 -0
- package/dist/tooling-telemetry/index.d.ts +5 -0
- package/dist/tooling-telemetry/index.js +23 -0
- package/dist/tooling-telemetry/telemetry-client.d.ts +65 -0
- package/dist/tooling-telemetry/telemetry-client.js +118 -0
- package/dist/tooling-telemetry/telemetry-settings.d.ts +22 -0
- package/dist/tooling-telemetry/telemetry-settings.js +180 -0
- package/dist/tooling-telemetry/types.d.ts +92 -0
- package/dist/tooling-telemetry/types.js +40 -0
- package/package.json +60 -0
|
@@ -0,0 +1,354 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.spawnCommand = exports.getCommonProperties = exports.processToolsSuiteTelemetry = void 0;
|
|
16
|
+
const btp_utils_1 = require("@sap-ux/btp-utils");
|
|
17
|
+
const axios_1 = __importDefault(require("axios"));
|
|
18
|
+
const fs_1 = __importDefault(require("fs"));
|
|
19
|
+
const path_1 = __importDefault(require("path"));
|
|
20
|
+
const yaml_1 = __importDefault(require("yaml"));
|
|
21
|
+
/**
|
|
22
|
+
* Import with Tree shaking behaviour '@sap/ux-project-access/dist/project/utils'
|
|
23
|
+
* performance optimization to remove unreachable code automatically from esbuild.
|
|
24
|
+
* Esbuild will only bundle parts of your packages that you actually use
|
|
25
|
+
*
|
|
26
|
+
* Note: Without Tree shaking import '@sap/ux-project-access'
|
|
27
|
+
* packages consuming telemetry need to add dependencies manually (for ex: sap/cds)
|
|
28
|
+
* Further, size of generated .vsix will be increased by esbuild
|
|
29
|
+
*/
|
|
30
|
+
const info_1 = require("@sap-ux/project-access/dist/project/info");
|
|
31
|
+
const search_1 = require("@sap-ux/project-access/dist/project/search");
|
|
32
|
+
const cap_1 = require("@sap-ux/project-access/dist/project/cap");
|
|
33
|
+
const types_1 = require("./types");
|
|
34
|
+
const child_process_1 = require("child_process");
|
|
35
|
+
const os_1 = __importDefault(require("os"));
|
|
36
|
+
const config_state_1 = require("./config-state");
|
|
37
|
+
/**
|
|
38
|
+
* Collect commone properties that needs to be added to telemetry event.
|
|
39
|
+
*
|
|
40
|
+
* @param telemetryHelperProperties Pass to report ApplicationInsightClient.report()
|
|
41
|
+
* @returns Common Fiori project properties
|
|
42
|
+
*/
|
|
43
|
+
function processToolsSuiteTelemetry(telemetryHelperProperties) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const commonProperties = yield getCommonProperties();
|
|
46
|
+
let appProperties = {};
|
|
47
|
+
if (telemetryHelperProperties) {
|
|
48
|
+
appProperties = yield getAppProperties(telemetryHelperProperties['appPath']);
|
|
49
|
+
}
|
|
50
|
+
return Object.assign(Object.assign({}, commonProperties), appProperties);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
exports.processToolsSuiteTelemetry = processToolsSuiteTelemetry;
|
|
54
|
+
/**
|
|
55
|
+
* Get common properties that related to Fiori project runtime environment.
|
|
56
|
+
*
|
|
57
|
+
* @returns Common properties
|
|
58
|
+
*/
|
|
59
|
+
function getCommonProperties() {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
const commonProperties = {};
|
|
62
|
+
commonProperties[types_1.CommonProperties.DevSpace] = yield getSbasDevspace();
|
|
63
|
+
commonProperties[types_1.CommonProperties.AppStudio] = (0, btp_utils_1.isAppStudio)();
|
|
64
|
+
commonProperties[types_1.CommonProperties.AppStudioBackwardCompatible] = commonProperties[types_1.CommonProperties.AppStudio];
|
|
65
|
+
commonProperties[types_1.CommonProperties.InternlVsExternal] = getInternalVsExternal();
|
|
66
|
+
commonProperties[types_1.CommonProperties.InternlVsExternalBackwardCompatible] =
|
|
67
|
+
commonProperties[types_1.CommonProperties.InternlVsExternal];
|
|
68
|
+
commonProperties[types_1.CommonProperties.NodeVersion] = (yield getProcessVersions()).node;
|
|
69
|
+
return commonProperties;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
exports.getCommonProperties = getCommonProperties;
|
|
73
|
+
/**
|
|
74
|
+
* Obtain dev space type from SBAS rest api.
|
|
75
|
+
*
|
|
76
|
+
* @returns SBAS Dev Space Name. Empty string is returned if unable to fetch workspace type or the environment is not SBAS
|
|
77
|
+
*/
|
|
78
|
+
function getSbasDevspace() {
|
|
79
|
+
var _a, _b;
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
if ((0, btp_utils_1.isAppStudio)()) {
|
|
82
|
+
try {
|
|
83
|
+
if (!process.env.H2O_URL || !process.env.WORKSPACE_ID) {
|
|
84
|
+
return '';
|
|
85
|
+
}
|
|
86
|
+
const h20Url = process.env.H2O_URL;
|
|
87
|
+
const workspaceId = process.env.WORKSPACE_ID.replace('workspaces-', '');
|
|
88
|
+
const url = `${h20Url}/ws-manager/api/v1/workspace/${workspaceId}`;
|
|
89
|
+
const response = yield axios_1.default.get(url);
|
|
90
|
+
if (response.data) {
|
|
91
|
+
const workspaceConfig = response.data;
|
|
92
|
+
// devspace stored in this path
|
|
93
|
+
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;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
// handling error
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return '';
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Get common properties from a give Fiori project path.
|
|
105
|
+
*
|
|
106
|
+
* @param appPath Fiori project path.
|
|
107
|
+
* @returns Properties to be append to properties in telemetry event
|
|
108
|
+
*/
|
|
109
|
+
function getAppProperties(appPath) {
|
|
110
|
+
var _a, _b, _c;
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
if (!appPath) {
|
|
113
|
+
return {};
|
|
114
|
+
}
|
|
115
|
+
const templateType = yield getTemplateType(appPath);
|
|
116
|
+
const deployTarget = yield getDeployTarget(appPath);
|
|
117
|
+
const applicationType = yield (0, info_1.getAppType)(appPath);
|
|
118
|
+
let odataSource = yield getODataSource(appPath);
|
|
119
|
+
// Correct logic in getAppType() implementation, if it's reuse lib type, odata source should be unknown
|
|
120
|
+
if (applicationType === 'Fiori Reuse') {
|
|
121
|
+
odataSource = types_1.ODataSource.UNKNOWN;
|
|
122
|
+
}
|
|
123
|
+
const sourceTemplate = yield getManifestSourceTemplate(appPath);
|
|
124
|
+
const appProgrammingLanguage = yield (0, info_1.getAppProgrammingLanguage)(appPath);
|
|
125
|
+
const output = {};
|
|
126
|
+
output[types_1.CommonProperties.TemplateType] = templateType;
|
|
127
|
+
output[types_1.CommonProperties.DeployTargetType] = deployTarget;
|
|
128
|
+
output[types_1.CommonProperties.ODataSourceType] = odataSource;
|
|
129
|
+
output[types_1.CommonProperties.AppToolsId] = (_a = sourceTemplate.toolsId) !== null && _a !== void 0 ? _a : '';
|
|
130
|
+
output[types_1.CommonProperties.AppProgrammingLanguage] = appProgrammingLanguage;
|
|
131
|
+
output[types_1.CommonProperties.TemplateId] = (_b = sourceTemplate.id) !== null && _b !== void 0 ? _b : '';
|
|
132
|
+
output[types_1.CommonProperties.TemplateVersion] = (_c = sourceTemplate.version) !== null && _c !== void 0 ? _c : '';
|
|
133
|
+
output[types_1.CommonProperties.ApplicationType] = applicationType !== null && applicationType !== void 0 ? applicationType : '';
|
|
134
|
+
return output;
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Read template type from README.md of an Fiori app. This will be improved once we have the floor
|
|
139
|
+
* plan information added to e.g. manifest.json of generated app.
|
|
140
|
+
*
|
|
141
|
+
* @param appPath Root folder path of Fiori app
|
|
142
|
+
* @returns Template type used in the Fiori app
|
|
143
|
+
*/
|
|
144
|
+
function getTemplateType(appPath) {
|
|
145
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
+
const readmeFilePath = path_1.default.join(appPath, 'README.md');
|
|
147
|
+
if (fs_1.default.existsSync(readmeFilePath)) {
|
|
148
|
+
const readmeContent = yield fs_1.default.promises.readFile(readmeFilePath, 'utf-8');
|
|
149
|
+
if (readmeContent) {
|
|
150
|
+
let templateType = '';
|
|
151
|
+
const lines = readmeContent.split(/\r?\n/);
|
|
152
|
+
for (const line of lines) {
|
|
153
|
+
// Check if the line matches the pattern |**Template Used**<br>{{TemplateType}}|
|
|
154
|
+
const regex = /\|\*\*Template Used\*\*<br>(.*?)\|/;
|
|
155
|
+
const match = regex.exec(line);
|
|
156
|
+
if (match && match.length >= 2) {
|
|
157
|
+
// Extract {{TemplateType}} from the matching pattern
|
|
158
|
+
templateType = match[1].trim();
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return templateType;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return '';
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Find OData Source type of a given app folder path.
|
|
170
|
+
*
|
|
171
|
+
* @param appPath Root folder path of Fiori app
|
|
172
|
+
* @returns Project Type ABAP | CAPJava | CAPNode | UNKNOWN
|
|
173
|
+
*/
|
|
174
|
+
function getODataSource(appPath) {
|
|
175
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
176
|
+
try {
|
|
177
|
+
// First attempt: Loop up a folder that contain a pacakge.json that has sapux property as project root
|
|
178
|
+
// If appPath has package.json that contains sapux, it is EDMX project type and we derive odata source
|
|
179
|
+
// is ABAP.
|
|
180
|
+
let projectRoot;
|
|
181
|
+
try {
|
|
182
|
+
projectRoot = yield (0, search_1.findProjectRoot)(appPath);
|
|
183
|
+
}
|
|
184
|
+
catch (_a) {
|
|
185
|
+
// No project root can be found
|
|
186
|
+
}
|
|
187
|
+
// Second attempt: For FF app, package.json does not have sapux property. Try to find the
|
|
188
|
+
// first parent folder that contain pacakge.json as CAP root. If no such folder exists,
|
|
189
|
+
// use appPath as project root.
|
|
190
|
+
if (!projectRoot) {
|
|
191
|
+
try {
|
|
192
|
+
const appParentFolder = path_1.default.dirname(appPath);
|
|
193
|
+
projectRoot = yield (0, search_1.findProjectRoot)(appParentFolder, false);
|
|
194
|
+
}
|
|
195
|
+
catch (e) {
|
|
196
|
+
// No project root can be found at parent folder.
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
// Third attempt: CAPJava that doesn't have package.json at project root. We assume
|
|
200
|
+
// the project has default structure <projectRoot>/app/<appPath>, and use parent folder
|
|
201
|
+
// path two levels above appPath as projectRoot. This should cover most cases until we have
|
|
202
|
+
// a better solution
|
|
203
|
+
let isCapJavaWithoutPackageJson = false;
|
|
204
|
+
if (!projectRoot) {
|
|
205
|
+
const directParentFolder = path_1.default.dirname(appPath);
|
|
206
|
+
const twoLevelUpParentFolder = path_1.default.dirname(directParentFolder);
|
|
207
|
+
isCapJavaWithoutPackageJson = yield (0, cap_1.isCapJavaProject)(twoLevelUpParentFolder);
|
|
208
|
+
projectRoot = isCapJavaWithoutPackageJson ? twoLevelUpParentFolder : appPath;
|
|
209
|
+
}
|
|
210
|
+
if (isCapJavaWithoutPackageJson) {
|
|
211
|
+
return types_1.ODataSource.CAPJava;
|
|
212
|
+
}
|
|
213
|
+
const projectType = yield (0, info_1.getProjectType)(projectRoot);
|
|
214
|
+
return getProjectTypeForTelemetry(projectType);
|
|
215
|
+
}
|
|
216
|
+
catch (e) {
|
|
217
|
+
return types_1.ODataSource.UNKNOWN;
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Map ProjectType to values used for telemetry reporting.
|
|
223
|
+
*
|
|
224
|
+
* @param projectType ProjectType
|
|
225
|
+
* @returns Odata source type
|
|
226
|
+
*/
|
|
227
|
+
function getProjectTypeForTelemetry(projectType) {
|
|
228
|
+
if (projectType === 'EDMXBackend') {
|
|
229
|
+
return types_1.ODataSource.ABAP;
|
|
230
|
+
}
|
|
231
|
+
else if (projectType === 'CAPNodejs') {
|
|
232
|
+
return types_1.ODataSource.CAPNode;
|
|
233
|
+
}
|
|
234
|
+
else if (projectType === 'CAPJava') {
|
|
235
|
+
return types_1.ODataSource.CAPJava;
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
return types_1.ODataSource.UNKNOWN;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Read ui5-deploy.yaml to decide if it is CF or ABAP deploy target.
|
|
243
|
+
*
|
|
244
|
+
* @param appPath appPath Root folder path of Fiori app
|
|
245
|
+
* @returns CF | ABAP | NO_DEPLOY_CONFIG | UNKNOWN_DEPLOY_CONFIG
|
|
246
|
+
*/
|
|
247
|
+
function getDeployTarget(appPath) {
|
|
248
|
+
var _a;
|
|
249
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
250
|
+
let deployTarget = types_1.DeployTarget.NO_DEPLOY_CONFIG;
|
|
251
|
+
const deployConfigPath = path_1.default.join(appPath, 'ui5-deploy.yaml');
|
|
252
|
+
try {
|
|
253
|
+
yield fs_1.default.promises.access(deployConfigPath);
|
|
254
|
+
const deployConfigContent = yield fs_1.default.promises.readFile(deployConfigPath, 'utf-8');
|
|
255
|
+
const deployConfig = yaml_1.default.parse(deployConfigContent);
|
|
256
|
+
const customTasks = (_a = deployConfig === null || deployConfig === void 0 ? void 0 : deployConfig.builder) === null || _a === void 0 ? void 0 : _a.customTasks;
|
|
257
|
+
if (customTasks) {
|
|
258
|
+
const isAbapDeployTarget = customTasks.some((task) => task.name === 'deploy-to-abap');
|
|
259
|
+
deployTarget = isAbapDeployTarget ? types_1.DeployTarget.ABAP : types_1.DeployTarget.CF;
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
deployTarget = types_1.DeployTarget.UNKNOWN_DEPLOY_CONFIG;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
catch (_b) {
|
|
266
|
+
// cannot determine deploy target, use default DeployTarget.NO_DEPLOY_CONFIG
|
|
267
|
+
}
|
|
268
|
+
return deployTarget;
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Convert init setting property internalFeaturesEnabled to string value.
|
|
273
|
+
*
|
|
274
|
+
* @returns String value 'internal' | 'external' to be backward compatible with existing telemetry data format.
|
|
275
|
+
*/
|
|
276
|
+
function getInternalVsExternal() {
|
|
277
|
+
return config_state_1.ToolingTelemetrySettings.internalFeature ? 'internal' : 'external';
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Read the manifest.json for the app and locate the tools id.
|
|
281
|
+
*
|
|
282
|
+
* @param appPath appPath Root folder path of Fiori app
|
|
283
|
+
* @returns sourceTemplate section of data from manifest.json
|
|
284
|
+
*/
|
|
285
|
+
function getManifestSourceTemplate(appPath) {
|
|
286
|
+
var _a, _b, _c, _d;
|
|
287
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
288
|
+
let sourceTemplate = {};
|
|
289
|
+
try {
|
|
290
|
+
const manifestPath = path_1.default.join(appPath, 'webapp', 'manifest.json');
|
|
291
|
+
if (fs_1.default.existsSync(manifestPath)) {
|
|
292
|
+
const manifestStr = yield fs_1.default.promises.readFile(manifestPath, 'utf-8');
|
|
293
|
+
const manifest = JSON.parse(manifestStr);
|
|
294
|
+
sourceTemplate = (_a = manifest['sap.app']) === null || _a === void 0 ? void 0 : _a.sourceTemplate;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
catch (_e) {
|
|
298
|
+
// Failed to read manifest.json
|
|
299
|
+
}
|
|
300
|
+
sourceTemplate = sourceTemplate !== null && sourceTemplate !== void 0 ? sourceTemplate : {};
|
|
301
|
+
sourceTemplate.id = (_b = sourceTemplate.id) !== null && _b !== void 0 ? _b : '';
|
|
302
|
+
sourceTemplate.version = (_c = sourceTemplate.version) !== null && _c !== void 0 ? _c : '';
|
|
303
|
+
sourceTemplate.toolsId = (_d = sourceTemplate.toolsId) !== null && _d !== void 0 ? _d : types_1.ToolsId.NO_TOOLS_ID;
|
|
304
|
+
return sourceTemplate;
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Get node.js runtime version.
|
|
309
|
+
*
|
|
310
|
+
* @returns Node.js version
|
|
311
|
+
*/
|
|
312
|
+
function getProcessVersions() {
|
|
313
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
314
|
+
try {
|
|
315
|
+
const output = yield spawnCommand('node', ['-p', 'JSON.stringify(process.versions)']);
|
|
316
|
+
return JSON.parse(output);
|
|
317
|
+
}
|
|
318
|
+
catch (_a) {
|
|
319
|
+
return {};
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Spawn a command to find out node.js version used for the runtime.
|
|
325
|
+
*
|
|
326
|
+
* @param command command name
|
|
327
|
+
* @param commandArgs command arguments
|
|
328
|
+
* @returns Node.js version
|
|
329
|
+
*/
|
|
330
|
+
function spawnCommand(command, commandArgs) {
|
|
331
|
+
const spawnOptions = process.platform.startsWith('win')
|
|
332
|
+
? { windowsVerbatimArguments: true, shell: true, cwd: os_1.default.homedir() }
|
|
333
|
+
: { cwd: os_1.default.homedir() };
|
|
334
|
+
return new Promise((resolve, reject) => {
|
|
335
|
+
let output = '';
|
|
336
|
+
const spawnProcess = (0, child_process_1.spawn)(command, commandArgs, spawnOptions);
|
|
337
|
+
spawnProcess.stdout.on('data', (data) => {
|
|
338
|
+
const newData = data.toString();
|
|
339
|
+
output += newData;
|
|
340
|
+
});
|
|
341
|
+
spawnProcess.stderr.on('data', (data) => {
|
|
342
|
+
const newData = data.toString();
|
|
343
|
+
output += newData;
|
|
344
|
+
});
|
|
345
|
+
spawnProcess.on('exit', () => {
|
|
346
|
+
resolve(output);
|
|
347
|
+
});
|
|
348
|
+
spawnProcess.on('error', (error) => {
|
|
349
|
+
reject(error);
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
exports.spawnCommand = spawnCommand;
|
|
354
|
+
//# sourceMappingURL=data-processor.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
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 __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.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
|
+
__exportStar(require("./telemetry-settings"), exports);
|
|
22
|
+
__exportStar(require("./types"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ApplicationInsightClient } from '../base/client/azure-appinsight-client';
|
|
2
|
+
import type { SampleRate } from '../base/types/sample-rate';
|
|
3
|
+
import type { TelemetryHelperProperties, TelemetryEvent } from './types';
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
declare class ToolsSuiteTelemetryClient extends ApplicationInsightClient {
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param applicationKey Application key to identify the Azure Application Insight resource
|
|
11
|
+
* @param extensionName Unique name of the extension in the format of {publisher}.{extension}
|
|
12
|
+
* @param extensionVersion Conventional version number of the extension
|
|
13
|
+
*/
|
|
14
|
+
constructor(applicationKey: string, extensionName: string, extensionVersion: string);
|
|
15
|
+
/**
|
|
16
|
+
* Send a telemetry event to Azure Application Insights.
|
|
17
|
+
*
|
|
18
|
+
* @deprecated Use reportEvent instead.
|
|
19
|
+
* @param eventName Categorize the type of the event within the scope of an extension.
|
|
20
|
+
* @param properties A set of string properties to be reported
|
|
21
|
+
* @param measurements A set of numeric measurements to be reported
|
|
22
|
+
* @param sampleRate Sampling the event to be sent
|
|
23
|
+
* @param telemetryHelperProperties Properties that are passed to the processCommonPropertiesHelper function to assit generate project specific telemetry data
|
|
24
|
+
* @param ignoreSettings Ignore telemetryEnabled settings and skip submitting telemetry data
|
|
25
|
+
* @returns Promise<void>
|
|
26
|
+
*/
|
|
27
|
+
report(eventName: string, properties: {
|
|
28
|
+
[key: string]: string;
|
|
29
|
+
}, measurements: {
|
|
30
|
+
[key: string]: number;
|
|
31
|
+
}, sampleRate: SampleRate | undefined, telemetryHelperProperties?: TelemetryHelperProperties, ignoreSettings?: boolean): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Send a telemetry event to Azure Application Insights.
|
|
34
|
+
*
|
|
35
|
+
* @param event Telemetry Event
|
|
36
|
+
* @param sampleRate Sampling the event to be sent
|
|
37
|
+
* @param telemetryHelperProperties Properties that are passed to the processCommonPropertiesHelper function to assit generate project specific telemetry data
|
|
38
|
+
* @param ignoreSettings Ignore telemetryEnabled settings and skip submitting telemetry data
|
|
39
|
+
* @returns Promise<void>
|
|
40
|
+
*/
|
|
41
|
+
reportEvent(event: TelemetryEvent, sampleRate?: SampleRate, telemetryHelperProperties?: TelemetryHelperProperties, ignoreSettings?: boolean): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Send a telemetry event to Azure Application Insights. This API makes sure the telemetry event
|
|
44
|
+
* is flushed to Azure backend before executing the next statement. Since this API blocks
|
|
45
|
+
* normal execution flow, please use this API cautiously. See `reportEvent()` method for non-blocking
|
|
46
|
+
* usage.
|
|
47
|
+
*
|
|
48
|
+
* @param event Telemetry Event
|
|
49
|
+
* @param sampleRate Sampling the event to be sent
|
|
50
|
+
* @param telemetryHelperProperties Properties that are passed to the processCommonPropertiesHelper function to assit generate project specific telemetry data
|
|
51
|
+
* @param ignoreSettings Ignore telemetryEnabled settings and skip submitting telemetry data
|
|
52
|
+
* @returns Promise<void>
|
|
53
|
+
*/
|
|
54
|
+
reportEventBlocking(event: TelemetryEvent, sampleRate?: SampleRate, telemetryHelperProperties?: TelemetryHelperProperties, ignoreSettings?: boolean): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Add common properties to properties and measurements of consumer's telemetry event.
|
|
57
|
+
*
|
|
58
|
+
* @param event telemetry event
|
|
59
|
+
* @param telemetryHelperProperties Additional properties that can be undefined
|
|
60
|
+
* @returns Telemetry properties and measurements
|
|
61
|
+
*/
|
|
62
|
+
private collectToolsSuiteTelemetry;
|
|
63
|
+
}
|
|
64
|
+
export { ToolsSuiteTelemetryClient };
|
|
65
|
+
//# sourceMappingURL=telemetry-client.d.ts.map
|
|
@@ -0,0 +1,118 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ToolsSuiteTelemetryClient = void 0;
|
|
13
|
+
const azure_appinsight_client_1 = require("../base/client/azure-appinsight-client");
|
|
14
|
+
const _1 = require(".");
|
|
15
|
+
const date_1 = require("../base/utils/date");
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
class ToolsSuiteTelemetryClient extends azure_appinsight_client_1.ApplicationInsightClient {
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @param applicationKey Application key to identify the Azure Application Insight resource
|
|
23
|
+
* @param extensionName Unique name of the extension in the format of {publisher}.{extension}
|
|
24
|
+
* @param extensionVersion Conventional version number of the extension
|
|
25
|
+
*/
|
|
26
|
+
constructor(applicationKey, extensionName, extensionVersion) {
|
|
27
|
+
super(applicationKey, extensionName, extensionVersion);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Send a telemetry event to Azure Application Insights.
|
|
31
|
+
*
|
|
32
|
+
* @deprecated Use reportEvent instead.
|
|
33
|
+
* @param eventName Categorize the type of the event within the scope of an extension.
|
|
34
|
+
* @param properties A set of string properties to be reported
|
|
35
|
+
* @param measurements A set of numeric measurements to be reported
|
|
36
|
+
* @param sampleRate Sampling the event to be sent
|
|
37
|
+
* @param telemetryHelperProperties Properties that are passed to the processCommonPropertiesHelper function to assit generate project specific telemetry data
|
|
38
|
+
* @param ignoreSettings Ignore telemetryEnabled settings and skip submitting telemetry data
|
|
39
|
+
* @returns Promise<void>
|
|
40
|
+
*/
|
|
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
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Send a telemetry event to Azure Application Insights.
|
|
57
|
+
*
|
|
58
|
+
* @param event Telemetry Event
|
|
59
|
+
* @param sampleRate Sampling the event to be sent
|
|
60
|
+
* @param telemetryHelperProperties Properties that are passed to the processCommonPropertiesHelper function to assit generate project specific telemetry data
|
|
61
|
+
* @param ignoreSettings Ignore telemetryEnabled settings and skip submitting telemetry data
|
|
62
|
+
* @returns Promise<void>
|
|
63
|
+
*/
|
|
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
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Send a telemetry event to Azure Application Insights. This API makes sure the telemetry event
|
|
75
|
+
* is flushed to Azure backend before executing the next statement. Since this API blocks
|
|
76
|
+
* normal execution flow, please use this API cautiously. See `reportEvent()` method for non-blocking
|
|
77
|
+
* usage.
|
|
78
|
+
*
|
|
79
|
+
* @param event Telemetry Event
|
|
80
|
+
* @param sampleRate Sampling the event to be sent
|
|
81
|
+
* @param telemetryHelperProperties Properties that are passed to the processCommonPropertiesHelper function to assit generate project specific telemetry data
|
|
82
|
+
* @param ignoreSettings Ignore telemetryEnabled settings and skip submitting telemetry data
|
|
83
|
+
* @returns Promise<void>
|
|
84
|
+
*/
|
|
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
|
+
});
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Add common properties to properties and measurements of consumer's telemetry event.
|
|
96
|
+
*
|
|
97
|
+
* @param event telemetry event
|
|
98
|
+
* @param telemetryHelperProperties Additional properties that can be undefined
|
|
99
|
+
* @returns Telemetry properties and measurements
|
|
100
|
+
*/
|
|
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
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.ToolsSuiteTelemetryClient = ToolsSuiteTelemetryClient;
|
|
118
|
+
//# sourceMappingURL=telemetry-client.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ToolsSuiteTelemetryInitSettings } from './types';
|
|
2
|
+
import { TelemetrySetting } from '@sap-ux/store';
|
|
3
|
+
/**
|
|
4
|
+
* Telemetry API function to init settings.
|
|
5
|
+
*
|
|
6
|
+
* @param options Settings pass from the consumer module.
|
|
7
|
+
*/
|
|
8
|
+
export declare const initTelemetrySettings: (options: ToolsSuiteTelemetryInitSettings) => Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Toggle on/off enable telemetry setting. This will update telemetry settings file
|
|
11
|
+
* and the runtime setting.
|
|
12
|
+
*
|
|
13
|
+
* @param enableTelemetry Telemetry is enabled or not
|
|
14
|
+
*/
|
|
15
|
+
export declare function setEnableTelemetry(enableTelemetry: boolean): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Get telemetry settings.
|
|
18
|
+
*
|
|
19
|
+
* @returns Telemetry settings of context module that consumes telemetry library
|
|
20
|
+
*/
|
|
21
|
+
export declare function getTelemetrySetting(): Promise<TelemetrySetting | undefined>;
|
|
22
|
+
//# sourceMappingURL=telemetry-settings.d.ts.map
|