-
Notifications
You must be signed in to change notification settings - Fork 5
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
how can i use in nuxt3 with provide function #10
Comments
This would be a great addition. But judging by the engagement on this repo, I don't see that happening any time soon? Also, the injections are wildly crazy in the way they just overwrite words without any namespacing. |
Just use |
That's how I ended up doing it. Sadly, I think you are right @Harm-Nullix, this vue3 component does not appear to be very high on the list for Tawk. We've started thinking about an alternative provider because of the dev api/docs/utilities. In the mean time, maybe my implementation can help someone to implement their solution with Nuxt3: I built this plugin / provider: import TawkMessengerVue from '@tawk.to/tawk-messenger-vue-3'
import { consola } from 'consola'
export default defineNuxtPlugin((nuxtApp) => {
const logger = consola.withTag('Plugin/TawkWidget.Client')
logger.debug('🛠️ Setup')
logger.debug('Loading Tawk')
nuxtApp.vueApp.use(TawkMessengerVue, {
propertyId: useRuntimeConfig().public.tawkto.idProperty,
widgetId: useRuntimeConfig().public.tawkto.idWidget,
})
return {
provide: {
tawk: window.Tawk_API,
},
}
}) Which then lets me do things like this: try {
const { $tawk } = useNuxtApp()
const tawkOnLoad = inject('onLoad')
tawkOnLoad(() => {
logger.debug('🦜 Tawk finished loading?', $tawk)
watchImmediate(route, (route) => {
const options = {
route: route.path,
}
try {
$tawk.setAttributes(options, result => logger.debug('🦜 Tawk set attributes', options, result))
}
catch (error) {
logger.warn('Tawk Error while setAttributes', error)
}
})
watchImmediate(userCurrent, (user) => {
const options = {
name: user?.displayName,
email: user?.email,
userId: user?.uid,
subscription: userCurrentClaims.value?.stripe?.status || 'none',
status: user ? 'registered' : 'anonymous',
}
try {
$tawk.setAttributes(options, result => logger.debug('🦜 Tawk set attributes', options, result))
}
catch (error) {
logger.warn('Tawk Error while setAttributes', error)
}
})
})
}
catch (error) {
logger.warn('Tawk Loading Error', error)
} |
how can i use in nuxt3 with provide function to set visitor
The text was updated successfully, but these errors were encountered: