Vue
LogSnag client for Vue applications
Installation
Using npm
npm install @logsnag/vueUsing yarn
yarn add @logsnag/vueUsing pnpm
pnpm add @logsnag/vueUsage
First, install the LogSnag plugin in your Vue application:
Set your token's scope to
publicin the LogSnag dashboard.
import { createApp } from 'vue';
import LogSnag from '@logsnag/vue';
const app = createApp(App);
app.use(LogSnag, {
token: '<TOKEN>',
project: '<PROJECT_NAME>'
});
app.mount('#app');Then, import the functions you need from the package:
You can also track events directly from HTML elements using data attributes:
In this example, when the button is clicked, an event named "Upgraded Plan" will be tracked with the specified tags.
Hooks
track(options: TrackOptions): Track custom events.identify(options: IdentifyOptions): Identify user traits.setUserId(userId: string | null): Set the user id for the current user. If the user is not logged in, pass null.clearUserId(): Clear the user id for the current user.setDebug(flag: boolean = true): Set debug mode for logging.
Last updated
Was this helpful?