diff --git a/src/components/Intercom/Intercom.tsx b/src/components/Intercom/Intercom.tsx index 16dc56b7a..7e40793db 100644 --- a/src/components/Intercom/Intercom.tsx +++ b/src/components/Intercom/Intercom.tsx @@ -2,27 +2,26 @@ import React, { useState, useCallback, useEffect } from 'react' import IntercomWidget from 'decentraland-dapps/dist/components/Intercom' import { getAnalytics, getAnonymousId } from 'decentraland-dapps/dist/modules/analytics/utils' import { config } from 'config' +import { IntercomUserData } from './Intercom.types' const APP_ID = config.get('INTERCOM_APP_ID', '') const analytics = getAnalytics() export const Intercom: React.FC = () => { - const [dclAnonymousUserID, setDclAnonymousUserID] = useState('') + const [intercomUserData, setIntercomUserData] = useState() const analyticsReadyCallback = useCallback(() => { const dclAnonymousUserID = getAnonymousId() if (dclAnonymousUserID) { - setDclAnonymousUserID(dclAnonymousUserID) + setIntercomUserData({ ...intercomUserData, anon_id: dclAnonymousUserID }) } - }, []) + }, [intercomUserData]) useEffect(() => { analytics.ready(analyticsReadyCallback) }, [analyticsReadyCallback]) - return dclAnonymousUserID ? ( - - ) : null + return } export default Intercom diff --git a/src/components/Intercom/Intercom.types.ts b/src/components/Intercom/Intercom.types.ts new file mode 100644 index 000000000..296a06c09 --- /dev/null +++ b/src/components/Intercom/Intercom.types.ts @@ -0,0 +1,3 @@ +export interface IntercomUserData { + anon_id: string | undefined +}