From e1d96458aa44df04432f0eb5190d509133fbc21b Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Thu, 2 Jan 2025 11:45:57 -0600
Subject: [PATCH 01/11] wip
---
.../catalog/libraries/server/node/index.md | 66 ++++++++++---------
.../libraries/server/node/migration.md | 4 +-
2 files changed, 37 insertions(+), 33 deletions(-)
diff --git a/src/connections/sources/catalog/libraries/server/node/index.md b/src/connections/sources/catalog/libraries/server/node/index.md
index bd338ad35f..a76b8dc889 100644
--- a/src/connections/sources/catalog/libraries/server/node/index.md
+++ b/src/connections/sources/catalog/libraries/server/node/index.md
@@ -291,23 +291,15 @@ See the complete `AnalyticsSettings` interface [in the analytics-next repository
## Usage in serverless environments
-When calling Track within functions in serverless runtime environments, wrap the call in a `Promise` and `await` it to avoid having the runtime exit or freeze:
-
-```js
-await new Promise((resolve) =>
- analytics().track({ ... }, resolve)
-)
-```
-
See the complete documentation on [Usage in AWS Lambda](https://github.com/segmentio/analytics-next/blob/master/packages/node/README.md#usage-in-aws-lambda){:target="_blank"}, [Usage in Vercel Edge Functions](https://github.com/segmentio/analytics-next/blob/master/packages/node/README.md#usage-in-vercel-edge-functions){:target="_blank"}, and [Usage in Cloudflare Workers](https://github.com/segmentio/analytics-next/blob/master/packages/node/README.md#usage-in-cloudflare-workers){:target="_blank"}
## Graceful shutdown
-Avoid losing events after shutting down your console. Call `.closeAndFlush()` to stop collecting new events and flush all existing events. If a callback on an event call is included, this also waits for all callbacks to be called, and any of their subsequent promises to be resolved.
+Avoid losing events after shutting down your console. Call `.flush({ close: true })` to stop collecting new events and flush all existing events. If a callback on an event call is included, this also waits for all callbacks to be called, and any of their subsequent promises to be resolved.
```javascript
-await analytics.closeAndFlush()
+await analytics.flush({ close: true })
// or
-await analytics.closeAndFlush({ timeout: 5000 }) // force resolve after 5000ms
+await analytics.flush({ close: true, timeout: 5000 }) // force resolve after 5000ms
```
Here's an example of how to use graceful shutdown:
@@ -316,7 +308,7 @@ const app = express()
const server = app.listen(3000)
const onExit = async () => {
- await analytics.closeAndFlush()
+ await analytics.flush({ close: true })
server.close(() => {
console.log("Gracefully closing server...")
process.exit()
@@ -326,15 +318,15 @@ const onExit = async () => {
```
### Collect unflushed events
-If you need to preserve all of your events in the instance of a forced timeout, even ones that came in after analytics.closeAndFlush() was called, you can still collect those events by using:
+If you need to preserve all of your events in the instance of a forced timeout, even ones that came in after analytics.flush({ close: true }) was called, you can still collect those events by using:
```javascript
const unflushedEvents = []
analytics.on('call_after_close', (event) => unflushedEvents.push(events))
-await analytics.closeAndFlush()
+await analytics.flush({ close: true })
-console.log(unflushedEvents) // all events that came in after closeAndFlush was called
+console.log(unflushedEvents) // all events that came in after flush was called
```
## Regional configuration
@@ -364,6 +356,7 @@ analytics.on('error', (err) => console.error(err))
### Event emitter interface
The event emitter interface allows you to track events, like Track and Identify calls, and it calls the function you provided with some arguments upon successful delivery. `error` emits on delivery error.
+
```javascript
analytics.on('error', (err) => console.error(err))
@@ -372,6 +365,7 @@ analytics.on('identify', (ctx) => console.log(ctx))
analytics.on('track', (ctx) => console.log(ctx))
```
+
Use the emitter to log all HTTP Requests.
```javascript
@@ -388,6 +382,24 @@ Use the emitter to log all HTTP Requests.
body: '...',
}
```
+
+ ### Emitter Types
+
+ The following table documents all the emitter types available in the Analytics Node.js library:
+
+ | Emitter Type | Description |
+ |-------------------|-----------------------------------------------------------------------------|
+ | `error` | Emitted when there is an error during event delivery or SDK initialization. |
+ | `identify` | Emitted when an Identify call is made.
+ | `track` | Emitted when a Track call is made.
+ | `page` | Emitted when a Page call is made.
+ | `group` | Emitted when a Group call is made.
+ | `alias` | Emitted when an Alias call is made.
+ | `flush` | Emitted after a batch is flushed.
+ | `http_request` | Emitted when an HTTP request is made. |
+ | `call_after_close`| Emitted when an event is received after the flush with `{ close: true }`. |
+
+ These emitters allow you to hook into various stages of the event lifecycle and handle them accordingly.
## Plugin architecture
@@ -396,22 +408,14 @@ When you develop in [Analytics.js 2.0](/docs/connections/sources/catalog/librari
Though middlewares function the same as plugins, it's best to use plugins as they are easier to implement and are more testable.
### Plugin categories
-Plugins are bound by Analytics.js 2.0 which handles operations such as observability, retries, and error handling. There are two different categories of plugins:
-* **Critical Plugins**: Analytics.js expects this plugin to be loaded before starting event delivery. Failure to load a critical plugin halts event delivery. Use this category sparingly, and only for plugins that are critical to your tracking.
-* **Non-critical Plugins**: Analytics.js can start event delivery before this plugin finishes loading. This means your plugin can fail to load independently from all other plugins. For example, every Analytics.js destination is a non-critical plugin. This makes it possible for Analytics.js to continue working if a partner destination fails to load, or if users have ad blockers turned on that are targeting specific destinations.
-
-> info ""
-> Non-critical plugins are only non-critical from a loading standpoint. For example, if the `before` plugin crashes, this can still halt the event delivery pipeline.
-
-Non-critical plugins run through a timeline that executes in order of insertion based on the entry type. Segment has these five entry types of non-critical plugins:
-
-| Type | Details
------- | --------
-| `before` | Executes before event processing begins. These are plugins that run before any other plugins run.
For example, validating events before passing them along to other plugins. A failure here could halt the event pipeline.
-| `enrichment` | Executes as the first level of event processing. These plugins modify an event.
-| `destination` | Executes as events begin to pass off to destinations.
This doesn't modify the event outside of the specific destination, and failure doesn't halt the execution.
-| `after` | Executes after all event processing completes. You can use this to perform cleanup operations.
An example of this is the [Segment.io Plugin](https://github.com/segmentio/analytics-next/blob/master/packages/browser/src/plugins/segmentio/index.ts){:target="_blank"} which waits for destinations to succeed or fail so it can send it observability metrics.
-| `utility` | Executes once during the bootstrap, to give you an outlet to make any modifications as to how Analytics.js works internally. This allows you to augment Analytics.js functionality.
+
+| Type | Details
+| ------------- | ------------- |
+| `before` | Executes before event processing begins. These are plugins that run before any other plugins run. Thrown errors here can block the event pipeline. Source middleware added via `addSourceMiddleware` is treated as a `before` plugin. |
+| `enrichment` | Executes as the first level of event processing. These plugins modify an event. Thrown errors here can block the event pipeline. |
+| `destination` | Executes as events begin to pass off to destinations. Segment.io is implemented as a destination plugin. Thrown errors here will _not_ block the event pipeline. |
+| `after` | Executes after all event processing completes. You can use this to perform cleanup operations. |
+| `utility` | Executes _only once_ during the bootstrap. Gives you access to the analytics instance via the plugin's `load()` method. This doesn't allow you to modify events. |
### Example plugins
Here's an example of a plugin that converts all track event names to lowercase before the event goes through the rest of the pipeline:
diff --git a/src/connections/sources/catalog/libraries/server/node/migration.md b/src/connections/sources/catalog/libraries/server/node/migration.md
index c430e6872c..b250ad9a93 100644
--- a/src/connections/sources/catalog/libraries/server/node/migration.md
+++ b/src/connections/sources/catalog/libraries/server/node/migration.md
@@ -32,14 +32,14 @@ If you're using the [classic version of Analytics Node.js](/docs/connections/sou
Before:
```javascript
- await analytics.flush(function(err, batch) {
+ await analytics.flush((err, batch) => {
console.log('Flushed, and now this program can exit!');
});
```
After:
```javascript
- await analytics.closeAndFlush()
+ await analytics.flush({ close: true })
```
### Key differences between the classic and updated version
From 8864a6a588cefcc39818ed7c030cfe5f05094470 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Thu, 2 Jan 2025 11:56:08 -0600
Subject: [PATCH 02/11] update docs
---
.../catalog/libraries/server/node/index.md | 111 +++++++++++++++---
1 file changed, 97 insertions(+), 14 deletions(-)
diff --git a/src/connections/sources/catalog/libraries/server/node/index.md b/src/connections/sources/catalog/libraries/server/node/index.md
index a76b8dc889..8c836e12d2 100644
--- a/src/connections/sources/catalog/libraries/server/node/index.md
+++ b/src/connections/sources/catalog/libraries/server/node/index.md
@@ -291,7 +291,97 @@ See the complete `AnalyticsSettings` interface [in the analytics-next repository
## Usage in serverless environments
-See the complete documentation on [Usage in AWS Lambda](https://github.com/segmentio/analytics-next/blob/master/packages/node/README.md#usage-in-aws-lambda){:target="_blank"}, [Usage in Vercel Edge Functions](https://github.com/segmentio/analytics-next/blob/master/packages/node/README.md#usage-in-vercel-edge-functions){:target="_blank"}, and [Usage in Cloudflare Workers](https://github.com/segmentio/analytics-next/blob/master/packages/node/README.md#usage-in-cloudflare-workers){:target="_blank"}
+## Runtime Support
+- Node.js >= 18
+- AWS Lambda
+- Cloudflare Workers
+- Vercel Edge Functions
+- Web Workers / Browser (no device mode destination support)
+
+### Usage in AWS Lambda
+- [AWS lambda execution environment](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtime-environment.html) is challenging for typically non-response-blocking async activites like tracking or logging, since the runtime terminates / freezes after a response is emitted.
+
+Here is an example of using analytics.js within a handler:
+```ts
+const { Analytics } = require('@segment/analytics-node');
+
+ // Preferable to create a new analytics instance per-invocation. Otherwise, we may get a warning about overlapping flush calls. Also, custom plugins have the potential to be stateful, so we prevent those kind of race conditions.
+const createAnalytics = () => new Analytics({
+ writeKey: '',
+ }).on('error', console.error);
+
+module.exports.handler = async (event) => {
+ const analytics = createAnalytics()
+
+ analytics.identify({ ... })
+ analytics.track({ ... })
+
+ // ensure analytics events get sent before program exits
+ await analytics.flush()
+
+ return {
+ statusCode: 200,
+ };
+ ....
+};
+```
+
+### Usage in Vercel Edge Functions
+
+```ts
+import { Analytics } from '@segment/analytics-node';
+import { NextRequest, NextResponse } from 'next/server';
+
+const createAnalytics = () => new Analytics({
+ writeKey: '',
+}).on('error', console.error)
+
+export const config = {
+ runtime: 'edge',
+};
+
+export default async (req: NextRequest) => {
+ const analytics = createAnalytics()
+
+ analytics.identify({ ... })
+ analytics.track({ ... })
+
+ // ensure analytics events get sent before program exits
+ await analytics.flush()
+
+ return NextResponse.json({ ... })
+};
+```
+
+### Usage in Cloudflare Workers
+
+```ts
+import { Analytics, Context } from '@segment/analytics-node';
+
+
+const createAnalytics = () => new Analytics({
+ writeKey: '',
+}).on('error', console.error);
+
+export default {
+ async fetch(
+ request: Request,
+ env: Env,
+ ctx: ExecutionContext
+ ): Promise {
+ const analytics = createAnalytics()
+
+ analytics.identify({ ... })
+ analytics.track({ ... })
+
+ // ensure analytics events get sent before program exits
+ await analytics.flush()
+
+ return new Response(...)
+ },
+};
+
+```
## Graceful shutdown
Avoid losing events after shutting down your console. Call `.flush({ close: true })` to stop collecting new events and flush all existing events. If a callback on an event call is included, this also waits for all callbacks to be called, and any of their subsequent promises to be resolved.
@@ -354,24 +444,17 @@ analytics.on('error', (err) => console.error(err))
### Event emitter interface
-The event emitter interface allows you to track events, like Track and Identify calls, and it calls the function you provided with some arguments upon successful delivery. `error` emits on delivery error.
+The event emitter interface allows you to pass a callback which will be invoked whenever a specific emitter event occurs in your app, such as when a certain method call is made.
+For example:
```javascript
-analytics.on('error', (err) => console.error(err))
-
-analytics.on('identify', (ctx) => console.log(ctx))
-
analytics.on('track', (ctx) => console.log(ctx))
-```
-
-
-Use the emitter to log all HTTP Requests.
+analytics.on('error', (err) => console.error(err))
- ```javascript
- analytics.on('http_request', (event) => console.log(event))
- // when triggered, emits an event of the shape:
+// when triggered, emits an event of the shape:
+analytics.on('http_request', (event) => console.log(event))
{
url: 'https://api.segment.io/v1/batch',
method: 'POST',
@@ -389,7 +472,7 @@ Use the emitter to log all HTTP Requests.
| Emitter Type | Description |
|-------------------|-----------------------------------------------------------------------------|
- | `error` | Emitted when there is an error during event delivery or SDK initialization. |
+ | `error` | Emitted when there is an error after SDK initialization. |
| `identify` | Emitted when an Identify call is made.
| `track` | Emitted when a Track call is made.
| `page` | Emitted when a Page call is made.
From 212aadc155783ee9b809bac0ed2aeaf9e2cb5dcf Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Thu, 2 Jan 2025 11:59:17 -0600
Subject: [PATCH 03/11] wip
---
.../catalog/libraries/server/node/index.md | 51 ++-----------------
1 file changed, 5 insertions(+), 46 deletions(-)
diff --git a/src/connections/sources/catalog/libraries/server/node/index.md b/src/connections/sources/catalog/libraries/server/node/index.md
index 8c836e12d2..d816f4ed83 100644
--- a/src/connections/sources/catalog/libraries/server/node/index.md
+++ b/src/connections/sources/catalog/libraries/server/node/index.md
@@ -480,27 +480,27 @@ analytics.on('http_request', (event) => console.log(event))
| `alias` | Emitted when an Alias call is made.
| `flush` | Emitted after a batch is flushed.
| `http_request` | Emitted when an HTTP request is made. |
+ | `register` | Emitted when a plugin is registered
| `call_after_close`| Emitted when an event is received after the flush with `{ close: true }`. |
These emitters allow you to hook into various stages of the event lifecycle and handle them accordingly.
## Plugin architecture
-When you develop in [Analytics.js 2.0](/docs/connections/sources/catalog/libraries/website/javascript/), the plugins you write can improve functionality, enrich data, and control the flow and delivery of events. From modifying event payloads to changing analytics functionality, plugins help to speed up the process of getting things done.
+The plugins you write can improve functionality, enrich data, and control the flow and delivery of events. From modifying event payloads to changing analytics functionality, plugins help to speed up the process of getting things done.
-Though middlewares function the same as plugins, it's best to use plugins as they are easier to implement and are more testable.
### Plugin categories
| Type | Details
| ------------- | ------------- |
-| `before` | Executes before event processing begins. These are plugins that run before any other plugins run. Thrown errors here can block the event pipeline. Source middleware added via `addSourceMiddleware` is treated as a `before` plugin. |
-| `enrichment` | Executes as the first level of event processing. These plugins modify an event. Thrown errors here can block the event pipeline. |
+| `before` | Executes before event processing begins. These are plugins that run before any other plugins run. Thrown errors here can block the event pipeline. Source middleware added via `addSourceMiddleware` is treated as a `before` plugin. No events will be sent to destinations until `.load()` method is resolved. |
+| `enrichment` | Executes as the first level of event processing. These plugins modify an event. Thrown errors here can block the event pipeline. No events will be sent to destinations until `.load()` method is resolved. |
| `destination` | Executes as events begin to pass off to destinations. Segment.io is implemented as a destination plugin. Thrown errors here will _not_ block the event pipeline. |
| `after` | Executes after all event processing completes. You can use this to perform cleanup operations. |
| `utility` | Executes _only once_ during the bootstrap. Gives you access to the analytics instance via the plugin's `load()` method. This doesn't allow you to modify events. |
-### Example plugins
+### Example plugin
Here's an example of a plugin that converts all track event names to lowercase before the event goes through the rest of the pipeline:
```js
@@ -517,49 +517,8 @@ export const lowercase: Plugin = {
return ctx
}
}
-
-const identityStitching = () => {
- let user
-
- const identity = {
- // Identifies your plugin in the Plugins stack.
- // Access `window.analytics.queue.plugins` to see the full list of plugins
- name: 'Identity Stitching',
- // Defines where in the event timeline a plugin should run
- type: 'enrichment',
- version: '0.1.0',
-
- // Used to signal that a plugin has been property loaded
- isLoaded: () => user !== undefined,
-
- // Applies the plugin code to every `identify` call in Analytics.js
- // You can override any of the existing types in the Segment Spec.
- async identify(ctx) {
- // Request some extra info to enrich your `identify` events from
- // an external API.
- const req = await fetch(
- `https://jsonplaceholder.typicode.com/users/${ctx.event.userId}`
- )
- const userReq = await req.json()
-
- // ctx.updateEvent can be used to update deeply nested properties
- // in your events. It's a safe way to change events as it'll
- // create any missing objects and properties you may require.
- ctx.updateEvent('traits.custom', userReq)
- user.traits(userReq)
-
- // Every plugin must return a `ctx` object, so that the event
- // timeline can continue processing.
- return ctx
- },
- }
-
- return identity
-}
```
-You can view Segment's [existing plugins](https://github.com/segmentio/analytics-next/tree/master/packages/browser/src/plugins){:target="_blank"} to see more examples.
-
### Register a plugin
Registering plugins enable you to modify your analytics implementation to best fit your needs. You can register a plugin using this:
From 498b292c6b44d5df1436652eb9ff6685a33da2c0 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Thu, 2 Jan 2025 12:01:43 -0600
Subject: [PATCH 04/11] wip
---
.../sources/catalog/libraries/server/node/index.md | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/connections/sources/catalog/libraries/server/node/index.md b/src/connections/sources/catalog/libraries/server/node/index.md
index d816f4ed83..6665b4bcdc 100644
--- a/src/connections/sources/catalog/libraries/server/node/index.md
+++ b/src/connections/sources/catalog/libraries/server/node/index.md
@@ -289,10 +289,8 @@ Setting | Details
See the complete `AnalyticsSettings` interface [in the analytics-next repository](https://github.com/segmentio/analytics-next/blob/master/packages/node/src/app/settings.ts){:target="_blank"}.
-## Usage in serverless environments
-
-## Runtime Support
-- Node.js >= 18
+## Usage in serverless environments and non-node runtimes
+We support a variety of runtimes, including, but not limited to:
- AWS Lambda
- Cloudflare Workers
- Vercel Edge Functions
From f8682ca83a1f7aabdc2fcd1cfa0eeecd8864ebf0 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Thu, 2 Jan 2025 12:02:13 -0600
Subject: [PATCH 05/11] wip
---
src/connections/sources/catalog/libraries/server/node/index.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/connections/sources/catalog/libraries/server/node/index.md b/src/connections/sources/catalog/libraries/server/node/index.md
index 6665b4bcdc..91c8177c70 100644
--- a/src/connections/sources/catalog/libraries/server/node/index.md
+++ b/src/connections/sources/catalog/libraries/server/node/index.md
@@ -15,7 +15,7 @@ All of Segment's server-side libraries are built for high-performance, so you ca
## Getting Started
> warning ""
-> Make sure you're using a version of Node that's 16 or higher.
+> Make sure you're using a version of Node that's 18 or higher.
1. Run the relevant command to add Segment's Node library module to your `package.json`.
From 047438bd03d0ff8b5634a753f625db37f801fbe4 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Mon, 6 Jan 2025 13:36:29 -0600
Subject: [PATCH 06/11] Update
src/connections/sources/catalog/libraries/server/node/index.md
Co-authored-by: stayseesong <83784848+stayseesong@users.noreply.github.com>
---
src/connections/sources/catalog/libraries/server/node/index.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/connections/sources/catalog/libraries/server/node/index.md b/src/connections/sources/catalog/libraries/server/node/index.md
index 91c8177c70..856f38c132 100644
--- a/src/connections/sources/catalog/libraries/server/node/index.md
+++ b/src/connections/sources/catalog/libraries/server/node/index.md
@@ -493,7 +493,7 @@ The plugins you write can improve functionality, enrich data, and control the fl
| Type | Details
| ------------- | ------------- |
| `before` | Executes before event processing begins. These are plugins that run before any other plugins run. Thrown errors here can block the event pipeline. Source middleware added via `addSourceMiddleware` is treated as a `before` plugin. No events will be sent to destinations until `.load()` method is resolved. |
-| `enrichment` | Executes as the first level of event processing. These plugins modify an event. Thrown errors here can block the event pipeline. No events will be sent to destinations until `.load()` method is resolved. |
+| `enrichment` | Executes as the first level of event processing. These plugins modify an event. Thrown errors here can block the event pipeline. No events send to destinations until `.load()` method is resolved. |
| `destination` | Executes as events begin to pass off to destinations. Segment.io is implemented as a destination plugin. Thrown errors here will _not_ block the event pipeline. |
| `after` | Executes after all event processing completes. You can use this to perform cleanup operations. |
| `utility` | Executes _only once_ during the bootstrap. Gives you access to the analytics instance via the plugin's `load()` method. This doesn't allow you to modify events. |
From fcde6fb70e111ebd2096fb25053dd50354e5c493 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Mon, 6 Jan 2025 13:36:40 -0600
Subject: [PATCH 07/11] Update
src/connections/sources/catalog/libraries/server/node/index.md
Co-authored-by: stayseesong <83784848+stayseesong@users.noreply.github.com>
---
src/connections/sources/catalog/libraries/server/node/index.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/connections/sources/catalog/libraries/server/node/index.md b/src/connections/sources/catalog/libraries/server/node/index.md
index 856f38c132..9915be6d27 100644
--- a/src/connections/sources/catalog/libraries/server/node/index.md
+++ b/src/connections/sources/catalog/libraries/server/node/index.md
@@ -290,7 +290,7 @@ Setting | Details
See the complete `AnalyticsSettings` interface [in the analytics-next repository](https://github.com/segmentio/analytics-next/blob/master/packages/node/src/app/settings.ts){:target="_blank"}.
## Usage in serverless environments and non-node runtimes
-We support a variety of runtimes, including, but not limited to:
+Segment supports a variety of runtimes, including, but not limited to:
- AWS Lambda
- Cloudflare Workers
- Vercel Edge Functions
From c85abfdf1570285d6cffa38d19b705e89f2dc064 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Mon, 6 Jan 2025 13:37:47 -0600
Subject: [PATCH 08/11] Update
src/connections/sources/catalog/libraries/server/node/index.md
Co-authored-by: stayseesong <83784848+stayseesong@users.noreply.github.com>
---
src/connections/sources/catalog/libraries/server/node/index.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/connections/sources/catalog/libraries/server/node/index.md b/src/connections/sources/catalog/libraries/server/node/index.md
index 9915be6d27..006a7c9fae 100644
--- a/src/connections/sources/catalog/libraries/server/node/index.md
+++ b/src/connections/sources/catalog/libraries/server/node/index.md
@@ -496,7 +496,7 @@ The plugins you write can improve functionality, enrich data, and control the fl
| `enrichment` | Executes as the first level of event processing. These plugins modify an event. Thrown errors here can block the event pipeline. No events send to destinations until `.load()` method is resolved. |
| `destination` | Executes as events begin to pass off to destinations. Segment.io is implemented as a destination plugin. Thrown errors here will _not_ block the event pipeline. |
| `after` | Executes after all event processing completes. You can use this to perform cleanup operations. |
-| `utility` | Executes _only once_ during the bootstrap. Gives you access to the analytics instance via the plugin's `load()` method. This doesn't allow you to modify events. |
+| `utility` | Executes _only once_ during the bootstrap. Gives you access to the analytics instance using the plugin's `load()` method. This doesn't allow you to modify events. |
### Example plugin
Here's an example of a plugin that converts all track event names to lowercase before the event goes through the rest of the pipeline:
From 987f8dff1aa26bcc1c89043b3735256ecbca0302 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Mon, 6 Jan 2025 13:39:42 -0600
Subject: [PATCH 09/11] Update
src/connections/sources/catalog/libraries/server/node/index.md
Co-authored-by: stayseesong <83784848+stayseesong@users.noreply.github.com>
---
src/connections/sources/catalog/libraries/server/node/index.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/connections/sources/catalog/libraries/server/node/index.md b/src/connections/sources/catalog/libraries/server/node/index.md
index 006a7c9fae..7c4ddce331 100644
--- a/src/connections/sources/catalog/libraries/server/node/index.md
+++ b/src/connections/sources/catalog/libraries/server/node/index.md
@@ -492,7 +492,7 @@ The plugins you write can improve functionality, enrich data, and control the fl
| Type | Details
| ------------- | ------------- |
-| `before` | Executes before event processing begins. These are plugins that run before any other plugins run. Thrown errors here can block the event pipeline. Source middleware added via `addSourceMiddleware` is treated as a `before` plugin. No events will be sent to destinations until `.load()` method is resolved. |
+| `before` | Executes before event processing begins. These are plugins that run before any other plugins run. Thrown errors here can block the event pipeline. Source middleware added using `addSourceMiddleware` is treated as a `before` plugin. No events send to destinations until `.load()` method is resolved. |
| `enrichment` | Executes as the first level of event processing. These plugins modify an event. Thrown errors here can block the event pipeline. No events send to destinations until `.load()` method is resolved. |
| `destination` | Executes as events begin to pass off to destinations. Segment.io is implemented as a destination plugin. Thrown errors here will _not_ block the event pipeline. |
| `after` | Executes after all event processing completes. You can use this to perform cleanup operations. |
From adab75d5023470f0acd67938c86c4ce0b1d40265 Mon Sep 17 00:00:00 2001
From: Seth Silesky <5115498+silesky@users.noreply.github.com>
Date: Mon, 6 Jan 2025 19:32:58 -0600
Subject: [PATCH 10/11] Update
src/connections/sources/catalog/libraries/server/node/index.md
Co-authored-by: stayseesong <83784848+stayseesong@users.noreply.github.com>
---
src/connections/sources/catalog/libraries/server/node/index.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/connections/sources/catalog/libraries/server/node/index.md b/src/connections/sources/catalog/libraries/server/node/index.md
index 7c4ddce331..16bf0bb300 100644
--- a/src/connections/sources/catalog/libraries/server/node/index.md
+++ b/src/connections/sources/catalog/libraries/server/node/index.md
@@ -297,7 +297,7 @@ Segment supports a variety of runtimes, including, but not limited to:
- Web Workers / Browser (no device mode destination support)
### Usage in AWS Lambda
-- [AWS lambda execution environment](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtime-environment.html) is challenging for typically non-response-blocking async activites like tracking or logging, since the runtime terminates / freezes after a response is emitted.
+- [AWS lambda execution environment](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtime-environment.html){:target="_blank"} is challenging for typically non-response-blocking async activities like tracking or logging, since the runtime terminates or freezes after a response is emitted.
Here is an example of using analytics.js within a handler:
```ts
From 8f2c5bd995ad88e4664f069844194c3e3210d1ba Mon Sep 17 00:00:00 2001
From: stayseesong <83784848+stayseesong@users.noreply.github.com>
Date: Thu, 9 Jan 2025 09:31:39 -0800
Subject: [PATCH 11/11] Update
src/connections/sources/catalog/libraries/server/node/index.md
---
src/connections/sources/catalog/libraries/server/node/index.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/connections/sources/catalog/libraries/server/node/index.md b/src/connections/sources/catalog/libraries/server/node/index.md
index 16bf0bb300..21462f502c 100644
--- a/src/connections/sources/catalog/libraries/server/node/index.md
+++ b/src/connections/sources/catalog/libraries/server/node/index.md
@@ -489,6 +489,7 @@ The plugins you write can improve functionality, enrich data, and control the fl
### Plugin categories
+Segment has these five entry types of plugins:
| Type | Details
| ------------- | ------------- |