@@ -266,6 +266,7 @@ import {
266266import DOMPurify from " dompurify" ;
267267import { ButtonStyled } from " @modrinth/ui" ;
268268import { refThrottled } from " @vueuse/core" ;
269+ import { Intercom , shutdown } from " @intercom/messenger-js-sdk" ;
269270import type { ServerState , Stats , WSEvent , WSInstallationResultEvent } from " ~/types/servers" ;
270271
271272const socket = ref <WebSocket | null >(null );
@@ -275,6 +276,19 @@ const reconnectInterval = ref<ReturnType<typeof setInterval> | null>(null);
275276const isFirstMount = ref (true );
276277const isMounted = ref (true );
277278
279+ const INTERCOM_APP_ID = ref (" ykeritl9" );
280+ const auth = await useAuth ();
281+ // @ts-expect-error - Auth is untyped
282+ const userId = ref (auth .value ?.user ?.id ?? null );
283+ // @ts-expect-error - Auth is untyped
284+ const username = ref (auth .value ?.user ?.username ?? null );
285+ // @ts-expect-error - Auth is untyped
286+ const email = ref (auth .value ?.user ?.email ?? null );
287+ const createdAt = ref (
288+ // @ts-expect-error - Auth is untyped
289+ auth .value ?.user ?.created ? Math .floor (new Date (auth .value .user .created ).getTime () / 1000 ) : null ,
290+ );
291+
278292const route = useNativeRoute ();
279293const router = useRouter ();
280294const serverId = route .params .id as string ;
@@ -735,6 +749,8 @@ const openInstallLog = () => {
735749const cleanup = () => {
736750 isMounted .value = false ;
737751
752+ shutdown ();
753+
738754 stopPolling ();
739755 stopUptimeUpdates ();
740756 if (reconnectInterval .value ) {
@@ -774,6 +790,27 @@ onMounted(() => {
774790 connectWebSocket ();
775791 }
776792
793+ if (username .value && email .value && userId .value && createdAt .value ) {
794+ const currentUser = auth .value ?.user as any ;
795+ const matches =
796+ username .value === currentUser ?.username &&
797+ email .value === currentUser ?.email &&
798+ userId .value === currentUser ?.id &&
799+ createdAt .value === Math .floor (new Date (currentUser ?.created ).getTime () / 1000 );
800+
801+ if (matches ) {
802+ Intercom ({
803+ app_id: INTERCOM_APP_ID .value ,
804+ userId: userId .value ,
805+ name: username .value ,
806+ email: email .value ,
807+ created_at: createdAt .value ,
808+ });
809+ } else {
810+ console .warn (" [PYROSERVERS][INTERCOM] mismatch" );
811+ }
812+ }
813+
777814 DOMPurify .addHook (
778815 " afterSanitizeAttributes" ,
779816 (node : {
0 commit comments