Skip to content

Commit 9e97af2

Browse files
authored
Merge pull request #4243 from segmentio/prigiattiperrut-patch-2
Update custom-proxy.md
2 parents 29ebe1f + fe76f94 commit 9e97af2

File tree

1 file changed

+57
-1
lines changed
  • src/connections/sources/catalog/libraries/website/javascript

1 file changed

+57
-1
lines changed

src/connections/sources/catalog/libraries/website/javascript/custom-proxy.md

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ You need to set up two important parts, regardless of the CDN provider you use:
3030
3131
## Set up
3232

33-
Follow the directions listed for CloudFront or use your own CDN setup. Once you complete those steps and verify that your proxy works for both `cdn.segment.com` and `api.segment.io`, [contact Segment Product Support](https://segment.com/help/contact/) with the following template email:
33+
There are 2 options you can choose from when you set up your custom domain proxy.
34+
1. [CloudFront](#cloudfront)
35+
2. [Custom CDN or API proxy](#custom-cdn--api-proxy)
36+
37+
Follow the directions listed for [CloudFront](#cloudfront) or [use your own CDN setup](#custom-cdn--api-proxy). Once you complete those steps and verify that your proxy works for both `cdn.segment.com` and `api.segment.io`, [contact Segment Product Support](https://segment.com/help/contact/) with the following template email:
3438

3539
```text
3640
Hi,
@@ -51,6 +55,58 @@ A Segment Customer Success team member will respond that they have enabled this
5155
> info ""
5256
> The **Host Address** field does not appear in source settings until it's enabled by Segment Customer Success.
5357
58+
59+
## Custom CDN / API Proxy
60+
61+
### Snippet instructions
62+
If you're a snippet user, you need to modify the [analytics snippet](/docs/getting-started/02-simple-install/#step-1-copy-the-snippet) that's inside your `<head>`.
63+
64+
To proxy settings and destination requests that typically go to `http://cdn.segment.com`, replace:
65+
```diff
66+
- t.src="https://cdn.segment.com/analytics.js/v1/" + key + "/analytics.min.js"
67+
+ t.src="https://MY-CUSTOM-CDN-PROXY.com" + key + "/analytics.min.js"
68+
```
69+
70+
To proxy tracking calls that typically go to `api.segment.io/v1`, replace:
71+
```diff
72+
- analytics.load("<MY_WRITE_KEY>")
73+
+ analytics.load("<MY_WRITE_KEY>", { integrations: { "Segment.io": { apiHost: "MY-CUSTOM-API-PROXY.com" }}})
74+
```
75+
76+
### npm instructions
77+
See the [`npm` library-users instructions](https://www.npmjs.com/package/@segment/analytics-next){:target="_blank"} for more information.
78+
79+
Proxy settings and destination requests that typically go to `http://cdn.segment.com` through a custom proxy.
80+
81+
```ts
82+
const analytics = AnalyticsBrowser.load({
83+
writeKey,
84+
// GET http://cdn.segment.com/v1/projects/<writekey>/settings ->
85+
// https://MY-CUSTOM-CDN-PROXY.com/v1/project/<writekey>/settings
86+
// GET https://cdn.segment.com/next-integrations/actions/...js ->
87+
// https://MY-CUSTOM-CDN-PROXY.com/next-integrations/actions/...js
88+
cdnURL: 'https://MY-CUSTOM-CDN-PROXY.com'
89+
})
90+
```
91+
92+
Proxy tracking calls that typically go to `api.segment.io/v1` by configuring `integrations['Segment.io'].apiHost`.
93+
```ts
94+
const analytics = AnalyticsBrowser.load(
95+
{
96+
writeKey,
97+
cdnURL: 'https://MY-CUSTOM-CDN-PROXY.com'
98+
},
99+
{
100+
integrations: {
101+
'Segment.io': {
102+
// POST https://api.segment.io/v1/t -> https://MY-CUSTOM-API-PROXY.com/t
103+
apiHost: 'MY-CUSTOM-API-PROXY.com' // omit the protocol (http/https) e.g. "api.segment.io/v1" rather than "https://api.segment.io/v1"
104+
}
105+
}
106+
}
107+
)
108+
```
109+
54110
## CloudFront
55111

56112
These instructions refer to Amazon CloudFront, but apply more generally to other providers as well.

0 commit comments

Comments
 (0)