Skip to content

Commit

Permalink
Send productClick events to PixelManager
Browse files Browse the repository at this point in the history
  • Loading branch information
italo-batista committed May 8, 2019
1 parent faa26c5 commit 361a37e
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- Send productClick events to Pixel Manager.

## [1.12.0] - 2019-04-24
### Changed
Expand Down
5 changes: 3 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"vtex.product-summary": "2.x",
"vtex.styleguide": "9.x",
"vtex.slider": "0.x",
"vtex.store-icons": "0.x"
"vtex.store-icons": "0.x",
"vtex.pixel-manager": "0.x"
}
}
}
2 changes: 1 addition & 1 deletion react/ProductList.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import GapPaddingTypes, {
getGapPaddingValues,
} from './paddingEnum'
import ShelfContent from './ShelfContent'
import ShelfItem from './ShelfItem'
import { ShelfItem } from './ShelfItem'

import shelf from './shelf.css'

Expand Down
2 changes: 1 addition & 1 deletion react/RelatedProducts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, { Component } from 'react'

import ProductList from './ProductList'
import { productListSchemaPropTypes } from './propTypes'
import ShelfItem from './ShelfItem'
import { ShelfItem } from './ShelfItem'
import shelf from './shelf.css'

/**
Expand Down
2 changes: 1 addition & 1 deletion react/ShelfContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {

import { getGapPaddingValues } from './paddingEnum'
import ScrollTypes from './ScrollTypes'
import ShelfItem from './ShelfItem'
import { ShelfItem } from './ShelfItem'

import shelf from './shelf.css'

Expand Down
13 changes: 12 additions & 1 deletion react/ShelfItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { Component } from 'react'
import { path, assocPath } from 'ramda'

import { ExtensionPoint } from 'vtex.render-runtime'
import { Pixel } from 'vtex.pixel-manager/PixelContext'

import { shelfItemPropTypes } from './propTypes'
import { changeImageUrlSize, toHttps } from './utils/urlHelpers'
Expand All @@ -10,9 +11,16 @@ import { changeImageUrlSize, toHttps } from './utils/urlHelpers'
* ShelfItem Component. Normalizes the item received in the props
* to adapt to the extension point prop.
*/
export default class ShelfItem extends Component {
export class ShelfItem extends Component {
static propTypes = shelfItemPropTypes

sendProductClickEvent = product => {
this.props.push({
event: 'productClick',
items: product,
})
}

findAvailableProduct = item =>
item.sellers.find(
({ commertialOffer = {} }) => commertialOffer.AvailableQuantity > 0
Expand Down Expand Up @@ -47,8 +55,11 @@ export default class ShelfItem extends Component {
<ExtensionPoint
id="product-summary"
product={this.normalizeProduct(item)}
actionOnClick={() => this.sendProductClickEvent(item)}
{...newSummary}
/>
)
}
}

export default Pixel(ShelfItem)
9 changes: 9 additions & 0 deletions react/__mocks__/vtex.pixel-manager/PixelContext.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react'

export function Pixel(Comp) {
return class extends React.Component {
render() {
return <Comp {...this.props} push={() => {}} subscribe={() => {}} />
}
}
}

0 comments on commit 361a37e

Please sign in to comment.