From 43ba1b1f4b919729e7686424acf095f7c3bbecbf Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Thu, 5 Sep 2024 16:53:09 -0400 Subject: [PATCH 1/6] mixpanel: report more information about the build and platform Signed-off-by: Jared Van Bortel --- gpt4all-chat/src/network.cpp | 57 ++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/gpt4all-chat/src/network.cpp b/gpt4all-chat/src/network.cpp index 19e96a10ce84..10251c684f6b 100644 --- a/gpt4all-chat/src/network.cpp +++ b/gpt4all-chat/src/network.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -36,12 +37,35 @@ #include #include +#ifdef __GLIBC__ +# include +#endif + using namespace Qt::Literals::StringLiterals; //#define DEBUG +#define STR_(x) #x +#define STR(x) STR_(x) + static const char MIXPANEL_TOKEN[] = "ce362e568ddaee16ed243eaffb5860a2"; +#ifdef __clang__ +#ifdef __apple_build_version__ +static const char COMPILER_NAME[] = "Apple Clang"; +#else +static const char COMPILER_NAME[] = "LLVM Clang"; +#endif +static const char COMPILER_VER[] = STR(__clang_major__) "." STR(__clang_minor__) "." STR(__clang_patchlevel__); +#elifdef _MSC_VER +static const char COMPILER_NAME[] = "MSVC"; +static const char COMPILER_VER[] = STR(_MSC_VER) " (" STR(_MSC_FULL_VER) ")"; +#elifdef __GNUC__ +static const char COMPILER_NAME[] = "GCC"; +static const char COMPILER_VER[] = STR(__GNUC__) "." STR(__GNUC_MINOR__) "." STR(__GNUC_PATCHLEVEL__); +#endif + + #if defined(Q_OS_MAC) #include @@ -286,12 +310,33 @@ void Network::sendStartup() const auto *display = QGuiApplication::primaryScreen(); trackEvent("startup", { - {"$screen_dpi", std::round(display->physicalDotsPerInch())}, - {"display", u"%1x%2"_s.arg(display->size().width()).arg(display->size().height())}, - {"ram", LLM::globalInstance()->systemTotalRAMInGB()}, - {"cpu", getCPUModel()}, - {"cpu_supports_avx2", LLModel::Implementation::cpuSupportsAVX2()}, - {"datalake_active", mySettings->networkIsActive()}, + // Build info + { "build_compiler", COMPILER_NAME }, + { "build_compiler_ver", COMPILER_VER }, + { "build_abi", QSysInfo::buildAbi() }, + { "build_cpu_arch", QSysInfo::buildCpuArchitecture() }, +#ifdef __GLIBC__ + { "build_glibc_ver", QStringLiteral(STR(__GLIBC__) "." STR(__GLIBC_MINOR__)) }, +#endif + { "qt_version", QLibraryInfo::version().toString() }, + { "qt_debug" , QLibraryInfo::isDebugBuild() }, + { "qt_shared", QLibraryInfo::isSharedBuild() }, + // System info + { "runtime_cpu_arch", QSysInfo::currentCpuArchitecture() }, +#ifdef __GLIBC__ + { "runtime_glibc_ver", gnu_get_libc_version() }, +#endif + { "kernel_type", QSysInfo::kernelType() }, + { "kernel_version", QSysInfo::kernelVersion() }, + { "product_type", QSysInfo::productType() }, + { "product_version", QSysInfo::productVersion() }, + { "$screen_dpi", std::round(display->physicalDotsPerInch()) }, + { "display", u"%1x%2"_s.arg(display->size().width()).arg(display->size().height()) }, + { "ram", LLM::globalInstance()->systemTotalRAMInGB() }, + { "cpu", getCPUModel() }, + { "cpu_supports_avx2", LLModel::Implementation::cpuSupportsAVX2() }, + // Datalake status + { "datalake_active", mySettings->networkIsActive() }, }); sendIpify(); From a81c233254c159475d42b2ed95d5a135c9ba57bc Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Mon, 9 Sep 2024 11:16:42 -0400 Subject: [PATCH 2/6] network: remove lingering assertion from #2238 This assertion was failing, but it's no longer needed. Signed-off-by: Jared Van Bortel --- gpt4all-chat/src/network.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/gpt4all-chat/src/network.cpp b/gpt4all-chat/src/network.cpp index 10251c684f6b..041bafd89b7c 100644 --- a/gpt4all-chat/src/network.cpp +++ b/gpt4all-chat/src/network.cpp @@ -366,7 +366,6 @@ void Network::trackEvent(const QString &ev, const QVariantMap &props) if (!m_sendUsageStats) return; - Q_ASSERT(ChatListModel::globalInstance()->currentChat()); QJsonObject properties; properties.insert("token", MIXPANEL_TOKEN); From 91510c9bbb052928b473b33495e6df12b0c498cd Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Mon, 9 Sep 2024 11:21:19 -0400 Subject: [PATCH 3/6] mixpanel: rename a few of the new keys Signed-off-by: Jared Van Bortel --- gpt4all-chat/src/network.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gpt4all-chat/src/network.cpp b/gpt4all-chat/src/network.cpp index 041bafd89b7c..276deff9bdbb 100644 --- a/gpt4all-chat/src/network.cpp +++ b/gpt4all-chat/src/network.cpp @@ -326,10 +326,10 @@ void Network::sendStartup() #ifdef __GLIBC__ { "runtime_glibc_ver", gnu_get_libc_version() }, #endif - { "kernel_type", QSysInfo::kernelType() }, - { "kernel_version", QSysInfo::kernelVersion() }, - { "product_type", QSysInfo::productType() }, - { "product_version", QSysInfo::productVersion() }, + { "sys_kernel_type", QSysInfo::kernelType() }, + { "sys_kernel_ver", QSysInfo::kernelVersion() }, + { "sys_product_type", QSysInfo::productType() }, + { "sys_product_ver", QSysInfo::productVersion() }, { "$screen_dpi", std::round(display->physicalDotsPerInch()) }, { "display", u"%1x%2"_s.arg(display->size().width()).arg(display->size().height()) }, { "ram", LLM::globalInstance()->systemTotalRAMInGB() }, From 50597308136e167d96f3a5fed3e8a36f1588402d Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Mon, 9 Sep 2024 11:42:36 -0400 Subject: [PATCH 4/6] changelog: add this PR Signed-off-by: Jared Van Bortel --- gpt4all-chat/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/gpt4all-chat/CHANGELOG.md b/gpt4all-chat/CHANGELOG.md index 91b42f5100fe..c9b45742a83d 100644 --- a/gpt4all-chat/CHANGELOG.md +++ b/gpt4all-chat/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ### Added - Use greedy sampling when temperature is set to zero ([#2854](https://github.com/nomic-ai/gpt4all/pull/2854)) - Use configured system prompt in server mode and ignore system messages ([#2921](https://github.com/nomic-ai/gpt4all/pull/2921), [#2924](https://github.com/nomic-ai/gpt4all/pull/2924)) +- Add more system information to anonymous usage stats ([#2939](https://github.com/nomic-ai/gpt4all/pull/2939)) ### Changed - The offline update button now directs users to the offline installer releases page. (by [@3Simplex](https://github.com/3Simplex) in [#2888](https://github.com/nomic-ai/gpt4all/pull/2888)) From 49f10c596e8f070bd6497126682339f715f9c521 Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Mon, 9 Sep 2024 11:42:42 -0400 Subject: [PATCH 5/6] mixpanel: add macOS hw.model Signed-off-by: Jared Van Bortel --- gpt4all-chat/src/network.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/gpt4all-chat/src/network.cpp b/gpt4all-chat/src/network.cpp index 276deff9bdbb..8092d6f22d39 100644 --- a/gpt4all-chat/src/network.cpp +++ b/gpt4all-chat/src/network.cpp @@ -69,14 +69,20 @@ static const char COMPILER_VER[] = STR(__GNUC__) "." STR(__GNUC_MINOR__) "." ST #if defined(Q_OS_MAC) #include -static QString getCPUModel() +static std::optional getSysctl(const char *name) { - char buffer[256]; + char buffer[256] = ""; size_t bufferlen = sizeof(buffer); - sysctlbyname("machdep.cpu.brand_string", &buffer, &bufferlen, NULL, 0); - return buffer; + if (sysctlbyname(name, &buffer, &bufferlen, NULL, 0) < 0) { + int err = errno; + qWarning() << "sysctlbyname(" << name << ") failed: " << strerror(err); + return std::nullopt; + } + return std::make_optional(buffer); } +static QString getCPUModel() { return getSysctl("machdep.cpu.brand_string").value_or(u"(unknown)"_s); } + #elif defined(__x86_64__) || defined(__i386__) || defined(_M_X64) || defined(_M_IX86) #ifndef _MSC_VER @@ -330,6 +336,9 @@ void Network::sendStartup() { "sys_kernel_ver", QSysInfo::kernelVersion() }, { "sys_product_type", QSysInfo::productType() }, { "sys_product_ver", QSysInfo::productVersion() }, +#ifdef Q_OS_MAC + { "sys_hw_model", getSysctl("hw.model").value_or(u"(unknown)"_s) }, +#endif { "$screen_dpi", std::round(display->physicalDotsPerInch()) }, { "display", u"%1x%2"_s.arg(display->size().width()).arg(display->size().height()) }, { "ram", LLM::globalInstance()->systemTotalRAMInGB() }, From 6f7492cd1ec2a231a7bed86279d7c7e3fa0f2390 Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Mon, 9 Sep 2024 17:09:39 -0400 Subject: [PATCH 6/6] network: prettier warning Signed-off-by: Jared Van Bortel --- gpt4all-chat/src/network.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gpt4all-chat/src/network.cpp b/gpt4all-chat/src/network.cpp index 8092d6f22d39..84fe1bc9034c 100644 --- a/gpt4all-chat/src/network.cpp +++ b/gpt4all-chat/src/network.cpp @@ -75,7 +75,7 @@ static std::optional getSysctl(const char *name) size_t bufferlen = sizeof(buffer); if (sysctlbyname(name, &buffer, &bufferlen, NULL, 0) < 0) { int err = errno; - qWarning() << "sysctlbyname(" << name << ") failed: " << strerror(err); + qWarning().nospace() << "sysctlbyname(\"" << name << "\") failed: " << strerror(err); return std::nullopt; } return std::make_optional(buffer);