Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: usage analytics report for project types status - ON HOLD - DO NOT MERGE!!! #315

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

NetaMolcho
Copy link
Contributor

No description provided.

Comment on lines 40 to 43
if (isBAS()) {
AnalyticsWrapper.createTracker(context.extensionPath);
void reportProjectTypesToUsageAnalytics(basToolkitAPI);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (isBAS()) {
AnalyticsWrapper.createTracker(context.extensionPath);
void reportProjectTypesToUsageAnalytics(basToolkitAPI);
}
setTimeout(() => {
if (isBAS()) {
AnalyticsWrapper.createTracker(context.extensionPath);
void reportProjectTypesToUsageAnalytics(basToolkitAPI);
}
});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider to move this code up into the first "if (isBAS())" code branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't because I need to use basToolkitAPI which is created after the first isBAS()

@@ -12,7 +18,7 @@ export enum ExtensionRunMode {
unexpected = `unexpected`,
}

export function shouldRunCtlServer(): boolean {
export function isBAS(): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function name is now confusing. it returns true in the case of "BAS", "hybrid" and "PE". the previous name was more meaningful

Comment on lines 71 to 72
const devspaceInfo = await devspace.getDevspaceInfo();
const projects = await getProjectsInfo(basToolkitAPI);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these two calls are independent of each other, consider calling at the same time, e.g. Promise.all (...)

@@ -58,3 +64,34 @@ function getExtensionRunPlatform(): ExtensionRunMode {

return runPlatform;
}

export async function reportProjectTypesToUsageAnalytics(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing the function return type

) {
const devspaceInfo = await devspace.getDevspaceInfo();
const projects = await getProjectsInfo(basToolkitAPI);
void AnalyticsWrapper.traceProjectTypesStatus(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whether we need to report the empty data ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will report only for the created projects

);
}

async function getProjectsInfo(basToolkitAPI: BasToolkit) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return type is missing in function signature

async function getProjectsInfo(basToolkitAPI: BasToolkit) {
try {
const workspaceAPI = basToolkitAPI.workspaceAPI;
const homedirProjects: string = joinPath(homedir(), "projects");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider to use 'workspace.workspaceFolders' instead of hardcode heuristics

undefined,
homedirProjects
);
const projectInfoList: (ProjectData | undefined)[] = await Promise.all(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please verify (ProjectData | undefined)[] casting.

Comment on lines 65 to 86
let projectType;
switch (type) {
case "com.sap.cap":
projectType = "CAP";
break;
case "com.sap.ui":
projectType = "UI5";
break;
case "com.sap.mdk":
projectType = "MDK";
break;
case "com.sap.fe":
projectType = "FE";
break;
case "com.sap.hana":
projectType = "HANA";
break;
case "com.sap.lcap":
projectType = "LCAP";
break;
default:
projectType = "BASEmpty";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this transformation needed? why not report the actual type received?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

@idoprz
Copy link
Contributor

idoprz commented May 28, 2024

Hi,

Before merging this, please validate with Xin:

  1. Check that this API actually return all projects under all structure. including deep nested projects
  2. We call this API several times when devspace starts. Make sure with Xin there is cache for this. If not, you cannot merge this.

): void {
try {
const eventName = AnalyticsWrapper.EVENT_TYPES.PROJECT_TYPES_STATUS;
for (const type in projects) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use typeName instead of type - it is the display name of the type and remove the for and switch case-
https://github.tools.sap/LCAP/project/blob/main/packages/artifact-management-base/src/project/ProjectData.ts#L12 .

@NetaMolcho NetaMolcho changed the title feat: usage analytics report for project types status feat: usage analytics report for project types status - ON HOLD - DO NOT MERGE!!! May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants