From e5fa57f470ef8ac004315ff0f2d5584e18b3fb9e Mon Sep 17 00:00:00 2001 From: rainxchzed Date: Tue, 28 Apr 2026 14:35:06 +0500 Subject: [PATCH] Stop sending hashed search queries to the legacy /v1/events pipeline --- .../zed/rainxch/core/data/dto/EventRequest.kt | 1 - .../data/repository/TelemetryRepositoryImpl.kt | 9 ++++----- .../zed/rainxch/core/data/utils/QueryHash.kt | 17 ----------------- .../domain/repository/TelemetryRepository.kt | 2 +- .../search/presentation/SearchViewModel.kt | 1 - 5 files changed, 5 insertions(+), 25 deletions(-) delete mode 100644 core/data/src/commonMain/kotlin/zed/rainxch/core/data/utils/QueryHash.kt diff --git a/core/data/src/commonMain/kotlin/zed/rainxch/core/data/dto/EventRequest.kt b/core/data/src/commonMain/kotlin/zed/rainxch/core/data/dto/EventRequest.kt index 1ec3b4628..3ff0b1c16 100644 --- a/core/data/src/commonMain/kotlin/zed/rainxch/core/data/dto/EventRequest.kt +++ b/core/data/src/commonMain/kotlin/zed/rainxch/core/data/dto/EventRequest.kt @@ -9,7 +9,6 @@ data class EventRequest( val appVersion: String? = null, val eventType: String, val repoId: Long? = null, - val queryHash: String? = null, val resultCount: Int? = null, val success: Boolean? = null, val errorCode: String? = null, diff --git a/core/data/src/commonMain/kotlin/zed/rainxch/core/data/repository/TelemetryRepositoryImpl.kt b/core/data/src/commonMain/kotlin/zed/rainxch/core/data/repository/TelemetryRepositoryImpl.kt index a36428895..9a720a33f 100644 --- a/core/data/src/commonMain/kotlin/zed/rainxch/core/data/repository/TelemetryRepositoryImpl.kt +++ b/core/data/src/commonMain/kotlin/zed/rainxch/core/data/repository/TelemetryRepositoryImpl.kt @@ -11,7 +11,6 @@ import kotlinx.coroutines.withContext import zed.rainxch.core.data.BuildKonfig import zed.rainxch.core.data.dto.EventRequest import zed.rainxch.core.data.network.BackendApiClient -import zed.rainxch.core.data.utils.hashQuery import zed.rainxch.core.domain.logging.GitHubStoreLogger import zed.rainxch.core.domain.model.Platform import zed.rainxch.core.domain.repository.DeviceIdentityRepository @@ -42,10 +41,12 @@ class TelemetryRepositoryImpl( // ── recording (fire-and-forget, guarded by opt-in) ────────────── - override fun recordSearchPerformed(query: String, resultCount: Int) { + override fun recordSearchPerformed(resultCount: Int) { + // Query intentionally dropped: a 16-hex SHA-256 prefix of a + // lowercased repo-name search is rainbow-table-trivial. The + // count-only signal here is what survives. enqueue( eventType = "search_performed", - queryHash = hashQuery(query), resultCount = resultCount, ) } @@ -240,7 +241,6 @@ class TelemetryRepositoryImpl( private fun enqueue( eventType: String, repoId: Long? = null, - queryHash: String? = null, resultCount: Int? = null, success: Boolean? = null, errorCode: String? = null, @@ -256,7 +256,6 @@ class TelemetryRepositoryImpl( appVersion = BuildKonfig.VERSION_NAME, eventType = eventType, repoId = repoId, - queryHash = queryHash, resultCount = resultCount, success = success, errorCode = errorCode, diff --git a/core/data/src/commonMain/kotlin/zed/rainxch/core/data/utils/QueryHash.kt b/core/data/src/commonMain/kotlin/zed/rainxch/core/data/utils/QueryHash.kt deleted file mode 100644 index bd43067b2..000000000 --- a/core/data/src/commonMain/kotlin/zed/rainxch/core/data/utils/QueryHash.kt +++ /dev/null @@ -1,17 +0,0 @@ -package zed.rainxch.core.data.utils - -import java.security.MessageDigest - -fun hashQuery(query: String): String { - val normalized = query.trim().lowercase() - if (normalized.isEmpty()) return "" - val digest = MessageDigest.getInstance("SHA-256").digest(normalized.encodeToByteArray()) - val hex = buildString(digest.size * 2) { - for (byte in digest) { - val v = byte.toInt() and 0xff - if (v < 0x10) append('0') - append(v.toString(16)) - } - } - return hex.take(16) -} diff --git a/core/domain/src/commonMain/kotlin/zed/rainxch/core/domain/repository/TelemetryRepository.kt b/core/domain/src/commonMain/kotlin/zed/rainxch/core/domain/repository/TelemetryRepository.kt index d5e394d95..a1d7a305b 100644 --- a/core/domain/src/commonMain/kotlin/zed/rainxch/core/domain/repository/TelemetryRepository.kt +++ b/core/domain/src/commonMain/kotlin/zed/rainxch/core/domain/repository/TelemetryRepository.kt @@ -1,7 +1,7 @@ package zed.rainxch.core.domain.repository interface TelemetryRepository { - fun recordSearchPerformed(query: String, resultCount: Int) + fun recordSearchPerformed(resultCount: Int) fun recordSearchResultClicked(repoId: Long) diff --git a/feature/search/presentation/src/commonMain/kotlin/zed/rainxch/search/presentation/SearchViewModel.kt b/feature/search/presentation/src/commonMain/kotlin/zed/rainxch/search/presentation/SearchViewModel.kt index 17f9530af..e9cf05431 100644 --- a/feature/search/presentation/src/commonMain/kotlin/zed/rainxch/search/presentation/SearchViewModel.kt +++ b/feature/search/presentation/src/commonMain/kotlin/zed/rainxch/search/presentation/SearchViewModel.kt @@ -412,7 +412,6 @@ class SearchViewModel( if (isInitial) { telemetryRepository.recordSearchPerformed( - query = query, resultCount = _state.value.repositories.size, ) }