Source code for django_rrweb.views

import json

from django.http import HttpResponse

from .models import Event


[docs]def record(request): """Record event""" obj = json.load(request) events = [ Event( user=None if request.user.is_anonymous else request.user, kind=event['type'], data=json.dumps(event['data']), timestamp=event['timestamp'], session_key=obj['sessionKey'], ) for event in obj['rrwebEvents'] ] Event.objects.bulk_create(events) return HttpResponse('OK', content_type='text/plain')