Skip to content

Commit

Permalink
moat data updates
Browse files Browse the repository at this point in the history
  • Loading branch information
giannif committed May 2, 2024
1 parent 54a5885 commit d1851ca
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 25 deletions.
22 changes: 15 additions & 7 deletions packages/react-components/src/components/moat-tracking.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
import React from 'react'
import { constructMoatData } from '@giphy/js-util'
import React from 'react'

type Props = { bottleData: any }

export const MoatTracking = ({ bottleData }: Props) => {
const moatCompatibleData = constructMoatData(bottleData as any)
// Constructing the URL with macros replaced by their values
const url = `https://z.moatads.com/giphyjsdisplay626459778035/moatad.js#${Object.entries(moatCompatibleData)
.map(([key, value]) => `${key}=${value}`)
.join('&')}`
const scriptTag = <script src={url} type="text/javascript"></script>
return scriptTag
if (moatCompatibleData) {
const partnerId = 'giphyjsdisplay626459778035'
const kvPairs = Object.entries(moatCompatibleData).map(([key, value]) => `${key}=${value}`)
// Constructing the URL with macros replaced by their values
const url = `https://z.moatads.com/${partnerId}/moatad.js#${kvPairs.join('&')}`
const noscriptClassName = `MOAT-${partnerId}?${kvPairs.join('&amp:')}`
return (
<>
<noscript className={noscriptClassName}></noscript>
<script src={url} type="text/javascript"></script>
</>
)
}
return null
}

export default MoatTracking
45 changes: 43 additions & 2 deletions packages/react-components/stories/gif.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,27 @@ type GifComponentProps = React.ComponentProps<typeof GifComponent>
type GifDemoProps = Omit<GifComponentProps, 'gif'> & {
id: string
scale: string
bottle_data: IGif['bottle_data']
}


const GifDemo = ({ id, width, height, noLink, borderRadius, percentWidth, overlay, ...other }: GifDemoProps) => {
const GifDemo = ({
id,
width,
height,
noLink,
borderRadius,
percentWidth,
overlay,
bottle_data,
...other
}: GifDemoProps) => {
const [gif, setGif] = useState<IGif>()

const fetch = useCallback(async () => {
const { data: gif } = await gf.gif(id)
if (bottle_data) {
gif.bottle_data = bottle_data
}
setGif(gif)
}, [id])

Expand Down Expand Up @@ -90,6 +103,34 @@ export const GifWithOverlay: Story = {
},
}

export const GifWithAd: Story = {
args: {
bottle_data: {
tid: 'd7494a8384b6906a880ff6dcc16a7151d3f2a3e8413be76e9ddb4ee1f8dc9fd0',
tags: [],
tdata: {
om: [],
bartab: [],
web: [
{
vendor: 'Moat',
verificationParameters: {
moatClientLevel1: 'Giphy',
moatClientLevel2: 'Giphy',
moatClientLevel3: 'Giphy',
moatClientLevel4: 'Giphy',
moatClientSlicer1: 'Giphy',
moatClientSlicer2: 'Giphy',
zMoatPosition: 'Giphy',
},
},
],
click_out_url: '',
},
},
},
}

export const GifThatStretches: Story = {
args: {
percentWidth: '50%',
Expand Down
1 change: 0 additions & 1 deletion packages/util/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ export {
} from './gif-utils'
export * from './log'
export * from './sdk-headers'
export { default as injectTrackingPixel } from './tracking-pixel'
export { checkIfWebP } from './webp-check'
15 changes: 0 additions & 15 deletions packages/util/src/tracking-pixel.ts

This file was deleted.

0 comments on commit d1851ca

Please sign in to comment.