I looked at the bugfix and implemented the code:
if (Object.keys(newConfig).length > 0) {
in this line:
https://github.com/adaptlearning/adapt-contrib-xapi/blob/d6b98eb8e48eecab98d09c89a378af802a2cb367/js/XAPI.js#L1004
And I suddenly got some statements in the LRS (I have tested in SCORM Cloud's sandbox LRS)!
But I noticed that some of the expected statements at the end of the session seemed to be missing (like "terminated").
I noticed an error occurred in this line:
https://github.com/adaptlearning/adapt-contrib-xapi/blob/d6b98eb8e48eecab98d09c89a378af802a2cb367/js/XAPI.js#L1004
I believe it is the same issue as in the above bug fix, but also a problem with the "result" parameter which is optional and could be undefined.
So I tried with this code:
if (result && (Object.keys(result).length > 0)) {
But the last statements are still missing, and I get this error when I close the course:
react_devtools_backend.js:4061 ERROR: adapt-contrib-xapi: DOMException: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'https://cloud.scorm.com/lrs/45MN2ZJO0D/sandbox/statements': Synchronous XHR in page dismissal. See https://www.chromestatus.com/feature/4664843055398912 for more details.
at Object._.XHR_request (https://cloud.scorm.com/sandbox/content/courses/45MN2ZJO0D/xapi-test-course_20220301_05349e0d0a36b-3c84-4027-a220-88af9cec56f8/0/libraries/xapiwrapper.min.js:3:33505)
at t.sendStatement (https://cloud.scorm.com/sandbox/content/courses/45MN2ZJO0D/xapi-test-course_20220301_05349e0d0a36b-3c84-4027-a220-88af9cec56f8/0/libraries/xapiwrapper.min.js:3:21672)
at XAPI._callee17$ (https://cloud.scorm.com/sandbox/content/courses/45MN2ZJO0D/xapi-test-course_20220301_05349e0d0a36b-3c84-4027-a220-88af9cec56f8/0/adapt/js/adapt.min.js:16037:43)
at s (https://cloud.scorm.com/sandbox/content/courses/45MN2ZJO0D/xapi-test-course_20220301_05349e0d0a36b-3c84-4027-a220-88af9cec56f8/0/libraries/bowser.js:2:105708)
at Generator._invoke (https://cloud.scorm.com/sandbox/content/courses/45MN2ZJO0D/xapi-test-course_20220301_05349e0d0a36b-3c84-4027-a220-88af9cec56f8/0/libraries/bowser.js:2:105496)
at Generator.forEach.t.<computed> [as next] (https://cloud.scorm.com/sandbox/content/courses/45MN2ZJO0D/xapi-test-course_20220301_05349e0d0a36b-3c84-4027-a220-88af9cec56f8/0/libraries/bowser.js:2:106131)
at asyncGeneratorStep (https://cloud.scorm.com/sandbox/content/courses/45MN2ZJO0D/xapi-test-course_20220301_05349e0d0a36b-3c84-4027-a220-88af9cec56f8/0/adapt/js/adapt.min.js:51:26)
at _next (https://cloud.scorm.com/sandbox/content/courses/45MN2ZJO0D/xapi-test-course_20220301_05349e0d0a36b-3c84-4027-a220-88af9cec56f8/0/adapt/js/adapt.min.js:73:11)
at https://cloud.scorm.com/sandbox/content/courses/45MN2ZJO0D/xapi-test-course_20220301_05349e0d0a36b-3c84-4027-a220-88af9cec56f8/0/adapt/js/adapt.min.js:80:9
at new Promise (<anonymous>)
And I am not sure what causes this error.