Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: custom attributes not being synced in intercom #14600

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you not user session here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the main reason to use this here is because in useIntercom this api is called and the data is not available initially when boot() is called LINK,
so this is to re-run boot when the user data is available

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