added telemetry to importer (#1525)
* added telemetry to importer * wip * ignore typescript errors in jitsu telemetrypull/1569/head
parent
118ee6bfb6
commit
c6e60bd706
|
@ -9,6 +9,7 @@ export const telemetryEventTypes = {
|
||||||
pageView: "page_view",
|
pageView: "page_view",
|
||||||
bookingConfirmed: "booking_confirmed",
|
bookingConfirmed: "booking_confirmed",
|
||||||
bookingCancelled: "booking_cancelled",
|
bookingCancelled: "booking_cancelled",
|
||||||
|
importSubmitted: "import_submitted",
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,7 +71,15 @@ function createTelemetryClient(): TelemetryClient {
|
||||||
if (!window) {
|
if (!window) {
|
||||||
console.warn("Jitsu has been called during SSR, this scenario isn't supported yet");
|
console.warn("Jitsu has been called during SSR, this scenario isn't supported yet");
|
||||||
return;
|
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-ignore
|
||||||
window["jitsu"] = jitsuClient({
|
window["jitsu"] = jitsuClient({
|
||||||
log_level: "ERROR",
|
log_level: "ERROR",
|
||||||
tracking_host: "https://t.calendso.com",
|
tracking_host: "https://t.calendso.com",
|
||||||
|
@ -79,6 +88,9 @@ function createTelemetryClient(): TelemetryClient {
|
||||||
capture_3rd_party_cookies: false,
|
capture_3rd_party_cookies: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// FIXME
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
// @ts-ignore
|
||||||
const res = callback(window["jitsu"]);
|
const res = callback(window["jitsu"]);
|
||||||
if (res && typeof res["catch"] === "function") {
|
if (res && typeof res["catch"] === "function") {
|
||||||
res.catch((e) => {
|
res.catch((e) => {
|
||||||
|
|
|
@ -23,6 +23,7 @@ import { useLocale } from "@lib/hooks/useLocale";
|
||||||
import { getCalendarCredentials, getConnectedCalendars } from "@lib/integrations/calendar/CalendarManager";
|
import { getCalendarCredentials, getConnectedCalendars } from "@lib/integrations/calendar/CalendarManager";
|
||||||
import getIntegrations from "@lib/integrations/getIntegrations";
|
import getIntegrations from "@lib/integrations/getIntegrations";
|
||||||
import prisma from "@lib/prisma";
|
import prisma from "@lib/prisma";
|
||||||
|
import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@lib/telemetry";
|
||||||
import { inferSSRProps } from "@lib/types/inferSSRProps";
|
import { inferSSRProps } from "@lib/types/inferSSRProps";
|
||||||
import { Schedule as ScheduleType } from "@lib/types/schedule";
|
import { Schedule as ScheduleType } from "@lib/types/schedule";
|
||||||
|
|
||||||
|
@ -48,6 +49,7 @@ type ScheduleFormValues = {
|
||||||
export default function Onboarding(props: inferSSRProps<typeof getServerSideProps>) {
|
export default function Onboarding(props: inferSSRProps<typeof getServerSideProps>) {
|
||||||
const { t } = useLocale();
|
const { t } = useLocale();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const telemetry = useTelemetry();
|
||||||
|
|
||||||
const DEFAULT_EVENT_TYPES = [
|
const DEFAULT_EVENT_TYPES = [
|
||||||
{
|
{
|
||||||
|
@ -267,6 +269,13 @@ export default function Onboarding(props: inferSSRProps<typeof getServerSideProp
|
||||||
<form
|
<form
|
||||||
className="flex"
|
className="flex"
|
||||||
onSubmit={formMethods.handleSubmit(async (values) => {
|
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);
|
setSubmitting(true);
|
||||||
const response = await fetch(`/api/import/${selectedImport}`, {
|
const response = await fetch(`/api/import/${selectedImport}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
|
Loading…
Reference in New Issue