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

DENG-3274 Add login funnel based on event metrics #5928

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

akkomar
Copy link
Collaborator

@akkomar akkomar commented Jul 17, 2024

Checklist for reviewer:

  • Commits should reference a bug or github issue, if relevant (if a bug is referenced, the pull request should include the bug number in the title).
  • If the PR comes from a fork, trigger integration CI tests by running the Push to upstream workflow and provide the <username>:<branch> of the fork as parameter. The parameter will also show up
    in the logs of the manual-trigger-required-for-fork CI task together with more detailed instructions.
  • If adding a new field to a query, ensure that the schema and dependent downstream schemas have been updated.
  • When adding a new derived dataset, ensure that data is not available already (fully or partially) and recommend extending an existing dataset in favor of creating new ones. Data can be available in the bigquery-etl repository, looker-hub or in looker-spoke-default.

For modifications to schemas in restricted namespaces (see CODEOWNERS):

┆Issue is synchronized with this Jira Task

@dataops-ci-bot
Copy link

Integration report for "Fix template"

sql.diff

Click to expand!
Only in /tmp/workspace/main-generated-sql/dags/: bqetl_firefox_desktop_ad_click_history.py
diff -bur --no-dereference --new-file /tmp/workspace/main-generated-sql/dags/bqetl_analytics_aggregations.py /tmp/workspace/generated-sql/dags/bqetl_analytics_aggregations.py
--- /tmp/workspace/main-generated-sql/dags/bqetl_analytics_aggregations.py	2024-07-17 16:52:09.000000000 +0000
+++ /tmp/workspace/generated-sql/dags/bqetl_analytics_aggregations.py	2024-07-17 17:12:49.000000000 +0000
@@ -440,6 +440,20 @@
         retries=0,
     )
 
+    with TaskGroup(
+        "checks__fail_fenix_derived__active_users_aggregates__v3_external",
+    ) as checks__fail_fenix_derived__active_users_aggregates__v3_external:
+        ExternalTaskMarker(
+            task_id="bqetl_search_dashboard__wait_for_checks__fail_fenix_derived__active_users_aggregates__v3",
+            external_dag_id="bqetl_search_dashboard",
+            external_task_id="wait_for_checks__fail_fenix_derived__active_users_aggregates__v3",
+            execution_date="{{ (execution_date - macros.timedelta(days=-1, seconds=85500)).isoformat() }}",
+        )
+
+        checks__fail_fenix_derived__active_users_aggregates__v3_external.set_upstream(
+            checks__fail_fenix_derived__active_users_aggregates__v3
+        )
+
     checks__fail_firefox_ios_derived__active_users_aggregates__v3 = bigquery_dq_check(
         task_id="checks__fail_firefox_ios_derived__active_users_aggregates__v3",
         source_table='active_users_aggregates_v3${{ macros.ds_format(macros.ds_add(ds, -1), "%Y-%m-%d", "%Y%m%d") }}',
@@ -457,6 +471,20 @@
         retries=0,
     )
 
+    with TaskGroup(
+        "checks__fail_firefox_ios_derived__active_users_aggregates__v3_external",
+    ) as checks__fail_firefox_ios_derived__active_users_aggregates__v3_external:
+        ExternalTaskMarker(
+            task_id="bqetl_search_dashboard__wait_for_checks__fail_firefox_ios_derived__active_users_aggregates__v3",
+            external_dag_id="bqetl_search_dashboard",
+            external_task_id="wait_for_checks__fail_firefox_ios_derived__active_users_aggregates__v3",
+            execution_date="{{ (execution_date - macros.timedelta(days=-1, seconds=85500)).isoformat() }}",
+        )
+
+        checks__fail_firefox_ios_derived__active_users_aggregates__v3_external.set_upstream(
+            checks__fail_firefox_ios_derived__active_users_aggregates__v3
+        )
+
     checks__fail_focus_android_derived__active_users_aggregates__v3 = bigquery_dq_check(
         task_id="checks__fail_focus_android_derived__active_users_aggregates__v3",
         source_table='active_users_aggregates_v3${{ macros.ds_format(macros.ds_add(ds, -1), "%Y-%m-%d", "%Y%m%d") }}',
@@ -474,6 +502,20 @@
         retries=0,
     )
 
+    with TaskGroup(
+        "checks__fail_focus_android_derived__active_users_aggregates__v3_external",
+    ) as checks__fail_focus_android_derived__active_users_aggregates__v3_external:
+        ExternalTaskMarker(
+            task_id="bqetl_search_dashboard__wait_for_checks__fail_focus_android_derived__active_users_aggregates__v3",
+            external_dag_id="bqetl_search_dashboard",
+            external_task_id="wait_for_checks__fail_focus_android_derived__active_users_aggregates__v3",
+            execution_date="{{ (execution_date - macros.timedelta(days=-1, seconds=85500)).isoformat() }}",
+        )
+
+        checks__fail_focus_android_derived__active_users_aggregates__v3_external.set_upstream(
+            checks__fail_focus_android_derived__active_users_aggregates__v3
+        )
+
     checks__fail_focus_ios_derived__active_users_aggregates__v3 = bigquery_dq_check(
         task_id="checks__fail_focus_ios_derived__active_users_aggregates__v3",
         source_table='active_users_aggregates_v3${{ macros.ds_format(macros.ds_add(ds, -1), "%Y-%m-%d", "%Y%m%d") }}',
@@ -491,6 +533,20 @@
         retries=0,
     )
 
+    with TaskGroup(
+        "checks__fail_focus_ios_derived__active_users_aggregates__v3_external",
+    ) as checks__fail_focus_ios_derived__active_users_aggregates__v3_external:
+        ExternalTaskMarker(
+            task_id="bqetl_search_dashboard__wait_for_checks__fail_focus_ios_derived__active_users_aggregates__v3",
+            external_dag_id="bqetl_search_dashboard",
+            external_task_id="wait_for_checks__fail_focus_ios_derived__active_users_aggregates__v3",
+            execution_date="{{ (execution_date - macros.timedelta(days=-1, seconds=85500)).isoformat() }}",
+        )
+
+        checks__fail_focus_ios_derived__active_users_aggregates__v3_external.set_upstream(
+            checks__fail_focus_ios_derived__active_users_aggregates__v3
+        )
+
     checks__fail_klar_android_derived__active_users_aggregates__v3 = bigquery_dq_check(
         task_id="checks__fail_klar_android_derived__active_users_aggregates__v3",
         source_table='active_users_aggregates_v3${{ macros.ds_format(macros.ds_add(ds, -1), "%Y-%m-%d", "%Y%m%d") }}',
@@ -508,6 +564,20 @@
         retries=0,
     )
 
+    with TaskGroup(
+        "checks__fail_klar_android_derived__active_users_aggregates__v3_external",
+    ) as checks__fail_klar_android_derived__active_users_aggregates__v3_external:
+        ExternalTaskMarker(
+            task_id="bqetl_search_dashboard__wait_for_checks__fail_klar_android_derived__active_users_aggregates__v3",
+            external_dag_id="bqetl_search_dashboard",
+            external_task_id="wait_for_checks__fail_klar_android_derived__active_users_aggregates__v3",
+            execution_date="{{ (execution_date - macros.timedelta(days=-1, seconds=85500)).isoformat() }}",
+        )
+
+        checks__fail_klar_android_derived__active_users_aggregates__v3_external.set_upstream(
+            checks__fail_klar_android_derived__active_users_aggregates__v3
+        )
+
     checks__fail_klar_ios_derived__active_users_aggregates__v3 = bigquery_dq_check(
         task_id="checks__fail_klar_ios_derived__active_users_aggregates__v3",
         source_table='active_users_aggregates_v3${{ macros.ds_format(macros.ds_add(ds, -1), "%Y-%m-%d", "%Y%m%d") }}',
@@ -525,6 +595,20 @@
         retries=0,
     )
 
+    with TaskGroup(
+        "checks__fail_klar_ios_derived__active_users_aggregates__v3_external",
+    ) as checks__fail_klar_ios_derived__active_users_aggregates__v3_external:
+        ExternalTaskMarker(
+            task_id="bqetl_search_dashboard__wait_for_checks__fail_klar_ios_derived__active_users_aggregates__v3",
+            external_dag_id="bqetl_search_dashboard",
+            external_task_id="wait_for_checks__fail_klar_ios_derived__active_users_aggregates__v3",
+            execution_date="{{ (execution_date - macros.timedelta(days=-1, seconds=85500)).isoformat() }}",
+        )
+
+        checks__fail_klar_ios_derived__active_users_aggregates__v3_external.set_upstream(
+            checks__fail_klar_ios_derived__active_users_aggregates__v3
+        )
+
     checks__warn_fenix_derived__active_users_aggregates__v3 = bigquery_dq_check(
         task_id="checks__warn_fenix_derived__active_users_aggregates__v3",
         source_table='active_users_aggregates_v3${{ macros.ds_format(macros.ds_add(ds, -1), "%Y-%m-%d", "%Y%m%d") }}',
@@ -676,6 +760,20 @@
         parameters=["submission_date:DATE:{{macros.ds_add(ds, -1)}}"],
     )
 
+    with TaskGroup(
+        "firefox_desktop_active_users_aggregates_external",
+    ) as firefox_desktop_active_users_aggregates_external:
+        ExternalTaskMarker(
+            task_id="bqetl_search_dashboard__wait_for_firefox_desktop_active_users_aggregates",
+            external_dag_id="bqetl_search_dashboard",
+            external_task_id="wait_for_firefox_desktop_active_users_aggregates",
+            execution_date="{{ (execution_date - macros.timedelta(days=-1, seconds=85500)).isoformat() }}",
+        )
+
+        firefox_desktop_active_users_aggregates_external.set_upstream(
+            firefox_desktop_active_users_aggregates
+        )
+
     firefox_ios_active_users_aggregates = bigquery_etl_query(
         task_id="firefox_ios_active_users_aggregates",
         destination_table='active_users_aggregates_v3${{ macros.ds_format(macros.ds_add(ds, -1), "%Y-%m-%d", "%Y%m%d") }}',
diff -bur --no-dereference --new-file /tmp/workspace/main-generated-sql/dags/bqetl_firefox_desktop_ad_click_history.py /tmp/workspace/generated-sql/dags/bqetl_firefox_desktop_ad_click_history.py
--- /tmp/workspace/main-generated-sql/dags/bqetl_firefox_desktop_ad_click_history.py	2024-07-17 16:52:09.000000000 +0000
+++ /tmp/workspace/generated-sql/dags/bqetl_firefox_desktop_ad_click_history.py	1970-01-01 00:00:00.000000000 +0000
@@ -1,99 +0,0 @@
-# Generated via https://github.com/mozilla/bigquery-etl/blob/main/bigquery_etl/query_scheduling/generate_airflow_dags.py
-
-from airflow import DAG
-from airflow.sensors.external_task import ExternalTaskMarker
-from airflow.sensors.external_task import ExternalTaskSensor
-from airflow.utils.task_group import TaskGroup
-import datetime
-from operators.gcp_container_operator import GKEPodOperator
-from utils.constants import ALLOWED_STATES, FAILED_STATES
-from utils.gcp import bigquery_etl_query, bigquery_dq_check
-
-docs = """
-### bqetl_firefox_desktop_ad_click_history
-
-Built from bigquery-etl repo, [`dags/bqetl_firefox_desktop_ad_click_history.py`](https://github.com/mozilla/bigquery-etl/blob/generated-sql/dags/bqetl_firefox_desktop_ad_click_history.py)
-
-#### Description
-
-Calculates # of historical ad clicks for Firefox Desktop clients
-
-#### Owner
-
-[email protected]
-
-#### Tags
-
-* impact/tier_2
-* repo/bigquery-etl
-"""
-
-
-default_args = {
-    "owner": "[email protected]",
-    "start_date": datetime.datetime(2024, 7, 16, 0, 0),
-    "end_date": None,
-    "email": ["[email protected]", "[email protected]"],
-    "depends_on_past": False,
-    "retry_delay": datetime.timedelta(seconds=1800),
-    "email_on_failure": True,
-    "email_on_retry": False,
-    "retries": 2,
-}
-
-tags = ["impact/tier_2", "repo/bigquery-etl"]
-
-with DAG(
-    "bqetl_firefox_desktop_ad_click_history",
-    default_args=default_args,
-    schedule_interval="0 16 * * *",
-    doc_md=docs,
-    tags=tags,
-) as dag:
-
-    wait_for_search_derived__search_clients_daily__v8 = ExternalTaskSensor(
-        task_id="wait_for_search_derived__search_clients_daily__v8",
-        external_dag_id="bqetl_search",
-        external_task_id="search_derived__search_clients_daily__v8",
-        execution_delta=datetime.timedelta(seconds=46800),
-        check_existence=True,
-        mode="reschedule",
-        allowed_states=ALLOWED_STATES,
-        failed_states=FAILED_STATES,
-        pool="DATA_ENG_EXTERNALTASKSENSOR",
-    )
-
-    checks__fail_firefox_desktop_derived__adclick_history__v1 = bigquery_dq_check(
-        task_id="checks__fail_firefox_desktop_derived__adclick_history__v1",
-        source_table="adclick_history_v1",
-        dataset_id="firefox_desktop_derived",
-        project_id="moz-fx-data-shared-prod",
-        is_dq_check_fail=True,
-        owner="[email protected]",
-        email=["[email protected]", "[email protected]"],
-        depends_on_past=False,
-        task_concurrency=1,
-        parameters=["submission_date:DATE:{{ds}}"],
-        retries=0,
-    )
-
-    firefox_desktop_derived__adclick_history__v1 = bigquery_etl_query(
-        task_id="firefox_desktop_derived__adclick_history__v1",
-        destination_table="adclick_history_v1",
-        dataset_id="firefox_desktop_derived",
-        project_id="moz-fx-data-shared-prod",
-        owner="[email protected]",
-        email=["[email protected]", "[email protected]"],
-        date_partition_parameter=None,
-        depends_on_past=False,
-        task_concurrency=1,
-        parameters=["submission_date:DATE:{{ds}}"],
-    )
-
-    checks__fail_firefox_desktop_derived__adclick_history__v1.set_upstream(
-        firefox_desktop_derived__adclick_history__v1
-    )
-
-    firefox_desktop_derived__adclick_history__v1.set_upstream(
-        wait_for_search_derived__search_clients_daily__v8
-    )
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-07-17 16:52:09.000000000 +0000
+++ /tmp/workspace/generated-sql/dags/bqetl_generated_funnels.py	2024-07-17 17:12:49.000000000 +0000
@@ -63,6 +63,30 @@
         pool="DATA_ENG_EXTERNALTASKSENSOR",
     )
 
+    wait_for_accounts_backend_derived__events_stream__v1 = ExternalTaskSensor(
+        task_id="wait_for_accounts_backend_derived__events_stream__v1",
+        external_dag_id="bqetl_glean_usage",
+        external_task_id="accounts_backend.accounts_backend_derived__events_stream__v1",
+        execution_delta=datetime.timedelta(seconds=10800),
+        check_existence=True,
+        mode="reschedule",
+        allowed_states=ALLOWED_STATES,
+        failed_states=FAILED_STATES,
+        pool="DATA_ENG_EXTERNALTASKSENSOR",
+    )
+
+    wait_for_accounts_frontend_derived__events_stream__v1 = ExternalTaskSensor(
+        task_id="wait_for_accounts_frontend_derived__events_stream__v1",
+        external_dag_id="bqetl_glean_usage",
+        external_task_id="accounts_frontend.accounts_frontend_derived__events_stream__v1",
+        execution_delta=datetime.timedelta(seconds=10800),
+        check_existence=True,
+        mode="reschedule",
+        allowed_states=ALLOWED_STATES,
+        failed_states=FAILED_STATES,
+        pool="DATA_ENG_EXTERNALTASKSENSOR",
+    )
+
     wait_for_checks__fail_fenix_derived__firefox_android_clients__v1 = (
         ExternalTaskSensor(
             task_id="wait_for_checks__fail_fenix_derived__firefox_android_clients__v1",
@@ -170,6 +194,21 @@
         depends_on_past=False,
     )
 
+    accounts_frontend_derived__login_funnels_by_service__v2 = bigquery_etl_query(
+        task_id="accounts_frontend_derived__login_funnels_by_service__v2",
+        destination_table="login_funnels_by_service_v2",
+        dataset_id="accounts_frontend_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,
+    )
+
     accounts_frontend_derived__monitor_mozilla_accounts_funnels__v1 = (
         bigquery_etl_query(
             task_id="accounts_frontend_derived__monitor_mozilla_accounts_funnels__v1",
@@ -249,6 +288,21 @@
         )
     )
 
+    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",
+        dataset_id="monitor_frontend_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,
+    )
+
     accounts_frontend_derived__email_first_reg_login_funnels__v1.set_upstream(
         wait_for_copy_deduplicate_all
     )
@@ -261,6 +315,14 @@
         wait_for_copy_deduplicate_all
     )
 
+    accounts_frontend_derived__login_funnels_by_service__v2.set_upstream(
+        wait_for_accounts_backend_derived__events_stream__v1
+    )
+
+    accounts_frontend_derived__login_funnels_by_service__v2.set_upstream(
+        wait_for_accounts_frontend_derived__events_stream__v1
+    )
+
     accounts_frontend_derived__monitor_mozilla_accounts_funnels__v1.set_upstream(
         wait_for_copy_deduplicate_all
     )
@@ -294,3 +356,7 @@
     firefox_accounts_derived__registration_funnels_legacy_events__v1.set_upstream(
         wait_for_firefox_accounts_derived__fxa_stdout_events__v1
     )
+
+    monitor_frontend_derived__monitor_dashboard_user_journey_funnels__v1.set_upstream(
+        wait_for_copy_deduplicate_all
+    )
diff -bur --no-dereference --new-file /tmp/workspace/main-generated-sql/dags/bqetl_search_dashboard.py /tmp/workspace/generated-sql/dags/bqetl_search_dashboard.py
--- /tmp/workspace/main-generated-sql/dags/bqetl_search_dashboard.py	2024-07-17 16:52:09.000000000 +0000
+++ /tmp/workspace/generated-sql/dags/bqetl_search_dashboard.py	2024-07-17 17:12:47.000000000 +0000
@@ -83,119 +83,25 @@
         pool="DATA_ENG_EXTERNALTASKSENSOR",
     )
 
-    wait_for_checks__fail_org_mozilla_fenix_derived__baseline_clients_last_seen__v1 = ExternalTaskSensor(
-        task_id="wait_for_checks__fail_org_mozilla_fenix_derived__baseline_clients_last_seen__v1",
-        external_dag_id="bqetl_glean_usage",
-        external_task_id="fenix.checks__fail_org_mozilla_fenix_derived__baseline_clients_last_seen__v1",
-        execution_delta=datetime.timedelta(seconds=9000),
+    wait_for_checks__fail_fenix_derived__active_users_aggregates__v3 = (
+        ExternalTaskSensor(
+            task_id="wait_for_checks__fail_fenix_derived__active_users_aggregates__v3",
+            external_dag_id="bqetl_analytics_aggregations",
+            external_task_id="checks__fail_fenix_derived__active_users_aggregates__v3",
+            execution_delta=datetime.timedelta(seconds=900),
         check_existence=True,
         mode="reschedule",
         allowed_states=ALLOWED_STATES,
         failed_states=FAILED_STATES,
         pool="DATA_ENG_EXTERNALTASKSENSOR",
     )
-
-    wait_for_checks__fail_org_mozilla_fenix_nightly_derived__baseline_clients_last_seen__v1 = ExternalTaskSensor(
-        task_id="wait_for_checks__fail_org_mozilla_fenix_nightly_derived__baseline_clients_last_seen__v1",
-        external_dag_id="bqetl_glean_usage",
-        external_task_id="fenix.checks__fail_org_mozilla_fenix_nightly_derived__baseline_clients_last_seen__v1",
-        execution_delta=datetime.timedelta(seconds=9000),
-        check_existence=True,
-        mode="reschedule",
-        allowed_states=ALLOWED_STATES,
-        failed_states=FAILED_STATES,
-        pool="DATA_ENG_EXTERNALTASKSENSOR",
-    )
-
-    wait_for_checks__fail_org_mozilla_fennec_aurora_derived__baseline_clients_last_seen__v1 = ExternalTaskSensor(
-        task_id="wait_for_checks__fail_org_mozilla_fennec_aurora_derived__baseline_clients_last_seen__v1",
-        external_dag_id="bqetl_glean_usage",
-        external_task_id="fenix.checks__fail_org_mozilla_fennec_aurora_derived__baseline_clients_last_seen__v1",
-        execution_delta=datetime.timedelta(seconds=9000),
-        check_existence=True,
-        mode="reschedule",
-        allowed_states=ALLOWED_STATES,
-        failed_states=FAILED_STATES,
-        pool="DATA_ENG_EXTERNALTASKSENSOR",
-    )
-
-    wait_for_checks__fail_org_mozilla_firefox_beta_derived__baseline_clients_last_seen__v1 = ExternalTaskSensor(
-        task_id="wait_for_checks__fail_org_mozilla_firefox_beta_derived__baseline_clients_last_seen__v1",
-        external_dag_id="bqetl_glean_usage",
-        external_task_id="fenix.checks__fail_org_mozilla_firefox_beta_derived__baseline_clients_last_seen__v1",
-        execution_delta=datetime.timedelta(seconds=9000),
-        check_existence=True,
-        mode="reschedule",
-        allowed_states=ALLOWED_STATES,
-        failed_states=FAILED_STATES,
-        pool="DATA_ENG_EXTERNALTASKSENSOR",
-    )
-
-    wait_for_checks__fail_org_mozilla_firefox_derived__baseline_clients_last_seen__v1 = ExternalTaskSensor(
-        task_id="wait_for_checks__fail_org_mozilla_firefox_derived__baseline_clients_last_seen__v1",
-        external_dag_id="bqetl_glean_usage",
-        external_task_id="fenix.checks__fail_org_mozilla_firefox_derived__baseline_clients_last_seen__v1",
-        execution_delta=datetime.timedelta(seconds=9000),
-        check_existence=True,
-        mode="reschedule",
-        allowed_states=ALLOWED_STATES,
-        failed_states=FAILED_STATES,
-        pool="DATA_ENG_EXTERNALTASKSENSOR",
-    )
-
-    wait_for_checks__fail_org_mozilla_focus_beta_derived__baseline_clients_last_seen__v1 = ExternalTaskSensor(
-        task_id="wait_for_checks__fail_org_mozilla_focus_beta_derived__baseline_clients_last_seen__v1",
-        external_dag_id="bqetl_glean_usage",
-        external_task_id="focus_android.checks__fail_org_mozilla_focus_beta_derived__baseline_clients_last_seen__v1",
-        execution_delta=datetime.timedelta(seconds=9000),
-        check_existence=True,
-        mode="reschedule",
-        allowed_states=ALLOWED_STATES,
-        failed_states=FAILED_STATES,
-        pool="DATA_ENG_EXTERNALTASKSENSOR",
-    )
-
-    wait_for_checks__fail_org_mozilla_focus_derived__baseline_clients_last_seen__v1 = ExternalTaskSensor(
-        task_id="wait_for_checks__fail_org_mozilla_focus_derived__baseline_clients_last_seen__v1",
-        external_dag_id="bqetl_glean_usage",
-        external_task_id="focus_android.checks__fail_org_mozilla_focus_derived__baseline_clients_last_seen__v1",
-        execution_delta=datetime.timedelta(seconds=9000),
-        check_existence=True,
-        mode="reschedule",
-        allowed_states=ALLOWED_STATES,
-        failed_states=FAILED_STATES,
-        pool="DATA_ENG_EXTERNALTASKSENSOR",
-    )
-
-    wait_for_checks__fail_org_mozilla_focus_nightly_derived__baseline_clients_last_seen__v1 = ExternalTaskSensor(
-        task_id="wait_for_checks__fail_org_mozilla_focus_nightly_derived__baseline_clients_last_seen__v1",
-        external_dag_id="bqetl_glean_usage",
-        external_task_id="focus_android.checks__fail_org_mozilla_focus_nightly_derived__baseline_clients_last_seen__v1",
-        execution_delta=datetime.timedelta(seconds=9000),
-        check_existence=True,
-        mode="reschedule",
-        allowed_states=ALLOWED_STATES,
-        failed_states=FAILED_STATES,
-        pool="DATA_ENG_EXTERNALTASKSENSOR",
-    )
-
-    wait_for_checks__fail_org_mozilla_ios_fennec_derived__baseline_clients_last_seen__v1 = ExternalTaskSensor(
-        task_id="wait_for_checks__fail_org_mozilla_ios_fennec_derived__baseline_clients_last_seen__v1",
-        external_dag_id="bqetl_glean_usage",
-        external_task_id="firefox_ios.checks__fail_org_mozilla_ios_fennec_derived__baseline_clients_last_seen__v1",
-        execution_delta=datetime.timedelta(seconds=9000),
-        check_existence=True,
-        mode="reschedule",
-        allowed_states=ALLOWED_STATES,
-        failed_states=FAILED_STATES,
-        pool="DATA_ENG_EXTERNALTASKSENSOR",
     )
 
-    wait_for_checks__fail_org_mozilla_ios_firefox_derived__baseline_clients_last_seen__v1 = ExternalTaskSensor(
-        task_id="wait_for_checks__fail_org_mozilla_ios_firefox_derived__baseline_clients_last_seen__v1",
-        external_dag_id="bqetl_glean_usage",
-        external_task_id="firefox_ios.checks__fail_org_mozilla_ios_firefox_derived__baseline_clients_last_seen__v1",
-        execution_delta=datetime.timedelta(seconds=9000),
+    wait_for_checks__fail_firefox_ios_derived__active_users_aggregates__v3 = ExternalTaskSensor(
+        task_id="wait_for_checks__fail_firefox_ios_derived__active_users_aggregates__v3",
+        external_dag_id="bqetl_analytics_aggregations",
+        external_task_id="checks__fail_firefox_ios_derived__active_users_aggregates__v3",
+        execution_delta=datetime.timedelta(seconds=900),
         check_existence=True,
         mode="reschedule",
         allowed_states=ALLOWED_STATES,
@@ -203,11 +109,11 @@
         pool="DATA_ENG_EXTERNALTASKSENSOR",
     )
 
-    wait_for_checks__fail_org_mozilla_ios_firefoxbeta_derived__baseline_clients_last_seen__v1 = ExternalTaskSensor(
-        task_id="wait_for_checks__fail_org_mozilla_ios_firefoxbeta_derived__baseline_clients_last_seen__v1",
-        external_dag_id="bqetl_glean_usage",
-        external_task_id="firefox_ios.checks__fail_org_mozilla_ios_firefoxbeta_derived__baseline_clients_last_seen__v1",
-        execution_delta=datetime.timedelta(seconds=9000),
+    wait_for_checks__fail_focus_android_derived__active_users_aggregates__v3 = ExternalTaskSensor(
+        task_id="wait_for_checks__fail_focus_android_derived__active_users_aggregates__v3",
+        external_dag_id="bqetl_analytics_aggregations",
+        external_task_id="checks__fail_focus_android_derived__active_users_aggregates__v3",
+        execution_delta=datetime.timedelta(seconds=900),
         check_existence=True,
         mode="reschedule",
         allowed_states=ALLOWED_STATES,
@@ -215,11 +121,11 @@
         pool="DATA_ENG_EXTERNALTASKSENSOR",
     )
 
-    wait_for_checks__fail_org_mozilla_ios_focus_derived__baseline_clients_last_seen__v1 = ExternalTaskSensor(
-        task_id="wait_for_checks__fail_org_mozilla_ios_focus_derived__baseline_clients_last_seen__v1",
-        external_dag_id="bqetl_glean_usage",
-        external_task_id="focus_ios.checks__fail_org_mozilla_ios_focus_derived__baseline_clients_last_seen__v1",
-        execution_delta=datetime.timedelta(seconds=9000),
+    wait_for_checks__fail_focus_ios_derived__active_users_aggregates__v3 = ExternalTaskSensor(
+        task_id="wait_for_checks__fail_focus_ios_derived__active_users_aggregates__v3",
+        external_dag_id="bqetl_analytics_aggregations",
+        external_task_id="checks__fail_focus_ios_derived__active_users_aggregates__v3",
+        execution_delta=datetime.timedelta(seconds=900),
         check_existence=True,
         mode="reschedule",
         allowed_states=ALLOWED_STATES,
@@ -227,11 +133,11 @@
         pool="DATA_ENG_EXTERNALTASKSENSOR",
     )
 
-    wait_for_checks__fail_org_mozilla_ios_klar_derived__baseline_clients_last_seen__v1 = ExternalTaskSensor(
-        task_id="wait_for_checks__fail_org_mozilla_ios_klar_derived__baseline_clients_last_seen__v1",
-        external_dag_id="bqetl_glean_usage",
-        external_task_id="klar_ios.checks__fail_org_mozilla_ios_klar_derived__baseline_clients_last_seen__v1",
-        execution_delta=datetime.timedelta(seconds=9000),
+    wait_for_checks__fail_klar_android_derived__active_users_aggregates__v3 = ExternalTaskSensor(
+        task_id="wait_for_checks__fail_klar_android_derived__active_users_aggregates__v3",
+        external_dag_id="bqetl_analytics_aggregations",
+        external_task_id="checks__fail_klar_android_derived__active_users_aggregates__v3",
+        execution_delta=datetime.timedelta(seconds=900),
         check_existence=True,
         mode="reschedule",
         allowed_states=ALLOWED_STATES,
@@ -239,11 +145,11 @@
         pool="DATA_ENG_EXTERNALTASKSENSOR",
     )
 
-    wait_for_checks__fail_org_mozilla_klar_derived__baseline_clients_last_seen__v1 = ExternalTaskSensor(
-        task_id="wait_for_checks__fail_org_mozilla_klar_derived__baseline_clients_last_seen__v1",
-        external_dag_id="bqetl_glean_usage",
-        external_task_id="klar_android.checks__fail_org_mozilla_klar_derived__baseline_clients_last_seen__v1",
-        execution_delta=datetime.timedelta(seconds=9000),
+    wait_for_checks__fail_klar_ios_derived__active_users_aggregates__v3 = ExternalTaskSensor(
+        task_id="wait_for_checks__fail_klar_ios_derived__active_users_aggregates__v3",
+        external_dag_id="bqetl_analytics_aggregations",
+        external_task_id="checks__fail_klar_ios_derived__active_users_aggregates__v3",
+        execution_delta=datetime.timedelta(seconds=900),
         check_existence=True,
         mode="reschedule",
         allowed_states=ALLOWED_STATES,
@@ -251,11 +157,11 @@
         pool="DATA_ENG_EXTERNALTASKSENSOR",
     )
 
-    wait_for_copy_deduplicate_all = ExternalTaskSensor(
-        task_id="wait_for_copy_deduplicate_all",
-        external_dag_id="copy_deduplicate",
-        external_task_id="copy_deduplicate_all",
-        execution_delta=datetime.timedelta(seconds=12600),
+    wait_for_firefox_desktop_active_users_aggregates = ExternalTaskSensor(
+        task_id="wait_for_firefox_desktop_active_users_aggregates",
+        external_dag_id="bqetl_analytics_aggregations",
+        external_task_id="firefox_desktop_active_users_aggregates",
+        execution_delta=datetime.timedelta(seconds=900),
         check_existence=True,
         mode="reschedule",
         allowed_states=ALLOWED_STATES,
@@ -325,13 +231,19 @@
 
     search_derived__search_revenue_levers_daily__v1 = bigquery_etl_query(
         task_id="search_derived__search_revenue_levers_daily__v1",
-        destination_table="search_revenue_levers_daily_v1",
+        destination_table='search_revenue_levers_daily_v1${{ macros.ds_format(macros.ds_add(ds, -1), "%Y-%m-%d", "%Y%m%d") }}',
         dataset_id="search_derived",
         project_id="moz-fx-data-shared-prod",
-        owner="mozilla/revenue_forecasting_data_reviewers",
-        email=["[email protected]", "[email protected]"],
-        date_partition_parameter="submission_date",
+        owner="[email protected]",
+        email=[
+            "[email protected]",
+            "[email protected]",
+            "[email protected]",
+            "[email protected]",
+        ],
+        date_partition_parameter=None,
         depends_on_past=False,
+        parameters=["submission_date:DATE:{{macros.ds_add(ds, -1)}}"],
     )
 
     search_derived__desktop_search_aggregates_by_userstate__v1.set_upstream(
@@ -347,63 +259,31 @@
     )
 
     search_derived__search_revenue_levers_daily__v1.set_upstream(
-        wait_for_checks__fail_org_mozilla_fenix_derived__baseline_clients_last_seen__v1
-    )
-
-    search_derived__search_revenue_levers_daily__v1.set_upstream(
-        wait_for_checks__fail_org_mozilla_fenix_nightly_derived__baseline_clients_last_seen__v1
-    )
-
-    search_derived__search_revenue_levers_daily__v1.set_upstream(
-        wait_for_checks__fail_org_mozilla_fennec_aurora_derived__baseline_clients_last_seen__v1
-    )
-
-    search_derived__search_revenue_levers_daily__v1.set_upstream(
-        wait_for_checks__fail_org_mozilla_firefox_beta_derived__baseline_clients_last_seen__v1
-    )
-
-    search_derived__search_revenue_levers_daily__v1.set_upstream(
-        wait_for_checks__fail_org_mozilla_firefox_derived__baseline_clients_last_seen__v1
-    )
-
-    search_derived__search_revenue_levers_daily__v1.set_upstream(
-        wait_for_checks__fail_org_mozilla_focus_beta_derived__baseline_clients_last_seen__v1
-    )
-
-    search_derived__search_revenue_levers_daily__v1.set_upstream(
-        wait_for_checks__fail_org_mozilla_focus_derived__baseline_clients_last_seen__v1
-    )
-
-    search_derived__search_revenue_levers_daily__v1.set_upstream(
-        wait_for_checks__fail_org_mozilla_focus_nightly_derived__baseline_clients_last_seen__v1
-    )
-
-    search_derived__search_revenue_levers_daily__v1.set_upstream(
-        wait_for_checks__fail_org_mozilla_ios_fennec_derived__baseline_clients_last_seen__v1
+        wait_for_checks__fail_fenix_derived__active_users_aggregates__v3
     )
 
     search_derived__search_revenue_levers_daily__v1.set_upstream(
-        wait_for_checks__fail_org_mozilla_ios_firefox_derived__baseline_clients_last_seen__v1
+        wait_for_checks__fail_firefox_ios_derived__active_users_aggregates__v3
     )
 
     search_derived__search_revenue_levers_daily__v1.set_upstream(
-        wait_for_checks__fail_org_mozilla_ios_firefoxbeta_derived__baseline_clients_last_seen__v1
+        wait_for_checks__fail_focus_android_derived__active_users_aggregates__v3
     )
 
     search_derived__search_revenue_levers_daily__v1.set_upstream(
-        wait_for_checks__fail_org_mozilla_ios_focus_derived__baseline_clients_last_seen__v1
+        wait_for_checks__fail_focus_ios_derived__active_users_aggregates__v3
     )
 
     search_derived__search_revenue_levers_daily__v1.set_upstream(
-        wait_for_checks__fail_org_mozilla_ios_klar_derived__baseline_clients_last_seen__v1
+        wait_for_checks__fail_klar_android_derived__active_users_aggregates__v3
     )
 
     search_derived__search_revenue_levers_daily__v1.set_upstream(
-        wait_for_checks__fail_org_mozilla_klar_derived__baseline_clients_last_seen__v1
+        wait_for_checks__fail_klar_ios_derived__active_users_aggregates__v3
     )
 
     search_derived__search_revenue_levers_daily__v1.set_upstream(
-        wait_for_copy_deduplicate_all
+        wait_for_firefox_desktop_active_users_aggregates
     )
 
     search_derived__search_revenue_levers_daily__v1.set_upstream(
diff -bur --no-dereference --new-file /tmp/workspace/main-generated-sql/dags/bqetl_search.py /tmp/workspace/generated-sql/dags/bqetl_search.py
--- /tmp/workspace/main-generated-sql/dags/bqetl_search.py	2024-07-17 16:52:09.000000000 +0000
+++ /tmp/workspace/generated-sql/dags/bqetl_search.py	2024-07-17 17:12:46.000000000 +0000
@@ -146,13 +146,6 @@
         )
 
         ExternalTaskMarker(
-            task_id="bqetl_firefox_desktop_ad_click_history__wait_for_search_derived__search_clients_daily__v8",
-            external_dag_id="bqetl_firefox_desktop_ad_click_history",
-            external_task_id="wait_for_search_derived__search_clients_daily__v8",
-            execution_date="{{ (execution_date - macros.timedelta(days=-1, seconds=39600)).isoformat() }}",
-        )
-
-        ExternalTaskMarker(
             task_id="bqetl_review_checker__wait_for_search_derived__search_clients_daily__v8",
             external_dag_id="bqetl_review_checker",
             external_task_id="wait_for_search_derived__search_clients_daily__v8",
Only in /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/accounts_frontend_derived: login_funnels_by_service_v2
Only in /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/firefox_desktop: adclick_history
Only in /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/firefox_desktop_derived: adclick_history_v1
Only in /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/org_mozilla_fenix_nightly/deletion_request: schema.yaml
Only in /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/org_mozilla_fenix_nightly/pageload: schema.yaml
Only in /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/org_mozilla_firefox_beta/crash: schema.yaml
Only in /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/search_derived/search_revenue_levers_daily_v1: backfill.yaml
diff -bur --no-dereference --new-file /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/accounts_backend_derived/users_services_daily_v1/checks.sql /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/accounts_backend_derived/users_services_daily_v1/checks.sql
--- /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/accounts_backend_derived/users_services_daily_v1/checks.sql	2024-07-17 16:46:27.000000000 +0000
+++ /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/accounts_backend_derived/users_services_daily_v1/checks.sql	2024-07-17 16:47:11.000000000 +0000
@@ -136,8 +136,8 @@
       'cad_mobile_pair_use_app_view'
     )
     AND (
-      (events_new.count_new IS NULL AND events_old.count_old > 10) -- ignore erroneous event names
-      OR (events_old.count_old IS NULL AND events_new.count_new > 10)
+      (events_new.count_new IS NULL AND events_old.count_old > 1) -- ignore erroneous event names
+      OR (events_old.count_old IS NULL AND events_new.count_new > 1)
       OR ABS(events_new.count_new - events_old.count_old) / LEAST(
         events_new.count_new,
         events_old.count_old
diff -bur --no-dereference --new-file /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/accounts_frontend_derived/email_first_reg_login_funnels_by_service_v1/metadata.yaml /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/accounts_frontend_derived/email_first_reg_login_funnels_by_service_v1/metadata.yaml
--- /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/accounts_frontend_derived/email_first_reg_login_funnels_by_service_v1/metadata.yaml	2024-07-17 16:47:01.000000000 +0000
+++ /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/accounts_frontend_derived/email_first_reg_login_funnels_by_service_v1/metadata.yaml	2024-07-17 17:07:10.000000000 +0000
@@ -1,4 +1,4 @@
-friendly_name: Email First Reg Login Funnels By Service
+friendly_name: Email First Reg Login Funnels By Service V1
 description: |-
   Please provide a description for the query
 owners:
diff -bur --no-dereference --new-file /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/accounts_frontend_derived/email_first_reg_login_funnels_v1/metadata.yaml /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/accounts_frontend_derived/email_first_reg_login_funnels_v1/metadata.yaml
--- /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/accounts_frontend_derived/email_first_reg_login_funnels_v1/metadata.yaml	2024-07-17 16:47:01.000000000 +0000
+++ /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/accounts_frontend_derived/email_first_reg_login_funnels_v1/metadata.yaml	2024-07-17 17:07:10.000000000 +0000
@@ -1,4 +1,4 @@
-friendly_name: Email First Reg Login Funnels
+friendly_name: Email First Reg Login Funnels V1
 description: |-
   Please provide a description for the query
 owners:
diff -bur --no-dereference --new-file /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/accounts_frontend_derived/login_funnels_by_service_v1/metadata.yaml /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/accounts_frontend_derived/login_funnels_by_service_v1/metadata.yaml
--- /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/accounts_frontend_derived/login_funnels_by_service_v1/metadata.yaml	2024-07-17 16:47:01.000000000 +0000
+++ /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/accounts_frontend_derived/login_funnels_by_service_v1/metadata.yaml	2024-07-17 17:07:10.000000000 +0000
@@ -1,4 +1,4 @@
-friendly_name: Login Funnels By Service
+friendly_name: Login Funnels By Service V1
 description: |-
   Please provide a description for the query
 owners:
diff -bur --no-dereference --new-file /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/accounts_frontend_derived/login_funnels_by_service_v2/metadata.yaml /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/accounts_frontend_derived/login_funnels_by_service_v2/metadata.yaml
--- /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/accounts_frontend_derived/login_funnels_by_service_v2/metadata.yaml	1970-01-01 00:00:00.000000000 +0000
+++ /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/accounts_frontend_derived/login_funnels_by_service_v2/metadata.yaml	2024-07-17 17:07:10.000000000 +0000
@@ -0,0 +1,27 @@
+friendly_name: Login Funnels By Service V2
+description: |-
+  Please provide a description for the query
+owners:
+- [email protected]
+labels:
+  incremental: true
+  dag: bqetl_generated_funnels
+  owner1: ksiegler
+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:
+  - mozdata.accounts_backend.events_stream
+  - mozdata.accounts_frontend.events_stream
diff -bur --no-dereference --new-file /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/accounts_frontend_derived/login_funnels_by_service_v2/query.sql /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/accounts_frontend_derived/login_funnels_by_service_v2/query.sql
--- /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/accounts_frontend_derived/login_funnels_by_service_v2/query.sql	1970-01-01 00:00:00.000000000 +0000
+++ /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/accounts_frontend_derived/login_funnels_by_service_v2/query.sql	2024-07-17 16:55:55.000000000 +0000
@@ -0,0 +1,861 @@
+-- extract the relevant fields for each funnel step and segment if necessary
+WITH login_overall_success_by_service_login_view AS (
+  SELECT
+    metrics.string.session_flow_id AS join_key,
+    IF(
+      COALESCE(
+        NULLIF(metrics.string.relying_party_oauth_client_id, ''),
+        NULLIF(metrics.string.relying_party_service, '')
+      ) = 'sync',
+      '5882386c6d801776',
+      COALESCE(
+        NULLIF(metrics.string.relying_party_oauth_client_id, ''),
+        NULLIF(metrics.string.relying_party_service, '')
+      )
+    ) AS service,
+    DATE(submission_timestamp) AS submission_date,
+    es.client_id AS client_id,
+    metrics.string.session_flow_id AS column
+  FROM
+    mozdata.accounts_frontend.events_stream AS es
+  WHERE
+    {% if is_init() %}
+      DATE(submission_timestamp) >= DATE("2024-01-01")
+    {% else %}
+      DATE(submission_timestamp) = @submission_date
+    {% endif %}
+    AND event = 'login.view'
+    AND metrics.string.session_flow_id != ''
+),
+login_overall_success_by_service_login_complete AS (
+  SELECT
+    metrics.string.session_flow_id AS join_key,
+    prev.service AS service,
+    DATE(submission_timestamp) AS submission_date,
+    es.client_id AS client_id,
+    metrics.string.session_flow_id AS column
+  FROM
+    mozdata.accounts_backend.events_stream AS es
+  INNER JOIN
+    login_overall_success_by_service_login_view AS prev
+    ON prev.submission_date = DATE(submission_timestamp)
+    AND prev.join_key = metrics.string.session_flow_id
+  WHERE
+    {% if is_init() %}
+      DATE(submission_timestamp) >= DATE("2024-01-01")
+    {% else %}
+      DATE(submission_timestamp) = @submission_date
+    {% endif %}
+    AND event = 'login.complete'
+    AND metrics.string.session_flow_id != ''
+),
+login_submit_overall_success_by_service_login_view AS (
+  SELECT
+    metrics.string.session_flow_id AS join_key,
+    IF(
+      COALESCE(
+        NULLIF(metrics.string.relying_party_oauth_client_id, ''),
+        NULLIF(metrics.string.relying_party_service, '')
+      ) = 'sync',
+      '5882386c6d801776',
+      COALESCE(
+        NULLIF(metrics.string.relying_party_oauth_client_id, ''),
+        NULLIF(metrics.string.relying_party_service, '')
+      )
+    ) AS service,
+    DATE(submission_timestamp) AS submission_date,
+    es.client_id AS client_id,
+    metrics.string.session_flow_id AS column
+  FROM
+    mozdata.accounts_frontend.events_stream AS es
+  WHERE
+    {% if is_init() %}
+      DATE(submission_timestamp) >= DATE("2024-01-01")
+    {% else %}
+      DATE(submission_timestamp) = @submission_date
+    {% endif %}
+    AND event = 'login.view'
+    AND metrics.string.session_flow_id != ''
+),
+login_submit_overall_success_by_service_login_submit AS (
+  SELECT
+    metrics.string.session_flow_id AS join_key,
+    prev.service AS service,
+    DATE(submission_timestamp) AS submission_date,
+    es.client_id AS client_id,
+    metrics.string.session_flow_id AS column
+  FROM
+    mozdata.accounts_frontend.events_stream AS es
+  INNER JOIN
+    login_submit_overall_success_by_service_login_view AS prev
+    ON prev.submission_date = DATE(submission_timestamp)
+    AND prev.join_key = metrics.string.session_flow_id
+  WHERE
+    {% if is_init() %}
+      DATE(submission_timestamp) >= DATE("2024-01-01")
+    {% else %}
+      DATE(submission_timestamp) = @submission_date
+    {% endif %}
+    AND event = 'login.submit'
+    AND metrics.string.session_flow_id != ''
+),
+login_submit_overall_success_by_service_login_success AS (
+  SELECT
+    metrics.string.session_flow_id AS join_key,
+    prev.service AS service,
+    DATE(submission_timestamp) AS submission_date,
+    es.client_id AS client_id,
+    metrics.string.session_flow_id AS column
+  FROM
+    mozdata.accounts_backend.events_stream AS es
+  INNER JOIN
+    login_submit_overall_success_by_service_login_submit AS prev
+    ON prev.submission_date = DATE(submission_timestamp)
+    AND prev.join_key = metrics.string.session_flow_id
+  WHERE
+    {% if is_init() %}
+      DATE(submission_timestamp) >= DATE("2024-01-01")
+    {% else %}
+      DATE(submission_timestamp) = @submission_date
+    {% endif %}
+    AND event = 'login.success'
+    AND metrics.string.session_flow_id != ''
+),
+login_submit_overall_success_by_service_login_complete AS (
+  SELECT
+    metrics.string.session_flow_id AS join_key,
+    prev.service AS service,
+    DATE(submission_timestamp) AS submission_date,
+    es.client_id AS client_id,
+    metrics.string.session_flow_id AS column
+  FROM
+    mozdata.accounts_backend.events_stream AS es
+  INNER JOIN
+    login_submit_overall_success_by_service_login_success AS prev
+    ON prev.submission_date = DATE(submission_timestamp)
+    AND prev.join_key = metrics.string.session_flow_id
+  WHERE
+    {% if is_init() %}
+      DATE(submission_timestamp) >= DATE("2024-01-01")
+    {% else %}
+      DATE(submission_timestamp) = @submission_date
+    {% endif %}
+    AND event = 'login.complete'
+    AND metrics.string.session_flow_id != ''
+),
+login_success_with_email_by_service_login_view AS (
+  SELECT
+    metrics.string.session_flow_id AS join_key,
+    IF(
+      COALESCE(
+        NULLIF(metrics.string.relying_party_oauth_client_id, ''),
+        NULLIF(metrics.string.relying_party_service, '')
+      ) = 'sync',
+      '5882386c6d801776',
+      COALESCE(
+        NULLIF(metrics.string.relying_party_oauth_client_id, ''),
+        NULLIF(metrics.string.relying_party_service, '')
+      )
+    ) AS service,
+    DATE(submission_timestamp) AS submission_date,
+    es.client_id AS client_id,
+    metrics.string.session_flow_id AS column
+  FROM
+    mozdata.accounts_frontend.events_stream AS es
+  WHERE
+    {% if is_init() %}
+      DATE(submission_timestamp) >= DATE("2024-01-01")
+    {% else %}
+      DATE(submission_timestamp) = @submission_date
+    {% endif %}
+    AND event = 'login.view'
+    AND metrics.string.session_flow_id != ''
+),
+login_success_with_email_by_service_login_submit AS (
+  SELECT
+    metrics.string.session_flow_id AS join_key,
+    prev.service AS service,
+    DATE(submission_timestamp) AS submission_date,
+    es.client_id AS client_id,
+    metrics.string.session_flow_id AS column
+  FROM
+    mozdata.accounts_frontend.events_stream AS es
+  INNER JOIN
+    login_success_with_email_by_service_login_view AS prev
+    ON prev.submission_date = DATE(submission_timestamp)
+    AND prev.join_key = metrics.string.session_flow_id
+  WHERE
+    {% if is_init() %}
+      DATE(submission_timestamp) >= DATE("2024-01-01")
+    {% else %}
+      DATE(submission_timestamp) = @submission_date
+    {% endif %}
+    AND event = 'login.submit'
+    AND metrics.string.session_flow_id != ''
+),
+login_success_with_email_by_service_login_success AS (
+  SELECT
+    metrics.string.session_flow_id AS join_key,
+    prev.service AS service,
+    DATE(submission_timestamp) AS submission_date,
+    es.client_id AS client_id,
+    metrics.string.session_flow_id AS column
+  FROM
+    mozdata.accounts_backend.events_stream AS es
+  INNER JOIN
+    login_success_with_email_by_service_login_submit AS prev
+    ON prev.submission_date = DATE(submission_timestamp)
+    AND prev.join_key = metrics.string.session_flow_id
+  WHERE
+    {% if is_init() %}
+      DATE(submission_timestamp) >= DATE("2024-01-01")
+    {% else %}
+      DATE(submission_timestamp) = @submission_date
+    {% endif %}
+    AND event = 'login.success'
+    AND metrics.string.session_flow_id != ''
+),
+login_success_with_email_by_service_login_email_confirmation_view AS (
+  SELECT
+    metrics.string.session_flow_id AS join_key,
+    prev.service AS service,
+    DATE(submission_timestamp) AS submission_date,
+    es.client_id AS client_id,
+    metrics.string.session_flow_id AS column
+  FROM
+    mozdata.accounts_frontend.events_stream AS es
+  INNER JOIN
+    login_success_with_email_by_service_login_success AS prev
+    ON prev.submission_date = DATE(submission_timestamp)
+    AND prev.join_key = metrics.string.session_flow_id
+  WHERE
+    {% if is_init() %}
+      DATE(submission_timestamp) >= DATE("2024-01-01")
+    {% else %}
+      DATE(submission_timestamp) = @submission_date
+    {% endif %}
+    AND event = 'login.email_confirmation_view'
+    AND metrics.string.session_flow_id != ''
+),
+login_success_with_email_by_service_login_email_confirmation_submit AS (
+  SELECT
+    metrics.string.session_flow_id AS join_key,
+    prev.service AS service,
+    DATE(submission_timestamp) AS submission_date,
+    es.client_id AS client_id,
+    metrics.string.session_flow_id AS column
+  FROM
+    mozdata.accounts_frontend.events_stream AS es
+  INNER JOIN
+    login_success_with_email_by_service_login_email_confirmation_view AS prev
+    ON prev.submission_date = DATE(submission_timestamp)
+    AND prev.join_key = metrics.string.session_flow_id
+  WHERE
+    {% if is_init() %}
+      DATE(submission_timestamp) >= DATE("2024-01-01")
+    {% else %}
+      DATE(submission_timestamp) = @submission_date
+    {% endif %}
+    AND event = 'login.email_confirmation_submit'
+    AND metrics.string.session_flow_id != ''
+),
+login_success_with_email_by_service_login_email_confirmation_success AS (
+  SELECT
+    metrics.string.session_flow_id AS join_key,
+    prev.service AS service,
+    DATE(submission_timestamp) AS submission_date,
+    es.client_id AS client_id,
+    metrics.string.session_flow_id AS column
+  FROM
+    mozdata.accounts_backend.events_stream AS es
+  INNER JOIN
+    login_success_with_email_by_service_login_email_confirmation_submit AS prev
+    ON prev.submission_date = DATE(submission_timestamp)
+    AND prev.join_key = metrics.string.session_flow_id
+  WHERE
+    {% if is_init() %}
+      DATE(submission_timestamp) >= DATE("2024-01-01")
+    {% else %}
+      DATE(submission_timestamp) = @submission_date
+    {% endif %}
+    AND event = 'login.email_confirmation_success'
+    AND metrics.string.session_flow_id != ''
+),
+login_success_with_email_by_service_login_complete AS (
+  SELECT
+    metrics.string.session_flow_id AS join_key,
+    prev.service AS service,
+    DATE(submission_timestamp) AS submission_date,
+    es.client_id AS client_id,
+    metrics.string.session_flow_id AS column
+  FROM
+    mozdata.accounts_backend.events_stream AS es
+  INNER JOIN
+    login_success_with_email_by_service_login_email_confirmation_success AS prev
+    ON prev.submission_date = DATE(submission_timestamp)
+    AND prev.join_key = metrics.string.session_flow_id
+  WHERE
+    {% if is_init() %}
+      DATE(submission_timestamp) >= DATE("2024-01-01")
+    {% else %}
+      DATE(submission_timestamp) = @submission_date
+    {% endif %}
+    AND event = 'login.complete'
+    AND metrics.string.session_flow_id != ''
+),
+login_success_with_2fa_by_service_login_view AS (
+  SELECT
+    metrics.string.session_flow_id AS join_key,
+    IF(
+      COALESCE(
+        NULLIF(metrics.string.relying_party_oauth_client_id, ''),
+        NULLIF(metrics.string.relying_party_service, '')
+      ) = 'sync',
+      '5882386c6d801776',
+      COALESCE(
+        NULLIF(metrics.string.relying_party_oauth_client_id, ''),
+        NULLIF(metrics.string.relying_party_service, '')
+      )
+    ) AS service,
+    DATE(submission_timestamp) AS submission_date,
+    es.client_id AS client_id,
+    metrics.string.session_flow_id AS column
+  FROM
+    mozdata.accounts_frontend.events_stream AS es
+  WHERE
+    {% if is_init() %}
+      DATE(submission_timestamp) >= DATE("2024-01-01")
+    {% else %}
+      DATE(submission_timestamp) = @submission_date
+    {% endif %}
+    AND event = 'login.view'
+    AND metrics.string.session_flow_id != ''
+),
+login_success_with_2fa_by_service_login_submit AS (
+  SELECT
+    metrics.string.session_flow_id AS join_key,
+    prev.service AS service,
+    DATE(submission_timestamp) AS submission_date,
+    es.client_id AS client_id,
+    metrics.string.session_flow_id AS column
+  FROM
+    mozdata.accounts_frontend.events_stream AS es
+  INNER JOIN
+    login_success_with_2fa_by_service_login_view AS prev
+    ON prev.submission_date = DATE(submission_timestamp)
+    AND prev.join_key = metrics.string.session_flow_id
+  WHERE
+    {% if is_init() %}
+      DATE(submission_timestamp) >= DATE("2024-01-01")
+    {% else %}
+      DATE(submission_timestamp) = @submission_date
+    {% endif %}
+    AND event = 'login.submit'
+    AND metrics.string.session_flow_id != ''
+),
+login_success_with_2fa_by_service_login_success AS (
+  SELECT
+    metrics.string.session_flow_id AS join_key,
+    prev.service AS service,
+    DATE(submission_timestamp) AS submission_date,
+    es.client_id AS client_id,
+    metrics.string.session_flow_id AS column
+  FROM
+    mozdata.accounts_backend.events_stream AS es
+  INNER JOIN
+    login_success_with_2fa_by_service_login_submit AS prev
+    ON prev.submission_date = DATE(submission_timestamp)
+    AND prev.join_key = metrics.string.session_flow_id
+  WHERE
+    {% if is_init() %}
+      DATE(submission_timestamp) >= DATE("2024-01-01")
+    {% else %}
+      DATE(submission_timestamp) = @submission_date
+    {% endif %}
+    AND event = 'login.success'
+    AND metrics.string.session_flow_id != ''
+),
+login_success_with_2fa_by_service_login_two_factor_view AS (
+  SELECT
+    metrics.string.session_flow_id AS join_key,
+    prev.service AS service,
+    DATE(submission_timestamp) AS submission_date,
+    es.client_id AS client_id,
+    metrics.string.session_flow_id AS column
+  FROM
+    mozdata.accounts_frontend.events_stream AS es
+  INNER JOIN
+    login_success_with_2fa_by_service_login_success AS prev
+    ON prev.submission_date = DATE(submission_timestamp)
+    AND prev.join_key = metrics.string.session_flow_id
+  WHERE
+    {% if is_init() %}
+      DATE(submission_timestamp) >= DATE("2024-01-01")
+    {% else %}
+      DATE(submission_timestamp) = @submission_date
+    {% endif %}
+    AND event = 'login.totp_form_view'
+    AND metrics.string.session_flow_id != ''
+),
+login_success_with_2fa_by_service_login_two_factor_submit AS (
+  SELECT
+    metrics.string.session_flow_id AS join_key,
+    prev.service AS service,
+    DATE(submission_timestamp) AS submission_date,
+    es.client_id AS client_id,
+    metrics.string.session_flow_id AS column
+  FROM
+    mozdata.accounts_frontend.events_stream AS es
+  INNER JOIN
+    login_success_with_2fa_by_service_login_two_factor_view AS prev
+    ON prev.submission_date = DATE(submission_timestamp)
+    AND prev.join_key = metrics.string.session_flow_id
+  WHERE
+    {% if is_init() %}
+      DATE(submission_timestamp) >= DATE("2024-01-01")
+    {% else %}
+      DATE(submission_timestamp) = @submission_date
+    {% endif %}
+    AND event = 'login.totp_code_submit'
+    AND metrics.string.session_flow_id != ''
+),
+login_success_with_2fa_by_service_login_two_factor_success AS (
+  SELECT
+    metrics.string.session_flow_id AS join_key,
+    prev.service AS service,
+    DATE(submission_timestamp) AS submission_date,
+    es.client_id AS client_id,
+    metrics.string.session_flow_id AS column
+  FROM
+    mozdata.accounts_frontend.events_stream AS es
+  INNER JOIN
+    login_success_with_2fa_by_service_login_two_factor_submit AS prev
+    ON prev.submission_date = DATE(submission_timestamp)
+    AND prev.join_key = metrics.string.session_flow_id
+  WHERE
+    {% if is_init() %}
+      DATE(submission_timestamp) >= DATE("2024-01-01")
+    {% else %}
+      DATE(submission_timestamp) = @submission_date
+    {% endif %}
+    AND event = 'login.totp_code_success_view'
+    AND metrics.string.session_flow_id != ''
+),
+login_success_with_2fa_by_service_login_complete AS (
+  SELECT
+    metrics.string.session_flow_id AS join_key,
+    prev.service AS service,
+    DATE(submission_timestamp) AS submission_date,
+    es.client_id AS client_id,
+    metrics.string.session_flow_id AS column
+  FROM
+    mozdata.accounts_backend.events_stream AS es
+  INNER JOIN
+    login_success_with_2fa_by_service_login_two_factor_success AS prev
+    ON prev.submission_date = DATE(submission_timestamp)
+    AND prev.join_key = metrics.string.session_flow_id
+  WHERE
+    {% if is_init() %}
+      DATE(submission_timestamp) >= DATE("2024-01-01")
+    {% else %}
+      DATE(submission_timestamp) = @submission_date
+    {% endif %}
+    AND event = 'login.complete'
+    AND metrics.string.session_flow_id != ''
+),
+-- aggregate each funnel step value
+login_overall_success_by_service_login_view_aggregated AS (
+  SELECT
+    submission_date,
+    "login_overall_success_by_service" AS funnel,
+    service,
+    COUNT(DISTINCT column) AS aggregated
+  FROM
+    login_overall_success_by_service_login_view
+  GROUP BY
+    service,
+    submission_date,
+    funnel
+),
+login_overall_success_by_service_login_complete_aggregated AS (
+  SELECT
+    submission_date,
+    "login_overall_success_by_service" AS funnel,
+    service,
+    COUNT(DISTINCT column) AS aggregated
+  FROM
+    login_overall_success_by_service_login_complete
+  GROUP BY
+    service,
+    submission_date,
+    funnel
+),
+login_submit_overall_success_by_service_login_view_aggregated AS (
+  SELECT
+    submission_date,
+    "login_submit_overall_success_by_service" AS funnel,
+    service,
+    COUNT(DISTINCT column) AS aggregated
+  FROM
+    login_submit_overall_success_by_service_login_view
+  GROUP BY
+    service,
+    submission_date,
+    funnel
+),
+login_submit_overall_success_by_service_login_submit_aggregated AS (
+  SELECT
+    submission_date,
+    "login_submit_overall_success_by_service" AS funnel,
+    service,
+    COUNT(DISTINCT column) AS aggregated
+  FROM
+    login_submit_overall_success_by_service_login_submit
+  GROUP BY
+    service,
+    submission_date,
+    funnel
+),
+login_submit_overall_success_by_service_login_success_aggregated AS (
+  SELECT
+    submission_date,
+    "login_submit_overall_success_by_service" AS funnel,
+    service,
+    COUNT(DISTINCT column) AS aggregated
+  FROM
+    login_submit_overall_success_by_service_login_success
+  GROUP BY
+    service,
+    submission_date,
+    funnel
+),
+login_submit_overall_success_by_service_login_complete_aggregated AS (
+  SELECT
+    submission_date,
+    "login_submit_overall_success_by_service" AS funnel,
+    service,
+    COUNT(DISTINCT column) AS aggregated
+  FROM
+    login_submit_overall_success_by_service_login_complete
+  GROUP BY
+    service,
+    submission_date,
+    funnel
+),
+login_success_with_email_by_service_login_view_aggregated AS (
+  SELECT
+    submission_date,
+    "login_success_with_email_by_service" AS funnel,
+    service,
+    COUNT(DISTINCT column) AS aggregated
+  FROM
+    login_success_with_email_by_service_login_view
+  GROUP BY
+    service,
+    submission_date,
+    funnel
+),
+login_success_with_email_by_service_login_submit_aggregated AS (
+  SELECT
+    submission_date,
+    "login_success_with_email_by_service" AS funnel,
+    service,
+    COUNT(DISTINCT column) AS aggregated
+  FROM
+    login_success_with_email_by_service_login_submit
+  GROUP BY
+    service,
+    submission_date,
+    funnel
+),
+login_success_with_email_by_service_login_success_aggregated AS (
+  SELECT
+    submission_date,
+    "login_success_with_email_by_service" AS funnel,
+    service,
+    COUNT(DISTINCT column) AS aggregated
+  FROM
+    login_success_with_email_by_service_login_success
+  GROUP BY
+    service,
+    submission_date,
+    funnel
+),
+login_success_with_email_by_service_login_email_confirmation_view_aggregated AS (
+  SELECT
+    submission_date,
+    "login_success_with_email_by_service" AS funnel,
+    service,
+    COUNT(DISTINCT column) AS aggregated
+  FROM
+    login_success_with_email_by_service_login_email_confirmation_view
+  GROUP BY
+    service,
+    submission_date,
+    funnel
+),
+login_success_with_email_by_service_login_email_confirmation_submit_aggregated AS (
+  SELECT
+    submission_date,
+    "login_success_with_email_by_service" AS funnel,
+    service,
+    COUNT(DISTINCT column) AS aggregated
+  FROM
+    login_success_with_email_by_service_login_email_confirmation_submit
+  GROUP BY
+    service,
+    submission_date,
+    funnel
+),
+login_success_with_email_by_service_login_email_confirmation_success_aggregated AS (
+  SELECT
+    submission_date,
+    "login_success_with_email_by_service" AS funnel,
+    service,
+    COUNT(DISTINCT column) AS aggregated
+  FROM
+    login_success_with_email_by_service_login_email_confirmation_success
+  GROUP BY
+    service,
+    submission_date,
+    funnel
+),
+login_success_with_email_by_service_login_complete_aggregated AS (
+  SELECT
+    submission_date,
+    "login_success_with_email_by_service" AS funnel,
+    service,
+    COUNT(DISTINCT column) AS aggregated
+  FROM
+    login_success_with_email_by_service_login_complete
+  GROUP BY
+    service,
+    submission_date,
+    funnel
+),
+login_success_with_2fa_by_service_login_view_aggregated AS (
+  SELECT
+    submission_date,
+    "login_success_with_2fa_by_service" AS funnel,
+    service,
+    COUNT(DISTINCT column) AS aggregated
+  FROM
+    login_success_with_2fa_by_service_login_view
+  GROUP BY
+    service,
+    submission_date,
+    funnel
+),
+login_success_with_2fa_by_service_login_submit_aggregated AS (
+  SELECT
+    submission_date,
+    "login_success_with_2fa_by_service" AS funnel,
+    service,
+    COUNT(DISTINCT column) AS aggregated
+  FROM
+    login_success_with_2fa_by_service_login_submit
+  GROUP BY
+    service,
+    submission_date,
+    funnel
+),
+login_success_with_2fa_by_service_login_success_aggregated AS (
+  SELECT
+    submission_date,
+    "login_success_with_2fa_by_service" AS funnel,
+    service,
+    COUNT(DISTINCT column) AS aggregated
+  FROM
+    login_success_with_2fa_by_service_login_success
+  GROUP BY
+    service,
+    submission_date,
+    funnel
+),
+login_success_with_2fa_by_service_login_two_factor_view_aggregated AS (
+  SELECT
+    submission_date,
+    "login_success_with_2fa_by_service" AS funnel,
+    service,
+    COUNT(DISTINCT column) AS aggregated
+  FROM
+    login_success_with_2fa_by_service_login_two_factor_view
+  GROUP BY
+    service,
+    submission_date,
+    funnel
+),
+login_success_with_2fa_by_service_login_two_factor_submit_aggregated AS (
+  SELECT
+    submission_date,
+    "login_success_with_2fa_by_service" AS funnel,
+    service,
+    COUNT(DISTINCT column) AS aggregated
+  FROM
+    login_success_with_2fa_by_service_login_two_factor_submit
+  GROUP BY
+    service,
+    submission_date,
+    funnel
+),
+login_success_with_2fa_by_service_login_two_factor_success_aggregated AS (
+  SELECT
+    submission_date,
+    "login_success_with_2fa_by_service" AS funnel,
+    service,
+    COUNT(DISTINCT column) AS aggregated
+  FROM
+    login_success_with_2fa_by_service_login_two_factor_success
+  GROUP BY
+    service,
+    submission_date,
+    funnel
+),
+login_success_with_2fa_by_service_login_complete_aggregated AS (
+  SELECT
+    submission_date,
+    "login_success_with_2fa_by_service" AS funnel,
+    service,
+    COUNT(DISTINCT column) AS aggregated
+  FROM
+    login_success_with_2fa_by_service_login_complete
+  GROUP BY
+    service,
+    submission_date,
+    funnel
+),
+-- merge all funnels so results can be written into one table
+merged_funnels AS (
+  SELECT
+    COALESCE(
+      login_overall_success_by_service_login_view_aggregated.service,
+      login_submit_overall_success_by_service_login_view_aggregated.service,
+      login_success_with_email_by_service_login_view_aggregated.service,
+      login_success_with_2fa_by_service_login_view_aggregated.service
+    ) AS service,
+    submission_date,
+    funnel,
+    COALESCE(
+      login_overall_success_by_service_login_view_aggregated.aggregated,
+      login_submit_overall_success_by_service_login_view_aggregated.aggregated,
+      login_success_with_email_by_service_login_view_aggregated.aggregated,
+      login_success_with_2fa_by_service_login_view_aggregated.aggregated
+    ) AS login_view,
+    COALESCE(
+      NULL,
+      login_submit_overall_success_by_service_login_submit_aggregated.aggregated,
+      login_success_with_email_by_service_login_submit_aggregated.aggregated,
+      login_success_with_2fa_by_service_login_submit_aggregated.aggregated
+    ) AS login_submit,
+    COALESCE(
+      NULL,
+      login_submit_overall_success_by_service_login_success_aggregated.aggregated,
+      login_success_with_email_by_service_login_success_aggregated.aggregated,
+      login_success_with_2fa_by_service_login_success_aggregated.aggregated
+   

⚠️ 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