Cloudflare app installing preview script on all pages

Hello Devs,

I have a cloudflare app name poptin. It has a functionality to install a JS script which triggers modal for the users. In order for user to have a demo, there is a special preview script that gets triggered only while user is testing it before installing on the site. It seems to be working fine when i test it using developer account but the actual users are having trouble after installing it:

  • The preview script which is supposed to be available on cloudlfare domain only gets installed
  • The actual script doesnt installed. Here is the piece of code for your reference:

// Trigger preview of default poptins when user previews the app
// from cloudflare app marketplace.
const domain = window.location.path
if (domain.includes(cloudflare.com/developer)) {
installPreviewPoptin()
}

// This code ensures that the app doesn’t run before the page is loaded.
if (document.readyState === “loading”) {
document.addEventListener(“DOMContentLoaded”, updateElement)
} else {
removeEmbedPoptin() // Remove any existing embed Poptin JS script, if exist
updateElement()
}