-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat(web-analytics): Add web analytics tabs #17981
Conversation
@@ -582,15 +569,28 @@ export interface WebTopClicksQueryResponse extends QueryResponse { | |||
columns?: unknown[] | |||
} | |||
|
|||
export interface WebTopPagesQuery extends WebAnalyticsQueryBase { | |||
kind: NodeKind.WebTopPagesQuery | |||
export enum WebStatsBreakdown { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used an enum here because some properties will take special handling on the query side, so I can't just pass a property name (well I could, but I'd have to handle it with cases in the same way)
posthog/hogql/property.py
Outdated
@@ -129,7 +129,7 @@ def property_to_expr( | |||
return ast.Or(exprs=exprs) | |||
|
|||
chain = ["person", "properties"] if property.type == "person" and scope != "person" else ["properties"] | |||
field = ast.Field(chain=chain + [property.key]) | |||
field = ast.Field(chain=chain + property.key.split(".")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drawing attention to this, theoretically could be breaking as it unescapes any .
.
i.e. a.b
was previously "properties"."a.b"
and now will be "properties"."a"."b"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, sorry, got to block this, as it's a global change in the hogql
folder. We have users who have actual dots in their property name strings, and this will break some filter somewhere for them. The event/feature/property filter is made to work with the current taxonomic filter, which presents just the first layer of properties and has never supported more.
You can use the hogql
template helper like
hogql`SELECT properties.${hogql.identifier('odd property')} FROM events`
if you want to cleanly escape multiple properties into a hogql string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fixed by creating hogql filters on the front end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good for most of the changes, but the one in hogql/property.py
will break the app for some existing users, so we're going to have to find another way.
posthog/hogql/property.py
Outdated
@@ -129,7 +129,7 @@ def property_to_expr( | |||
return ast.Or(exprs=exprs) | |||
|
|||
chain = ["person", "properties"] if property.type == "person" and scope != "person" else ["properties"] | |||
field = ast.Field(chain=chain + [property.key]) | |||
field = ast.Field(chain=chain + property.key.split(".")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, sorry, got to block this, as it's a global change in the hogql
folder. We have users who have actual dots in their property name strings, and this will break some filter somewhere for them. The event/feature/property filter is made to work with the current taxonomic filter, which presents just the first layer of properties and has never supported more.
You can use the hogql
template helper like
hogql`SELECT properties.${hogql.identifier('odd property')} FROM events`
if you want to cleanly escape multiple properties into a hogql string.
206fb13
to
2e3aa89
Compare
2e9cac2
to
30babc3
Compare
30babc3
to
7c89fd6
Compare
I switched the parser over to CPP and moved the navbar icon to the right section |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thought regarding escaping strings, but LGTM.
export const initialWebAnalyticsFilter = [] as WebAnalyticsPropertyFilters | ||
|
||
const setOncePropertyNames = ['$initial_pathname', '$initial_referrer', '$initial_utm_source', '$initial_utm_campaign'] | ||
const hogqlForSetOnceProperty = (key: string, value: string): string => `properties.$set_once.${key} = '${value}'` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will work for a limited subset of keys, but you can use hogql.identifier(key)
(from import { hogql } from './utils'
) to actually safely escape all keys.
* Add web analytics tabs * Add stats table query runner and use it for pathname * Add stats query runner, replacing page and source * Remove classes for now-unused queries * Add remaining breakdowns * Prefer unknown to any * Remove unused ctes * Fix typing issues * Fix python typing * Switch to hogql filters for set_once properties * Use cpp parser * Move web analytics to the right navbar section * Fix typing issues
Problem
Want to be able to breakdown by more properties
Ticks off 4 boxes here https://docs.google.com/document/d/1LsK70o5CTPKHWEeB_8txmJHmOMhNPCc5GnHhw87nLYY/edit
Changes
How did you test this code?
(Behind FF) ran it manually