code: def _create_event(instance, action):
      
      user = None
      user_repr = repr(user)
      if CUSER:
          user = CuserMiddleware.get_user()
          user_repr = repr(user)
          if user is not None and user.is_anonymous:
              user = None
      return TrackingEvent.objects.create(
          action=action,
          object=instance,
          object_repr=repr(instance),
          user=user,
          user_repr=user_repr,
      )
docs: Create a new event, getting the use if django-cuser is available.