Skip to content

Commit

Permalink
Merge pull request #1090 from Aalto-LeTech/report-course-info
Browse files Browse the repository at this point in the history
Add course info to error reports
  • Loading branch information
OlliKiljunen authored Jan 12, 2024
2 parents 7192066 + 8e4a84f commit cb1b71a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import fi.aalto.cs.apluscourses.intellij.utils.CourseFileManager;
import fi.aalto.cs.apluscourses.intellij.utils.IntelliJFilterOption;
import fi.aalto.cs.apluscourses.intellij.utils.ProjectKey;
import fi.aalto.cs.apluscourses.model.Course;
import fi.aalto.cs.apluscourses.model.ExercisesTree;
import fi.aalto.cs.apluscourses.model.NewsTree;
import fi.aalto.cs.apluscourses.presentation.CourseEndedBannerViewModel;
Expand All @@ -33,7 +34,9 @@
import fi.aalto.cs.apluscourses.presentation.module.ModuleFilter;
import fi.aalto.cs.apluscourses.presentation.news.NewsTreeViewModel;
import fi.aalto.cs.apluscourses.utils.observable.ObservableProperty;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -229,6 +232,14 @@ public CourseProject getCourseProject(@Nullable Project project) {
return courseProjects.get(new ProjectKey(project));
}

/**
* Returns a list of all open course projects. The order is arbitrary.
* @return A list.
*/
private @NotNull List<@NotNull CourseProject> getAllCourseProjects() {
return new ArrayList<>(courseProjects.values());
}

/**
* Returns the {@link CourseFileManager} instance corresponding to the given project. A new
* instance is created if no instance exists yet.
Expand Down Expand Up @@ -379,6 +390,18 @@ public void unsetLocalIdeSettings() {
.forEach(applicationPropertiesManager::unsetValue);
}

/**
* Returns a string that holds technical info about the course projects that are open in the IDE.
* @return A string.
*/
public @NotNull String getTechnicalCourseDescription() {
return String.join(",", getAllCourseProjects()
.stream()
.map(CourseProject::getCourse)
.map(Course::getTechnicalDescription)
.toList());
}

public interface PropertiesManager {
@Nullable String getValue(@NotNull String key);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.util.Consumer;
import fi.aalto.cs.apluscourses.intellij.services.PluginSettings;
import fi.aalto.cs.apluscourses.utils.BuildInfo;
import java.awt.Component;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -63,7 +64,8 @@ private JSONObject serializeErrorData(@Nullable String errorInfo,
.put("loadedPlugins", loadedPlugins)
.put("errorInfo", errorInfo)
.put("lastAction", lastActionId)
.put("stackTraces", stackTraces);
.put("stackTraces", stackTraces)
.put("course", PluginSettings.getInstance().getTechnicalCourseDescription());
}

@Override
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/fi/aalto/cs/apluscourses/model/Course.java
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,10 @@ public String getApiUrl() {
return aplusUrl + "api/v2/";
}

public @NotNull String getCourseApiUrl() {
return getApiUrl() + "courses/" + getId();
}

@NotNull
public Map<String, String[]> getReplInitialCommands() {
return replInitialCommands;
Expand Down Expand Up @@ -813,4 +817,8 @@ public String getFeedbackParser() {
public String getNewsParser() {
return newsParser;
}

public @NotNull String getTechnicalDescription() {
return String.format("%s <%s>", getName(), getCourseApiUrl());
}
}
1 change: 1 addition & 0 deletions tools/reports-server/reportmgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def save_report(client_address, report_string):
report_file.write(f"JVM version: {_get_string_safe(report_data, 'jvmName')} ({_get_string_safe(report_data, 'jvmVersion')})\n\n")
report_file.write(f"Plugin version: {_get_string_safe(report_data, 'pluginVersion')}\n")
report_file.write(f"Last action performed by user: {_get_string_safe(report_data, 'lastAction')}\n")
report_file.write(f"Open courses: {_get_string_safe(report_data, 'course')}\n")
report_file.write(f"Additional error details: {_get_string_safe(report_data, 'errorInfo')}\n\n")
report_file.write(f"Active plugins: (count: {len(active_plugins)}):\n")
for plugin in active_plugins:
Expand Down

0 comments on commit cb1b71a

Please sign in to comment.