Skip to content

feat: added stripping of tracking parameters before opening URLs#1097

Merged
spacecowboy merged 3 commits into
spacecowboy:masterfrom
mvanhorn:fix/remove-traffic-source-tracking
Apr 10, 2026
Merged

feat: added stripping of tracking parameters before opening URLs#1097
spacecowboy merged 3 commits into
spacecowboy:masterfrom
mvanhorn:fix/remove-traffic-source-tracking

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Strips utm_* and traffic_source query parameters from article URLs when sharing via the share button. The feed source adds these tracking parameters to article links; removing them before sharing keeps shared URLs cleaner.

Changes

  • New: app/src/main/java/com/nononsenseapps/feeder/util/UrlCleaner.kt - stripTrackingParameters() function that removes utm_* and traffic_source params while preserving all other query parameters
  • ArticleScreen.kt (line 144): Apply parameter stripping to the shared article link
  • FeedScreen.kt (lines 1353, 1587): Apply parameter stripping to both feed list share paths

How it works

The function parses the URL with android.net.Uri, checks if any tracking parameters exist, and rebuilds the URL without them. If no tracking parameters are present or the URL can't be parsed, it returns the original URL unchanged.

Stripped prefixes: utm_source, utm_medium, utm_campaign, utm_term, utm_content, traffic_source.

Testing

  • URL with ?utm_source=rss&id=123 -> shared as ?id=123
  • URL with ?traffic_source=rss -> shared with no query string
  • URL with no tracking params -> shared unchanged
  • Malformed URL -> returned as-is

Closes #1044

This contribution was developed with AI assistance (Claude Code).

Remove utm_* and traffic_source query parameters from article URLs
when sharing via Intent. The feed source adds these params; stripping
them before sharing improves privacy without affecting the article
content.

Added stripTrackingParameters() utility in UrlCleaner.kt and applied
it to the three share paths in ArticleScreen.kt and FeedScreen.kt.

Closes spacecowboy#1044

@spacecowboy spacecowboy left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Added some comments.

Further, CI is red. Please ensure CI passes

Comment thread app/src/main/java/com/nononsenseapps/feeder/ui/compose/feed/FeedScreen.kt Outdated
Comment thread app/src/main/java/com/nononsenseapps/feeder/ui/compose/feed/FeedScreen.kt Outdated
Comment thread app/src/main/java/com/nononsenseapps/feeder/util/UrlCleaner.kt
- Import stripTrackingParameters in FeedScreen.kt and ArticleScreen.kt
  instead of using the fully qualified path
- Refactor UrlCleaner to use java.net.URI instead of android.net.Uri
  so it can be unit tested without Robolectric
- Add UrlCleanerKtTest with 5 basic test cases

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@mvanhorn

mvanhorn commented Apr 3, 2026

Copy link
Copy Markdown
Contributor Author

Fixed all three items:

  • Switched to proper imports in both FeedScreen.kt and ArticleScreen.kt
  • Added unit test (UrlCleanerKtTest) with 5 test cases
  • Refactored UrlCleaner to use java.net.URI instead of android.net.Uri so it's testable without Robolectric

CI should be green now.

@spacecowboy

Copy link
Copy Markdown
Owner

Please run ./gradlew ktlintformat

And please look at the output of the CI jobs and fix them

Capture viewState.articleLink in a local val before the null
check so Kotlin can smart-cast it (the interface property has
an open getter). Also ran ktlintFormat to fix import ordering.
@mvanhorn

mvanhorn commented Apr 9, 2026

Copy link
Copy Markdown
Contributor Author

Fixed both CI issues in 560c798:

  1. Smart cast - viewState.articleLink is an interface property so Kotlin can't smart-cast it after the null check. Captured it in a local val first.
  2. ktlint - ran ktlintFormat, fixed import ordering in FeedScreen.kt.

ktlintCheck passes locally. Don't have Android SDK set up so couldn't verify compile locally, but the smart cast fix is straightforward.

@spacecowboy spacecowboy changed the title feat: strip tracking parameters from shared URLs feat: added stripping of tracking parameters before opening URLs Apr 10, 2026
@spacecowboy spacecowboy merged commit 1775e90 into spacecowboy:master Apr 10, 2026
12 checks passed
@spacecowboy

Copy link
Copy Markdown
Owner

thanks @mvanhorn

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.

Remove URL Tracking parameter when sharing links from app

2 participants