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

Error with 'setVisitorInfo' or 'sendOfflineMsg' - Cannot set property 'lastIndex' of undefined #25

Open
ecadagiani opened this issue Aug 29, 2019 · 0 comments

Comments

@ecadagiani
Copy link

On my react zendesk webchat, I try to make a form to send the user name, email, and phone number.

For this I initialize the webchat, set the current visitor, then I send the data.

Here is my code:

const msg = {
    name: this.inputNameRef.current.value,
    email: this.inputMailRef.current.value,
    phone: this.inputPhoneRef.current.value,
    message: `Demande de démo depuis ${this.getDemoRequestPath()}`
}; // {name: "foo bar", email: "foo@bar.io", phone: "0611223344", message: "Demande de démo depuis /solutions/theapp"}

// Need to init the chat to be able to send offline message..
if (!this.props.data.isChatInit) {
    zChat.init({
        account_key: ACCOUNT_KEY
    });
    this.props.dispatch({
        type: 'initChat'
    });
}

zChat.setVisitorInfo({
    display_name: this.inputNameRef.current.value,
    email: this.inputMailRef.current.value,
    phone: this.inputPhoneRef.current.value
}, (err) => {
    if (err) log('Error setting visitor info');
});

zChat.sendOfflineMsg(msg, (err) => {
    if (err) log('Error sending demo request form');
});

When I try this, setVisitorInfo trigger this error:

web-sdk.js?452d:1453 Uncaught TypeError: Cannot set property 'lastIndex' of undefined
    at eval (eval at <anonymous> (widget.js:1465), <anonymous>:1453:21)
    at i.E.validate (eval at <anonymous> (widget.js:1465), <anonymous>:1533:13)
    at eval (eval at <anonymous> (widget.js:1465), <anonymous>:1411:25)
    at i.E.validate (eval at <anonymous> (widget.js:1465), <anonymous>:1533:13)
    at eval (eval at <anonymous> (widget.js:1465), <anonymous>:1433:22)
    at i.E.validate (eval at <anonymous> (widget.js:1465), <anonymous>:1533:13)
    at le (eval at <anonymous> (widget.js:1465), <anonymous>:5038:27)
    at h (eval at <anonymous> (widget.js:1465), <anonymous>:4559:12)
    at Object.eval [as setVisitorInfo] (eval at <anonymous> (widget.js:1465), <anonymous>:5220:33)
    at DemoRequestForm.send (eval at <anonymous> (widget.js:2221), <anonymous>:139:24)

If I comment setVisitorInfo, and just leave sendOfflineMsg the same error is trigger.

I check: my msg is correct, and the init is executed. And I do not receive anything from zChat.on()

This is a zChat bug or just me who is forgotten an info?

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

1 participant