diff --git a/packages/extension-mouse-tracking/src/index.ts b/packages/extension-mouse-tracking/src/index.ts index cb2aa81c15..37bcc0d23d 100644 --- a/packages/extension-mouse-tracking/src/index.ts +++ b/packages/extension-mouse-tracking/src/index.ts @@ -155,8 +155,6 @@ class MouseTrackingExtension implements JsPsychExtension { } return { - extension_type: "mouse-tracking", - extension_version: version, mouse_tracking_data: this.currentTrialData, mouse_tracking_targets: Object.fromEntries(this.currentTrialTargets.entries()), }; diff --git a/packages/extension-record-video/src/index.ts b/packages/extension-record-video/src/index.ts index bf6b2ced55..1774cfdbb9 100644 --- a/packages/extension-record-video/src/index.ts +++ b/packages/extension-record-video/src/index.ts @@ -58,18 +58,10 @@ class RecordVideoExtension implements JsPsychExtension { if (!this.currentTrialData.record_video_data) { this.onUpdateCallback = () => { - resolve({ - extension_type: "record-video", - extension_version: version, - ...this.currentTrialData, - }); + resolve(this.currentTrialData); }; } else { - resolve({ - extension_type: "record-video", - extension_version: version, - ...this.currentTrialData, - }); + resolve(this.currentTrialData); } }); }; diff --git a/packages/extension-webgazer/src/index.ts b/packages/extension-webgazer/src/index.ts index 2f0f7368f2..56f02a4496 100644 --- a/packages/extension-webgazer/src/index.ts +++ b/packages/extension-webgazer/src/index.ts @@ -211,8 +211,6 @@ class WebGazerExtension implements JsPsychExtension { // send back the gazeData return { - extension_type: "webgazer", - extension_version: version, webgazer_data: this.currentTrialData, webgazer_targets: this.currentTrialTargets, }; diff --git a/packages/jspsych/src/ExtensionManager.ts b/packages/jspsych/src/ExtensionManager.ts index 75802759d2..bafc139bfc 100644 --- a/packages/jspsych/src/ExtensionManager.ts +++ b/packages/jspsych/src/ExtensionManager.ts @@ -40,9 +40,28 @@ export class ExtensionManager { public async initializeExtensions() { await Promise.all( - this.extensionsConfiguration.map(({ type, params = {} }) => - this.getExtensionInstanceByClass(type).initialize(params) - ) + this.extensionsConfiguration.map(({ type, params = {} }) => { + this.getExtensionInstanceByClass(type).initialize(params); + + const extensionInfo = type["info"] as JsPsychExtensionInfo; + + if (!("version" in extensionInfo) && !("data" in extensionInfo)) { + console.warn( + extensionInfo["name"], + "is missing the 'version' and 'data' fields. Please update extension as 'version' and 'data' will be required in v9. See https://www.jspsych.org/latest/developers/extension-development/ for more details." + ); + } else if (!("version" in extensionInfo)) { + console.warn( + extensionInfo["name"], + "is missing the 'version' field. Please update extension as 'version' will be required in v9. See https://www.jspsych.org/latest/developers/extension-development/ for more details." + ); + } else if (!("data" in extensionInfo)) { + console.warn( + extensionInfo["name"], + "is missing the 'data' field. Please update extension as 'data' will be required in v9. See https://www.jspsych.org/latest/developers/extension-development/ for more details." + ); + } + }) ); } @@ -67,14 +86,14 @@ export class ExtensionManager { ) ); - const extensionInfo = trialExtensionsConfiguration.length + const extensionInfos = trialExtensionsConfiguration.length ? { - extension_type: results.map((result) => result.extension_type), - extension_version: results.map((result) => result.extension_version), + extension_type: trialExtensionsConfiguration.map(({ type }) => type["info"].name), + extension_version: trialExtensionsConfiguration.map(({ type }) => type["info"].version), } : {}; - results.push(extensionInfo); + results.push(extensionInfos); return Object.assign({}, ...results); }