Skip to content

Commit 2aba723

Browse files
author
markzegarelli
authored
Merge pull request #1646 from segmentio/misteryeo-patch-1
Update batch parameter outreach
2 parents 8c931cf + f88e87d commit 2aba723

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

src/connections/functions/destination-functions.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ integration_type: feature
88
---
99
Destination functions allow you to transform and annotate your Segment events and send them to any external tool or API without worrying about setting up or maintaining any infrastructure.
1010

11-
All functions are scoped to your workspace, so members of other workspaces won't be able to view or use them.
11+
All functions are scoped to your workspace, so members of other workspaces can't view or use them.
1212

1313
> info ""
1414
> Functions is available to all customer plan types with a free allotment of usage hours. Read more about [Functions usage limits](/docs/connections/functions/usage/), or see [your workspace’s Functions usage stats](https://app.segment.com/goto-my-workspace/settings/usage?metric=functions).
@@ -17,7 +17,7 @@ All functions are scoped to your workspace, so members of other workspaces won't
1717

1818

1919
> note ""
20-
> Destination functions can't currently accept data from [Object Cloud sources](/docs/connections/sources/#object-cloud-sources).
20+
> Destination functions does not accept data from [Object Cloud sources](/docs/connections/sources/#object-cloud-sources).
2121
2222
## Create a destination function
2323

@@ -37,9 +37,9 @@ When you click **Build**, a code editor appears. Use the editor to write the cod
3737
Segment invokes a separate part of the function (called a "handler") for each event type that you send to your destination function.
3838

3939
> info ""
40-
> Your function is not invoked for an event if a [destination filter](/docs/connections/destinations/destination-filters/) is set up, and the event doesn't pass the filter.
40+
> Your function is not invoked for an event if you've configured a [destination filter](/docs/connections/destinations/destination-filters/), and the event doesn't pass the filter.
4141
42-
The default source code template includes handlers for all event types. However, you do not need to implement all of them - just use the ones you need, and skip the ones you don't.
42+
The default source code template includes handlers for all event types. You do not need to implement all of them - just use the ones you need, and skip the ones you don't.
4343

4444
Destination functions can define handlers for each message type in the [Segment spec](/docs/connections/spec/):
4545

@@ -54,11 +54,9 @@ Destination functions can define handlers for each message type in the [Segment
5454

5555
Each of the functions above accepts two arguments:
5656

57-
- **event** - Segment event object, where fields and values depend on the type of event. For example, for "Identify" events, the object is formatted to match the [Identify spec](/docs/connections/spec/identify/).
57+
- **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/).
5858
- **settings** - Set of [settings](#create-settings-and-secrets) for this function.
5959

60-
We'll learn more about settings later, let's see how we can process Segment events with destination function first.
61-
6260
The example below shows a destination function that listens for "Track" events, and sends some details about them to an external service.
6361

6462
```js
@@ -77,16 +75,16 @@ async function onTrack(event) {
7775
}
7876
```
7977

80-
To change which type of event 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.
78+
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.
8179

8280
> info ""
8381
> Functions' runtime includes a `fetch()` polyfill using a `node-fetch` package. Check out the [node-fetch documentation](https://www.npmjs.com/package/node-fetch) for usage examples.
8482
8583
### Errors and error handling
8684

87-
A function's execution is considered successful if it finishes without any errors. You can also `throw` an error to indicate a failure on purpose. You can use these errors to validate event data before processing it, to ensure your function works as expected.
85+
Segment considers a function's execution successful if it finishes without error. You can also `throw` an error to create a failure on purpose. Use these errors to validate event data before processing it, to ensure the function works as expected.
8886

89-
You can `throw` the following pre-defined error types to indicate that the function ran as expected, but that data could not be delivered:
87+
You can `throw` the following pre-defined error types to indicate that the function ran as expected, but that data was deliverable:
9088

9189
- `EventNotSupported`
9290
- `InvalidEventPayload`
@@ -192,9 +190,9 @@ If your function fails, you can check the error details and logs in the **Output
192190
## Batching the destination function (Beta)
193191

194192
> warning ""
195-
> Batch handling for Functions is currently available as an early access beta release. By enabling batch handlers for your function, you acknowledge that your use of batch handlers is subject to [Segment’s Beta Terms and Conditions](https://segment.com/legal/first-access-beta-preview), or the applicable terms governing Beta Releases found in your subscription agreement with Segment.
193+
> Batch handling for Functions is available as an early access beta release. By enabling batch handlers for your function, you acknowledge that your use of batch handlers is subject to [Segment’s Beta Terms and Conditions](https://segment.com/legal/first-access-beta-preview), or the applicable terms governing Beta Releases found in your subscription agreement with Segment.
196194
>
197-
> If you notice any bugs or have any general feedback on this new feature, contact [[email protected]](mailto:beta@segment.com).
195+
> If you notice any bugs or have any general feedback on this new feature, please fill out [this form](https://airtable.com/shr9TU4huO0PK0DSU).
198196
199197
Batch handlers are an extension of destination functions. When you define an `onBatch` handler alongside the handler functions for single events (for example: `onTrack` or `onIdentity`), you're telling Segment that the destination function can accept and handle batches of events.
200198

@@ -285,7 +283,7 @@ async function onIdentifyBatch(events, settings) {
285283

286284
### Configure your batch parameters
287285

288-
You cannot yet configure batch parameters (either in the code or UI) in this version of the beta. If you would like to change your batch parameters, contact [[email protected]](mailto:beta@segment.com) with information about your specific use case, the reason you need to adjust parameters, and the URL to your destination function.
286+
You cannot configure batch parameters (either in the code or UI) in this version of the beta. Functions waits up to 10 seconds to form a batch of 20 events. If you would like to change your batch parameters, please fill out [this form](https://airtable.com/shr9TU4huO0PK0DSU) and Support will contact you once this is made available.
289287

290288
### Avoid writing batch and single event handlers
291289

@@ -384,11 +382,11 @@ async function onTrack(event, settings) {
384382
```
385383

386384
> warning ""
387-
> **Warning:** Do not log sensitive data, such as personally-identifying information (PII), authentication tokens, or other secrets. You should especially avoid logging entire request/response payloads. The **Function Logs** tab may be visible to other workspace members if they have the necessary permissions.
385+
> **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.
388386
389387
## Caching in destination functions
390388

391-
Functions execute only in response to incoming data, but the environments that functions run in are generally long-running. Because of this, you can use global variables to cache small amounts of information between invocations. For example, you can reduce the number of access tokens you generate by caching a token, and regenerating it only after it expires. Segment cannot make any guarantees about the longevity of environments, but by using this strategy, you can significantly improve the performance and reliability of your Functions by reducing the need for redundant API requests.
389+
Functions execute only in response to incoming data, but the environments that functions run in are generally long-running. Because of this, you can use global variables to cache small amounts of information between invocations. For example, you can reduce the number of access tokens you generate by caching a token, and regenerating it only after it expires. Segment cannot make any guarantees about the longevity of environments, but by using this strategy, you can improve the performance and reliability of your Functions by reducing the need for redundant API requests.
392390

393391
This example code fetches an access token from an external API and refreshes it every hour:
394392

@@ -430,7 +428,7 @@ If any of your deployed function instances are failing consistently, they will a
430428

431429
### Data control
432430

433-
You can use [Destination Filters](/docs/connections/destinations/destination-filters/) or [Privacy Portal](https://segment.com/docs/privacy/portal/) to manage what events and, of those events, which event properties are sent to your destination function.
431+
You can use [Destination Filters](/docs/connections/destinations/destination-filters/) or [Privacy Portal](/docs/privacy/portal/) to manage what events and, of those events, which event properties are sent to your destination function.
434432

435433
## Destination functions FAQs
436434

0 commit comments

Comments
 (0)