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 cluster info for telemetry #1423

Merged
merged 3 commits into from
Oct 26, 2022
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
2 changes: 1 addition & 1 deletion ui/packages/tidb-dashboard-for-dbaas/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pingcap/tidb-dashboard-for-dbaas",
"version": "0.0.44",
"version": "0.0.45",
"main": "dist/main.js",
"module": "dist/main.js",
"files": [
Expand Down
7 changes: 6 additions & 1 deletion ui/packages/tidb-dashboard-for-dbaas/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,17 @@
}
const promBaseUrl = localStorage.getItem('dbaas.cluster_prom_base_url')

const clusterInfo = JSON.parse(
localStorage.getItem('dbaas.cluster_info') ?? '{}'
)

startDashboard({
apiPathBase,
apiToken,
mixpanelUser,
timezone,
promBaseUrl
promBaseUrl,
clusterInfo
})
</script>
</body>
Expand Down
15 changes: 14 additions & 1 deletion ui/packages/tidb-dashboard-for-dbaas/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,25 @@ function start(globalConfig: IGlobalConfig) {
setupClient(apiPathBase, apiToken)
loadWhoAmI()
loadAppInfo()

// telemetry
telemetry.init(
process.env.REACT_APP_MIXPANEL_HOST,
process.env.REACT_APP_MIXPANEL_TOKEN
)
telemetry.enable(`tidb-dashboard-for-dbaas-${process.env.REACT_APP_VERSION}`)
const {
clusterInfo: { orgId, tenantPlan, projectId, clusterId, deployType }
} = globalConfig
telemetry.enable(
`tidb-dashboard-for-dbaas-${process.env.REACT_APP_VERSION}`,
{
tenant_id: orgId,
tenant_plan: tenantPlan,
project_id: projectId,
cluster_id: clusterId,
deploy_type: deployType
}
)
if (mixpanelUser) {
telemetry.identifyUser(mixpanelUser)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ export interface IGlobalConfig {
mixpanelUser: string
timezone: number | null
promBaseUrl: string

clusterInfo: {
orgId: string
tenantPlan: string // FREE_TRIAL / POC / ON_DEMAND
projectId: string
clusterId: string
deployType: string // Dedicated / Dev Tier
}
}

export const GlobalConfigContext = createContext<IGlobalConfig | null>(null)
Expand Down
8 changes: 6 additions & 2 deletions ui/packages/tidb-dashboard-lib/src/utils/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ function init(apiHost?: string, token?: string) {
mixpanel.opt_out_tracking()
}

function enable(dashboardVersion: string) {
function enable(
dashboardVersion: string,
extraData: { [k: string]: any } = {}
) {
mixpanel.register({
$current_url: getPathInLocationHash(),
dashboard_version: dashboardVersion
dashboard_version: dashboardVersion,
...extraData
})
mixpanel.opt_in_tracking()
}
Expand Down