Releases: mathieustan/vue-intercom
@vue-intercom v1.0.0-alpha.2
@vue-intercom v1.0.0-alpha.1
Do not use this version.
@vue-intercom v1.0.0-alpha.0
This version is only working with Vue3.
If you want to use vue-intercom for Vue2, you'll need to install v0.0.9.
Install
npm install --save @mathieustan/vue-intercom
yarn add @mathieustan/vue-intercom
CreateApp
import { createApp } from 'vue';
import { createIntercom } from '@mathieustan/vue-intercom';
const app = createApp(/**/);
const intercom = createIntercom({ appId: 'your-app-id' });
app.use(intercom);
Usage inside setup
Inside a setup, you can easily use useIntercom
to manage intercom.
<script setup lang="ts">
import { shallowRef, onBeforeMount, watch } from 'vue';
import { useIntercom } from '@mathieustan/vue-intercom';
const userId = shallowRef('id');
const name = shallowRef('name');
const email = shallowRef('email');
const intercom = useIntercom();
onBeforeMount(() => {
intercom.shutdown();
intercom.once('ready', bootIntercom);
});
watch(email, (newEmail) => {
intercom.update({ email: newEmail });
});
function bootIntercom() {
intercom.boot({
user_id: userId.value,
name: name.value,
email: email.value,
});
intercom.show();
}
</script>
Usage optionS API
vue-intercom handles the injection of Intercom's script into your html and wraps calls to the Intercom API with methods and exposes them through the $intercom object in your components.
new Vue({
el: '#app',
data: () => ({
userId: 1,
name: 'Foo Bar',
email: 'foo@bar.com',
}),
created() {
this.$intercom.shutdown();
this.$intercom.once('ready', this.bootIntercom);
},
watch: {
email(email) {
this.$intercom.update({ email });
},
},
methods: {
bootIntercom() {
this.$intercom.boot({
user_id: this.userId,
name: this.name,
email: this.email,
});
this.$intercom.show();
},
},
});
@intercom v1.0.0-alpha-0
@intercom v1.0.0-alpha-0
You can install intercom only as a service. If you don't want to use Intercom inside vue components.
Install
npm install --save @mathieustan/intercom
yarn add @mathieustan/intercom
Usage
import Intercom from '@mathieustan/intercom';
const appId = 'fakeAppId';
const intercom = new Intercom({ appId });
function startIntercomMessenger (user) {
if (!intercom.ready) {
intercom.once('ready', () => rebootIntercom(user));
} else {
rebootIntercom(user);
}
}
function rebootIntercom () {
intercom.shutdown();
if (intercom.isBooted) return;
intercom.boot(user);
}
v0.0.9
What's new in v0.0.9
Minor updates
- Updated
core-js
dependency to3.14.0
- Removed unnecessary dependencies
- Cleaned husky
v0.0.7
What's new in v0.0.7
π₯ Breaking Change
- Migration from
v0.0.6
tov0.0.7
:
Only if you were using import { Intercom } from '@mathieustan/vue-intercom'
It will no longer wait script to be loaded before init
import { Intercom } from '@mathieustan/vue-intercom';
const appId = 'faleAppId';
// -- Before
async function initIntercomService() {
const service = new Intercom({ appId });
await service.load();
service.init();
return service;
}
async function startIntercomMessenger(user) {
try {
const intercom = await initIntercomService();
intercom.boot(user);
} catch (err) => ...
}
// -- After
function startIntercomMessenger(user) {
try {
const intercom = new Intercom({ appId });
intercom.once('ready', () => intercom.boot(user));
} catch (err) => ...
}
π Fixes
If you are using 'vue-intercom' as vue plugin.
Intercom script may not yet be ready when trying to boot intercom with a user.
To solve this problem, just do:
created() {
this.$intercom.once('ready', () => this.$intercom.boot(this.user));
}
v0.0.6
What's new in v0.0.6
π Fixes
- appId was undefined when loading intercom script
π¨ Clean
- Added more tests
- Renamed some functions
_load => load
|_init => init
|_call => callIntercom
v0.0.5
What's new in v0.0.5
π Fixes
- Now we wait for the intercom script to be loaded before starting
π¨ Redesigned intercom
- Now Intercom can be used with Vue (with $intercom)
- or you can also import { Intercom } to be used as a service. Check README.
v0.0.4
Release v0.0.4
β¨ Props
isBooted
is now set to false on shutting down
v0.0.3
Release v0.0.3
π News
- Added value
isBooted
when $intercom.boot() has been called.
You can access to this value with:this.$intercom.isBooted
π¦ Install
- Block install if appId isn't defined.