import { BaseAPIClient } from "./types" import { AnalyticsPingRequest } from "@budibase/types" export interface AnalyticsEndpoints { getAnalyticsStatus: () => Promise<{ enabled: boolean }> analyticsPing: ( payload: Omit ) => Promise } export const buildAnalyticsEndpoints = ( API: BaseAPIClient ): AnalyticsEndpoints => ({ /** * Gets the current status of analytics for this environment */ getAnalyticsStatus: async () => { return await API.get({ url: "/api/bbtel", }) }, /** * Notifies analytics of a certain environment */ analyticsPing: async request => { return await API.post({ url: "/api/bbtel/ping", body: { ...request, timezone: Intl.DateTimeFormat().resolvedOptions().timeZone, }, }) }, })