Data Loss When Integrating jsPsych Experiment with SONA #2435
-
Hello, I programmed an experiment using jsPsych, and I was using Firestore on Firebase to save my experiment data. When I was running my program locally, all of the data was successfully saved to Firebase. However, once I integrated SONA into my experiment (I added a SONA URL to my code that redirects the participants to a credit-granting page), I noticed that more than half of the data was not saved. I was wondering if anyone had any similar issues with data loss or had any potential solutions/pointers to resolve this problem? In case this is useful, here is my original code:
I also attempted to use an
Thank you very much for your time, and any help would be much appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi @rmtham, I think the problem is that this line redirects participants to a different page: window.location.assign("**sona_study_url**"+sona_id) And that line comes before the data saving bit of code. This is a problem because the data saving happens over the network and therefore is affected by the connection speed, which means that sometimes the participant is redirected before the data has saved. So instead what you want to happen is for the data to save first, and only when that's completed, redirect the participant to the SONA completion page. To fix this, you can try moving the |
Beta Was this translation helpful? Give feedback.
-
Hi @becky-gilbert , I just wanted to say a huge thank you for all your help and for pointing me in the right direction! It took me a while to figure out how to program this up, but I was able to resolve the data loss problem by using JavaScript promises and the
As a quick note: I included an Thank you again for your help, I really appreciate it! |
Beta Was this translation helpful? Give feedback.
Hi @rmtham, I think the problem is that this line redirects participants to a different page:
And that line comes before the data saving bit of code. This is a problem because the data saving happens over the network and therefore is affected by the connection speed, which means that sometimes the participant is redirected before the data has saved. So instead what you want to happen is for the data to save first, and only when that's completed, redirect the participant to the SONA completion page.
To fix this, you can try moving the
window.location.assign("**sona_study_url**"+sona_id)
line so that it runs after data saving is complete,…