budibase/packages/frontend-core/src/api/analytics.ts

37 lines
924 B
TypeScript
Raw Normal View History

import { BaseAPIClient } from "./types"
import { AnalyticsEnabledResponse, AnalyticsPingRequest } from "@budibase/types"
export interface AnalyticsEndpoints {
getAnalyticsStatus: () => Promise<AnalyticsEnabledResponse>
2024-12-02 11:02:30 +01:00
analyticsPing: (
payload: Omit<AnalyticsPingRequest, "timezone">
) => Promise<void>
}
export const buildAnalyticsEndpoints = (
API: BaseAPIClient
): AnalyticsEndpoints => ({
/**
* Gets the current status of analytics for this environment
*/
getAnalyticsStatus: async () => {
return await API.get({
url: "/api/bbtel",
})
},
2024-12-02 11:02:30 +01:00
/**
* Notifies analytics of a certain environment
*/
2024-12-02 11:02:30 +01:00
analyticsPing: async request => {
return await API.post<AnalyticsPingRequest>({
url: "/api/bbtel/ping",
2024-12-02 11:02:30 +01:00
body: {
...request,
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
},
2024-12-05 17:44:56 +01:00
parseResponse: () => undefined,
})
},
})