feat: event tracking using posthog and created application provider to render multiple wrappers (#2757)
* fix: event tracker changes * fix: App provider implementation using wrappers * fix: updating packages * fix: handling warning * fix: wrapper fixes and minor optimization changes * fix: chore app-provider clearnup * fix: cleanup * fix: removing jitsu tracking * fix: minor updates * fix: adding event to posthog event tracker (#2802) * dev: posthog event tracker update intitiate * fix: adding events for posthog integration * fix: event payload --------- Co-authored-by: Ramesh Kumar Chandra <31303617+rameshkumarchandra@users.noreply.github.com>
This commit is contained in:
parent
33be52792f
commit
78fee22fec
114 changed files with 825 additions and 2768 deletions
|
|
@ -1,45 +0,0 @@
|
|||
import { useCallback, useEffect } from "react";
|
||||
import { observer } from "mobx-react-lite";
|
||||
// hooks
|
||||
import { useMobxStore } from "lib/mobx/store-provider";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
$crisp: any;
|
||||
CRISP_WEBSITE_ID: any;
|
||||
}
|
||||
}
|
||||
|
||||
const Crisp = observer(() => {
|
||||
const {
|
||||
user: { currentUser },
|
||||
} = useMobxStore();
|
||||
|
||||
const validateCurrentUser = useCallback(() => {
|
||||
if (currentUser) return currentUser.email;
|
||||
return null;
|
||||
}, [currentUser]);
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window && validateCurrentUser()) {
|
||||
window.$crisp = [];
|
||||
window.CRISP_WEBSITE_ID = process.env.NEXT_PUBLIC_CRISP_ID;
|
||||
(function () {
|
||||
var d = document;
|
||||
var s = d.createElement("script");
|
||||
s.src = "https://client.crisp.chat/l.js";
|
||||
s.async = true;
|
||||
d.getElementsByTagName("head")[0].appendChild(s);
|
||||
// defining email when logged in
|
||||
if (validateCurrentUser()) {
|
||||
window.$crisp.push(["set", "user:email", [validateCurrentUser()]]);
|
||||
window.$crisp.push(["do", "chat:hide"]);
|
||||
window.$crisp.push(["do", "chat:close"]);
|
||||
}
|
||||
})();
|
||||
}
|
||||
}, [validateCurrentUser]);
|
||||
|
||||
return <></>;
|
||||
});
|
||||
export default Crisp;
|
||||
Loading…
Add table
Add a link
Reference in a new issue