Skip to content

add custom proxy section to README #793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Feb 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions packages/browser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,40 @@ analytics
.catch((err) => ...);
```

## Custom CDN / API Proxy

You can proxy settings and destination requests that typically go to `http://cdn.segment.com` through a custom proxy.
```ts
const analytics = AnalyticsBrowser.load({
writeKey,
// GET http://cdn.segment.com/v1/projects/<writekey>/settings ->
// https://MY-CUSTOM-CDN-PROXY.com/v1/project/<writekey>/settings

// GET https://cdn.segment.com/next-integrations/actions/...js ->
// https://MY-CUSTOM-CDN-PROXY.com/next-integrations/actions/...js
cdnURL: 'https://MY-CUSTOM-CDN-PROXY.com' // 🔥
})
```

You can proxy event calls that typically go to `https://api.segment.io` by configuring `integrations['Segment.io'].apiHost`.
```ts
const analytics = AnalyticsBrowser.load(
{
writeKey,
cdnURL: 'https://MY-CUSTOM-CDN-PROXY.com'
},
{
integrations: {
'Segment.io': {
// POST https://api.segment.io/v1/t ->
// https://MY-CUSTOM-API-PROXY.com/v1/t
apiHost: 'MY-CUSTOM-API-PROXY.com' // 🔥
}
}
}
)
```

## Usage in Common Frameworks
### React
```tsx
Expand Down