@tell-rs/vue 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +116 -0
- package/dist/index.cjs +64 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +37 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/package.json +42 -0
package/README.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# @tell-rs/vue
|
|
2
|
+
|
|
3
|
+
Tell SDK Vue integration — plugin and composable for Vue 3.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
# npm
|
|
9
|
+
npm install @tell-rs/vue @tell-rs/browser
|
|
10
|
+
|
|
11
|
+
# yarn
|
|
12
|
+
yarn add @tell-rs/vue @tell-rs/browser
|
|
13
|
+
|
|
14
|
+
# pnpm
|
|
15
|
+
pnpm add @tell-rs/vue @tell-rs/browser
|
|
16
|
+
|
|
17
|
+
# bun
|
|
18
|
+
bun add @tell-rs/vue @tell-rs/browser
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`@tell-rs/browser` is a peer dependency and must be installed alongside `@tell-rs/vue`.
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
### 1. Install the plugin
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
// main.ts
|
|
29
|
+
import { createApp } from "vue";
|
|
30
|
+
import { TellPlugin } from "@tell-rs/vue";
|
|
31
|
+
import App from "./App.vue";
|
|
32
|
+
|
|
33
|
+
const app = createApp(App);
|
|
34
|
+
app.use(TellPlugin, { apiKey: "your-api-key" });
|
|
35
|
+
app.mount("#app");
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 2. Track events
|
|
39
|
+
|
|
40
|
+
```vue
|
|
41
|
+
<script setup>
|
|
42
|
+
import { useTell } from "@tell-rs/vue";
|
|
43
|
+
|
|
44
|
+
const tell = useTell();
|
|
45
|
+
|
|
46
|
+
function onSignUp() {
|
|
47
|
+
tell.track("Sign Up Clicked", { plan: "pro" });
|
|
48
|
+
}
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<template>
|
|
52
|
+
<button @click="onSignUp">Sign Up</button>
|
|
53
|
+
</template>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## API
|
|
57
|
+
|
|
58
|
+
### `TellPlugin`
|
|
59
|
+
|
|
60
|
+
Vue plugin. Pass options to `app.use()`:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
app.use(TellPlugin, {
|
|
64
|
+
apiKey: "your-api-key",
|
|
65
|
+
// Plus any TellBrowserConfig options:
|
|
66
|
+
// endpoint, batchSize, flushInterval, sessionTimeout, etc.
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The plugin:
|
|
71
|
+
|
|
72
|
+
1. Calls `tell.configure(apiKey, config)` on install
|
|
73
|
+
2. Provides the Tell instance via Vue's `provide`/`inject`
|
|
74
|
+
3. Calls `tell.close()` when the app unmounts
|
|
75
|
+
|
|
76
|
+
### `useTell()`
|
|
77
|
+
|
|
78
|
+
Composable that returns the Tell instance inside a `setup` function.
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
const tell = useTell();
|
|
82
|
+
|
|
83
|
+
tell.track("Page Viewed", { path: "/dashboard" });
|
|
84
|
+
tell.identify("user_123", { name: "Alice" });
|
|
85
|
+
tell.logInfo("Component mounted", "ui");
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Throws if `TellPlugin` was not installed.
|
|
89
|
+
|
|
90
|
+
### Direct access
|
|
91
|
+
|
|
92
|
+
For use outside of components:
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
import { tell } from "@tell-rs/vue";
|
|
96
|
+
|
|
97
|
+
tell.track("Background Task Done");
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## With Vue Router
|
|
101
|
+
|
|
102
|
+
Track page views on route changes:
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
// router.ts
|
|
106
|
+
import { tell } from "@tell-rs/vue";
|
|
107
|
+
import router from "./router";
|
|
108
|
+
|
|
109
|
+
router.afterEach((to) => {
|
|
110
|
+
tell.track("Page Viewed", { path: to.path, url: to.fullPath });
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## License
|
|
115
|
+
|
|
116
|
+
MIT
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
TellPlugin: () => TellPlugin,
|
|
34
|
+
tell: () => import_browser2.tell,
|
|
35
|
+
useTell: () => useTell
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(index_exports);
|
|
38
|
+
var import_vue = require("vue");
|
|
39
|
+
var import_browser = __toESM(require("@tell-rs/browser"), 1);
|
|
40
|
+
var import_browser2 = require("@tell-rs/browser");
|
|
41
|
+
var TELL_KEY = /* @__PURE__ */ Symbol("tell");
|
|
42
|
+
var TellPlugin = {
|
|
43
|
+
install(app, options) {
|
|
44
|
+
const { apiKey, ...config } = options;
|
|
45
|
+
import_browser.default.configure(apiKey, config);
|
|
46
|
+
app.provide(TELL_KEY, import_browser.default);
|
|
47
|
+
app.config.globalProperties.$tell = import_browser.default;
|
|
48
|
+
const originalUnmount = app.unmount.bind(app);
|
|
49
|
+
app.unmount = () => {
|
|
50
|
+
import_browser.default.close();
|
|
51
|
+
originalUnmount();
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
function useTell() {
|
|
56
|
+
const instance = (0, import_vue.inject)(TELL_KEY);
|
|
57
|
+
if (!instance) {
|
|
58
|
+
throw new Error(
|
|
59
|
+
"Tell is not provided. Did you install TellPlugin on your app?"
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
return instance;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { inject, type App, type InjectionKey } from \"vue\";\nimport tell from \"@tell-rs/browser\";\nimport type { TellBrowserConfig, TellInstance } from \"@tell-rs/browser\";\n\nexport { tell } from \"@tell-rs/browser\";\nexport type { TellBrowserConfig, TellInstance } from \"@tell-rs/browser\";\n\nconst TELL_KEY: InjectionKey<TellInstance> = Symbol(\"tell\");\n\nexport interface TellPluginOptions extends TellBrowserConfig {\n apiKey: string;\n}\n\n/**\n * Vue plugin that configures Tell and provides the instance via injection.\n *\n * ```ts\n * // main.ts\n * import { createApp } from \"vue\";\n * import { TellPlugin } from \"@tell-rs/vue\";\n *\n * const app = createApp(App);\n * app.use(TellPlugin, { apiKey: \"...\" });\n * app.mount(\"#app\");\n * ```\n */\nexport const TellPlugin = {\n install(app: App, options: TellPluginOptions) {\n const { apiKey, ...config } = options;\n tell.configure(apiKey, config);\n app.provide(TELL_KEY, tell);\n\n // Flush on unmount\n app.config.globalProperties.$tell = tell;\n const originalUnmount = app.unmount.bind(app);\n app.unmount = () => {\n tell.close();\n originalUnmount();\n };\n },\n};\n\n/**\n * Composable to access the Tell instance inside a setup function.\n *\n * ```vue\n * <script setup>\n * import { useTell } from \"@tell-rs/vue\";\n * const tell = useTell();\n * tell.track(\"Page Viewed\");\n * </script>\n * ```\n */\nexport function useTell(): TellInstance {\n const instance = inject(TELL_KEY);\n if (!instance) {\n throw new Error(\n \"Tell is not provided. Did you install TellPlugin on your app?\"\n );\n }\n return instance;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAoD;AACpD,qBAAiB;AAGjB,IAAAA,kBAAqB;AAGrB,IAAM,WAAuC,uBAAO,MAAM;AAmBnD,IAAM,aAAa;AAAA,EACxB,QAAQ,KAAU,SAA4B;AAC5C,UAAM,EAAE,QAAQ,GAAG,OAAO,IAAI;AAC9B,mBAAAC,QAAK,UAAU,QAAQ,MAAM;AAC7B,QAAI,QAAQ,UAAU,eAAAA,OAAI;AAG1B,QAAI,OAAO,iBAAiB,QAAQ,eAAAA;AACpC,UAAM,kBAAkB,IAAI,QAAQ,KAAK,GAAG;AAC5C,QAAI,UAAU,MAAM;AAClB,qBAAAA,QAAK,MAAM;AACX,sBAAgB;AAAA,IAClB;AAAA,EACF;AACF;AAaO,SAAS,UAAwB;AACtC,QAAM,eAAW,mBAAO,QAAQ;AAChC,MAAI,CAAC,UAAU;AACb,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":["import_browser","tell"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
import { TellBrowserConfig, TellInstance } from '@tell-rs/browser';
|
|
3
|
+
export { TellBrowserConfig, TellInstance, tell } from '@tell-rs/browser';
|
|
4
|
+
|
|
5
|
+
interface TellPluginOptions extends TellBrowserConfig {
|
|
6
|
+
apiKey: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Vue plugin that configures Tell and provides the instance via injection.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* // main.ts
|
|
13
|
+
* import { createApp } from "vue";
|
|
14
|
+
* import { TellPlugin } from "@tell-rs/vue";
|
|
15
|
+
*
|
|
16
|
+
* const app = createApp(App);
|
|
17
|
+
* app.use(TellPlugin, { apiKey: "..." });
|
|
18
|
+
* app.mount("#app");
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare const TellPlugin: {
|
|
22
|
+
install(app: App, options: TellPluginOptions): void;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Composable to access the Tell instance inside a setup function.
|
|
26
|
+
*
|
|
27
|
+
* ```vue
|
|
28
|
+
* <script setup>
|
|
29
|
+
* import { useTell } from "@tell-rs/vue";
|
|
30
|
+
* const tell = useTell();
|
|
31
|
+
* tell.track("Page Viewed");
|
|
32
|
+
* </script>
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare function useTell(): TellInstance;
|
|
36
|
+
|
|
37
|
+
export { TellPlugin, type TellPluginOptions, useTell };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
import { TellBrowserConfig, TellInstance } from '@tell-rs/browser';
|
|
3
|
+
export { TellBrowserConfig, TellInstance, tell } from '@tell-rs/browser';
|
|
4
|
+
|
|
5
|
+
interface TellPluginOptions extends TellBrowserConfig {
|
|
6
|
+
apiKey: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Vue plugin that configures Tell and provides the instance via injection.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* // main.ts
|
|
13
|
+
* import { createApp } from "vue";
|
|
14
|
+
* import { TellPlugin } from "@tell-rs/vue";
|
|
15
|
+
*
|
|
16
|
+
* const app = createApp(App);
|
|
17
|
+
* app.use(TellPlugin, { apiKey: "..." });
|
|
18
|
+
* app.mount("#app");
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare const TellPlugin: {
|
|
22
|
+
install(app: App, options: TellPluginOptions): void;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Composable to access the Tell instance inside a setup function.
|
|
26
|
+
*
|
|
27
|
+
* ```vue
|
|
28
|
+
* <script setup>
|
|
29
|
+
* import { useTell } from "@tell-rs/vue";
|
|
30
|
+
* const tell = useTell();
|
|
31
|
+
* tell.track("Page Viewed");
|
|
32
|
+
* </script>
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare function useTell(): TellInstance;
|
|
36
|
+
|
|
37
|
+
export { TellPlugin, type TellPluginOptions, useTell };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { inject } from "vue";
|
|
3
|
+
import tell from "@tell-rs/browser";
|
|
4
|
+
import { tell as tell2 } from "@tell-rs/browser";
|
|
5
|
+
var TELL_KEY = /* @__PURE__ */ Symbol("tell");
|
|
6
|
+
var TellPlugin = {
|
|
7
|
+
install(app, options) {
|
|
8
|
+
const { apiKey, ...config } = options;
|
|
9
|
+
tell.configure(apiKey, config);
|
|
10
|
+
app.provide(TELL_KEY, tell);
|
|
11
|
+
app.config.globalProperties.$tell = tell;
|
|
12
|
+
const originalUnmount = app.unmount.bind(app);
|
|
13
|
+
app.unmount = () => {
|
|
14
|
+
tell.close();
|
|
15
|
+
originalUnmount();
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
function useTell() {
|
|
20
|
+
const instance = inject(TELL_KEY);
|
|
21
|
+
if (!instance) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
"Tell is not provided. Did you install TellPlugin on your app?"
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
return instance;
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
TellPlugin,
|
|
30
|
+
tell2 as tell,
|
|
31
|
+
useTell
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { inject, type App, type InjectionKey } from \"vue\";\nimport tell from \"@tell-rs/browser\";\nimport type { TellBrowserConfig, TellInstance } from \"@tell-rs/browser\";\n\nexport { tell } from \"@tell-rs/browser\";\nexport type { TellBrowserConfig, TellInstance } from \"@tell-rs/browser\";\n\nconst TELL_KEY: InjectionKey<TellInstance> = Symbol(\"tell\");\n\nexport interface TellPluginOptions extends TellBrowserConfig {\n apiKey: string;\n}\n\n/**\n * Vue plugin that configures Tell and provides the instance via injection.\n *\n * ```ts\n * // main.ts\n * import { createApp } from \"vue\";\n * import { TellPlugin } from \"@tell-rs/vue\";\n *\n * const app = createApp(App);\n * app.use(TellPlugin, { apiKey: \"...\" });\n * app.mount(\"#app\");\n * ```\n */\nexport const TellPlugin = {\n install(app: App, options: TellPluginOptions) {\n const { apiKey, ...config } = options;\n tell.configure(apiKey, config);\n app.provide(TELL_KEY, tell);\n\n // Flush on unmount\n app.config.globalProperties.$tell = tell;\n const originalUnmount = app.unmount.bind(app);\n app.unmount = () => {\n tell.close();\n originalUnmount();\n };\n },\n};\n\n/**\n * Composable to access the Tell instance inside a setup function.\n *\n * ```vue\n * <script setup>\n * import { useTell } from \"@tell-rs/vue\";\n * const tell = useTell();\n * tell.track(\"Page Viewed\");\n * </script>\n * ```\n */\nexport function useTell(): TellInstance {\n const instance = inject(TELL_KEY);\n if (!instance) {\n throw new Error(\n \"Tell is not provided. Did you install TellPlugin on your app?\"\n );\n }\n return instance;\n}\n"],"mappings":";AAAA,SAAS,cAA2C;AACpD,OAAO,UAAU;AAGjB,SAAS,QAAAA,aAAY;AAGrB,IAAM,WAAuC,uBAAO,MAAM;AAmBnD,IAAM,aAAa;AAAA,EACxB,QAAQ,KAAU,SAA4B;AAC5C,UAAM,EAAE,QAAQ,GAAG,OAAO,IAAI;AAC9B,SAAK,UAAU,QAAQ,MAAM;AAC7B,QAAI,QAAQ,UAAU,IAAI;AAG1B,QAAI,OAAO,iBAAiB,QAAQ;AACpC,UAAM,kBAAkB,IAAI,QAAQ,KAAK,GAAG;AAC5C,QAAI,UAAU,MAAM;AAClB,WAAK,MAAM;AACX,sBAAgB;AAAA,IAClB;AAAA,EACF;AACF;AAaO,SAAS,UAAwB;AACtC,QAAM,WAAW,OAAO,QAAQ;AAChC,MAAI,CAAC,UAAU;AACb,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":["tell"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tell-rs/vue",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Tell SDK Vue integration — plugin and composable",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": ["dist"],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsup",
|
|
19
|
+
"test": "echo 'no tests'",
|
|
20
|
+
"typecheck": "tsc --noEmit",
|
|
21
|
+
"clean": "rm -rf dist"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"vue": ">=3",
|
|
25
|
+
"@tell-rs/browser": "*"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"vue": "^3.5.0",
|
|
29
|
+
"@tell-rs/browser": "*",
|
|
30
|
+
"tsup": "^8.0.0",
|
|
31
|
+
"typescript": "^5.5.0"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/tell-rs/tell-js.git",
|
|
36
|
+
"directory": "packages/vue"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://tell.rs",
|
|
39
|
+
"keywords": ["analytics", "vue", "composable", "tell"],
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"author": "Arcade Labs Inc."
|
|
42
|
+
}
|