pb-sxp-ui 1.15.32 → 1.15.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +10 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -37
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +4 -4
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +4 -4
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +10 -37
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +4 -4
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/context/SxpDataSourceProvider.js +8 -31
- package/lib/core/context/SxpDataSourceProvider.js +8 -31
- package/package.json +1 -1
@@ -49,6 +49,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
49
49
|
const [playbookType, setPlaybookType] = useState();
|
50
50
|
const [chatlabsId, setChatlabsId] = useState();
|
51
51
|
const finalPageData = useMemo(() => pageData !== null && pageData !== void 0 ? pageData : data, [pageData, data]);
|
52
|
+
const pixelPvStatusRef = useRef(false);
|
52
53
|
const isShowConsent = useMemo(() => {
|
53
54
|
var _a, _b, _c, _d;
|
54
55
|
return (((((_d = (_c = (_b = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.consent) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.item) === null || _c === void 0 ? void 0 : _c.props) === null || _d === void 0 ? void 0 : _d.privacy_necessity) && !isAgreePolicy && !isEditor) || isOpenConsent) &&
|
@@ -105,7 +106,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
105
106
|
return ((_a = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _a === void 0 ? void 0 : _a['x-app-id']) + storeAndLoadFeUserId();
|
106
107
|
}, [bffDataSource]);
|
107
108
|
const bffFetch = useCallback((path, options) => {
|
108
|
-
var _a
|
109
|
+
var _a;
|
109
110
|
if (!bffDataSource)
|
110
111
|
return;
|
111
112
|
const url = bffDataSource.url;
|
@@ -113,7 +114,6 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
113
114
|
const queryString = qs.stringify(options.query);
|
114
115
|
path = `${path}?${queryString}`;
|
115
116
|
}
|
116
|
-
let isTikTokChannel = false;
|
117
117
|
const params = {};
|
118
118
|
const queryString = location.search.slice(1);
|
119
119
|
(_a = splitUrlParams(queryString)) === null || _a === void 0 ? void 0 : _a.forEach((val) => {
|
@@ -121,39 +121,12 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
121
121
|
const value = val.split('=')[1];
|
122
122
|
params[key] = value;
|
123
123
|
});
|
124
|
-
const cl_source = params === null || params === void 0 ? void 0 : params.cl_source;
|
125
|
-
if (cl_source &&
|
126
|
-
((_b = [
|
127
|
-
'40A-SPRK--DRESS_EYEWEAR-',
|
128
|
-
'41A-SPRK--MADRAGUE-',
|
129
|
-
'42A-SPRK--MOOD-',
|
130
|
-
'43A-SPRK--SUMMER-',
|
131
|
-
'44A-SPRK--DRESS_EYEWEAR-',
|
132
|
-
'45A-SPRK--MADRAGUE-',
|
133
|
-
'46A-SPRK--MOOD-',
|
134
|
-
'47A-SPRK--SUMMER-',
|
135
|
-
'48A-SPRK--DRESS_EYEWEAR-',
|
136
|
-
'49A-SPRK--MADRAGUE-',
|
137
|
-
'50A-SPRK--MOOD-',
|
138
|
-
'51A-SPRK--SUMMER-'
|
139
|
-
]) === null || _b === void 0 ? void 0 : _b.includes(cl_source))) {
|
140
|
-
isTikTokChannel = true;
|
141
|
-
}
|
142
|
-
if (options.type === 'beacon' && navigator.sendBeacon && !isTikTokChannel) {
|
143
|
-
return navigator.sendBeacon(`${url}/api/${path}`, new Blob([
|
144
|
-
JSON.stringify({
|
145
|
-
body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
|
146
|
-
})
|
147
|
-
], {
|
148
|
-
type: 'application/json;charset=UTF-8'
|
149
|
-
}));
|
150
|
-
}
|
151
124
|
return window
|
152
|
-
.fetch(`${url}/api/${path}`, Object.assign({ headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId }, bffDataSource.headers), method: options.method, body:
|
125
|
+
.fetch(`${url}/api/${path}`, Object.assign({ headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId }, bffDataSource.headers), method: options.method, body: options.type === 'beacon'
|
153
126
|
? JSON.stringify({
|
154
127
|
body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
|
155
128
|
})
|
156
|
-
: JSON.stringify(options.body) }, (
|
129
|
+
: JSON.stringify(options.body) }, (options.type === 'beacon' && { keepalive: true })))
|
157
130
|
.then((res) => res.json())
|
158
131
|
.catch((err) => Promise.reject(err));
|
159
132
|
}, [bffDataSource, fakeUserId]);
|
@@ -397,6 +370,10 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
397
370
|
}
|
398
371
|
}
|
399
372
|
if (eventName === 'PageView' && (pixelEventParamsJson === null || pixelEventParamsJson === void 0 ? void 0 : pixelEventParamsJson.event_name) === 'PageView') {
|
373
|
+
if (!pixelPvStatusRef.current) {
|
374
|
+
pixelPvStatusRef.current = true;
|
375
|
+
return;
|
376
|
+
}
|
400
377
|
const currentUrl = window.location.href;
|
401
378
|
const newUrl = updateQueryStringParameter(currentUrl, 'timestamp', Date.now());
|
402
379
|
history.pushState({ path: newUrl }, '', newUrl);
|
@@ -52,6 +52,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
52
52
|
const [playbookType, setPlaybookType] = (0, react_1.useState)();
|
53
53
|
const [chatlabsId, setChatlabsId] = (0, react_1.useState)();
|
54
54
|
const finalPageData = (0, react_1.useMemo)(() => pageData !== null && pageData !== void 0 ? pageData : data, [pageData, data]);
|
55
|
+
const pixelPvStatusRef = (0, react_1.useRef)(false);
|
55
56
|
const isShowConsent = (0, react_1.useMemo)(() => {
|
56
57
|
var _a, _b, _c, _d;
|
57
58
|
return (((((_d = (_c = (_b = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.consent) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.item) === null || _c === void 0 ? void 0 : _c.props) === null || _d === void 0 ? void 0 : _d.privacy_necessity) && !isAgreePolicy && !isEditor) || isOpenConsent) &&
|
@@ -108,7 +109,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
108
109
|
return ((_a = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _a === void 0 ? void 0 : _a['x-app-id']) + (0, localStore_1.storeAndLoadFeUserId)();
|
109
110
|
}, [bffDataSource]);
|
110
111
|
const bffFetch = (0, react_1.useCallback)((path, options) => {
|
111
|
-
var _a
|
112
|
+
var _a;
|
112
113
|
if (!bffDataSource)
|
113
114
|
return;
|
114
115
|
const url = bffDataSource.url;
|
@@ -116,7 +117,6 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
116
117
|
const queryString = qs_1.default.stringify(options.query);
|
117
118
|
path = `${path}?${queryString}`;
|
118
119
|
}
|
119
|
-
let isTikTokChannel = false;
|
120
120
|
const params = {};
|
121
121
|
const queryString = location.search.slice(1);
|
122
122
|
(_a = (0, tool_1.splitUrlParams)(queryString)) === null || _a === void 0 ? void 0 : _a.forEach((val) => {
|
@@ -124,39 +124,12 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
124
124
|
const value = val.split('=')[1];
|
125
125
|
params[key] = value;
|
126
126
|
});
|
127
|
-
const cl_source = params === null || params === void 0 ? void 0 : params.cl_source;
|
128
|
-
if (cl_source &&
|
129
|
-
((_b = [
|
130
|
-
'40A-SPRK--DRESS_EYEWEAR-',
|
131
|
-
'41A-SPRK--MADRAGUE-',
|
132
|
-
'42A-SPRK--MOOD-',
|
133
|
-
'43A-SPRK--SUMMER-',
|
134
|
-
'44A-SPRK--DRESS_EYEWEAR-',
|
135
|
-
'45A-SPRK--MADRAGUE-',
|
136
|
-
'46A-SPRK--MOOD-',
|
137
|
-
'47A-SPRK--SUMMER-',
|
138
|
-
'48A-SPRK--DRESS_EYEWEAR-',
|
139
|
-
'49A-SPRK--MADRAGUE-',
|
140
|
-
'50A-SPRK--MOOD-',
|
141
|
-
'51A-SPRK--SUMMER-'
|
142
|
-
]) === null || _b === void 0 ? void 0 : _b.includes(cl_source))) {
|
143
|
-
isTikTokChannel = true;
|
144
|
-
}
|
145
|
-
if (options.type === 'beacon' && navigator.sendBeacon && !isTikTokChannel) {
|
146
|
-
return navigator.sendBeacon(`${url}/api/${path}`, new Blob([
|
147
|
-
JSON.stringify({
|
148
|
-
body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
|
149
|
-
})
|
150
|
-
], {
|
151
|
-
type: 'application/json;charset=UTF-8'
|
152
|
-
}));
|
153
|
-
}
|
154
127
|
return window
|
155
|
-
.fetch(`${url}/api/${path}`, Object.assign({ headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId }, bffDataSource.headers), method: options.method, body:
|
128
|
+
.fetch(`${url}/api/${path}`, Object.assign({ headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId }, bffDataSource.headers), method: options.method, body: options.type === 'beacon'
|
156
129
|
? JSON.stringify({
|
157
130
|
body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
|
158
131
|
})
|
159
|
-
: JSON.stringify(options.body) }, (
|
132
|
+
: JSON.stringify(options.body) }, (options.type === 'beacon' && { keepalive: true })))
|
160
133
|
.then((res) => res.json())
|
161
134
|
.catch((err) => Promise.reject(err));
|
162
135
|
}, [bffDataSource, fakeUserId]);
|
@@ -400,6 +373,10 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
400
373
|
}
|
401
374
|
}
|
402
375
|
if (eventName === 'PageView' && (pixelEventParamsJson === null || pixelEventParamsJson === void 0 ? void 0 : pixelEventParamsJson.event_name) === 'PageView') {
|
376
|
+
if (!pixelPvStatusRef.current) {
|
377
|
+
pixelPvStatusRef.current = true;
|
378
|
+
return;
|
379
|
+
}
|
403
380
|
const currentUrl = window.location.href;
|
404
381
|
const newUrl = updateQueryStringParameter(currentUrl, 'timestamp', Date.now());
|
405
382
|
history.pushState({ path: newUrl }, '', newUrl);
|