Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webhook deliveries: show user's endpoint response #3918

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,22 @@ const ExpandedRow = (props: CellContext<DeliveryRow, unknown>) => {
</Button>
</div>
<hr />
<pre className="whitespace-pre-wrap">
{JSON.stringify(payload, undefined, 2)}
</pre>
<div>
<h3 className="font-bold">Request Payload</h3>
<pre className="whitespace-pre-wrap">
{JSON.stringify(payload, undefined, 2)}
</pre>
</div>
<hr />
{delivery.webhook_event.response && (
<div>
<h3 className="font-bold">Response</h3>
<pre className="whitespace-pre-wrap">
{delivery.webhook_event.response}
</pre>
</div>
)}
</div>
)
}

4 changes: 3 additions & 1 deletion server/polar/models/webhook_delivery.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from uuid import UUID

from sqlalchemy import Boolean, ForeignKey, Integer, Uuid
from sqlalchemy import Boolean, ForeignKey, Integer, String, Uuid
from sqlalchemy.orm import Mapped, declared_attr, mapped_column, relationship

from polar.kit.db.models.base import RecordModel
Expand Down Expand Up @@ -30,4 +30,6 @@ def webhook_event(cls) -> Mapped[WebhookEvent]:

http_code: Mapped[int | None] = mapped_column(Integer, nullable=True)

response: Mapped[str | None] = mapped_column(String, nullable=True)

succeeded: Mapped[bool] = mapped_column(Boolean, nullable=False)
2 changes: 2 additions & 0 deletions server/polar/models/webhook_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ def webhook_endpoint(cls) -> Mapped[WebhookEndpoint]:
succeeded: Mapped[bool | None] = mapped_column(Boolean, nullable=True)

payload: Mapped[str] = mapped_column(String, nullable=False)

response: Mapped[str] = mapped_column(String, nullable=False)
1 change: 1 addition & 0 deletions server/polar/webhook/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class WebhookEvent(TimestampedSchema):
),
)
payload: str = Field(description="The payload of the webhook event.")
response: str = Field(description="The response of the webhook event.")


class WebhookDelivery(TimestampedSchema):
Expand Down
1 change: 1 addition & 0 deletions server/polar/webhook/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ async def _webhook_event_send(
webhook_event_id=webhook_event_id,
webhook_endpoint_id=event.webhook_endpoint_id,
http_code=r.status_code,
response=r.text,
succeeded=succeeded,
)
session.add(delivery)
Expand Down