mirror of
https://github.com/supabase/supabase.git
synced 2026-12-03 23:18:57 +00:00
The telemetry skill had no rules for mistakes I keep flagging in telemetry PR reviews, two of its sections repeated the rest of the file, and its approved verb list held verbs that no event uses or that another verb already covers. I added the rules, collapsed the repetition, cut four verbs, and renamed the three events whose verb is outside the list. **Changed:** - **New tracking rules**: I added rules for dismiss and abandonment events (a property must be able to differ at the call site), values captured at submit time, `track()` on conditionally rendered elements, debounced sends, events sent just before leaving the page, experiment exposure, and org-level events. I also added a rule for actions that change nothing: a bulk or menu action that changed nothing sends no result event, and a count property reports only the items that changed. The verify step now checks that case too. - **Shorter skill**: I changed "Review Rules" and "Implementing New Tracking" to link to the section that states each rule. I removed the verification checklist because each item duplicated a rule stated above it. - **Approved verbs**: I removed `intended` and `converted` (no event uses them) and `sent` and `moved` (one event each, both covered by another verb), and defined `created` against `added`. The skill now says the list is the authority. It used to say the list was derived from `telemetry-constants.ts`, which still holds older events with other verbs. I also stated when each verb fires: `clicked` and `submitted` in the handler, the rest once the result has happened. I updated the verb list in `.coderabbit.yaml` to match. - **Event renames**: `www_subprocessor_updates_subscribed` is now `www_subprocessor_updates_form_completed` (still sent after the successful response, so it keeps counting completed subscriptions), `realtime_inspector_broadcast_sent` is now `realtime_inspector_broadcast_submitted`, and `home_section_rows_moved` is now `home_section_rows_updated`. Nothing else in this repo references the old names. **Note:** after each app deploys, the renamed event is a new series, so a chart that spans the change needs both names. ## To test Tested on the PR preview: - [ ] On www, open `/legal/customer-resources/subprocessor-list`, submit the updates form with a test email, expect one `telemetry/event` request whose `action` is `www_subprocessor_updates_form_completed`, and no event after a failed submit. - [x] In Studio, open a project's Realtime Inspector, join a channel, send a broadcast message, expect one `telemetry/event` request whose `action` is `realtime_inspector_broadcast_submitted`. Observed: one request with that action and a 201 response, and no event after canceling the modal. - [x] In Studio, on the project home page, drag a section to a new position, expect one `telemetry/event` request whose `action` is `home_section_rows_updated` with `section_moved`, `old_position` and `new_position`. Observed: one request per drag, with `section_moved: "usage"`, `old_position: 1`, `new_position: 2`. I checked the staging analytics project: both new Studio event names showed up with matching counts, and neither old name did. ## Linear - fixes GROWTH-1584
130 lines
4.4 KiB
TypeScript
130 lines
4.4 KiB
TypeScript
import { useSendTelemetryEvent } from '~/lib/telemetry'
|
|
import Link from 'next/link'
|
|
import { useState } from 'react'
|
|
import { Button, Input, Label } from 'ui'
|
|
|
|
const isValidEmail = (email: string): boolean => {
|
|
const emailPattern = /^[\w-\.+]+@([\w-]+\.)+[\w-]{2,8}$/
|
|
return emailPattern.test(email)
|
|
}
|
|
|
|
/**
|
|
* Subscribe form for subprocessor update notifications.
|
|
* Mirrors components/SecurityNewsletterForm.tsx, posting to the
|
|
* /api-v2/submit-form-subprocessor-updates route (Customer.io "Subprocessor Alerts", topic_4).
|
|
*/
|
|
const SubprocessorUpdatesForm = () => {
|
|
const [firstName, setFirstName] = useState('')
|
|
const [lastName, setLastName] = useState('')
|
|
const [email, setEmail] = useState('')
|
|
const [status, setStatus] = useState<'idle' | 'loading' | 'success' | 'error'>('idle')
|
|
const [errorMessage, setErrorMessage] = useState('')
|
|
const sendTelemetryEvent = useSendTelemetryEvent()
|
|
|
|
const handleSubmit = async (e: React.FormEvent) => {
|
|
e.preventDefault()
|
|
setErrorMessage('')
|
|
|
|
if (!firstName || !lastName || !email) {
|
|
setErrorMessage('All fields are required.')
|
|
return
|
|
}
|
|
|
|
if (!isValidEmail(email)) {
|
|
setErrorMessage('Please enter a valid email address.')
|
|
return
|
|
}
|
|
|
|
setStatus('loading')
|
|
|
|
try {
|
|
const res = await fetch('/api-v2/submit-form-subprocessor-updates', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ firstName, lastName, email }),
|
|
})
|
|
|
|
if (!res.ok) {
|
|
const data = await res.json()
|
|
throw new Error(data.message || 'Something went wrong')
|
|
}
|
|
|
|
setStatus('success')
|
|
sendTelemetryEvent({ action: 'www_subprocessor_updates_form_completed' })
|
|
} catch (err: any) {
|
|
setStatus('error')
|
|
setErrorMessage(err.message || 'Something went wrong. Please try again.')
|
|
}
|
|
}
|
|
|
|
return (
|
|
<div className="border rounded-xl bg-surface-75 p-4 md:p-6 w-full max-w-lg not-prose">
|
|
<p className="text-foreground-light text-sm text-pretty mb-6">
|
|
<strong className="text-foreground">Subscribe to updates</strong>. Receive an email
|
|
notification when Supabase updates its sub-processors. By submitting this form, you
|
|
acknowledge and agree that Supabase will process your personal information in accordance
|
|
with our{' '}
|
|
<Link
|
|
href="https://supabase.com/privacy"
|
|
className="text-primary hover:underline"
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
>
|
|
Privacy Policy
|
|
</Link>
|
|
.
|
|
</p>
|
|
|
|
{status === 'success' ? (
|
|
<p className="text-foreground text-sm">
|
|
Thanks for subscribing! You'll receive an email when Supabase updates its sub-processors.
|
|
</p>
|
|
) : (
|
|
<form onSubmit={handleSubmit} className="flex flex-col gap-4">
|
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
<div className="flex flex-col gap-2">
|
|
<Label htmlFor="subprocessor-first-name">First name</Label>
|
|
<Input
|
|
id="subprocessor-first-name"
|
|
type="text"
|
|
value={firstName}
|
|
onChange={(e) => setFirstName(e.target.value)}
|
|
placeholder="First name"
|
|
required
|
|
/>
|
|
</div>
|
|
<div className="flex flex-col gap-2">
|
|
<Label htmlFor="subprocessor-last-name">Last name</Label>
|
|
<Input
|
|
id="subprocessor-last-name"
|
|
type="text"
|
|
value={lastName}
|
|
onChange={(e) => setLastName(e.target.value)}
|
|
placeholder="Last name"
|
|
required
|
|
/>
|
|
</div>
|
|
</div>
|
|
<div className="flex flex-col gap-2">
|
|
<Label htmlFor="subprocessor-email">Email</Label>
|
|
<Input
|
|
id="subprocessor-email"
|
|
type="email"
|
|
value={email}
|
|
onChange={(e) => setEmail(e.target.value)}
|
|
placeholder="Email"
|
|
required
|
|
/>
|
|
</div>
|
|
{errorMessage && <p className="text-destructive text-sm">{errorMessage}</p>}
|
|
<Button variant="primary" size="large" type="submit" loading={status === 'loading'}>
|
|
Subscribe
|
|
</Button>
|
|
</form>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default SubprocessorUpdatesForm
|