@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.
- package/dist/index.js +48 -46
- 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: "
|
|
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
|
|
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
|
|
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)
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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 (
|
|
157
|
-
|
|
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
|
|
160
|
-
|
|
161
|
-
|
|
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
|
-
-
|
|
165
|
-
|
|
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/
|
|
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
|
-
|
|
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
|
|
214
|
+
## SDK: Whisperr for Web \u2014 package \`@whisperr/web\` (+ \`@whisperr/react\` for React)
|
|
213
215
|
|
|
214
|
-
1)
|
|
215
|
-
|
|
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
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
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
|
-
|
|
230
|
-
|
|
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
|
-
|
|
237
|
-
In React
|
|
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
|
|
242
|
-
|
|
243
|
-
-
|
|
244
|
-
|
|
245
|
-
|
|
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.
|
|
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.
|
|
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,
|