Skip to content

Commit cb2a466

Browse files
committed
docs: normalize plugin adapter sections with install instructions
1 parent ebdfef8 commit cb2a466

3 files changed

Lines changed: 245 additions & 73 deletions

File tree

apps/docs/src/pages/composables/plugins/use-features.md

Lines changed: 64 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,29 @@ Adapters let you swap the underlying feature flag provider without changing your
9494
| `FlagsmithFeatureAdapter` | `@vuetify/v0/features/adapters/flagsmith` | [Flagsmith](https://flagsmith.com/) integration |
9595
| `LaunchDarklyFeatureAdapter` | `@vuetify/v0/features/adapters/launchdarkly` | [LaunchDarkly](https://launchdarkly.com/) integration |
9696

97-
### Built-in Adapters
97+
### Flagsmith
9898

99-
Each adapter is imported from its own nested subpath under `@vuetify/v0/features/adapters/`.
99+
[Flagsmith](https://flagsmith.com/) is an open-source feature flag platform. Requires the `@flagsmith/flagsmith` package.
100100

101-
#### Flagsmith
101+
::: code-group no-filename
102102

103-
Requires `@flagsmith/flagsmith` package.
103+
```bash pnpm
104+
pnpm add @flagsmith/flagsmith
105+
```
106+
107+
```bash npm
108+
npm install @flagsmith/flagsmith
109+
```
110+
111+
```bash yarn
112+
yarn add @flagsmith/flagsmith
113+
```
114+
115+
```bash bun
116+
bun add @flagsmith/flagsmith
117+
```
118+
119+
:::
104120

105121
```ts
106122
import flagsmith from '@flagsmith/flagsmith'
@@ -114,9 +130,29 @@ app.use(createFeaturesPlugin({
114130
}))
115131
```
116132

117-
#### LaunchDarkly
133+
### LaunchDarkly
134+
135+
[LaunchDarkly](https://launchdarkly.com/) is a feature management platform. Requires the `launchdarkly-js-client-sdk` package.
136+
137+
::: code-group no-filename
138+
139+
```bash pnpm
140+
pnpm add launchdarkly-js-client-sdk
141+
```
142+
143+
```bash npm
144+
npm install launchdarkly-js-client-sdk
145+
```
118146

119-
Requires `launchdarkly-js-client-sdk` package.
147+
```bash yarn
148+
yarn add launchdarkly-js-client-sdk
149+
```
150+
151+
```bash bun
152+
bun add launchdarkly-js-client-sdk
153+
```
154+
155+
:::
120156

121157
```ts
122158
import * as LDClient from 'launchdarkly-js-client-sdk'
@@ -131,9 +167,29 @@ app.use(createFeaturesPlugin({
131167
}))
132168
```
133169

134-
#### PostHog
170+
### PostHog
171+
172+
[PostHog](https://posthog.com/) is an open-source product analytics and feature flag platform. Requires the `posthog-js` package.
173+
174+
::: code-group no-filename
175+
176+
```bash pnpm
177+
pnpm add posthog-js
178+
```
135179

136-
Requires `posthog-js` package.
180+
```bash npm
181+
npm install posthog-js
182+
```
183+
184+
```bash yarn
185+
yarn add posthog-js
186+
```
187+
188+
```bash bun
189+
bun add posthog-js
190+
```
191+
192+
:::
137193

138194
```ts
139195
import posthog from 'posthog-js'

apps/docs/src/pages/composables/plugins/use-logger.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,82 @@ Adapters let you swap the underlying logging implementation without changing you
7777

7878
The default `Vuetify0LoggerAdapter` maps each level to the correct native console method — `debug``console.debug`, `info``console.info`, `warn``console.warn`, `error`/`fatal``console.error`. This ensures browser DevTools can correctly filter by level.
7979

80+
### Pino
81+
82+
[Pino](https://getpino.io/) is a high-performance JSON logger. Requires the `pino` package.
83+
84+
::: code-group no-filename
85+
86+
```bash pnpm
87+
pnpm add pino
88+
```
89+
90+
```bash npm
91+
npm install pino
92+
```
93+
94+
```bash yarn
95+
yarn add pino
96+
```
97+
98+
```bash bun
99+
bun add pino
100+
```
101+
102+
:::
103+
104+
```ts src/plugins/zero.ts
105+
import pino from 'pino'
106+
import { PinoLoggerAdapter } from '@vuetify/v0/logger/adapters/pino'
107+
import { createLoggerPlugin } from '@vuetify/v0'
108+
109+
const logger = pino({ level: 'debug' })
110+
111+
app.use(
112+
createLoggerPlugin({
113+
adapter: new PinoLoggerAdapter(logger),
114+
})
115+
)
116+
```
117+
118+
### Consola
119+
120+
[Consola](https://github.com/unjs/consola) is an elegant console logger by UnJS. Requires the `consola` package.
121+
122+
::: code-group no-filename
123+
124+
```bash pnpm
125+
pnpm add consola
126+
```
127+
128+
```bash npm
129+
npm install consola
130+
```
131+
132+
```bash yarn
133+
yarn add consola
134+
```
135+
136+
```bash bun
137+
bun add consola
138+
```
139+
140+
:::
141+
142+
```ts src/plugins/zero.ts
143+
import { createConsola } from 'consola'
144+
import { ConsolaLoggerAdapter } from '@vuetify/v0/logger/adapters/consola'
145+
import { createLoggerPlugin } from '@vuetify/v0'
146+
147+
const consola = createConsola({ level: 4 })
148+
149+
app.use(
150+
createLoggerPlugin({
151+
adapter: new ConsolaLoggerAdapter(consola),
152+
})
153+
)
154+
```
155+
80156
### Custom Adapters
81157

82158
Implement `LoggerAdapter` to route logs to any destination:

apps/docs/src/pages/composables/plugins/use-notifications.md

Lines changed: 105 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -192,78 +192,29 @@ Adapters let you swap the underlying notification service without changing your
192192
| `createKnockAdapter` | `@vuetify/v0/notifications` | [Knock](https://knock.app) integration |
193193
| `createNovuAdapter` | `@vuetify/v0/notifications` | [Novu](https://novu.co) integration |
194194

195-
### Custom Adapters
196-
197-
Implement `NotificationsAdapterInterface` to connect any backend:
198-
199-
```ts
200-
import type { NotificationsAdapterInterface, NotificationsAdapterContext } from '@vuetify/v0'
201-
202-
class MyBackendAdapter implements NotificationsAdapterInterface {
203-
setup (context: NotificationsAdapterContext) {
204-
// Wire inbound: push notifications into the registry
205-
myBackend.onMessage(msg => {
206-
context.send({ id: msg.id, title: msg.title, body: msg.body })
207-
})
195+
### Knock
208196

209-
// Wire outbound: sync read/archive actions back to the backend
210-
context.on('notification:read', (data: any) => {
211-
myBackend.markRead(data.id)
212-
})
213-
}
197+
[Knock](https://knock.app) is a notification infrastructure platform with feeds, preferences, and multi-channel delivery. Install their [JavaScript SDK](https://docs.knock.app/sdks/javascript/overview) to get started. Supports both inbound (feed → notifications) and outbound (read/archive → Knock API).
214198

215-
dispose () {
216-
myBackend.disconnect()
217-
}
218-
}
199+
::: code-group no-filename
219200

220-
app.use(createNotificationsPlugin({ adapter: new MyBackendAdapter() }))
201+
```bash pnpm
202+
pnpm add @knocklabs/client
221203
```
222204

223-
**Adapter context methods:**
224-
225-
| Method | Purpose |
226-
| - | - |
227-
| `send(input)` | Register and enqueue for toast display (real-time inbound) |
228-
| `register(input)` | Register in history only — no toast (initial/historical load) |
229-
| `on(event, handler)` | Subscribe to outbound lifecycle events |
230-
| `off(event, handler)` | Unsubscribe from a lifecycle event |
231-
232-
### Custom Ticket Fields
233-
234-
Extend `NotificationInput` to add domain-specific fields. Pass the type parameter through the adapter and plugin:
235-
236-
```ts
237-
import type { NotificationInput, NotificationsAdapterInterface, NotificationsAdapterContext } from '@vuetify/v0'
238-
239-
interface AppNotification extends NotificationInput {
240-
priority: 'low' | 'medium' | 'high'
241-
imageUrl?: string
242-
}
243-
244-
class MyBackendAdapter implements NotificationsAdapterInterface<AppNotification> {
245-
setup (context: NotificationsAdapterContext<AppNotification>) {
246-
myBackend.onMessage(msg => {
247-
context.send({
248-
id: msg.id,
249-
subject: msg.title,
250-
priority: msg.priority, // custom field
251-
imageUrl: msg.imageUrl, // custom field
252-
})
253-
})
254-
}
255-
}
256-
257-
app.use(createNotificationsPlugin<AppNotification>({ adapter: new MyBackendAdapter() }))
205+
```bash npm
206+
npm install @knocklabs/client
258207
```
259208

260-
Custom fields are preserved on the ticket and accessible anywhere you inject the notifications context.
261-
262-
> [!ASKAI] How do I write a custom adapter for my backend?
209+
```bash yarn
210+
yarn add @knocklabs/client
211+
```
263212

264-
### Knock
213+
```bash bun
214+
bun add @knocklabs/client
215+
```
265216

266-
[Knock](https://knock.app) is a notification infrastructure platform with feeds, preferences, and multi-channel delivery. Install their [JavaScript SDK](https://docs.knock.app/sdks/javascript/overview) to get started. Supports both inbound (feed → notifications) and outbound (read/archive → Knock API).
217+
:::
267218

268219
::: code-group
269220

@@ -289,7 +240,7 @@ app.mount('#app')
289240
import Knock from '@knocklabs/client'
290241

291242
export const knock = new Knock(import.meta.env.VITE_KNOCK_PUBLIC_KEY)
292-
knock.authenticate(userId)
243+
knock.authenticate(import.meta.env.VITE_KNOCK_USER_ID)
293244

294245
export const feed = knock.feeds.initialize(
295246
import.meta.env.VITE_KNOCK_FEED_CHANNEL_ID
@@ -304,6 +255,26 @@ export const feed = knock.feeds.initialize(
304255

305256
The adapter maps Novu severity strings to `NotificationSeverity` by default: `critical`/`high``error`, `medium``warning`, `low``info`. Pass a custom `severity` function to override.
306257

258+
::: code-group no-filename
259+
260+
```bash pnpm
261+
pnpm add @novu/js
262+
```
263+
264+
```bash npm
265+
npm install @novu/js
266+
```
267+
268+
```bash yarn
269+
yarn add @novu/js
270+
```
271+
272+
```bash bun
273+
bun add @novu/js
274+
```
275+
276+
:::
277+
307278
::: code-group
308279

309280
```ts src/main.ts
@@ -328,11 +299,80 @@ app.mount('#app')
328299
import { Novu } from '@novu/js'
329300

330301
export const novu = new Novu({
331-
subscriberId: userId,
302+
subscriberId: import.meta.env.VITE_NOVU_SUBSCRIBER_ID,
332303
applicationIdentifier: import.meta.env.VITE_NOVU_APP_ID,
333304
})
334305
```
335306

336307
:::
337308

309+
### Custom Adapters
310+
311+
Implement `NotificationsAdapterInterface` to connect any backend:
312+
313+
```ts
314+
import type { NotificationsAdapterInterface, NotificationsAdapterContext } from '@vuetify/v0'
315+
316+
class MyBackendAdapter implements NotificationsAdapterInterface {
317+
setup (context: NotificationsAdapterContext) {
318+
// Wire inbound: push notifications into the registry
319+
myBackend.onMessage(msg => {
320+
context.send({ id: msg.id, title: msg.title, body: msg.body })
321+
})
322+
323+
// Wire outbound: sync read/archive actions back to the backend
324+
context.on('notification:read', (data: any) => {
325+
myBackend.markRead(data.id)
326+
})
327+
}
328+
329+
dispose () {
330+
myBackend.disconnect()
331+
}
332+
}
333+
334+
app.use(createNotificationsPlugin({ adapter: new MyBackendAdapter() }))
335+
```
336+
337+
**Adapter context methods:**
338+
339+
| Method | Purpose |
340+
| - | - |
341+
| `send(input)` | Register and enqueue for toast display (real-time inbound) |
342+
| `register(input)` | Register in history only — no toast (initial/historical load) |
343+
| `on(event, handler)` | Subscribe to outbound lifecycle events |
344+
| `off(event, handler)` | Unsubscribe from a lifecycle event |
345+
346+
### Custom Ticket Fields
347+
348+
Extend `NotificationInput` to add domain-specific fields. Pass the type parameter through the adapter and plugin:
349+
350+
```ts
351+
import type { NotificationInput, NotificationsAdapterInterface, NotificationsAdapterContext } from '@vuetify/v0'
352+
353+
interface AppNotification extends NotificationInput {
354+
priority: 'low' | 'medium' | 'high'
355+
imageUrl?: string
356+
}
357+
358+
class MyBackendAdapter implements NotificationsAdapterInterface<AppNotification> {
359+
setup (context: NotificationsAdapterContext<AppNotification>) {
360+
myBackend.onMessage(msg => {
361+
context.send({
362+
id: msg.id,
363+
subject: msg.title,
364+
priority: msg.priority, // custom field
365+
imageUrl: msg.imageUrl, // custom field
366+
})
367+
})
368+
}
369+
}
370+
371+
app.use(createNotificationsPlugin<AppNotification>({ adapter: new MyBackendAdapter() }))
372+
```
373+
374+
Custom fields are preserved on the ticket and accessible anywhere you inject the notifications context.
375+
376+
> [!ASKAI] How do I write a custom adapter for my backend?
377+
338378
<DocsApi />

0 commit comments

Comments
 (0)