Skip to content

Commit

Permalink
Restored construct moat data file
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksantan committed Apr 9, 2024
1 parent 47be0ed commit ebe3a83
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
44 changes: 44 additions & 0 deletions packages/components/src/util/construct-moat-data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
type MoatData = {
moatClientLevel1: string
moatClientLevel2: string
moatClientLevel3: string
moatClientLevel4: string
moatClientSlicer1: string
moatClientSlicer2: string
zMoatPosition: string
zMoatSession?: string
}

type Tracker = {
vendor: string
verificationParameters: any
}

type TData = {
web?: Tracker[]
}

export const constructMoatData = ({ tdata }: { tdata: TData }): MoatData | undefined => {
const [moatTrackerData] = tdata?.web?.filter((tracker) => tracker.vendor === 'Moat') || []
if (moatTrackerData?.verificationParameters) {
const {
moatClientLevel1 = '_ADVERTISER_',
moatClientLevel2 = '_CAMPAIGN_',
moatClientLevel3 = '_LINE_ITEM_',
moatClientLevel4 = '_CREATIVE_',
moatClientSlicer1 = '_SITE_',
moatClientSlicer2 = '_PLACEMENT_',
zMoatPosition = '_POSITION_',
} = moatTrackerData.verificationParameters

return {
moatClientLevel1,
moatClientLevel2,
moatClientLevel3,
moatClientLevel4,
moatClientSlicer1,
moatClientSlicer2,
zMoatPosition,
}
}
}
1 change: 1 addition & 0 deletions packages/util/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export { default as bestfit, setRenditionScaleUpMaxPixels } from './bestfit'
export * from './collections'
export * from './construct-moat-data'
export { default as getClientRect } from './get-client-rect-from-el'
export { default as getPingbackId } from './get-pingback-id'
export {
Expand Down

0 comments on commit ebe3a83

Please sign in to comment.