Skip to content

fix: guard toJSON() debug call with #if DEBUG in ProfileView#214

Merged
sebastianricaldoni merged 6 commits into
mainfrom
bug/BAL-211-SR-fix-game-session-duration-logging
Jun 11, 2026
Merged

fix: guard toJSON() debug call with #if DEBUG in ProfileView#214
sebastianricaldoni merged 6 commits into
mainfrom
bug/BAL-211-SR-fix-game-session-duration-logging

Conversation

@sebastianricaldoni

Copy link
Copy Markdown
Collaborator

Summary

  • Wraps toJSON() call in ProfileView.loadLogs() with #if DEBUG guard
  • toJSON() is defined only in #if DEBUG — Release builds (Fastlane/TestFlight) would fail to compile without this guard

Test plan

  • Build in Release configuration — no compile errors
  • Debug build still prints log dump in loadLogs()

🤖 Generated with Claude Code

- Add finalizeOpenActions() to close pending "Opened X" actions when
  app backgrounds, fixing zero-duration bug when app is killed mid-game
- Move reset() logic to UIApplication.willEnterForegroundNotification
  observer on ActivityLogEntry (synchronous, fires before SwiftUI views)
  to avoid race condition with async saveLog on background
- Add didBecomeActiveNotification handler in ActivityLogBaseView with
  isVisible guard to re-log current view on resume when onAppear does
  not fire reliably
- Add Home view logging via ActivityLogBaseView wrapper
- Add Encodable.toJSON() debug utility in BalanceExtensions
- Fix WKCompanionAppBundleIdentifier for local device signing
…model

Replace fragile "Opened X" / "Closed X" string-matching with a clean
push(viewName:) + finalizePending() stack model:

- push() finalizes previous pending entry then opens a new one
- finalizePending() closes current entry with correct duration
- onDisappear only finalizes if pendingEntry matches view (guards
  against forward-nav double-finalize since onAppear fires first)
- ActivityLogEntry observes willEnterForegroundNotification directly
  (synchronous, before SwiftUI views) to guarantee reset fires before
  any onAppear on resume
- ActivityLogBaseView uses didBecomeActiveNotification + isVisible guard
  to re-push current view when onAppear does not fire on resume
- Home ActivityLogBaseView moved inside NavigationStack root so
  onAppear/onDisappear fire correctly on forward/back navigation
- Rename actions → entries (CodingKeys maps to "actions" for backwards
  compatibility with existing user data)
- addActionButton renamed to addButtonEvent for clarity
- Coins eligibility extracted to Set<String> replacing long if-chain
- ProfileView share buttons do fresh file load on tap (single source of
  truth); ShareLink replaced with Button + UIActivityViewController
- SpotifyViewController updated to new push/finalizePending API
@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 5.23%. Comparing base (689a7a2) to head (01cacc0).

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main    #214   +/-   ##
=====================================
  Coverage   5.23%   5.23%           
=====================================
  Files        130     130           
  Lines       2142    2142           
=====================================
  Hits         112     112           
  Misses      2030    2030           
Files with missing lines Coverage Δ
Balance/Profile/ProfileView.swift 0.00% <ø> (ø)

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 689a7a2...01cacc0. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gperissetcelteeka gperissetcelteeka left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@sebastianricaldoni sebastianricaldoni self-assigned this Jun 11, 2026
@sebastianricaldoni sebastianricaldoni merged commit e5123f2 into main Jun 11, 2026
5 checks passed
@sebastianricaldoni sebastianricaldoni deleted the bug/BAL-211-SR-fix-game-session-duration-logging branch June 11, 2026 16:41
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.

2 participants