papamonkey / vue-tawk

wrapper of tawk
MIT License
25 stars 21 forks source link

updateChatUser doesn't work #8

Open VincentMRA opened 4 years ago

VincentMRA commented 4 years ago

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.

davidplappert commented 4 years ago

same issue

yzoldan commented 4 years ago

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.

albertovincenzi commented 3 years ago

You might try to install my fork. It should work correctly: https://github.com/albertovincenzi/vue-tawk

Just run npm install albertovincenzi/vue-tawk

mheers commented 3 years ago

@albertovincenzi Thanks very much for your work! I can confirm that it works as intended.

waziaq commented 2 years ago

@albertovincenzi I try to use your fork but still have an error when set the atrribute. window.Tawk_API.setAttributes is not a function

albertovincenzi commented 2 years ago

@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 commented 2 years ago

@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. image

albertovincenzi commented 2 years ago

Maybe you are calling that function before Tawk is initialized. I think it might be a lifecycle issue.

waziaq commented 2 years ago

@albertovincenzi Work now, thanks. I miss the lifecycle.

albertovincenzi commented 9 months ago

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