Skip to content

Bugfix: adjustments to querying time:minutes and time:hours dimensions for goal conversion#6187

Closed
aerosol wants to merge 5 commits intomasterfrom
bug-query-minutes
Closed

Bugfix: adjustments to querying time:minutes and time:hours dimensions for goal conversion#6187
aerosol wants to merge 5 commits intomasterfrom
bug-query-minutes

Conversation

@aerosol
Copy link
Copy Markdown
Member

@aerosol aerosol commented Mar 23, 2026

Changes

Disclaimer: my confidence about this solution is close to zero 😅

https://sentry.plausible.io/organizations/plausible/issues/1101/?environment=prod&project=2&query=is%3Aunresolved%20issue.priority%3A%5Bhigh%2C%20medium%5D&referrer=issue-stream - when querying timeseries with
time:minute` interval and a goal filter, the app would crash with `** (Ecto.QueryError) lib/plausible/stats/sql/special_metrics.ex:114: field `visitors` does not exist in subquery in query.

For time:minute, session visitor counts are split into a separate "smeared" subquery. The conversion rate calculation then tries to read visitors from the events subquery - but visitors is no longer there, because table decider moves it to another query. The fix is to skip that split entirely when group_conversion_rate is in the query.

Tests

  • Automated tests have been added
  • This PR does not require tests

Changelog

  • Entry has been added to changelog
  • This PR does not make a user-facing change

Documentation

  • Docs have been updated
  • This change does not need a documentation update

Dark mode

  • The UI has been tested both in dark and light mode
  • This PR does not change the UI

@github-actions
Copy link
Copy Markdown

Preview environment👷🏼‍♀️🏗️
PR-6187

@aerosol aerosol force-pushed the bug-query-minutes branch from cf6cbde to 541b6dc Compare March 23, 2026 14:16
@aerosol aerosol force-pushed the bug-query-minutes branch from 541b6dc to 9b471c4 Compare March 23, 2026 14:17
defp smear_session_metrics({:sessions, metrics} = value, query) do
if "time:minute" in query.dimensions or "time:hour" in query.dimensions do
if ("time:minute" in query.dimensions or "time:hour" in query.dimensions) and
:group_conversion_rate not in query.metrics and
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Given that bypass_session_smearing? is set to true on adding group_conversion_rate metric, is this condition necessary? 🤔

@aerosol
Copy link
Copy Markdown
Member Author

aerosol commented Mar 24, 2026

To be fleshed out further, I have no idea what I'm doing and @ukutaht is pointing at different direction. Closing

@aerosol aerosol closed this Mar 24, 2026
@aerosol aerosol reopened this Mar 25, 2026
@aerosol aerosol closed this Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants