Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions console/e2e-tests/platform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,8 @@ for (const region of REGIONS) {
// await testAccountBlocking(page, context, region);
// }

// Wait for the onboarding survey to load then skip it
await page.getByTestId("onboarding-survey").waitFor();
await context.goto(`${CONSOLE_ADDR}/environment-not-ready/enable-region`);
// Wait for the enable region page to load
await page.getByTestId("enable-region").waitFor();

await retry(
async () => {
Expand Down
4 changes: 2 additions & 2 deletions console/e2e-tests/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ export class TestContext {

// Navigate to the home page && wait for that to load.
await context.goto(CONSOLE_ADDR);
// We assume the first page is the onboarding survey
await page.waitForSelector("[data-testid=onboarding-survey]");
// We assume the first page is the enable region page
await page.waitForSelector("[data-testid=enable-region]");
return context;
}

Expand Down
83 changes: 0 additions & 83 deletions console/src/analytics/hubspot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import {
import { getStore } from "~/jotai";

import {
ONBOARDING_SURVEY_API_ENDPOINT,
submitOnboardingSurvey,
TRACK_SIGNUP_API_ENDPOINT,
trackSignupInHubspot,
trackSignUpInHubspotActions,
Expand All @@ -35,22 +33,6 @@ const trackSignupErrorHandler = http.post(TRACK_SIGNUP_API_ENDPOINT, () => {
return HttpResponse.error();
});

const onboardingSurveySuccessHandlerSpy = vi.fn();

const onboardingSurveySuccessHandler = http.post(
ONBOARDING_SURVEY_API_ENDPOINT,
() => {
onboardingSurveySuccessHandlerSpy();
return HttpResponse.json({ ok: true });
},
);
const onboardingSurveyErrorHandler = http.post(
ONBOARDING_SURVEY_API_ENDPOINT,
() => {
return HttpResponse.error();
},
);

describe("trackSignupInHubspot", () => {
beforeEach(() => {
vi.resetAllMocks();
Expand Down Expand Up @@ -117,71 +99,6 @@ describe("trackSignupInHubspot", () => {
});
});

describe("submitOnboardingSurvey", () => {
beforeEach(() => {
vi.resetAllMocks();
});

it("successfully calls the hubspot api", async () => {
server.use(onboardingSurveySuccessHandler);
await submitOnboardingSurvey({
email: "someuser@example.com",
organizationId: "9e8b1bc8-fa08-4870-a21f-22ac01cc3808",
userId: "some-user-id",
roleDescription: "Other",
materializeUseCase: "Other",
projectDescription: "Other",
primaryDataSource: "Other",
});
expect(onboardingSurveySuccessHandlerSpy).toHaveBeenCalledOnce();
});

it("retries if the the call fails initially", async () => {
server.use(
http.post(
TRACK_SIGNUP_API_ENDPOINT,
() => {
return HttpResponse.error();
},
{ once: true },
),
onboardingSurveySuccessHandler,
);
await submitOnboardingSurvey(
{
email: "someuser@example.com",
organizationId: "9e8b1bc8-fa08-4870-a21f-22ac01cc3808",
userId: "some-user-id",
roleDescription: "Other",
materializeUseCase: "Other",
projectDescription: "Other",
primaryDataSource: "Other",
},
{ retryDelay: 10 },
);
expect(onboardingSurveySuccessHandlerSpy).toHaveBeenCalledOnce();
});

it("fails after 3 tries", async () => {
server.use(onboardingSurveyErrorHandler);
await expect(() =>
submitOnboardingSurvey(
{
email: "someuser@example.com",
organizationId: "9e8b1bc8-fa08-4870-a21f-22ac01cc3808",
userId: "some-user-id",
roleDescription: "Other",
materializeUseCase: "Other",
projectDescription: "Other",
primaryDataSource: "Other",
},
{ retryDelay: 10 },
),
).rejects.toThrowError();
expect(onboardingSurveySuccessHandlerSpy).not.toHaveBeenCalled();
});
});

describe("trackSignUpInHubspotActions", () => {
it("should reset state on userVerified when in signedUp state", async () => {
const store = getStore();
Expand Down
125 changes: 0 additions & 125 deletions console/src/analytics/hubspot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,7 @@ import {
} from "~/external-library-wrappers/frontegg";
import { getStore } from "~/jotai";
import { getQueryClient } from "~/queryClient";
import { notNullOrUndefined } from "~/util";

import {
MaterializeUseCase,
PrimaryDataSource,
ProjectDescription,
RoleDescription,
} from "./onboardingSurveyOptions";
import { segment } from "./segment";

async function getAnonymousId() {
Expand Down Expand Up @@ -60,11 +53,6 @@ export const TRACK_SIGNUP_API_ENDPOINT = buildFormSubmissionUrl({
formGuid: "e1f0065e-c5ec-4004-afb7-d4aeab96c6b2",
});

export const ONBOARDING_SURVEY_API_ENDPOINT = buildFormSubmissionUrl({
portalId: "23399445",
formGuid: "7038d05b-0ad2-4c85-8ef7-36a163c6ddaf",
});

type HubspotPayload = {
fields: { name: string; value: string }[];
context: { pageUri: string; hutk?: string };
Expand All @@ -76,10 +64,6 @@ export const hubspotQueryKeys = {
...hubspotQueryKeys.all(),
buildGlobalQueryKey("track-signup"),
],
onboardingSurvey: () => [
...hubspotQueryKeys.all(),
buildGlobalQueryKey("onboarding-survey"),
],
};

export async function trackSignupInHubspot(
Expand Down Expand Up @@ -204,112 +188,3 @@ export const trackSignUpInHubspotActions = {
}
},
};

type OnboardingSurveyPayload = {
email: string;
organizationId: string;
userId: string;
roleDescription: RoleDescription;
roleDescriptionDetails?: string;
materializeUseCase: MaterializeUseCase;
materializeUseCaseDetails?: string;
projectDescription: ProjectDescription;
projectDescriptionDetails?: string;
primaryDataSource: PrimaryDataSource;
primaryDataSourceDetails?: string;
};

export async function submitOnboardingSurvey(
payload: OnboardingSurveyPayload,
options?: { retryDelay?: number },
) {
const data: HubspotPayload = {
fields: [
{ name: "email", value: payload.email },
{ name: "organization_id", value: payload.organizationId },
{ name: "mz_user_id", value: payload.userId },

{
name: "how_would_you_describe_your_role_",
value: payload.roleDescription,
},

{
name: "why_are_you_trying_materialize_",
value: payload.materializeUseCase,
},

{
name: "what_are_you_trying_to_solve_with_materialize_",
value: payload.projectDescription,
},

{
name: "what_is_the_primary_or_origin_data_source_",
value: payload.primaryDataSource,
},
],
context: {
pageUri: window.location.href,
},
};

[
{
name: "how_would_you_describe_your_role__details",
value: payload.roleDescriptionDetails,
},
{
name: "why_are_you_trying_materialize__details",
value: payload.materializeUseCaseDetails,
},
{
name: "what_are_you_trying_to_solve_with_materialize__details",
value: payload.projectDescriptionDetails,
},
{
name: "what_is_the_primary_or_origin_data_source__details",
value: payload.primaryDataSourceDetails,
},
].forEach(({ name, value }) => {
if (notNullOrUndefined(value)) {
data.fields.push({
name: name,
value: value,
});
}
});

const hutk = getHubspotUtk();
if (hutk) {
data.context = {
...data.context,
hutk,
};
}

return getQueryClient()
.getMutationCache()
.build(getQueryClient(), {
mutationKey: hubspotQueryKeys.onboardingSurvey(),
mutationFn: (params: HubspotPayload) => {
return fetch(ONBOARDING_SURVEY_API_ENDPOINT, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(params),
});
},
retry: 3,
retryDelay: options?.retryDelay,
onError: (error) => {
Sentry.captureException(
new Error("Hubspot onboarding survey submit failed", {
cause: error,
}),
);
},
})
.execute(data);
}
97 changes: 0 additions & 97 deletions console/src/analytics/onboardingSurveyOptions.ts

This file was deleted.

Loading
Loading