diff --git a/static/to_compile/entrypoints/assistant/script-to-iframe.ts b/static/to_compile/entrypoints/assistant/script-to-iframe.ts index 69585a86b..5c62c7418 100644 --- a/static/to_compile/entrypoints/assistant/script-to-iframe.ts +++ b/static/to_compile/entrypoints/assistant/script-to-iframe.ts @@ -3,7 +3,8 @@ import { iframeResize } from "iframe-resizer"; const script = document.currentScript as HTMLScriptElement const slug = script?.dataset?.objet; const origin = new URL(script?.getAttribute("src")).origin -const src = `${origin}/${slug || ''}?iframe`; +// TODO: mise en prod, remplacer dechet ci-dessous par une string vide +const src = `${origin}/${slug || 'dechet'}?iframe`; const iframe = document.createElement("iframe"); const iframeAttributes = { diff --git a/static/to_compile/js/controllers/assistant/analytics.ts b/static/to_compile/js/controllers/assistant/analytics.ts index fbebde9a5..09bc9d2c4 100644 --- a/static/to_compile/js/controllers/assistant/analytics.ts +++ b/static/to_compile/js/controllers/assistant/analytics.ts @@ -78,6 +78,11 @@ export default class extends Controller { } #checkIfWeAreInAnIframe() { + // The iframe URL parameter is not always set : + // - After a navigaation (click on a link) + // - If the iframe integration does not use our script + // In all these cases, we still want to determine + // whether the user browse inside an iframe or not. try { if (window.self !== window.top) { this.personProperties.iframe = true @@ -91,7 +96,7 @@ export default class extends Controller { this.personProperties.iframe = true } - if (document.referrer) { + if (document.referrer && !document.referrer.includes(document.location.origin)) { this.personProperties.iframe = true } }