fix(ukui-panel/panel)(ukui-panel-widgets/ukui-taskmanager)修改改变任务栏大小、任务栏位置、固定应用到任务栏不会生成埋点数据的问题

This commit is contained in:
aming 2024-07-10 15:46:37 +08:00 committed by iaom
parent 26b2e7af99
commit 04d65749b7
6 changed files with 111 additions and 1 deletions

View File

@ -27,7 +27,7 @@ file(GLOB TS_FILES translations/*.ts)
set(QRC_FILES qml/qml.qrc)
set(UKUI_PANEL_EXTERNAL_LIBS "")
set(UKUI_PANEL_PC_PKGS gsettings-qt kysdk-waylandhelper)
set(UKUI_PANEL_PC_PKGS gsettings-qt kysdk-waylandhelper kysdk-datacollect)
foreach(PC_LIB IN ITEMS ${UKUI_PANEL_PC_PKGS})
pkg_check_modules(${PC_LIB} REQUIRED IMPORTED_TARGET ${PC_LIB})
@ -51,6 +51,8 @@ set(PROJECT_SOURCES
src/view/widget-model.cpp
src/view/widget-model.h
src/view/common.h
src/data-collector.h
src/data-collector.cpp
)
qt5_generate_repc(PROJECT_SOURCES src/remote-config.rep SOURCE)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)

View File

@ -0,0 +1,46 @@
#include "data-collector.h"
QString DataCollector::positionToStr(const int &pos)
{
switch (pos)
{
case 1:
return QString("Top");
case 2:
return QString("Left");
case 3:
return QString("Right");
case 0:
return QString("Bottom");
}
return QString();
}
void DataCollector::setPanelPositionEvent(const int &pos)
{
KCustomProperty *property = new KCustomProperty;
property->key = strdup(QStringLiteral("panelPosition").toLocal8Bit().data());
property->value = strdup(positionToStr(pos).toLocal8Bit().data());
KTrackData *node = kdk_dia_data_init(KEVENTSOURCE_DESKTOP, KEVENT_CLICK);
kdk_dia_append_custom_property(node, property, 1);
kdk_dia_upload_default(node, strdup(QStringLiteral("adjust_panel_position_event").toLocal8Bit().data()),strdup(QStringLiteral("ukui-panel").toLocal8Bit().data()));
kdk_dia_data_free(node);
free(property->key);
free(property->value);
delete property;
}
void DataCollector::setPanelSizeEvent(const int &panelSize)
{
KCustomProperty *property = new KCustomProperty;
property->key = strdup(QStringLiteral("panelSize").toLocal8Bit().data());
property->value = strdup(QString::number(panelSize).toLocal8Bit().data());
KTrackData *node = kdk_dia_data_init(KEVENTSOURCE_DESKTOP, KEVENT_CLICK);
kdk_dia_append_custom_property(node, property, 1);
kdk_dia_upload_default(node, strdup(QStringLiteral("adjust_panel_size_event").toLocal8Bit().data()),strdup(QStringLiteral("ukui-panel").toLocal8Bit().data()));
kdk_dia_data_free(node);
free(property->key);
free(property->value);
delete property;
}

View File

@ -0,0 +1,29 @@
#ifndef DATACOLLECTOR_H
#define DATACOLLECTOR_H
#include <kysdk/diagnosetest/libkydatacollect.h>
#include <QString>
class DataCollector
{
private:
/**
* panel的位置转化为英文字符串上下左右 : 1, : 0, : 2, : 3,
* @param pos panel的位置
*/
static QString positionToStr(const int &pos);
public:
/**
* panel位置改变事件的数据锚点
* @param pos panel的位置
*/
static void setPanelPositionEvent(const int &pos);
/**
* panel大小改变事件的数据锚点描点
* @param panelSize panel的大小
*/
static void setPanelSizeEvent(const int &panelSize);
};
#endif // DATACOLLECTOR_H

View File

@ -36,6 +36,7 @@
#include "general-config-define.h"
#include "widget-model.h"
#include "shell.h"
#include "data-collector.h"
namespace UkuiPanel {
#define DEFAULT_PANEL_SIZE 48
@ -273,6 +274,8 @@ void Panel::setPosition(UkuiQuick::Types::Pos position)
// 仅同步到gsetting
QGSettings settings("org.ukui.panel.settings", "/org/ukui/panel/settings/", this);
settings.set(QStringLiteral("panelposition"), panelPosition);
//上传埋点数据
DataCollector::setPanelPositionEvent(panelPosition);
}
if (m_positionAction) {
@ -303,6 +306,8 @@ void Panel::setPanelSize(int size)
} else {
settings.set(QStringLiteral("panelsize"), m_panelSize + mainView()->margin()->right() + mainView()->margin()->left());
}
//上传埋点数据
DataCollector::setPanelSizeEvent(size);
}
void Panel::loadWidgetsConfig()

View File

@ -40,6 +40,7 @@
#include "actions.h"
#include "config.h"
#include "taskmanageradaptor.h"
#include <kysdk/diagnosetest/libkydatacollect.h>
static const QString QUICK_LAUNCHERS_KEY("quickLaunchers");
@ -488,6 +489,8 @@ void UkuiTaskManager::addQuickLauncher(const QString &desktopFile, int order)
endRemoveRows();
}
d->m_quickLaunchersOrder.removeAt(oldOrder);
//上传埋点数据
addQuickLauncherEvent(desktopFile, "unpin from taskbar");
} else {
if (order > d->m_quickLaunchersOrder.size() - 1) {
order = d->m_quickLaunchersOrder.size() - 1;
@ -524,6 +527,8 @@ void UkuiTaskManager::addQuickLauncher(const QString &desktopFile, int order)
}
d->m_quickLaunchersOrder.insert(order, desktopFile);
d->save();
//上传埋点数据
addQuickLauncherEvent(desktopFile, "pin to taskbar");
}
}
@ -749,5 +754,23 @@ void UkuiTaskManager::onAppUninstalled(const QStringList &desktopFiles)
}
}
}
void UkuiTaskManager::addQuickLauncherEvent(const QString &applicationName, const QString &operate )
{
KCustomProperty *property = new KCustomProperty[2];
property[0].key = strdup(QStringLiteral("AppliciationName").toLocal8Bit().data());
property[0].value = strdup(applicationName.toLocal8Bit().data());
property[1].key = strdup(QStringLiteral("EventType").toLocal8Bit().data());
property[1].value = strdup(operate.toLocal8Bit().data());
KTrackData *node = kdk_dia_data_init(KEVENTSOURCE_DESKTOP, KEVENT_CLICK);
kdk_dia_append_custom_property(node, property, 2);
kdk_dia_upload_default(node, strdup(QStringLiteral("pin_to_taskbar_event").toLocal8Bit().data()),strdup(QStringLiteral("ukui-panel").toLocal8Bit().data()));
kdk_dia_data_free(node);
free(property[0].key);
free(property[0].value);
free(property[1].key);
free(property[1].value);
delete []property;
}
}
#include "moc_ukui-task-manager.cpp"

View File

@ -125,6 +125,11 @@ private:
void addQuickLauncher(const QString &desktopFile, int order);
int quickLauncherCountBeforeRow(int row) const;
void onAppUninstalled(const QStringList &desktopFiles);
/**
* /
* @param applicationName desktop文件
*/
void addQuickLauncherEvent(const QString &applicationName, const QString &operate);
class Private;
Private *d = nullptr;
};