Skip to content

Commit

Permalink
Add FxA custom events to view definition (#4483)
Browse files Browse the repository at this point in the history
* Add FxA custom events to view definition

* Update sql_generators/event_monitoring/templates/event_monitoring_live.init.sql

* Update sql_generators/event_monitoring/templates/event_monitoring_live.init.sql

* Update sql_generators/event_monitoring/templates/event_monitoring_live.init.sql

* Update sql_generators/event_monitoring/templates/event_monitoring_live.init.sql

---------

Co-authored-by: Anna Scholtz <anna@scholtzan.net>
  • Loading branch information
akkomar and scholtzan committed Oct 31, 2023
1 parent 7ed68a8 commit 256460f
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
OPTIONS
(enable_refresh = TRUE, refresh_interval_minutes = 60)
AS
{% if dataset_id != "telemetry" %}
{% if dataset_id not in ["telemetry", "accounts_frontend", "accounts_backend"] %}
SELECT
TIMESTAMP_ADD( TIMESTAMP_TRUNC(TIMESTAMP_ADD(SAFE.PARSE_TIMESTAMP('%FT%H:%M%Ez', ping_info.start_time), INTERVAL event.timestamp MILLISECOND), HOUR),
-- Aggregates event counts over 30-minute intervals
Expand All @@ -25,6 +25,24 @@ FROM
CROSS JOIN
UNNEST(events) AS event,
UNNEST(event.extra) AS event_extra
{% elif dataset_id in ["accounts_frontend", "accounts_backend"] %}
-- FxA uses custom pings to send events without a category and extras.
SELECT
TIMESTAMP_ADD(TIMESTAMP_TRUNC(SAFE.PARSE_TIMESTAMP('%FT%H:%M%Ez', ping_info.start_time), HOUR),
-- Aggregates event counts over 30-minute intervals
INTERVAL(DIV(EXTRACT(MINUTE
FROM
SAFE.PARSE_TIMESTAMP('%FT%H:%M%Ez', ping_info.start_time)), 60) * 60) MINUTE) AS window_start,
TIMESTAMP_ADD(TIMESTAMP_TRUNC(SAFE.PARSE_TIMESTAMP('%FT%H:%M%Ez', ping_info.start_time), HOUR), INTERVAL((DIV(EXTRACT(MINUTE
FROM SAFE.PARSE_TIMESTAMP('%FT%H:%M%Ez', ping_info.start_time)), 60) + 1) * 60) MINUTE) AS window_end,
NULL AS event_category,
metrics.string.event_name,
NULL AS event_extra_key,
normalized_channel,
client_info.app_display_version AS VERSION,
COUNT(*) AS total_events
FROM
`{{ project_id }}.{{ dataset_id }}_live.accounts_events_v1`
{% else %}
TIMESTAMP_ADD( TIMESTAMP_TRUNC(TIMESTAMP_ADD(submission_timestamp, INTERVAL event.f0_ MILLISECOND), HOUR),
-- Aggregates event counts over 30-minute intervals
Expand Down

0 comments on commit 256460f

Please sign in to comment.