@whisperr/wizard 0.1.5 → 0.1.6

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.
Files changed (2) hide show
  1. package/dist/index.js +48 -46
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -113,7 +113,7 @@ var target2 = {
113
113
  id: "nextjs",
114
114
  displayName: "Next.js",
115
115
  language: "typescript",
116
- availability: "planned"
116
+ availability: "available"
117
117
  };
118
118
  async function detect2(ctx) {
119
119
  if (!await ctx.exists("package.json")) return null;
@@ -140,34 +140,37 @@ async function detect2(ctx) {
140
140
  return { target: target2, confidence: Math.min(confidence, 1), evidence };
141
141
  }
142
142
  var systemPrompt2 = `
143
- ## SDK: Whisperr for Web in Next.js \u2014 package \`@whisperr/web\`
144
-
145
- Same SDK as plain web, with Next-specific wiring.
143
+ ## SDK: Whisperr for Next.js \u2014 package \`@whisperr/next\` (+ \`@whisperr/web\`)
146
144
 
147
- 1) Install \`@whisperr/web\`. Put the key in NEXT_PUBLIC_WHISPERR_KEY in
148
- .env.local (and add it to .env.example).
145
+ 1) Install: \`<pm> add @whisperr/next @whisperr/web\`. Put the key in
146
+ NEXT_PUBLIC_WHISPERR_KEY in .env.local (and add it to .env.example).
149
147
 
150
- 2) Whisperr runs client-side. Create a client provider:
151
- - App Router: a 'use client' component (e.g. app/whisperr-provider.tsx) that
152
- calls Whisperr.init(...) in a useEffect and renders children; mount it in
153
- app/layout.tsx.
154
- - Pages Router: init in pages/_app.tsx inside a useEffect.
148
+ 2) Mount the provider in app/layout.tsx. It is already a 'use client' boundary,
149
+ so it drops straight into the server-component layout \u2014 no wrapper file needed:
150
+ import { WhisperrProvider } from '@whisperr/next';
151
+ // inside <body>:
152
+ <WhisperrProvider apiKey={process.env.NEXT_PUBLIC_WHISPERR_KEY!}>{children}</WhisperrProvider>
153
+ Pages Router: wrap the tree in pages/_app.tsx with <WhisperrProvider apiKey=...>.
155
154
 
156
- 3) identify() after auth resolves on the client (e.g. in your auth/session
157
- hook). reset() on sign-out.
155
+ 3) identify() after auth resolves on the client (in your session hook/effect);
156
+ reset() on sign-out. Use the useWhisperr() hook inside 'use client' components.
158
157
 
159
- 4) track() in client components / event handlers / mutation callbacks. Do NOT
160
- call track from server components, route handlers, or getServerSideProps \u2014
161
- this SDK is a browser client. Copy event_type verbatim from the manifest.
158
+ 4) track() in client components / event handlers / mutation callbacks:
159
+ 'use client';
160
+ import { useWhisperr } from '@whisperr/next';
161
+ const whisperr = useWhisperr();
162
+ whisperr.track('event_type_from_manifest', { ... });
163
+ Do NOT call track from server components, route handlers, or getServerSideProps \u2014
164
+ it is a browser client. Copy event_type verbatim (snake_case) from the manifest.
162
165
 
163
166
  Notes:
164
- - Guard against double-init under React Strict Mode (init is idempotent, but
165
- wire it so it only runs once).
167
+ - Pageviews are auto-captured via the History API (covers Next client navigation).
168
+ - Provider init is idempotent (safe under React Strict Mode).
166
169
  `.trim();
167
170
  var nextjsPlaybook = {
168
171
  target: target2,
169
172
  detect: detect2,
170
- packageRef: "@whisperr/web (npm)",
173
+ packageRef: "@whisperr/next (npm)",
171
174
  systemPrompt: systemPrompt2
172
175
  };
173
176
 
@@ -176,8 +179,7 @@ var target3 = {
176
179
  id: "web-js",
177
180
  displayName: "Web (JavaScript / TypeScript)",
178
181
  language: "typescript",
179
- // Flip to "available" once @whisperr/web ships (Phase 2).
180
- availability: "planned"
182
+ availability: "available"
181
183
  };
182
184
  function dependsOn(pkgJson, names) {
183
185
  try {
@@ -209,41 +211,41 @@ async function detect3(ctx) {
209
211
  return { target: target3, confidence: Math.min(confidence, 0.95), evidence };
210
212
  }
211
213
  var systemPrompt3 = `
212
- ## SDK: Whisperr for Web (TypeScript/JavaScript) \u2014 package \`@whisperr/web\`
214
+ ## SDK: Whisperr for Web \u2014 package \`@whisperr/web\` (+ \`@whisperr/react\` for React)
213
215
 
214
- 1) Dependency. Install with the repo's package manager (detect pnpm/yarn/npm
215
- from the lockfile): \`<pm> add @whisperr/web\`.
216
+ 1) Install (detect pnpm/yarn/npm from the lockfile):
217
+ - Vanilla / Vue / Svelte / Angular / plain TS: \`<pm> add @whisperr/web\`
218
+ - React (not Next.js): \`<pm> add @whisperr/react @whisperr/web\`
216
219
 
217
- 2) Initialize once at app entry (e.g. src/main.tsx, src/index.ts, or the root
218
- layout). Create a singleton client:
219
- import { Whisperr } from '@whisperr/web';
220
- export const whisperr = Whisperr.init({
221
- apiKey: import.meta.env.VITE_WHISPERR_KEY, // or process.env.NEXT_PUBLIC_... etc
222
- baseUrl: '<INGESTION_BASE_URL from manifest>',
223
- });
224
- Put the key in the project's env mechanism (Vite VITE_*, CRA REACT_APP_*,
225
- plain .env) and write the example var into .env / .env.example.
220
+ 2) Initialize once at app entry, using the app's PUBLIC env var (VITE_*,
221
+ REACT_APP_*, etc.). Write the var into .env / .env.example.
222
+ - Core (any framework): create a singleton in e.g. src/whisperr.ts:
223
+ import { Whisperr } from '@whisperr/web';
224
+ export const whisperr = Whisperr.init({
225
+ apiKey: import.meta.env.VITE_WHISPERR_KEY,
226
+ baseUrl: '<INGESTION_BASE_URL from manifest>', // omit if it's the default
227
+ });
228
+ - React: wrap the app root instead of a bare singleton:
229
+ import { WhisperrProvider } from '@whisperr/react';
230
+ <WhisperrProvider apiKey={import.meta.env.VITE_WHISPERR_KEY}>\u2026</WhisperrProvider>
226
231
 
227
232
  3) identify(). After auth resolves (login success, and on app load if a session
228
233
  is restored):
229
- whisperr.identify(user.id, {
230
- traits: { /* manifest traits */ },
231
- email: user.email, phone: user.phone,
232
- });
234
+ whisperr.identify(user.id, { traits: { /* manifest traits */ }, email: user.email, phone: user.phone });
235
+ React: const whisperr = useWhisperr(); then whisperr.identify(...).
233
236
  Call whisperr.reset() on logout.
234
237
 
235
238
  4) track(). For each manifest event, instrument the real handler:
236
- whisperr.track('event_type_from_manifest', { /* properties */ });
237
- In React, this belongs in event handlers / effects / mutation callbacks, not
239
+ whisperr.track('event_type_from_manifest', { /* properties */ });
240
+ In React this belongs in event handlers / effects / mutation callbacks, never
238
241
  in render. Copy event_type verbatim (snake_case) from the manifest.
239
242
 
240
243
  Notes:
241
- - The SDK batches via /v1/events/batch and flushes on a timer + on
242
- visibilitychange/unload (sendBeacon). Fire-and-forget is fine.
243
- - Only the NEXT_PUBLIC_/VITE_-style public env vars are exposed to the browser;
244
- the ingestion key is a public, rate-limited key so that is expected.
245
- - If the project uses an analytics wrapper/provider pattern, follow it rather
246
- than scattering raw whisperr.track calls.
244
+ - The SDK batches + flushes automatically (timer + on page hide). Fire-and-forget
245
+ is fine; do NOT await track().
246
+ - It auto-captures pageviews \u2014 you only add the named business events.
247
+ - Only PUBLIC env vars (VITE_/REACT_APP_/NEXT_PUBLIC_) reach the browser; the
248
+ ingestion key is meant to be public + rate-limited, so that's expected.
247
249
  `.trim();
248
250
  var webPlaybook = {
249
251
  target: target3,
@@ -1315,7 +1317,7 @@ async function main() {
1315
1317
  return;
1316
1318
  }
1317
1319
  if ("version" in parsed) {
1318
- console.log("0.1.5");
1320
+ console.log("0.1.6");
1319
1321
  return;
1320
1322
  }
1321
1323
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whisperr/wizard",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Whisperr Wizard — one command to integrate the Whisperr SDK into your app. Authenticates with your onboarded account and uses an AI coding agent to wire up identify() and your business events automatically.",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,