Skip to content

Commit fa11ea7

Browse files
committed
edits to destination functions
1 parent b4d12e7 commit fa11ea7

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/connections/functions/destination-functions.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ All functions are scoped to your workspace, so members of other workspaces can't
2828
After you click **Next: Build Function**, a code editor appears. Use the editor to write the code for your function, configure settings, and test the function's behavior.
2929

3030
> success ""
31-
> **Tip:** Want to see some example functions? Check out the templates available in the Functions UI, or in the open-source [Segment Functions Library](https://github.com/segmentio/functions-library){:target="_blank"}.
31+
> Want to see some example functions? Check out the templates available in the Functions UI, or in the open-source [Segment Functions Library](https://github.com/segmentio/functions-library){:target="_blank"}.
3232
3333

3434
## Code the destination function
@@ -53,10 +53,10 @@ Destination functions can define handlers for each message type in the [Segment
5353

5454
Each of the functions above accepts two arguments:
5555

56-
- **event** - Segment event object, where fields and values depend on the event type. For example, in "Identify" events, Segment formats the object to match the [Identify spec](/docs/connections/spec/identify/).
57-
- **settings** - Set of [settings](#create-settings-and-secrets) for this function.
56+
- **event**: Segment event object, where fields and values depend on the event type. For example, in Identify events, Segment formats the object to match the [Identify spec](/docs/connections/spec/identify/).
57+
- **settings**: Set of [settings](#create-settings-and-secrets) for this function.
5858

59-
The example below shows a destination function that listens for "Track" events, and sends some details about them to an external service.
59+
The example below shows a destination function that listens for Track events, and sends some details about them to an external service.
6060

6161
```js
6262
async function onTrack(event) {
@@ -74,7 +74,7 @@ async function onTrack(event) {
7474
}
7575
```
7676

77-
To change which event type the handler listens to, you can rename it to the name of the message type. For example, if you rename this function `onIdentify`, it listens for "Identify" events instead.
77+
To change which event type the handler listens to, you can rename it to the name of the message type. For example, if you rename this function `onIdentify`, it listens for Identify events instead.
7878

7979
> info ""
8080
> Functions' runtime includes a `fetch()` polyfill using a `node-fetch` package. Check out the [node-fetch documentation](https://www.npmjs.com/package/node-fetch){:target="_blank"} for usage examples.
@@ -89,9 +89,9 @@ The handler for destination functions is event-specific. For example, you might
8989

9090
{% include content/functions/errors-and-error-handling.md %}
9191

92-
You can incorporate a a `try-catch` block to ensure smooth operation of functions even when fetch calls fail. This allows for the interception of any errors during the API call, enabling the application of specific error handling procedures, such as error logging for future debugging, or the assignment of fallback values when the API call is unsuccessful. By positioning the continuation logic either outside the `try-catch` block or within a `finally` block, the function is guaranteed to proceed with its execution, maintaining its workflow irrespective of the outcome of the API call.
92+
You can incorporate a `try-catch` block to ensure smooth operation of functions even when fetch calls fail. This allows for the interception of any errors during the API call, enabling the application of specific error handling procedures, such as error logging for future debugging, or the assignment of fallback values when the API call is unsuccessful. By positioning the continuation logic either outside the `try-catch` block or within a `finally` block, the function is guaranteed to proceed with its execution, maintaining its workflow irrespective of the outcome of the API call.
9393

94-
You can read more about [error handling](#destination-functions-logs-and-errors) below.
94+
See [error handling](#destination-functions-logs-and-errors) for additional details.
9595

9696
### Runtime and dependencies
9797

@@ -140,8 +140,8 @@ You can also manually include your own JSON payload of a Segment event, instead
140140

141141
If your function fails, you can check the error details and logs in the **Output** section.
142142

143-
- **Error Message** - This shows the error surfaced from your function.
144-
- **Logs** - This section displays any messages to `console.log()` from the function.
143+
- **Error Message**: The error surfaced from your function.
144+
- **Logs**: Messages to `console.log()` from the function.
145145

146146
## Batching the destination function
147147

@@ -152,7 +152,7 @@ Batch handlers are an extension of destination functions. When you define an `on
152152
153153
### When to use batching
154154

155-
Consider creating a batch handler if:
155+
Create a batch handler when:
156156

157157
- **Your function sends data to a service that has a batch endpoint.** Batch endpoints may allow you both to send more data downstream and stay within the rate limits imposed by the service. Batch handlers that use one or more batch endpoints improve the efficiency of the function, and enable it to scale more easily. Specifically, you can use batch handlers to build [list-based](/docs/engage/using-engage-data/#personas-destination-types-event-vs-list) Engage destinations.
158158
- **You have a high-throughput function and want to reduce cost.** When you define a batch handler, Segment invokes the function once per *batch*, rather than once per event. As long as the function's execution time isn't adversely affected, the reduction in invocations should lead to a reduction in cost.
@@ -165,7 +165,7 @@ Consider creating a batch handler if:
165165
Segment collects the events over a short period of time and combines them into a batch. The system flushes them when the batch reaches a certain number of events, or when the batch has been waiting for a specified wait time.
166166

167167
To create a batch handler, define an `onBatch` function within your destination function.
168-
You can also use the "Default Batch" template found in the Functions editor to get started quickly.
168+
You can also use the "Default Batch" template found in the functions editor to get started quickly.
169169

170170
```js
171171
async function onBatch(events, settings){
@@ -316,7 +316,7 @@ Standard [function error types](/docs/connections/functions/destination-function
316316

317317
For example, after receiving the responses above from the `onBatch` handler, Segment only retries **event_4** and **event_5**.
318318

319-
| Error Type | Result |
319+
| Error type | Result |
320320
| ---------------------- | ------- |
321321
| Bad Request | Discard |
322322
| Invalid Settings | Discard |
@@ -334,14 +334,14 @@ Once you do that, the destination function appears on the **Functions** page in
334334

335335
If you're editing an existing function, you can **Save** changes without updating instances of the function that are already deployed and running.
336336

337-
You can also choose to **Save & Deploy** to save the changes, and then choose which of the already-deployed functions to update with your changes. [You might need additional permissions](#functions-permissions) to update existing functions.
337+
You can click **Save & Deploy** to save the changes, and then choose which of the already-deployed functions to update with your changes. [You might need additional permissions](#functions-permissions) to update existing functions.
338338

339339
## Destination functions logs and errors
340340

341341
{% include content/functions/logs.md %}
342342

343343
> warning ""
344-
> **Warning:** Do not log sensitive data, such as personally-identifying information (PII), authentication tokens, or other secrets. Avoid logging entire request/response payloads. The **Function Logs** tab may be visible to other workspace members if they have the necessary permissions.
344+
> Do not log sensitive data, such as personally-identifying information (PII), authentication tokens, or other secrets. Avoid logging entire request/response payloads. The **Function Logs** tab may be visible to other workspace members if they have the necessary permissions.
345345
346346
## Caching in destination functions
347347

@@ -381,7 +381,7 @@ If you are a **Workspace Owner** or **Functions Admin**, you can manage your fun
381381

382382
### Monitoring destination functions
383383

384-
You can use [Destination Event Delivery](/docs/connections/event-delivery/) to understand if Segment encounters any issues delivering your source data to destinations. Errors that the Function throws appear here.
384+
Use [Destination Event Delivery](/docs/connections/event-delivery/) to understand if Segment encounters any issues delivering your source data to destinations. Errors that the Function throws appear here.
385385

386386
If any of your deployed function instances are failing consistently, they will also appear in [Connection Health](/docs/segment-app/#health).
387387

@@ -444,10 +444,10 @@ If you're sending your batch to an external service, the execution time of the f
444444
##### Can I use a Destination Function to send data to another Segment source?
445445
Yes, to do so, remove the `messageId` and the `writeKey` from the payload in your Function code. Leaving either field on your payload will cause unexpected behavior that may cause your event to be delivered to the wrong source or to not be delivered at all.
446446

447-
##### Can I view console.log() outputs in Destination Functions?
447+
##### Can I view console.log() outputs in destination functions?
448448

449-
Incorporating console.log() statements in your Destination Function code aids in debugging. However, logs generated by these statements will only be accessible in the [Event Delivery](/docs/connections/event-delivery/) view if the payloads encounter errors during processing. Logs from successfully processed payloads are not displayed.
449+
Incorporating console.log() statements in your destination function code aids in debugging. However, logs generated by these statements will only be accessible in the [Event Delivery](/docs/connections/event-delivery/) view if the payloads encounter errors during processing. Logs from successfully processed payloads are not displayed.
450450

451451
##### What is the maximum data size that can be displayed in console.logs() when testing a Function?
452452

453-
The test function interface has a 4KB console logging limit. Outputs larger than this limit are not visible in the user interface.
453+
The test function interface has a 4 KB console logging limit. Outputs larger than this limit are not visible in the user interface.

0 commit comments

Comments
 (0)