MediaJel / mediajel-tracker

hosted mediajel tracker
4 stars 0 forks source link

Create data structure for storing multiple segment ids in mediajel-tracker #456

Closed pacholoamit closed 1 week ago

pacholoamit commented 1 month ago

Description

Implement a way to store multiple segment ids in the mediajel-tracker

Proposal

Our tag will look like this:

// Where `s1` and `s2` are segment ids
<script src="https://tags.cnna.io/?appId=example&s1=123456&s2=1234567"></script?

We create the following code to handle the creation of the segment tag in the mediajel-tracker


// imports code to create Liquid M segment tag
import { createLiquidMSegmentTag } from "./segments/liquidm";

// import code to create Nexxen segment tag
import { createNexxenSegmentTag } from "./segments/nexxen";

// We create an object that maps the keys to a function that creates the Segment tag
const segments = {
  liquidm: createLiquidMSegmentTag(id),
  nexxen:  createNexxenSegmentTag(id)
}

// getContexts is a function that gets the params from the tracker (I.E. appId: example, environment: dutchie-iframe)
// We destructure the `s1` and `s2` params
const { s1, s2 } = getContexts()

// Execute the function if segment ids are available
s1 && segments[liquidm](s1)
s2 && segments[nexxen](s2)
pacholoamit commented 4 weeks ago

Update: Still in progress