Skip to content

feat: add UTM parameter data to insights bookings CSV download#27854

Merged
anikdhabal merged 3 commits intomainfrom
devin/1770797380-add-utm-to-insights-csv
Feb 11, 2026
Merged

feat: add UTM parameter data to insights bookings CSV download#27854
anikdhabal merged 3 commits intomainfrom
devin/1770797380-add-utm-to-insights-csv

Conversation

@CarinaWolli
Copy link
Copy Markdown
Member

@CarinaWolli CarinaWolli commented Feb 11, 2026

What does this PR do?

Adds UTM parameter data (utm_source, utm_medium, utm_campaign, utm_term, utm_content) to the CSV download from /insights bookings, matching the format already used in the /insights/routing CSV download.

Previously, the bookings CSV export did not include any UTM tracking data. UTM data is stored on the Tracking model (one-to-one relation with Booking via @@unique([bookingId])). The routing form responses CSV already includes UTM columns (see routing-events.ts lines 191-195), so this change brings parity.

Changes:

  • Extended the BookingWithAttendees type to include the tracking relation (nullable, since not all bookings have tracking data)
  • Added the tracking relation with UTM fields to the Prisma select in getCsvData
  • Added getUtmDataForBooking helper to extract UTM data via booking.tracking, with empty-string defaults for null values (matching routing CSV behavior)
  • UTM columns appear at the end of each CSV row
  • Added unit tests for getUtmDataForBooking and UTM inclusion in transformBookingsForCsv, updated existing test fixtures and snapshots

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  1. Create bookings that have UTM parameters (book via a URL with ?utm_source=test&utm_medium=email etc.)
  2. Go to /insights, select a date range covering those bookings
  3. Click Download → As CSV
  4. Open the CSV and confirm utm_source, utm_medium, utm_campaign, utm_term, utm_content columns are present with correct values
  5. Compare with the routing CSV download from /insights/routing to verify the format matches

Human Review Checklist

  • Verify the tracking relation JOIN in getCsvData doesn't significantly impact query performance for large exports
  • Confirm empty-string default for missing UTM values (matching routing CSV) vs. null is the desired behavior
  • Check that the additional bookingsByUid Map construction in transformBookingsForCsv is acceptable (iterates bookings array once more per batch of up to 100)

Link to Devin run: https://app.devin.ai/sessions/9683a4a30f3344f7a52a2954eb9119e7
Requested by: @CarinaWolli

Co-Authored-By: carina@cal.com <c.wollendorfer@me.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Co-Authored-By: carina@cal.com <c.wollendorfer@me.com>
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

@pull-request-size pull-request-size Bot added size/L and removed size/M labels Feb 11, 2026
…king

Co-Authored-By: carina@cal.com <c.wollendorfer@me.com>
@CarinaWolli CarinaWolli marked this pull request as ready for review February 11, 2026 09:31
@graphite-app graphite-app Bot requested a review from a team February 11, 2026 09:31
@graphite-app graphite-app Bot added the core area: core, team members only label Feb 11, 2026
Copy link
Copy Markdown
Contributor

@eunjae-lee eunjae-lee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the code change looks good !

@anikdhabal anikdhabal merged commit 36713fc into main Feb 11, 2026
90 of 91 checks passed
@anikdhabal anikdhabal deleted the devin/1770797380-add-utm-to-insights-csv branch February 11, 2026 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

consumer core area: core, team members only ready-for-e2e size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants