Skip to content

Commit 30ebbc9

Browse files
kik-kiksoGaussianirrationalagent
authored
feat(DENG-9467): add mobile logic to the terms_of_use_events_v1 template (#8479)
* feat: add mobile logic to the terms_of_use_events_v1 template * feat: separate mobile and desktop logic and rename desktop to terms_of_use_messages_v1 * feat: add terms_of_use_events_v1 templates to fenix and ios configuration * feat: update terms_of_use generator tests * Update sql_generators/terms_of_use/templates/terms_of_use_events_v1/schema.yaml.jinja Co-authored-by: Leif Oines <[email protected]> * Update sql_generators/terms_of_use/templates/terms_of_use_messages_v1/query.sql.jinja Co-authored-by: Leif Oines <[email protected]> * Update sql_generators/terms_of_use/templates/terms_of_use_messages_v1/query.sql.jinja Co-authored-by: Leif Oines <[email protected]> * feat: remove glean client_id and update sample_id description * feat: update terms_of_use expected test results --------- Co-authored-by: richard baffour <[email protected]> Co-authored-by: Leif Oines <[email protected]>
1 parent f71a506 commit 30ebbc9

File tree

19 files changed

+319
-66
lines changed

19 files changed

+319
-66
lines changed

bqetl_project.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,19 +529,21 @@ generate:
529529
fenix:
530530
templates:
531531
- terms_of_use_status_v1
532+
- terms_of_use_events_v1
532533
bigeye:
533534
collection: Operational Checks
534535
notification_channel: '#de-bigeye-triage'
535536
firefox_ios:
536537
templates:
537538
- terms_of_use_status_v1
539+
- terms_of_use_events_v1
538540
bigeye:
539541
collection: Operational Checks
540542
notification_channel: '#de-bigeye-triage'
541543
firefox_desktop:
542544
templates:
543545
- terms_of_use_status_v1
544-
- terms_of_use_events_v1
546+
- terms_of_use_messages_v1
545547
bigeye:
546548
collection: Operational Checks
547549
notification_channel: '#de-bigeye-triage'
Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,40 @@
11
-- {{ header }}
22
SELECT
33
submission_timestamp,
4-
client_info.client_id,
4+
client_id,
55
sample_id,
6-
metrics.uuid.messaging_system_client_id AS legacy_telemetry_client_id,
7-
metrics.text2.messaging_system_message_id,
8-
metrics.string.messaging_system_event,
9-
metrics.string.messaging_system_event_source,
10-
-- the events for the infobar are different than the events for the modal - this should standardize the modal events so they look like the infobar events
6+
event_timestamp,
7+
event_category,
8+
event_name,
119
CASE
12-
-- these are the infobar events or the events for which the infobar and modal are the same - treat them as-is
13-
WHEN metrics.string.messaging_system_event IN ("IMPRESSION", "CLICK_PRIMARY_BUTTON", "DISMISSED", "CLICK_SECONDARY_BUTTON") THEN metrics.string.messaging_system_event
14-
-- for the modal the modal DISMISS == DISMISSED
15-
WHEN metrics.string.messaging_system_event = "DISMISS" THEN "DISMISSED"
16-
WHEN metrics.string.messaging_system_event_source = "primary_button" THEN "CLICK_PRIMARY_BUTTON"
17-
WHEN metrics.string.messaging_system_event_source = "secondary_button" THEN "CLICK_SECONDARY_BUTTON"
18-
-- otherwise, its a privacy notice or other button click
19-
ELSE UPPER(REPLACE(metrics.string.messaging_system_event_source, "-", "_")
20-
) END AS normalized_event,
21-
-- standardize the surface of the message. there are two message_ids for the blue infobar - collapse them.
10+
WHEN (event_category = "onboarding" OR JSON_VALUE(event_extra.surface) = "onboarding") THEN "onboarding"
11+
ELSE
12+
{% if app_name == "firefox_ios" %}
13+
"bottom_sheet"
14+
{% else %}
15+
JSON_VALUE(event_extra.surface)
16+
{% endif %}
17+
END AS surface,
2218
CASE
23-
WHEN metrics.text2.messaging_system_message_id LIKE "%infobar%" THEN "infobar"
24-
WHEN LOWER(metrics.text2.messaging_system_message_id) LIKE "%onboarding%" THEN "onboarding"
25-
ELSE "modal"
26-
END messaging_surface,
19+
{% if app_name == "firefox_ios" %}
20+
WHEN (event_name = "accepted" AND JSON_VALUE(event_extra.surface) = "bottom_sheet") OR (event_name = "terms_of_service_accepted") THEN "accepted"
21+
{% else %}
22+
WHEN (event_name = "accepted") OR (event_name = "terms_of_service_accepted") THEN "accepted"
23+
{% endif %}
24+
WHEN event_name IN ("terms_of_service_card", "shown", "impression") THEN "impressions"
25+
WHEN event_name IN ("terms_of_service_privacy_notice_link_clicked", "privacy_notice_tapped", "privacy_notice_clicked") THEN "privacy_notice_clicked"
26+
WHEN event_name IN ("terms_of_service_link_clicked", "terms_of_use_link_tapped", "terms_of_use_click") THEN "terms_of_use_link_clicked"
27+
{% if app_name == "fenix" %}
28+
WHEN event_name IN ("dismiss") THEN "dismissed"
29+
{% endif %}
30+
ELSE event_name
31+
END AS normalized_event_name
2732
FROM
28-
`{{ project_id }}.{{ app_name }}.messaging_system`
33+
`{{ project_id }}.{{ app_name }}.events_stream`
2934
WHERE
3035
DATE(submission_timestamp) = @submission_date
36+
AND DATE(submission_timestamp) >= "2025-03-01" -- when terms of use started getting rolled out.
3137
AND (
32-
(UPPER(metrics.text2.messaging_system_message_id) LIKE "TOU%")
33-
OR (UPPER(metrics.text2.messaging_system_message_id) LIKE "TOS%")
34-
OR (UPPER(metrics.text2.messaging_system_message_id) LIKE "NEW_USER_TOU%")
38+
event_category = "terms_of_use"
39+
OR (event_category = "onboarding" AND event_name LIKE "%terms_of_%")
3540
)

sql_generators/terms_of_use/templates/terms_of_use_events_v1/schema.yaml.jinja

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,22 @@ fields:
2121
for analysis. It is a pipeline-generated artifact that should match between pings.
2222

2323
- mode: NULLABLE
24-
name: legacy_telemetry_client_id
25-
type: STRING
26-
description: |
27-
Legacy client identifier.
28-
29-
- mode: NULLABLE
30-
name: messaging_system_message_id
31-
type: STRING
32-
description: |
33-
A string identifier of the message in Activity Stream Router.
34-
35-
- mode: NULLABLE
36-
name: messaging_system_event
37-
type: STRING
24+
name: event_timestamp
25+
type: TIMESTAMP
3826
description: |
39-
The type of event. Any user defined string (e.g. “IMPRESSION”, “CLICK_BUTTON”, "INDEXEDDB_OPEN_FAILED", “SESSION_END”).
40-
27+
Timestamp when the event occurred.
4128
- mode: NULLABLE
42-
name: messaging_system_event_source
29+
name: event_category
4330
type: STRING
4431
description: |
45-
The event_context's source. Likely something like "primary_button".
46-
32+
Category of the recorded event.
4733
- mode: NULLABLE
48-
name: normalized_event
34+
name: event_name
4935
type: STRING
5036
description: |
51-
The events for the infobar are different than the events for the modal, this field contains standardized modal events so they look like the infobar events.
52-
37+
Name of the recorded event.
5338
- mode: NULLABLE
54-
name: messaging_surface
39+
name: normalized_event_name
5540
type: STRING
5641
description: |
57-
The surface the terms of use prompt/impression was served.
42+
Normalized name of the event, used to align events from both fenix and iOS as well as collapse across events from different surfaces.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
type: BIGCONFIG_FILE
2+
table_deployments:
3+
- collection:
4+
name: {{ bigeye_collection }}
5+
notification_channels:
6+
- slack: '{{ slack_notification_channel }}'
7+
8+
deployments:
9+
- fq_table_name: {{ project_id }}.{{ project_id }}.{{ app_name }}_derived.{{ table_name }}
10+
table_metrics:
11+
- saved_metric_id: volume
12+
- saved_metric_id: freshness
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# {{ header }}
2+
friendly_name: Terms of Use - Messages
3+
description: |-
4+
This dataset contains messages / events related to Terms of Use.
5+
6+
Clustered by: sample_id
7+
Partitioned by: submission_timestamp by day
8+
9+
owners:
10+
11+
labels:
12+
incremental: true
13+
schedule: daily
14+
table_type: client_level
15+
scheduling:
16+
dag_name: {{ dag_name }}
17+
task_group: {{ app_name }}
18+
bigquery:
19+
time_partitioning:
20+
type: day
21+
field: submission_timestamp
22+
require_partition_filter: false
23+
expiration_days: null
24+
clustering:
25+
fields:
26+
- sample_id
27+
monitoring:
28+
enabled: true
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
-- {{ header }}
2+
SELECT
3+
submission_timestamp,
4+
metrics.uuid.messaging_system_client_id AS legacy_telemetry_client_id,
5+
udf.safe_sample_id(metrics.uuid.messaging_system_client_id) AS sample_id,
6+
metrics.text2.messaging_system_message_id,
7+
metrics.string.messaging_system_event,
8+
metrics.string.messaging_system_event_source,
9+
-- the events for the infobar are different than the events for the modal - this should standardize the modal events so they look like the infobar events
10+
CASE
11+
-- these are the infobar events or the events for which the infobar and modal are the same - treat them as-is
12+
WHEN metrics.string.messaging_system_event IN ("IMPRESSION", "CLICK_PRIMARY_BUTTON", "DISMISSED", "CLICK_SECONDARY_BUTTON") THEN metrics.string.messaging_system_event
13+
-- for the modal the modal DISMISS == DISMISSED
14+
WHEN metrics.string.messaging_system_event = "DISMISS" THEN "DISMISSED"
15+
WHEN metrics.string.messaging_system_event_source = "primary_button" THEN "CLICK_PRIMARY_BUTTON"
16+
WHEN metrics.string.messaging_system_event_source = "secondary_button" THEN "CLICK_SECONDARY_BUTTON"
17+
-- otherwise, its a privacy notice or other button click
18+
ELSE UPPER(REPLACE(metrics.string.messaging_system_event_source, "-", "_")
19+
) END AS normalized_event,
20+
-- standardize the surface of the message.
21+
CASE
22+
WHEN metrics.text2.messaging_system_message_id LIKE "%infobar%" THEN "infobar"
23+
WHEN LOWER(metrics.text2.messaging_system_message_id) LIKE "%onboarding%" THEN "onboarding"
24+
ELSE "modal"
25+
END messaging_surface,
26+
FROM
27+
`{{ project_id }}.{{ app_name }}.messaging_system`
28+
WHERE
29+
DATE(submission_timestamp) = @submission_date
30+
AND (
31+
(UPPER(metrics.text2.messaging_system_message_id) LIKE "TOU%")
32+
OR (UPPER(metrics.text2.messaging_system_message_id) LIKE "TOS%")
33+
OR (UPPER(metrics.text2.messaging_system_message_id) LIKE "NEW_USER_TOU%")
34+
)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# {{ header }}
2+
fields:
3+
- mode: NULLABLE
4+
name: submission_timestamp
5+
type: TIMESTAMP
6+
description: |
7+
Timestamp when the ping is received on the server side. Also used as the logical date
8+
by the ETL process and partitioning.
9+
10+
- mode: NULLABLE
11+
name: legacy_telemetry_client_id
12+
type: STRING
13+
description: |
14+
Legacy client identifier.
15+
16+
- mode: NULLABLE
17+
name: sample_id
18+
type: INTEGER
19+
description: |
20+
A number, 0-99, that samples by client_id and allows filtering data
21+
for analysis. It is a pipeline-generated artifact that should match between pings (based off legacy_telemetry_client_id).
22+
23+
- mode: NULLABLE
24+
name: messaging_system_message_id
25+
type: STRING
26+
description: |
27+
A string identifier of the message in Activity Stream Router.
28+
29+
- mode: NULLABLE
30+
name: messaging_system_event
31+
type: STRING
32+
description: |
33+
The type of event. Any user defined string (e.g. “IMPRESSION”, “CLICK_BUTTON”, "INDEXEDDB_OPEN_FAILED", “SESSION_END”).
34+
35+
- mode: NULLABLE
36+
name: messaging_system_event_source
37+
type: STRING
38+
description: |
39+
The event_context's source. Likely something like "primary_button".
40+
41+
- mode: NULLABLE
42+
name: normalized_event
43+
type: STRING
44+
description: |
45+
The events for the infobar are different than the events for the modal, this field contains standardized modal events so they look like the infobar events.
46+
47+
- mode: NULLABLE
48+
name: messaging_surface
49+
type: STRING
50+
description: |
51+
The surface the terms of use prompt/impression was served.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CREATE OR REPLACE VIEW
2+
`{{ project_id }}.{{ app_name }}.{{ table_name_no_version }}`
3+
AS
4+
SELECT
5+
*
6+
FROM
7+
`{{ project_id }}.{{ app_name }}_derived.{{ table_name }}`
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CREATE OR REPLACE VIEW
2+
`moz-fx-data-shared-prod.fenix.terms_of_use_events`
3+
AS
4+
SELECT
5+
*
6+
FROM
7+
`moz-fx-data-shared-prod.fenix_derived.terms_of_use_events_v1`
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ table_deployments:
66
- slack: '#de-bigeye-triage'
77

88
deployments:
9-
- fq_table_name: moz-fx-data-shared-prod.moz-fx-data-shared-prod.firefox_desktop_derived.terms_of_use_events_v1
9+
- fq_table_name: moz-fx-data-shared-prod.moz-fx-data-shared-prod.fenix_derived.terms_of_use_events_v1
1010
table_metrics:
1111
- saved_metric_id: volume
1212
- saved_metric_id: freshness

0 commit comments

Comments
 (0)