diff --git a/CMakeLists.txt b/CMakeLists.txt index de70376..b561b03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ find_package(PkgConfig REQUIRED) set(UKUI_MENU_EXTERNAL_LIBS "") # glib-2.0 gio-unix-2.0 gsettings-qt x11 kysdk-waylandhelper -set(UKUI_MENU_PC_PKGS glib-2.0 gsettings-qt x11 kysdk-waylandhelper ukui-search) +set(UKUI_MENU_PC_PKGS glib-2.0 gsettings-qt x11 kysdk-waylandhelper ukui-search kysdk-datacollect) foreach(external_lib IN ITEMS ${UKUI_MENU_PC_PKGS}) pkg_check_modules(${external_lib} REQUIRED ${external_lib}) @@ -115,6 +115,7 @@ set(SOURCE_FILES src/utils/app-page-header-utils.cpp src/utils/app-page-header-utils.h src/utils/power-button.cpp src/utils/power-button.h src/utils/app-manager.cpp src/utils/app-manager.h + src/utils/event-track.cpp src/utils/event-track.h src/menu/menu-provider.h src/menu/menu-manager.cpp src/menu/menu-manager.h src/items/theme-icon.h src/items/theme-icon.cpp diff --git a/qml/AppUI/AppPageContent.qml b/qml/AppUI/AppPageContent.qml index 348fb0f..cc4fad6 100644 --- a/qml/AppUI/AppPageContent.qml +++ b/qml/AppUI/AppPageContent.qml @@ -100,12 +100,14 @@ SwipeView { appPageHeader.title = folderName; appPageHeader.content = folderPageHeader; root.currentIndex = SwipeView.index; + EventTrack.sendClickEvent("EnterFolderPage", "AppView"); } function hideFolderPage() { root.currentIndex = appListBase.SwipeView.index; appPageHeader.title = appList.title; appPageHeader.content = null; //active = false; + EventTrack.sendClickEvent("ExitFolderPage", "AppView"); } Component.onCompleted: { diff --git a/qml/AppUI/Sidebar.qml b/qml/AppUI/Sidebar.qml index e1357a4..2037d83 100644 --- a/qml/AppUI/Sidebar.qml +++ b/qml/AppUI/Sidebar.qml @@ -249,6 +249,7 @@ Item { function select() { if (extensionLoader.source !== model.url) { extensionLoader.setSource(model.url, {extensionData: extensionData}); + EventTrack.sendClickEvent("Switch Plugin: " + model.name, "Sidebar"); } } diff --git a/src/appdata/app-folder-helper.cpp b/src/appdata/app-folder-helper.cpp index 68dc1e6..2b0235b 100644 --- a/src/appdata/app-folder-helper.cpp +++ b/src/appdata/app-folder-helper.cpp @@ -21,6 +21,7 @@ #include "app-data-manager.h" #include "model-manager.h" #include "app-model.h" +#include "event-track.h" #include #include @@ -219,6 +220,8 @@ void AppFolderHelper::addAppToFolder(const QString &appId, const int &folderId) forceSync(); Q_EMIT folderDataChanged(folderId); + + EventTrack::instance()->sendDefaultEvent("AddAppToFolder", "AppView"); } void AppFolderHelper::addAppToNewFolder(const QString &appId, const QString &folderName) @@ -241,6 +244,8 @@ void AppFolderHelper::addAppToNewFolder(const QString &appId, const QString &fol insertFolder(folder); Q_EMIT folderAdded(folder.id); + + EventTrack::instance()->sendDefaultEvent("AddAppToNewFolder", "AppView"); } void AppFolderHelper::addAppsToNewFolder(const QString &appIdA, const QString &appIdB, const QString &folderName) @@ -306,6 +311,7 @@ bool AppFolderHelper::deleteFolder(const int& folderId) } Q_EMIT folderDeleted(folderId); + EventTrack::instance()->sendDefaultEvent("DeleteFolder", "AppView"); return true; } diff --git a/src/appdata/data-provider-manager.cpp b/src/appdata/data-provider-manager.cpp index 3e8bff4..85bcf5f 100644 --- a/src/appdata/data-provider-manager.cpp +++ b/src/appdata/data-provider-manager.cpp @@ -17,6 +17,7 @@ */ #include "data-provider-manager.h" +#include "event-track.h" #include "plugin/all-app-data-provider.h" #include "plugin/app-search-plugin.h" #include "plugin/app-category-plugin.h" @@ -159,6 +160,7 @@ void DataProviderManager::activateProvider(const QString &id) m_activatedPlugin = id; Q_EMIT pluginChanged(m_activatedPlugin, m_providers.value(m_activatedPlugin)->group()); + EventTrack::instance()->sendClickEvent("Switch AppView: " + id, "AppView"); } DataProviderManager::~DataProviderManager() diff --git a/src/extension/extensions/favorite-extension.cpp b/src/extension/extensions/favorite-extension.cpp index cb19ffe..51d79fa 100644 --- a/src/extension/extensions/favorite-extension.cpp +++ b/src/extension/extensions/favorite-extension.cpp @@ -21,6 +21,7 @@ #include "app-manager.h" #include "commons.h" #include "settings.h" +#include "event-track.h" #include #include @@ -218,11 +219,13 @@ FavoriteMenuProvider::generateActions(QObject *parent, const QVariant &data, con list << new QAction(QObject::tr("Fix to favorite"), parent); QObject::connect(list.last(), &QAction::triggered, parent, [app] { Q_EMIT AppDataManager::instance()->fixToFavoriteSignal(app.id(), 1); + EventTrack::instance()->sendDefaultEvent("Fix to favorite", "Right-click Menu"); }); } else if (locationId == "favorite") { list << new QAction(QObject::tr("Remove from favorite"), parent); QObject::connect(list.last(), &QAction::triggered, parent, [app] { Q_EMIT AppDataManager::instance()->fixToFavoriteSignal(app.id(), 0); + EventTrack::instance()->sendDefaultEvent("Remove from favorite", "Right-click Menu"); }); } break; diff --git a/src/ukui-menu-application.cpp b/src/ukui-menu-application.cpp index 0267bf8..6f0fb61 100644 --- a/src/ukui-menu-application.cpp +++ b/src/ukui-menu-application.cpp @@ -31,6 +31,7 @@ #include "app-manager.h" #include "menu-manager.h" #include "data-provider-manager.h" +#include "event-track.h" #include #include @@ -78,6 +79,7 @@ void UkuiMenuApplication::registerQmlTypes() qRegisterMetaType("Palette::ColorRole"); qRegisterMetaType("Palette::ColorGroup"); qmlRegisterUncreatableType(uri, versionMajor, versionMinor, "Palette", "Use enums only."); + qmlRegisterUncreatableType(uri, versionMajor, versionMinor, "EventTrack", "Attached only."); } void UkuiMenuApplication::initQmlEngine() diff --git a/src/utils/event-track.cpp b/src/utils/event-track.cpp new file mode 100644 index 0000000..d76555a --- /dev/null +++ b/src/utils/event-track.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2023, KylinSoft Co., Ltd. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include "event-track.h" + +#include + +namespace UkuiMenu { + +EventTrack::EventTrack(QObject *parent) : QObject(parent) +{ + +} + +EventTrack *EventTrack::qmlAttachedProperties(QObject *object) +{ + Q_UNUSED(object) + return EventTrack::instance(); +} + +EventTrack *EventTrack::instance() +{ + static EventTrack eventTrack; + return &eventTrack; +} + +void EventTrack::sendClickEvent(const QString &event, const QString &page) +{ + KTrackData* data = kdk_dia_data_init(KEVENTSOURCE_DESKTOP, KEVENT_CLICK); + kdk_dia_upload_default(data, event.toUtf8().data(), page.toUtf8().data()); + kdk_dia_data_free(data); +} + +void EventTrack::sendDefaultEvent(const QString& event, const QString& page) +{ + KTrackData* data = kdk_dia_data_init(KEVENTSOURCE_DESKTOP, KEVENT_CUSTOM); + kdk_dia_upload_default(data, event.toUtf8().data(), page.toUtf8().data()); + kdk_dia_data_free(data); +} + +void EventTrack::sendSearchEvent(const QString &event, const QString &page, const QString &content) +{ + KTrackData* data = kdk_dia_data_init(KEVENTSOURCE_DESKTOP, KEVENT_SEARCH); + kdk_dia_upload_search_content(data, event.toUtf8().data(), page.toUtf8().data(), content.toUtf8().data()); + kdk_dia_data_free(data); +} + +} // Sidebar diff --git a/src/utils/event-track.h b/src/utils/event-track.h new file mode 100644 index 0000000..56c3cf0 --- /dev/null +++ b/src/utils/event-track.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2023, KylinSoft Co., Ltd. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#ifndef UKUI_MENU_EVENT_TRACK_H +#define UKUI_MENU_EVENT_TRACK_H + +#include +#include + +namespace UkuiMenu { + +class EventTrack : public QObject +{ + Q_OBJECT +public: + static EventTrack *qmlAttachedProperties(QObject *object); + static EventTrack *instance(); + + explicit EventTrack(QObject *parent = nullptr); + Q_INVOKABLE void sendClickEvent(const QString& event, const QString& page); + Q_INVOKABLE void sendDefaultEvent(const QString& event, const QString& page); + Q_INVOKABLE void sendSearchEvent(const QString& event, const QString& page, const QString& content); +}; + +} // Sidebar + +QML_DECLARE_TYPEINFO(UkuiMenu::EventTrack, QML_HAS_ATTACHED_PROPERTIES) + +#endif //UKUI_MENU_EVENT_TRACK_H