Skip to content

Commit

Permalink
Merge pull request #27 from PiwikPRO/fix/ecommerce-custom-dimensions
Browse files Browse the repository at this point in the history
fix: ecommerce customDimensions
  • Loading branch information
auto200 authored Jan 30, 2024
2 parents f9a8326 + c1be33a commit c8b47cc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion example/src/components/ECommerce/ProductDetailView.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Product } from '../../../../src/interfaces/product.ts'
import { Product } from '@piwikpro/react-piwik-pro'
import { FunctionComponent } from 'react'
import {
Dialog,
Expand Down
28 changes: 13 additions & 15 deletions example/src/pages/ECommercePage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { FunctionComponent, useEffect, useState } from 'react'
import { Product } from '../../../src/interfaces/product.ts'
import { PaymentInformation } from '../../../src/interfaces/payment.ts'
import { eCommerce } from '@piwikpro/react-piwik-pro'
import { eCommerce, Product, PaymentInformation } from '@piwikpro/react-piwik-pro'
import { useSnackbar } from 'notistack'
import {
Box,
Expand Down Expand Up @@ -29,8 +27,8 @@ const products: Product[] = [
variant: 'Variant 1',
price: 9.99,
customDimensions: {
dimension1: 'value1',
dimension2: 'value2'
1: 'value1',
2: 'value2'
}
},
{
Expand All @@ -41,8 +39,8 @@ const products: Product[] = [
variant: 'Variant 2',
price: 19.98,
customDimensions: {
dimension1: 'value1',
dimension2: 'value2'
1: 'value1',
2: 'value2'
}
},
{
Expand All @@ -53,8 +51,8 @@ const products: Product[] = [
variant: 'Variant 3',
price: 29.97,
customDimensions: {
dimension1: 'value1',
dimension2: 'value2'
1: 'value1',
2: 'value2'
}
},
{
Expand All @@ -65,8 +63,8 @@ const products: Product[] = [
variant: 'Variant 4',
price: 39.96,
customDimensions: {
dimension1: 'value1',
dimension2: 'value2'
1: 'value1',
2: 'value2'
}
},
{
Expand All @@ -77,8 +75,8 @@ const products: Product[] = [
variant: 'Variant 5',
price: 49.95,
customDimensions: {
dimension1: 'value1',
dimension2: 'value2'
1: 'value1',
2: 'value2'
}
},
{
Expand All @@ -89,8 +87,8 @@ const products: Product[] = [
variant: 'Variant 6',
price: 59.94,
customDimensions: {
dimension1: 'value1',
dimension2: 'value2'
1: 'value1',
2: 'value2'
}
}
]
Expand Down
3 changes: 3 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ export * as SiteSearch from './services/site-search/site-search.service';
export * as UserManagement from './services/user-management/userManagement.service';
export * as DataLayer from './services/dataLayer/dataLayer.service';

export * from './interfaces/payment';
export * from './interfaces/product';

export default {
initialize: PiwikPro.default.init,
}
4 changes: 3 additions & 1 deletion src/interfaces/product.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { LimitedArrayFiveStrings } from './utils'

type DimensionId = number;

export type Product = {
sku: string,
name?: string,
Expand All @@ -8,5 +10,5 @@ export type Product = {
quantity?: number,
brand?: string,
variant?: string,
customDimensions?: object,
customDimensions?: Record<DimensionId, string>,
}

0 comments on commit c8b47cc

Please sign in to comment.