Skip to content

loganbussey/change-segment-metric-host

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Segment Metrics API Host Changer

When changing the Segment apiHost to point to a proxy using the integration options on the analytics.load() call, identify, page, track, and screen calls will be made to your proxy, but Segment's internal metric calls will still be made to api.segment.io. There's no way to pass in a different metrics host and you would usually have to contact their support team to ask them to change the tracking code loaded by the snippet. This small script intercepts XHR requests and modifies the URL of metric calls to go through your proxy instead.

E.g. When using the following code to change the apiHost,

analytics.load("yourWriteKey", {
  integrations: {
    "Segment.io": {
      apiHost: "segment.example.com/v1",
    },
  },
});

Installation & Usage

NPM

$ npm install @loganbussey/change-segment-metric-host --save
import changeMetricHost from '@loganbussey/change-segment-metric-host';

changeMetricHost('api.example.com');

About

Changes the Segment metrics host to point to your proxy

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published