Skip to content

Commit 7acdd2a

Browse files
committed
Catch AttributeError from amplitude.page_view_event in middleware
1 parent 76a214b commit 7acdd2a

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

amplitude/middleware.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,12 @@ def __init__(self, get_response):
88
self.get_response = get_response
99

1010
def __call__(self, request):
11-
amplitude.page_view_event(request)
11+
try:
12+
"""
13+
Catches 'WSGIRequest' object has no attribute 'user' or 'session'
14+
if django.contrib.auth or django.contrib.sessions not in INSTALLED_APPS
15+
""" # NOQA: E501
16+
amplitude.page_view_event(request)
17+
except AttributeError:
18+
pass
1219
return self.get_response(request)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "django-amplitude"
33
packages = [
44
{include = "amplitude"}
55
]
6-
version = "0.2.0"
6+
version = "0.2.1"
77
description = "Integration between Django and Amplitude"
88
authors = ["Matt Pye <[email protected]>"]
99
readme = "README.md"

0 commit comments

Comments
 (0)