Console from Iframe is not reliable on some messages | XM Community
Skip to main content

Hello all,

I have a game that is embedded within an iframe for my qualtrics survey. The game sends messages through the iframe using this type script function.

postEvent(type: string, data: any = {}): void {    console.log('post event: ' + type, data);    window.parent.postMessage({        type: type,        ...data    }, '*');}

The problem is this function only works for some messages reliably but not others. For instance I have a message that sends for every time a player throws a ball in my game, but when there is a unusual event such as letting a player leave after a set time, this message proves to be unreliable. It will sometimes work, and sometimes not work. It is sometimes accurate and sometimes way off on the set number of time.

 

The messages work flawlessly when i use the game not embedded into an iframe, as in, the messages will always appear on time and accurately. 

 

There are even some other bugs that are only introduced when the game is inside qualtrics.

 

these messages are essential to my survey as they are read using javascript in qualtrics to make the next question button appear. 

 

So all in all, the problem is that I have messages that are posted from my game using the code above but there are some messages that will appear inconsistently both in the console log and the functionality of the next button appearing. There are some messages that always appear with 100% consistency, but there are others that are very unpredictable in their behavior.

 

Does anyone have any ideas on how to fix this, or a better way to embed a game that is a webapp into qualtrics?

Be the first to reply!

Leave a Reply