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

Added top_os.pipe to tinybird and bumped all pipes to version 1 #22290

Merged
merged 3 commits into from
Feb 26, 2025

Conversation

cmraible
Copy link
Collaborator

ref https://linear.app/ghost/issue/ANAL-128/experiment-update-the-implementation-to-also-store-os-for-each-event

  • This commit is an experiment to learn more about how change control works with Tinybird.
  • It bumps the version of all existing pipes from version 0 to version 1
  • It adds a new top_os.json pipe to aggregate pageviews by operating system, and updates all other relevant pipes so they can be filtered/grouped by operating system
  • The actual implementation of parsing the operating system from the user-agent is super naive and doesn't really matter for this experiment, since we're mainly trying to learn how change management works.
  • These changes have already been deployed manually to TB, so this commit doesn't really do anything (yet), apart from keeping our source datafiles in sync with Tinybird.

Copy link
Contributor

coderabbitai bot commented Feb 26, 2025

Walkthrough

The update applies changes across several analytics pipeline files in the ghost/tinybird-dedicated repository. In each modified pipe, a new SQL case statement has been introduced to derive the operating system (os) from the user agent string, categorizing it as 'windows', 'mac', 'ios', 'android', or 'Unknown'. This new field is added to the SELECT and GROUP BY clauses or used in aggregation tokens. Additionally, conditional SQL clauses checking for a defined os have been implemented to enable filtering based on the operating system. Version numbers in multiple files have been incremented from 0 to 1 to reflect these changes. Furthermore, a new pipeline file, top_os.pipe, has been created to aggregate and display operating system statistics, incorporating parameters for date range and pagination.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 70897d9 and b657842.

📒 Files selected for processing (1)
  • ghost/tinybird-dedicated/pipes/top_os.pipe (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • ghost/tinybird-dedicated/pipes/top_os.pipe
⏰ Context from checks skipped due to timeout of 90000ms (12)
  • GitHub Check: Ghost-CLI tests
  • GitHub Check: Unit tests (Node 22.13.1)
  • GitHub Check: Unit tests (Node 20.11.1)
  • GitHub Check: Regression tests (Node 20.11.1, sqlite3)
  • GitHub Check: Unit tests (Node 18.12.1)
  • GitHub Check: Database tests (Node 20.11.1, sqlite3)
  • GitHub Check: Regression tests (Node 20.11.1, mysql8)
  • GitHub Check: Database tests (Node 22.13.1, mysql8)
  • GitHub Check: Database tests (Node 20.11.1, mysql8)
  • GitHub Check: i18n
  • GitHub Check: Database tests (Node 18.12.1, mysql8)
  • GitHub Check: Lint

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

Copy link
Contributor

@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

🔭 Outside diff range comments (1)
ghost/tinybird-dedicated/pipes/kpis.pipe (1)

166-166: ⚠️ Potential issue

Missing OS field in GROUP BY clause for single-day case.

The GROUP BY clause for the single-day case doesn't include the os field, while it's been added to the SELECT clause. This inconsistency could lead to aggregation issues since the output includes os but doesn't group by it.

- group by toStartOfHour(timestamp), session_id, site_uuid, member_status, device, browser, location, source, pathname
+ group by toStartOfHour(timestamp), session_id, site_uuid, member_status, device, browser, os, location, source, pathname
🧹 Nitpick comments (1)
ghost/tinybird-dedicated/pipes/top_os.pipe (1)

1-45: New pipe implementation looks good, with two minor issues

The new top_os.pipe follows the same structure and conventions as other similar pipes, which is excellent for consistency. The SQL query correctly groups by OS and calculates visits and pageviews.

There are two minor issues to address:

  1. Line 28: The default date filter is set to 1 year (interval -1 year), which differs from the 7-day default mentioned in the description and used in other pipes.

  2. Line 38: The description for the OS filter incorrectly says "Browser to filter on" instead of "Operating System to filter on".

-                and date >= timestampAdd(today(), interval -1 year)
+                and date >= timestampAdd(today(), interval -7 day)
-            {% if defined(os) %} and os = {{ String(os, description="Browser to filter on", required=False) }} {% end %}
+            {% if defined(os) %} and os = {{ String(os, description="Operating System to filter on", required=False) }} {% end %}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a8fa52f and 70897d9.

📒 Files selected for processing (10)
  • ghost/tinybird-dedicated/pipes/analytics_pages.pipe (4 hunks)
  • ghost/tinybird-dedicated/pipes/analytics_sessions.pipe (3 hunks)
  • ghost/tinybird-dedicated/pipes/analytics_sources.pipe (4 hunks)
  • ghost/tinybird-dedicated/pipes/kpis.pipe (6 hunks)
  • ghost/tinybird-dedicated/pipes/top_browsers.pipe (2 hunks)
  • ghost/tinybird-dedicated/pipes/top_devices.pipe (2 hunks)
  • ghost/tinybird-dedicated/pipes/top_locations.pipe (1 hunks)
  • ghost/tinybird-dedicated/pipes/top_os.pipe (1 hunks)
  • ghost/tinybird-dedicated/pipes/top_pages.pipe (2 hunks)
  • ghost/tinybird-dedicated/pipes/top_sources.pipe (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • ghost/tinybird-dedicated/pipes/top_locations.pipe
⏰ Context from checks skipped due to timeout of 90000ms (12)
  • GitHub Check: Database tests (Node 20.11.1, sqlite3)
  • GitHub Check: Regression tests (Node 20.11.1, sqlite3)
  • GitHub Check: Database tests (Node 22.13.1, mysql8)
  • GitHub Check: Regression tests (Node 20.11.1, mysql8)
  • GitHub Check: Database tests (Node 20.11.1, mysql8)
  • GitHub Check: Database tests (Node 18.12.1, mysql8)
  • GitHub Check: Ghost-CLI tests
  • GitHub Check: Unit tests (Node 22.13.1)
  • GitHub Check: Unit tests (Node 20.11.1)
  • GitHub Check: Lint
  • GitHub Check: Unit tests (Node 18.12.1)
  • GitHub Check: i18n
🔇 Additional comments (23)
ghost/tinybird-dedicated/pipes/top_browsers.pipe (2)

1-1: Version increment is consistent with PR objectives

The version has been properly incremented from 0 to 1 as stated in the PR description.


38-38: OS filter implementation follows existing pattern

The new OS filter follows the same conditional pattern used for other filters in this file. The parameter is correctly defined with an appropriate description and marked as optional.

ghost/tinybird-dedicated/pipes/analytics_sources.pipe (3)

1-1: Version increment is consistent with PR objectives

The version has been properly incremented from 0 to 1 as stated in the PR description.


63-73: OS detection implementation is appropriate

The case statement for OS detection follows the same pattern as the existing device and browser detection. The implementation is intentionally simplistic as mentioned in the PR objectives, since the focus is on change management processes rather than robust OS detection.


94-94: OS field correctly added to both SELECT and GROUP BY clauses

The OS field has been properly added to both the SELECT clause and GROUP BY clause, which is necessary for correct aggregation in the analytics pipeline.

Also applies to: 103-103

ghost/tinybird-dedicated/pipes/top_sources.pipe (2)

1-1: Version increment is consistent with PR objectives

The version has been properly incremented from 0 to 1 as stated in the PR description.


38-38: OS filter implementation follows existing pattern

The new OS filter follows the same conditional pattern used for other filters in this file. The parameter is correctly defined with an appropriate description and marked as optional.

ghost/tinybird-dedicated/pipes/top_pages.pipe (2)

1-1: Version increment is consistent with PR objectives

The version has been properly incremented from 0 to 1 as stated in the PR description.


42-42: OS filter implementation follows existing pattern

The new OS filter follows the same conditional pattern used for other filters in this file. The parameter is correctly defined with an appropriate description and marked as optional.

ghost/tinybird-dedicated/pipes/analytics_sessions.pipe (3)

1-1: Version incrementing looks good

The version has been properly updated from 0 to 1 to reflect the changes made to the pipe.


67-78: OS detection implementation looks appropriate

The implementation for parsing operating systems from user agent strings is straightforward and follows the same pattern as the existing browser detection logic. As mentioned in the PR objectives, this implementation is intentionally simplistic as the main goal is to understand change control in Tinybird.


100-100: OS aggregation added correctly

The OS field has been properly added to the analytics_sessions_1 node using the same anySimpleState pattern as other fields.

ghost/tinybird-dedicated/pipes/analytics_pages.pipe (3)

1-1: Version incrementing looks good

The version has been properly updated from 0 to 1 to reflect the changes made to the pipe.


63-74: OS detection implementation is consistent

The OS detection logic is consistent with the implementation in analytics_sessions.pipe, applying the same pattern matching approach for identifying operating systems from user agent strings.


88-88: OS field properly added to SELECT and GROUP BY clauses

The OS field has been correctly added to both the SELECT statement and GROUP BY clause, enabling proper aggregation and filtering by operating system.

Also applies to: 99-99

ghost/tinybird-dedicated/pipes/top_devices.pipe (2)

1-1: Version incrementing looks good

The version has been properly updated from 0 to 1 to reflect the changes made to the pipe.


39-39: OS filter condition added correctly

The conditional clause for filtering by operating system follows the same pattern as the existing filters and is properly implemented.

ghost/tinybird-dedicated/pipes/kpis.pipe (6)

1-1: Version increment appropriately reflects the added functionality.

The version number has been bumped from 0 to 1, which aligns with the PR objective of updating all pipes to version 1 for the OS filtering experiment.


128-138: OS detection implementation is straightforward and consistent with existing patterns.

The case statement for OS detection follows the same pattern as the browser detection above it. While the implementation is intentionally simplistic (as noted in the PR objectives), it provides the necessary functionality for this experiment.


155-155: OS field correctly added to SELECT clause for single-day case.

The addition of the os field to the SELECT clause for the single-day case ensures the OS information is included in the results.


174-174: OS field correctly added to SELECT clause for multi-day case.

The addition of the os field to the SELECT clause for the multi-day case ensures the OS information is included in the results.


192-192: OS field correctly added to GROUP BY clause for multi-day case.

The GROUP BY clause for the multi-day case now includes the os field, which is necessary for proper aggregation.


214-214: OS filtering capability correctly implemented.

The conditional filter for the os variable follows the same pattern as other filters in the file. This enables filtering analytics data by operating system, which is one of the main objectives of this PR.

@cmraible cmraible merged commit b0cb64b into TryGhost:main Feb 26, 2025
24 checks passed
@cmraible cmraible deleted the add-os-to-tinybird branch February 26, 2025 22:28
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.

1 participant