#docs #guides #Setup #JavaScript #Node #NPM #TypeScript #Vue #VueJS
Vue.js Setup Guide
You have an account, and you have an app ID. Now let's include the TelemetryClient Package in your Vue.js application
Prerequisites
- You’ll need a TelemetryDeck account. Sign up for free if you don’t have one yet.
- You’ll need a TelemetryDeck App ID. Create a new app if you don’t have one yet.
Installation
npm i @peerigon/telemetrydeck-vue --save
Setup
Set up the plugin in your application setup:
import TelemetryDeckPlugin from "@peerigon/telemetrydeck-vue";
const app = createApp(App);
app.use(TelemetryDeckPlugin, {
appID: "{your telemetrydeck appID}",
testMode: true, // optional - defaults to false
clientUser: "Guest", // optional - defaults to 'Guest'
});
app.mount("#app");
Basic Usage
<script setup lang="ts">
import { useTelemetryDeck } from "@peerigon/telemetrydeck-vue";
const { signal, queue, setClientUser } = useTelemetryDeck();
const changeClientUserClick = () => {
setClientUser("user" + Math.floor(Math.random() * 1000));
};
const buttonSignalClick = () => {
signal("example_signal_event_name", {
custom_data: "other_data", // any custom data as required
});
};
const buttonQueueClick = () => {
queue("example_queue_event_name", {
custom_data: "other_data", // any custom data as required
});
};
const buttonSignalClickWithOptions = () => {
signal(
"example_signal_event_name_with_options",
{
custom_data: "other_data", // any custom data as required
},
{
testMode: true,
clientUser: "other_user",
appID: "other_app_id",
},
); // telemetryDeck options (optional)
};
const buttonQueueClickWithOptions = () => {
queue(
"example_queue_event_name_with_options",
{
custom_data: "other_data", // any custom data as required
},
{
testMode: true,
clientUser: "other_user",
appID: "other_app_id",
},
); // telemetryDeck options (optional)
};
</script>
<template>
<div>
<div>
<button id="btnSignalClick" @click="buttonSignalClick">
Log a click with signal
</button>
<button id="btnQueueClick" @click="buttonQueueClick">
Log a click with queue
</button>
<button id="btnSetClient" @click="changeClientUserClick">
Change user
</button>
</div>
<div>
<button
id="btnSignalClickWithOptions"
@click="buttonSignalClickWithOptions"
>
Log a click with signal with Options
</button>
<button
id="btnQueueClickWithOptions"
@click="buttonQueueClickWithOptions"
>
Log a click with queue with Options
</button>
</div>
</div>
</template>
Sponsors
The development of the TelemetryDeck Vue SDK was graciously provided by our friends at Augsburg-based bespoke software development company Peerigon. Thanks a lot, and check them out for your application development needs. 🧡