Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added

- Support for `eventParameters` encoded event parameter for sponsored products.

## [2.90.10] - 2025-10-23

### Fixed
Expand Down
14 changes: 5 additions & 9 deletions react/ProductSummaryCustom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import LocalProductSummaryContext from './ProductSummaryContext'
import ProductPriceSimulationWrapper from './components/ProductPriceSimulationWrapper'
import { SponsoredBadge } from './components/SponsoredBadge'
import getAdsDataProperties from './utils/getAdsDataProperties'
Comment thread
MatheusLealv marked this conversation as resolved.
import { mapCatalogProductToProductSummary } from './utils/normalize'
import shouldShowSponsoredBadge from './utils/shouldShowSponsoredBadge'

Expand All @@ -40,7 +39,6 @@
children,
href,
priceBehavior = 'default',
placement,
position,
classes,
}: PropsWithChildren<Props>) {
Expand All @@ -57,7 +55,7 @@
const dispatch = useProductSummaryDispatch()
const { handles } = useCssHandles(CSS_HANDLES, { classes })
const { getSettings } = useRuntime()

const settings = getSettings('vtex.store')
const useSemanticHtml = settings?.advancedSettings?.a11ySemanticHtmlMigration

Expand Down Expand Up @@ -184,11 +182,9 @@
}`,
}

const adsDataProperties = getAdsDataProperties({
product,
position,
placement,
})
const eventParameters =
(product.advertisement as any)?.eventParameters ??

Check warning on line 186 in react/ProductSummaryCustom.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
product.advertisement?.adId

const showSponsoredBadge = shouldShowSponsoredBadge(
product,
Expand Down Expand Up @@ -219,7 +215,7 @@
onMouseLeave={handleMouseLeave}
style={{ maxWidth: PRODUCT_SUMMARY_MAX_WIDTH }}
ref={inViewRef}
{...adsDataProperties}
data-van-aid={eventParameters}
>
<Link className={linkClasses} {...linkProps}>
<article className={summaryClasses}>
Expand Down
2 changes: 1 addition & 1 deletion react/__mocks__/vtex.render-runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ export const useRuntime = () => {
}
}
return {}
}
},
}
}
35 changes: 0 additions & 35 deletions react/utils/getAdsDataProperties.ts

This file was deleted.

8 changes: 7 additions & 1 deletion react/utils/shouldShowSponsoredBadge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ import {
SponsoredBadgePosition,
} from 'vtex.product-summary-context/react/ProductSummaryTypes'

interface NewAdvertisement {
eventParameters?: string
}

const shouldShowSponsoredBadge = (
product: Product,
position: SponsoredBadgePosition,
eligiblePosition: SponsoredBadgePosition
) => {
const isSponsored = !!product?.advertisement?.adId
const isSponsored =
!!product?.advertisement?.adId ||
!!(product.advertisement as NewAdvertisement)?.eventParameters
const showSponsoredBadge = isSponsored && position === eligiblePosition

return showSponsoredBadge
Expand Down
Loading