File tree Expand file tree Collapse file tree 3 files changed +36
-1
lines changed
packages/enhanced-ecommerce Expand file tree Collapse file tree 3 files changed +36
-1
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " lin3s-react-analytics-enhanced-ecommerce" ,
3
- "version" : " 0.0.2 " ,
3
+ "version" : " 0.0.3 " ,
4
4
"author" : " LIN3S" ,
5
5
"license" : " MIT" ,
6
6
"description" : " React components to help integrating Google Analytics and Google Tag Manager in a React application" ,
Original file line number Diff line number Diff line change
1
+ import React , { PureComponent } from 'react' ;
2
+ import { pushDataLayer } from 'lin3s-react-analytics' ;
3
+ import PropTypes from 'prop-types' ;
4
+
5
+ class ProductClick extends PureComponent {
6
+ constructor ( props ) {
7
+ super ( props ) ;
8
+
9
+ this . handleProductClick = this . handleProductClick . bind ( this ) ;
10
+ }
11
+
12
+ handleProductClick ( ) {
13
+ const { productTransform, product, ...rest } = this . props ;
14
+
15
+ pushDataLayer ( productTransform ( product , { ...rest } ) ) ;
16
+ }
17
+
18
+ render ( ) {
19
+ const { component : Component , ...rest } = this . props ;
20
+
21
+ return (
22
+ < div onClick = { this . handleProductClick } > < Component { ...rest } /> </ div >
23
+ ) ;
24
+ }
25
+ }
26
+
27
+ ProductClick . propTypes = {
28
+ component : PropTypes . func . isRequired ,
29
+ product : PropTypes . object . isRequired ,
30
+ productTransform : PropTypes . func . isRequired ,
31
+ } ;
32
+
33
+ export default ProductClick ;
Original file line number Diff line number Diff line change 1
1
import Checkout from './Checkout' ;
2
2
import Page from './Page' ;
3
+ import ProductClick from './ProductClick' ;
3
4
import ProductDetail from './ProductDetail' ;
4
5
import ProductImpressions from './ProductImpressions' ;
5
6
import Purchase from './Purchase' ;
6
7
7
8
export {
8
9
Checkout ,
9
10
Page ,
11
+ ProductClick ,
10
12
ProductDetail ,
11
13
ProductImpressions ,
12
14
Purchase ,
You can’t perform that action at this time.
0 commit comments