|
1 |
| -# Vue 3 + TypeScript + Vite |
| 1 | +# telemetrydeck-vue |
| 2 | + |
| 3 | +A library for using TelemetryDeck in your React app. |
2 | 4 |
|
3 | 5 | [](https://github.com/semantic-release/semantic-release)
|
4 | 6 |
|
| 7 | +## Installation |
| 8 | + |
| 9 | +```shell |
| 10 | +npm i @peerigon/telemetrydeck-vue --save |
| 11 | +``` |
| 12 | + |
| 13 | +## Setup |
| 14 | + |
| 15 | +Set up the plugin in your application setup: |
| 16 | + |
| 17 | +```javascript |
| 18 | +import TelemetryDeckPlugin from '@peerigon/telemetrydeck-vue'; |
| 19 | + |
| 20 | +const app = createApp(App); |
| 21 | +app.use(TelemetryDeckPlugin, { |
| 22 | + appID: "{your telemetrydeck appID}", |
| 23 | + testMode: true, // optional - defaults to false |
| 24 | + clientUser: 'Guest' // optional - defaults to 'Guest' |
| 25 | +}); |
| 26 | + |
| 27 | +app.mount('#app'); |
| 28 | +``` |
| 29 | + |
| 30 | +## Basic Usage |
| 31 | + |
| 32 | +```vue |
| 33 | +<script setup lang="ts"> |
| 34 | +import { useTelemetryDeck } from "@peerigon/telemetrydeck-vue"; |
| 35 | +const { signal, queue, setClientUser } = useTelemetryDeck(); |
| 36 | +
|
| 37 | +const changeClientUserClick = () => { |
| 38 | + setClientUser('user' + Math.floor(Math.random() * 1000)); |
| 39 | +}; |
| 40 | +
|
| 41 | +const buttonSignalClick = () => { |
| 42 | + signal('example_signal_event_name', { |
| 43 | + custom_data: 'other_data', // any custom data as required |
| 44 | + }); |
| 45 | +}; |
| 46 | +
|
| 47 | +const buttonQueueClick = () => { |
| 48 | + queue('example_queue_event_name', { |
| 49 | + custom_data: 'other_data', // any custom data as required |
| 50 | + }); |
| 51 | +}; |
| 52 | +
|
| 53 | +const buttonSignalClickWithOptions = () => { |
| 54 | + signal('example_signal_event_name_with_options', { |
| 55 | + custom_data: 'other_data', // any custom data as required |
| 56 | + }, { |
| 57 | + testMode: true, |
| 58 | + clientUser: 'other_user', |
| 59 | + appID: 'other_app_id', |
| 60 | + }); // telemetryDeck options (optional) |
| 61 | +}; |
| 62 | +
|
| 63 | +const buttonQueueClickWithOptions = () => { |
| 64 | + queue('example_queue_event_name_with_options', { |
| 65 | + custom_data: 'other_data', // any custom data as required |
| 66 | + }, { |
| 67 | + testMode: true, |
| 68 | + clientUser: 'other_user', |
| 69 | + appID: 'other_app_id', |
| 70 | + }); // telemetryDeck options (optional) |
| 71 | +}; |
| 72 | +</script> |
| 73 | +
|
| 74 | +<template> |
| 75 | + <div> |
| 76 | + <div> |
| 77 | + <button id="btnSignalClick" @click="buttonSignalClick">Log a click with signal</button> |
| 78 | + <button id="btnQueueClick" @click="buttonQueueClick">Log a click with queue</button> |
| 79 | + <button id="btnSetClient" @click="changeClientUserClick">Change user</button> |
| 80 | + </div> |
| 81 | + <div> |
| 82 | + <button id="btnSignalClickWithOptions" @click="buttonSignalClickWithOptions">Log a click with signal with Options</button> |
| 83 | + <button id="btnQueueClickWithOptions" @click="buttonQueueClickWithOptions">Log a click with queue with Options</button> |
| 84 | + </div> |
| 85 | + </div> |
| 86 | +</template> |
| 87 | +``` |
| 88 | + |
| 89 | +## Contributions |
| 90 | + |
| 91 | +### Local Development |
| 92 | + |
| 93 | +To run the plugin locally for development: |
| 94 | + |
| 95 | +1. Install Node.js v20 |
| 96 | +2. Run `npm i` |
| 97 | +3. create .env file from .env.example and add your test telemetryDeck appID. Create an account here: [telemetrydeck.com](https://telemetrydeck.com/) |
| 98 | +3. Run `npm run dev` |
| 99 | +4. Navigate to [http://localhost:5173/](http://localhost:5173/) for the test page |
5 | 100 |
|
| 101 | +### Tests |
6 | 102 |
|
7 |
| -This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more. |
| 103 | +Run the tests with: |
8 | 104 |
|
9 |
| -Learn more about the recommended Project Setup and IDE Support in the [Vue Docs TypeScript Guide](https://vuejs.org/guide/typescript/overview.html#project-setup). |
| 105 | +```shell |
| 106 | +npm run test |
| 107 | +``` |
0 commit comments