Skip to content

Commit

Permalink
feat(events-v2) Add raw JSON event URL (#13520)
Browse files Browse the repository at this point in the history
I also fixed the doubly encoded JSON response in the endpoint.

Refs SEN-708
  • Loading branch information
markstory authored Jun 5, 2019
1 parent 0ff26a3 commit fd4cd62
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
4 changes: 1 addition & 3 deletions src/sentry/api/endpoints/project_event_details.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import absolute_import

import json

from datetime import datetime
from rest_framework.response import Response

Expand Down Expand Up @@ -96,4 +94,4 @@ def get(self, request, project, event_id):
if isinstance(event_dict['datetime'], datetime):
event_dict['datetime'] = event_dict['datetime'].isoformat()

return Response(json.dumps(event_dict), status=200)
return Response(event_dict, status=200)
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class EventDetails extends AsyncComponent {
handleTabChange = tab => this.setState({activeTab: tab});

renderBody() {
const {orgId} = this.props.params;
const [projectId, _] = this.props.eventSlug.split(':');
return (
<ModalContainer>
Expand All @@ -45,6 +46,7 @@ class EventDetails extends AsyncComponent {
event={this.state.event}
activeTab={this.state.activeTab}
projectId={projectId}
orgId={orgId}
/>
</ModalContainer>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ ActiveTab.propTypes = {
* Controlled by the EventDetails View.
*/
const EventModalContent = props => {
const {event, activeTab, projectId, onTabChange} = props;
const {event, activeTab, projectId, orgId, onTabChange} = props;
const eventJsonUrl = `/api/0/projects/${orgId}/${projectId}/events/${
event.eventID
}/json/`;

return (
<ColumnGrid>
Expand Down Expand Up @@ -129,7 +132,7 @@ const EventModalContent = props => {
</ContentColumn>
<SidebarColumn>
{event.groupID && <LinkedIssuePreview groupId={event.groupID} />}
<EventMetadata event={event} />
<EventMetadata event={event} eventJsonUrl={eventJsonUrl} />
<SidebarBlock>
<TagsTable tags={event.tags} />
</SidebarBlock>
Expand All @@ -140,6 +143,7 @@ const EventModalContent = props => {
EventModalContent.propTypes = {
...ActiveTab.propTypes,
onTabChange: PropTypes.func.isRequired,
orgId: PropTypes.string.isRequired,
};

/**
Expand All @@ -162,8 +166,7 @@ EventHeader.propTypes = {
* Render metadata about the event and provide a link to the JSON blob
*/
const EventMetadata = props => {
const jsonUrl = 'TODO build this';
const {event} = props;
const {event, eventJsonUrl} = props;

return (
<SidebarBlock withSeparator>
Expand All @@ -172,7 +175,7 @@ const EventMetadata = props => {
<DateTime
date={getDynamicText({value: event.dateCreated, fixed: 'Dummy timestamp'})}
/>
<ExternalLink href={jsonUrl} className="json-link">
<ExternalLink href={eventJsonUrl} className="json-link">
JSON (<FileSize bytes={event.size} />)
</ExternalLink>
</MetadataContainer>
Expand All @@ -181,6 +184,7 @@ const EventMetadata = props => {
};
EventMetadata.propTypes = {
event: SentryTypes.Event.isRequired,
eventJsonUrl: PropTypes.string.isRequired,
};

const MetadataContainer = styled('div')`
Expand Down
2 changes: 0 additions & 2 deletions tests/snuba/api/endpoints/test_project_event_details.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import absolute_import

import json
import six

from datetime import timedelta
Expand Down Expand Up @@ -156,7 +155,6 @@ def setUp(self):
)

def assert_event(self, data):
data = json.loads(data.decode('utf-8'))
assert data['event_id'] == self.event_id
assert data['user']['email'] == self.user.email
assert data['datetime'][:19] == self.min_ago
Expand Down

0 comments on commit fd4cd62

Please sign in to comment.