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
@@ -50,18 +50,16 @@ export const load = () => {
} }
} }
})(); })();
console.log("loaded", APP_ID);
} }
// Initializes Intercom // Initializes Intercom
export const boot = (options = {}) => { export const boot = (options = {}) => {
console.log("boot", options)
window && window &&
window.Intercom && window.Intercom &&
window.Intercom("boot", { app_id: APP_ID, ...options }); window.Intercom("boot", { app_id: APP_ID, ...options });
console.log("booted");
}; };
export const update = () => { export const update = () => {
window && window.Intercom && window.Intercom("update"); window && window.Intercom && window.Intercom("update");
console.log("updated");
}; };
@@ -1,6 +1,8 @@
import { useEffect } from "react"; import { useEffect } from "react";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import { useUser } from "@app/context";
import { import {
boot as bootIntercom, boot as bootIntercom,
load as loadIntercom, load as loadIntercom,
@@ -9,12 +11,13 @@ import {
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
export const IntercomProvider = ({ children }: { children: any }) => { export const IntercomProvider = ({ children }: { children: any }) => {
const { user } = useUser();
const router = useRouter(); const router = useRouter();
if (typeof window !== "undefined") { if (typeof window !== "undefined") {
console.log("window is defined"); console.log("window is defined");
loadIntercom(); loadIntercom();
bootIntercom(); bootIntercom({name: `${user.firstName} ${user.lastName}`, email: user.email});
} }
useEffect(() => { useEffect(() => {