Skip to content

Commit 8edffef

Browse files
committed
instance info into telemetry
1 parent ca3a1fe commit 8edffef

3 files changed

Lines changed: 31 additions & 12 deletions

File tree

packages/web-console/src/components/TopBar/toolbar.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ import { InstanceSettingsPopper } from "./InstanceSettingsPopper"
1919
import { Preferences, InstanceType } from "../../utils"
2020
import { PopperHover, Placement } from "../"
2121
import { useTheme } from "styled-components"
22+
import { TelemetryTable } from "../../consts";
23+
import { TelemetryConfigShape } from "../../store/Telemetry/types";
24+
import { sendEntTelemetry } from "../../utils/telemetry";
2225

2326
const EnvIconWrapper = styled.div<{ $background?: string }>`
2427
display: flex;
@@ -415,8 +418,14 @@ export const Toolbar = () => {
415418
try {
416419
const result = await quest.savePreferences(values)
417420
if (result.success) {
418-
handleToggle(false)
421+
await handleToggle(false)
419422
toast.success("Instance information updated successfully.")
423+
424+
const response = await quest.query<TelemetryConfigShape>(`${TelemetryTable.CONFIG} limit -1`)
425+
if (response.type === QuestDB.Type.DQL && response.count === 1) {
426+
const config = response.data[0] as TelemetryConfigShape
427+
sendEntTelemetry(config)
428+
}
420429
return
421430
}
422431

packages/web-console/src/store/Telemetry/epics.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import * as QuestDB from "../../utils/questdb"
4444
import { getValue } from "../../utils/localStorage"
4545
import { StoreKey } from "../../utils/localStorage/types"
4646
import { AuthPayload } from "../../modules/OAuth2/types"
47+
import { sendEntTelemetry } from "../../utils/telemetry";
4748

4849
const quest = new QuestDB.Client()
4950

@@ -100,17 +101,8 @@ export const getRemoteConfig: Epic<StoreAction, TelemetryAction, StoreShape> = (
100101
withLatestFrom(state$),
101102
switchMap(([_, state]) => {
102103
const config = selectors.telemetry.getConfig(state)
103-
104-
const releaseType = getValue(StoreKey.RELEASE_TYPE);
105-
if (releaseType === "EE" || config?.enabled) {
106-
fetch(`${API}/add-ent`, {
107-
method: "POST",
108-
headers: {
109-
"Content-Type": "application/json",
110-
},
111-
body: JSON.stringify({ ...config, releaseType }),
112-
}).catch( () => {
113-
})
104+
if (config) {
105+
sendEntTelemetry(config)
114106
}
115107

116108
if (config?.enabled) {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { getValue } from "./localStorage";
2+
import { StoreKey } from "./localStorage/types";
3+
import { API } from "../consts";
4+
import { TelemetryConfigShape } from "../store/Telemetry/types";
5+
6+
export const sendEntTelemetry = (config: Readonly<TelemetryConfigShape>) => {
7+
const releaseType = getValue(StoreKey.RELEASE_TYPE);
8+
if (releaseType === "EE" || config?.enabled) {
9+
fetch(`${API}/add-ent`, {
10+
method: "POST",
11+
headers: {
12+
"Content-Type": "application/json",
13+
},
14+
body: JSON.stringify({...config, releaseType}),
15+
}).catch(() => {
16+
})
17+
}
18+
}

0 commit comments

Comments
 (0)