Skip to content

Commit 5691c38

Browse files
authored
Make Ingest its own separate site in the docs and add more docs (#253)
With this, Ingest is no longer mixed up with the Dispatch docs, which was confusing. I've also added docs pages for Transformations (a user asked about this) and Source Errors. We now have a lot of extra space with the new structure, it needs a few more pages so it doesn't look empty. The Ingest docs are still a bit lame, but I think this is a step in the right direction. Closes [#11770](svix/monorepo-private#11770) (kinda)
1 parent bd1ab9a commit 5691c38

File tree

12 files changed

+81
-5
lines changed

12 files changed

+81
-5
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ Session.vim
2626
# yarn
2727
/.yarn/cache
2828
/.yarn/install-state.gz
29+
30+
.cursor
231 KB
Loading
290 KB
Loading
358 KB
Loading

docs/img/ingest/source-errors.png

159 KB
Loading

docs/ingest/source-errors.mdx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: Source Errors
3+
---
4+
5+
In the Source Errors tab, you can see the log of all the incoming webhooks that were rejected by the Source.
6+
The most likely reason for a source error is an invalid signature, or an invalid payload format in the incoming message.
7+
8+
Every time your Ingest URL returns a non-200 status code, the reason for the failure will be logged here, and the incoming message will not be delivered to your endpoints.
9+
10+
![Source Errors tab](../img/ingest/source-errors.png)
11+
12+
In the error details, you can inspect the message payload, the HTTP method and headers, and the reason for the failure.
13+
14+
![Source Error details](../img/ingest/source-errors-details.png)

docs/ingest/transformations.mdx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
title: Transformations
3+
---
4+
5+
Ingest Transformations are a powerful Svix feature that allows the modification of certain webhook properties in-flight.
6+
With transformations, you can write JavaScript code to change a webhook's HTTP method, target URL, and body payload before it's sent to your endpoint.
7+
8+
## Using Transformations
9+
10+
Ingest Transformations are available in all plans. To use them, after creating an endpoint in a Source, go to the 'Advanced' tab and scroll down to the 'Transformations' card:
11+
12+
![Ingest Transformations card](../img/ingest/ingest-transformation.png)
13+
14+
An endpoint's Transformation can be enabled or disabled at any time by toggling the switch on this card.
15+
16+
You can write Javascript code to edit an endpoint's Transformation, and test your code against a sample incoming payload to see the result.
17+
18+
![Editing an endpoint's Transformation](../img/ingest/edit-transformation.png)
19+
20+
### How to write a Transformation
21+
22+
Svix expects a Transformation to declare a function named `handler`. Svix will pass an object with the following properties to the function:
23+
24+
- `method`, a string representing the HTTP method the webhook will be sent with. It is always `"POST"` by default, and its only valid values are `"POST"` or `"PUT"`.
25+
- `url`, a string representing the destination endpoint's URL. It can be changed to any valid URL.
26+
- `payload`, which contains the webhook's payload as a JSON object. It can be changed as needed.
27+
28+
The Transformation must return the same object, but may modify its properties as described above.
29+
In addition to the ones listed above, it can also set the following properties on the returned object:
30+
31+
- `cancel`, a boolean which controls whether or not to cancel the dispatch of a webhook. This value defaults to `false`.
32+
- `headers`, an object with keys being HTTP header names and values being the associated header values. Headers set here take precedence over endpoint headers.
33+
34+
### An example Transformation
35+
36+
Suppose that sometimes, you want to redirect webhooks to a custom URL instead of the endpoint's defined URL. And you only want to do this redirect if a custom URL is present in the webhook payload. You can write a transformation like this:
37+
38+
```js
39+
function handler(webhook) {
40+
if (webhook.payload.customUrl) {
41+
webhook.url = webhook.payload.customUrl;
42+
}
43+
return webhook;
44+
}
45+
```
46+
47+
Great, the webhook is redirected to the custom URL if the `customUrl` property exists on the payload. Otherwise, it is sent to the endpoint's defined URL.

docs/receiving/verifying-payloads/receiving-with-bridge.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ See [Adding Endpoints](../using-app-portal/adding-endpoints.mdx) for more on how
5151

5252
## Using A Polling Endpoint
5353

54-
Bridge can consume messages sent to [Ingest](/receiving/receiving-with-ingest) or any Svix Application with a
54+
Bridge can consume messages sent to [Ingest](/ingest/receiving-with-ingest) or any Svix Application with a
5555
[Polling Endpoint](/advanced-endpoints/polling-endpoints) configured as a destination.
5656

5757
This is a great option if you don't want to run a public-internet-facing HTTP server to receive webhooks.

docusaurus.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ module.exports = {
9191
to: "/receiving/verifying-payloads/why",
9292
from: "/receiving/verifying-payloads",
9393
},
94+
{
95+
to: "/ingest/receiving-with-ingest",
96+
from: "/ingest",
97+
},
98+
{
99+
to: "/ingest/receiving-with-ingest",
100+
from: "/receiving/receiving-with-ingest",
101+
},
94102
{
95103
to: "/app-portal",
96104
from: "/management-ui",

0 commit comments

Comments
 (0)