fix: 修改埋点事件名称,适配sdk接口

This commit is contained in:
hewenfei 2023-11-21 16:02:22 +08:00 committed by He Sir
parent 84ffa42c23
commit 5d2f696677
8 changed files with 68 additions and 16 deletions

View File

@ -100,14 +100,14 @@ SwipeView {
appPageHeader.title = folderName; appPageHeader.title = folderName;
appPageHeader.content = folderPageHeader; appPageHeader.content = folderPageHeader;
root.currentIndex = SwipeView.index; root.currentIndex = SwipeView.index;
EventTrack.sendClickEvent("EnterFolderPage", "AppView"); EventTrack.sendClickEvent("enter_folder_page", "AppView");
} }
function hideFolderPage() { function hideFolderPage() {
root.currentIndex = appListBase.SwipeView.index; root.currentIndex = appListBase.SwipeView.index;
appPageHeader.title = appList.title; appPageHeader.title = appList.title;
appPageHeader.content = null; appPageHeader.content = null;
//active = false; //active = false;
EventTrack.sendClickEvent("ExitFolderPage", "AppView"); EventTrack.sendClickEvent("exit_folder_page", "AppView");
} }
Component.onCompleted: { Component.onCompleted: {

View File

@ -242,6 +242,7 @@ Item {
Keys.onPressed: { Keys.onPressed: {
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) { if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
ListView.view.currentIndex = model.index; ListView.view.currentIndex = model.index;
EventTrack.sendClickEvent("switch_plugin", "Sidebar", {"plugin": model.name});
} }
} }
@ -254,7 +255,6 @@ Item {
function select() { function select() {
if (extensionLoader.source !== model.url) { if (extensionLoader.source !== model.url) {
extensionLoader.setSource(model.url, {extensionData: extensionData}); extensionLoader.setSource(model.url, {extensionData: extensionData});
EventTrack.sendClickEvent("Switch Plugin: " + model.name, "Sidebar");
} }
} }
@ -274,6 +274,7 @@ Item {
onClicked: { onClicked: {
normalUI.focusToFalse(); normalUI.focusToFalse();
parent.ListView.view.currentIndex = model.index; parent.ListView.view.currentIndex = model.index;
EventTrack.sendClickEvent("switch_plugin", "Sidebar", {"plugin": model.name});
} }
} }
} }

View File

@ -221,7 +221,7 @@ void AppFolderHelper::addAppToFolder(const QString &appId, const int &folderId)
forceSync(); forceSync();
Q_EMIT folderDataChanged(folderId); Q_EMIT folderDataChanged(folderId);
EventTrack::instance()->sendDefaultEvent("AddAppToFolder", "AppView"); EventTrack::instance()->sendDefaultEvent("add_app_to_folder", "AppView");
} }
void AppFolderHelper::addAppToNewFolder(const QString &appId, const QString &folderName) void AppFolderHelper::addAppToNewFolder(const QString &appId, const QString &folderName)
@ -245,7 +245,7 @@ void AppFolderHelper::addAppToNewFolder(const QString &appId, const QString &fol
insertFolder(folder); insertFolder(folder);
Q_EMIT folderAdded(folder.id); Q_EMIT folderAdded(folder.id);
EventTrack::instance()->sendDefaultEvent("AddAppToNewFolder", "AppView"); EventTrack::instance()->sendDefaultEvent("add_app_to_new_folder", "AppView");
} }
void AppFolderHelper::addAppsToNewFolder(const QString &appIdA, const QString &appIdB, const QString &folderName) void AppFolderHelper::addAppsToNewFolder(const QString &appIdA, const QString &appIdB, const QString &folderName)
@ -311,7 +311,7 @@ bool AppFolderHelper::deleteFolder(const int& folderId)
} }
Q_EMIT folderDeleted(folderId); Q_EMIT folderDeleted(folderId);
EventTrack::instance()->sendDefaultEvent("DeleteFolder", "AppView"); EventTrack::instance()->sendDefaultEvent("delete_folder", "AppView");
return true; return true;
} }

View File

@ -60,7 +60,7 @@ void DataProviderManager::initProviders()
connect(this, &DataProviderManager::toUpdate, sort, &AppLetterSortPlugin::update); connect(this, &DataProviderManager::toUpdate, sort, &AppLetterSortPlugin::update);
registerProvider(sort); registerProvider(sort);
activateProvider(allProvider->id()); activateProvider(allProvider->id(), false);
allProvider->moveToThread(&m_worker); allProvider->moveToThread(&m_worker);
search->moveToThread(&m_worker); search->moveToThread(&m_worker);
category->moveToThread(&m_worker); category->moveToThread(&m_worker);
@ -152,7 +152,7 @@ ProviderInfo DataProviderManager::providerInfo(const QString &id) const
return info; return info;
} }
void DataProviderManager::activateProvider(const QString &id) void DataProviderManager::activateProvider(const QString &id, bool record)
{ {
if (!m_providers.contains(id) || m_activatedPlugin == id) { if (!m_providers.contains(id) || m_activatedPlugin == id) {
return; return;
@ -160,7 +160,11 @@ void DataProviderManager::activateProvider(const QString &id)
m_activatedPlugin = id; m_activatedPlugin = id;
Q_EMIT pluginChanged(m_activatedPlugin, m_providers.value(m_activatedPlugin)->group()); Q_EMIT pluginChanged(m_activatedPlugin, m_providers.value(m_activatedPlugin)->group());
EventTrack::instance()->sendClickEvent("Switch AppView: " + id, "AppView"); if (record) {
QMap<QString, QVariant> map;
map.insert("viewName", id);
EventTrack::instance()->sendClickEvent("switch_app_view", "AppView", map);
}
} }
DataProviderManager::~DataProviderManager() DataProviderManager::~DataProviderManager()

View File

@ -49,7 +49,7 @@ public:
QVector<ProviderInfo> providers(PluginGroup::Group group) const; QVector<ProviderInfo> providers(PluginGroup::Group group) const;
ProviderInfo providerInfo(const QString &id) const; ProviderInfo providerInfo(const QString &id) const;
QString activatedProvider() const; QString activatedProvider() const;
void activateProvider(const QString &id); void activateProvider(const QString &id, bool record = true);
QVector<DataEntity> data() const; QVector<DataEntity> data() const;
QVector<LabelItem> labels() const; QVector<LabelItem> labels() const;
void forceUpdate() const; void forceUpdate() const;

View File

@ -219,13 +219,13 @@ FavoriteMenuProvider::generateActions(QObject *parent, const QVariant &data, con
list << new QAction(QObject::tr("Fix to favorite"), parent); list << new QAction(QObject::tr("Fix to favorite"), parent);
QObject::connect(list.last(), &QAction::triggered, parent, [app] { QObject::connect(list.last(), &QAction::triggered, parent, [app] {
Q_EMIT AppDataManager::instance()->fixToFavoriteSignal(app.id(), 1); Q_EMIT AppDataManager::instance()->fixToFavoriteSignal(app.id(), 1);
EventTrack::instance()->sendDefaultEvent("Fix to favorite", "Right-click Menu"); EventTrack::instance()->sendDefaultEvent("fix_to_favorite", "Right-click Menu");
}); });
} else if (locationId == "favorite") { } else if (locationId == "favorite") {
list << new QAction(QObject::tr("Remove from favorite"), parent); list << new QAction(QObject::tr("Remove from favorite"), parent);
QObject::connect(list.last(), &QAction::triggered, parent, [app] { QObject::connect(list.last(), &QAction::triggered, parent, [app] {
Q_EMIT AppDataManager::instance()->fixToFavoriteSignal(app.id(), 0); Q_EMIT AppDataManager::instance()->fixToFavoriteSignal(app.id(), 0);
EventTrack::instance()->sendDefaultEvent("Remove from favorite", "Right-click Menu"); EventTrack::instance()->sendDefaultEvent("remove_from_favorite", "Right-click Menu");
}); });
} }
break; break;

View File

@ -22,6 +22,40 @@
namespace UkuiMenu { namespace UkuiMenu {
KCustomProperty* appendCustomProp(KTrackData *data, const QVariantMap &map)
{
if (!data || map.isEmpty()) {
return nullptr;
}
int i = 0;
auto properties = new KCustomProperty[map.size()];
QMapIterator<QString, QVariant> it(map);
while (it.hasNext()) {
it.next();
std::string string = it.key().toStdString();
properties[i].key = strdup(string.c_str());
string = it.value().toString().toStdString();
properties[i].value = strdup(string.c_str());
++i;
}
return properties;
}
void freeKCustomProperty(KCustomProperty *customProperty, int size)
{
for (int i = 0; i < size; ++i) {
delete customProperty[i].key;
delete customProperty[i].value;
}
delete [] customProperty;
}
EventTrack::EventTrack(QObject *parent) : QObject(parent) EventTrack::EventTrack(QObject *parent) : QObject(parent)
{ {
@ -39,18 +73,30 @@ EventTrack *EventTrack::instance()
return &eventTrack; return &eventTrack;
} }
void EventTrack::sendClickEvent(const QString &event, const QString &page) void EventTrack::sendClickEvent(const QString &event, const QString &page, const QVariantMap &map)
{ {
KTrackData* data = kdk_dia_data_init(KEVENTSOURCE_DESKTOP, KEVENT_CLICK); KTrackData* data = kdk_dia_data_init(KEVENTSOURCE_DESKTOP, KEVENT_CLICK);
KCustomProperty* properties = appendCustomProp(data, map);
if (properties) {
kdk_dia_append_custom_property(data, properties, map.size());
}
kdk_dia_upload_default(data, event.toUtf8().data(), page.toUtf8().data()); kdk_dia_upload_default(data, event.toUtf8().data(), page.toUtf8().data());
kdk_dia_data_free(data); kdk_dia_data_free(data);
freeKCustomProperty(properties, map.size());
} }
void EventTrack::sendDefaultEvent(const QString& event, const QString& page) void EventTrack::sendDefaultEvent(const QString& event, const QString& page, const QVariantMap &map)
{ {
KTrackData* data = kdk_dia_data_init(KEVENTSOURCE_DESKTOP, KEVENT_CUSTOM); KTrackData* data = kdk_dia_data_init(KEVENTSOURCE_DESKTOP, KEVENT_CUSTOM);
KCustomProperty* properties = appendCustomProp(data, map);
if (properties) {
kdk_dia_append_custom_property(data, properties, map.size());
}
kdk_dia_upload_default(data, event.toUtf8().data(), page.toUtf8().data()); kdk_dia_upload_default(data, event.toUtf8().data(), page.toUtf8().data());
kdk_dia_data_free(data); kdk_dia_data_free(data);
freeKCustomProperty(properties, map.size());
} }
void EventTrack::sendSearchEvent(const QString &event, const QString &page, const QString &content) void EventTrack::sendSearchEvent(const QString &event, const QString &page, const QString &content)

View File

@ -20,6 +20,7 @@
#define UKUI_MENU_EVENT_TRACK_H #define UKUI_MENU_EVENT_TRACK_H
#include <QObject> #include <QObject>
#include <QVariant>
#include <qqml.h> #include <qqml.h>
namespace UkuiMenu { namespace UkuiMenu {
@ -32,8 +33,8 @@ public:
static EventTrack *instance(); static EventTrack *instance();
explicit EventTrack(QObject *parent = nullptr); explicit EventTrack(QObject *parent = nullptr);
Q_INVOKABLE void sendClickEvent(const QString& event, const QString& page); Q_INVOKABLE void sendClickEvent(const QString& event, const QString& page, const QVariantMap &map = {});
Q_INVOKABLE void sendDefaultEvent(const QString& event, const QString& page); Q_INVOKABLE void sendDefaultEvent(const QString& event, const QString& page, const QVariantMap &map = {});
Q_INVOKABLE void sendSearchEvent(const QString& event, const QString& page, const QString& content); Q_INVOKABLE void sendSearchEvent(const QString& event, const QString& page, const QString& content);
}; };