Created
March 8, 2020 17:08
-
-
Save pierreabreup/5a0bb1ef7b0e82765d4144918c8cd6e1 to your computer and use it in GitHub Desktop.
Tracking xAPI statemente event on H5P
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import PropTypes from 'prop-types' | |
const H5pContent = ({ iframeSrc }) => { | |
const handleContentRef = dom => { | |
if (dom) { | |
dom.onload = () => { | |
dom.contentWindow.H5P.externalDispatcher.on('xAPI', function(event) { | |
console.log('INITIAL STATEMENT ON externalDispatcher') | |
console.log(event.data.statement) | |
}) | |
} | |
} | |
} | |
return ( | |
<iframe | |
title='h5p-embed' | |
ref={handleContentRef} | |
src={iframeSrc} | |
frameBorder='0' | |
allowFullScreen='allowfullscreen' | |
/> | |
) | |
} | |
H5pContent.propTypes = { | |
iframeSrc: PropTypes.string.isRequired, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment