Skip to content

Commit

Permalink
update onboarding survery endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
timothycarambat committed Nov 13, 2024
1 parent 27b07d4 commit da3d028
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
44 changes: 28 additions & 16 deletions frontend/src/pages/OnboardingFlow/Steps/Survey/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { COMPLETE_QUESTIONNAIRE } from "@/utils/constants";
import {
COMPLETE_QUESTIONNAIRE,
ONBOARDING_SURVEY_URL,
} from "@/utils/constants";
import paths from "@/utils/paths";
import { CheckCircle } from "@phosphor-icons/react";
import React, { useState, useEffect, useRef } from "react";
Expand All @@ -13,22 +16,31 @@ async function sendQuestionnaire({ email, useCase, comment }) {
return;
}

return fetch(`https://onboarding-wxich7363q-uc.a.run.app`, {
method: "POST",
body: JSON.stringify({
email,
useCase,
comment,
sourceId: "0VRjqHh6Vukqi0x0Vd0n/m8JuT7k8nOz",
}),
})
.then(() => {
window.localStorage.setItem(COMPLETE_QUESTIONNAIRE, true);
console.log(`✅ Questionnaire responses sent.`);
const data = JSON.stringify({
email,
useCase,
comment,
sourceId: "0VRjqHh6Vukqi0x0Vd0n/m8JuT7k8nOz",
});

if (!navigator.sendBeacon) {
console.log("navigator.sendBeacon not supported, falling back to fetch");
return fetch(ONBOARDING_SURVEY_URL, {
method: "POST",
body: data,
})
.catch((error) => {
console.error(`sendQuestionnaire`, error.message);
});
.then(() => {
window.localStorage.setItem(COMPLETE_QUESTIONNAIRE, true);
console.log(`✅ Questionnaire responses sent.`);
})
.catch((error) => {
console.error(`sendQuestionnaire`, error.message);
});
}

navigator.sendBeacon(ONBOARDING_SURVEY_URL, data);
window.localStorage.setItem(COMPLETE_QUESTIONNAIRE, true);
console.log(`✅ Questionnaire responses sent.`);
}

export default function Survey({ setHeader, setForwardBtn, setBackBtn }) {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/utils/constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const API_BASE = import.meta.env.VITE_API_BASE || "/api";
export const ONBOARDING_SURVEY_URL = "https://onboarding.anythingllm.com";

export const AUTH_USER = "anythingllm_user";
export const AUTH_TOKEN = "anythingllm_authToken";
Expand Down

0 comments on commit da3d028

Please sign in to comment.