@molecule/app-analytics-vue

Feature · analytics · App (browser) · v1.1.2 · Apache-2.0

Vue bindings for @molecule/app-analytics (route listener)

npm install @molecule/app-analytics-vue

npm · Source on GitHub

How it works

@molecule/app-analytics-vue is a ready-made analytics feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.

import { createApp, h } from 'vue'
import { createMemoryRouter } from '@molecule/app-routing'
import { createRouterPlugin } from '@molecule/app-vue'
import { AnalyticsRouteListener } from '@molecule/app-analytics-vue'
import { Home } from './Home.js'

const app = createApp({
  render: () => [h(AnalyticsRouteListener), h(Home)],
})

app.use(createRouterPlugin(createMemoryRouter({ initialEntries: ['/'] })))
app.mount('#app')

Works with: @molecule/app-analytics, @molecule/app-ui, @molecule/app-ui-vue, @molecule/app-vue

Reference

Vue bindings for @molecule/app-analytics.

Provides ready-made Vue components that consume the wired analytics bond. Currently exports AnalyticsRouteListener, a render-free component that fires a page event on every client-side route change.

Mount AnalyticsRouteListener once inside the router plugin's scope — it watches useLocation() and forwards each pathname / search change to the wired analytics bond's page().

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Quick Start

import { createApp, h } from 'vue'
import { createMemoryRouter } from '@molecule/app-routing'
import { createRouterPlugin } from '@molecule/app-vue'
import { AnalyticsRouteListener } from '@molecule/app-analytics-vue'
import { Home } from './Home.js'

const app = createApp({
  render: () => [h(AnalyticsRouteListener), h(Home)],
})

app.use(createRouterPlugin(createMemoryRouter({ initialEntries: ['/'] })))
app.mount('#app')

Type

feature

Installation

npm install @molecule/app-analytics-vue @molecule/app-analytics @molecule/app-ui @molecule/app-ui-vue @molecule/app-vue vue

API

Constants

AnalyticsRouteListener

Records a page_view on client-side route changes.

Mount once inside the router plugin's scope (createRouterPlugin). On every pathname / search change, dispatches a page event through the wired analytics bond. Renders nothing.

const AnalyticsRouteListener: DefineComponent<
  {},
  () => null,
  {},
  {},
  {},
  ComponentOptionsMixin,
  ComponentOptionsMixin,
  {},
  string,
  PublicProps,
  Readonly<{}> & Readonly<{}>,
  {},
  {},
  {},
  {},
  string,
  ComponentProvideOptions,
  true,
  {},
  any
>

Returns: The render-free listener component.

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-analytics ^1.0.1
  • @molecule/app-ui ^1.0.1
  • @molecule/app-ui-vue ^1.1.0
  • @molecule/app-vue ^3.11.0 || ^4.0.0
  • vue ^3.4.0

Runtime Dependencies

  • @molecule/app-analytics
  • @molecule/app-ui
  • @molecule/app-ui-vue
  • @molecule/app-vue
  • vue