Open VincentMRA opened 4 years ago
same issue
I've found a couple of bugs in the code but I haven't been able to solve them yet.
The first problem is that the window.Tawk_API.onLoad
function isn't being called on the $updateChatUser
method:
Vue.prototype.$Tawk.$updateChatUser = function (user) {
if (!user) return
window.Tawk_API.onLoad = function () {
// This doesn't run...
window.Tawk_API.setAttributes({
'name': user.name,
'email': user.email,
'hash': user.emailHmac
}, function (error) {
console.log(error)
})
}
}
The second is that in the documentation the user object is specified with a hash
key but in the code it expects a emailHmac
key.
Lastly, when inspecting the minified version of the code I found that name
in user
is created from a first_name
and last_name
key that isn't in the original code.
The last two problems are easy enough to solve by adjusting the user
object we provide but I don't know how to get the onLoad
function to trigger.
You might try to install my fork. It should work correctly: https://github.com/albertovincenzi/vue-tawk
Just run npm install albertovincenzi/vue-tawk
@albertovincenzi Thanks very much for your work! I can confirm that it works as intended.
@albertovincenzi I try to use your fork but still have an error when set the atrribute. window.Tawk_API.setAttributes is not a function
@waziaq you can use $Tawk.$updateChatUser()
which implement setAttributes:
let user = {
name: this.userData.name,
email: this.userData.email,
hash: this.userData.tawkHash
};
this.$Tawk.$updateChatUser(user);
@waziaq you can use
$Tawk.$updateChatUser()
which implement setAttributes:let user = { name: this.userData.name, email: this.userData.email, hash: this.userData.tawkHash }; this.$Tawk.$updateChatUser(user);
Yes, I use it. But still show window.Tawk_API.setAttributes is not a function
. I don't why. This this.$Tawk.$startChat();
can work. If I use another function still shows say error.
Maybe you are calling that function before Tawk is initialized. I think it might be a lifecycle issue.
@albertovincenzi Work now, thanks. I miss the lifecycle.
If anyone interested, I rewrote the plugin from scratch adding all the missing functionalities check here It's not a drop-in replacement for this library, so read the documentation before evaluating the migration
Update chat user once user has signed up/ signed in doesn't seem to work. No error logging, but no changes in the tawk app. Tried with the secure hash and without but neither work. Even when using the secure API and no hash i don't get any error logging.