Skip to content
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

Conserver le mode iframe durant la navigation #1215

Merged
merged 8 commits into from
Jan 21, 2025
Merged
2 changes: 1 addition & 1 deletion core/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def content(request):
def assistant(request) -> dict:
return {
"assistant": {
"is_iframe": "iframe" in request.GET,
"is_home": request.path == reverse("qfdmd:home"),
"is_iframe": request.session.get("iframe"),
fabienheureux marked this conversation as resolved.
Show resolved Hide resolved
"POSTHOG_KEY": settings.ASSISTANT["POSTHOG_KEY"],
"MATOMO_ID": settings.ASSISTANT["MATOMO_ID"],
},
Expand Down
9 changes: 9 additions & 0 deletions qfdmd/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
)
return context

def setup(self, request, *args, **kwargs):
if "iframe" not in request.session:
request.session["iframe"] = "iframe" in request.GET
if not request.user.is_authenticated:
request.session.set_expiry(
0
) # set to 0 expires when the users closes its browser
super().setup(request, *args, **kwargs)


class HomeView(BaseView, ListView):
template_name = "qfdmd/home.html"
Expand Down
5 changes: 5 additions & 0 deletions static/to_compile/js/controllers/assistant/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ export default class extends Controller<HTMLElement> {
conversionScore,
},
})

const posthogBannerConversionScore = document.querySelector("#posthog-banner-conversion-score")
if (posthogBannerConversionScore) {
posthogBannerConversionScore.textContent = conversionScore.toString()
}
}, 1000)
}

Expand Down
2 changes: 1 addition & 1 deletion templates/components/header/header.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load static %}
{% load static url_extra %}
<header class="qf-flex qf-flex-col fr-container qf-relative">
<div class="qf-flex qf-justify-between qf-pt-3w">
<a
Expand Down
10 changes: 10 additions & 0 deletions templates/qfdmd/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,15 @@
{% endif %}
data-analytics-action-value="{% block analytics_action %}{% endblock %}"
></script>
{% if assistant.is_iframe and request.user.is_authenticated %}
<div class="qf-bg-warning-425-625-hover qf-text-white qf-text-center qf-w-screen qf-py-1v qf-text-xs">
Le mode iframe de l'assistant est actif
</div>
{% endif %}
{% if "posthog" in request.GET %}
<div class="qf-bg-green-bourgeon-main-640 qf-text-white qf-text-center qf-w-screen qf-py-1v qf-text-xs">
Identifiant PostHog : {{ assistant.POSTHOG_KEY }} | Score de conversion : <span id="posthog-banner-conversion-score"></span>
</div>
{% endif %}
kolok marked this conversation as resolved.
Show resolved Hide resolved
</body>
</html>
Loading