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

Add telemetry for vp #1340

Merged
merged 9 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
177 changes: 103 additions & 74 deletions ui/lib/apps/SlowQuery/pages/Detail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ import {
TreeDiagramView,
} from '@lib/components'
import { useVersionedLocalStorageState } from '@lib/utils/useVersionedLocalStorageState'
import { telemetry } from '@lib/apps/SlowQuery/utils/telemetry'

import DetailTabs from './DetailTabs'

// import vpData from './example'

export interface IPageQuery {
connectId?: string
digest?: string
Expand Down Expand Up @@ -71,7 +70,8 @@ function DetailPage() {
setDetailExpand((prev) => ({ ...prev, plan: !prev.plan }))

const [isVpVisible, setIsVpVisable] = useState(false)
const toggleVisualPlan = () => {
const toggleVisualPlan = (action: string) => {
telemetry.toggleVisualPlanModal(action)
setIsVpVisable(!isVpVisible)
}

Expand Down Expand Up @@ -157,78 +157,107 @@ function DetailPage() {
})()}
</Descriptions>
{(binaryPlan || !!data.plan) && (
<Tabs
defaultActiveKey={
binaryPlan && !binaryPlan.main.discardedDueToTooLong
? 'binary_plan'
: 'text_plan'
}
>
{binaryPlan && !binaryPlan.main.discardedDueToTooLong && (
<Tabs.TabPane tab="Visual Plan" key="binary_plan">
<Modal
title="Visual Plan Tree Diagram"
centered
visible={isVpVisible}
width={window.innerWidth}
onCancel={toggleVisualPlan}
footer={null}
destroyOnClose={true}
bodyStyle={{
background: '#f5f5f5',
height: window.innerHeight - 100,
}}
>
<TreeDiagramView
data={
binaryPlan.ctes
? [binaryPlan.main].concat(binaryPlan.ctes)
: [binaryPlan.main]
<Descriptions>
<Descriptions.Item
label={
<Space align="baseline" size="middle">
<span style={{ paddingRight: '2rem' }}>
{t('slow_query.detail.plan.title')}
</span>
<Tabs
defaultActiveKey={
binaryPlan && !binaryPlan.main.discardedDueToTooLong
? 'binary_plan'
: 'text_plan'
}
// data={[vpData.main].concat(vpData.ctes)}
showMinimap={true}
/>
</Modal>
<Descriptions>
<Descriptions.Item span={2}>
<div onClick={toggleVisualPlan}>
<TreeDiagramView
data={
binaryPlan.ctes
? [binaryPlan.main].concat(binaryPlan.ctes)
: [binaryPlan.main]
}
// data={[vpData.main].concat(vpData.ctes)}
isThumbnail={true}
/>
</div>
</Descriptions.Item>
</Descriptions>
</Tabs.TabPane>
)}

<Tabs.TabPane tab="Text Plan" key="text_plan">
<Descriptions>
<Descriptions.Item
span={2}
multiline={detailExpand.plan}
label={
<Space size="middle">
<Expand.Link
expanded={detailExpand.plan}
onClick={togglePlan}
/>
<CopyLink data={data.plan ?? ''} />
</Space>
}
>
<Expand expanded={detailExpand.plan}>
<Pre noWrap>{data.plan}</Pre>
</Expand>
</Descriptions.Item>
</Descriptions>
</Tabs.TabPane>
</Tabs>
onTabClick={(key) =>
telemetry.clickPlanTabs(key, data.digest!)
}
>
{binaryPlan &&
!binaryPlan.main.discardedDueToTooLong && (
<Tabs.TabPane
tab={t('slow_query.detail.plan.visual')}
key="binary_plan"
>
<Modal
title={t(
'slow_query.detail.plan.modal_title'
)}
centered
visible={isVpVisible}
width={window.innerWidth}
onCancel={() => toggleVisualPlan('close')}
footer={null}
destroyOnClose={true}
bodyStyle={{
background: '#f5f5f5',
height: window.innerHeight - 100,
}}
>
<TreeDiagramView
data={
binaryPlan.ctes
? [binaryPlan.main].concat(
binaryPlan.ctes
)
: [binaryPlan.main]
}
showMinimap={true}
/>
</Modal>
<Descriptions>
<Descriptions.Item span={2}>
<div
onClick={() => toggleVisualPlan('open')}
>
<TreeDiagramView
data={
binaryPlan.ctes
? [binaryPlan.main].concat(
binaryPlan.ctes
)
: [binaryPlan.main]
}
isThumbnail={true}
/>
</div>
</Descriptions.Item>
</Descriptions>
</Tabs.TabPane>
)}

<Tabs.TabPane
tab={t('slow_query.detail.plan.text')}
key="text_plan"
>
<Descriptions>
<Descriptions.Item
span={2}
multiline={detailExpand.plan}
label={
<Space size="middle">
<Expand.Link
expanded={detailExpand.plan}
onClick={togglePlan}
/>
<CopyLink data={data.plan ?? ''} />
</Space>
}
>
<Expand expanded={detailExpand.plan}>
<Pre noWrap>{data.plan}</Pre>
</Expand>
</Descriptions.Item>
</Descriptions>
</Tabs.TabPane>
</Tabs>
</Space>
}
>
<React.Fragment />
</Descriptions.Item>
</Descriptions>
)}

<DetailTabs data={data} />
Expand Down
7 changes: 5 additions & 2 deletions ui/lib/apps/SlowQuery/translations/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,11 @@ slow_query:
back: List
sql: Query
previous_sql: Previous Query
plan: Plan
tree_diagram: Tree Diagram
plan:
title: Plan
visual: Visual
text: Text
modal_title: Visual Plan
tabs:
basic: Basic
time: Time
Expand Down
7 changes: 5 additions & 2 deletions ui/lib/apps/SlowQuery/translations/zh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,11 @@ slow_query:
back: 列表
sql: SQL 查询
previous_sql: 上一条 SQL 查询
plan: 执行计划
tree_diagram: 树形图
plan:
title: 执行计划
visual: 图形
text: 文本
modal_title: 执行计划可视化
tabs:
basic: 基本信息
time: 执行时间
Expand Down
20 changes: 20 additions & 0 deletions ui/lib/apps/SlowQuery/utils/telemetry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2022 PingCAP, Inc. Licensed under Apache-2.0.
import { mixpanel } from '@lib/utils/telemetry'

export const telemetry = {
clickPlanTabs(tab: string, queryDigest: string) {
mixpanel.track('Slowquery: Plan Tab Clicked', { tab, queryDigest })
},
toggleVisualPlanModal(action: string) {
mixpanel.track('Slowquery: Visual Plan Modal Toggled', { action })
},
toggleExpandBtnOnNode(nodeName: string) {
mixpanel.track('Slowquery: Node Button Toggled', { nodeName })
},
clickNode(nodeName: string) {
mixpanel.track('Slowquery: Node Clicked', { nodeName })
},
clickTabOnNodeDetail(tab: string) {
mixpanel.track('Slowquery: Detail Tab on Node Clicked', { tab })
},
}
Loading