File indexing completed on 2024-12-22 04:45:40

0001 /*
0002    SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "analyticswidget.h"
0008 #include <KLocalizedString>
0009 #include <QCheckBox>
0010 #include <QFormLayout>
0011 #include <QLabel>
0012 #include <QLineEdit>
0013 #include <QPlainTextEdit>
0014 
0015 AnalyticsWidget::AnalyticsWidget(RocketChatAccount *account, QWidget *parent)
0016     : SettingsWidgetBase(account, parent)
0017     , mMessages(new QCheckBox(i18n("Messages"), this))
0018     , mRooms(new QCheckBox(i18n("Rooms"), this))
0019     , mUsers(new QCheckBox(i18n("Users"), this))
0020     , mGoogleEnabled(new QCheckBox(i18n("Enable"), this))
0021     , mPiwikEnabled(new QCheckBox(i18n("Enable"), this))
0022     , mGoogleTrackingId(new QLineEdit(this))
0023     , mPiwikUrl(new QLineEdit(this))
0024     , mPiwikClientID(new QLineEdit(this))
0025     , mPrependDomain(new QCheckBox(i18n("Prepend Domain"), this))
0026     , mAllSubdomains(new QCheckBox(i18n("All Subdomains"), this))
0027     , mAdditionalPiwikSites(new QPlainTextEdit(this))
0028     , mHideOutgoingLinks(new QPlainTextEdit(this))
0029 {
0030     auto featuresEnabledLabel = createBoldLabel(i18n("Features Enabled"));
0031     featuresEnabledLabel->setObjectName(QStringLiteral("featuresEnabledLabel"));
0032     mMainLayout->addWidget(featuresEnabledLabel);
0033 
0034     mMessages->setObjectName(QStringLiteral("mMessages"));
0035     mMainLayout->addWidget(mMessages);
0036     mMessages->setToolTip(i18n("Tracks custom events related to actions a user does on messages."));
0037     connectCheckBox(mMessages, QStringLiteral("Analytics_features_messages"));
0038 
0039     mRooms->setObjectName(QStringLiteral("mRooms"));
0040     mMainLayout->addWidget(mRooms);
0041     mRooms->setToolTip(i18n("Tracks custom events related to actions on a channel or group (create, leave, delete)."));
0042     connectCheckBox(mRooms, QStringLiteral("Analytics_features_rooms"));
0043 
0044     mUsers->setObjectName(QStringLiteral("mUsers"));
0045     mMainLayout->addWidget(mUsers);
0046     mUsers->setToolTip(i18n("Tracks custom events related to actions related to users (password reset times, profile picture change, etc)."));
0047     connectCheckBox(mUsers, QStringLiteral("Analytics_features_users"));
0048 
0049     auto googleAnalyticsLabel = createBoldLabel(i18n("Google Analytics"));
0050     googleAnalyticsLabel->setObjectName(QStringLiteral("googleAnalyticsLabel"));
0051     mMainLayout->addWidget(googleAnalyticsLabel);
0052 
0053     mGoogleEnabled->setObjectName(QStringLiteral("mGoogleEnabled"));
0054     mMainLayout->addWidget(mGoogleEnabled);
0055     connectCheckBox(mGoogleEnabled, QStringLiteral("GoogleAnalytics_enabled"));
0056 
0057     mGoogleTrackingId->setObjectName(QStringLiteral("mGoogleTrackingId"));
0058     addLineEdit(i18n("Tracking ID"), mGoogleTrackingId, QStringLiteral("GoogleAnalytics_ID"));
0059 
0060     auto piwikAnalyticsLabel = createBoldLabel(i18n("Piwik Analytics"));
0061     piwikAnalyticsLabel->setObjectName(QStringLiteral("piwikAnalyticsLabel"));
0062     mMainLayout->addWidget(piwikAnalyticsLabel);
0063 
0064     mPiwikEnabled->setObjectName(QStringLiteral("mPiwikEnabled"));
0065     mMainLayout->addWidget(mPiwikEnabled);
0066     connectCheckBox(mPiwikEnabled, QStringLiteral("PiwikAnalytics_enabled"));
0067 
0068     mPiwikUrl->setObjectName(QStringLiteral("mPiwikUrl"));
0069     mPiwikUrl->setToolTip(i18n("The url where the Piwik resides, be sure to include the trailing slash. Example: //piwik.rocket.chat/"));
0070     addLineEdit(i18n("URL"), mPiwikUrl, QStringLiteral("PiwikAnalytics_url"));
0071 
0072     mPiwikClientID->setObjectName(QStringLiteral("mPiwikClientID"));
0073     mPiwikClientID->setToolTip(i18n("The site id to use for identifying this site. Example: 17"));
0074     addLineEdit(i18n("Client ID"), mPiwikClientID, QStringLiteral("PiwikAnalytics_siteId"));
0075 
0076     mAdditionalPiwikSites->setObjectName(QStringLiteral("mAdditionalPiwikSites"));
0077     addPlainTextEdit(i18n("Additional Piwik Sites"), mAdditionalPiwikSites, QStringLiteral("PiwikAdditionalTrackers"));
0078 
0079     mPrependDomain->setObjectName(QStringLiteral("mPrependDomain"));
0080     mPrependDomain->setToolTip(i18n("Prepend the site domain to the page title when tracking"));
0081     mMainLayout->addWidget(mPrependDomain);
0082     connectCheckBox(mPrependDomain, QStringLiteral("PiwikAnalytics_prependDomain"));
0083 
0084     mAllSubdomains->setObjectName(QStringLiteral("mAllSubdomains"));
0085     mAllSubdomains->setToolTip(i18n("Track visitors across all subdomains"));
0086     mMainLayout->addWidget(mAllSubdomains);
0087     connectCheckBox(mAllSubdomains, QStringLiteral("PiwikAnalytics_cookieDomain"));
0088 
0089     mHideOutgoingLinks->setObjectName(QStringLiteral("mHideOutgoingLinks"));
0090     addPlainTextEdit(i18n("Hide Outgoing Links"), mHideOutgoingLinks, QStringLiteral("PiwikAnalytics_domains"));
0091 }
0092 
0093 AnalyticsWidget::~AnalyticsWidget() = default;
0094 
0095 void AnalyticsWidget::initialize(const QMap<QString, QVariant> &mapSettings)
0096 {
0097     initializeWidget(mMessages, mapSettings, true);
0098     initializeWidget(mRooms, mapSettings, true);
0099     initializeWidget(mUsers, mapSettings, true);
0100     initializeWidget(mGoogleEnabled, mapSettings, false);
0101     initializeWidget(mGoogleTrackingId, mapSettings, {});
0102     initializeWidget(mPiwikEnabled, mapSettings, false);
0103     initializeWidget(mPiwikUrl, mapSettings, {});
0104     initializeWidget(mPiwikClientID, mapSettings, {});
0105     initializeWidget(mPrependDomain, mapSettings, false);
0106     initializeWidget(mAllSubdomains, mapSettings, false);
0107     initializeWidget(mAdditionalPiwikSites, mapSettings, {});
0108     initializeWidget(mHideOutgoingLinks, mapSettings, {});
0109 }
0110 
0111 #include "moc_analyticswidget.cpp"