From b3e231c6d7f835c21d828c59ac58b67970b47491 Mon Sep 17 00:00:00 2001 From: Eduardo Filho Date: Fri, 19 Sep 2025 13:29:22 -0400 Subject: [PATCH 1/3] DENG-9703: STMO links lead to appropriate templates that replace copy/paste of query --- src/components/AuthenticatedLink.svelte | 3 +- src/data/gleanSql.js | 164 +++--------------------- src/pages/MetricDetail.svelte | 53 ++++---- src/pages/PingDetail.svelte | 39 +++--- 4 files changed, 60 insertions(+), 199 deletions(-) diff --git a/src/components/AuthenticatedLink.svelte b/src/components/AuthenticatedLink.svelte index 38347309f..e1286a856 100644 --- a/src/components/AuthenticatedLink.svelte +++ b/src/components/AuthenticatedLink.svelte @@ -2,11 +2,12 @@ import tippy from "./tippy"; export let href; + export let target = ""; export let label = null; // a prop for glean click events export let type = null; // a prop for glean click events - + ` --- Auto-generated by the Glean Dictionary. --- https://docs.telemetry.mozilla.org/cookbooks/accessing_glean_data.html#accessing-glean-data-in-bigquery +export const getGleanQuerySTMOTemplateUrl = (columnName, table) => + `https://sql.telemetry.mozilla.org/queries/110672/source?p_columnName=${columnName}&p_table=${table}`; -SELECT - ${columnName} -FROM - ${table} AS m -WHERE - -- Pick yesterday's data from stable/historical tables. - -- https://docs.telemetry.mozilla.org/cookbooks/bigquery/querying.html#table-layout-and-naming - DATE(submission_timestamp) = DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY) --- IMPORTANT: Remove the limit clause when the query is ready. -LIMIT 10`; +export const getGleanLabeledCounterQuerySTMOTemplateUrl = (columnName, table) => + `https://sql.telemetry.mozilla.org/queries/110677/source?p_columnName=${columnName}&p_table=${table}`; -export const getGleanLabeledCounterQuery = (columnName, table) => ` --- Auto-generated by the Glean Dictionary. --- https://docs.telemetry.mozilla.org/cookbooks/accessing_glean_data.html#accessing-glean-data-in-bigquery +export const getGleanDualLabeledCounterQuerySTMOTemplateUrl = ( + columnName, + table +) => + `https://sql.telemetry.mozilla.org/queries/110678/source?p_columnName=${columnName}&p_table=${table}`; -SELECT - DATE(submission_timestamp) AS date, - metric.key AS label, - SUM(metric.value) AS count, -FROM - ${table} AS m -CROSS JOIN - UNNEST(${columnName}) AS metric -WHERE - -- Pick yesterday's data from stable/historical tables. - -- https://docs.telemetry.mozilla.org/cookbooks/bigquery/querying.html#table-layout-and-naming - DATE(submission_timestamp) = DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY) -GROUP BY 1, 2 --- IMPORTANT: Remove the limit clause when the query is ready. -LIMIT 10`; +export const getGleanLegacyEventQuerySTMOTemplateUrl = (table, additionalInfo) => + `https://sql.telemetry.mozilla.org/queries/110679/source?p_table=${table}&p_eventCategory=${additionalInfo.category}&p_eventName=${additionalInfo.name}`; -export const getGleanDualLabeledCounterQuery = (columnName, table) => ` --- Auto-generated by the Glean Dictionary. --- https://docs.telemetry.mozilla.org/cookbooks/accessing_glean_data.html#accessing-glean-data-in-bigquery +export const getGleanEventQuerySTMOTemplateUrl = (table, additionalInfo) => + `https://sql.telemetry.mozilla.org/queries/110680/source?p_table=${table}&p_eventCategory=${additionalInfo.category}&p_eventName=${additionalInfo.name}`; -SELECT - keys.key, - categories.key as category, - categories.value -FROM - ${table} AS m -CROSS JOIN - UNNEST(${columnName}) AS keys -CROSS JOIN - UNNEST(keys.value) AS categories -WHERE - -- Pick yesterday's data from stable/historical tables. - -- https://docs.telemetry.mozilla.org/cookbooks/bigquery/querying.html#table-layout-and-naming - DATE(submission_timestamp) = DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY) - AND ${columnName} IS NOT NULL --- IMPORTANT: Remove the limit clause when the query is ready. -LIMIT 10`; +export const getGleanAutoEventQuerySTMOTemplateUrl = (table, additionalInfo) => + `https://sql.telemetry.mozilla.org/queries/110681/source?p_table=${table}&p_eventCategory=${additionalInfo.category}&p_eventName=${additionalInfo.name}&p_autoEventId=${additionalInfo.auto_event_id}`; -export const getGleanLegacyEventQuery = (table, additionalInfo) => ` --- Auto-generated by the Glean Dictionary. --- https://docs.telemetry.mozilla.org/cookbooks/accessing_glean_data.html#event-metrics - -WITH events AS ( - SELECT - submission_timestamp, - client_info.client_id, - event.timestamp AS event_timestamp, - event.category AS event_category, - event.name AS event_name, - event.extra AS event_extra, - FROM ${table} AS e - CROSS JOIN UNNEST(e.events) AS event - WHERE - -- Pick yesterday's data from stable/historical tables. - -- https://docs.telemetry.mozilla.org/cookbooks/bigquery/querying.html#table-layout-and-naming - date(submission_timestamp) = DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY) - AND sample_id = 1 -- 1% sample for development - AND event.category = '${additionalInfo.category}' - AND event.name = '${additionalInfo.name}' -) -SELECT * FROM events --- IMPORTANT: Remove the limit clause when the query is ready. -LIMIT 10`; - -export const getGleanEventQuery = (table, additionalInfo) => ` --- Auto-generated by the Glean Dictionary. --- https://docs.telemetry.mozilla.org/cookbooks/accessing_glean_data.html#event-metrics - -WITH events AS ( - SELECT - -- The table is partitioned by submission timestamp, so we need to - -- include it in the query. We use event_timestamp instead to understand - -- when the event happened exactly at the source. - submission_timestamp, - event_timestamp, - event, - event_extra - FROM ${table} as e - WHERE - -- Pick data for the last two days from stable/historical tables. - -- https://docs.telemetry.mozilla.org/cookbooks/bigquery/querying.html#table-layout-and-naming - date(submission_timestamp) >= DATE_SUB(CURRENT_DATE(), INTERVAL 2 DAY) - AND event = '${additionalInfo.category}.${additionalInfo.name}' - -- Event extras can be queried as a JSON object. Here is an example - -- to only fetch events that carry an extra property named 'the_name' - -- with a value of 'the_value'. - -- AND JSON_VALUE(event_extra.the_name) = 'the_value' -) -SELECT event_timestamp, event, event_extra FROM events -ORDER BY event_timestamp DESC --- IMPORTANT: Remove the limit clause when the query is ready. -LIMIT 10`; - -export const getGleanAutoEventQuery = (table, additionalInfo) => ` --- Auto-generated by the Glean Dictionary. --- https://docs.telemetry.mozilla.org/cookbooks/accessing_glean_data.html#event-metrics - -WITH events AS ( - SELECT - -- The table is partitioned by submission timestamp, so we need to - -- include it in the query. We use event_timestamp instead to understand - -- when the event happened exactly at the source. - submission_timestamp, - event_timestamp, - event, - event_extra - FROM ${table} as e - WHERE - -- Pick data for the last two days from stable/historical tables. - -- https://docs.telemetry.mozilla.org/cookbooks/bigquery/querying.html#table-layout-and-naming - date(submission_timestamp) >= DATE_SUB(CURRENT_DATE(), INTERVAL 2 DAY) - AND event = '${additionalInfo.category}.${additionalInfo.name}' - AND JSON_VALUE(event_extra.id) = '${additionalInfo.auto_event_id}' -) -SELECT event_timestamp, event, event_extra FROM events -ORDER BY event_timestamp DESC --- IMPORTANT: Remove the limit clause when the query is ready. -LIMIT 10`; - -export const getGleanPingQuery = (table) => ` --- Autogenerated by the Glean Dictionary. --- https://mozilla.github.io/glean/book/user/pings/index.html#payload-structure -SELECT - client_info.*, - ping_info.*, - metrics.* -FROM - ${table} AS m -WHERE - -- Pick yesterday's data from stable/historical tables. - -- https://docs.telemetry.mozilla.org/cookbooks/bigquery/querying.html#table-layout-and-naming - DATE(submission_timestamp) = DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY) --- IMPORTANT: Remove the limit clause when the query is ready. -LIMIT 10`; +export const getGleanPingQuerySTMOTemplateUrl = (table) => + `https://sql.telemetry.mozilla.org/queries/110682/source?p_table=${table}`; diff --git a/src/pages/MetricDetail.svelte b/src/pages/MetricDetail.svelte index d186a63e5..ac5400637 100644 --- a/src/pages/MetricDetail.svelte +++ b/src/pages/MetricDetail.svelte @@ -42,12 +42,13 @@ import { isExpired, isRemoved, isRecent } from "../state/items"; import { - getGleanQuery, - getGleanLabeledCounterQuery, - getGleanDualLabeledCounterQuery, - getGleanEventQuery, - getGleanLegacyEventQuery, - getGleanAutoEventQuery, + getGleanAutoEventQuerySTMOTemplateUrl, + getGleanEventQuerySTMOTemplateUrl, + getGleanLegacyEventQuerySTMOTemplateUrl, + getGleanLabeledCounterQuerySTMOTemplateUrl, + getGleanDualLabeledCounterQuerySTMOTemplateUrl, + getGleanQuerySTMOTemplateUrl, + getGleanPingQuerySTMOTemplateUrl, } from "../data/gleanSql"; export let params; @@ -56,9 +57,7 @@ let selectedPingVariant; let pingData = {}; - const STMO_NEW_QUERY_URL = "https://sql.telemetry.mozilla.org/queries/new"; - - function getSampleSQLQueryCode( + function getSQLTemplateURL( metricType, table, columnName, @@ -72,20 +71,20 @@ const override = `${tableNameParts[0]}.events_stream`; if (tableNameParts[1] === "events") { if (additionalInfo.is_auto) { - return getGleanAutoEventQuery(override, additionalInfo); + return getGleanAutoEventQuerySTMOTemplateUrl(override, additionalInfo); } - return getGleanEventQuery(override, additionalInfo); + return getGleanEventQuerySTMOTemplateUrl(override, additionalInfo); } - return getGleanLegacyEventQuery(table, additionalInfo); + return getGleanLegacyEventQuerySTMOTemplateUrl(table, additionalInfo); } if (metricType === "labeled_counter") { - return getGleanLabeledCounterQuery(columnName, table); + return getGleanLabeledCounterQuerySTMOTemplateUrl(columnName, table); } if (metricType === "dual_labeled_counter") { - return getGleanDualLabeledCounterQuery(columnName, table); + return getGleanDualLabeledCounterQuerySTMOTemplateUrl(columnName, table); } - return getGleanQuery(columnName, table); + return getGleanQuerySTMOTemplateUrl(columnName, table); } const metricDataPromise = getMetricData(params.app, params.metric).then( @@ -585,25 +584,19 @@
- Start a query in STMO with the following SQL ➡   + target="_blank" + >Explore this metric on STMO
- diff --git a/src/pages/PingDetail.svelte b/src/pages/PingDetail.svelte index 1db529df8..165cde189 100644 --- a/src/pages/PingDetail.svelte +++ b/src/pages/PingDetail.svelte @@ -32,7 +32,7 @@ import { getMetricSearchURL } from "../state/urls"; import { isRemoved, isRecent } from "../state/items"; import { getAppBreadcrumbs } from "./AppDetail.svelte"; - import { getGleanPingQuery } from "../data/gleanSql"; + import { getGleanPingQuerySTMOTemplateUrl } from "../data/gleanSql"; export let params; @@ -200,26 +200,23 @@ {/if} - - STMO - - - -
- Start a query in - STMO with the following SQL ➡   -
- - + + + STMO + + + +
+ Explore this ping on STMO +
+ + {/if} From 7054ac19d4739d02f72b4c7016bcefd340ac6ce5 Mon Sep 17 00:00:00 2001 From: Eduardo Filho Date: Fri, 19 Sep 2025 15:13:45 -0400 Subject: [PATCH 2/3] keep Generate SQL button --- src/data/gleanSql.js | 154 ++++++++++++++++++++++++++++++++++ src/pages/MetricDetail.svelte | 47 ++++++++--- src/pages/PingDetail.svelte | 13 ++- 3 files changed, 198 insertions(+), 16 deletions(-) diff --git a/src/data/gleanSql.js b/src/data/gleanSql.js index 9123be8d6..7470a8973 100644 --- a/src/data/gleanSql.js +++ b/src/data/gleanSql.js @@ -1,23 +1,177 @@ +export const getGleanQuery = (columnName, table) => ` +-- Auto-generated by the Glean Dictionary. +-- https://docs.telemetry.mozilla.org/cookbooks/accessing_glean_data.html#accessing-glean-data-in-bigquery + +SELECT + ${columnName} +FROM + ${table} AS m +WHERE + -- Pick yesterday's data from stable/historical tables. + -- https://docs.telemetry.mozilla.org/cookbooks/bigquery/querying.html#table-layout-and-naming + DATE(submission_timestamp) = DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY) +-- IMPORTANT: Remove the limit clause when the query is ready. +LIMIT 10`; + export const getGleanQuerySTMOTemplateUrl = (columnName, table) => `https://sql.telemetry.mozilla.org/queries/110672/source?p_columnName=${columnName}&p_table=${table}`; +export const getGleanLabeledCounterQuery = (columnName, table) => ` +-- Auto-generated by the Glean Dictionary. +-- https://docs.telemetry.mozilla.org/cookbooks/accessing_glean_data.html#accessing-glean-data-in-bigquery + +SELECT + DATE(submission_timestamp) AS date, + metric.key AS label, + SUM(metric.value) AS count, +FROM + ${table} AS m +CROSS JOIN + UNNEST(${columnName}) AS metric +WHERE + -- Pick yesterday's data from stable/historical tables. + -- https://docs.telemetry.mozilla.org/cookbooks/bigquery/querying.html#table-layout-and-naming + DATE(submission_timestamp) = DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY) +GROUP BY 1, 2 +-- IMPORTANT: Remove the limit clause when the query is ready. +LIMIT 10`; + export const getGleanLabeledCounterQuerySTMOTemplateUrl = (columnName, table) => `https://sql.telemetry.mozilla.org/queries/110677/source?p_columnName=${columnName}&p_table=${table}`; +export const getGleanDualLabeledCounterQuery = (columnName, table) => ` +-- Auto-generated by the Glean Dictionary. +-- https://docs.telemetry.mozilla.org/cookbooks/accessing_glean_data.html#accessing-glean-data-in-bigquery + +SELECT + keys.key, + categories.key as category, + categories.value +FROM + ${table} AS m +CROSS JOIN + UNNEST(${columnName}) AS keys +CROSS JOIN + UNNEST(keys.value) AS categories +WHERE + -- Pick yesterday's data from stable/historical tables. + -- https://docs.telemetry.mozilla.org/cookbooks/bigquery/querying.html#table-layout-and-naming + DATE(submission_timestamp) = DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY) + AND ${columnName} IS NOT NULL +-- IMPORTANT: Remove the limit clause when the query is ready. +LIMIT 10`; + export const getGleanDualLabeledCounterQuerySTMOTemplateUrl = ( columnName, table ) => `https://sql.telemetry.mozilla.org/queries/110678/source?p_columnName=${columnName}&p_table=${table}`; +export const getGleanLegacyEventQuery = (table, additionalInfo) => ` +-- Auto-generated by the Glean Dictionary. +-- https://docs.telemetry.mozilla.org/cookbooks/accessing_glean_data.html#event-metrics + +WITH events AS ( + SELECT + submission_timestamp, + client_info.client_id, + event.timestamp AS event_timestamp, + event.category AS event_category, + event.name AS event_name, + event.extra AS event_extra, + FROM ${table} AS e + CROSS JOIN UNNEST(e.events) AS event + WHERE + -- Pick yesterday's data from stable/historical tables. + -- https://docs.telemetry.mozilla.org/cookbooks/bigquery/querying.html#table-layout-and-naming + date(submission_timestamp) = DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY) + AND sample_id = 1 -- 1% sample for development + AND event.category = '${additionalInfo.category}' + AND event.name = '${additionalInfo.name}' +) +SELECT * FROM events +-- IMPORTANT: Remove the limit clause when the query is ready. +LIMIT 10`; + export const getGleanLegacyEventQuerySTMOTemplateUrl = (table, additionalInfo) => `https://sql.telemetry.mozilla.org/queries/110679/source?p_table=${table}&p_eventCategory=${additionalInfo.category}&p_eventName=${additionalInfo.name}`; +export const getGleanEventQuery = (table, additionalInfo) => ` +-- Auto-generated by the Glean Dictionary. +-- https://docs.telemetry.mozilla.org/cookbooks/accessing_glean_data.html#event-metrics + +WITH events AS ( + SELECT + -- The table is partitioned by submission timestamp, so we need to + -- include it in the query. We use event_timestamp instead to understand + -- when the event happened exactly at the source. + submission_timestamp, + event_timestamp, + event, + event_extra + FROM ${table} as e + WHERE + -- Pick data for the last two days from stable/historical tables. + -- https://docs.telemetry.mozilla.org/cookbooks/bigquery/querying.html#table-layout-and-naming + date(submission_timestamp) >= DATE_SUB(CURRENT_DATE(), INTERVAL 2 DAY) + AND event = '${additionalInfo.category}.${additionalInfo.name}' + -- Event extras can be queried as a JSON object. Here is an example + -- to only fetch events that carry an extra property named 'the_name' + -- with a value of 'the_value'. + -- AND JSON_VALUE(event_extra.the_name) = 'the_value' +) +SELECT event_timestamp, event, event_extra FROM events +ORDER BY event_timestamp DESC +-- IMPORTANT: Remove the limit clause when the query is ready. +LIMIT 10`; + export const getGleanEventQuerySTMOTemplateUrl = (table, additionalInfo) => `https://sql.telemetry.mozilla.org/queries/110680/source?p_table=${table}&p_eventCategory=${additionalInfo.category}&p_eventName=${additionalInfo.name}`; +export const getGleanAutoEventQuery = (table, additionalInfo) => ` +-- Auto-generated by the Glean Dictionary. +-- https://docs.telemetry.mozilla.org/cookbooks/accessing_glean_data.html#event-metrics + +WITH events AS ( + SELECT + -- The table is partitioned by submission timestamp, so we need to + -- include it in the query. We use event_timestamp instead to understand + -- when the event happened exactly at the source. + submission_timestamp, + event_timestamp, + event, + event_extra + FROM ${table} as e + WHERE + -- Pick data for the last two days from stable/historical tables. + -- https://docs.telemetry.mozilla.org/cookbooks/bigquery/querying.html#table-layout-and-naming + date(submission_timestamp) >= DATE_SUB(CURRENT_DATE(), INTERVAL 2 DAY) + AND event = '${additionalInfo.category}.${additionalInfo.name}' + AND JSON_VALUE(event_extra.id) = '${additionalInfo.auto_event_id}' +) +SELECT event_timestamp, event, event_extra FROM events +ORDER BY event_timestamp DESC +-- IMPORTANT: Remove the limit clause when the query is ready. +LIMIT 10`; + export const getGleanAutoEventQuerySTMOTemplateUrl = (table, additionalInfo) => `https://sql.telemetry.mozilla.org/queries/110681/source?p_table=${table}&p_eventCategory=${additionalInfo.category}&p_eventName=${additionalInfo.name}&p_autoEventId=${additionalInfo.auto_event_id}`; +export const getGleanPingQuery = (table) => ` +-- Autogenerated by the Glean Dictionary. +-- https://mozilla.github.io/glean/book/user/pings/index.html#payload-structure +SELECT + client_info.*, + ping_info.*, + metrics.* +FROM + ${table} AS m +WHERE + -- Pick yesterday's data from stable/historical tables. + -- https://docs.telemetry.mozilla.org/cookbooks/bigquery/querying.html#table-layout-and-naming + DATE(submission_timestamp) = DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY) +-- IMPORTANT: Remove the limit clause when the query is ready. +LIMIT 10`; + export const getGleanPingQuerySTMOTemplateUrl = (table) => `https://sql.telemetry.mozilla.org/queries/110682/source?p_table=${table}`; diff --git a/src/pages/MetricDetail.svelte b/src/pages/MetricDetail.svelte index ac5400637..2cd24a703 100644 --- a/src/pages/MetricDetail.svelte +++ b/src/pages/MetricDetail.svelte @@ -42,6 +42,12 @@ import { isExpired, isRemoved, isRecent } from "../state/items"; import { + getGleanQuery, + getGleanLabeledCounterQuery, + getGleanDualLabeledCounterQuery, + getGleanEventQuery, + getGleanLegacyEventQuery, + getGleanAutoEventQuery, getGleanAutoEventQuerySTMOTemplateUrl, getGleanEventQuerySTMOTemplateUrl, getGleanLegacyEventQuerySTMOTemplateUrl, @@ -57,11 +63,13 @@ let selectedPingVariant; let pingData = {}; - function getSQLTemplateURL( + + function getSQLResource( metricType, table, columnName, - additionalInfo + additionalInfo, + isSTMOTemplate ) { if (metricType === "event") { // Although events might come from other pings, we override that and @@ -71,20 +79,20 @@ const override = `${tableNameParts[0]}.events_stream`; if (tableNameParts[1] === "events") { if (additionalInfo.is_auto) { - return getGleanAutoEventQuerySTMOTemplateUrl(override, additionalInfo); + return isSTMOTemplate ? getGleanAutoEventQuerySTMOTemplateUrl(override, additionalInfo) : getGleanAutoEventQuery(override, additionalInfo); } - return getGleanEventQuerySTMOTemplateUrl(override, additionalInfo); + return isSTMOTemplate ? getGleanEventQuerySTMOTemplateUrl(override, additionalInfo) : getGleanEventQuery(override, additionalInfo); } - return getGleanLegacyEventQuerySTMOTemplateUrl(table, additionalInfo); + return isSTMOTemplate ? getGleanLegacyEventQuerySTMOTemplateUrl(table, additionalInfo) : getGleanLegacyEventQuery(table, additionalInfo); } if (metricType === "labeled_counter") { - return getGleanLabeledCounterQuerySTMOTemplateUrl(columnName, table); + return isSTMOTemplate ? getGleanLabeledCounterQuerySTMOTemplateUrl(columnName, table) : getGleanLabeledCounterQuery(columnName, table); } if (metricType === "dual_labeled_counter") { - return getGleanDualLabeledCounterQuerySTMOTemplateUrl(columnName, table); + return isSTMOTemplate ? getGleanDualLabeledCounterQuerySTMOTemplateUrl(columnName, table) : getGleanDualLabeledCounterQuery(columnName, table); } - return getGleanQuerySTMOTemplateUrl(columnName, table); + return isSTMOTemplate ? getGleanQuerySTMOTemplateUrl(columnName, table) : getGleanQuery(columnName, table); } const metricDataPromise = getMetricData(params.app, params.metric).then( @@ -584,19 +592,32 @@
+ Start a query in Explore this metric on STMO + >STMO with the following SQL ➡  
+ diff --git a/src/pages/PingDetail.svelte b/src/pages/PingDetail.svelte index 165cde189..58214c7ad 100644 --- a/src/pages/PingDetail.svelte +++ b/src/pages/PingDetail.svelte @@ -32,7 +32,7 @@ import { getMetricSearchURL } from "../state/urls"; import { isRemoved, isRecent } from "../state/items"; import { getAppBreadcrumbs } from "./AppDetail.svelte"; - import { getGleanPingQuerySTMOTemplateUrl } from "../data/gleanSql"; + import { getGleanPingQuery, getGleanPingQuerySTMOTemplateUrl } from "../data/gleanSql"; export let params; @@ -210,11 +210,18 @@
+ Explore this ping in Explore this ping on STMO + target="_blank">STMO or use the following SQL ➡  
+
+ +
From b5dee9076d4179e4a6c2fc888d445bc49d009e5d Mon Sep 17 00:00:00 2001 From: Eduardo Filho Date: Mon, 22 Sep 2025 11:41:12 -0400 Subject: [PATCH 3/3] prettier --- src/data/gleanSql.js | 5 ++++- src/pages/MetricDetail.svelte | 26 ++++++++++++++++++-------- src/pages/PingDetail.svelte | 7 +++++-- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/data/gleanSql.js b/src/data/gleanSql.js index 7470a8973..99a4f3766 100644 --- a/src/data/gleanSql.js +++ b/src/data/gleanSql.js @@ -93,7 +93,10 @@ SELECT * FROM events -- IMPORTANT: Remove the limit clause when the query is ready. LIMIT 10`; -export const getGleanLegacyEventQuerySTMOTemplateUrl = (table, additionalInfo) => +export const getGleanLegacyEventQuerySTMOTemplateUrl = ( + table, + additionalInfo +) => `https://sql.telemetry.mozilla.org/queries/110679/source?p_table=${table}&p_eventCategory=${additionalInfo.category}&p_eventName=${additionalInfo.name}`; export const getGleanEventQuery = (table, additionalInfo) => ` diff --git a/src/pages/MetricDetail.svelte b/src/pages/MetricDetail.svelte index 2cd24a703..452baa741 100644 --- a/src/pages/MetricDetail.svelte +++ b/src/pages/MetricDetail.svelte @@ -54,7 +54,6 @@ getGleanLabeledCounterQuerySTMOTemplateUrl, getGleanDualLabeledCounterQuerySTMOTemplateUrl, getGleanQuerySTMOTemplateUrl, - getGleanPingQuerySTMOTemplateUrl, } from "../data/gleanSql"; export let params; @@ -63,7 +62,6 @@ let selectedPingVariant; let pingData = {}; - function getSQLResource( metricType, table, @@ -79,20 +77,32 @@ const override = `${tableNameParts[0]}.events_stream`; if (tableNameParts[1] === "events") { if (additionalInfo.is_auto) { - return isSTMOTemplate ? getGleanAutoEventQuerySTMOTemplateUrl(override, additionalInfo) : getGleanAutoEventQuery(override, additionalInfo); + return isSTMOTemplate + ? getGleanAutoEventQuerySTMOTemplateUrl(override, additionalInfo) + : getGleanAutoEventQuery(override, additionalInfo); } - return isSTMOTemplate ? getGleanEventQuerySTMOTemplateUrl(override, additionalInfo) : getGleanEventQuery(override, additionalInfo); + return isSTMOTemplate + ? getGleanEventQuerySTMOTemplateUrl(override, additionalInfo) + : getGleanEventQuery(override, additionalInfo); } - return isSTMOTemplate ? getGleanLegacyEventQuerySTMOTemplateUrl(table, additionalInfo) : getGleanLegacyEventQuery(table, additionalInfo); + return isSTMOTemplate + ? getGleanLegacyEventQuerySTMOTemplateUrl(table, additionalInfo) + : getGleanLegacyEventQuery(table, additionalInfo); } if (metricType === "labeled_counter") { - return isSTMOTemplate ? getGleanLabeledCounterQuerySTMOTemplateUrl(columnName, table) : getGleanLabeledCounterQuery(columnName, table); + return isSTMOTemplate + ? getGleanLabeledCounterQuerySTMOTemplateUrl(columnName, table) + : getGleanLabeledCounterQuery(columnName, table); } if (metricType === "dual_labeled_counter") { - return isSTMOTemplate ? getGleanDualLabeledCounterQuerySTMOTemplateUrl(columnName, table) : getGleanDualLabeledCounterQuery(columnName, table); + return isSTMOTemplate + ? getGleanDualLabeledCounterQuerySTMOTemplateUrl(columnName, table) + : getGleanDualLabeledCounterQuery(columnName, table); } - return isSTMOTemplate ? getGleanQuerySTMOTemplateUrl(columnName, table) : getGleanQuery(columnName, table); + return isSTMOTemplate + ? getGleanQuerySTMOTemplateUrl(columnName, table) + : getGleanQuery(columnName, table); } const metricDataPromise = getMetricData(params.app, params.metric).then( diff --git a/src/pages/PingDetail.svelte b/src/pages/PingDetail.svelte index 58214c7ad..e4997ed33 100644 --- a/src/pages/PingDetail.svelte +++ b/src/pages/PingDetail.svelte @@ -32,7 +32,10 @@ import { getMetricSearchURL } from "../state/urls"; import { isRemoved, isRecent } from "../state/items"; import { getAppBreadcrumbs } from "./AppDetail.svelte"; - import { getGleanPingQuery, getGleanPingQuerySTMOTemplateUrl } from "../data/gleanSql"; + import { + getGleanPingQuery, + getGleanPingQuerySTMOTemplateUrl, + } from "../data/gleanSql"; export let params; @@ -221,7 +224,7 @@ openModalText="Generate SQL" sqlContent={getGleanPingQuery(selectedAppVariant.table)} /> - +