diff --git a/CHANGELOG.md b/CHANGELOG.md index 77829189..90f3fd2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project tries to adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.2.0] - 2020-10-05 +### Added +- posthog event to distinguish between mobile/desktop device + ## [1.1.0] - 2020-09-02 ### Changed - legal and dgstvo links are not shown on summary page + ### Fixed - On some devices desktop parts were hidden diff --git a/e_metrobus/__init__.py b/e_metrobus/__init__.py index 73583f9c..64f9c53d 100644 --- a/e_metrobus/__init__.py +++ b/e_metrobus/__init__.py @@ -1,4 +1,4 @@ -__version__ = "1.1.0" +__version__ = "1.2.0" __version_info__ = tuple( [ int(num) if num.isdigit() else num diff --git a/e_metrobus/navigation/urls.py b/e_metrobus/navigation/urls.py index b18a9efd..10360ab9 100644 --- a/e_metrobus/navigation/urls.py +++ b/e_metrobus/navigation/urls.py @@ -35,6 +35,7 @@ path("get_desktop_page/", view=views.DesktopPage.as_view(), name="get_desktop_page"), path("accept_privacy_policy/", views.accept_privacy_policy), path("send_posthog_event/", views.send_posthog_event), + path("check_mobile/", views.check_mobile), path( "get_comparison_chart/", views.get_comparison_chart, name="get_comparison_chart" ), diff --git a/e_metrobus/navigation/views.py b/e_metrobus/navigation/views.py index 9d8854e5..271dcdd4 100644 --- a/e_metrobus/navigation/views.py +++ b/e_metrobus/navigation/views.py @@ -439,6 +439,8 @@ def get_context_data(self, **kwargs): context["visited"] = True if "privacy" in self.request.session: context["privacy_accepted"] = True + if "mobile" not in self.request.session: + context["initial_mobile_check"] = True return context @@ -465,6 +467,12 @@ def send_posthog_event(request): return HttpResponse() +def check_mobile(request): + request.session["mobile"] = request.GET["is_mobile"] + utils.posthog_event(request) + return HttpResponse() + + def get_comparison_chart(request): chart_order = ("pedestrian", "e-bus", "e-pkw", "bus", "car") route = request.GET["route"] diff --git a/e_metrobus/templates/base.html b/e_metrobus/templates/base.html index df5f1f06..0e794dab 100644 --- a/e_metrobus/templates/base.html +++ b/e_metrobus/templates/base.html @@ -142,6 +142,14 @@ $("#desktop").show(); $("#portrait").remove(); } + + {% if initial_mobile_check %} + $.ajax({ + url: "/check_mobile/", + dataType: "html", + data: {"is_mobile": check_mobile()} + }); + {% endif %} {% endblock javascript %} diff --git a/package.json b/package.json index 3edf0ce8..7191ffe2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "e_metrobus", - "version": "1.1.0", + "version": "1.2.0", "dependencies": {}, "devDependencies": { "autoprefixer": "^9.4.7",