def serialize(self, obj, attrs, user):
    errors = []
    error_set = set()
    for error in obj.data.get('errors', []):
        message = EventError.get_message(error)
        if (message in error_set):
            continue
        error_set.add(message)
        error_result = {'type': error['type'], 'message': message, 'data': {k: v for (k, v) in error.iteritems() if (k != 'type')}}
        errors.append(error_result)
    tags = sorted([{'key': k.split('sentry:', 1)[(- 1)], 'value': v} for (k, v) in obj.get_tags()], key=(lambda x: x['key']))
    received = obj.data.get('received')
    if received:
        try:
            received = datetime.utcfromtimestamp(received).replace(tzinfo=timezone.utc)
        except TypeError:
            received = None
    event_type = obj.data.get('type', 'default')
    metadata = (obj.data.get('metadata') or {'title': obj.message_short})
    d = {'id': str(obj.id), 'groupID': obj.group.id, 'eventID': str(obj.event_id), 'size': obj.size, 'entries': attrs['entries'], 'message': obj.get_legacy_message(), 'user': attrs['user'], 'sdk': attrs['sdk'], 'device': attrs['device'], 'context': obj.data.get('extra', {}), 'packages': obj.data.get('modules', {}), 'type': event_type, 'metadata': metadata, 'tags': tags, 'platform': obj.platform, 'dateCreated': obj.datetime, 'dateReceived': received, 'errors': errors}
    return d
def serialize(self, obj, attrs, user):
    errors = []
    error_set = set()
    for error in obj.data.get('errors', []):
        message = EventError.get_message(error)
        if (message in error_set):
            continue
        error_set.add(message)
        error_result = {'type': error['type'], 'message': message, 'data': {k: v for (k, v) in error.iteritems() if (k != 'type')}}
        errors.append(error_result)
    tags = sorted([{'key': k.split('sentry:', 1)[(- 1)], 'value': v} for (k, v) in obj.get_tags()], key=(lambda x: x['key']))
    received = obj.data.get('received')
    if received:
        try:
            received = datetime.utcfromtimestamp(received).replace(tzinfo=timezone.utc)
        except TypeError:
            received = None
    event_type = obj.data.get('type', 'default')
    metadata = (obj.data.get('metadata') or {'title': obj.message_short})
    d = {'id': str(obj.id), 'groupID': obj.group.id, 'eventID': str(obj.event_id), 'size': obj.size, 'entries': attrs['entries'], 'message': obj.get_legacy_message(), 'user': attrs['user'], 'sdk': attrs['sdk'], 'device': attrs['device'], 'context': obj.data.get('extra', {}), 'packages': obj.data.get('modules', {}), 'type': event_type, 'metadata': metadata, 'tags': tags, 'platform': obj.platform, 'dateCreated': obj.datetime, 'dateReceived': received, 'errors': errors}
    return d