@@ -78,7 +78,10 @@ export default class RunestoneBase {
7878 headers : headers ,
7979 body : JSON . stringify ( eventInfo ) ,
8080 } ) ;
81- post_return = fetch ( request ) ;
81+ post_return = await fetch ( request ) ;
82+ if ( ! post_return . ok ) {
83+ throw new Error ( "Failed to save the log entry" ) ;
84+ }
8285 }
8386 console . log ( "logging event " + JSON . stringify ( eventInfo ) ) ;
8487 if (
@@ -98,35 +101,24 @@ export default class RunestoneBase {
98101 eventInfo . course = eBookConfig . course ;
99102 eventInfo . clientLoginStatus = eBookConfig . isLoggedIn ;
100103 eventInfo . timezoneoffset = new Date ( ) . getTimezoneOffset ( ) / 60 ;
101- if ( this . forceSave || ! "to_save" in eventInfo ) {
104+ if ( this . forceSave || "to_save" in eventInfo === false ) {
102105 eventInfo . save_code = "True" ;
103106 }
104107 if ( eBookConfig . useRunestoneServices && eBookConfig . logLevel > 0 ) {
105- post_promise = jQuery
106- . post ( eBookConfig . ajaxURL + "runlog.json" , eventInfo ) // Log the run event
107- . done (
108- function ( data , status , whatever ) {
109- // data = JSON.parse(data);
110- if ( data . message ) {
111- alert ( data . message ) ;
112- if ( data . log == false ) {
113- location . href =
114- eBookConfig . app +
115- "/default/user/login?_next=" +
116- location . pathname ;
117- }
118- }
119- this . forceSave = false ;
120- } . bind ( this )
121- )
122- . fail (
123- function ( ) {
124- alert (
125- "WARNING: Your code was not saved! Please Try again."
126- ) ;
127- this . forceSave = true ;
128- } . bind ( this )
129- ) ;
108+ let headers = new Headers ( {
109+ "Content-type" : "application/json; charset=utf-8" ,
110+ Accept : "application/json" ,
111+ } ) ;
112+ let request = new Request ( eBookConfig . ajaxURL + "runlog.json" , {
113+ method : "POST" ,
114+ headers : headers ,
115+ body : JSON . stringify ( eventInfo ) ,
116+ } ) ;
117+ post_promise = await fetch ( request ) ;
118+ post_promise = await fetch ( request ) ;
119+ if ( ! post_promise . ok ) {
120+ throw new Error ( "Failed to log the run" ) ;
121+ }
130122 }
131123 console . log ( "running " + JSON . stringify ( eventInfo ) ) ;
132124 if (
0 commit comments