diff --git a/sql/firefox_accounts/fxa_amplitude_export/view.sql b/sql/firefox_accounts/fxa_amplitude_export/view.sql index a7a51fd1fc..9baf4ada87 100644 --- a/sql/firefox_accounts/fxa_amplitude_export/view.sql +++ b/sql/firefox_accounts/fxa_amplitude_export/view.sql @@ -34,7 +34,11 @@ active_events AS ( 'fxa_activity - active' AS event_type, timestamp, TO_JSON_STRING(STRUCT(services, oauth_client_ids)) AS event_properties, - '' AS user_events + region, + country, + `LANGUAGE`, + app_version AS version, + '' AS user_properties FROM active_users ), @@ -46,6 +50,11 @@ user_properties AS ( '$identify' AS event_type, timestamp, '' AS event_properties, + -- Some Amplitude properties are top level + region, + country, + `LANGUAGE`, + app_version AS version, -- We don't want to include user_properties if they are null, so we need -- to list them out explicitly and filter with WHERE CONCAT( @@ -56,18 +65,6 @@ user_properties AS ( CONCAT(TO_JSON_STRING(key), ":", value) FROM ( - SELECT AS STRUCT - "region" AS key, - TO_JSON_STRING(region) AS value, - UNION ALL - SELECT AS STRUCT - "country" AS key, - TO_JSON_STRING(country) AS value, - UNION ALL - SELECT AS STRUCT - "LANGUAGE" AS key, - TO_JSON_STRING(LANGUAGE) AS value, - UNION ALL SELECT AS STRUCT "os_used_day" AS key, TO_JSON_STRING(os_used_day) AS value, @@ -104,21 +101,18 @@ user_properties AS ( "ua_browser" AS key, TO_JSON_STRING(ua_browser) AS value, UNION ALL - SELECT AS STRUCT - "app_version" AS key, - TO_JSON_STRING(app_version) AS value, - UNION ALL SELECT AS STRUCT "$postInsert", TO_JSON_STRING(STRUCT(fxa_services_used)) AS value ) WHERE value != "null" + AND value != "[]" ), "," ), "}" - ) AS used_properties + ) AS user_properties FROM active_users ),