-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
track project id in intercom (#3941)
- Loading branch information
Feroze Mohideen
authored
Nov 7, 2023
1 parent
615323b
commit 0056bf8
Showing
2 changed files
with
36 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,36 @@ | ||
// useIntercom contains all the utility methods related to the Intercom chat widget | ||
export const useIntercom = () => { | ||
const showIntercomWithMessageAfterDelay = (message: string, delaySeconds: number) => { | ||
const func = () => { | ||
if (typeof window.Intercom === 'function') { | ||
window.Intercom('showNewMessage', message); | ||
} | ||
} | ||
setTimeout(func, delaySeconds * 1000); | ||
} | ||
export const useIntercom = (): { | ||
showIntercomWithMessage: ({ | ||
message, | ||
delaySeconds, | ||
}: { | ||
message: string; | ||
delaySeconds?: number | undefined; | ||
}) => void; | ||
} => { | ||
const showIntercomWithMessageAfterDelay = ( | ||
message: string, | ||
delaySeconds: number | ||
): void => { | ||
const func = (): void => { | ||
if (typeof window.Intercom === "function") { | ||
window.Intercom("showNewMessage", message); | ||
} | ||
}; | ||
setTimeout(func, delaySeconds * 1000); | ||
}; | ||
|
||
const showIntercomWithMessage = ({ message, delaySeconds = 3 }: { message: string, delaySeconds?: number }) => { | ||
showIntercomWithMessageAfterDelay(message, delaySeconds); | ||
} | ||
const showIntercomWithMessage = ({ | ||
message, | ||
delaySeconds = 3, | ||
}: { | ||
message: string; | ||
delaySeconds?: number; | ||
}): void => { | ||
showIntercomWithMessageAfterDelay(message, delaySeconds); | ||
}; | ||
|
||
return { | ||
showIntercomWithMessage, | ||
} | ||
} | ||
return { | ||
showIntercomWithMessage, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters