Skip to content

Pass PROLIFIC_PID through to the post-survey URL - #135

Merged
jon-bell merged 1 commit into
mainfrom
prolific-pid-survey-passthrough
Aug 5, 2026
Merged

Pass PROLIFIC_PID through to the post-survey URL#135
jon-bell merged 1 commit into
mainfrom
prolific-pid-survey-passthrough

Conversation

@jon-bell

@jon-bell jon-bell commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

What

The Qualtrics post-survey needs the participant's PROLIFIC_PID so their response can be matched back to the study. The tutorial finish screen (CompletionCta) already links to the workshop's surveyUrl; this appends ?PROLIFIC_PID=<pid> to that link when the workspace carries a captured Prolific PID.

How

  • withProlificPid() helper in lib/prolific.ts — merges the PID into the survey URL via the URL API, so it:
    • appends ?PROLIFIC_PID=… to a bare URL,
    • merges with an existing query string (…?foo=bar&PROLIFIC_PID=…) rather than clobbering it,
    • overwrites a stale PROLIFIC_PID instead of duplicating it,
    • URL-encodes the value,
    • passes the URL through untouched when there's no PID (participant didn't arrive via Prolific), no URL, or the URL isn't absolute/parseable.
  • PatchLensArea reads the workspace's captured prolific.prolificPid (same query key already cached elsewhere) and composes the surveyUrl handed to the finish-screen CTA. Naturally gated: surveyUrl only exists for workshops and the PID only exists for Prolific arrivals.
  • Unit tests for both parseProlificParams and withProlificPid.

Testing

bun test → 114/114 pass. tsc/prettier clean on changed files.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Survey links launched from Patch Lens now include the workspace’s Prolific participant ID.
    • Existing survey URL parameters are preserved while the participant ID is added or updated.
  • Bug Fixes

    • Survey links remain unchanged when the URL or participant ID is unavailable or invalid.

The Qualtrics post-survey needs the participant's PROLIFIC_PID so the
response can be matched back to the study. The tutorial finish screen
already links to the workshop's surveyUrl; append `?PROLIFIC_PID=<pid>`
(merged with any existing query string) when the workspace carries a
captured Prolific PID, and pass the URL through untouched otherwise
(participant didn't arrive via Prolific, or no survey configured).

- withProlificPid() helper in lib/prolific.ts (URL-based merge; overwrites
  a stale key, encodes the value, no-ops on non-absolute/malformed URLs).
- PatchLensArea reads the workspace's captured prolific.prolificPid and
  composes the surveyUrl handed to the finish-screen CTA.
- Unit tests for parse + pass-through.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
workbench Ready Ready Preview Aug 5, 2026 6:03pm

Request Review

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The patch lens retrieves the workspace’s Prolific participant ID and adds it to the tutorial survey URL. A new helper handles insertion, replacement, encoding, parameter preservation, and invalid input. Unit tests cover these cases.

Changes

Prolific participant ID flow

Layer / File(s) Summary
PID URL helper and validation
workbench/_web/src/lib/prolific.ts, workbench/_web/src/lib/__tests__/prolific.test.ts
Adds withProlificPid and tests URL parameter handling, encoding, preservation, replacement, and pass-through behavior.
Patch lens workspace integration
workbench/_web/src/app/workbench/[workspaceId]/patch-lens/[chartId]/components/PatchLensArea.tsx
Fetches the workspace participant ID and passes the enriched survey URL to TutorialActivityPanel.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PatchLensArea
  participant WorkspaceQuery
  participant withProlificPid
  participant TutorialActivityPanel
  PatchLensArea->>WorkspaceQuery: fetch workspace by workspaceId
  WorkspaceQuery-->>PatchLensArea: return captured Prolific participant ID
  PatchLensArea->>withProlificPid: add participant ID to survey URL
  withProlificPid-->>PatchLensArea: return enriched survey URL
  PatchLensArea->>TutorialActivityPanel: pass enriched survey URL
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: passing PROLIFIC_PID through to the post-survey URL.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch prolific-pid-survey-passthrough

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
workbench/_web/src/app/workbench/[workspaceId]/patch-lens/[chartId]/components/PatchLensArea.tsx (1)

179-179: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use async/await in the query function.

Line 179 returns the promise from getWorkspaceById directly. Make the query function async and await the call.

Proposed fix
-        queryFn: () => getWorkspaceById(workspaceId as string),
+        queryFn: async () => await getWorkspaceById(workspaceId as string),

As per coding guidelines, “Always use async/await for promises in TypeScript code”.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@workbench/_web/src/app/workbench/`[workspaceId]/patch-lens/[chartId]/components/PatchLensArea.tsx
at line 179, Update the queryFn callback in PatchLensArea to be async and await
the getWorkspaceById(workspaceId as string) call, preserving the existing
workspace query behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@workbench/_web/src/app/workbench/`[workspaceId]/patch-lens/[chartId]/components/PatchLensArea.tsx:
- Line 179: Update the queryFn callback in PatchLensArea to be async and await
the getWorkspaceById(workspaceId as string) call, preserving the existing
workspace query behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: af904f3f-6dac-444b-b807-0683d3f058c5

📥 Commits

Reviewing files that changed from the base of the PR and between 75fe646 and 3bb5ea1.

📒 Files selected for processing (3)
  • workbench/_web/src/app/workbench/[workspaceId]/patch-lens/[chartId]/components/PatchLensArea.tsx
  • workbench/_web/src/lib/__tests__/prolific.test.ts
  • workbench/_web/src/lib/prolific.ts

@argos-ci

argos-ci Bot commented Aug 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) 👍 Approved by Jonathan Bell 9 changed Aug 5, 2026, 6:07 PM

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🧹 Preview for PR #135 torn down.

@jon-bell
jon-bell merged commit 974bbde into main Aug 5, 2026
8 checks passed
@jon-bell
jon-bell deleted the prolific-pid-survey-passthrough branch August 5, 2026 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant