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

Commit43ee873

Browse files
authored
Merge branch 'develop' into master
2 parents7e63d36 +4aaa361 commit43ee873

File tree

4 files changed

+70
-11
lines changed

4 files changed

+70
-11
lines changed

‎src/_data/catalog/slugs.yml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,6 @@ destinations:
116116
-original:"encharge-actions"
117117
override:"encharge-cloud-actions"
118118
-original:"pardot-actions"
119-
override:"actions-pardot"
119+
override:"actions-pardot"
120+
-original:"airship-actions"
121+
override:"actions-airship"

‎src/connections/destinations/catalog/airship-actions/index.md‎

Lines changed: 0 additions & 9 deletions
This file was deleted.

‎src/connections/destinations/destination-filters.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ Use the [Public API](https://docs.segmentapis.com/tag/Destination-Filters/){:tar
124124
"destinationId":"<DESTIANTION_ID>",
125125
"title":"Don't send event if userId is null",
126126
"description":"Drop event if there is no userId on the request",
127-
"if":"length( userId ) < 1 or typeof( userId ) != 'string'",
127+
"if":"length( userId ) < 1",
128128
"actions": [
129129
{
130130
"type":"DROP"

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

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ Setting | Details
284284
`flushInterval` _number_ | The number of milliseconds to wait before flushing the queue automatically. The default is: `10000`
285285
`httpRequestTimeout` | The maximum number of milliseconds to wait for an http request. The default is: `10000`
286286
`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.
287288
288289
## Graceful shutdown
289290
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.
@@ -553,7 +554,72 @@ Different parts of your application may require different types of batching, or
553554
const marketingAnalytics = new Analytics({ writeKey:'MARKETING_WRITE_KEY' });
554555
const appAnalytics = new Analytics({ writeKey:'APP_WRITE_KEY' });
555556
```
557+
## AnalyticsHTTPClient
556558
559+
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:
560+
561+
Use a custom fetch-like implementation with proxy (simple, recommended)
562+
```javascript
563+
import { HTTPFetchFn } from'../lib/http-client'
564+
import axios from'axios'
565+
566+
const httpClient: HTTPFetchFn = async (url, options) => {
567+
return axios({
568+
url,
569+
proxy: {
570+
protocol:'http',
571+
host:'proxy.example.com',
572+
port: 8886,
573+
auth: {
574+
username:'user',
575+
password:'pass',
576+
},
577+
},
578+
...options,
579+
})
580+
}
581+
582+
const analytics = new Analytics({
583+
writeKey:'<YOUR_WRITE_KEY>',
584+
httpClient,
585+
})
586+
```
587+
Augment the default HTTP Client
588+
```javascript
589+
import { FetchHTTPClient, HTTPClientRequest } from'@segment/analytics-node'
590+
591+
class MyClient extends FetchHTTPClient {
592+
async makeRequest(options: HTTPClientRequest) {
593+
return super.makeRequest({
594+
...options,
595+
headers: { ...options.headers, foo:'bar' }
596+
}})
597+
}
598+
}
599+
600+
const analytics = new Analytics({
601+
writeKey:'<YOUR_WRITE_KEY>',
602+
httpClient: new MyClient()
603+
})
604+
```
605+
Completely override the full HTTPClient (Advanced, you probably don't need todo this)
606+
```javascript
607+
import { HTTPClient, HTTPClientRequest } from'@segment/analytics-node'
608+
609+
class CustomClient implements HTTPClient {
610+
async makeRequest(options: HTTPClientRequest) {
611+
return someRequestLibrary(options.url, {
612+
method: options.method,
613+
body: JSON.stringify(options.data) // serialize data
614+
headers: options.headers,
615+
})
616+
}
617+
}
618+
const analytics = new Analytics({
619+
writeKey:'<YOUR_WRITE_KEY>',
620+
httpClient: newCustomClient()
621+
})
622+
```
557623
558624
## Troubleshooting
559625

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp