@m13v/seo-components 0.32.1 → 0.33.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m13v/seo-components",
3
- "version": "0.32.1",
3
+ "version": "0.33.0",
4
4
  "scripts": {
5
5
  "build:css": "tailwind -i src/_build.css -o dist/styles.css --minify",
6
6
  "lint:mobile-spans": "node scripts/lint-mobile-spans.mjs",
@@ -69,9 +69,22 @@ export interface InstallEmailGateProps {
69
69
  newsletterPath?: string;
70
70
  /** Render a custom trigger element instead of the default button. Receives an onClick handler. */
71
71
  renderTrigger?: (props: { onClick: () => void; disabled?: boolean }) => React.ReactNode;
72
+ /**
73
+ * Email-only delivery mode. When true, the command is NEVER revealed in the
74
+ * modal; instead, after a successful email submit the user sees a
75
+ * "Check your inbox" success state. The newsletter route is responsible for
76
+ * sending the install command via email. Forces a re-submit on every click
77
+ * (no localStorage skip) so each click drives a fresh send and a clean
78
+ * `newsletter_subscribed` + `get_started_click` signal.
79
+ */
80
+ emailOnly?: boolean;
81
+ /** Stage 2 (sent) heading when emailOnly is true. */
82
+ sentTitle?: string;
83
+ /** Stage 2 (sent) body copy when emailOnly is true. Receives the submitted email. */
84
+ sentDescription?: (email: string) => React.ReactNode;
72
85
  }
73
86
 
74
- type Stage = "closed" | "email" | "command";
87
+ type Stage = "closed" | "email" | "command" | "sent";
75
88
 
76
89
  export function InstallEmailGate({
77
90
  command,
@@ -92,10 +105,14 @@ export function InstallEmailGate({
92
105
  storageKey = DEFAULT_STORAGE_KEY,
93
106
  newsletterPath = "/api/newsletter",
94
107
  renderTrigger,
108
+ emailOnly = false,
109
+ sentTitle = "Check your inbox",
110
+ sentDescription,
95
111
  }: InstallEmailGateProps) {
96
112
  const capture = useCapture();
97
113
  const [stage, setStage] = useState<Stage>("closed");
98
114
  const [email, setEmail] = useState("");
115
+ const [submittedEmail, setSubmittedEmail] = useState("");
99
116
  const [submitting, setSubmitting] = useState(false);
100
117
  const [error, setError] = useState("");
101
118
  const [copied, setCopied] = useState<"command" | "config" | null>(null);
@@ -119,14 +136,22 @@ export function InstallEmailGate({
119
136
  }, [stage]);
120
137
 
121
138
  const onOpen = () => {
122
- const skip = remember && hasCapturedInstallEmail(storageKey);
123
- trackGetStartedClick({
124
- destination: skip ? "modal:command" : "modal:email",
125
- site,
126
- section,
127
- text: label,
128
- component: "InstallEmailGate",
129
- });
139
+ // emailOnly mode: never skip via localStorage, never reveal the command.
140
+ // Every click goes through the email form so the user gets a fresh email
141
+ // and the funnel records a fresh signal.
142
+ const skip = !emailOnly && remember && hasCapturedInstallEmail(storageKey);
143
+ if (skip) {
144
+ // Gate already passed previously: fire the canonical funnel event for
145
+ // the gated-passed click. No event when the gate is fresh and we're
146
+ // about to ask for the email; that fires on submit instead.
147
+ trackGetStartedClick({
148
+ destination: "modal:command",
149
+ site,
150
+ section,
151
+ text: label,
152
+ component: "InstallEmailGate",
153
+ });
154
+ }
130
155
  setStage(skip ? "command" : "email");
131
156
  setError("");
132
157
  };
@@ -163,20 +188,23 @@ export function InstallEmailGate({
163
188
  site,
164
189
  section,
165
190
  source: "install_gate",
191
+ delivery: emailOnly ? "email_only" : "page_reveal",
166
192
  });
167
193
  trackGetStartedClick({
168
- destination: "modal:command",
194
+ destination: emailOnly ? "email:install" : "modal:command",
169
195
  site,
170
196
  section,
171
197
  text: "email-submitted",
172
198
  component: "InstallEmailGate",
173
- extra: { email: trimmed },
199
+ extra: { email: trimmed, delivery: emailOnly ? "email_only" : "page_reveal" },
174
200
  });
175
- setStage("command");
201
+ setSubmittedEmail(trimmed);
202
+ setStage(emailOnly ? "sent" : "command");
176
203
  } catch (err) {
177
204
  console.warn("[InstallEmailGate] newsletter POST network error", err);
178
205
  if (remember) markInstallEmailCaptured(trimmed, storageKey);
179
- setStage("command");
206
+ setSubmittedEmail(trimmed);
207
+ setStage(emailOnly ? "sent" : "command");
180
208
  } finally {
181
209
  setSubmitting(false);
182
210
  }
@@ -186,12 +214,16 @@ export function InstallEmailGate({
186
214
  try {
187
215
  await navigator.clipboard.writeText(text);
188
216
  setCopied(which);
189
- trackGetStartedClick({
190
- destination: which === "command" ? "clipboard:command" : "clipboard:config",
217
+ // Track the copy as its own event so it does not inflate the
218
+ // canonical `get_started_click` funnel. The gate event fires once
219
+ // when the email is submitted (or once on each subsequent gated-
220
+ // passed click), not for every clipboard copy.
221
+ capture("install_command_copied", {
222
+ component: "InstallEmailGate",
191
223
  site,
192
224
  section,
193
- text: which === "command" ? command : configBlock?.label,
194
- component: "InstallEmailGate",
225
+ which,
226
+ page: typeof window !== "undefined" ? window.location.pathname : undefined,
195
227
  });
196
228
  setTimeout(() => setCopied(null), 1800);
197
229
  } catch {
@@ -282,11 +314,72 @@ export function InstallEmailGate({
282
314
  </button>
283
315
  </form>
284
316
  <p className="mt-4 text-xs text-zinc-500">
285
- Already subscribed? Submit anyway, the command unlocks either way.
317
+ {emailOnly
318
+ ? "Already subscribed? Submit anyway, we'll resend the install link."
319
+ : "Already subscribed? Submit anyway, the command unlocks either way."}
286
320
  </p>
287
321
  </div>
288
322
  )}
289
323
 
324
+ {stage === "sent" && (
325
+ <div className="p-7">
326
+ <div className="mb-5 flex items-start justify-between gap-4">
327
+ <div>
328
+ <div className="mb-3 inline-flex h-10 w-10 items-center justify-center rounded-full bg-teal-50 text-teal-600">
329
+ <svg
330
+ className="h-5 w-5"
331
+ fill="none"
332
+ viewBox="0 0 24 24"
333
+ stroke="currentColor"
334
+ strokeWidth={2}
335
+ aria-hidden="true"
336
+ >
337
+ <path strokeLinecap="round" strokeLinejoin="round" d="M3 8l7.5 5.25a3 3 0 003 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" />
338
+ </svg>
339
+ </div>
340
+ <h2 className="text-xl font-semibold tracking-tight text-zinc-900">
341
+ {sentTitle}
342
+ </h2>
343
+ <p className="mt-1 text-sm leading-relaxed text-zinc-600">
344
+ {sentDescription
345
+ ? sentDescription(submittedEmail)
346
+ : (
347
+ <>
348
+ Sent the install command to{" "}
349
+ <span className="font-medium text-zinc-900">{submittedEmail}</span>.
350
+ It usually arrives in under a minute. If you don&apos;t see it, check
351
+ spam or promotions.
352
+ </>
353
+ )}
354
+ </p>
355
+ </div>
356
+ <CloseButton onClick={() => setStage("closed")} />
357
+ </div>
358
+
359
+ <div className="mt-5 flex items-center justify-between gap-3">
360
+ {githubUrl ? (
361
+ <a
362
+ href={githubUrl}
363
+ target="_blank"
364
+ rel="noopener noreferrer"
365
+ className="text-sm font-medium text-teal-700 hover:text-teal-800"
366
+ >
367
+ View on GitHub →
368
+ </a>
369
+ ) : (
370
+ <span />
371
+ )}
372
+ <button
373
+ type="button"
374
+ onClick={() => setStage("closed")}
375
+ className="rounded-md border border-zinc-300 bg-white px-4 py-2 text-sm font-medium text-zinc-900 hover:bg-zinc-50"
376
+ >
377
+ Done
378
+ </button>
379
+ </div>
380
+ </div>
381
+ )}
382
+
290
383
  {stage === "command" && (
291
384
  <div className="p-7">
292
385
  <div className="mb-5 flex items-start justify-between gap-4">