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: added recommendation acceptance tracking #158

Merged
merged 1 commit into from
May 11, 2024

Conversation

olavtar
Copy link
Contributor

@olavtar olavtar commented May 10, 2024

Added "component_analysis_recommendation_accepted" event to track recommendation acceptance for telemetry.

Jira: APPENG-2312

var telemetryMsg = TelemetryService.instance().action("component_analysis_recommendation_accepted");
telemetryMsg.property("package", this.report.getRef().name());
telemetryMsg.property("version", recommendedVersion);
telemetryMsg.property(ApiService.TelemetryKeys.ECOSYSTEM.toString(), saUtils.determinePackageManagerName(file.getName()));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
telemetryMsg.property(ApiService.TelemetryKeys.ECOSYSTEM.toString(), saUtils.determinePackageManagerName(file.getName()));
telemetryMsg.property(ApiService.TelemetryKeys.ECOSYSTEM.toString(), CAAnnotator.getPackageManager(file.getName()));

Please use this method instead and change it to be static. Also delete line 63.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

telemetryMsg.property(ApiService.TelemetryKeys.PLATFORM.toString(), System.getProperty("os.name"));
telemetryMsg.property(ApiService.TelemetryKeys.MANIFEST.toString(), file.getName());
telemetryMsg.property(ApiService.TelemetryKeys.RHDA_TOKEN.toString(), ApiSettingsState.getInstance().rhdaToken);
apiService.setRequestProperties(file.getName());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
apiService.setRequestProperties(file.getName());

This method should not be called. It is only used when calling exhort-java-api. Also delete line 62.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines 64 to 72
var telemetryMsg = TelemetryService.instance().action("component_analysis_recommendation_accepted");
telemetryMsg.property("package", this.report.getRef().name());
telemetryMsg.property("version", recommendedVersion);
telemetryMsg.property(ApiService.TelemetryKeys.ECOSYSTEM.toString(), saUtils.determinePackageManagerName(file.getName()));
telemetryMsg.property(ApiService.TelemetryKeys.PLATFORM.toString(), System.getProperty("os.name"));
telemetryMsg.property(ApiService.TelemetryKeys.MANIFEST.toString(), file.getName());
telemetryMsg.property(ApiService.TelemetryKeys.RHDA_TOKEN.toString(), ApiSettingsState.getInstance().rhdaToken);
apiService.setRequestProperties(file.getName());
telemetryMsg.send();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please move these lines of code for telemetry to a new method in the exhort package. Create the method in TelemetryService or ApiService.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

this.updateVersion(project, editor, file, recommendedVersion);
ApiService apiService = ServiceManager.getService(ApiService.class);
SaUtils saUtils = new SaUtils();
var telemetryMsg = TelemetryService.instance().action("component_analysis_recommendation_accepted");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
var telemetryMsg = TelemetryService.instance().action("component_analysis_recommendation_accepted");
var telemetryMsg = TelemetryService.instance().action("recommendation-accepted");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -21,4 +25,16 @@ public class TelemetryService {
public static TelemetryMessageBuilder instance() {
return INSTANCE.builder.get();
}

public static void sendTelemetryEvent(PsiFile file, String recommendedVersion, DependencyReport report, String actionName) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
public static void sendTelemetryEvent(PsiFile file, String recommendedVersion, DependencyReport report, String actionName) {
public static void sendPackageUpdateEvent(PsiFile file, String packageName, String packageVersion, String actionName) {

I think the method name is too generic. This method only sends package and version that are changed.
Maybe, rename it to sendPackageUpdateEvent.
The third argument can be changed to String.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

this.updateVersion(project, editor, file, getRecommendedVersion(this.report));
String recommendedVersion = getRecommendedVersion(this.report);
this.updateVersion(project, editor, file, recommendedVersion);
TelemetryService.sendTelemetryEvent(file, recommendedVersion, this.report, "recommendation_accepted");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
TelemetryService.sendTelemetryEvent(file, recommendedVersion, this.report, "recommendation_accepted");
TelemetryService.sendTelemetryEvent(file, recommendedVersion, this.report, "recommendation-accepted");

The actionName used dash instead of underscore in other scenarios.
For example:

var telemetryMsg = TelemetryService.instance().action("stack-analysis");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Initially was using the same action name as Ilona did in the VS Code extension, not sure if they should match.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link

sonarcloud bot commented May 10, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@olavtar olavtar requested a review from xieshenzh May 10, 2024 19:30
@zvigrinberg zvigrinberg merged commit ee5a910 into redhat-developer:main May 11, 2024
8 checks passed
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.

3 participants