Skip to content

Commit

Permalink
fix: custom attributes not being synced in intercom (#14600)
Browse files Browse the repository at this point in the history
* fix: custom attributes not being synced in intercom

* fix: ssrInit
  • Loading branch information
SomayChauhan committed Apr 16, 2024
1 parent 1606272 commit b61820d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions apps/web/server/lib/ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export async function ssrInit(context: GetServerSidePropsContext, options?: { no
// Provides a better UX to the users who have already upgraded.
ssr.viewer.teams.hasTeamPlan.prefetch(),
ssr.viewer.public.session.prefetch(),
ssr.viewer.me.prefetch(),
]);

return ssr;
Expand Down
1 change: 1 addition & 0 deletions packages/features/ee/support/lib/intercom/useIntercom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const useIntercom = () => {
const { hasTeamPlan } = useHasTeamPlan();

const boot = async () => {
if (!data) return;
let userHash;

const req = await fetch(`/api/intercom-hash`);
Expand Down
8 changes: 5 additions & 3 deletions packages/features/shell/Shell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,17 @@ const useBanners = () => {
const Layout = (props: LayoutProps) => {
const banners = useBanners();

const showIntercom = localStorage.getItem("showIntercom");
const { data: user } = trpc.viewer.me.useQuery();
const { boot } = useIntercom();
const pageTitle = typeof props.heading === "string" && !props.title ? props.heading : props.title;

useEffect(() => {
// not using useMediaQuery as it toggles between true and false
if (showIntercom === "false" || window.innerWidth <= 768) return;
const showIntercom = localStorage.getItem("showIntercom");
if (showIntercom === "false" || window.innerWidth <= 768 || !user) return;
boot();
}, [showIntercom]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [user]);

const bannersHeight = useMemo(() => {
const activeBanners =
Expand Down

0 comments on commit b61820d

Please sign in to comment.