File indexing completed on 2024-04-21 16:12:16
0001 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0002 // SPDX-FileCopyrightText: 2022 Harald Sitter <sitter@kde.org> 0003 0004 #pragma once 0005 0006 #include <QNetworkAccessManager> 0007 #include <QObject> 0008 #include <memory> 0009 0010 struct SentryDSNContext { 0011 QString project; 0012 QString key; 0013 QString index; 0014 }; 0015 0016 class SentryBeacon : public QObject 0017 { 0018 Q_OBJECT 0019 public: 0020 using QObject::QObject; 0021 0022 void sendEvent(); 0023 void sendUserFeedback(const QString &feedback); 0024 0025 Q_SIGNALS: 0026 void eventSent(); 0027 void userFeedbackSent(); 0028 0029 private Q_SLOTS: 0030 void getDSNs(); 0031 void onDSNsReceived(); 0032 0033 bool maybePostStore(const QJsonValue &value); 0034 0035 void postStore(const SentryDSNContext &context); 0036 void onStoreSent(); 0037 0038 void postUserFeedback(); 0039 void onUserFeedbackSent(); 0040 0041 private: 0042 QString m_userFeedback; 0043 std::unique_ptr<QNetworkAccessManager> m_manager = std::make_unique<QNetworkAccessManager>(); 0044 SentryDSNContext m_context; 0045 QByteArray m_eventPayload; 0046 QVariant m_eventID; 0047 bool m_started = false; 0048 };