diff --git a/editor/CMakeLists.txt b/editor/CMakeLists.txt index 63b1bd3..e4edb46 100644 --- a/editor/CMakeLists.txt +++ b/editor/CMakeLists.txt @@ -4747,4 +4747,13 @@ target_link_libraries(step651_test PRIVATE tree_sitter_javascript tree_sitter_typescript tree_sitter_java tree_sitter_rust tree_sitter_go) +add_executable(step652_test tests/step652_test.cpp) +target_include_directories(step652_test PRIVATE src) +target_link_libraries(step652_test PRIVATE + nlohmann_json::nlohmann_json + unofficial::tree-sitter::tree-sitter + tree_sitter_python tree_sitter_cpp tree_sitter_elisp + tree_sitter_javascript tree_sitter_typescript + tree_sitter_java tree_sitter_rust tree_sitter_go) + # Step 12: Dear ImGui shell scaffolding created (main.cpp exists but not built due to dependencies) diff --git a/editor/src/LocalTelemetryModel.h b/editor/src/LocalTelemetryModel.h new file mode 100644 index 0000000..192e854 --- /dev/null +++ b/editor/src/LocalTelemetryModel.h @@ -0,0 +1,41 @@ +#pragma once +// Step 652: Privacy-preserving local telemetry + +#include +#include + +struct TelemetryCounters { + int sessionMinutes = 0; + int toolCalls = 0; + int errorCount = 0; + std::map generatorUsage; +}; + +class LocalTelemetryModel { +public: + static void recordSessionMinutes(TelemetryCounters* c, int minutes) { + if (!c || minutes < 0) return; + c->sessionMinutes += minutes; + } + + static void recordToolCall(TelemetryCounters* c) { + if (!c) return; + ++c->toolCalls; + } + + static void recordError(TelemetryCounters* c) { + if (!c) return; + ++c->errorCount; + } + + static void recordGeneratorUse(TelemetryCounters* c, const std::string& generatorName) { + if (!c || generatorName.empty()) return; + ++c->generatorUsage[generatorName]; + } + + static std::string weeklyReport(const TelemetryCounters& c) { + return "session_minutes=" + std::to_string(c.sessionMinutes) + + ";tool_calls=" + std::to_string(c.toolCalls) + + ";errors=" + std::to_string(c.errorCount); + } +}; diff --git a/editor/tests/step652_test.cpp b/editor/tests/step652_test.cpp new file mode 100644 index 0000000..8f25684 --- /dev/null +++ b/editor/tests/step652_test.cpp @@ -0,0 +1,24 @@ +// Step 652: Privacy-preserving local telemetry (12 tests) + +#include "LocalTelemetryModel.h" +#include +static int p=0,f=0; +#define T(n) { std::cout<<" "<<#n<<"... "; } +#define P() { std::cout<<"PASS\n"; ++p; } +#define F(m) { std::cout<<"FAIL: "<