Skip to content

Commit

Permalink
Revert "chore(api): Unpublish ProjectUserReportsEndpoint (#75079)"
Browse files Browse the repository at this point in the history
This reverts commit be176fc.

Co-authored-by: aliu39 <159852527+aliu39@users.noreply.github.com>
  • Loading branch information
getsentry-bot and aliu39 committed Jul 31, 2024
1 parent 25aafd3 commit dce017f
Show file tree
Hide file tree
Showing 4 changed files with 217 additions and 2 deletions.
3 changes: 3 additions & 0 deletions api-docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@
"/api/0/projects/{organization_id_or_slug}/{project_id_or_slug}/stats/": {
"$ref": "paths/projects/stats.json"
},
"/api/0/projects/{organization_id_or_slug}/{project_id_or_slug}/user-feedback/": {
"$ref": "paths/projects/user-feedback.json"
},
"/api/0/projects/{organization_id_or_slug}/{project_id_or_slug}/hooks/": {
"$ref": "paths/projects/service-hooks.json"
},
Expand Down
175 changes: 175 additions & 0 deletions api-docs/paths/projects/user-feedback.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
{
"get": {
"tags": ["Projects"],
"description": "Return a list of user feedback items within this project.",
"operationId": "List a Project's User Feedback",
"parameters": [
{
"name": "organization_id_or_slug",
"in": "path",
"description": "The id or slug of the organization.",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "project_id_or_slug",
"in": "path",
"description": "The id or slug of the project.",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "../../components/schemas/user-feedback.json#/UserFeedback"
}
},
"example": [
{
"comments": "It broke!",
"dateCreated": "2018-11-06T21:20:11.468Z",
"email": "jane@example.com",
"event": {
"eventID": "14bad9a2e3774046977a21440ddb39b2",
"id": null
},
"eventID": "14bad9a2e3774046977a21440ddb39b2",
"id": "1",
"issue": null,
"name": "Jane Smith",
"user": null
}
]
}
}
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "Not Found"
}
},
"security": [
{
"auth_token": ["project:read"]
}
]
},
"post": {
"tags": ["Projects"],
"description": "Submit and associate user feedback with an issue.\n\nFeedback must be received by the server no more than 30 minutes after the event was saved.\n\nAdditionally, within 5 minutes of submitting feedback it may also be overwritten. This is useful in situations where you may need to retry sending a request due to network failures.\n\nIf feedback is rejected due to a mutability threshold, a 409 status code will be returned.\n\nNote: Feedback may be submitted with DSN authentication (see auth documentation).",
"operationId": "Submit User Feedback",
"parameters": [
{
"name": "organization_id_or_slug",
"in": "path",
"description": "The id or slug of the organization.",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "project_id_or_slug",
"in": "path",
"description": "The id or slug of the project.",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"required": ["event_id", "name", "email", "comments"],
"type": "object",
"properties": {
"event_id": {
"type": "string",
"description": "The event ID. This can be retrieved from the [beforeSend callback](https://docs.sentry.io/platforms/javascript/configuration/filtering/#using-beforesend)."
},
"name": {
"type": "string",
"description": "User's name."
},
"email": {
"type": "string",
"description": "User's email address."
},
"comments": {
"type": "string",
"description": "Comments supplied by user."
}
}
},
"example": {
"event_id": "14bad9a2e3774046977a21440ddb39b2",
"name": "Jane Schmidt",
"email": "jane@empowerplant.io",
"comments": "It broke!"
}
}
},
"required": false
},
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"$ref": "../../components/schemas/user-feedback.json#/UserFeedback"
},
"example": {
"comments": "It broke!",
"dateCreated": "2018-11-06T21:20:11.468Z",
"email": "jane@example.com",
"event": {
"eventID": "14bad9a2e3774046977a21440ddb39b2",
"id": null
},
"eventID": "14bad9a2e3774046977a21440ddb39b2",
"id": "1",
"issue": null,
"name": "Jane Smith",
"user": null
}
}
}
},
"400": {
"description": "Bad Input"
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "The requested resource does not exist"
},
"409": {
"description": "Conflict"
}
},
"security": [
{
"auth_token": ["project:write"]
},
{
"dsn": []
}
]
}
}
4 changes: 2 additions & 2 deletions src/sentry/api/endpoints/project_user_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class _PaginateKwargs(TypedDict):
class ProjectUserReportsEndpoint(ProjectEndpoint, EnvironmentMixin):
owner = ApiOwner.FEEDBACK
publish_status = {
"GET": ApiPublishStatus.PRIVATE,
"POST": ApiPublishStatus.PRIVATE,
"GET": ApiPublishStatus.PRIVATE, # TODO: deprecate
"POST": ApiPublishStatus.PRIVATE, # TODO: deprecate
}
authentication_classes = ProjectEndpoint.authentication_classes + (DSNAuthentication,)

Expand Down
37 changes: 37 additions & 0 deletions tests/apidocs/endpoints/projects/test_user_feedback.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from django.test.client import RequestFactory
from django.utils import timezone

from fixtures.apidocs_test_case import APIDocsTestCase


class ProjectUserFeedbackDocs(APIDocsTestCase):
def setUp(self):
event = self.create_event("a", message="oh no")
self.event_id = event.event_id
self.create_userreport(
date_added=timezone.now(),
project=self.project,
event_id=self.event_id,
)

self.url = f"/api/0/projects/{self.organization.slug}/{self.project.slug}/user-feedback/"

self.login_as(user=self.user)

def test_get(self):
response = self.client.get(self.url)
request = RequestFactory().get(self.url)

self.validate_schema(request, response)

def test_post(self):
data = {
"event_id": self.event_id,
"name": "Hellboy",
"email": "hellboy@sentry.io",
"comments": "It broke!",
}
response = self.client.post(self.url, data)
request = RequestFactory().post(self.url, data)

self.validate_schema(request, response)

0 comments on commit dce017f

Please sign in to comment.