Repository navigation
Improved telemetry by adding anonymous usage reports - #4687
gabriel-bolbotina wants to merge 21 commits into
Conversation
Coverage Report for CI Build 38541450983Coverage decreased (-0.7%) to 58.842%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions319 previously-covered lines in 6 files lost coverage.
Coverage Stats
💛 - Coveralls |
📦 Build Artifacts Ready
|
📦 Build Artifacts Ready
|
Add usageReportEnabled property to AppSettings with QSettings persistence under usage_report/enabled. On opt-out, all accumulated usage_report/* data is cleared but the enabled flag is preserved. Wire the toggle to the settings page UI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add USAGE_REPORT_KEY CMake variable and mmconfig.h.in define. Add trySubmitUsageSnapshot() function in main.cpp that: - checks if a weekly snapshot is due - collects static data (device, app, server info) - merges accumulated dynamic data from QSettings - sends a single HTTP POST to the EU endpoint - resets dynamic data on success, silently ignores errors Called once after app initialization. No signal connections yet — dynamic data accumulation will be wired in the next commit. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Wire feature class signals in main.cpp to lambdas that write usage data to QSettings under usage_report/data/*. Signals connected: - FilterController::hasFiltersActivatedChanged → filtering - AutosyncController::projectSyncRequested → autosync - ProjectWizard::projectCreated → created_project - AndroidUtils/IosUtils::photoCaptured/photoFromGallery → image counts - MerginUserInfo::activeWorkspaceChanged → workspace_switches - PositionKit::positionProviderChanged → external GPS tracking - ActiveProject::projectRoleChanged → highest_role - ActiveProject::loadingStarted/projectReloaded → project load time New signals added: - MapSketchingController::sketched() for map sketching detection - AndroidUtils/IosUtils::photoCaptured()/photoFromGallery() to distinguish camera capture from gallery attachment Connectivity ping timer: HEAD request every 5 minutes, counts success/failure in QSettings. Note: map measuring, map sketching, photo sketching, reuse last value, and bulk editing are QML-instantiated objects — these will be tracked via AppSettings helpers in the next commit. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add trackUsageFeature() and incrementUsageCounter() to AppSettings for features whose C++ controllers are QML-instantiated per-use objects with no persistent instance to connect to in main.cpp. Tracked from QML: - map_measuring (MMMapController) - map_sketching (MMMapController) - photo_sketching (MMFormPhotoSketchingPageDialog) - reuse_last_value (MMFormStackController, on form save) - bulk_editing (main.qml, on multi-edit with >1 feature) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Added a temporary endpoint Remaned distinct_id with device_id
Added layer and feature search analytics Updated filtering analytics
f3dce9f to
8567d83
Compare
Updated the dialog image
📦 Build Artifacts Ready
|
Moved the logic out of main
Small changes in the usage reporter controller
📦 Build Artifacts Ready
|
Added total ping count
📦 Build Artifacts Ready
|
📦 Build Artifacts Ready
|
Updated connectivity ping endpoint
📦 Build Artifacts Ready
|
xkello
left a comment
There was a problem hiding this comment.
@gabriel-bolbotina looks good. Just some small things here and there.
| // Temporary: immediate snapshot trigger from QML test button | ||
| QObject::connect( as, &AppSettings::immediateUsageSnapshotRequested, &usageReportController, &UsageReportController::forceSubmitSnapshot ); | ||
|
|
||
| // Gather dynamic usage data via signal connections | ||
| UsageReportController &urc = usageReportController; | ||
|
|
||
| // Auto-sync | ||
| QObject::connect( &activeProject, &ActiveProject::autosyncControllerChanged, &lambdaContext, [&urc]( AutosyncController * ac ) | ||
| { | ||
| if ( !ac ) return; | ||
| QObject::connect( ac, &AutosyncController::projectSyncRequested, ac, [&urc]( SyncOptions::RequestOrigin origin ) | ||
| { | ||
| if ( origin == SyncOptions::AutomaticRequest ) | ||
| urc.trackFeature( QStringLiteral( "autosync" ) ); | ||
| } ); | ||
| } ); | ||
|
|
||
| // Created project | ||
| QObject::connect( &pw, &ProjectWizard::projectCreated, &lambdaContext, [&urc]( const QString &, const QString & ) | ||
| { | ||
| urc.trackFeature( QStringLiteral( "created_project" ) ); | ||
| } ); | ||
|
|
||
| // Photo captured vs attached | ||
| QObject::connect( &androidUtils, &AndroidUtils::photoCaptured, &lambdaContext, [&urc]() | ||
| { | ||
| urc.incrementCounter( QStringLiteral( "captured_images" ) ); | ||
| } ); | ||
| QObject::connect( &androidUtils, &AndroidUtils::photoFromGallery, &lambdaContext, [&urc]() | ||
| { | ||
| urc.incrementCounter( QStringLiteral( "attached_images" ) ); | ||
| } ); | ||
| QObject::connect( &iosUtils, &IosUtils::photoCaptured, &lambdaContext, [&urc]() | ||
| { | ||
| urc.incrementCounter( QStringLiteral( "captured_images" ) ); | ||
| } ); | ||
| QObject::connect( &iosUtils, &IosUtils::photoFromGallery, &lambdaContext, [&urc]() | ||
| { | ||
| urc.incrementCounter( QStringLiteral( "attached_images" ) ); | ||
| } ); | ||
|
|
||
| // Workspace switches | ||
| QObject::connect( ma->userInfo(), &MerginUserInfo::activeWorkspaceChanged, &lambdaContext, [&urc]() | ||
| { | ||
| urc.incrementCounter( QStringLiteral( "workspace_switches" ) ); | ||
| } ); | ||
|
|
||
| // External GPS provider | ||
| QObject::connect( pk, &PositionKit::positionProviderChanged, &lambdaContext, [&urc]( AbstractPositionProvider * provider ) | ||
| { | ||
| if ( !provider ) return; | ||
|
|
||
| // simulated provider has type "internal", so check it by id first | ||
| const QString type = provider->type(); | ||
| QString connectionType; | ||
| if ( provider->id() == QLatin1String( "simulated" ) ) | ||
| connectionType = QStringLiteral( "mock" ); | ||
| else if ( type == QLatin1String( "external_bt" ) ) | ||
| connectionType = QStringLiteral( "bluetooth" ); | ||
| else if ( type == QLatin1String( "external_ip" ) ) | ||
| connectionType = QStringLiteral( "network" ); | ||
| else if ( type == QLatin1String( "external_trimble" ) ) | ||
| connectionType = QStringLiteral( "trimble" ); | ||
| else | ||
| return; // internal | ||
|
|
||
| urc.trackFeature( QStringLiteral( "external_gps" ) ); | ||
| urc.setData( QStringLiteral( "external_connection_type" ), connectionType ); | ||
| urc.setData( QStringLiteral( "external_brand" ), UsageReportController::externalProviderBrand( type, provider->name() ) ); | ||
| } ); | ||
|
|
||
| // Highest project role | ||
| QObject::connect( &activeProject, &ActiveProject::projectRoleChanged, &lambdaContext, [&urc, as, &activeProject]() | ||
| { | ||
| if ( !as->usageReportEnabled() ) return; | ||
|
|
||
| const QString role = activeProject.projectRole(); | ||
| auto roleRank = []( const QString & r ) -> int | ||
| { | ||
| if ( r == QLatin1String( "owner" ) ) return 5; | ||
| if ( r == QLatin1String( "admin" ) ) return 4; | ||
| if ( r == QLatin1String( "writer" ) ) return 3; | ||
| if ( r == QLatin1String( "reader" ) ) return 2; | ||
| if ( r == QLatin1String( "guest" ) ) return 1; | ||
| return 0; | ||
| }; | ||
|
|
||
| QSettings s; | ||
| const QString current = s.value( QStringLiteral( "usage_report/data/highest_role" ) ).toString(); | ||
| if ( roleRank( role ) > roleRank( current ) ) | ||
| urc.setData( QStringLiteral( "highest_role" ), role ); | ||
| } ); | ||
|
|
||
| // Project load time | ||
| QObject::connect( &activeProject, &ActiveProject::loadingStarted, &lambdaContext, [&urc]() | ||
| { | ||
| urc.startLoadTimer(); | ||
| } ); | ||
|
|
||
| urc.startPingTimer(); | ||
|
|
||
| QObject::connect( &activeProject, &ActiveProject::projectReloaded, &lambdaContext, [merginApi = ma.get(), &activeProject, &urc]() |
There was a problem hiding this comment.
Can't this be moved to the usagereportcontroller.cpp?
| if ( r == QLatin1String( "owner" ) ) return 5; | ||
| if ( r == QLatin1String( "admin" ) ) return 4; | ||
| if ( r == QLatin1String( "writer" ) ) return 3; | ||
| if ( r == QLatin1String( "reader" ) ) return 2; | ||
| if ( r == QLatin1String( "guest" ) ) return 1; | ||
| return 0; |
There was a problem hiding this comment.
I don't see the role editor. Is that intentional?
| onSearchTextChanged: { | ||
| featuresModel.searchExpression = searchBar.text | ||
| if ( searchBar.text.length > 0 ) | ||
| AppSettings.trackUsageFeature( "features_search" ) | ||
| } |
There was a problem hiding this comment.
Does this write on every keystroke? Could probably work the same with writing once per search.
| QSettings s; | ||
| const QString fullKey = QStringLiteral( "usage_report/data/" ) + key; | ||
| s.setValue( fullKey, s.value( fullKey, 0 ).toInt() + amount ); | ||
| } |
There was a problem hiding this comment.
Don't these do the same as trackUsageFeature and incrementUsageCounter in appsettings.cpp? Could we expose them and drop the appsettings version?
| mAutosyncController.reset(); | ||
| } | ||
|
|
||
| emit autosyncControllerChanged( mAutosyncController.get() ); |
There was a problem hiding this comment.
This signal wasn't emitted before so it could have some unwanted effects outside of telemetry. Might need some special attention when testing.
This enhancement has been done to better understand our app and which features are valuable to our users, as well as continuing on improving the experience overall. It also helps prioritise development and simplifies UX/ UI design. It is an OPT-OUT enhancement that stores no personal data.
Summary of changes:
trySubmitUsageSnapshot+ signal connections for each feature that is analysedTemporary parts of code for testing:
Remaining things to be added/ decided:
Resolves: https://github.com/MerginMaps/product/issues/127