From 61cf0ee2adfb50d7ca3a5e2a535b794e5eee537c Mon Sep 17 00:00:00 2001 From: Becky Gilbert Date: Tue, 15 Oct 2024 09:57:25 -0700 Subject: [PATCH] add chs_type: consent to video consent plugin --- packages/record/src/consentVideo.spec.ts | 4 ++++ packages/record/src/consentVideo.ts | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/packages/record/src/consentVideo.spec.ts b/packages/record/src/consentVideo.spec.ts index 630846c3..add1ba7c 100644 --- a/packages/record/src/consentVideo.spec.ts +++ b/packages/record/src/consentVideo.spec.ts @@ -272,3 +272,7 @@ test("nextButton", () => { expect(jsPsych.finishTrial).toHaveBeenCalledTimes(1); }); + +test("Does video consent plugin return chsData correctly?", () => { + expect(VideoConsentPlugin.chsData()).toMatchObject({ chs_type: "consent" }); +}); diff --git a/packages/record/src/consentVideo.ts b/packages/record/src/consentVideo.ts index 0bea6140..0fbbb85c 100644 --- a/packages/record/src/consentVideo.ts +++ b/packages/record/src/consentVideo.ts @@ -281,4 +281,15 @@ export class VideoConsentPlugin implements JsPsychPlugin { const next = this.getButton(display, "next"); next.addEventListener("click", () => this.jsPsych.finishTrial()); } + + /** + * Add CHS type to experiment data. This will enable Lookit API to run the + * "consent" Frame Action Dispatcher method after the experiment has + * completed. It looks like jsPsych uses snake case for these data. + * + * @returns Object containing CHS type. + */ + public static chsData() { + return { chs_type: "consent" }; + } }