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

[Chore] Add telemetry event for breaking change analysis #588

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions js/src/components/lineage/LineageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,9 @@ import { createSchemaDiffCheck } from "@/lib/api/schemacheck";
import { useLocation } from "wouter";
import { Check } from "@/lib/api/checks";
import useValueDiffAlertDialog from "./useValueDiffAlertDialog";
import { trackMultiNodesAction } from "@/lib/api/track";
import { trackBreakingChange, trackMultiNodesAction } from "@/lib/api/track";
import { PresetCheckRecommendation } from "./PresetCheckRecommendation";



export interface LineageViewProps {
viewOptions?: LineageDiffViewOptions;
interactive?: boolean;
Expand Down Expand Up @@ -867,9 +865,10 @@ export function PrivateLineageView(
<Switch
isChecked={breakingChangeEnabled}
onChange={(e) => {
const advancedImpactRadius = e.target.checked;
setBreakingChangeEnabled(advancedImpactRadius);
highlightImpactRadius(advancedImpactRadius);
const enabled = e.target.checked;
setBreakingChangeEnabled(enabled);
highlightImpactRadius(enabled);
trackBreakingChange({ enabled });
}}
alignItems={"center"}
></Switch>
Expand All @@ -892,7 +891,7 @@ export function PrivateLineageView(
Breaking changes are determined by analyzing SQL for
changes that may impact downstream models.{" "}
<Link
href="https://datarecce.io/docs/features/lineage/"
href="https://datarecce.io/docs/features/breaking-change-analysis/"
target="_blank"
>
Learn more
Expand Down
5 changes: 5 additions & 0 deletions js/src/lib/api/checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { axiosClient } from "./axiosClient";
import { Run, RunType } from "./types";
import { useQuery } from "@tanstack/react-query";
import { cacheKeys } from "./cacheKeys";
import { getExperimentTrackingBreakingChangeEnabled } from "./track";

export interface Check<PT = any, RT = any, VO = any> {
check_id: string;
Expand All @@ -29,9 +30,13 @@ export async function createCheckByRun(
runId: string,
viewOptions?: any
): Promise<Check> {
const track_props = getExperimentTrackingBreakingChangeEnabled()
? { breaking_change_analysis: true }
: {};
const response = await axiosClient.post("/api/checks", {
run_id: runId,
view_options: viewOptions,
track_props,
});
const check = response.data;

Expand Down
5 changes: 5 additions & 0 deletions js/src/lib/api/runs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import _ from "lodash";
import { axiosClient } from "./axiosClient";
import { Run, RunType } from "./types";
import { getExperimentTrackingBreakingChangeEnabled } from "./track";

export interface SubmitOptions {
nowait?: boolean;
Expand All @@ -11,10 +12,14 @@ export async function submitRun<PT = any, RT = any>(
params?: PT,
options?: SubmitOptions
) {
const track_props = getExperimentTrackingBreakingChangeEnabled()
? { breaking_change_analysis: true }
: {};
const response = await axiosClient.post("/api/runs", {
type,
params,
nowait: options?.nowait,
track_props,
});

const run: Run<PT, RT> | Pick<Run, "run_id"> = response.data;
Expand Down
16 changes: 16 additions & 0 deletions js/src/lib/api/track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,19 @@ interface RecommendPresetCheckProps {
export function trackRecommendCheck(props: RecommendPresetCheckProps) {
amplitude.track("[Experiment] recommend_preset_check", props);
}


interface BreakingChangeAnalysisProps {
enabled: boolean;
}

let _breakingChangeEnabled = false;

export function trackBreakingChange(props: BreakingChangeAnalysisProps) {
amplitude.track("[Experiment] breaking_change_analysis", props);
_breakingChangeEnabled = props.enabled;
}

export function getExperimentTrackingBreakingChangeEnabled() {
return _breakingChangeEnabled;
}
2 changes: 2 additions & 0 deletions recce/apis/check_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class CreateCheckIn(BaseModel):
type: Optional[RunType] = None,
params: Optional[dict] = None
view_options: Optional[dict] = None
track_props: Optional[dict] = None


class CheckOut(BaseModel):
Expand Down Expand Up @@ -67,6 +68,7 @@ async def create_check(check_in: CreateCheckIn, background_tasks: BackgroundTask
)
log_api_event('create_check', dict(
type=str(check.type),
track_props=check_in.track_props,
))
except NameError as e:
raise HTTPException(status_code=404, detail=str(e))
Expand Down
2 changes: 2 additions & 0 deletions recce/apis/run_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ class CreateRunIn(BaseModel):
params: dict
check_id: Optional[str] = None
nowait: Optional[bool] = False
track_props: Optional[dict] = None


@run_router.post("/runs", status_code=201)
async def create_run_handler(input: CreateRunIn):
log_api_event('create_run', dict(
type=input.type,
track_props=input.track_props,
))
try:
run, future = submit_run(input.type, input.params)
Expand Down
Loading