New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for monetization in iframes #100
Conversation
TODO: rename |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just some nits and wording/doc suggestions
@sharon-wang addressed your comments and tested. Let me know if you have any other comments, otherwise the PR is in good shape. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested these changes with https://defold.itch.io/climberz and it's working for me on Brave.
just noticed this one thing, probably leftover typo from before. But lgtm and ready to merge!
💯 |
Closes #82
Design Notes
The design for iframe web monetization tracking was outlined in #82, as discussed with @sharon-wang (and ❤️'d by @thejustinwalsh). Iframe web monetization tracking in Akita works as follow:
A new field called iframeSrcOrigin will be added to AkitaPaymentPointerData to keep track of the origin of payment pointers inside of iframes.(actually not necessary right now, I will discuss with @sharon-wang if this should be added)For example, https://defold.itch.io/climberz only contains monetization within an iframe (the iframe contains a web game). This is how it appears in Akita:
Note that the iframe's origin is https://v6p9d9t4.ssl.hwcdn.net/html/2866116/Climberz/index.html, but that origin is not tracked nor is it shown in the UI.
Implementation Notes
src/content_main.js
has been split into three content scripts and moved to a new foldersrc/content_scripts/
webBrowser.runtime
message channel. Each content_iframe.js in each iframe is assigned a uuid from content_origin.js via postMessage so that content_origin.js can know which iframe the script is associated with when the script sends messages.manifest.json
includes these content scripts in a specific order:content_shared.js
must be included before bothcontent_main.js
andcontent_iframe.js
because it initializes constants and starts tracking monetization events, andcontent_main.js
must be included beforecontent_iframe.js
because it sets a flagwindow.isTopLevel
which letscontent_iframe.js
not run the code it contains if it is in the top level page.Note that
webBrowser.runtime.sendMessage
is used bycontent_iframe.js
to send payment pointers when they change to the top level page instead ofpostMessage
because the messages it sends cannot be accessed by the page, so it should be a little safer.postMessage
must be used for sending uuids to iframes because the uuids must be sent directly to the iframe element so content_main.js knows which iframe it assigned the uuid.Testing Notes