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

DENG-6880 - Daily aggregations for NewTab #6863

Merged
merged 10 commits into from
Jan 27, 2025
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
friendly_name: Newtab Conditional Daily Aggregates
description: |-
Conditional computations for daily aggregation for newtab.
owners:
- [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE OR REPLACE VIEW
`moz-fx-data-shared-prod.telemetry.newtab_conditional_daily_aggregates`
AS
SELECT
*
FROM
`moz-fx-data-shared-prod.telemetry_derived.newtab_conditional_daily_aggregates_v1`
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
friendly_name: Newtab Interactions Daily Aggregates
description: |-
A daily aggregation of newtab interactions, partitioned by day.
owners:
- [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE OR REPLACE VIEW
`moz-fx-data-shared-prod.telemetry.newtab_daily_interactions_aggregates`
AS
SELECT
*
FROM
`moz-fx-data-shared-prod.telemetry_derived.newtab_daily_interactions_aggregates_v1`
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ SELECT
SUM(pocket_saves) AS pocket_saves,
SUM(sponsored_pocket_saves) AS sponsored_pocket_saves,
SUM(organic_pocket_saves) AS organic_pocket_saves,
SUM(pocket_thumb_voting_events) AS pocket_thumb_voting_events,
SUM(topic_selection_opened) AS topic_selection_opened,
SUM(topic_selection_updates) AS topic_selection_updates,
SUM(weather_widget_clicks) AS weather_widget_clicks,
SUM(weather_widget_change_display_to_detailed) AS weather_widget_change_display_to_detailed,
SUM(weather_widget_change_display_to_simple) AS weather_widget_change_display_to_simple,
SUM(wallpaper_clicks) AS wallpaper_clicks,
SUM(
IF(topic_selection_selected_topics_first_time, 1, 0)
) AS topic_selection_selected_topics_first_time_count,
SUM(sponsored_pocket_dismissals) AS sponsored_pocket_dismissals,
SUM(organic_pocket_dismissals) AS organic_pocket_dismissals,
SUM(topic_selection_dismissals) AS topic_selection_dismissals,
SUM(visits_with_default_ui) AS visits_with_default_ui,
FROM
`moz-fx-data-shared-prod.telemetry_derived.newtab_clients_daily_v1`
WHERE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,39 @@ fields:
- name: organic_pocket_saves
type: INTEGER
mode: NULLABLE
- name: pocket_thumb_voting_events
type: INTEGER
mode: NULLABLE
- name: topic_selection_opened
type: INTEGER
mode: NULLABLE
- name: topic_selection_updates
type: INTEGER
mode: NULLABLE
- name: weather_widget_clicks
type: INTEGER
mode: NULLABLE
- name: weather_widget_change_display_to_detailed
type: INTEGER
mode: NULLABLE
- name: weather_widget_change_display_to_simple
type: INTEGER
mode: NULLABLE
- name: wallpaper_clicks
type: INTEGER
mode: NULLABLE
- name: topic_selection_selected_topics_first_time_count
type: INTEGER
mode: NULLABLE
- name: sponsored_pocket_dismissals
type: INTEGER
mode: NULLABLE
- name: organic_pocket_dismissals
type: INTEGER
mode: NULLABLE
- name: topic_selection_dismissals
type: INTEGER
mode: NULLABLE
- name: visits_with_default_ui
type: INTEGER
mode: NULLABLE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
friendly_name: Newtab Conditional Daily Aggregates
description: |-
Conditional computations for daily aggregation for newtab.
owners:
- [email protected]
labels:
application: firefox
incremental: true
schedule: daily
dag: bqetl_newtab
owner1: gkatre
scheduling:
dag_name: bqetl_newtab
bigquery:
time_partitioning:
type: day
field: submission_date
require_partition_filter: true
expiration_days: null
clustering:
fields:
- country_code
references: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
SELECT
submission_date,
country_code,
pocket_enabled,
pocket_sponsored_stories_enabled,
topsites_enabled,
COUNT(DISTINCT client_id) AS total_client_count,
COUNT(DISTINCT newtab_visit_id) AS total_visit_count,
-- conditional
COUNT(DISTINCT IF(channel = 'release', client_id, NULL)) AS client_count,
COUNT(DISTINCT IF(channel = 'release', newtab_visit_id, NULL)) AS visit_count,
COUNT(
DISTINCT IF(
channel = 'release'
AND newtab_open_source = 'about:home'
AND newtab_homepage_category = 'enabled',
client_id,
NULL
)
) AS home_default_client_count,
COUNT(
DISTINCT IF(
channel = 'release'
AND newtab_open_source = 'about:home'
AND newtab_homepage_category = 'enabled',
newtab_visit_id,
NULL
)
) AS home_default_visit_count,
COUNT(
DISTINCT IF(
channel = 'release'
AND newtab_open_source = 'about:newtab'
AND newtab_newtab_category = 'enabled',
client_id,
NULL
)
) AS newtab_default_client_count,
COUNT(
DISTINCT IF(
channel = 'release'
AND newtab_open_source = 'about:newtab'
AND newtab_newtab_category = 'enabled',
newtab_visit_id,
NULL
)
) AS newtab_default_visit_count,
COUNT(
DISTINCT IF(
channel = 'release'
AND newtab_open_source = 'about:home'
AND newtab_homepage_category != 'enabled',
client_id,
NULL
)
) AS home_nondefault_client_count,
COUNT(
DISTINCT IF(
channel = 'release'
AND newtab_open_source = 'about:home'
AND newtab_homepage_category != 'enabled',
newtab_visit_id,
NULL
)
) AS home_nondefault_visit_count,
COUNT(
DISTINCT IF(
channel = 'release'
AND newtab_open_source = 'about:newtab'
AND newtab_newtab_category != 'enabled',
client_id,
NULL
)
) AS newtab_nondefault_client_count,
COUNT(
DISTINCT IF(
channel = 'release'
AND newtab_open_source = 'about:newtab'
AND newtab_newtab_category != 'enabled',
newtab_visit_id,
NULL
)
) AS newtab_nondefault_visit_count,
COUNT(
DISTINCT IF(channel = 'release' AND newtab_open_source = 'about:welcome', client_id, NULL)
) AS welcome_client_count,
COUNT(
DISTINCT IF(channel = 'release' AND newtab_open_source = 'about:welcome', newtab_visit_id, NULL)
) AS welcome_visit_count,
COUNT(
DISTINCT IF(channel = 'release' AND searches > 0, client_id, NULL)
) AS searched_client_count,
COUNT(
DISTINCT IF(channel = 'release' AND searches > 0, newtab_visit_id, NULL)
) AS searched_visit_count,
COUNT(
DISTINCT IF(channel = 'release' AND sponsored_topsite_impressions > 0, client_id, NULL)
) AS sponsored_topsite_impressed_client_count,
COUNT(
DISTINCT IF(channel = 'release' AND sponsored_topsite_impressions > 0, newtab_visit_id, NULL)
) AS sponsored_topsite_impressed_visit_count,
COUNT(
DISTINCT IF(channel = 'release' AND sponsored_topsite_clicks > 0, client_id, NULL)
) AS sponsored_topsite_clicked_client_count,
COUNT(
DISTINCT IF(channel = 'release' AND sponsored_topsite_clicks > 0, newtab_visit_id, NULL)
) AS sponsored_topsite_clicked_visit_count,
COUNT(
DISTINCT IF(channel = 'release' AND topsite_impressions > 0, client_id, NULL)
) AS topsite_impressed_client_count,
COUNT(
DISTINCT IF(channel = 'release' AND topsite_impressions > 0, newtab_visit_id, NULL)
) AS topsite_impressed_visit_count,
COUNT(
DISTINCT IF(channel = 'release' AND topsite_clicks > 0, client_id, NULL)
) AS topsite_clicked_client_count,
COUNT(
DISTINCT IF(channel = 'release' AND topsite_clicks > 0, newtab_visit_id, NULL)
) AS topsite_clicked_visit_count,
COUNT(
DISTINCT IF(channel = 'release' AND sponsored_pocket_impressions > 0, client_id, NULL)
) AS sponsored_pocket_impressed_client_count,
COUNT(
DISTINCT IF(channel = 'release' AND sponsored_pocket_impressions > 0, newtab_visit_id, NULL)
) AS sponsored_pocket_impressed_visit_count,
COUNT(
DISTINCT IF(channel = 'release' AND sponsored_pocket_clicks > 0, client_id, NULL)
) AS sponsored_pocket_clicked_client_count,
COUNT(
DISTINCT IF(channel = 'release' AND sponsored_pocket_clicks > 0, newtab_visit_id, NULL)
) AS sponsored_pocket_clicked_visit_count,
COUNT(
DISTINCT IF(channel = 'release' AND organic_pocket_impressions > 0, client_id, NULL)
) AS organic_pocket_impressed_client_count,
COUNT(
DISTINCT IF(channel = 'release' AND organic_pocket_impressions > 0, newtab_visit_id, NULL)
) AS organic_pocket_impressed_visit_count,
COUNT(
DISTINCT IF(channel = 'release' AND organic_pocket_clicks > 0, client_id, NULL)
) AS organic_pocket_clicked_client_count,
COUNT(
DISTINCT IF(channel = 'release' AND organic_pocket_clicks > 0, newtab_visit_id, NULL)
) AS organic_pocket_clicked_visit_count,
COUNT(
DISTINCT IF(channel = 'release' AND pocket_impressions > 0, client_id, NULL)
) AS pocket_impressed_client_count,
COUNT(
DISTINCT IF(channel = 'release' AND pocket_impressions > 0, newtab_visit_id, NULL)
) AS pocket_impressed_visit_count,
COUNT(
DISTINCT IF(channel = 'release' AND pocket_clicks > 0, client_id, NULL)
) AS pocket_clicked_client_count,
COUNT(
DISTINCT IF(channel = 'release' AND pocket_clicks > 0, newtab_visit_id, NULL)
) AS pocket_clicked_visit_count,
COUNT(
DISTINCT IF(channel = 'release' AND pocket_is_signed_in, client_id, NULL)
) AS pocket_signed_in_client_count,
COUNT(
DISTINCT IF(channel = 'release' AND pocket_is_signed_in, newtab_visit_id, NULL)
) AS pocket_signed_in_visit_count,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need one for counting just homepage category enabled/disabled independent of source?
Maybe I missed it but I couldn't find.

For this widget: https://mozilla.cloud.looker.com/explore/firefox_desktop/newtab_interactions?qid=qOIDEWK6Oo10MxPDZcg7rn&origin_space=464&toggle=vis

Copy link
Contributor

Choose a reason for hiding this comment

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

Also for this widget with newtab_category: https://mozilla.cloud.looker.com/explore/firefox_desktop/newtab_interactions?qid=L3HcgEzCJWLQBVDaYeVVbg&origin_space=464&toggle=vis

I think due to the count distinct we can't just SUM home vs newtab in the end.

Copy link
Contributor Author

@gkatre gkatre Jan 24, 2025

Choose a reason for hiding this comment

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

I have it here:

Would this work? Or perhaps I could add newtab_homepage_category and/or newtab_newtab_category to the granularity (GROUP BY) if you feel its ok (that is: we will not end up double counting clients and visits)

Copy link
Contributor

Choose a reason for hiding this comment

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

My point was that all aggregations of that field have either newtab_open_source = 'about:home' or newtab_open_source = 'about:newtab' but the query on the explore doesn't include anything about newtab_open_source and I'm not sure how that affects the numbers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. Just to be safe, instead of adding newtab_homepage_category and newtab_newtab_category as a dimension in the GROUP BY, I will add a set of 2 distinct count metrics:

  • one set for newtab_homepage_category enabled
  • one set for newtab_newtab_category enabled

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bani added the aggregates for newtab_homepage_category enabled and newtab_newtab_category enabled

FROM
`moz-fx-data-shared-prod.telemetry_derived.newtab_interactions_v1`
WHERE
submission_date = @submission_date
GROUP BY
submission_date,
country_code,
pocket_enabled,
pocket_sponsored_stories_enabled,
topsites_enabled
Loading