Skip to content

Commit 507c4bb

Browse files
committed
fix: add email source to mixpanel events
1 parent beb6749 commit 507c4bb

8 files changed

Lines changed: 26 additions & 7 deletions

File tree

testgen/__main__.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from testgen.commands.run_test_execution import run_test_execution
3333
from testgen.commands.run_test_metadata_exporter import run_test_metadata_exporter
3434
from testgen.commands.run_upgrade_db_config import get_schema_revision, is_db_revision_up_to_date, run_upgrade_db_config
35-
from testgen.commands.test_generation import run_test_generation
35+
from testgen.commands.test_generation import run_monitor_generation, run_test_generation
3636
from testgen.common import (
3737
configure_logging,
3838
display_service,
@@ -176,6 +176,20 @@ def run_generation(test_suite_id: str | None = None, table_group_id: str | None
176176
click.echo("\n" + message)
177177

178178

179+
@cli.command("run-monitor-generation", help="Generates or refreshes the monitors for a table group.")
180+
@click.option(
181+
"-t",
182+
"--test-suite-id",
183+
required=True,
184+
type=click.STRING,
185+
help="ID of the monitor suite to generate",
186+
)
187+
@with_database_session
188+
def generate_monitors(test_suite_id: str):
189+
click.echo(f"run-monitor-generation for suite: {test_suite_id}")
190+
run_monitor_generation(test_suite_id, ["Freshness_Trend", "Volume_Trend", "Schema_Drift"])
191+
192+
179193
@register_scheduler_job
180194
@cli.command("run-tests", help="Performs tests defined for a test suite.")
181195
@click.option(

testgen/common/notifications/monitor_run.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ def send_monitor_notifications(test_run: TestRun, result_list_ct=20):
230230
str(table_group.id),
231231
"&table_name_filter=" if table_name else "",
232232
table_name if table_name else "",
233+
"&source=email",
233234
)
234235
)
235236
try:

testgen/common/notifications/profiling_run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def send_profiling_run_notifications(profiling_run: ProfilingRun, result_list_ct
258258
return
259259

260260
profiling_run_issues_url = "".join(
261-
(PersistedSetting.get("BASE_URL", ""), "/profiling-runs:hygiene?run_id=", str(profiling_run.id))
261+
(PersistedSetting.get("BASE_URL", ""), "/profiling-runs:hygiene?run_id=", str(profiling_run.id), "&source=email")
262262
)
263263

264264
hygiene_issues_summary = []
@@ -304,7 +304,7 @@ def send_profiling_run_notifications(profiling_run: ProfilingRun, result_list_ct
304304
"id": str(profiling_run.id),
305305
"issues_url": profiling_run_issues_url,
306306
"results_url": "".join(
307-
(PersistedSetting.get("BASE_URL", ""), "/profiling-runs:results?run_id=", str(profiling_run.id))
307+
(PersistedSetting.get("BASE_URL", ""), "/profiling-runs:results?run_id=", str(profiling_run.id), "&source=email")
308308
),
309309
"start_time": profiling_run.profiling_starttime,
310310
"end_time": profiling_run.profiling_endtime,

testgen/common/notifications/score_drop.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ def send_score_drop_notifications(notification_data: list[tuple[ScoreDefinition,
180180
PersistedSetting.get("BASE_URL", ""),
181181
"/quality-dashboard:score-details?definition_id=",
182182
str(definition.id),
183+
"&source=email",
183184
)
184185
),
185186
"diff": context_diff,

testgen/common/notifications/test_run.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ def send_test_run_notifications(test_run: TestRun, result_list_ct=20, result_sta
328328
PersistedSetting.get("BASE_URL", ""),
329329
"/test-runs:results?run_id=",
330330
str(test_run.id),
331+
"&source=email",
331332
)
332333
)
333334

testgen/ui/components/frontend/js/pages/edit_table_monitors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ const EditTableMonitors = (/** @type Properties */ props) => {
234234
updated_definitions: Object.values(updatedDefinitions.val),
235235
new_metrics: Object.values(newMetrics.val),
236236
deleted_metric_ids: deletedMetricIds.val,
237-
close: false,
237+
close: true,
238238
};
239239
emitEvent('SaveTestDefinition', { payload });
240240
},

testgen/ui/components/frontend/js/pages/project_dashboard.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ const TableGroupLatestProfile = (/** @type TableGroupSummary */ tableGroup) => {
261261
})
262262
: '',
263263
),
264-
div({ style: 'flex: 1 1 120px;' })
265264
);
266265
};
267266

testgen/ui/navigation/router.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __init__(
2727
self._routes = {route.path: route(self) for route in routes} if routes else {}
2828
self._pending_navigation: dict | None = None
2929

30-
def _init_session(self):
30+
def _init_session(self, url: str):
3131
# Clear cache on initial load or page refresh
3232
st.cache_data.clear()
3333

@@ -37,13 +37,16 @@ def _init_session(self):
3737
except Exception as e:
3838
LOG.exception("Error capturing the base URL")
3939

40+
source = st.query_params.pop("source", None)
41+
MixpanelService().send_event(f"nav-{url}", page_load=True, source=source)
42+
4043
def run(self) -> None:
4144
streamlit_pages = [route.streamlit_page for route in self._routes.values()]
4245

4346
current_page = st.navigation(streamlit_pages, position="hidden")
4447

4548
if not session.initialized:
46-
self._init_session()
49+
self._init_session(url=current_page.url_path)
4750
session.initialized = True
4851

4952
# This hack is needed because the auth cookie is not set if navigation happens immediately after login

0 commit comments

Comments
 (0)