Scheduling infrastructure for absolutely everyone.
added telemetry to importer (#1525)
Peer Richelsenc6e60bd70697
diff --git a/lib/telemetry.ts b/lib/telemetry.tsindex 6b945b07b5f..9f2cd6433ab 100644--- a/lib/telemetry.ts+++ b/lib/telemetry.ts@@ -9,6 +9,7 @@ export const telemetryEventTypes = {pageView: "page_view",bookingConfirmed: "booking_confirmed",bookingCancelled: "booking_cancelled",+ importSubmitted: "import_submitted",};/**@@ -70,7 +71,15 @@ function createTelemetryClient(): TelemetryClient {if (!window) {console.warn("Jitsu has been called during SSR, this scenario isn't supported yet");return;- } else if (!window["jitsu"]) {+ } else if (+ // FIXME+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment+ // @ts-ignore+ !window["jitsu"]+ ) {+ // FIXME+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment+ // @ts-ignorewindow["jitsu"] = jitsuClient({log_level: "ERROR",tracking_host: "https://t.calendso.com",@@ -79,6 +88,9 @@ function createTelemetryClient(): TelemetryClient {capture_3rd_party_cookies: false,});}+ // FIXME+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment+ // @ts-ignoreconst res = callback(window["jitsu"]);if (res && typeof res["catch"] === "function") {res.catch((e) => {diff --git a/pages/getting-started.tsx b/pages/getting-started.tsxindex ce1597d5b0f..107de631b82 100644--- a/pages/getting-started.tsx+++ b/pages/getting-started.tsx@@ -23,6 +23,7 @@ import { useLocale } from "@lib/hooks/useLocale";import { getCalendarCredentials, getConnectedCalendars } from "@lib/integrations/calendar/CalendarManager";import getIntegrations from "@lib/integrations/getIntegrations";import prisma from "@lib/prisma";+import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@lib/telemetry";import { inferSSRProps } from "@lib/types/inferSSRProps";import { Schedule as ScheduleType } from "@lib/types/schedule";@@ -48,6 +49,7 @@ type ScheduleFormValues = {export default function Onboarding(props: inferSSRProps<typeof getServerSideProps>) {const { t } = useLocale();const router = useRouter();+ const telemetry = useTelemetry();const DEFAULT_EVENT_TYPES = [{@@ -267,6 +269,13 @@ export default function Onboarding(props: inferSSRProps<typeof getServerSideProp<formclassName="flex"onSubmit={formMethods.handleSubmit(async (values) => {+ // track the number of imports. Without personal data/payload+ telemetry.withJitsu((jitsu) =>+ jitsu.track(telemetryEventTypes.importSubmitted, {+ ...collectPageParameters(),+ selectedImport,+ })+ );setSubmitting(true);const response = await fetch(`/api/import/${selectedImport}`, {method: "POST",