Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes made through setAttributes are only reflected sporadically in tawkto dashboard #26

Open
mleister97 opened this issue Aug 2, 2023 · 1 comment

Comments

@mleister97
Copy link

mleister97 commented Aug 2, 2023

In my code, I use the SecureMode, and I have made sure that the method setAttributes is only called when all values are available. I see in the WebSocket connection that the data is being transmitted successfully. However, the callback function of setAttributes returns undefined, and none of the possible errors mentioned in the documentation. Sometimes, the attributes get updated in the dashboard, but sometimes they don't. Could it be that they are not being added live, or are there currently any issues?

import React, {useEffect, useRef, useState} from 'react';
import {useAuth} from "./auth/context";
import TawkMessengerReact from '@tawk.to/tawk-messenger-react';

function generateName() {...}

const TawkMessenger = () => {
    const tawkMessengerRef = useRef();
    const {user} = useAuth()
    const [isTawkLoaded, setIsTawkLoaded] = useState(false)

    useEffect(() => {
        if (tawkMessengerRef.current == null || user == null || !isTawkLoaded) return
        tawkMessengerRef.current.setAttributes({
            reference: user.id,
            name: generateName(user.firstName, user.lastName),
            email: user.email,
            hash: user.tawktoHash,
        }, function (error: unknown) {
            console.log(error)
        })
    }, [user?.tawktoHash, user?.firstName, user?.lastName, user?.email, user?.id, isTawkLoaded])

    return <TawkMessengerReact
        onLoad={() => { setIsTawkLoaded(true) }}
        propertyId="XXXXX"
        widgetId="XXXXX"
        ref={tawkMessengerRef}
    />
}

export default TawkMessenger

Websocket:
image

Dashboard View:

tawkto

@jaoaustero
Copy link
Contributor

Hello, this is correct since setAttributes is async in our backend and it takes time to reflect in the dashboard, If your data is prepared already before you load the widget, you can use the visitor API instead it's more realtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants