feat: add user hash for intercom (#8263)

Co-authored-by: Joe Au-Yeung <[email protected]>
Co-authored-by: Peer Richelsen <[email protected]>
This commit is contained in:
authored and GitHub committed 2023-04-19 22:22:07 +02:00
1 parent 877220caa0
commit 8a2ab68e9a
7 files changed
+49 -8

No files matched your search

@@ -187,12 +187,12 @@ export default function HelpMenuItem({ onHelpItemSelect }: HelpMenuItemProps) {
<p className="">{t("specific_issue")}</p>
<button
className="hover:text-emphasis text-defualt font-medium underline"
onClick={() => {
onClick={async () => {
setActive(true);
if (isFreshChatEnabled) {
setFreshChat(true);
} else if (isInterComEnabled) {
open();
await open();
} else {
loadChat({ open: true });
}
@@ -15,8 +15,8 @@ export default function IntercomMenuItem(props: IntercomMenuItemProps) {
return (
<button
onClick={() => {
open();
onClick={async () => {
await open();
onHelpItemSelect();
}}
className="hover:bg-subtle hover:text-emphasis text-default flex w-full px-5 py-2 pr-4 text-sm font-medium">
@@ -25,12 +25,21 @@ export const useIntercom = () => {
const { hasPaidPlan } = useHasPaidPlan();
const { hasTeamPlan } = useHasTeamPlan();
const open = () => {
const open = async () => {
let userHash;
const req = await fetch(`/api/intercom-hash`);
const res = await req.json();
if (res?.hash) {
userHash = res.hash;
}
hookData.boot({
name: data?.name ?? "",
email: data?.email,
userId: String(data?.id),
createdAt: String(dayjs(data?.createdDate).unix()),
...(userHash && { userHash }),
customAttributes: {
//keys should be snake cased
user_name: data?.username,