Skip to content

Commit 2d56c14

Browse files
kik-kikalekhyamoz
andauthored
feat(DENG-9250): update firefox app store territory report to include new connector data (#7971)
* feat: update firefox_app_store_territory_source_type_report view to include new connector data * feat: enable monitoring and remove clustering settings * feat: remove bqetl checks and add bugconfig * feat: update app_store_funnel_v1 to use new app store data * fix: invalid view error and comments * fix: use correct field name impressions instead of views * feat: revert firefox_app_store_territory_source_type_report * feat: add comments to the views and remove timezone converversion * feat: limit which source types count toward impressions in the old version of the data to match the new report data * add app_store_funnel to dry run skip list --------- Co-authored-by: Alekhya <[email protected]> Co-authored-by: alekhyamoz <[email protected]>
1 parent 3c9a6b7 commit 2d56c14

File tree

6 files changed

+148
-107
lines changed

6 files changed

+148
-107
lines changed

bqetl_project.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ dry_run:
6060
- sql/moz-fx-data-shared-prod/accounts_db_nonprod_external/**/*.sql
6161
- sql/moz-fx-data-shared-prod/ads/ppa_measurements/*.sql
6262
- sql/moz-fx-data-shared-prod/ads/ppa_measurements_limited/*.sql
63+
- sql/moz-fx-data-shared-prod/firefox_ios_derived/app_store_funnel_v1/query.sql
6364
- sql/moz-fx-data-shared-prod/firefox_accounts_derived/fxa_content_events_v1/query.sql
6465
- sql/moz-fx-data-shared-prod/firefox_accounts_derived/fxa_auth_bounce_events_v1/query.sql
6566
- sql/moz-fx-data-shared-prod/firefox_accounts_derived/fxa_auth_events_v1/query.sql

sql/moz-fx-data-shared-prod/app_store/firefox_app_store_territory_source_type_report/view.sql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ SELECT
55
-- https://developer.apple.com/help/app-store-connect/view-sales-and-trends/download-and-view-reports
66
-- "Time zone: Reports are based on Pacific Time (PT). A day includes transactions that happened from 12:00 a.m. to 11:59 p.m. PT."
77
-- Date conversion in the query is required to unify the dates to UTC timezone which is what we use.
8-
* REPLACE (TIMESTAMP(DATETIME(`date`, "America/Los_Angeles")) AS `date`),
9-
`date` AS date_pst,
8+
-- However, the `date` timestamp field appear to always show midnight meaning if we do timezone conversion
9+
-- we will end up moving all results 1 day back if we attempt conversion to UTC.
10+
-- This is why we are not doing timezone converstions here.
11+
*,
1012
FROM
1113
`moz-fx-data-shared-prod.app_store_syndicate.app_store_territory_source_type_report`
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
type: BIGCONFIG_FILE
2+
tag_deployments:
3+
- collection:
4+
name: Operational Checks
5+
notification_channels:
6+
- slack: '#de-bigeye-triage'
7+
8+
deployments:
9+
- column_selectors:
10+
- name: moz-fx-data-shared-prod.moz-fx-data-shared-prod.firefox_ios_derived.app_store_funnel_v1.session_date
11+
- name: moz-fx-data-shared-prod.moz-fx-data-shared-prod.firefox_ios_derived.app_store_funnel_v1.first_seen_date
12+
- name: moz-fx-data-shared-prod.moz-fx-data-shared-prod.firefox_ios_derived.app_store_funnel_v1.country
13+
metrics:
14+
- saved_metric_id: is_not_null
15+
rct_overrides:
16+
- date
17+
- column_selectors:
18+
- name: moz-fx-data-shared-prod.moz-fx-data-shared-prod.firefox_ios_derived.app_store_funnel_v1.submission_date
19+
- name: moz-fx-data-shared-prod.moz-fx-data-shared-prod.firefox_ios_derived.app_store_funnel_v1.country
20+
metrics:
21+
- saved_metric_id: composite_key_uniqueness_2_column
22+
rct_overrides:
23+
- date
24+
parameters:
25+
- key: col_1
26+
column_name: submission_date
27+
- key: col_1_string
28+
string_value: submission_date
29+
- key: col_2
30+
column_name: country
31+
- key: col_2_string
32+
string_value: country
33+
- key: table
34+
string_value: moz-fx-data-shared-prod.firefox_ios_derived.app_store_funnel_v1
35+
- column_selectors:
36+
- name: moz-fx-data-shared-prod.moz-fx-data-shared-prod.firefox_ios_derived.app_store_funnel_v1.*
37+
metrics:
38+
- saved_metric_id: volume
39+
- saved_metric_id: freshness

sql/moz-fx-data-shared-prod/firefox_ios_derived/app_store_funnel_v1/checks.sql

Lines changed: 0 additions & 66 deletions
This file was deleted.

sql/moz-fx-data-shared-prod/firefox_ios_derived/app_store_funnel_v1/metadata.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,5 @@ bigquery:
1818
type: day
1919
field: submission_date
2020
require_partition_filter: false
21-
clustering:
22-
fields:
23-
- country
21+
monitoring:
22+
enabled: true
Lines changed: 102 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,141 @@
1-
-- TODO: should we run this job with 7 day delay to make sure all data landed (a wider window to be on the safe side).
2-
WITH views_data AS (
1+
-- https://developer.apple.com/help/app-store-connect/view-sales-and-trends/download-and-view-reports
2+
-- "Time zone: Reports are based on Pacific Time (PT). A day includes transactions that happened from 12:00 a.m. to 11:59 p.m. PT.
3+
-- However, the `date` timestamp field appear to always show midnight meaning if we do timezone conversion
4+
-- we will end up moving all results 1 day back if we attempt conversion to UTC.
5+
-- This is why we are not doing timezone converstions here.
6+
WITH historical_store_data AS (
7+
WITH impression_data AS (
8+
SELECT
9+
DATE(`date`) AS `date`,
10+
territory AS country_name,
11+
-- Apple used to count pageviews from these sources as impressions as well but no longer do in the new data they're sending back
12+
-- for compatibility with the new report we only want to count impressions from specific source types?
13+
SUM(
14+
CASE
15+
WHEN source_type IN ('App Referrer', 'Unavailable', 'Web Referrer')
16+
THEN 0
17+
ELSE impressions_unique_device
18+
END
19+
) AS impressions,
20+
FROM
21+
`moz-fx-data-shared-prod.app_store.firefox_app_store_territory_source_type_report`
22+
WHERE
23+
DATE(`date`) = DATE_SUB(@submission_date, INTERVAL 7 DAY)
24+
AND source_type <> 'Institutional Purchase'
25+
AND app_id = 989804926 -- Filter to only include the Firefox app
26+
GROUP BY
27+
`date`,
28+
country_name
29+
),
30+
downloads_data AS (
31+
SELECT
32+
DATE(`date`) AS `date`,
33+
territory AS country_name,
34+
SUM(total_downloads) AS total_downloads,
35+
SUM(first_time_downloads) AS first_time_downloads,
36+
SUM(redownloads) AS redownloads,
37+
FROM
38+
`moz-fx-data-shared-prod.app_store.firefox_downloads_territory_source_type_report`
39+
WHERE
40+
DATE(`date`) = DATE_SUB(@submission_date, INTERVAL 7 DAY)
41+
AND source_type <> 'Institutional Purchase'
42+
AND app_id = 989804926 -- Filter to only include the Firefox app
43+
GROUP BY
44+
ALL
45+
)
346
SELECT
447
DATE(`date`) AS `date`,
5-
territory AS country_name,
6-
SUM(impressions_unique_device) AS views,
48+
country_name,
49+
COALESCE(impressions, 0) AS impressions,
50+
COALESCE(total_downloads, 0) AS total_downloads,
51+
COALESCE(first_time_downloads, 0) AS first_time_downloads,
52+
COALESCE(redownloads, 0) AS redownloads,
753
FROM
8-
`moz-fx-data-shared-prod.app_store.firefox_app_store_territory_source_type_report`
9-
WHERE
10-
DATE(`date`) = DATE_SUB(@submission_date, INTERVAL 7 DAY)
11-
GROUP BY
12-
`date`,
13-
country_name
54+
impression_data
55+
FULL OUTER JOIN
56+
downloads_data
57+
USING (`date`, country_name)
1458
),
15-
downloads_data AS (
59+
app_store_data AS (
1660
SELECT
17-
DATE(`date`) AS `date`,
18-
territory AS country_name,
61+
date_day AS `date`,
62+
territory_long AS country_name,
63+
SUM(impressions_unique_device) AS impressions,
1964
SUM(total_downloads) AS total_downloads,
2065
SUM(first_time_downloads) AS first_time_downloads,
2166
SUM(redownloads) AS redownloads,
2267
FROM
23-
`moz-fx-data-shared-prod.app_store.firefox_downloads_territory_source_type_report`
68+
`moz-fx-data-bq-fivetran.firefox_app_store_v2_apple_store.apple_store__territory_report`
2469
WHERE
25-
DATE(`date`) = DATE_SUB(@submission_date, INTERVAL 7 DAY)
70+
DATE(date_day) = DATE_SUB(@submission_date, INTERVAL 7 DAY)
2671
AND source_type <> 'Institutional Purchase'
72+
AND app_id = 989804926 -- Filter to only include the Firefox app
2773
GROUP BY
74+
ALL
75+
),
76+
combine_app_store_data AS (
77+
SELECT
2878
`date`,
29-
country_name
79+
country_name,
80+
impressions,
81+
total_downloads,
82+
first_time_downloads,
83+
redownloads,
84+
FROM
85+
historical_store_data
86+
WHERE
87+
`date` < "2024-01-01"
88+
UNION ALL
89+
SELECT
90+
`date`,
91+
country_name,
92+
impressions,
93+
total_downloads,
94+
first_time_downloads,
95+
redownloads,
96+
FROM
97+
app_store_data
98+
WHERE
99+
`date` >= "2024-01-01"
30100
),
31-
store_stats AS (
101+
normalize_country AS (
32102
SELECT
33-
DATE(`date`) AS `date`,
103+
`date`,
34104
country_names.code AS country,
35-
views,
105+
impressions,
36106
total_downloads,
37107
first_time_downloads,
38108
redownloads,
39109
FROM
40-
views_data
41-
FULL OUTER JOIN
42-
downloads_data
43-
USING (`date`, country_name)
110+
combine_app_store_data
44111
LEFT JOIN
45112
`moz-fx-data-shared-prod.static.country_names_v1` AS country_names
46-
ON country_names.name = views_data.country_name
113+
ON combine_app_store_data.country_name = country_names.name
47114
),
48115
_new_profiles AS (
49116
SELECT
50117
first_seen_date AS `date`,
51-
first_reported_country AS country,
52-
COUNT(*) AS new_profiles,
118+
country,
119+
SUM(new_profiles) AS new_profiles,
53120
FROM
54-
`moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients`
121+
`moz-fx-data-shared-prod.firefox_ios.new_profiles`
55122
WHERE
56123
first_seen_date = DATE_SUB(@submission_date, INTERVAL 7 DAY)
57-
AND channel = "release"
124+
AND normalized_channel = "release"
58125
GROUP BY
59-
`date`,
60-
country
126+
ALL
61127
)
62128
SELECT
63129
@submission_date AS submission_date,
64130
`date` AS first_seen_date,
65131
country,
66-
COALESCE(views, 0) AS impressions,
67-
COALESCE(total_downloads, 0) AS total_downloads,
68-
COALESCE(first_time_downloads, 0) AS first_time_downloads,
69-
COALESCE(redownloads, 0) AS redownloads,
132+
impressions,
133+
total_downloads,
134+
first_time_downloads,
135+
redownloads,
70136
COALESCE(new_profiles, 0) AS new_profiles,
71137
FROM
72-
store_stats
73-
FULL OUTER JOIN
138+
normalize_country
139+
LEFT JOIN
74140
_new_profiles
75141
USING (`date`, country)

0 commit comments

Comments
 (0)