[PULSE-4] Goals & Events dashboard block and settings UI #5
Reference in New Issue
Block a user
No description provided.
Delete Branch "staging"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Work Item
PULSE-4
Summary
pulse.track(eventName)in the snippet and document it on the installation page.Changes
components/dashboard/GoalStats.tsx— shows goal counts from dashboard data; empty state with “Need help tracking goals?” and link to installation.app/sites/[id]/page.tsx— fetches and passesgoal_countsintoGoalStats.lib/api/stats.ts—GoalCountStatandgoal_countsonDashboardData.app/sites/[id]/settings/page.tsx— new “Goals & Events” tab; state and modal for add/edit; list with edit/delete; calls to goals API.lib/api/goals.ts—listGoals,createGoal,updateGoal,deleteGoal.public/script.js—window.pulse.track(eventName)with validation (regex/length).app/installation/page.tsx— instructions and example forpulse.track()and Goals & Events in settings.Test Plan
[ ] Site dashboard shows Goals & Events block; with no custom events, empty state and doc link display.
[ ] After sending
pulse.track('event_name')events, dashboard shows counts for those event names.[ ] Settings → Goals & Events: create, edit, and delete goals; list updates and persists.
[ ] Installation page documents
pulse.track()and points to Settings → Goals & Events for defining goals.Greptile Overview
Greptile Summary
This PR implements a comprehensive goals and events tracking system for Pulse. Users can define custom goals in Settings → Goals & Events, track them via
pulse.track('event_name')in their site code, and view counts in the dashboard.Key changes:
pulse.track()API with validation (alphanumeric + underscores, max 64 chars)GoalStatscomponent showing display namesArchitecture highlights:
display_namefield from backendThe implementation is well-structured with proper validation at multiple layers and good user experience.
Confidence Score: 4.5/5
Important Files Changed
pulse.track()API with proper validation for custom event trackingdisplay_namefallbackSequence Diagram
2 files reviewed, 1 comment
Edit Code Review Agent Settings | Greptile
Event name validation missing max length check. The client-side script enforces a 64-character limit (EVENT_NAME_MAX in
public/script.js:232), but this validation doesn't check length.Prompt To Fix With AI
4 files reviewed, 2 comments
Edit Code Review Agent Settings | Greptile
@@ -115,3 +202,4 @@const handleSubmit = async (e: React.FormEvent) => {e.preventDefault()setSaving(true)order of operations: transform then validate length. The transformation (
.trim().toLowerCase().replace(/\s+/g, '_')) happens before length check. A 50-char input with spaces becomes 48 chars after replacing spaces with underscores. This is fine, but consider if users might be confused when "my event name" (13 chars) becomes "my_event_name" (13 chars) - the length stays the same here but spaces→underscores could theoretically reduce length if multiple spaces exist.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
@@ -0,0 +1,64 @@'use client'displays transformed
event_nameinstead of goal's display name. The API returnsGoalCountStatwith onlyevent_nameandcount, but goals have a separatenamefield (display name). Users define goals with friendly names like "User Signups" for event "signup_click", but this shows "signup click" (transformed event name).Verify if the backend should return goal names with the counts, or if showing transformed event names is intentional.
Prompt To Fix With AI
3 files reviewed, 1 comment
Edit Code Review Agent Settings | Greptile
@@ -0,0 +1,64 @@'use client'siteIdanddateRangeprops are unused - can remove from interface and componentPrompt To Fix With AI
4 files reviewed, 3 comments
Edit Code Review Agent Settings | Greptile
no validation for duplicate
event_namewithin the same site. Users can create multiple goals with the sameevent_name, which could cause confusion in the dashboard or unexpected behavior when tracking events.Prompt To Fix With AI
updating a goal's
event_nameloses historical connection to tracked events. Events already tracked under the old name won't be associated with the renamed goal.Prompt To Fix With AI
@@ -228,4 +228,40 @@// * Track popstate (browser back/forward)overwrites existing
window.pulseif it exists. If the script loads multiple times or another library useswindow.pulse, this silently replaces it.Prompt To Fix With AI
3 files reviewed, 1 comment
Edit Code Review Agent Settings | Greptile
transformation logic only handles spaces. Input like
"test!!!test"gets trimmed/lowercased but has no spaces, so thereplace(/\s+/g, '_')doesn't change invalid chars. It's then rejected by the regex. The current approach is correct (reject rather than silently fix), but consider adding a hint in the UI that invalid characters cannot be used (not just that spaces become underscores).Prompt To Fix With AI