Skip to content

Commit e3527ec

Browse files
committed
edits
1 parent 7edc2f3 commit e3527ec

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/connections/sources/catalog/libraries/server/node/index.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ analytics.on('error', (err) => console.error(err))
348348
349349
350350
### Event emitter interface
351-
The event emitter interface allows you to track when certain things happen in the app, such as a track call or an error, and it will call the function you provided with some arguments when that event happens.
351+
The event emitter interface allows you to track events, such as `track` and `identify` calls, and it calls the function you provided with some arguments upon successful delivery. `error` emits on delivery error. See the complete list of emitted events in the [GitHub Node repository](https://github.com/segmentio/analytics-next/blob/master/packages/node/src/app/emitter.ts).
352352
353353
```javascript
354354
analytics.on('error', (err) => console.error(err))
@@ -358,6 +358,24 @@ analytics.on('identify', (ctx) => console.log(ctx))
358358
analytics.on('track', (ctx) => console.log(ctx))
359359
```
360360
361+
Use the emitter to log all HTTP Requests.
362+
363+
```javascript
364+
analytics.on('http_request', (event) => console.log(event))
365+
366+
// when triggered, emits an event of the shape:
367+
{
368+
url: 'https://api.segment.io/v1/batch',
369+
method: 'POST',
370+
headers: {
371+
'Content-Type': 'application/json',
372+
...
373+
},
374+
body: '...',
375+
}
376+
```
377+
378+
361379
## Plugin architecture
362380
When you develop against [Analytics.js 2.0](/docs/connections/sources/catalog/libraries/website/javascript/), the plugins you write can augment 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.
363381

src/connections/sources/catalog/libraries/server/node/migration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ If you're using the [classic version of Analytics Node.js](/docs/connections/sou
2929

3030
After:
3131
```javascript
32-
const analytics = new Analytics({ writeKey: '<MY_WRITE_KEY>' })
32+
const analytics = new Analytics({ writeKey: '<YOUR_WRITE_KEY>' })
3333
```
3434
3. Change flushing to [graceful shutdown](/docs/connections/sources/catalog/libraries/server/node//#graceful-shutdown).
3535

0 commit comments

Comments
 (0)