Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Why is our Javascript app data being properly captured locally, but lost on Sawtooth server?

We are having a problem with a custom javascript app that we have included in a survey.  The app outputs a string as data.  When tested locally, the string is recorded properly.  However, when hosted and tested on the Sawtooth server, all the output comes as “0” for some reason.

I’m looking for help to try and debug this.

We have inspected the request that is sent to the server (on Sawtooth’s server) and it seems to have a valid request being sent to the server, containing the data we want recorded.  

It isn’t easy to post the code / inspected request data without revealing confidential client information.  So, first I’d like to ask if anyone has experienced this problem before, or if anybody has a good theory for why it would work locally but not on the Sawtooth server?

Otherwise, please let us know what information would be most helpful to provide, and we can work on a redacted version.  (Hopefully the redacting doesn’t fix the problem!)
asked Nov 27, 2017 by Andrew S (210 points)
Ok, I have taken the captured server request body and redacted part of the content.

It basically  looks like this:

Request body:
hid_backup=NV%2C25%2C76156961%2C47%2C1&hid_studyname=NV&hid_respnum=25%2C76156961&hid_s=Av8AAF7DHdJ1ne7xMY2gcb4yyWojAAAAbu8q5ESo2MgHvIxChwrlW2vyLOpFpdfEBqGSRJIC5SSDHsAPqEAzLOxQfaxjZOVa&hid_pagenum=47&hid_javascript=1&hid_previous=0&hid_screenwidth=1908&XYZ_task=%5B%7B%3Aitem+%22cell-1-Biscuit-v1b1.png%22%2C+%3Adisplay+%3Aimage%2C+%3Awrong+468.6%2C+%3Acorrect+1884.885%7D+%7B%3Aitem+%22qshoa-XYZ.png%22%2C+%3Adisplay+%3Aimage%2C+%3Acorrect+210854.185%7D+%7B%3Aitem+%22tm11.png%22%2C+%3Adisplay+%3Aimage%2C+%3Awrong+508.54%2C+%3Acorrect+964.55%7D+%7B%3Aitem+%22WordSo%22%2C+%3Adisplay+%3Aword%2C+%3Awrong+36.95%2C+%3Acorrect+60.87%7D+%7B%3Aitem+%22qotgcr-XYZ.png%22%2C+%3Adisplay+%3Aimage%2C+%3Awrong+37.56%2C+%3Acorrect+141.55%7D+%7B%3Aitem+%22qccc-XYZ.png%22%2C+%3Adisplay+%3Aimage%2C+%3Awrong+12.585%2C+%3Acorrect+144.105%7D+%7B%3Aitem+%22WordSup%22%2C+%3Adisplay+%3Aword%2C+%3Awrong+25.535%2C+%3Acorrect+73.92%7D+%7B%3Aitem+%22WordExc%22%2C+%3Adisplay+%3Aword%2C+%3Awrong+5.915%2C+%3Acorrect+93.27%7D+%7B%3Aitem+%22WordDel%22%2C+%3Adisplay+%3Aword%2C+%3Awrong+84.835%2C+%3Acorrect+108.87%7D+%7B%3Aitem+%22Store+brand%22%2C+%3Adisplay+%3Aword%2C+%3Acorrect+13.135%7D+%7B%3Aitem+%22c1LBv11.png%22%2C+%3Adisplay+%3Aimage%2C+%3Awrong+37.32%2C+%3Acorrect+85.32%7D+%7B%3Aitem+%22WordFa%22%2C+%3Adisplay+%3Aword%2C+%3Acorrect+109.75%7D+%7B%3Aitem+%22WordReg%22%2C+%3Adisplay+%3Aword%2C+%3Acorrect+76.995%7D+%7B%3Aitem+%22Best%22%2C+%3Adisplay+%3Aword%2C+%3Acorrect+29.925%7D+%7B%3Aitem+%22SS11.png%22%2C+%3Adisplay+%3Aimage%2C+%3Acorrect+5.94%7D+%7B%3Aitem+%22WordHQ%22%2C+%3Adisplay+%3Aword%2C+%3Acorrect+21.215%7D+%7B%3Aitem+%22qhbs-XYZ.png%22%2C+%3Adisplay+%3Aimage%2C+%3Awrong+21.195%2C+%3Acorrect+93.185%7D+%7B%3Aitem+%22WordPre%22%2C+%3Adisplay+%3Aword%2C+%3Awrong+53.245%2C+%3Acorrect+93.34%7D+%7B%3Aitem+%22Generic%22%2C+%3Adisplay+%3Aword%2C+%3Awrong+4.995%2C+%3Acorrect+36.995%7D+%7B%3Aitem+%22WordTy%22%2C+%3Adisplay+%3Aword%2C+%3Acorrect+77.66%7D+%7B%3Aitem+%22hcqcnm-XYZ.png%22%2C+%3Adisplay+%3Aimage%2C+%3Acorrect+61.875%7D+%7B%3Aitem+%22c1Cpsv11.png%22%2C+%3Adisplay+%3Aimage%2C+%3Acorrect+44.63%7D+%7B%3Aitem+%22WordStan%22%2C+%3Adisplay+%3Aword%2C+%3Awrong+21.865%2C+%3Acorrect+141.74%7D+%7B%3Aitem+%22WordUs%22%2C+%3Adisplay+%3Aword%2C+%3Acorrect+109.055%7D+%7B%3Aitem+%22WordMai%22%2C+%3Adisplay+%3Aword%2C+%3Awrong+37.7%2C+%3Acorrect+141.635%7D+%7B%3Aitem+%22qotgcr-XYZ.png%22%2C+%3Adisplay+%3Aimage%2C+%3Awrong+29.255%2C+%3Acorrect+125.24%7D+%7B%3Aitem+%22qshotg-XYZ.png%22%2C+%3Adisplay+%3Aimage%2C+%3Awrong+61.795%2C+%3Acorrect+85.925%7D+%7B%3Aitem+%22c1Bv1b1.png%22%2C+%3Adisplay+%3Aimage%2C+%3Awrong+77.255%2C+%3Acorrect+141.37%7D+%7B%3Aitem+%22TM11.png%22%2C+%3Adisplay+%3Aimage%2C+%3Awrong+13.45%2C+%3Acorrect+21.42%7D+%7B%3Aitem+%22qccc-XYZ.png%22%2C+%3Adisplay+%3Aimage%2C+%3Awrong+21.925%2C+%3Acorrect+85.93%7D%5D&hid_q_XYZ=XYZ&hid_prev_XYZ.2=192%2CXYZ.2%2C47%2C2e68c908bf06821c85c2ae0ed31ebbec&XYZLoop=2%2C1%2C3%2C4&hid_SavedListNames=XYZLoop&hid_loops=XYZLoops%2C1&hid_page_vars=XYZLoop%2Chid_SavedListNames%2Chid_loops&hid_pagetime=1511808957


So, this is what was sent to the Sawtooth server.  But instead of recording the stuff after "XYZ_task=" as a string in the data, it just was lost.

However, it works fine when run locally.

1 Answer

+2 votes
 
Best answer
This is not my area of expertise, but what I do know is that testing a survey uses a SQLite database while your live survey is most likely using a MySQL database.  This gives me two ideas about what might be causing your problem.

First, please check that XYZ_task is expecting a string instead of a number in Lighthouse Studio.  SQLite might be more forgiving about an unexpected data type than MySQL.

Second, this may be a matter of character encoding between the two database types.  Try using a simpler XYZ_task value like "abc."  If a simple text works on the live survey when the more complex one does not, we should investigate this possibility further.

Are either of those helpful in resolving your problem?
answered Nov 27, 2017 by Zachary Platinum Sawtooth Software, Inc. (91,100 points)
selected Nov 27, 2017 by Andrew S
Thanks, Zachary!

You were right... we had that variable set as a number, not as a string.  And the different databases must have different levels of strictness.   We switched it to string, and it worked!

We really appreciate your help, because we were stumped all weekend!
...