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

Create iOS_onboarding.toml #6329

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rhythmofrain63
Copy link
Contributor

@rhythmofrain63 rhythmofrain63 commented Oct 10, 2024

Description

Related Tickets & Documents

  • DENG-XXXX
  • DSRE-XXXX

Reviewer, please follow this checklist

┆Issue is synchronized with this Jira Task

@dataops-ci-bot
Copy link

Integration report for "Create iOS_onboarding.toml"

sql.diff

Click to expand!
diff -bur --no-dereference --new-file /tmp/workspace/main-generated-sql/dags/bqetl_firefox_ios.py /tmp/workspace/generated-sql/dags/bqetl_firefox_ios.py
--- /tmp/workspace/main-generated-sql/dags/bqetl_firefox_ios.py	2024-10-10 18:28:59.000000000 +0000
+++ /tmp/workspace/generated-sql/dags/bqetl_firefox_ios.py	2024-10-10 18:41:54.000000000 +0000
@@ -258,6 +258,13 @@
         )
 
         ExternalTaskMarker(
+            task_id="bqetl_generated_funnels__wait_for_checks__fail_firefox_ios_derived__clients_activation__v1",
+            external_dag_id="bqetl_generated_funnels",
+            external_task_id="wait_for_checks__fail_firefox_ios_derived__clients_activation__v1",
+            execution_date="{{ (execution_date - macros.timedelta(days=-1, seconds=82800)).isoformat() }}",
+        )
+
+        ExternalTaskMarker(
             task_id="bqetl_org_mozilla_firefox_derived__wait_for_checks__fail_firefox_ios_derived__clients_activation__v1",
             external_dag_id="bqetl_org_mozilla_firefox_derived",
             external_task_id="wait_for_checks__fail_firefox_ios_derived__clients_activation__v1",
@@ -307,6 +314,13 @@
         )
 
         ExternalTaskMarker(
+            task_id="bqetl_generated_funnels__wait_for_checks__fail_firefox_ios_derived__firefox_ios_clients__v1",
+            external_dag_id="bqetl_generated_funnels",
+            external_task_id="wait_for_checks__fail_firefox_ios_derived__firefox_ios_clients__v1",
+            execution_date="{{ (execution_date - macros.timedelta(days=-1, seconds=82800)).isoformat() }}",
+        )
+
+        ExternalTaskMarker(
             task_id="bqetl_org_mozilla_firefox_derived__wait_for_checks__fail_firefox_ios_derived__firefox_ios_clients__v1",
             external_dag_id="bqetl_org_mozilla_firefox_derived",
             external_task_id="wait_for_checks__fail_firefox_ios_derived__firefox_ios_clients__v1",
@@ -522,6 +536,20 @@
         depends_on_past=False,
     )
 
+    with TaskGroup(
+        "firefox_ios_derived__funnel_retention_clients_week_2__v1_external",
+    ) as firefox_ios_derived__funnel_retention_clients_week_2__v1_external:
+        ExternalTaskMarker(
+            task_id="bqetl_generated_funnels__wait_for_firefox_ios_derived__funnel_retention_clients_week_2__v1",
+            external_dag_id="bqetl_generated_funnels",
+            external_task_id="wait_for_firefox_ios_derived__funnel_retention_clients_week_2__v1",
+            execution_date="{{ (execution_date - macros.timedelta(days=-1, seconds=82800)).isoformat() }}",
+        )
+
+        firefox_ios_derived__funnel_retention_clients_week_2__v1_external.set_upstream(
+            firefox_ios_derived__funnel_retention_clients_week_2__v1
+        )
+
     firefox_ios_derived__funnel_retention_clients_week_4__v1 = bigquery_etl_query(
         task_id="firefox_ios_derived__funnel_retention_clients_week_4__v1",
         destination_table="funnel_retention_clients_week_4_v1",
@@ -533,6 +561,20 @@
         depends_on_past=False,
     )
 
+    with TaskGroup(
+        "firefox_ios_derived__funnel_retention_clients_week_4__v1_external",
+    ) as firefox_ios_derived__funnel_retention_clients_week_4__v1_external:
+        ExternalTaskMarker(
+            task_id="bqetl_generated_funnels__wait_for_firefox_ios_derived__funnel_retention_clients_week_4__v1",
+            external_dag_id="bqetl_generated_funnels",
+            external_task_id="wait_for_firefox_ios_derived__funnel_retention_clients_week_4__v1",
+            execution_date="{{ (execution_date - macros.timedelta(days=-1, seconds=82800)).isoformat() }}",
+        )
+
+        firefox_ios_derived__funnel_retention_clients_week_4__v1_external.set_upstream(
+            firefox_ios_derived__funnel_retention_clients_week_4__v1
+        )
+
     firefox_ios_derived__funnel_retention_week_4__v1 = bigquery_etl_query(
         task_id="firefox_ios_derived__funnel_retention_week_4__v1",
         destination_table="funnel_retention_week_4_v1",
diff -bur --no-dereference --new-file /tmp/workspace/main-generated-sql/dags/bqetl_generated_funnels.py /tmp/workspace/generated-sql/dags/bqetl_generated_funnels.py
--- /tmp/workspace/main-generated-sql/dags/bqetl_generated_funnels.py	2024-10-10 18:28:59.000000000 +0000
+++ /tmp/workspace/generated-sql/dags/bqetl_generated_funnels.py	2024-10-10 18:41:56.000000000 +0000
@@ -150,6 +150,60 @@
         pool="DATA_ENG_EXTERNALTASKSENSOR",
     )
 
+    wait_for_checks__fail_firefox_ios_derived__clients_activation__v1 = (
+        ExternalTaskSensor(
+            task_id="wait_for_checks__fail_firefox_ios_derived__clients_activation__v1",
+            external_dag_id="bqetl_firefox_ios",
+            external_task_id="checks__fail_firefox_ios_derived__clients_activation__v1",
+            execution_delta=datetime.timedelta(seconds=3600),
+            check_existence=True,
+            mode="reschedule",
+            allowed_states=ALLOWED_STATES,
+            failed_states=FAILED_STATES,
+            pool="DATA_ENG_EXTERNALTASKSENSOR",
+        )
+    )
+
+    wait_for_checks__fail_firefox_ios_derived__firefox_ios_clients__v1 = ExternalTaskSensor(
+        task_id="wait_for_checks__fail_firefox_ios_derived__firefox_ios_clients__v1",
+        external_dag_id="bqetl_firefox_ios",
+        external_task_id="checks__fail_firefox_ios_derived__firefox_ios_clients__v1",
+        execution_delta=datetime.timedelta(seconds=3600),
+        check_existence=True,
+        mode="reschedule",
+        allowed_states=ALLOWED_STATES,
+        failed_states=FAILED_STATES,
+        pool="DATA_ENG_EXTERNALTASKSENSOR",
+    )
+
+    wait_for_firefox_ios_derived__funnel_retention_clients_week_2__v1 = (
+        ExternalTaskSensor(
+            task_id="wait_for_firefox_ios_derived__funnel_retention_clients_week_2__v1",
+            external_dag_id="bqetl_firefox_ios",
+            external_task_id="firefox_ios_derived__funnel_retention_clients_week_2__v1",
+            execution_delta=datetime.timedelta(seconds=3600),
+            check_existence=True,
+            mode="reschedule",
+            allowed_states=ALLOWED_STATES,
+            failed_states=FAILED_STATES,
+            pool="DATA_ENG_EXTERNALTASKSENSOR",
+        )
+    )
+
+    wait_for_firefox_ios_derived__funnel_retention_clients_week_4__v1 = (
+        ExternalTaskSensor(
+            task_id="wait_for_firefox_ios_derived__funnel_retention_clients_week_4__v1",
+            external_dag_id="bqetl_firefox_ios",
+            external_task_id="firefox_ios_derived__funnel_retention_clients_week_4__v1",
+            execution_delta=datetime.timedelta(seconds=3600),
+            check_existence=True,
+            mode="reschedule",
+            allowed_states=ALLOWED_STATES,
+            failed_states=FAILED_STATES,
+            pool="DATA_ENG_EXTERNALTASKSENSOR",
+        )
+    )
+
     accounts_frontend_derived__account_pref_delete_funnel__v1 = bigquery_etl_query(
         task_id="accounts_frontend_derived__account_pref_delete_funnel__v1",
         destination_table="account_pref_delete_funnel_v1",
@@ -334,6 +388,21 @@
         )
     )
 
+    firefox_ios_derived__iOS_onboarding__v1 = bigquery_etl_query(
+        task_id="firefox_ios_derived__iOS_onboarding__v1",
+        destination_table="iOS_onboarding_v1",
+        dataset_id="firefox_ios_derived",
+        project_id="moz-fx-data-shared-prod",
+        owner="[email protected]",
+        email=[
+            "[email protected]",
+            "[email protected]",
+            "[email protected]",
+        ],
+        date_partition_parameter="submission_date",
+        depends_on_past=False,
+    )
+
     monitor_frontend_derived__monitor_dashboard_user_journey_funnels__v1 = bigquery_etl_query(
         task_id="monitor_frontend_derived__monitor_dashboard_user_journey_funnels__v1",
         destination_table="monitor_dashboard_user_journey_funnels_v1",
@@ -435,6 +504,24 @@
         wait_for_firefox_accounts_derived__fxa_stdout_events__v1
     )
 
+    firefox_ios_derived__iOS_onboarding__v1.set_upstream(
+        wait_for_checks__fail_firefox_ios_derived__clients_activation__v1
+    )
+
+    firefox_ios_derived__iOS_onboarding__v1.set_upstream(
+        wait_for_checks__fail_firefox_ios_derived__firefox_ios_clients__v1
+    )
+
+    firefox_ios_derived__iOS_onboarding__v1.set_upstream(wait_for_copy_deduplicate_all)
+
+    firefox_ios_derived__iOS_onboarding__v1.set_upstream(
+        wait_for_firefox_ios_derived__funnel_retention_clients_week_2__v1
+    )
+
+    firefox_ios_derived__iOS_onboarding__v1.set_upstream(
+        wait_for_firefox_ios_derived__funnel_retention_clients_week_4__v1
+    )
+
     monitor_frontend_derived__monitor_dashboard_user_journey_funnels__v1.set_upstream(
         wait_for_copy_deduplicate_all
     )
Only in /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/firefox_ios_derived: iOS_onboarding_v1
diff -bur --no-dereference --new-file /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/contextual_services/event_aggregates/schema.yaml /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/contextual_services/event_aggregates/schema.yaml
--- /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/contextual_services/event_aggregates/schema.yaml	2024-10-10 18:23:50.000000000 +0000
+++ /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/contextual_services/event_aggregates/schema.yaml	2024-10-10 18:32:13.000000000 +0000
@@ -1,49 +1,49 @@
 fields:
-- mode: NULLABLE
-  name: submission_date
+- name: submission_date
   type: DATE
-- mode: NULLABLE
-  name: source
+  mode: NULLABLE
+- name: source
   type: STRING
-- mode: NULLABLE
-  name: event_type
+  mode: NULLABLE
+- name: event_type
   type: STRING
-- mode: NULLABLE
-  name: form_factor
+  mode: NULLABLE
+- name: form_factor
   type: STRING
-- mode: NULLABLE
-  name: country
+  mode: NULLABLE
+- name: country
   type: STRING
-- mode: NULLABLE
-  name: subdivision1
+  mode: NULLABLE
+- name: subdivision1
   type: STRING
-- mode: NULLABLE
-  name: advertiser
+  mode: NULLABLE
+- name: advertiser
   type: STRING
-- mode: NULLABLE
-  name: release_channel
+  mode: NULLABLE
+- name: release_channel
   type: STRING
-- mode: NULLABLE
-  name: position
+  mode: NULLABLE
+- name: position
   type: INTEGER
-- mode: NULLABLE
-  name: provider
+  mode: NULLABLE
+- name: provider
   type: STRING
-- mode: NULLABLE
-  name: match_type
+  mode: NULLABLE
+- name: match_type
   type: STRING
-- mode: NULLABLE
-  name: normalized_os
+  mode: NULLABLE
+- name: normalized_os
   type: STRING
-- mode: NULLABLE
-  name: suggest_data_sharing_enabled
+  mode: NULLABLE
+- name: suggest_data_sharing_enabled
   type: BOOLEAN
-- mode: NULLABLE
-  name: event_count
+  mode: NULLABLE
+- name: event_count
   type: INTEGER
-- mode: NULLABLE
-  name: user_count
+  mode: NULLABLE
+- name: user_count
   type: INTEGER
-- mode: NULLABLE
-  name: query_type
+  mode: NULLABLE
+- name: query_type
   type: STRING
+  mode: NULLABLE
diff -bur --no-dereference --new-file /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/contextual_services/event_aggregates_suggest/schema.yaml /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/contextual_services/event_aggregates_suggest/schema.yaml
--- /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/contextual_services/event_aggregates_suggest/schema.yaml	2024-10-10 18:23:50.000000000 +0000
+++ /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/contextual_services/event_aggregates_suggest/schema.yaml	2024-10-10 18:32:20.000000000 +0000
@@ -1,40 +1,40 @@
 fields:
-- mode: NULLABLE
-  name: submission_date
+- name: submission_date
   type: DATE
-- mode: NULLABLE
-  name: form_factor
+  mode: NULLABLE
+- name: form_factor
   type: STRING
-- mode: NULLABLE
-  name: country
+  mode: NULLABLE
+- name: country
   type: STRING
-- mode: NULLABLE
-  name: advertiser
+  mode: NULLABLE
+- name: advertiser
   type: STRING
-- mode: NULLABLE
-  name: normalized_os
+  mode: NULLABLE
+- name: normalized_os
   type: STRING
-- mode: NULLABLE
-  name: release_channel
+  mode: NULLABLE
+- name: release_channel
   type: STRING
-- mode: NULLABLE
-  name: position
+  mode: NULLABLE
+- name: position
   type: INTEGER
-- mode: NULLABLE
-  name: provider
+  mode: NULLABLE
+- name: provider
   type: STRING
-- mode: NULLABLE
-  name: match_type
+  mode: NULLABLE
+- name: match_type
   type: STRING
-- mode: NULLABLE
-  name: suggest_data_sharing_enabled
+  mode: NULLABLE
+- name: suggest_data_sharing_enabled
   type: BOOLEAN
-- mode: NULLABLE
-  name: impression_count
+  mode: NULLABLE
+- name: impression_count
   type: INTEGER
-- mode: NULLABLE
-  name: click_count
+  mode: NULLABLE
+- name: click_count
   type: INTEGER
-- mode: NULLABLE
-  name: query_type
+  mode: NULLABLE
+- name: query_type
   type: STRING
+  mode: NULLABLE
diff -bur --no-dereference --new-file /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/fenix/funnel_retention_clients/schema.yaml /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/fenix/funnel_retention_clients/schema.yaml
--- /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/fenix/funnel_retention_clients/schema.yaml	2024-10-10 18:23:50.000000000 +0000
+++ /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/fenix/funnel_retention_clients/schema.yaml	2024-10-10 18:32:31.000000000 +0000
@@ -26,6 +26,9 @@
 - name: adjust_network
   type: STRING
   mode: NULLABLE
+- name: install_source
+  type: STRING
+  mode: NULLABLE
 - name: retained_week_2
   type: BOOLEAN
   mode: NULLABLE
diff -bur --no-dereference --new-file /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/fenix/funnel_retention_week_4/schema.yaml /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/fenix/funnel_retention_week_4/schema.yaml
--- /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/fenix/funnel_retention_week_4/schema.yaml	2024-10-10 18:23:50.000000000 +0000
+++ /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/fenix/funnel_retention_week_4/schema.yaml	2024-10-10 18:32:17.000000000 +0000
@@ -48,6 +48,10 @@
   description: 'The type of source of a client installation.
 
     '
+- name: install_source
+  type: STRING
+  mode: NULLABLE
+  description: null
 - name: new_profiles
   type: INTEGER
   mode: NULLABLE
diff -bur --no-dereference --new-file /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/fenix/use_counters/schema.yaml /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/fenix/use_counters/schema.yaml
--- /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/fenix/use_counters/schema.yaml	2024-10-10 18:24:31.000000000 +0000
+++ /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/fenix/use_counters/schema.yaml	2024-10-10 18:34:38.000000000 +0000
@@ -1,11 +1,11 @@
 fields:
 - name: normalized_app_id
-  type: STRING
   mode: NULLABLE
+  type: STRING
   description: App ID of the channel data was received from
 - name: normalized_channel
-  type: STRING
   mode: NULLABLE
+  type: STRING
   description: Normalized channel name
 - name: additional_properties
   type: STRING
diff -bur --no-dereference --new-file /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/firefox_ios_derived/iOS_onboarding_v1/metadata.yaml /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/firefox_ios_derived/iOS_onboarding_v1/metadata.yaml
--- /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/firefox_ios_derived/iOS_onboarding_v1/metadata.yaml	1970-01-01 00:00:00.000000000 +0000
+++ /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/firefox_ios_derived/iOS_onboarding_v1/metadata.yaml	2024-10-10 18:36:58.000000000 +0000
@@ -0,0 +1,29 @@
+friendly_name: Ios Onboarding
+description: |-
+  Please provide a description for the query
+owners:
+- [email protected]
+labels:
+  incremental: true
+  dag: bqetl_generated_funnels
+  owner1: rzhao
+scheduling:
+  dag_name: bqetl_generated_funnels
+bigquery:
+  time_partitioning:
+    type: day
+    field: submission_date
+    require_partition_filter: false
+    expiration_days: null
+  range_partitioning: null
+  clustering: null
+workgroup_access:
+- role: roles/bigquery.dataViewer
+  members:
+  - workgroup:mozilla-confidential
+references:
+  query.sql:
+  - firefox_ios.events_unnested
+  - firefox_ios.firefox_ios_clients
+  - moz-fx-data-shared-prod.firefox_ios_derived.funnel_retention_clients_week_2_v1
+  - moz-fx-data-shared-prod.firefox_ios_derived.funnel_retention_clients_week_4_v1
diff -bur --no-dereference --new-file /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/firefox_ios_derived/iOS_onboarding_v1/query.sql /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/firefox_ios_derived/iOS_onboarding_v1/query.sql
--- /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/firefox_ios_derived/iOS_onboarding_v1/query.sql	1970-01-01 00:00:00.000000000 +0000
+++ /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/firefox_ios_derived/iOS_onboarding_v1/query.sql	2024-10-10 18:38:10.000000000 +0000
@@ -0,0 +1,2818 @@
+-- extract the relevant fields for each funnel step and segment if necessary
+WITH ios_onboarding_funnel_new_profile AS (
+  SELECT
+    COALESCE(funnel_id, 'no_onboarding_reported') AS funnel_id,
+    COALESCE(r.repeat_first_month_user, FALSE) AS repeat_first_month_user,
+    COALESCE(r.retained_week_2, FALSE) AS retained_week_2,
+    COALESCE(r.retained_week_4, FALSE) AS retained_week_4,
+    ic.first_reported_country AS country,
+    ic.locale AS locale,
+    ic.os_version AS ios_version,
+    ic.channel AS channel,
+    ic.device_model AS device_model,
+    ic.device_manufacturer AS device_manufacturer,
+    ic.first_seen_date AS first_seen_date,
+    ic.adjust_network AS adjust_network,
+    ic.adjust_campaign AS adjust_campaign,
+    ic.adjust_creative AS adjust_creative,
+    ic.adjust_ad_group AS adjust_ad_group,
+    DATE(ic.submission_timestamp) AS submission_date,
+    ic.client_id AS client_id_column,
+    ic.client_id AS column
+  FROM
+    `moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients` ic --each client_id has only one row
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_4_v1 r --each client_id has only one row
+    ON ic.client_id = r.client_id
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_2_v1 r2 -- retained_week_2 is not included in funnel_retention_clients_week_4_v1
+    ON ic.client_id = r2.client_id
+  LEFT JOIN
+    (
+      SELECT
+        *
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested` eu
+      WHERE
+        DATE(submission_timestamp) = @submission_date
+    ) eu
+    ON ic.client_id = eu.client_info.client_id
+  LEFT JOIN
+    (
+      SELECT
+        client_info.client_id,
+        ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')) AS funnel_id,
+        1 + LENGTH(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id'))) - LENGTH(
+          REPLACE(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')), '_', '')
+        ) AS number_of_onboarding_cards
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested`
+      WHERE
+        `mozfun.map.get_key`(event_extra, 'sequence_id') IS NOT NULL
+        AND DATE(submission_timestamp) = @submission_date
+      GROUP BY
+        1
+    ) funnel_ids
+    ON ic.client_id = funnel_ids.client_id
+  WHERE
+    DATE(ic.submission_timestamp) = @submission_date
+),
+ios_onboarding_funnel_first_card_impression AS (
+  SELECT
+    COALESCE(funnel_id, 'no_onboarding_reported') AS funnel_id,
+    COALESCE(r.repeat_first_month_user, FALSE) AS repeat_first_month_user,
+    COALESCE(r.retained_week_2, FALSE) AS retained_week_2,
+    COALESCE(r.retained_week_4, FALSE) AS retained_week_4,
+    ic.first_reported_country AS country,
+    ic.locale AS locale,
+    ic.os_version AS ios_version,
+    ic.channel AS channel,
+    ic.device_model AS device_model,
+    ic.device_manufacturer AS device_manufacturer,
+    ic.first_seen_date AS first_seen_date,
+    ic.adjust_network AS adjust_network,
+    ic.adjust_campaign AS adjust_campaign,
+    ic.adjust_creative AS adjust_creative,
+    ic.adjust_ad_group AS adjust_ad_group,
+    DATE(ic.submission_timestamp) AS submission_date,
+    ic.client_id AS client_id_column,
+    CASE
+      WHEN `mozfun.map.get_key`(event_extra, 'sequence_position') = '1'
+        AND event_name = 'card_view'
+        AND event_category = 'onboarding'
+        THEN ic.client_id
+    END AS column
+  FROM
+    `moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients` ic --each client_id has only one row
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_4_v1 r --each client_id has only one row
+    ON ic.client_id = r.client_id
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_2_v1 r2 -- retained_week_2 is not included in funnel_retention_clients_week_4_v1
+    ON ic.client_id = r2.client_id
+  LEFT JOIN
+    (
+      SELECT
+        *
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested` eu
+      WHERE
+        DATE(submission_timestamp) = @submission_date
+    ) eu
+    ON ic.client_id = eu.client_info.client_id
+  LEFT JOIN
+    (
+      SELECT
+        client_info.client_id,
+        ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')) AS funnel_id,
+        1 + LENGTH(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id'))) - LENGTH(
+          REPLACE(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')), '_', '')
+        ) AS number_of_onboarding_cards
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested`
+      WHERE
+        `mozfun.map.get_key`(event_extra, 'sequence_id') IS NOT NULL
+        AND DATE(submission_timestamp) = @submission_date
+      GROUP BY
+        1
+    ) funnel_ids
+    ON ic.client_id = funnel_ids.client_id
+  WHERE
+    DATE(ic.submission_timestamp) = @submission_date
+),
+ios_onboarding_funnel_first_card_primary_click AS (
+  SELECT
+    COALESCE(funnel_id, 'no_onboarding_reported') AS funnel_id,
+    COALESCE(r.repeat_first_month_user, FALSE) AS repeat_first_month_user,
+    COALESCE(r.retained_week_2, FALSE) AS retained_week_2,
+    COALESCE(r.retained_week_4, FALSE) AS retained_week_4,
+    ic.first_reported_country AS country,
+    ic.locale AS locale,
+    ic.os_version AS ios_version,
+    ic.channel AS channel,
+    ic.device_model AS device_model,
+    ic.device_manufacturer AS device_manufacturer,
+    ic.first_seen_date AS first_seen_date,
+    ic.adjust_network AS adjust_network,
+    ic.adjust_campaign AS adjust_campaign,
+    ic.adjust_creative AS adjust_creative,
+    ic.adjust_ad_group AS adjust_ad_group,
+    DATE(ic.submission_timestamp) AS submission_date,
+    ic.client_id AS client_id_column,
+    CASE
+      WHEN `mozfun.map.get_key`(event_extra, 'sequence_position') = '1'
+        AND event_name = 'primary_button_tap'
+        AND event_category = 'onboarding'
+        THEN ic.client_id
+    END AS column
+  FROM
+    `moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients` ic --each client_id has only one row
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_4_v1 r --each client_id has only one row
+    ON ic.client_id = r.client_id
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_2_v1 r2 -- retained_week_2 is not included in funnel_retention_clients_week_4_v1
+    ON ic.client_id = r2.client_id
+  LEFT JOIN
+    (
+      SELECT
+        *
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested` eu
+      WHERE
+        DATE(submission_timestamp) = @submission_date
+    ) eu
+    ON ic.client_id = eu.client_info.client_id
+  LEFT JOIN
+    (
+      SELECT
+        client_info.client_id,
+        ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')) AS funnel_id,
+        1 + LENGTH(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id'))) - LENGTH(
+          REPLACE(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')), '_', '')
+        ) AS number_of_onboarding_cards
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested`
+      WHERE
+        `mozfun.map.get_key`(event_extra, 'sequence_id') IS NOT NULL
+        AND DATE(submission_timestamp) = @submission_date
+      GROUP BY
+        1
+    ) funnel_ids
+    ON ic.client_id = funnel_ids.client_id
+  WHERE
+    DATE(ic.submission_timestamp) = @submission_date
+),
+ios_onboarding_funnel_first_card_secondary_click AS (
+  SELECT
+    COALESCE(funnel_id, 'no_onboarding_reported') AS funnel_id,
+    COALESCE(r.repeat_first_month_user, FALSE) AS repeat_first_month_user,
+    COALESCE(r.retained_week_2, FALSE) AS retained_week_2,
+    COALESCE(r.retained_week_4, FALSE) AS retained_week_4,
+    ic.first_reported_country AS country,
+    ic.locale AS locale,
+    ic.os_version AS ios_version,
+    ic.channel AS channel,
+    ic.device_model AS device_model,
+    ic.device_manufacturer AS device_manufacturer,
+    ic.first_seen_date AS first_seen_date,
+    ic.adjust_network AS adjust_network,
+    ic.adjust_campaign AS adjust_campaign,
+    ic.adjust_creative AS adjust_creative,
+    ic.adjust_ad_group AS adjust_ad_group,
+    DATE(ic.submission_timestamp) AS submission_date,
+    ic.client_id AS client_id_column,
+    CASE
+      WHEN `mozfun.map.get_key`(event_extra, 'sequence_position') = '1'
+        AND event_name = 'secondary_button_tap'
+        AND event_category = 'onboarding'
+        THEN ic.client_id
+    END AS column
+  FROM
+    `moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients` ic --each client_id has only one row
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_4_v1 r --each client_id has only one row
+    ON ic.client_id = r.client_id
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_2_v1 r2 -- retained_week_2 is not included in funnel_retention_clients_week_4_v1
+    ON ic.client_id = r2.client_id
+  LEFT JOIN
+    (
+      SELECT
+        *
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested` eu
+      WHERE
+        DATE(submission_timestamp) = @submission_date
+    ) eu
+    ON ic.client_id = eu.client_info.client_id
+  LEFT JOIN
+    (
+      SELECT
+        client_info.client_id,
+        ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')) AS funnel_id,
+        1 + LENGTH(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id'))) - LENGTH(
+          REPLACE(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')), '_', '')
+        ) AS number_of_onboarding_cards
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested`
+      WHERE
+        `mozfun.map.get_key`(event_extra, 'sequence_id') IS NOT NULL
+        AND DATE(submission_timestamp) = @submission_date
+      GROUP BY
+        1
+    ) funnel_ids
+    ON ic.client_id = funnel_ids.client_id
+  WHERE
+    DATE(ic.submission_timestamp) = @submission_date
+),
+ios_onboarding_funnel_first_card_close_click AS (
+  SELECT
+    COALESCE(funnel_id, 'no_onboarding_reported') AS funnel_id,
+    COALESCE(r.repeat_first_month_user, FALSE) AS repeat_first_month_user,
+    COALESCE(r.retained_week_2, FALSE) AS retained_week_2,
+    COALESCE(r.retained_week_4, FALSE) AS retained_week_4,
+    ic.first_reported_country AS country,
+    ic.locale AS locale,
+    ic.os_version AS ios_version,
+    ic.channel AS channel,
+    ic.device_model AS device_model,
+    ic.device_manufacturer AS device_manufacturer,
+    ic.first_seen_date AS first_seen_date,
+    ic.adjust_network AS adjust_network,
+    ic.adjust_campaign AS adjust_campaign,
+    ic.adjust_creative AS adjust_creative,
+    ic.adjust_ad_group AS adjust_ad_group,
+    DATE(ic.submission_timestamp) AS submission_date,
+    ic.client_id AS client_id_column,
+    CASE
+      WHEN `mozfun.map.get_key`(event_extra, 'sequence_position') = '1'
+        AND event_name = 'close_tap'
+        AND event_category = 'onboarding'
+        THEN ic.client_id
+    END AS column
+  FROM
+    `moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients` ic --each client_id has only one row
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_4_v1 r --each client_id has only one row
+    ON ic.client_id = r.client_id
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_2_v1 r2 -- retained_week_2 is not included in funnel_retention_clients_week_4_v1
+    ON ic.client_id = r2.client_id
+  LEFT JOIN
+    (
+      SELECT
+        *
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested` eu
+      WHERE
+        DATE(submission_timestamp) = @submission_date
+    ) eu
+    ON ic.client_id = eu.client_info.client_id
+  LEFT JOIN
+    (
+      SELECT
+        client_info.client_id,
+        ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')) AS funnel_id,
+        1 + LENGTH(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id'))) - LENGTH(
+          REPLACE(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')), '_', '')
+        ) AS number_of_onboarding_cards
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested`
+      WHERE
+        `mozfun.map.get_key`(event_extra, 'sequence_id') IS NOT NULL
+        AND DATE(submission_timestamp) = @submission_date
+      GROUP BY
+        1
+    ) funnel_ids
+    ON ic.client_id = funnel_ids.client_id
+  WHERE
+    DATE(ic.submission_timestamp) = @submission_date
+),
+ios_onboarding_funnel_second_card_impression AS (
+  SELECT
+    COALESCE(funnel_id, 'no_onboarding_reported') AS funnel_id,
+    COALESCE(r.repeat_first_month_user, FALSE) AS repeat_first_month_user,
+    COALESCE(r.retained_week_2, FALSE) AS retained_week_2,
+    COALESCE(r.retained_week_4, FALSE) AS retained_week_4,
+    ic.first_reported_country AS country,
+    ic.locale AS locale,
+    ic.os_version AS ios_version,
+    ic.channel AS channel,
+    ic.device_model AS device_model,
+    ic.device_manufacturer AS device_manufacturer,
+    ic.first_seen_date AS first_seen_date,
+    ic.adjust_network AS adjust_network,
+    ic.adjust_campaign AS adjust_campaign,
+    ic.adjust_creative AS adjust_creative,
+    ic.adjust_ad_group AS adjust_ad_group,
+    DATE(ic.submission_timestamp) AS submission_date,
+    ic.client_id AS client_id_column,
+    CASE
+      WHEN `mozfun.map.get_key`(event_extra, 'sequence_position') = '2'
+        AND event_name = 'card_view'
+        AND event_category = 'onboarding'
+        THEN ic.client_id
+    END AS column
+  FROM
+    `moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients` ic --each client_id has only one row
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_4_v1 r --each client_id has only one row
+    ON ic.client_id = r.client_id
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_2_v1 r2 -- retained_week_2 is not included in funnel_retention_clients_week_4_v1
+    ON ic.client_id = r2.client_id
+  LEFT JOIN
+    (
+      SELECT
+        *
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested` eu
+      WHERE
+        DATE(submission_timestamp) = @submission_date
+    ) eu
+    ON ic.client_id = eu.client_info.client_id
+  LEFT JOIN
+    (
+      SELECT
+        client_info.client_id,
+        ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')) AS funnel_id,
+        1 + LENGTH(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id'))) - LENGTH(
+          REPLACE(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')), '_', '')
+        ) AS number_of_onboarding_cards
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested`
+      WHERE
+        `mozfun.map.get_key`(event_extra, 'sequence_id') IS NOT NULL
+        AND DATE(submission_timestamp) = @submission_date
+      GROUP BY
+        1
+    ) funnel_ids
+    ON ic.client_id = funnel_ids.client_id
+  WHERE
+    DATE(ic.submission_timestamp) = @submission_date
+),
+ios_onboarding_funnel_second_card_primary_click AS (
+  SELECT
+    COALESCE(funnel_id, 'no_onboarding_reported') AS funnel_id,
+    COALESCE(r.repeat_first_month_user, FALSE) AS repeat_first_month_user,
+    COALESCE(r.retained_week_2, FALSE) AS retained_week_2,
+    COALESCE(r.retained_week_4, FALSE) AS retained_week_4,
+    ic.first_reported_country AS country,
+    ic.locale AS locale,
+    ic.os_version AS ios_version,
+    ic.channel AS channel,
+    ic.device_model AS device_model,
+    ic.device_manufacturer AS device_manufacturer,
+    ic.first_seen_date AS first_seen_date,
+    ic.adjust_network AS adjust_network,
+    ic.adjust_campaign AS adjust_campaign,
+    ic.adjust_creative AS adjust_creative,
+    ic.adjust_ad_group AS adjust_ad_group,
+    DATE(ic.submission_timestamp) AS submission_date,
+    ic.client_id AS client_id_column,
+    CASE
+      WHEN `mozfun.map.get_key`(event_extra, 'sequence_position') = '2'
+        AND event_name = 'primary_button_tap'
+        AND event_category = 'onboarding'
+        THEN ic.client_id
+    END AS column
+  FROM
+    `moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients` ic --each client_id has only one row
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_4_v1 r --each client_id has only one row
+    ON ic.client_id = r.client_id
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_2_v1 r2 -- retained_week_2 is not included in funnel_retention_clients_week_4_v1
+    ON ic.client_id = r2.client_id
+  LEFT JOIN
+    (
+      SELECT
+        *
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested` eu
+      WHERE
+        DATE(submission_timestamp) = @submission_date
+    ) eu
+    ON ic.client_id = eu.client_info.client_id
+  LEFT JOIN
+    (
+      SELECT
+        client_info.client_id,
+        ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')) AS funnel_id,
+        1 + LENGTH(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id'))) - LENGTH(
+          REPLACE(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')), '_', '')
+        ) AS number_of_onboarding_cards
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested`
+      WHERE
+        `mozfun.map.get_key`(event_extra, 'sequence_id') IS NOT NULL
+        AND DATE(submission_timestamp) = @submission_date
+      GROUP BY
+        1
+    ) funnel_ids
+    ON ic.client_id = funnel_ids.client_id
+  WHERE
+    DATE(ic.submission_timestamp) = @submission_date
+),
+ios_onboarding_funnel_second_card_secondary_click AS (
+  SELECT
+    COALESCE(funnel_id, 'no_onboarding_reported') AS funnel_id,
+    COALESCE(r.repeat_first_month_user, FALSE) AS repeat_first_month_user,
+    COALESCE(r.retained_week_2, FALSE) AS retained_week_2,
+    COALESCE(r.retained_week_4, FALSE) AS retained_week_4,
+    ic.first_reported_country AS country,
+    ic.locale AS locale,
+    ic.os_version AS ios_version,
+    ic.channel AS channel,
+    ic.device_model AS device_model,
+    ic.device_manufacturer AS device_manufacturer,
+    ic.first_seen_date AS first_seen_date,
+    ic.adjust_network AS adjust_network,
+    ic.adjust_campaign AS adjust_campaign,
+    ic.adjust_creative AS adjust_creative,
+    ic.adjust_ad_group AS adjust_ad_group,
+    DATE(ic.submission_timestamp) AS submission_date,
+    ic.client_id AS client_id_column,
+    CASE
+      WHEN `mozfun.map.get_key`(event_extra, 'sequence_position') = '2'
+        AND event_name = 'secondary_button_tap'
+        AND event_category = 'onboarding'
+        THEN ic.client_id
+    END AS column
+  FROM
+    `moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients` ic --each client_id has only one row
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_4_v1 r --each client_id has only one row
+    ON ic.client_id = r.client_id
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_2_v1 r2 -- retained_week_2 is not included in funnel_retention_clients_week_4_v1
+    ON ic.client_id = r2.client_id
+  LEFT JOIN
+    (
+      SELECT
+        *
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested` eu
+      WHERE
+        DATE(submission_timestamp) = @submission_date
+    ) eu
+    ON ic.client_id = eu.client_info.client_id
+  LEFT JOIN
+    (
+      SELECT
+        client_info.client_id,
+        ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')) AS funnel_id,
+        1 + LENGTH(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id'))) - LENGTH(
+          REPLACE(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')), '_', '')
+        ) AS number_of_onboarding_cards
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested`
+      WHERE
+        `mozfun.map.get_key`(event_extra, 'sequence_id') IS NOT NULL
+        AND DATE(submission_timestamp) = @submission_date
+      GROUP BY
+        1
+    ) funnel_ids
+    ON ic.client_id = funnel_ids.client_id
+  WHERE
+    DATE(ic.submission_timestamp) = @submission_date
+),
+ios_onboarding_funnel_second_card_close_click AS (
+  SELECT
+    COALESCE(funnel_id, 'no_onboarding_reported') AS funnel_id,
+    COALESCE(r.repeat_first_month_user, FALSE) AS repeat_first_month_user,
+    COALESCE(r.retained_week_2, FALSE) AS retained_week_2,
+    COALESCE(r.retained_week_4, FALSE) AS retained_week_4,
+    ic.first_reported_country AS country,
+    ic.locale AS locale,
+    ic.os_version AS ios_version,
+    ic.channel AS channel,
+    ic.device_model AS device_model,
+    ic.device_manufacturer AS device_manufacturer,
+    ic.first_seen_date AS first_seen_date,
+    ic.adjust_network AS adjust_network,
+    ic.adjust_campaign AS adjust_campaign,
+    ic.adjust_creative AS adjust_creative,
+    ic.adjust_ad_group AS adjust_ad_group,
+    DATE(ic.submission_timestamp) AS submission_date,
+    ic.client_id AS client_id_column,
+    CASE
+      WHEN `mozfun.map.get_key`(event_extra, 'sequence_position') = '2'
+        AND event_name = 'close_tap'
+        AND event_category = 'onboarding'
+        THEN ic.client_id
+    END AS column
+  FROM
+    `moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients` ic --each client_id has only one row
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_4_v1 r --each client_id has only one row
+    ON ic.client_id = r.client_id
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_2_v1 r2 -- retained_week_2 is not included in funnel_retention_clients_week_4_v1
+    ON ic.client_id = r2.client_id
+  LEFT JOIN
+    (
+      SELECT
+        *
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested` eu
+      WHERE
+        DATE(submission_timestamp) = @submission_date
+    ) eu
+    ON ic.client_id = eu.client_info.client_id
+  LEFT JOIN
+    (
+      SELECT
+        client_info.client_id,
+        ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')) AS funnel_id,
+        1 + LENGTH(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id'))) - LENGTH(
+          REPLACE(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')), '_', '')
+        ) AS number_of_onboarding_cards
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested`
+      WHERE
+        `mozfun.map.get_key`(event_extra, 'sequence_id') IS NOT NULL
+        AND DATE(submission_timestamp) = @submission_date
+      GROUP BY
+        1
+    ) funnel_ids
+    ON ic.client_id = funnel_ids.client_id
+  WHERE
+    DATE(ic.submission_timestamp) = @submission_date
+),
+ios_onboarding_funnel_third_card_impression AS (
+  SELECT
+    COALESCE(funnel_id, 'no_onboarding_reported') AS funnel_id,
+    COALESCE(r.repeat_first_month_user, FALSE) AS repeat_first_month_user,
+    COALESCE(r.retained_week_2, FALSE) AS retained_week_2,
+    COALESCE(r.retained_week_4, FALSE) AS retained_week_4,
+    ic.first_reported_country AS country,
+    ic.locale AS locale,
+    ic.os_version AS ios_version,
+    ic.channel AS channel,
+    ic.device_model AS device_model,
+    ic.device_manufacturer AS device_manufacturer,
+    ic.first_seen_date AS first_seen_date,
+    ic.adjust_network AS adjust_network,
+    ic.adjust_campaign AS adjust_campaign,
+    ic.adjust_creative AS adjust_creative,
+    ic.adjust_ad_group AS adjust_ad_group,
+    DATE(ic.submission_timestamp) AS submission_date,
+    ic.client_id AS client_id_column,
+    CASE
+      WHEN `mozfun.map.get_key`(event_extra, 'sequence_position') = '3'
+        AND event_name = 'card_view'
+        AND event_category = 'onboarding'
+        THEN ic.client_id
+    END AS column
+  FROM
+    `moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients` ic --each client_id has only one row
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_4_v1 r --each client_id has only one row
+    ON ic.client_id = r.client_id
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_2_v1 r2 -- retained_week_2 is not included in funnel_retention_clients_week_4_v1
+    ON ic.client_id = r2.client_id
+  LEFT JOIN
+    (
+      SELECT
+        *
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested` eu
+      WHERE
+        DATE(submission_timestamp) = @submission_date
+    ) eu
+    ON ic.client_id = eu.client_info.client_id
+  LEFT JOIN
+    (
+      SELECT
+        client_info.client_id,
+        ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')) AS funnel_id,
+        1 + LENGTH(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id'))) - LENGTH(
+          REPLACE(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')), '_', '')
+        ) AS number_of_onboarding_cards
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested`
+      WHERE
+        `mozfun.map.get_key`(event_extra, 'sequence_id') IS NOT NULL
+        AND DATE(submission_timestamp) = @submission_date
+      GROUP BY
+        1
+    ) funnel_ids
+    ON ic.client_id = funnel_ids.client_id
+  WHERE
+    DATE(ic.submission_timestamp) = @submission_date
+),
+ios_onboarding_funnel_third_card_primary_click AS (
+  SELECT
+    COALESCE(funnel_id, 'no_onboarding_reported') AS funnel_id,
+    COALESCE(r.repeat_first_month_user, FALSE) AS repeat_first_month_user,
+    COALESCE(r.retained_week_2, FALSE) AS retained_week_2,
+    COALESCE(r.retained_week_4, FALSE) AS retained_week_4,
+    ic.first_reported_country AS country,
+    ic.locale AS locale,
+    ic.os_version AS ios_version,
+    ic.channel AS channel,
+    ic.device_model AS device_model,
+    ic.device_manufacturer AS device_manufacturer,
+    ic.first_seen_date AS first_seen_date,
+    ic.adjust_network AS adjust_network,
+    ic.adjust_campaign AS adjust_campaign,
+    ic.adjust_creative AS adjust_creative,
+    ic.adjust_ad_group AS adjust_ad_group,
+    DATE(ic.submission_timestamp) AS submission_date,
+    ic.client_id AS client_id_column,
+    CASE
+      WHEN `mozfun.map.get_key`(event_extra, 'sequence_position') = '3'
+        AND event_name = 'primary_button_tap'
+        AND event_category = 'onboarding'
+        THEN ic.client_id
+    END AS column
+  FROM
+    `moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients` ic --each client_id has only one row
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_4_v1 r --each client_id has only one row
+    ON ic.client_id = r.client_id
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_2_v1 r2 -- retained_week_2 is not included in funnel_retention_clients_week_4_v1
+    ON ic.client_id = r2.client_id
+  LEFT JOIN
+    (
+      SELECT
+        *
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested` eu
+      WHERE
+        DATE(submission_timestamp) = @submission_date
+    ) eu
+    ON ic.client_id = eu.client_info.client_id
+  LEFT JOIN
+    (
+      SELECT
+        client_info.client_id,
+        ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')) AS funnel_id,
+        1 + LENGTH(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id'))) - LENGTH(
+          REPLACE(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')), '_', '')
+        ) AS number_of_onboarding_cards
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested`
+      WHERE
+        `mozfun.map.get_key`(event_extra, 'sequence_id') IS NOT NULL
+        AND DATE(submission_timestamp) = @submission_date
+      GROUP BY
+        1
+    ) funnel_ids
+    ON ic.client_id = funnel_ids.client_id
+  WHERE
+    DATE(ic.submission_timestamp) = @submission_date
+),
+ios_onboarding_funnel_third_card_secondary_click AS (
+  SELECT
+    COALESCE(funnel_id, 'no_onboarding_reported') AS funnel_id,
+    COALESCE(r.repeat_first_month_user, FALSE) AS repeat_first_month_user,
+    COALESCE(r.retained_week_2, FALSE) AS retained_week_2,
+    COALESCE(r.retained_week_4, FALSE) AS retained_week_4,
+    ic.first_reported_country AS country,
+    ic.locale AS locale,
+    ic.os_version AS ios_version,
+    ic.channel AS channel,
+    ic.device_model AS device_model,
+    ic.device_manufacturer AS device_manufacturer,
+    ic.first_seen_date AS first_seen_date,
+    ic.adjust_network AS adjust_network,
+    ic.adjust_campaign AS adjust_campaign,
+    ic.adjust_creative AS adjust_creative,
+    ic.adjust_ad_group AS adjust_ad_group,
+    DATE(ic.submission_timestamp) AS submission_date,
+    ic.client_id AS client_id_column,
+    CASE
+      WHEN `mozfun.map.get_key`(event_extra, 'sequence_position') = '3'
+        AND event_name = 'secondary_button_tap'
+        AND event_category = 'onboarding'
+        THEN ic.client_id
+    END AS column
+  FROM
+    `moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients` ic --each client_id has only one row
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_4_v1 r --each client_id has only one row
+    ON ic.client_id = r.client_id
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_2_v1 r2 -- retained_week_2 is not included in funnel_retention_clients_week_4_v1
+    ON ic.client_id = r2.client_id
+  LEFT JOIN
+    (
+      SELECT
+        *
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested` eu
+      WHERE
+        DATE(submission_timestamp) = @submission_date
+    ) eu
+    ON ic.client_id = eu.client_info.client_id
+  LEFT JOIN
+    (
+      SELECT
+        client_info.client_id,
+        ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')) AS funnel_id,
+        1 + LENGTH(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id'))) - LENGTH(
+          REPLACE(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')), '_', '')
+        ) AS number_of_onboarding_cards
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested`
+      WHERE
+        `mozfun.map.get_key`(event_extra, 'sequence_id') IS NOT NULL
+        AND DATE(submission_timestamp) = @submission_date
+      GROUP BY
+        1
+    ) funnel_ids
+    ON ic.client_id = funnel_ids.client_id
+  WHERE
+    DATE(ic.submission_timestamp) = @submission_date
+),
+ios_onboarding_funnel_third_card_close_click AS (
+  SELECT
+    COALESCE(funnel_id, 'no_onboarding_reported') AS funnel_id,
+    COALESCE(r.repeat_first_month_user, FALSE) AS repeat_first_month_user,
+    COALESCE(r.retained_week_2, FALSE) AS retained_week_2,
+    COALESCE(r.retained_week_4, FALSE) AS retained_week_4,
+    ic.first_reported_country AS country,
+    ic.locale AS locale,
+    ic.os_version AS ios_version,
+    ic.channel AS channel,
+    ic.device_model AS device_model,
+    ic.device_manufacturer AS device_manufacturer,
+    ic.first_seen_date AS first_seen_date,
+    ic.adjust_network AS adjust_network,
+    ic.adjust_campaign AS adjust_campaign,
+    ic.adjust_creative AS adjust_creative,
+    ic.adjust_ad_group AS adjust_ad_group,
+    DATE(ic.submission_timestamp) AS submission_date,
+    ic.client_id AS client_id_column,
+    CASE
+      WHEN `mozfun.map.get_key`(event_extra, 'sequence_position') = '3'
+        AND event_name = 'close_tap'
+        AND event_category = 'onboarding'
+        THEN ic.client_id
+    END AS column
+  FROM
+    `moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients` ic --each client_id has only one row
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_4_v1 r --each client_id has only one row
+    ON ic.client_id = r.client_id
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_2_v1 r2 -- retained_week_2 is not included in funnel_retention_clients_week_4_v1
+    ON ic.client_id = r2.client_id
+  LEFT JOIN
+    (
+      SELECT
+        *
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested` eu
+      WHERE
+        DATE(submission_timestamp) = @submission_date
+    ) eu
+    ON ic.client_id = eu.client_info.client_id
+  LEFT JOIN
+    (
+      SELECT
+        client_info.client_id,
+        ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')) AS funnel_id,
+        1 + LENGTH(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id'))) - LENGTH(
+          REPLACE(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')), '_', '')
+        ) AS number_of_onboarding_cards
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested`
+      WHERE
+        `mozfun.map.get_key`(event_extra, 'sequence_id') IS NOT NULL
+        AND DATE(submission_timestamp) = @submission_date
+      GROUP BY
+        1
+    ) funnel_ids
+    ON ic.client_id = funnel_ids.client_id
+  WHERE
+    DATE(ic.submission_timestamp) = @submission_date
+),
+ios_onboarding_funnel_fourth_card_impression AS (
+  SELECT
+    COALESCE(funnel_id, 'no_onboarding_reported') AS funnel_id,
+    COALESCE(r.repeat_first_month_user, FALSE) AS repeat_first_month_user,
+    COALESCE(r.retained_week_2, FALSE) AS retained_week_2,
+    COALESCE(r.retained_week_4, FALSE) AS retained_week_4,
+    ic.first_reported_country AS country,
+    ic.locale AS locale,
+    ic.os_version AS ios_version,
+    ic.channel AS channel,
+    ic.device_model AS device_model,
+    ic.device_manufacturer AS device_manufacturer,
+    ic.first_seen_date AS first_seen_date,
+    ic.adjust_network AS adjust_network,
+    ic.adjust_campaign AS adjust_campaign,
+    ic.adjust_creative AS adjust_creative,
+    ic.adjust_ad_group AS adjust_ad_group,
+    DATE(ic.submission_timestamp) AS submission_date,
+    ic.client_id AS client_id_column,
+    CASE
+      WHEN `mozfun.map.get_key`(event_extra, 'sequence_position') = '4'
+        AND event_name = 'card_view'
+        AND event_category = 'onboarding'
+        THEN ic.client_id
+    END AS column
+  FROM
+    `moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients` ic --each client_id has only one row
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_4_v1 r --each client_id has only one row
+    ON ic.client_id = r.client_id
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_2_v1 r2 -- retained_week_2 is not included in funnel_retention_clients_week_4_v1
+    ON ic.client_id = r2.client_id
+  LEFT JOIN
+    (
+      SELECT
+        *
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested` eu
+      WHERE
+        DATE(submission_timestamp) = @submission_date
+    ) eu
+    ON ic.client_id = eu.client_info.client_id
+  LEFT JOIN
+    (
+      SELECT
+        client_info.client_id,
+        ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')) AS funnel_id,
+        1 + LENGTH(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id'))) - LENGTH(
+          REPLACE(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')), '_', '')
+        ) AS number_of_onboarding_cards
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested`
+      WHERE
+        `mozfun.map.get_key`(event_extra, 'sequence_id') IS NOT NULL
+        AND DATE(submission_timestamp) = @submission_date
+      GROUP BY
+        1
+    ) funnel_ids
+    ON ic.client_id = funnel_ids.client_id
+  WHERE
+    DATE(ic.submission_timestamp) = @submission_date
+),
+ios_onboarding_funnel_fourth_card_primary_click AS (
+  SELECT
+    COALESCE(funnel_id, 'no_onboarding_reported') AS funnel_id,
+    COALESCE(r.repeat_first_month_user, FALSE) AS repeat_first_month_user,
+    COALESCE(r.retained_week_2, FALSE) AS retained_week_2,
+    COALESCE(r.retained_week_4, FALSE) AS retained_week_4,
+    ic.first_reported_country AS country,
+    ic.locale AS locale,
+    ic.os_version AS ios_version,
+    ic.channel AS channel,
+    ic.device_model AS device_model,
+    ic.device_manufacturer AS device_manufacturer,
+    ic.first_seen_date AS first_seen_date,
+    ic.adjust_network AS adjust_network,
+    ic.adjust_campaign AS adjust_campaign,
+    ic.adjust_creative AS adjust_creative,
+    ic.adjust_ad_group AS adjust_ad_group,
+    DATE(ic.submission_timestamp) AS submission_date,
+    ic.client_id AS client_id_column,
+    CASE
+      WHEN `mozfun.map.get_key`(event_extra, 'sequence_position') = '4'
+        AND event_name = 'primary_button_tap'
+        AND event_category = 'onboarding'
+        THEN ic.client_id
+    END AS column
+  FROM
+    `moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients` ic --each client_id has only one row
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_4_v1 r --each client_id has only one row
+    ON ic.client_id = r.client_id
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_2_v1 r2 -- retained_week_2 is not included in funnel_retention_clients_week_4_v1
+    ON ic.client_id = r2.client_id
+  LEFT JOIN
+    (
+      SELECT
+        *
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested` eu
+      WHERE
+        DATE(submission_timestamp) = @submission_date
+    ) eu
+    ON ic.client_id = eu.client_info.client_id
+  LEFT JOIN
+    (
+      SELECT
+        client_info.client_id,
+        ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')) AS funnel_id,
+        1 + LENGTH(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id'))) - LENGTH(
+          REPLACE(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')), '_', '')
+        ) AS number_of_onboarding_cards
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested`
+      WHERE
+        `mozfun.map.get_key`(event_extra, 'sequence_id') IS NOT NULL
+        AND DATE(submission_timestamp) = @submission_date
+      GROUP BY
+        1
+    ) funnel_ids
+    ON ic.client_id = funnel_ids.client_id
+  WHERE
+    DATE(ic.submission_timestamp) = @submission_date
+),
+ios_onboarding_funnel_fourth_card_secondary_click AS (
+  SELECT
+    COALESCE(funnel_id, 'no_onboarding_reported') AS funnel_id,
+    COALESCE(r.repeat_first_month_user, FALSE) AS repeat_first_month_user,
+    COALESCE(r.retained_week_2, FALSE) AS retained_week_2,
+    COALESCE(r.retained_week_4, FALSE) AS retained_week_4,
+    ic.first_reported_country AS country,
+    ic.locale AS locale,
+    ic.os_version AS ios_version,
+    ic.channel AS channel,
+    ic.device_model AS device_model,
+    ic.device_manufacturer AS device_manufacturer,
+    ic.first_seen_date AS first_seen_date,
+    ic.adjust_network AS adjust_network,
+    ic.adjust_campaign AS adjust_campaign,
+    ic.adjust_creative AS adjust_creative,
+    ic.adjust_ad_group AS adjust_ad_group,
+    DATE(ic.submission_timestamp) AS submission_date,
+    ic.client_id AS client_id_column,
+    CASE
+      WHEN `mozfun.map.get_key`(event_extra, 'sequence_position') = '4'
+        AND event_name = 'secondary_button_tap'
+        AND event_category = 'onboarding'
+        THEN ic.client_id
+    END AS column
+  FROM
+    `moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients` ic --each client_id has only one row
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_4_v1 r --each client_id has only one row
+    ON ic.client_id = r.client_id
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_2_v1 r2 -- retained_week_2 is not included in funnel_retention_clients_week_4_v1
+    ON ic.client_id = r2.client_id
+  LEFT JOIN
+    (
+      SELECT
+        *
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested` eu
+      WHERE
+        DATE(submission_timestamp) = @submission_date
+    ) eu
+    ON ic.client_id = eu.client_info.client_id
+  LEFT JOIN
+    (
+      SELECT
+        client_info.client_id,
+        ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')) AS funnel_id,
+        1 + LENGTH(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id'))) - LENGTH(
+          REPLACE(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')), '_', '')
+        ) AS number_of_onboarding_cards
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested`
+      WHERE
+        `mozfun.map.get_key`(event_extra, 'sequence_id') IS NOT NULL
+        AND DATE(submission_timestamp) = @submission_date
+      GROUP BY
+        1
+    ) funnel_ids
+    ON ic.client_id = funnel_ids.client_id
+  WHERE
+    DATE(ic.submission_timestamp) = @submission_date
+),
+ios_onboarding_funnel_fourth_card_close_click AS (
+  SELECT
+    COALESCE(funnel_id, 'no_onboarding_reported') AS funnel_id,
+    COALESCE(r.repeat_first_month_user, FALSE) AS repeat_first_month_user,
+    COALESCE(r.retained_week_2, FALSE) AS retained_week_2,
+    COALESCE(r.retained_week_4, FALSE) AS retained_week_4,
+    ic.first_reported_country AS country,
+    ic.locale AS locale,
+    ic.os_version AS ios_version,
+    ic.channel AS channel,
+    ic.device_model AS device_model,
+    ic.device_manufacturer AS device_manufacturer,
+    ic.first_seen_date AS first_seen_date,
+    ic.adjust_network AS adjust_network,
+    ic.adjust_campaign AS adjust_campaign,
+    ic.adjust_creative AS adjust_creative,
+    ic.adjust_ad_group AS adjust_ad_group,
+    DATE(ic.submission_timestamp) AS submission_date,
+    ic.client_id AS client_id_column,
+    CASE
+      WHEN `mozfun.map.get_key`(event_extra, 'sequence_position') = '4'
+        AND event_name = 'close_tap'
+        AND event_category = 'onboarding'
+        THEN ic.client_id
+    END AS column
+  FROM
+    `moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients` ic --each client_id has only one row
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_4_v1 r --each client_id has only one row
+    ON ic.client_id = r.client_id
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_2_v1 r2 -- retained_week_2 is not included in funnel_retention_clients_week_4_v1
+    ON ic.client_id = r2.client_id
+  LEFT JOIN
+    (
+      SELECT
+        *
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested` eu
+      WHERE
+        DATE(submission_timestamp) = @submission_date
+    ) eu
+    ON ic.client_id = eu.client_info.client_id
+  LEFT JOIN
+    (
+      SELECT
+        client_info.client_id,
+        ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')) AS funnel_id,
+        1 + LENGTH(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id'))) - LENGTH(
+          REPLACE(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')), '_', '')
+        ) AS number_of_onboarding_cards
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested`
+      WHERE
+        `mozfun.map.get_key`(event_extra, 'sequence_id') IS NOT NULL
+        AND DATE(submission_timestamp) = @submission_date
+      GROUP BY
+        1
+    ) funnel_ids
+    ON ic.client_id = funnel_ids.client_id
+  WHERE
+    DATE(ic.submission_timestamp) = @submission_date
+),
+ios_onboarding_funnel_fifth_card_impression AS (
+  SELECT
+    COALESCE(funnel_id, 'no_onboarding_reported') AS funnel_id,
+    COALESCE(r.repeat_first_month_user, FALSE) AS repeat_first_month_user,
+    COALESCE(r.retained_week_2, FALSE) AS retained_week_2,
+    COALESCE(r.retained_week_4, FALSE) AS retained_week_4,
+    ic.first_reported_country AS country,
+    ic.locale AS locale,
+    ic.os_version AS ios_version,
+    ic.channel AS channel,
+    ic.device_model AS device_model,
+    ic.device_manufacturer AS device_manufacturer,
+    ic.first_seen_date AS first_seen_date,
+    ic.adjust_network AS adjust_network,
+    ic.adjust_campaign AS adjust_campaign,
+    ic.adjust_creative AS adjust_creative,
+    ic.adjust_ad_group AS adjust_ad_group,
+    DATE(ic.submission_timestamp) AS submission_date,
+    ic.client_id AS client_id_column,
+    CASE
+      WHEN `mozfun.map.get_key`(event_extra, 'sequence_position') = '5'
+        AND event_name = 'card_view'
+        AND event_category = 'onboarding'
+        THEN ic.client_id
+    END AS column
+  FROM
+    `moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients` ic --each client_id has only one row
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_4_v1 r --each client_id has only one row
+    ON ic.client_id = r.client_id
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_2_v1 r2 -- retained_week_2 is not included in funnel_retention_clients_week_4_v1
+    ON ic.client_id = r2.client_id
+  LEFT JOIN
+    (
+      SELECT
+        *
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested` eu
+      WHERE
+        DATE(submission_timestamp) = @submission_date
+    ) eu
+    ON ic.client_id = eu.client_info.client_id
+  LEFT JOIN
+    (
+      SELECT
+        client_info.client_id,
+        ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')) AS funnel_id,
+        1 + LENGTH(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id'))) - LENGTH(
+          REPLACE(ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')), '_', '')
+        ) AS number_of_onboarding_cards
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested`
+      WHERE
+        `mozfun.map.get_key`(event_extra, 'sequence_id') IS NOT NULL
+        AND DATE(submission_timestamp) = @submission_date
+      GROUP BY
+        1
+    ) funnel_ids
+    ON ic.client_id = funnel_ids.client_id
+  WHERE
+    DATE(ic.submission_timestamp) = @submission_date
+),
+ios_onboarding_funnel_fifth_card_primary_click AS (
+  SELECT
+    COALESCE(funnel_id, 'no_onboarding_reported') AS funnel_id,
+    COALESCE(r.repeat_first_month_user, FALSE) AS repeat_first_month_user,
+    COALESCE(r.retained_week_2, FALSE) AS retained_week_2,
+    COALESCE(r.retained_week_4, FALSE) AS retained_week_4,
+    ic.first_reported_country AS country,
+    ic.locale AS locale,
+    ic.os_version AS ios_version,
+    ic.channel AS channel,
+    ic.device_model AS device_model,
+    ic.device_manufacturer AS device_manufacturer,
+    ic.first_seen_date AS first_seen_date,
+    ic.adjust_network AS adjust_network,
+    ic.adjust_campaign AS adjust_campaign,
+    ic.adjust_creative AS adjust_creative,
+    ic.adjust_ad_group AS adjust_ad_group,
+    DATE(ic.submission_timestamp) AS submission_date,
+    ic.client_id AS client_id_column,
+    CASE
+      WHEN `mozfun.map.get_key`(event_extra, 'sequence_position') = '5'
+        AND event_name = 'primary_button_tap'
+        AND event_category = 'onboarding'
+        THEN ic.client_id
+    END AS column
+  FROM
+    `moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients` ic --each client_id has only one row
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_4_v1 r --each client_id has only one row
+    ON ic.client_id = r.client_id
+  LEFT JOIN
+    `moz-fx-data-shared-prod`.firefox_ios_derived.funnel_retention_clients_week_2_v1 r2 -- retained_week_2 is not included in funnel_retention_clients_week_4_v1
+    ON ic.client_id = r2.client_id
+  LEFT JOIN
+    (
+      SELECT
+        *
+      FROM
+        `moz-fx-data-shared-prod.firefox_ios.events_unnested` eu
+      WHERE
+        DATE(submission_timestamp) = @submission_date
+    ) eu
+    ON ic.client_id = eu.client_info.client_id
+  LEFT JOIN
+    (
+      SELECT
+        client_info.client_id,
+        ANY_VALUE(`mozfun.map.get_key`(event_extra, 'sequence_id')) AS funnel_id,
+        1 + LENGTH(ANY_VALUE(`mozfun.map.get_key`(event_extra, 

⚠️ Only part of the diff is displayed.

Link to full diff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants