@require_POST
@expect_json
@csrf_exempt
def segmentio_event(request):
 expected_secret = getattr(settings, 'TRACKING_SEGMENTIO_WEBHOOK_SECRET', None)
 provided_secret = request.GET.get('key')
 if ((not expected_secret) or (provided_secret != expected_secret)):
  return HttpResponse(status=401)
 try:
  track_segmentio_event(request)
 except EventValidationError as err:
  log.debug('Unable to process event received from Segment: message="%s" event="%s"', str(err), request.body)
 return HttpResponse(status=200)

@ require_POST @ expect_json @ csrf_exempt def segmentio_event ( request ) : expected_secret = getattr ( settings , 'TRACKING_SEGMENTIO_WEBHOOK_SECRET' , None ) provided_secret = request . GET . get ( 'key' ) if ( ( not expected_secret ) or ( provided_secret != expected_secret ) ) : return HttpResponse ( status = 401 ) try : track_segmentio_event ( request ) except EventValidationError as err : log . debug ( 'Unable to process event received from Segment: message="%s" event="%s"' , str ( err ) , request . body ) return HttpResponse ( status = 200 )
an endpoint for logging events using segments webhook integration .