Skip to content

Commit c8b47cc

Browse files
authored
Merge pull request #27 from PiwikPRO/fix/ecommerce-custom-dimensions
fix: ecommerce customDimensions
2 parents f9a8326 + c1be33a commit c8b47cc

4 files changed

Lines changed: 20 additions & 17 deletions

File tree

example/src/components/ECommerce/ProductDetailView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Product } from '../../../../src/interfaces/product.ts'
1+
import { Product } from '@piwikpro/react-piwik-pro'
22
import { FunctionComponent } from 'react'
33
import {
44
Dialog,

example/src/pages/ECommercePage.tsx

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { FunctionComponent, useEffect, useState } from 'react'
2-
import { Product } from '../../../src/interfaces/product.ts'
3-
import { PaymentInformation } from '../../../src/interfaces/payment.ts'
4-
import { eCommerce } from '@piwikpro/react-piwik-pro'
2+
import { eCommerce, Product, PaymentInformation } from '@piwikpro/react-piwik-pro'
53
import { useSnackbar } from 'notistack'
64
import {
75
Box,
@@ -29,8 +27,8 @@ const products: Product[] = [
2927
variant: 'Variant 1',
3028
price: 9.99,
3129
customDimensions: {
32-
dimension1: 'value1',
33-
dimension2: 'value2'
30+
1: 'value1',
31+
2: 'value2'
3432
}
3533
},
3634
{
@@ -41,8 +39,8 @@ const products: Product[] = [
4139
variant: 'Variant 2',
4240
price: 19.98,
4341
customDimensions: {
44-
dimension1: 'value1',
45-
dimension2: 'value2'
42+
1: 'value1',
43+
2: 'value2'
4644
}
4745
},
4846
{
@@ -53,8 +51,8 @@ const products: Product[] = [
5351
variant: 'Variant 3',
5452
price: 29.97,
5553
customDimensions: {
56-
dimension1: 'value1',
57-
dimension2: 'value2'
54+
1: 'value1',
55+
2: 'value2'
5856
}
5957
},
6058
{
@@ -65,8 +63,8 @@ const products: Product[] = [
6563
variant: 'Variant 4',
6664
price: 39.96,
6765
customDimensions: {
68-
dimension1: 'value1',
69-
dimension2: 'value2'
66+
1: 'value1',
67+
2: 'value2'
7068
}
7169
},
7270
{
@@ -77,8 +75,8 @@ const products: Product[] = [
7775
variant: 'Variant 5',
7876
price: 49.95,
7977
customDimensions: {
80-
dimension1: 'value1',
81-
dimension2: 'value2'
78+
1: 'value1',
79+
2: 'value2'
8280
}
8381
},
8482
{
@@ -89,8 +87,8 @@ const products: Product[] = [
8987
variant: 'Variant 6',
9088
price: 59.94,
9189
customDimensions: {
92-
dimension1: 'value1',
93-
dimension2: 'value2'
90+
1: 'value1',
91+
2: 'value2'
9492
}
9593
}
9694
]

src/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ export * as SiteSearch from './services/site-search/site-search.service';
1212
export * as UserManagement from './services/user-management/userManagement.service';
1313
export * as DataLayer from './services/dataLayer/dataLayer.service';
1414

15+
export * from './interfaces/payment';
16+
export * from './interfaces/product';
17+
1518
export default {
1619
initialize: PiwikPro.default.init,
1720
}

src/interfaces/product.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { LimitedArrayFiveStrings } from './utils'
22

3+
type DimensionId = number;
4+
35
export type Product = {
46
sku: string,
57
name?: string,
@@ -8,5 +10,5 @@ export type Product = {
810
quantity?: number,
911
brand?: string,
1012
variant?: string,
11-
customDimensions?: object,
13+
customDimensions?: Record<DimensionId, string>,
1214
}

0 commit comments

Comments
 (0)