Skip to content

fix: [MR-175] add debug-only custom cr_user_id and local sub-app redirect - #283

Open
janfb-codev wants to merge 2 commits into
developfrom
feature/MR-175
Open

fix: [MR-175] add debug-only custom cr_user_id and local sub-app redirect#283
janfb-codev wants to merge 2 commits into
developfrom
feature/MR-175

Conversation

@janfb-codev

@janfb-codev janfb-codev commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Changes

Two debug-only testing tools. Both are no-ops in release builds.

  • Custom cr_user_id: debug-only field in the language popup to override the device's random pseudoId, so a tester can target a known Firestore doc. Honored by both WebApp and MainActivity.warmFirestoreDataSync().
  • Local sub-app redirect: WebAppsAdapter.maybeOverrideAppUrlForLocalDev() rewrites a matching sub-app URL to a local dev server. Replaces the origin only — path dropped, query/fragment preserved.
  • Redirect config lives in two local.properties keys (gitignored), read into LOCAL_SUBAPP_* on the debug buildType. CI has no local.properties, so the redirect is inert in the debug APK CI commits for testers — nothing to revert before pushing. See local.properties.example.
  • Adds the test-subapp-locally skill documenting the full rig.

How to test

  • Redirect: copy the FTM block from local.properties.example, npm run dev in FeedTheMonsterJS (:8080), adb reverse tcp:8080 tcp:8080, run debug from Android Studio, tap FTM. Expect the WebAppsAdapter: DEBUG sub-app URL override: ... -> http://localhost:8080/?... log and the local build loading. Confirm monster-state polling still fires and attribution.hostname holds the real host, not localhost.
  • Custom cr_user_id: debug build → enter a known id in the language popup → launch FTM → payload lands on that doc. Not visible in release.

Ref: MR-175

Summary by CodeRabbit

  • New Features

    • Added debug-only local development redirects for supported sub-apps, including localhost network access.
    • Added a debug-only custom user ID field for testing and event tracking.
    • Preserved deployed app identity and specialized behavior when using local redirects.
  • Documentation

    • Added setup guidance and examples for configuring local sub-app redirects, emulator access, and secure local development.

@janfb-codev
janfb-codev requested a review from miguelccodev July 30, 2026 11:59
@janfb-codev janfb-codev self-assigned this Jul 30, 2026
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Debug builds now support configurable local sub-app redirects, loopback HTTP access, and a custom cr_user_id override. Redirected WebApps retain their deployed identity for host and FTM-specific behavior, while release builds keep empty redirect settings and no identity override.

Changes

Debug development controls

Layer / File(s) Summary
Local redirect configuration
app/build.gradle, app/src/debug/..., local.properties.example
Debug BuildConfig values load optional local redirect settings, and loopback cleartext traffic is permitted only in debug builds.
Local sub-app launch redirect
app/src/main/java/org/curiouslearning/container/presentation/adapters/WebAppsAdapter.java
Configured matching hosts are redirected to a replacement origin while preserving query and fragment values; the original URL is passed to WebApp.
Debug identity override flow
app/src/main/java/org/curiouslearning/container/MainActivity.java, app/src/main/java/org/curiouslearning/container/WebApp.java, app/src/main/res/layout/language_popup.xml, app/src/main/res/values/strings.xml
The language popup stores a debug custom user ID, and runtime identity, hostname, and FTM detection use the appropriate original URL and override values.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Developer
  participant WebAppsAdapter
  participant WebApp
  participant LocalSubAppServer
  Developer->>WebAppsAdapter: configure debug redirect properties
  WebAppsAdapter->>WebAppsAdapter: match and rewrite sub-app origin
  WebAppsAdapter->>WebApp: launch local URL with original deployed URL
  WebApp->>LocalSubAppServer: load redirected sub-app
  WebApp->>WebApp: retain deployed hostname and FTM identity
Loading

Possibly related PRs

Suggested reviewers: miguelccodev, amitsinghsutara, dz4va

🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Tests & Lint & Coverage ⚠️ Warning No new/updated tests cover the debug-only user-id or local-redirect paths, and there’s no verifiable lint/coverage result showing ≥70%. Add tests for custom_cr_user_id and local URL rewrite edge cases, then run lint and publish a coverage report proving at least 70%.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main debug-only custom user ID and local sub-app redirect changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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 feature/MR-175

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.

@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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@app/src/main/java/org/curiouslearning/container/presentation/adapters/WebAppsAdapter.java`:
- Around line 184-191: Update the URL reconstruction in WebAppsAdapter to add
the container parameters to the query component before restoring the fragment,
rather than appending them after the fragment. Use a URI builder to preserve
existing query values and safely encode the added source, campaign_id,
container_app_version, and cr_user_id parameters, and add coverage for URLs
containing both query and fragment components.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ff6809f0-8107-46eb-b314-8b7d1481810a

📥 Commits

Reviewing files that changed from the base of the PR and between af7a783 and 1123c3e.

⛔ Files ignored due to path filters (1)
  • .claude/skills/test-subapp-locally/SKILL.md is excluded by !**/*.md
📒 Files selected for processing (9)
  • app/build.gradle
  • app/src/debug/AndroidManifest.xml
  • app/src/debug/res/xml/network_security_config.xml
  • app/src/main/java/org/curiouslearning/container/MainActivity.java
  • app/src/main/java/org/curiouslearning/container/WebApp.java
  • app/src/main/java/org/curiouslearning/container/presentation/adapters/WebAppsAdapter.java
  • app/src/main/res/layout/language_popup.xml
  • app/src/main/res/values/strings.xml
  • local.properties.example

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