Skip to content

Analytics: Log triple find times and game completion stats#220

Merged
amorris13 merged 1 commit into
masterfrom
analytics-enhancements-duration-count-7196037304184557660
Apr 4, 2026
Merged

Analytics: Log triple find times and game completion stats#220
amorris13 merged 1 commit into
masterfrom
analytics-enhancements-duration-count-7196037304184557660

Conversation

@amorris13

@amorris13 amorris13 commented Apr 4, 2026

Copy link
Copy Markdown
Owner

This PR enhances analytics logging by adding duration information to triple discovery events and total duration and triple counts to game completion events. This provides better insight into user performance and game progression across different modes.

Fixes #219


PR created automatically by Jules for task 7196037304184557660 started by @amorris13

Changes Overview

This PR enhances analytics logging to capture duration metrics and completion statistics for improved insight into user performance and game progression.

Key Changes

Analytics Constants (AnalyticsConstants.java)

  • Added DURATION parameter constant ("duration")
  • Added TRIPLES_FOUND parameter constant ("triples_found")

Game Activity Logging (BaseGameActivity.java)

  • Triple Find Events: Enhanced logTripleFoundEvent() to compute and log the duration for each triple discovery, calculated as the time difference between consecutive entries in the triple find times list
  • Game Completion Events: Updated gameFinished() to log comprehensive game completion analytics including:
    • Game type
    • Total game duration
    • Count of triples found

Test Coverage

  • GameFlowTest: Added assertion to verify that FIND_TRIPLE events include the duration parameter
  • GameEndFlowTest: Added verification that FINISH_GAME events contain the expected GAME_TYPE, DURATION, and TRIPLES_FOUND parameters

High Priority Review Comments

CC: @jules

- Added DURATION and TRIPLES_FOUND to AnalyticsConstants.
- Updated BaseGameActivity to log individual triple find durations.
- Updated BaseGameActivity to log total game duration and triples found on completion.
- Added verification in GameFlowTest and GameEndFlowTest.

Co-authored-by: amorris13 <4523811+amorris13@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Apr 4, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The changes add analytics tracking for game timing and triple counts by introducing two new parameter constants (DURATION and TRIPLES_FOUND), enhancing Firebase Analytics logging to capture per-triple duration in FIND_TRIPLE events and overall game duration and triple count in FINISH_GAME events, and updating test cases to verify the new analytics payloads.

Changes

Cohort / File(s) Summary
Analytics Constants
app/src/main/java/com/antsapps/triples/AnalyticsConstants.java
Added two new parameter constants: DURATION with value "duration" and TRIPLES_FOUND with value "triples_found" to the Param class.
Analytics Implementation
app/src/main/java/com/antsapps/triples/BaseGameActivity.java
Enhanced logTripleFoundEvent to compute and log per-triple duration from the difference between consecutive entries in getGame().getTripleFindTimes(); updated gameFinished to log FINISH_GAME event directly with bundle containing GAME_TYPE, DURATION (from getGame().getTimeElapsed()), and TRIPLES_FOUND (from getGame().getNumTriplesFound()).
Test Coverage
app/src/test/java/com/antsapps/triples/GameEndFlowTest.java, app/src/test/java/com/antsapps/triples/GameFlowTest.java
Updated test cases to verify Firebase Analytics behavior: GameEndFlowTest now mocks and inspects logEvent invocation with FINISH_GAME event and asserts bundle contains expected GAME_TYPE, DURATION, and TRIPLES_FOUND keys; GameFlowTest adds assertion to verify DURATION key is present in FIND_TRIPLE event bundle.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~14 minutes

Poem

🐰 Hops of joy, with metrics in tow!
Duration and triples now glow,
Each triple finds time, each game spans the climb,
Analytics dance in Firebase's flow!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main changes: adding duration logging for triple finds and game completion statistics to analytics.
Linked Issues check ✅ Passed All coding requirements from issue #219 are met: individual triple find durations are logged, total game duration is recorded, and triples found count is included.
Out of Scope Changes check ✅ Passed All changes are focused on analytics logging for triple durations and game completion stats, directly addressing the linked issue requirements with no extraneous modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch analytics-enhancements-duration-count-7196037304184557660

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
app/src/test/java/com/antsapps/triples/GameFlowTest.java (1)

74-74: Assert duration value, not just key presence

This currently passes even if duration is present but wrong. Add a value-level assertion (e.g., non-negative) to make the test meaningful.

Proposed test tightening
-            assertThat(capturedBundle.containsKey(AnalyticsConstants.Param.DURATION)).isTrue();
+            assertThat(capturedBundle.containsKey(AnalyticsConstants.Param.DURATION)).isTrue();
+            assertThat(capturedBundle.getLong(AnalyticsConstants.Param.DURATION)).isAtLeast(0L);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/test/java/com/antsapps/triples/GameFlowTest.java` at line 74, The
test currently only checks the presence of the DURATION key; update GameFlowTest
to also assert the actual duration value is valid by retrieving the value from
capturedBundle (e.g., capturedBundle.getLong(AnalyticsConstants.Param.DURATION)
or getDouble depending on type) and using assertThat(...) to assert it is
non-negative (assertThat(duration).isGreaterThanOrEqualTo(0)). Ensure you
reference AnalyticsConstants.Param.DURATION and capturedBundle when adding the
assertion.
app/src/test/java/com/antsapps/triples/GameEndFlowTest.java (1)

103-107: Strengthen completion analytics assertions with value checks

Presence checks are helpful, but asserting actual values will catch payload regressions more reliably.

Proposed assertion upgrade
             Bundle capturedBundle = bundleCaptor.getValue();
             assertThat(capturedBundle.getString(AnalyticsConstants.Param.GAME_TYPE))
                 .isEqualTo(ClassicGame.GAME_TYPE_FOR_ANALYTICS);
             assertThat(capturedBundle.containsKey(AnalyticsConstants.Param.DURATION)).isTrue();
             assertThat(capturedBundle.containsKey(AnalyticsConstants.Param.TRIPLES_FOUND)).isTrue();
+            assertThat(capturedBundle.getLong(AnalyticsConstants.Param.DURATION)).isAtLeast(0L);
+            assertThat(capturedBundle.getLong(AnalyticsConstants.Param.TRIPLES_FOUND))
+                .isEqualTo(game.getNumTriplesFound());
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/test/java/com/antsapps/triples/GameEndFlowTest.java` around lines 103
- 107, The test currently only asserts presence of DURATION and TRIPLES_FOUND
keys; update GameEndFlowTest to assert their actual values: retrieve values from
capturedBundle (e.g., capturedBundle.getLong(AnalyticsConstants.Param.DURATION)
and capturedBundle.getInt(AnalyticsConstants.Param.TRIPLES_FOUND) or getString
if appropriate) and compare them to the expected values used in the test (use
existing variables or compute expectedDuration/expectedTriplesFound from the
test setup) with assertThat(...).isEqualTo(...); keep the existing assert for
GAME_TYPE using ClassicGame.GAME_TYPE_FOR_ANALYTICS and replace the containsKey
assertions with these value equality assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@app/src/test/java/com/antsapps/triples/GameEndFlowTest.java`:
- Around line 103-107: The test currently only asserts presence of DURATION and
TRIPLES_FOUND keys; update GameEndFlowTest to assert their actual values:
retrieve values from capturedBundle (e.g.,
capturedBundle.getLong(AnalyticsConstants.Param.DURATION) and
capturedBundle.getInt(AnalyticsConstants.Param.TRIPLES_FOUND) or getString if
appropriate) and compare them to the expected values used in the test (use
existing variables or compute expectedDuration/expectedTriplesFound from the
test setup) with assertThat(...).isEqualTo(...); keep the existing assert for
GAME_TYPE using ClassicGame.GAME_TYPE_FOR_ANALYTICS and replace the containsKey
assertions with these value equality assertions.

In `@app/src/test/java/com/antsapps/triples/GameFlowTest.java`:
- Line 74: The test currently only checks the presence of the DURATION key;
update GameFlowTest to also assert the actual duration value is valid by
retrieving the value from capturedBundle (e.g.,
capturedBundle.getLong(AnalyticsConstants.Param.DURATION) or getDouble depending
on type) and using assertThat(...) to assert it is non-negative
(assertThat(duration).isGreaterThanOrEqualTo(0)). Ensure you reference
AnalyticsConstants.Param.DURATION and capturedBundle when adding the assertion.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 628d5511-5e2f-4bdd-adc1-d78d6bf858bc

📥 Commits

Reviewing files that changed from the base of the PR and between ed77e1e and 85b0b23.

📒 Files selected for processing (4)
  • app/src/main/java/com/antsapps/triples/AnalyticsConstants.java
  • app/src/main/java/com/antsapps/triples/BaseGameActivity.java
  • app/src/test/java/com/antsapps/triples/GameEndFlowTest.java
  • app/src/test/java/com/antsapps/triples/GameFlowTest.java

@amorris13 amorris13 merged commit 10c6b53 into master Apr 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Log find triple times and complete game times to analytics

1 participant