From 02bf939d141e33f3b940e8132bd69776ebaaa39c Mon Sep 17 00:00:00 2001 From: Bhagirath Mehta Date: Mon, 14 Sep 2026 13:14:57 -0500 Subject: [PATCH 1/5] Avoid session sidecars for in-memory storage Treat SQLite's :memory: cache path as non-file-backed so telemetry fallback does not leave a physical .ses file in the working directory. Files changed: - lib/offline/LogSessionDataProvider.cpp - tests/functests/LogSessionDataFuncTests.cpp Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f2382f49-919c-48fe-b04f-5c2b9b2c744c --- lib/offline/LogSessionDataProvider.cpp | 7 ++++--- tests/functests/LogSessionDataFuncTests.cpp | 21 +++++++++++++++++++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/lib/offline/LogSessionDataProvider.cpp b/lib/offline/LogSessionDataProvider.cpp index 68e152d0e..e457dff5b 100644 --- a/lib/offline/LogSessionDataProvider.cpp +++ b/lib/offline/LogSessionDataProvider.cpp @@ -97,7 +97,8 @@ namespace MAT_NS_BEGIN void LogSessionDataProvider::DeleteLogSessionDataFromFile() { - std::string sessionPath = m_cacheFilePath.empty() ? "" : (m_cacheFilePath + ".ses").c_str(); + std::string sessionPath = + (m_cacheFilePath.empty() || m_cacheFilePath == ":memory:") ? "" : m_cacheFilePath + ".ses"; if (!sessionPath.empty() && MAT::FileExists(sessionPath.c_str())) { MAT::FileDelete(sessionPath.c_str()); @@ -108,7 +109,8 @@ namespace MAT_NS_BEGIN { uint64_t sessionFirstTimeLaunch = 0; std::string sessionSDKUid; - std::string sessionPath = m_cacheFilePath.empty() ? "" : (m_cacheFilePath + ".ses").c_str(); + std::string sessionPath = + (m_cacheFilePath.empty() || m_cacheFilePath == ":memory:") ? "" : m_cacheFilePath + ".ses"; if (!sessionPath.empty()) { if (MAT::FileExists(sessionPath.c_str())) @@ -209,4 +211,3 @@ namespace MAT_NS_BEGIN } } MAT_NS_END - diff --git a/tests/functests/LogSessionDataFuncTests.cpp b/tests/functests/LogSessionDataFuncTests.cpp index f1f1dbe68..f675eb36a 100644 --- a/tests/functests/LogSessionDataFuncTests.cpp +++ b/tests/functests/LogSessionDataFuncTests.cpp @@ -14,14 +14,18 @@ using namespace MAT; const std::string SessionFileArgument = "test"; const char* const SessionFile = "test.ses"; +const char* const MemorySessionFile = ":memory:.ses"; class LogSessionDataFuncTests : public ::testing::Test { void CleanupLocalSessionFile() { - if (MAT::FileExists(SessionFile)) + for (const auto* sessionFile : {SessionFile, MemorySessionFile}) { - MAT::FileDelete(SessionFile); + if (MAT::FileExists(sessionFile)) + { + MAT::FileDelete(sessionFile); + } } } @@ -76,6 +80,19 @@ TEST_F(LogSessionDataFuncTests, Constructor_SessionFile_FileCreated) ASSERT_TRUE(MAT::FileExists(SessionFile)); } +TEST_F(LogSessionDataFuncTests, Constructor_InMemoryCache_NoSessionFileCreated) +{ + auto logSessionDataProvider = LogSessionDataProvider(":memory:"); + logSessionDataProvider.CreateLogSessionData(); + ASSERT_NE(logSessionDataProvider.GetLogSessionData(), nullptr); + EXPECT_FALSE(MAT::FileExists(MemorySessionFile)); + + logSessionDataProvider.ResetLogSessionData(); + EXPECT_FALSE(MAT::FileExists(MemorySessionFile)); + logSessionDataProvider.DeleteLogSessionData(); + EXPECT_FALSE(MAT::FileExists(MemorySessionFile)); +} + TEST_F(LogSessionDataFuncTests, Constructor_ValidSessionFileExists_MembersSetToExistingFile) { const std::string validSessionFirstTime{ "123456" }; From 89ebcc5f272536b1f0785bdeb7a721dc3f6a4f26 Mon Sep 17 00:00:00 2001 From: Bhagirath Mehta Date: Mon, 14 Sep 2026 15:00:23 -0500 Subject: [PATCH 2/5] Preserve session telemetry with in-memory storage Generate ephemeral session metadata when SQLite uses :memory: so session events remain valid without creating a sidecar file. Files changed: - lib/offline/LogSessionDataProvider.cpp - tests/functests/LogSessionDataFuncTests.cpp Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f2382f49-919c-48fe-b04f-5c2b9b2c744c --- lib/offline/LogSessionDataProvider.cpp | 9 +++++++-- tests/functests/LogSessionDataFuncTests.cpp | 11 ++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/offline/LogSessionDataProvider.cpp b/lib/offline/LogSessionDataProvider.cpp index e457dff5b..644e27ae8 100644 --- a/lib/offline/LogSessionDataProvider.cpp +++ b/lib/offline/LogSessionDataProvider.cpp @@ -109,8 +109,8 @@ namespace MAT_NS_BEGIN { uint64_t sessionFirstTimeLaunch = 0; std::string sessionSDKUid; - std::string sessionPath = - (m_cacheFilePath.empty() || m_cacheFilePath == ":memory:") ? "" : m_cacheFilePath + ".ses"; + const bool inMemory = m_cacheFilePath == ":memory:"; + std::string sessionPath = (m_cacheFilePath.empty() || inMemory) ? "" : m_cacheFilePath + ".ses"; if (!sessionPath.empty()) { if (MAT::FileExists(sessionPath.c_str())) @@ -129,6 +129,11 @@ namespace MAT_NS_BEGIN writeFileContents(sessionPath, sessionFirstTimeLaunch, sessionSDKUid); } } + else if (inMemory) + { + sessionFirstTimeLaunch = PAL::getUtcSystemTimeMs(); + sessionSDKUid = PAL::generateUuidString(); + } m_logSessionData.reset(new LogSessionData(sessionFirstTimeLaunch, sessionSDKUid)); } diff --git a/tests/functests/LogSessionDataFuncTests.cpp b/tests/functests/LogSessionDataFuncTests.cpp index f675eb36a..9afde6926 100644 --- a/tests/functests/LogSessionDataFuncTests.cpp +++ b/tests/functests/LogSessionDataFuncTests.cpp @@ -84,10 +84,19 @@ TEST_F(LogSessionDataFuncTests, Constructor_InMemoryCache_NoSessionFileCreated) { auto logSessionDataProvider = LogSessionDataProvider(":memory:"); logSessionDataProvider.CreateLogSessionData(); - ASSERT_NE(logSessionDataProvider.GetLogSessionData(), nullptr); + const auto* logSessionData = logSessionDataProvider.GetLogSessionData(); + ASSERT_NE(logSessionData, nullptr); + EXPECT_GT(logSessionData->getSessionFirstTime(), 0ull); + EXPECT_FALSE(logSessionData->getSessionSDKUid().empty()); + const auto sessionSDKUid = logSessionData->getSessionSDKUid(); EXPECT_FALSE(MAT::FileExists(MemorySessionFile)); logSessionDataProvider.ResetLogSessionData(); + logSessionData = logSessionDataProvider.GetLogSessionData(); + ASSERT_NE(logSessionData, nullptr); + EXPECT_GT(logSessionData->getSessionFirstTime(), 0ull); + EXPECT_FALSE(logSessionData->getSessionSDKUid().empty()); + EXPECT_NE(logSessionData->getSessionSDKUid(), sessionSDKUid); EXPECT_FALSE(MAT::FileExists(MemorySessionFile)); logSessionDataProvider.DeleteLogSessionData(); EXPECT_FALSE(MAT::FileExists(MemorySessionFile)); From 732a465e30e14977e3f558a8e12d5f31ad094ed5 Mon Sep 17 00:00:00 2001 From: bmehta001 Date: Mon, 14 Sep 2026 16:38:19 -0500 Subject: [PATCH 3/5] Simplify --- lib/offline/LogSessionDataProvider.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/offline/LogSessionDataProvider.cpp b/lib/offline/LogSessionDataProvider.cpp index 644e27ae8..cdcefe1c0 100644 --- a/lib/offline/LogSessionDataProvider.cpp +++ b/lib/offline/LogSessionDataProvider.cpp @@ -109,8 +109,8 @@ namespace MAT_NS_BEGIN { uint64_t sessionFirstTimeLaunch = 0; std::string sessionSDKUid; - const bool inMemory = m_cacheFilePath == ":memory:"; - std::string sessionPath = (m_cacheFilePath.empty() || inMemory) ? "" : m_cacheFilePath + ".ses"; + std::string sessionPath = + (m_cacheFilePath.empty() || m_cacheFilePath == ":memory:") ? "" : m_cacheFilePath + ".ses"; if (!sessionPath.empty()) { if (MAT::FileExists(sessionPath.c_str())) From f453ca92e41e07c8b248a4e6cbcb6e380e6e1e0a Mon Sep 17 00:00:00 2001 From: Bhagirath Mehta Date: Mon, 14 Sep 2026 18:05:59 -0500 Subject: [PATCH 4/5] Complete in-memory path simplification Reference the cache path directly after removing the local inMemory variable, restoring compilation across all native targets. Files changed: - lib/offline/LogSessionDataProvider.cpp Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f2382f49-919c-48fe-b04f-5c2b9b2c744c --- lib/offline/LogSessionDataProvider.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/offline/LogSessionDataProvider.cpp b/lib/offline/LogSessionDataProvider.cpp index cdcefe1c0..ea3112c72 100644 --- a/lib/offline/LogSessionDataProvider.cpp +++ b/lib/offline/LogSessionDataProvider.cpp @@ -129,7 +129,7 @@ namespace MAT_NS_BEGIN writeFileContents(sessionPath, sessionFirstTimeLaunch, sessionSDKUid); } } - else if (inMemory) + else if (m_cacheFilePath == ":memory:") { sessionFirstTimeLaunch = PAL::getUtcSystemTimeMs(); sessionSDKUid = PAL::generateUuidString(); From 6bc46bff5cdd3976c1a9710ae4d5bed2bb563289 Mon Sep 17 00:00:00 2001 From: Bhagirath Mehta Date: Mon, 14 Sep 2026 18:17:17 -0500 Subject: [PATCH 5/5] Repair CI after SQLite target migration Adapt legacy SQLite targets produced by older CMake FindSQLite3 modules and stop Android setup from requesting the removed tools package. Files changed: - .github/workflows/build-android.yml - .github/workflows/codeql-analysis.yml - cmake/MSTelemetryConfig.cmake.in - cmake/MatsdkDependencyTargets.cmake Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f2382f49-919c-48fe-b04f-5c2b9b2c744c --- .github/workflows/build-android.yml | 2 ++ .github/workflows/codeql-analysis.yml | 2 ++ cmake/MSTelemetryConfig.cmake.in | 1 + cmake/MatsdkDependencyTargets.cmake | 8 +++++++- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml index 576eeb1ce..96cb76c80 100644 --- a/.github/workflows/build-android.yml +++ b/.github/workflows/build-android.yml @@ -50,6 +50,8 @@ jobs: java-version: '17' - name: Setup Android SDK uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407 # v3.2.2 + with: + packages: platform-tools - name: Install NDK run: | java -version diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index a47773036..bad283b5f 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -132,6 +132,8 @@ jobs: java-version: '17' - name: Setup Android SDK uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407 # v3.2.2 + with: + packages: platform-tools - name: Install NDK run: | java -version diff --git a/cmake/MSTelemetryConfig.cmake.in b/cmake/MSTelemetryConfig.cmake.in index a46d7d94c..60a3579c2 100644 --- a/cmake/MSTelemetryConfig.cmake.in +++ b/cmake/MSTelemetryConfig.cmake.in @@ -17,6 +17,7 @@ if(@MATSDK_CONFIG_STATIC_PACKAGE@) SQLite3::SQLite3 "@MATSDK_SQLITE_PROVIDER_RESOLVED@" SQLite3 + LEGACY_TARGET SQLite::SQLite3 ${_matsdk_package_sqlite_args}) matsdk_add_package_system_dependency( MSTelemetry::zlib_dependency diff --git a/cmake/MatsdkDependencyTargets.cmake b/cmake/MatsdkDependencyTargets.cmake index f5f320043..47ddf21a4 100644 --- a/cmake/MatsdkDependencyTargets.cmake +++ b/cmake/MatsdkDependencyTargets.cmake @@ -20,7 +20,7 @@ function(matsdk_add_package_system_dependency dependency_target canonical_target endif() set(options APPLE_SYSTEM) - set(one_value_args APPLE_LIBRARY) + set(one_value_args APPLE_LIBRARY LEGACY_TARGET) cmake_parse_arguments(MATSDK_PACKAGE_DEP "${options}" "${one_value_args}" "" ${ARGN}) if(MATSDK_PACKAGE_DEP_APPLE_SYSTEM) @@ -35,6 +35,12 @@ function(matsdk_add_package_system_dependency dependency_target canonical_target elseif(NOT TARGET "${canonical_target}") find_dependency(${package_name}) endif() + if(NOT TARGET "${canonical_target}" + AND DEFINED MATSDK_PACKAGE_DEP_LEGACY_TARGET + AND TARGET "${MATSDK_PACKAGE_DEP_LEGACY_TARGET}") + matsdk_add_interface_dependency( + "${canonical_target}" "${MATSDK_PACKAGE_DEP_LEGACY_TARGET}") + endif() if(NOT TARGET "${canonical_target}") message(FATAL_ERROR "${package_name} did not create the required ${canonical_target} target.")