Generate Events
Run the Gradle build to trigger KSP code generation for analytics events.
Pre-flight (do this BEFORE adding any new event definitions)
- Ask the user which ticket they are working on. Use
AskUserQuestionto capture the ticket ID (e.g.,AND-XXXXX). Do not assume the current branch name reflects the right ticket — the user may be starting fresh work. - Pull latest
main. If there are uncommitted changes, stash them first, pull, then pop:
If already on a clean tree, justgit stash push -m "WIP: <ticket> <short description>" git pull origin main git stash popgit pull origin main(or check outmainfirst if on another branch). - Create a new branch prefixed with the current git user's initials (never use
task/or commit directly tomain). Derive the prefix fromgit config user.name— take the lowercase initials of the first and last name (e.g.,Hai Luong→lh,Jane Doe→jd):
Example for userUSER_PREFIX=$(git config user.name | awk '{print tolower(substr($1,1,1) substr($NF,1,1))}') git checkout -b "${USER_PREFIX}/<TICKET>-<short-kebab-description>"Hai Luong:lh/AND-22751-cloud-drive-document-provider-events.
Only after these three steps should you add or modify event definitions.
Steps
- Ensure the new event definitions have been added. Events are annotated interfaces or classes in
shared/src/commonMain/kotlin/mega/privacy/mobile/analytics/event/in the appropriate file (e.g.,ButtonPressEvents.kt,ScreenViewEvents.kt, etc.). Simple events use aninterface, events with runtime parameters use aclasswith constructor params. SeeCLAUDE.mdfor the full annotation reference. - Run
./gradlew buildfrom the project root to trigger KSP annotation processing. - Wait for the build to complete. This generates:
- Event Kotlin classes from annotated interfaces/classes
- Updated JSON event ID mappings in
shared/src/commonMain/resources/
- After the build completes, run
git statusto show which files were generated or updated. - Remind the user: The updated JSON files in
shared/src/commonMain/resources/must be committed to preserve stable event IDs. If they are not committed, event IDs may change and corrupt analytics data.