Skip to content

Commit 1ec7fa7

Browse files
committed
update docs with self-hosted info
1 parent 5122dce commit 1ec7fa7

File tree

1 file changed

+17
-4
lines changed
  • src/connections/sources/catalog/libraries/website/javascript

1 file changed

+17
-4
lines changed

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,22 @@ To add a CNAME record to your DNS settings:
172172
4. Run `curl` on your domain to check if the proxy is working correctly.
173173

174174

175-
## Self Hosting Analytics.js
175+
## Self-Hosting Analytics.js
176+
Sometimes, users want to host as much as Segment on their own infrastructure as possible, for control or to minimize network calls.
176177

177-
Follow the instructions at [Using Analytics.js as an NPM Package](https://github.com/segmentio/analytics-next/tree/master/packages/browser#-using-as-an-npm-package), to host Analytics.js and eliminate the requirement of downloading it from the CDN file during every page load. This enables you to self-host/import the library itself.
178+
Some things you can do:
179+
1. Use [Analytics.js as an npm package](https://github.com/segmentio/analytics-next/tree/master/packages/browser#-using-as-an-npm-package).
180+
181+
2. Use [npm to bundle your destinations ](https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/#add-destinations-from-npm) with your own code instead of fetching them from the CDN.
182+
183+
184+
3. Hardcode your settings instead of fetching from the CDN (Not recommended; this bypasses the Segment GUI completely).
185+
```ts
186+
// npm-only
187+
export const analytics = new AnalyticsBrowser()
188+
analytics.load({
189+
...
190+
cdnSettings: 'Paste object from https://cdn.segment.com/v1/projects/<YOUR_WRITE_KEY>/settings'
191+
})
192+
```
178193

179-
> warning ""
180-
> Segment does not recommend self-hosting, as it requires that you configure integration settings individually and manually redeploy Analytics.js when there are changes to your settings. When you enable third-party libraries in device-mode, Segment loads them, which defeats the purpose of self-hosting.

0 commit comments

Comments
 (0)