Skip to content

Commit dcc8fb8

Browse files
@W-17405592 - DataCloud Events in PWA (#2229)
* initial * Add Datacloud Typescript sdk * datacloud * Send Datacloud events for PLP and ProductImpressions * initial * Add Datacloud Typescript sdk * datacloud * Send Datacloud events for PLP and ProductImpressions * Update site and add in pages for catalog events * Update use-datacloud.js * error handling update * Update package.json * add unit test for usedatacloud hook * add all unit tests * lint * update retail app package-lock * fix retail app jest tests * revert lock file changes * update package lock * revert package-lock changes * revert package lock changes * Update Changelog * revert all package-lock changes * lint * update retail package lock * resolve generated project lint errors * fix datacloud eventtype * add customer no to registered customers * surface datacloud config values in generator script * fix typo * update constructdatacloudproduct * add block comments to all methods * push datacloud hook changes * lint * remove contactpointemail from pageview event * update mock data * lint * move sdk initialization to constructor * DRY code * move datacloud mock data to mocks module * fix syntax error * Cleanup * update dnt behavior based on new guidelines * log error and pass config as args * lint * if DNT, do not send identity profile event * bump bundle size max * update deviceid and sessionid values * usecurrentcustomer for customerid * use js-cookie Cookies * fix tests * reduce bundle size --------- Signed-off-by: Yuna Kim <84923642+yunakim714@users.noreply.github.com> Co-authored-by: yunakim714 <yunakim@salesforce.com> Co-authored-by: Yuna Kim <84923642+yunakim714@users.noreply.github.com>
1 parent 0173f8d commit dcc8fb8

File tree

27 files changed

+1187
-13
lines changed

27 files changed

+1187
-13
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@
3838
"dependencies": {
3939
"node-fetch": "^2.6.9"
4040
}
41-
}
41+
}

packages/pwa-kit-create-app/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## v3.9.0-dev (Oct 29, 2024)
22
- Support Node 22 [#2218](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2218)
33
- Update `default.js` template to include new login configurations [#2079] (https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2079)
4+
- Add Data Cloud API configuration to `default.js`. [#2229] (https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2229)
45

56
## v3.8.0 (Oct 28, 2024)
67

packages/pwa-kit-create-app/assets/bootstrap/js/config/default.js.hbs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ module.exports = {
4444
// By setting this to true, the Einstein activities generated by the environment will appear
4545
// in production environment reports
4646
isProduction: false
47+
},
48+
// Datacloud api config
49+
dataCloudAPI: {
50+
appSourceId: '{{answers.project.dataCloud.appSourceId}}',
51+
tenantId: '{{answers.project.dataCloud.tenantId}}'
4752
}
4853
},
4954
// This list contains server-side only libraries that you don't want to be compiled by webpack

packages/pwa-kit-create-app/assets/bootstrap/js/overrides/app/ssr.js.hbs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ const {handler} = runtime.createHandler(options, (app) => {
6868
],
6969
'connect-src': [
7070
// Connect to Einstein APIs
71-
'api.cquotient.com'
71+
'api.cquotient.com',
72+
'*.c360a.salesforce.com'
7273
]
7374
}
7475
}

packages/pwa-kit-create-app/assets/templates/@salesforce/retail-react-app/app/ssr.js.hbs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ const {handler} = runtime.createHandler(options, (app) => {
6868
],
6969
'connect-src': [
7070
// Connect to Einstein APIs
71-
'api.cquotient.com'
71+
'api.cquotient.com',
72+
'*.c360a.salesforce.com'
7273
]
7374
}
7475
}

packages/pwa-kit-create-app/assets/templates/@salesforce/retail-react-app/config/default.js.hbs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ module.exports = {
7373
// By setting this to true, the Einstein activities generated by the environment will appear
7474
// in production environment reports
7575
isProduction: false
76+
},
77+
// Datacloud api config
78+
dataCloudAPI: {
79+
appSourceId: '{{answers.project.dataCloud.appSourceId}}',
80+
tenantId: '{{answers.project.dataCloud.tenantId}}'
7681
}
7782
},
7883
// This list contains server-side only libraries that you don't want to be compiled by webpack

packages/pwa-kit-create-app/scripts/create-mobify-app.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ const RETAIL_REACT_APP_QUESTIONS = [
219219
}
220220
]
221221

222-
// Project dictionary describing details and how the gerator should ask questions etc.
222+
// Project dictionary describing details and how the generator should ask questions etc.
223223
const PRESETS = [
224224
{
225225
id: 'retail-react-app',
@@ -265,7 +265,9 @@ const PRESETS = [
265265
['project.commerce.shortCode']: 'kv7kzm78',
266266
['project.commerce.isSlasPrivate']: false,
267267
['project.einstein.clientId']: '1ea06c6e-c936-4324-bcf0-fada93f83bb1',
268-
['project.einstein.siteId']: 'aaij-MobileFirst'
268+
['project.einstein.siteId']: 'aaij-MobileFirst',
269+
['project.dataCloud.appSourceId']: '10a761d0-5d19-41fa-8681-0591d5884e27',
270+
['project.dataCloud.tenantId']: 'g43g8zrvh1ytcztdmmzg8m3dh1'
269271
},
270272
assets: ['translations'],
271273
private: false
@@ -290,7 +292,9 @@ const PRESETS = [
290292
['project.commerce.shortCode']: 'kv7kzm78',
291293
['project.commerce.isSlasPrivate']: false,
292294
['project.einstein.clientId']: '1ea06c6e-c936-4324-bcf0-fada93f83bb1',
293-
['project.einstein.siteId']: 'aaij-MobileFirst'
295+
['project.einstein.siteId']: 'aaij-MobileFirst',
296+
['project.dataCloud.appSourceId']: '10a761d0-5d19-41fa-8681-0591d5884e27',
297+
['project.dataCloud.tenantId']: 'g43g8zrvh1ytcztdmmzg8m3dh1'
294298
},
295299
assets: ['translations'],
296300
private: true
@@ -315,7 +319,9 @@ const PRESETS = [
315319
['project.commerce.shortCode']: 'kv7kzm78',
316320
['project.commerce.isSlasPrivate']: true,
317321
['project.einstein.clientId']: '1ea06c6e-c936-4324-bcf0-fada93f83bb1',
318-
['project.einstein.siteId']: 'aaij-MobileFirst'
322+
['project.einstein.siteId']: 'aaij-MobileFirst',
323+
['project.dataCloud.appSourceId']: '10a761d0-5d19-41fa-8681-0591d5884e27',
324+
['project.dataCloud.tenantId']: 'g43g8zrvh1ytcztdmmzg8m3dh1'
319325
},
320326
assets: ['translations'],
321327
private: true
@@ -340,7 +346,9 @@ const PRESETS = [
340346
['project.commerce.shortCode']: 'xitgmcd3',
341347
['project.einstein.clientId']: '1ea06c6e-c936-4324-bcf0-fada93f83bb1',
342348
['project.einstein.siteId']: 'aaij-MobileFirst',
343-
['project.commerce.isSlasPrivate']: true
349+
['project.commerce.isSlasPrivate']: true,
350+
['project.dataCloud.appSourceId']: '10a761d0-5d19-41fa-8681-0591d5884e27',
351+
['project.dataCloud.tenantId']: 'g43g8zrvh1ytcztdmmzg8m3dh1'
344352
},
345353
assets: ['translations'],
346354
private: true
@@ -365,7 +373,9 @@ const PRESETS = [
365373
['project.commerce.shortCode']: 'performance-001',
366374
['project.einstein.clientId']: '1ea06c6e-c936-4324-bcf0-fada93f83bb1',
367375
['project.einstein.siteId']: 'aaij-MobileFirst',
368-
['project.commerce.isSlasPrivate']: false
376+
['project.commerce.isSlasPrivate']: false,
377+
['project.dataCloud.appSourceId']: '10a761d0-5d19-41fa-8681-0591d5884e27',
378+
['project.dataCloud.tenantId']: 'g43g8zrvh1ytcztdmmzg8m3dh1'
369379
},
370380
assets: ['translations'],
371381
private: true

packages/template-retail-react-app/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## v6.1.0-dev
2+
- Send PWA Kit events to Data Cloud [#2229] (https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2229)
3+
14
## v6.0.0
25
- DNT Consent Banner: [#2203](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2203)
36
- Implemented opt-in Social & Passwordless Login features and fixed the Reset Password flow which now leverages SLAS APIs [#2079] (https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2079)

packages/template-retail-react-app/app/components/recommended-products/index.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {useIntl} from 'react-intl'
1111
import {Button} from '@salesforce/retail-react-app/app/components/shared/ui'
1212
import ProductScroller from '@salesforce/retail-react-app/app/components/product-scroller'
1313
import useEinstein from '@salesforce/retail-react-app/app/hooks/use-einstein'
14+
import useDatacloud from '@salesforce/retail-react-app/app/hooks/use-datacloud'
1415
import {useCurrentCustomer} from '@salesforce/retail-react-app/app/hooks/use-current-customer'
1516
import useIntersectionObserver from '@salesforce/retail-react-app/app/hooks/use-intersection-observer'
1617
import {useWishList} from '@salesforce/retail-react-app/app/hooks/use-wish-list'
@@ -41,6 +42,7 @@ const RecommendedProducts = ({zone, recommender, products, title, shouldFetch, .
4142
const {data: customer} = useCurrentCustomer()
4243
const {customerId} = customer
4344
const {data: wishlist} = useWishList()
45+
const datacloud = useDatacloud()
4446

4547
const createCustomerProductListItem = useShopperCustomersMutation(
4648
'createCustomerProductListItem'
@@ -98,6 +100,13 @@ const RecommendedProducts = ({zone, recommender, products, title, shouldFetch, .
98100
},
99101
recommendations.recs.map((rec) => ({id: rec.id}))
100102
)
103+
datacloud.sendViewRecommendations(
104+
{
105+
recommenderName: recommendations.recommenderName,
106+
__recoUUID: recommendations.recoUUID
107+
},
108+
recommendations.recs.map((rec) => ({id: rec.id}))
109+
)
101110
}
102111
}, [isOnScreen, recommendations])
103112

0 commit comments

Comments
 (0)