We will be using the integration and destination term loosely and interchangeably
RudderStack JS SDK reads the config data from the control plane to fetch the native integrations. The native integrations must have the following methods/attributes defined by you as shown below. RudderStack JS SDK calls these for initializing the destination global object and forwarding event data namely identify, page and track.
constructor: RudderStack JS SDK, constructs an integration object with the destination specific keys such as
custom mappings etc, fetched from your config plane. These information are required by the below calls.
identify: RudderStack JS SDK calls this method to pass identify event data. One can write custom logic specific to the destination before calling destination specific implementation.
page: Similar to identify, with page event data
track: Similar to identify, with track event data
isLoaded: RudderStack JS SDK checks the output of this method, once true, events are forwarded to above methods.
To add a new integration, add the above said methods to a JS object and export that object to be picked up by the integrations map.
This map is iterated and matched against the config fetched from the control plane to construct only those enabled integrations. This is matched against the
name property of the integration object and destination config
All the activities of fetching configs and constructing and event forwarding to integrations is handled by the core analytics object.
Refer the existing integrations in case of any parameter reference. For adding destination JS snippet, use the init method of the new integration.