@temps-sdk/vue-analytics 0.0.1

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 ADDED
@@ -0,0 +1,78 @@
1
+ # @temps-sdk/vue-analytics
2
+
3
+ Temps analytics for Vue 3.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @temps-sdk/vue-analytics
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```ts
14
+ // main.ts
15
+ import { createApp } from "vue";
16
+ import { TempsAnalyticsPlugin } from "@temps-sdk/vue-analytics";
17
+ import App from "./App.vue";
18
+
19
+ const app = createApp(App);
20
+ app.use(TempsAnalyticsPlugin, {
21
+ basePath: "/api/_temps",
22
+ enableSessionRecording: true,
23
+ });
24
+ app.mount("#app");
25
+ ```
26
+
27
+ ## Composables
28
+
29
+ ```vue
30
+ <script setup>
31
+ import {
32
+ useTempsAnalytics,
33
+ useTrackEvent,
34
+ usePageLeave,
35
+ useEngagementTracking,
36
+ useScrollVisibility,
37
+ useSessionRecording,
38
+ } from "@temps-sdk/vue-analytics";
39
+
40
+ const analytics = useTempsAnalytics();
41
+ const track = useTrackEvent();
42
+
43
+ const handleClick = () => track("cta_click", { variant: "blue" });
44
+
45
+ const { engagementData } = useEngagementTracking({ heartbeatInterval: 15000 });
46
+ const { triggerPageLeave } = usePageLeave();
47
+ const pricingRef = useScrollVisibility({ eventName: "pricing_viewed" });
48
+ const { isEnabled, toggle } = useSessionRecording();
49
+ </script>
50
+
51
+ <template>
52
+ <button @click="handleClick">Track me</button>
53
+ <section ref="pricingRef">Pricing</section>
54
+ </template>
55
+ ```
56
+
57
+ ## Declarative events
58
+
59
+ ```html
60
+ <button temps-event-name="cta_click" temps-data-section="hero">Get started</button>
61
+ ```
62
+
63
+ Any element with `temps-event-name` fires an event on click.
64
+
65
+ ## API parity
66
+
67
+ Same surface as `@temps-sdk/react-analytics`, mapped to Vue 3 composables:
68
+
69
+ | React | Vue |
70
+ |---|---|
71
+ | `<TempsAnalyticsProvider>` | `app.use(TempsAnalyticsPlugin, options)` |
72
+ | `useTempsAnalytics()` | `useTempsAnalytics()` |
73
+ | `useTrackEvent()` | `useTrackEvent()` |
74
+ | `useTrackPageview()` | `useTrackPageview()` |
75
+ | `usePageLeave()` | `usePageLeave()` |
76
+ | `useEngagementTracking()` | `useEngagementTracking()` |
77
+ | `useScrollVisibility()` | `useScrollVisibility()` |
78
+ | `useSessionRecordingControl()` | `useSessionRecording()` |
@@ -0,0 +1,10 @@
1
+ export * from "@temps-sdk/analytics-core";
2
+ export { TempsAnalyticsPlugin, TempsAnalyticsKey } from "./plugin";
3
+ export { useTempsAnalytics } from "./useTempsAnalytics";
4
+ export { useTrackEvent } from "./useTrackEvent";
5
+ export { useTrackPageview } from "./useTrackPageview";
6
+ export { usePageLeave, type UsePageLeaveOptions } from "./usePageLeave";
7
+ export { useEngagementTracking, type UseEngagementTrackingOptions, } from "./useEngagementTracking";
8
+ export { useScrollVisibility, type UseScrollVisibilityOptions, } from "./useScrollVisibility";
9
+ export { useSessionRecording, type UseSessionRecordingReturn, } from "./useSessionRecording";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EACL,qBAAqB,EACrB,KAAK,4BAA4B,GAClC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,mBAAmB,EACnB,KAAK,0BAA0B,GAChC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,mBAAmB,EACnB,KAAK,yBAAyB,GAC/B,MAAM,uBAAuB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ export * from "@temps-sdk/analytics-core";
2
+ export { TempsAnalyticsPlugin, TempsAnalyticsKey } from "./plugin";
3
+ export { useTempsAnalytics } from "./useTempsAnalytics";
4
+ export { useTrackEvent } from "./useTrackEvent";
5
+ export { useTrackPageview } from "./useTrackPageview";
6
+ export { usePageLeave } from "./usePageLeave";
7
+ export { useEngagementTracking, } from "./useEngagementTracking";
8
+ export { useScrollVisibility, } from "./useScrollVisibility";
9
+ export { useSessionRecording, } from "./useSessionRecording";
@@ -0,0 +1,27 @@
1
+ import type { InjectionKey, Plugin } from "vue";
2
+ import { type AnalyticsApi, type AnalyticsOptions } from "@temps-sdk/analytics-core";
3
+ export declare const TempsAnalyticsKey: InjectionKey<AnalyticsApi>;
4
+ export interface TempsAnalyticsPluginOptions extends AnalyticsOptions {
5
+ /**
6
+ * Provide a pre-built instance instead of constructing one from options.
7
+ * Useful for testing or shared instances across micro-frontends.
8
+ */
9
+ instance?: AnalyticsApi;
10
+ }
11
+ /**
12
+ * Vue 3 plugin.
13
+ *
14
+ * ```ts
15
+ * import { createApp } from "vue";
16
+ * import { TempsAnalyticsPlugin } from "@temps-sdk/vue-analytics";
17
+ * const app = createApp(App);
18
+ * app.use(TempsAnalyticsPlugin, { basePath: "/api/_temps" });
19
+ * ```
20
+ */
21
+ export declare const TempsAnalyticsPlugin: Plugin<TempsAnalyticsPluginOptions | undefined>;
22
+ declare module "vue" {
23
+ interface ComponentCustomProperties {
24
+ $temps: AnalyticsApi;
25
+ }
26
+ }
27
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAO,YAAY,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAmB,KAAK,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAEtG,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,YAAY,CAA4B,CAAC;AAEtF,MAAM,WAAW,2BAA4B,SAAQ,gBAAgB;IACnE;;;OAGG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAC;CACzB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,2BAA2B,GAAG,SAAS,CAchF,CAAC;AAEF,OAAO,QAAQ,KAAK,CAAC;IACnB,UAAU,yBAAyB;QACjC,MAAM,EAAE,YAAY,CAAC;KACtB;CACF"}
package/dist/plugin.js ADDED
@@ -0,0 +1,28 @@
1
+ import { createAnalytics } from "@temps-sdk/analytics-core";
2
+ export const TempsAnalyticsKey = Symbol("TempsAnalytics");
3
+ /**
4
+ * Vue 3 plugin.
5
+ *
6
+ * ```ts
7
+ * import { createApp } from "vue";
8
+ * import { TempsAnalyticsPlugin } from "@temps-sdk/vue-analytics";
9
+ * const app = createApp(App);
10
+ * app.use(TempsAnalyticsPlugin, { basePath: "/api/_temps" });
11
+ * ```
12
+ */
13
+ export const TempsAnalyticsPlugin = {
14
+ install(app, options) {
15
+ const analytics = options?.instance ?? createAnalytics(options);
16
+ app.provide(TempsAnalyticsKey, analytics);
17
+ app.config.globalProperties.$temps = analytics;
18
+ const onUnmount = app.unmount.bind(app);
19
+ app.unmount = () => {
20
+ try {
21
+ analytics.destroy();
22
+ }
23
+ finally {
24
+ onUnmount();
25
+ }
26
+ };
27
+ },
28
+ };
@@ -0,0 +1,16 @@
1
+ import { type Ref } from "vue";
2
+ import { type EngagementData, type EngagementTrackerOptions } from "@temps-sdk/analytics-core";
3
+ export interface UseEngagementTrackingOptions extends Omit<EngagementTrackerOptions, "basePath" | "domain"> {
4
+ enabled?: boolean;
5
+ onEngagementUpdate?: (data: EngagementData) => void;
6
+ onPageLeave?: (data: EngagementData) => void;
7
+ }
8
+ /**
9
+ * Manual engagement tracking for specific routes / components.
10
+ * Mirrors the React `useEngagementTracking` hook.
11
+ */
12
+ export declare function useEngagementTracking(options?: UseEngagementTrackingOptions): {
13
+ engagementData: Ref<EngagementData>;
14
+ isTracking: Ref<boolean>;
15
+ };
16
+ //# sourceMappingURL=useEngagementTracking.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEngagementTracking.d.ts","sourceRoot":"","sources":["../src/useEngagementTracking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;AAChE,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAC9B,MAAM,2BAA2B,CAAC;AAGnC,MAAM,WAAW,4BACf,SAAQ,IAAI,CAAC,wBAAwB,EAAE,UAAU,GAAG,QAAQ,CAAC;IAC7D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;IACpD,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;CAC9C;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,GAAE,4BAAiC,GACzC;IACD,cAAc,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IACpC,UAAU,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;CAC1B,CAsCA"}
@@ -0,0 +1,43 @@
1
+ import { onBeforeUnmount, onMounted, ref } from "vue";
2
+ import { EngagementTracker, } from "@temps-sdk/analytics-core";
3
+ import { useTempsAnalytics } from "./useTempsAnalytics";
4
+ /**
5
+ * Manual engagement tracking for specific routes / components.
6
+ * Mirrors the React `useEngagementTracking` hook.
7
+ */
8
+ export function useEngagementTracking(options = {}) {
9
+ const analytics = useTempsAnalytics();
10
+ const tracker = ref(null);
11
+ const isTracking = ref(false);
12
+ const engagementData = ref({
13
+ engagement_time_seconds: 0,
14
+ total_time_seconds: 0,
15
+ heartbeat_count: 0,
16
+ is_engaged: false,
17
+ is_visible: true,
18
+ time_since_last_activity: 0,
19
+ });
20
+ const { enabled = true, onEngagementUpdate, onPageLeave, ...trackerOptions } = options;
21
+ onMounted(() => {
22
+ if (!enabled || !analytics.enabled)
23
+ return;
24
+ tracker.value = new EngagementTracker({
25
+ ...trackerOptions,
26
+ onHeartbeat: (data) => {
27
+ engagementData.value = data;
28
+ onEngagementUpdate?.(data);
29
+ },
30
+ onPageLeave: (data) => {
31
+ engagementData.value = data;
32
+ onPageLeave?.(data);
33
+ },
34
+ });
35
+ isTracking.value = true;
36
+ });
37
+ onBeforeUnmount(() => {
38
+ tracker.value?.destroy();
39
+ tracker.value = null;
40
+ isTracking.value = false;
41
+ });
42
+ return { engagementData, isTracking };
43
+ }
@@ -0,0 +1,15 @@
1
+ import type { JsonValue } from "@temps-sdk/analytics-core";
2
+ export interface UsePageLeaveOptions {
3
+ /** Custom event name. Defaults to "page_leave". */
4
+ eventName?: string;
5
+ /** Additional data to send with the page leave event. */
6
+ eventData?: Record<string, JsonValue>;
7
+ /** Whether to enable page leave tracking. Defaults to true. */
8
+ enabled?: boolean;
9
+ /** Override base path (falls back to the one used by the plugin). */
10
+ basePath?: string;
11
+ }
12
+ export declare function usePageLeave(options?: UsePageLeaveOptions): {
13
+ triggerPageLeave: () => Promise<void> | void;
14
+ };
15
+ //# sourceMappingURL=usePageLeave.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePageLeave.d.ts","sourceRoot":"","sources":["../src/usePageLeave.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAI3D,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACtC,+DAA+D;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG;IAC/D,gBAAgB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC9C,CA+DA"}
@@ -0,0 +1,55 @@
1
+ import { onBeforeUnmount, onMounted, ref } from "vue";
2
+ import { DEFAULT_BASE_PATH, sendAnalyticsReliable } from "@temps-sdk/analytics-core";
3
+ import { useTempsAnalytics } from "./useTempsAnalytics";
4
+ export function usePageLeave(options = {}) {
5
+ const { eventName = "page_leave", eventData = {}, enabled = true, basePath = DEFAULT_BASE_PATH, } = options;
6
+ const analytics = useTempsAnalytics();
7
+ const hasTracked = ref(false);
8
+ const startTime = ref(null);
9
+ const handler = () => {
10
+ if (hasTracked.value)
11
+ return;
12
+ hasTracked.value = true;
13
+ const timeOnPage = startTime.value ? Date.now() - startTime.value : 0;
14
+ sendAnalyticsReliable("event", {
15
+ event_name: eventName,
16
+ request_query: window.location.search,
17
+ request_path: window.location.pathname,
18
+ domain: window.location.hostname,
19
+ event_data: {
20
+ ...eventData,
21
+ time_on_page_ms: timeOnPage,
22
+ timestamp: new Date().toISOString(),
23
+ url: window.location.href,
24
+ referrer: document.referrer,
25
+ },
26
+ }, basePath);
27
+ };
28
+ onMounted(() => {
29
+ if (!enabled || !analytics.enabled)
30
+ return;
31
+ startTime.value = Date.now();
32
+ hasTracked.value = false;
33
+ window.addEventListener("pagehide", handler);
34
+ window.addEventListener("beforeunload", handler);
35
+ });
36
+ onBeforeUnmount(() => {
37
+ window.removeEventListener("pagehide", handler);
38
+ window.removeEventListener("beforeunload", handler);
39
+ });
40
+ const triggerPageLeave = () => {
41
+ if (!enabled || !analytics.enabled || hasTracked.value)
42
+ return;
43
+ hasTracked.value = true;
44
+ const timeOnPage = startTime.value ? Date.now() - startTime.value : 0;
45
+ return analytics.trackEvent(eventName, {
46
+ ...eventData,
47
+ time_on_page_ms: timeOnPage,
48
+ timestamp: new Date().toISOString(),
49
+ url: window.location.href,
50
+ referrer: document.referrer,
51
+ manual_trigger: true,
52
+ });
53
+ };
54
+ return { triggerPageLeave };
55
+ }
@@ -0,0 +1,17 @@
1
+ import { type Ref } from "vue";
2
+ import type { JsonValue } from "@temps-sdk/analytics-core";
3
+ export interface UseScrollVisibilityOptions {
4
+ eventName?: string;
5
+ eventData?: Record<string, JsonValue>;
6
+ threshold?: number;
7
+ root?: Element | null;
8
+ rootMargin?: string;
9
+ once?: boolean;
10
+ enabled?: boolean;
11
+ }
12
+ /**
13
+ * Tracks when an element scrolls into view using IntersectionObserver.
14
+ * Returns a `Ref<HTMLElement | null>` to bind with `ref="elementRef"` in a template.
15
+ */
16
+ export declare function useScrollVisibility(options?: UseScrollVisibilityOptions): Ref<HTMLElement | null>;
17
+ //# sourceMappingURL=useScrollVisibility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScrollVisibility.d.ts","sourceRoot":"","sources":["../src/useScrollVisibility.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAG3D,MAAM,WAAW,0BAA0B;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,GAAE,0BAA+B,GACvC,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,CA+CzB"}
@@ -0,0 +1,35 @@
1
+ import { onBeforeUnmount, ref, watch } from "vue";
2
+ import { useTempsAnalytics } from "./useTempsAnalytics";
3
+ /**
4
+ * Tracks when an element scrolls into view using IntersectionObserver.
5
+ * Returns a `Ref<HTMLElement | null>` to bind with `ref="elementRef"` in a template.
6
+ */
7
+ export function useScrollVisibility(options = {}) {
8
+ const { eventName = "component_visible", eventData, threshold = 0.5, root = null, rootMargin = "0px", once = true, enabled = true, } = options;
9
+ const analytics = useTempsAnalytics();
10
+ const elementRef = ref(null);
11
+ const hasTracked = ref(false);
12
+ let observer = null;
13
+ const cleanup = () => {
14
+ observer?.disconnect();
15
+ observer = null;
16
+ };
17
+ watch(elementRef, (node) => {
18
+ cleanup();
19
+ if (!enabled || !node || typeof IntersectionObserver === "undefined")
20
+ return;
21
+ if (!once)
22
+ hasTracked.value = false;
23
+ observer = new IntersectionObserver((entries) => {
24
+ entries.forEach((entry) => {
25
+ if (entry.isIntersecting && (!once || !hasTracked.value)) {
26
+ void analytics.trackEvent(eventName, eventData);
27
+ hasTracked.value = true;
28
+ }
29
+ });
30
+ }, { root, rootMargin, threshold });
31
+ observer.observe(node);
32
+ }, { immediate: true, flush: "post" });
33
+ onBeforeUnmount(cleanup);
34
+ return elementRef;
35
+ }
@@ -0,0 +1,15 @@
1
+ import { type Ref } from "vue";
2
+ export interface UseSessionRecordingReturn {
3
+ isEnabled: Ref<boolean>;
4
+ sessionId: Ref<string | null>;
5
+ enable: () => void;
6
+ disable: () => void;
7
+ toggle: () => void;
8
+ }
9
+ /**
10
+ * Composable mirror of the React `useSessionRecordingControl` hook.
11
+ * Persists user preference to localStorage and drives the SessionRecorder
12
+ * instance owned by the analytics core.
13
+ */
14
+ export declare function useSessionRecording(defaultEnabled?: boolean): UseSessionRecordingReturn;
15
+ //# sourceMappingURL=useSessionRecording.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSessionRecording.d.ts","sourceRoot":"","sources":["../src/useSessionRecording.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;AAK9C,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACxB,SAAS,EAAE,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC9B,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,cAAc,UAAQ,GAAG,yBAAyB,CAmCrF"}
@@ -0,0 +1,37 @@
1
+ import { computed, ref } from "vue";
2
+ import { useTempsAnalytics } from "./useTempsAnalytics";
3
+ const STORAGE_KEY = "temps_session_recording_enabled";
4
+ /**
5
+ * Composable mirror of the React `useSessionRecordingControl` hook.
6
+ * Persists user preference to localStorage and drives the SessionRecorder
7
+ * instance owned by the analytics core.
8
+ */
9
+ export function useSessionRecording(defaultEnabled = false) {
10
+ const analytics = useTempsAnalytics();
11
+ const initial = typeof localStorage !== "undefined" && localStorage.getItem(STORAGE_KEY) !== null
12
+ ? localStorage.getItem(STORAGE_KEY) === "true"
13
+ : defaultEnabled;
14
+ const isEnabled = ref(initial);
15
+ const sessionId = computed(() => {
16
+ if (typeof localStorage === "undefined")
17
+ return null;
18
+ return localStorage.getItem("currentRecordingSessionId");
19
+ });
20
+ const persist = (value) => {
21
+ if (typeof localStorage !== "undefined") {
22
+ localStorage.setItem(STORAGE_KEY, String(value));
23
+ }
24
+ };
25
+ const enable = () => {
26
+ isEnabled.value = true;
27
+ persist(true);
28
+ analytics.enableSessionRecording();
29
+ };
30
+ const disable = () => {
31
+ isEnabled.value = false;
32
+ persist(false);
33
+ analytics.disableSessionRecording();
34
+ };
35
+ const toggle = () => (isEnabled.value ? disable() : enable());
36
+ return { isEnabled, sessionId, enable, disable, toggle };
37
+ }
@@ -0,0 +1,3 @@
1
+ import type { AnalyticsApi } from "@temps-sdk/analytics-core";
2
+ export declare function useTempsAnalytics(): AnalyticsApi;
3
+ //# sourceMappingURL=useTempsAnalytics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTempsAnalytics.d.ts","sourceRoot":"","sources":["../src/useTempsAnalytics.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAG9D,wBAAgB,iBAAiB,IAAI,YAAY,CAQhD"}
@@ -0,0 +1,9 @@
1
+ import { inject } from "vue";
2
+ import { TempsAnalyticsKey } from "./plugin";
3
+ export function useTempsAnalytics() {
4
+ const analytics = inject(TempsAnalyticsKey);
5
+ if (!analytics) {
6
+ throw new Error("useTempsAnalytics() requires app.use(TempsAnalyticsPlugin) at the root of your app.");
7
+ }
8
+ return analytics;
9
+ }
@@ -0,0 +1,3 @@
1
+ import type { JsonValue } from "@temps-sdk/analytics-core";
2
+ export declare function useTrackEvent(): (eventName: string, data?: Record<string, JsonValue>) => Promise<void>;
3
+ //# sourceMappingURL=useTrackEvent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTrackEvent.d.ts","sourceRoot":"","sources":["../src/useTrackEvent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAG3D,wBAAgB,aAAa,IAAI,CAC/B,SAAS,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,KAC7B,OAAO,CAAC,IAAI,CAAC,CAGjB"}
@@ -0,0 +1,5 @@
1
+ import { useTempsAnalytics } from "./useTempsAnalytics";
2
+ export function useTrackEvent() {
3
+ const analytics = useTempsAnalytics();
4
+ return (eventName, data) => analytics.trackEvent(eventName, data);
5
+ }
@@ -0,0 +1,2 @@
1
+ export declare function useTrackPageview(): () => void;
2
+ //# sourceMappingURL=useTrackPageview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTrackPageview.d.ts","sourceRoot":"","sources":["../src/useTrackPageview.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,IAAI,MAAM,IAAI,CAG7C"}
@@ -0,0 +1,5 @@
1
+ import { useTempsAnalytics } from "./useTempsAnalytics";
2
+ export function useTrackPageview() {
3
+ const analytics = useTempsAnalytics();
4
+ return () => analytics.trackPageview();
5
+ }
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@temps-sdk/vue-analytics",
3
+ "version": "0.0.1",
4
+ "description": "Temps analytics for Vue 3 — plugin + composables for events, Web Vitals, engagement, and session replay.",
5
+ "private": false,
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "build:js": "tsc -p tsconfig.json",
21
+ "build:types": "tsc -p tsconfig.types.json",
22
+ "build": "bun run build:js && bun run build:types",
23
+ "clean": "rm -rf dist",
24
+ "prepublishOnly": "bun run clean && bun run build"
25
+ },
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "peerDependencies": {
30
+ "vue": "^3.3.0"
31
+ },
32
+ "dependencies": {
33
+ "@temps-sdk/analytics-core": "0.0.2"
34
+ },
35
+ "devDependencies": {
36
+ "typescript": "^5.5.4",
37
+ "vue": "^3.4.0"
38
+ },
39
+ "sideEffects": false
40
+ }