Skip to content

Conversation

@Ecarrion
Copy link
Contributor

Closes: #8340

Why

We found out that using a single enum for the analytics hub ranges was not ideal because the UI and the business logic had slightly different requirements that forced us to write code that was not very readable.

  • We couldn't use swift case iterable synthesizer.
  • We had to deal with a bunch of optionals that made the code less clear.

To mitigate this, this PR is decoupling that situation by adding a new Range enum just meant for the view.
As this enum needs some metadata from the original SelectionType, I've extracted that into a new AnalyticsHubRangeAdapter type that helps the conversions between those two and contains the shared data.

The AnalyticsHubRangeAdapter is a bit verbose and looks like it's duplicating work but keeps the complexity contained and we gain things like:

  • Easier code to read and maintain
  • Easier way to pass initial dates (previously selected) to the range time picker

Demo

Screen.Recording.2022-12-13.at.11.35.34.PM.mov

Testing Steps

  • Make sure the time range selection keeps working as expected.

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@Ecarrion Ecarrion added the category: tracks Related to analytics, including Tracks Events. label Dec 14, 2022
@Ecarrion Ecarrion added this to the 11.7 milestone Dec 14, 2022
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 14, 2022

You can test the changes from this Pull Request by:
  • Clicking here or scanning the QR code below to access App Center
  • Then installing the build number pr8401-e6d60f1 on your iPhone

If you need access to App Center, please ask a maintainer to add you.

@rachelmcr rachelmcr self-assigned this Dec 14, 2022
Copy link
Contributor

@rachelmcr rachelmcr left a comment

Choose a reason for hiding this comment

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

This is really nice! I agree that the verbosity in AnalyticsHubRangeAdapter is worth it for the clarity it provides. 🚀

@Ecarrion Ecarrion merged commit 791f111 into trunk Dec 14, 2022
@Ecarrion Ecarrion deleted the issue/8340-decouple-bussiness-ui branch December 14, 2022 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: tracks Related to analytics, including Tracks Events.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Analytics Hub] Decouple Business from UI ranges

4 participants