Skip to content

[MOB-4254] Handle same url search event#1084

Merged
lucaschifino merged 3 commits intomainfrom
ls-mob-4254-same-url-search-event
Mar 19, 2026
Merged

[MOB-4254] Handle same url search event#1084
lucaschifino merged 3 commits intomainfrom
ls-mob-4254-same-url-search-event

Conversation

@lucaschifino
Copy link
Copy Markdown
Collaborator

@lucaschifino lucaschifino commented Mar 17, 2026

MOB-4254

Context

The previousUrl check was introduced to prevent tab switching from re-firing the inapp search event. In practice, tab switching never reaches didCommit — WKWebView handles it at the view level without
triggering navigation delegates. The check was solving a phantom problem, and as a side effect was incorrectly suppressing legitimate same-URL navigations (e.g. tapping a search vertical you're already on).

Depends on #1083 being merged first ❗

Approach

Remove url check and simplified logic.

The only guard retained is !isBackForward, matching web behaviour where bfcache keeps the page mounted across back/forward so Vue never refires.

Before merging

Checklist

  • I performed some relevant testing on a real device and/or simulator for both iPhone and iPad
  • I added the // Ecosia: helper comments where needed

@lucaschifino lucaschifino marked this pull request as ready for review March 18, 2026 09:54
@lucaschifino lucaschifino requested a review from Copilot March 18, 2026 09:55
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adjusts Ecosia in-app search analytics tracking to correctly fire on same-URL navigations (e.g., re-selecting the current search vertical), by removing the prior previousUrl suppression that was preventing legitimate events. This fits into the Ecosia fork’s navigation/analytics integration by keeping the “eligible in decidePolicyFor, fire in didCommit” bridge while simplifying the eligibility logic.

Changes:

  • Remove previousUrl-based suppression and simplify ecosiaHandleNavigationAction to only suppress .backForward.
  • Update WKNavigationDelegate integration to use the simplified tracking helper signature.
  • Update/add unit tests to assert same-URL tracking behavior and back/forward suppression.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
firefox-ios/EcosiaTests/Analytics/AnalyticsSpyTests.swift Updates existing webview-tracking tests and adds a new test covering same-URL navigation via link activation.
firefox-ios/Client/Frontend/Browser/BrowserViewController/Views/BrowserViewController.swift Removes the previousUrl state previously used to suppress duplicate tracking.
firefox-ios/Client/Frontend/Browser/BrowserViewController/Extensions/BrowserViewController+WebViewDelegates.swift Updates the delegate flow to call the simplified navigation tracking helper.
firefox-ios/Client/Ecosia/Extensions/BrowserViewController+EcosiaNavigationHandling.swift Simplifies tracking eligibility: always track Ecosia search vertical navigations except .backForward.

You can also share your feedback on Copilot code review. Take the survey.

@lucaschifino lucaschifino requested a review from a team March 18, 2026 09:59
Copy link
Copy Markdown
Member

@d4r1091 d4r1091 left a comment

Choose a reason for hiding this comment

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

If I understand correctly, we moved the "previous url" tracking as well 👍 .
All good!

Base automatically changed from ls-mob-4251-move-search-analytics to main March 19, 2026 16:16
@lucaschifino lucaschifino force-pushed the ls-mob-4254-same-url-search-event branch from 8e049c3 to 177c950 Compare March 19, 2026 16:35
@lucaschifino lucaschifino merged commit 15347d6 into main Mar 19, 2026
3 checks passed
@lucaschifino lucaschifino deleted the ls-mob-4254-same-url-search-event branch March 19, 2026 16:49
lucaschifino added a commit that referenced this pull request Mar 24, 2026
* [MOB-4254] Handle tab restore and navigation type

* [MOB-4254] Add new test on AnalyticsSpyTests

* [MOB-4254] Remove URL check
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.

3 participants