feat: add application launch event reporting#354
Merged
Conversation
89bf3d6 to
b924948
Compare
BLumia
reviewed
May 8, 2026
b924948 to
185ec30
Compare
BLumia
reviewed
May 8, 2026
BLumia
reviewed
May 8, 2026
Add event reporting for application launch lifecycle, including launch, launch failure, launch duration, and abnormal exit events via DDEAPI EventLogger. 添加应用启动事件上报功能,通过 DDEAPI EventLogger 上报启动、启动失败、 启动耗时及异常退出等事件。 - Add EventReporter module for reporting app launch, launch failure, launch duration and abnormal exit events. - Pass launch type through dde-am CLI (--launch-type) and track it in InstanceService as a D-Bus property. - Monitor systemd unit result to detect abnormal exits (failed, canceled, timeout, signal, core-dump, exit-code) and report with journalctl logs. - Handle ll-cli applications by extracting actual appId for event reporting. - Add LaunchType property (0: other, 1: launcher, 2: taskbar, 3: desktop icon, 4: autostart) to Instance D-Bus interface. - Add dde-api-dev build dependency. - 新增 EventReporter 模块,用于上报应用启动、启动失败、启动耗时及异常退出事件。 - 通过 dde-am CLI (--launch-type) 传递启动来源类型,并在 InstanceService 中 作为 D-Bus 属性记录。 - 监听 systemd unit 的 Result 属性变化,检测异常退出(failed、canceled、 timeout、signal、core-dump、exit-code)并上报 journalctl 日志。 - 对 ll-cli 应用解析出实际 appId 用于事件上报。 - 在 Instance D-Bus 接口新增 LaunchType 属性(0: 其他,1: 启动器, 2: 任务栏,3: 桌面图标,4: 自启动)。 - 添加 dde-api-dev 打包依赖。 PMS: TASK-388657
185ec30 to
880836d
Compare
deepin pr auto reviewGit Diff 代码审查报告整体概述这段代码主要实现了应用程序启动事件的记录和报告功能,包括:
语法与逻辑审查1. CMakeLists.txt 修改find_package(DDEAPI QUIET)
if(DDEAPI_FOUND)
set(HAVE_DDE_API_EVENTLOGGER ON)
message(STATUS "Found DDEAPI: EventLogger available")
else()
message(STATUS "DDEAPI not found, event logging will be disabled")
endif()优点:
建议:
2. DBus接口修改<property name="LaunchType" type="s" access="read">优点:
建议:
3. EventReporter 实现void EventReporter::reportAppLaunch(const QString &appName, const QString &appVersion, qint64 timeMs, const QString &launchType, const QString &uniqueID)
{
#ifdef HAVE_DDE_API_EVENTLOGGER
DDE_EventLogger::EventLogger::instance().writeEventLog({...});
#else
Q_UNUSED(appName)
Q_UNUSED(appVersion)
Q_UNUSED(timeMs)
Q_UNUSED(launchType)
Q_UNUSED(uniqueID)
#endif
}优点:
问题:
建议:
4. 版本查询实现QString EventReporter::getAppVersion(const QString &appId)
{
// ...
QProcess proc;
proc.start("dpkg-query", {"-W", "-f=${Version}", appId});
proc.waitForFinished(3000);
// ...
if (version.isEmpty() && appId.startsWith("org.")) {
proc.start("ll-cli", {"info", appId});
proc.waitForFinished(5000);
// ...
}
// ...
}问题:
建议:
5. 异常退出处理if (result == u"failed" || result == u"canceled" || result == u"timeout"
|| result == u"signal" || result == u"core-dump" || result == u"exit-code") {
QStringList logArgs{QStringLiteral("--unit=%1").arg(unitName),
"-n", "20", "-o", "cat", "-o", "with-unit", "--no-pager"};
QProcess logProc;
logProc.start("journalctl", logArgs);
logProc.waitForFinished(3000);
QString logInfo = QString::fromUtf8(logProc.readAllStandardOutput());
EventReporter::reportAppAbnormalExit(app->eventAppId(), (*instanceIt)->launchType(), unitName, logInfo, (*instanceIt)->launchUniqueId());
}问题:
建议:
代码质量审查优点
改进建议
代码性能审查
代码安全审查
其他建议
总结这段代码实现了应用程序启动事件的记录功能,整体设计合理,但存在以下主要问题需要改进:
建议在合并前重点解决同步操作和安全性问题,并添加适当的测试用例。 |
BLumia
approved these changes
May 8, 2026
ComixHe
approved these changes
May 9, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, ComixHe, Ivy233 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add event reporting for application launch lifecycle, including launch, launch failure, launch duration, and abnormal exit events via DDEAPI EventLogger.
添加应用启动事件上报功能,通过 DDEAPI EventLogger 上报启动、启动失败、
启动耗时及异常退出等事件。
Add EventReporter module for reporting app launch, launch failure, launch duration and abnormal exit events.
Pass launch type through dde-am CLI (--launch-type) and track it in InstanceService as a D-Bus property.
Monitor systemd unit result to detect abnormal exits (failed, canceled, timeout, signal, core-dump, exit-code) and report with journalctl logs.
Handle ll-cli applications by extracting actual appId for event reporting.
Add LaunchType property (0: other, 1: launcher, 2: taskbar, 3: desktop icon, 4: autostart) to Instance D-Bus interface.
Add dde-api-dev build dependency.
新增 EventReporter 模块,用于上报应用启动、启动失败、启动耗时及异常退出事件。
通过 dde-am CLI (--launch-type) 传递启动来源类型,并在 InstanceService 中 作为 D-Bus 属性记录。
监听 systemd unit 的 Result 属性变化,检测异常退出(failed、canceled、 timeout、signal、core-dump、exit-code)并上报 journalctl 日志。
对 ll-cli 应用解析出实际 appId 用于事件上报。
在 Instance D-Bus 接口新增 LaunchType 属性(0: 其他,1: 启动器, 2: 任务栏,3: 桌面图标,4: 自启动)。
添加 dde-api-dev 打包依赖。
PMS: TASK-388657