Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb6184a9

Browse files
committed
update node docs
1 parentdb4125f commitb6184a9

File tree

1 file changed

+19
-16
lines changed
  • src/connections/sources/catalog/libraries/server/node

1 file changed

+19
-16
lines changed

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

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,12 @@ Setting | Details
282282
`maxRetries` _number_ | The number of times to retry flushing a batch. The default is: `3`
283283
`maxEventsInBatch` _number_ | The number of messages to enqueue before flushing. The default is: `15`
284284
`flushInterval` _number_ | The number of milliseconds to wait before flushing the queue automatically. The default is: `10000`
285-
`httpRequestTimeout` | The maximum number of milliseconds to wait for an http request. The default is: `10000`
286-
`disable` | Disable the analytics library for testing. The default is: `false`
287-
`httpClient` *Optional* | A custom AnalyticsHTTPClient implementation to support alternate libraries or proxies. Defaults to global fetch or node-fetch for older versions of node.
285+
`httpRequestTimeout` _number_ | The maximum number of milliseconds to wait for an http request. The default is: `10000`
286+
`disable` _boolean_ | Disable the analytics library for testing. The default is: `false`
287+
`httpClient` _HTTPClient or HTTPClientFn_ | A custom HTTP Client implementation to support alternate libraries or proxies. Defaults to global fetch or node-fetch for older versions of node. See the [Overriding the default HTTP Client](#overriding-the-default-http-client) section for more details.
288+
289+
> info ""
290+
> See the complete [`AnalyticsSettings` interface](https://github.com/segmentio/analytics-next/blob/master/packages/node/src/app/settings.ts){:target="_blank"}
288291
289292
## Graceful shutdown
290293
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.
@@ -554,7 +557,7 @@ Different parts of your application may require different types of batching, or
554557
const marketingAnalytics = new Analytics({ writeKey:'MARKETING_WRITE_KEY' });
555558
const appAnalytics = new Analytics({ writeKey:'APP_WRITE_KEY' });
556559
```
557-
##AnalyticsHTTPClient
560+
##Overriding the default HTTP Client
558561
559562
Segment attempts to use the global `fetch` implementation if available in order to support several diverse environments. Some special cases (for example, http proxy) may require a different implementation for http communication. You can provide a customized wrapper in the Analytics configuration to support this. Here are a few approaches:
560563
@@ -563,21 +566,21 @@ Use a custom fetch-like implementation with proxy (simple, recommended)
563566
import { HTTPFetchFn } from'../lib/http-client'
564567
import axios from'axios'
565568
566-
const httpClient: HTTPFetchFn = async (url, options) => {
567-
returnaxios({
569+
const httpClient: HTTPFetchFn = async (url,{ body, ...options }) =>
570+
axios({
568571
url,
572+
data: body,
569573
proxy: {
570-
protocol:'http',
571-
host:'proxy.example.com',
572-
port: 8886,
573-
auth: {
574-
username:'user',
575-
password:'pass',
576-
},
574+
protocol:'http',
575+
host:'proxy.example.com',
576+
port: 8886,
577+
auth: {
578+
username:'user',
579+
password:'pass',
577580
},
581+
},
578582
...options,
579583
})
580-
}
581584
582585
const analytics = new Analytics({
583586
writeKey:'<YOUR_WRITE_KEY>',
@@ -591,8 +594,8 @@ import { FetchHTTPClient, HTTPClientRequest } from '@segment/analytics-node'
591594
class MyClient extends FetchHTTPClient {
592595
async makeRequest(options: HTTPClientRequest) {
593596
return super.makeRequest({
594-
...options,
595-
headers: { ...options.headers, foo:'bar' }
597+
...options,
598+
headers: { ...options.headers, foo:'bar' }
596599
}})
597600
}
598601
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp