Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analytics for device forecast details entry point #214

Conversation

pantelisss
Copy link
Collaborator

@pantelisss pantelisss commented Jan 17, 2025

Why?

Fix the inconsistency of screen tracking in station details.
The issue occurred when the user swipes with more "power" from the first tab (Overview) to the second (Forecast). So because of the scroller bounce effect, a small part of the third tab (Rewards) appears and triggers the onAppear callback

How?

Now we track the screen event from the container (StationDetailsContainerView) on every selectedIndex change

Testing

There are some debug prints in WXMAnalytics file which shows in the console every screen and event track.
Just filter the console output with WXMAnalytics.
Screenshot 2025-01-17 at 12 27 34

This code will be removed once the review is over

Additional context

fixes fe-1529

Summary by CodeRabbit

  • Analytics

    • Removed screen tracking from various views in the app
    • Updated StationDetailsViewModel to handle screen view tracking more dynamically
    • Added temporary debugging print statements for analytics tracking
  • Refactor

    • Simplified screen view event tracking mechanism across multiple views

Copy link

coderabbitai bot commented Jan 17, 2025

Walkthrough

This pull request focuses on modifying analytics tracking across several UI components in the PresentationLayer. The changes primarily involve removing existing screen tracking calls from various views and introducing a more centralized approach to tracking screen view events in the StationDetailsContainerView and StationDetailsViewModel. A new method for tracking screen events has been added, and temporary debugging print statements have been introduced in the WXMAnalytics class to aid in tracking.

Changes

File Change Summary
PresentationLayer/UIComponents/Screens/LoggedInViews/LoggedInTabViewContainer.swift Removed analytics tracking for home tab
PresentationLayer/UIComponents/Screens/WeatherStations/StationDetails/Forecast/StationForecastView.swift Removed onAppear screen tracking
PresentationLayer/UIComponents/Screens/WeatherStations/StationDetails/Overview/OverviewView.swift Removed onAppear screen tracking
PresentationLayer/UIComponents/Screens/WeatherStations/StationDetails/Rewards/StationRewardsView.swift Removed onAppear screen tracking
PresentationLayer/UIComponents/Screens/WeatherStations/StationDetails/StationDetailsContainerView.swift Added new screen view tracking method and .task modifier
PresentationLayer/UIComponents/Screens/WeatherStations/StationDetails/StationDetailsViewModel.swift Added trackScreenViewEvent(for:) method and analyticsScreen computed property
wxm-ios/Toolkit/Toolkit/Analytics/WXMAnalytics.swift Added debugging print statements for screen and event tracking

Sequence Diagram

sequenceDiagram
    participant View as StationDetailsContainerView
    participant ViewModel as StationDetailsViewModel
    participant Analytics as WXMAnalytics

    View->>ViewModel: trackScreenViewEvent(for: index)
    ViewModel->>Analytics: trackScreen(screen)
    Analytics-->>ViewModel: Screen tracked
Loading

Possibly related PRs

Suggested reviewers

  • PavlosTze

Poem

🐰 Hop, hop, analytics dance,
Tracking screens with rabbit's glance,
Debugging prints now take the stage,
A playful leap on coding's page,
Metrics flow with bunny's grace! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@pantelisss pantelisss requested a review from PavlosTze January 17, 2025 10:29
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
wxm-ios/Toolkit/Toolkit/Analytics/WXMAnalytics.swift (1)

63-70: Consider moving the test extension to a test-specific file.

The testString extension is only used for debugging purposes. Consider moving it to a separate test utilities file to keep the production code clean.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4afee69 and 56c665f.

📒 Files selected for processing (7)
  • PresentationLayer/UIComponents/Screens/LoggedInViews/LoggedInTabViewContainer.swift (0 hunks)
  • PresentationLayer/UIComponents/Screens/WeatherStations/StationDetails/Forecast/StationForecastView.swift (0 hunks)
  • PresentationLayer/UIComponents/Screens/WeatherStations/StationDetails/Overview/OverviewView.swift (0 hunks)
  • PresentationLayer/UIComponents/Screens/WeatherStations/StationDetails/Rewards/StationRewardsView.swift (0 hunks)
  • PresentationLayer/UIComponents/Screens/WeatherStations/StationDetails/StationDetailsContainerView.swift (2 hunks)
  • PresentationLayer/UIComponents/Screens/WeatherStations/StationDetails/StationDetailsViewModel.swift (2 hunks)
  • wxm-ios/Toolkit/Toolkit/Analytics/WXMAnalytics.swift (2 hunks)
💤 Files with no reviewable changes (4)
  • PresentationLayer/UIComponents/Screens/WeatherStations/StationDetails/Rewards/StationRewardsView.swift
  • PresentationLayer/UIComponents/Screens/WeatherStations/StationDetails/Forecast/StationForecastView.swift
  • PresentationLayer/UIComponents/Screens/WeatherStations/StationDetails/Overview/OverviewView.swift
  • PresentationLayer/UIComponents/Screens/LoggedInViews/LoggedInTabViewContainer.swift
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: WeatherXM | Unit tests | Test - iOS
🔇 Additional comments (5)
wxm-ios/Toolkit/Toolkit/Analytics/WXMAnalytics.swift (1)

33-33: Remove debug print statements after testing.

These print statements are marked as temporary and should be removed before merging to production.

Also applies to: 38-39

✅ Verification successful

Remove temporary debug print statements in WXMAnalytics.swift

The following temporary debug prints should be removed:

  • Line 33: print("WXMAnalytics screen: \(screen.rawValue)")
  • Line 38: print("WXMAnalytics event: \(event.rawValue) parameters: \(parameters?.testString ?? "")")

Other print statements in RemoteConfigManager.swift and FirebaseManager.swift are legitimate logging statements and should be retained.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for other debug prints that might need cleanup
rg -l 'print.*TEMP for testing' 

Length of output: 86


Script:

#!/bin/bash
# Check for various debug print patterns
echo "=== Checking for print statements ==="
rg -l "print\(" 'wxm-ios/Toolkit'

echo -e "\n=== Checking for debug comments ==="
rg -l "// *(?i)(DEBUG|TEMP|TEMPORARY|TODO|FIXME)" 'wxm-ios/Toolkit'

Length of output: 507


Script:

#!/bin/bash
echo "=== WXMAnalytics.swift prints ==="
rg "print\(" wxm-ios/Toolkit/Toolkit/Analytics/WXMAnalytics.swift -A 1

echo -e "\n=== RemoteConfigManager.swift prints ==="
rg "print\(" wxm-ios/Toolkit/Toolkit/FirebaseManager/RemoteConfigManager.swift -A 1

echo -e "\n=== FirebaseManager.swift prints ==="
rg "print\(" wxm-ios/Toolkit/Toolkit/FirebaseManager/FirebaseManager.swift -A 1

Length of output: 1405

PresentationLayer/UIComponents/Screens/WeatherStations/StationDetails/StationDetailsContainerView.swift (2)

178-183: LGTM! Robust implementation of screen tracking.

The screen tracking is now properly handled when tabs change, fixing the original issue with force swipes.


196-198: LGTM! Initial screen view tracking.

Good addition to track the initial screen view when the view appears.

PresentationLayer/UIComponents/Screens/WeatherStations/StationDetails/StationDetailsViewModel.swift (2)

143-149: LGTM! Safe implementation of screen tracking.

The method safely handles index bounds and delegates to the analytics service.


175-184: Consider adding a test for the analytics screen mapping.

The mapping between tabs and analytics screens is critical for accurate tracking. Consider adding unit tests to verify this mapping.

✅ Verification successful

The review comment is valid - no tests found for analytics screen mapping

The codebase search confirms there are no existing tests for the StationDetailsViewModel or its analytics screen mapping. Adding tests would help ensure the reliability of analytics tracking.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if tests exist for the Tab enum
rg -l "TestStationDetailsViewModel.*Tab" 

Length of output: 42


Script:

#!/bin/bash
# Search for StationDetailsViewModel tests with various patterns
echo "=== Searching for StationDetailsViewModel tests ==="
rg -l "StationDetailsViewModel.*Test|Test.*StationDetailsViewModel"

echo -e "\n=== Searching for Screen enum usage in tests ==="
rg -l "Screen.*case|enum.*Screen" --type swift "*Test*.swift"

echo -e "\n=== Searching for analytics-related test files ==="
rg -l "analytics|Analytics" "*Test*.swift"

Length of output: 627


Script:

#!/bin/bash
# Find all Swift test files
echo "=== Finding Swift test files ==="
fd -e swift -g "*Test*.swift"

echo -e "\n=== Searching for StationDetailsViewModel in test files ==="
fd -e swift -g "*Test*.swift" -x rg -l "StationDetailsViewModel"

echo -e "\n=== Searching for Screen enum and analytics in test files ==="
fd -e swift -g "*Test*.swift" -x rg -l "Screen|analytics|Analytics"

Length of output: 772

@pantelisss pantelisss merged commit 3b7c19a into main Jan 20, 2025
6 checks passed
@pantelisss pantelisss deleted the feature/fe-1529-analytics-for-device-forecast-details-entry-point branch January 20, 2025 12:57
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