gpt4all/gpt4all-chat/network.h
Jared Van Bortel c622921894
improve mixpanel usage statistics (#2238)
Other changes:
- Always display first start dialog if privacy options are unset (e.g. if the user closed GPT4All without selecting them)
- LocalDocs scanQueue is now always deferred
- Fix a potential crash in magic_match
- LocalDocs indexing is now started after the first start dialog is dismissed so usage stats are included

Signed-off-by: Jared Van Bortel <jared@nomic.ai>
2024-04-25 13:16:52 -04:00

65 lines
1.6 KiB
C++

#ifndef NETWORK_H
#define NETWORK_H
#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QJsonValue>
struct KeyValue {
QString key;
QJsonValue value;
};
class Network : public QObject
{
Q_OBJECT
public:
static Network *globalInstance();
Q_INVOKABLE QString generateUniqueId() const;
Q_INVOKABLE bool sendConversation(const QString &ingestId, const QString &conversation);
Q_INVOKABLE void trackChatEvent(const QString &event, QVariantMap props = QVariantMap());
Q_INVOKABLE void trackEvent(const QString &event, const QVariantMap &props = QVariantMap());
Q_SIGNALS:
void healthCheckFailed(int code);
void requestMixpanel(const QByteArray &json, bool isOptOut = false);
public Q_SLOTS:
void sendStartup();
private Q_SLOTS:
void handleIpifyFinished();
void handleHealthFinished();
void handleJsonUploadFinished();
void handleSslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
void handleMixpanelFinished();
void handleIsActiveChanged();
void handleUsageStatsActiveChanged();
void sendMixpanel(const QByteArray &json, bool isOptOut);
private:
void sendOptOut();
void sendHealth();
void sendIpify();
bool packageAndSendJson(const QString &ingestId, const QString &json);
private:
bool m_sendUsageStats = false;
bool m_hasSentOptIn;
bool m_hasSentOptOut;
QString m_ipify;
QString m_uniqueId;
QString m_sessionId;
QNetworkAccessManager m_networkManager;
QVector<QNetworkReply*> m_activeUploads;
private:
explicit Network();
~Network() {}
friend class MyNetwork;
};
#endif // LLM_H