intercom update

This commit is contained in:
Vladyslav Matsiiako
2023-06-22 14:59:55 -07:00
parent 7b3bd54386
commit 0a6e8e009b
2 changed files with 5 additions and 4 deletions

View File

@ -50,18 +50,16 @@ export const load = () => {
}
}
})();
console.log("loaded", APP_ID);
}
// Initializes Intercom
export const boot = (options = {}) => {
console.log("boot", options)
window &&
window.Intercom &&
window.Intercom("boot", { app_id: APP_ID, ...options });
console.log("booted");
};
export const update = () => {
window && window.Intercom && window.Intercom("update");
console.log("updated");
};

View File

@ -1,6 +1,8 @@
import { useEffect } from "react";
import { useRouter } from "next/router";
import { useUser } from "@app/context";
import {
boot as bootIntercom,
load as loadIntercom,
@ -9,12 +11,13 @@ import {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const IntercomProvider = ({ children }: { children: any }) => {
const { user } = useUser();
const router = useRouter();
if (typeof window !== "undefined") {
console.log("window is defined");
loadIntercom();
bootIntercom();
bootIntercom({name: `${user.firstName} ${user.lastName}`, email: user.email});
}
useEffect(() => {