feat: replace chb with consent groups and preserve runtime config (api#317, #17)
deploy-preland / deploy zoomstage.online (push) Successful in 42s
deploy-preland / deploy zoomstage.online (push) Successful in 42s
This commit is contained in:
1 parent
188b78a115
commit
89cc16eb4a
12 files changed
+208
-9
No files matched your search
+12
-1
@@ -72,6 +72,16 @@ $basePickerAccept = 'image/jpeg,image/png,image/gif,image/webp,image/bmp,image/a
|
||||
const utmData = <?= $utmJson ?>;
|
||||
const redirectUrlBase = <?= json_encode($redirectUrlBase, JSON_UNESCAPED_UNICODE) ?>;
|
||||
const redirectUrlUtm = <?= json_encode($redirectUrlUtm, JSON_UNESCAPED_UNICODE) ?>;
|
||||
// Сохранённая до перехода на cons загрузка не должна вернуть legacy chb.
|
||||
const normalizeConsentRedirect = query => {
|
||||
const params = new URLSearchParams(query || '');
|
||||
params.delete('chb');
|
||||
const value = params.get('cons');
|
||||
if (!/^[1-9][0-9]{0,9}$/.test(value || '') || Number(value) > 2147483647) {
|
||||
params.set('cons', String(utmData.cons || '2'));
|
||||
}
|
||||
return params.toString();
|
||||
};
|
||||
const createApiUrl = <?= json_encode($createApiUrl, JSON_UNESCAPED_UNICODE) ?>;
|
||||
const uploadPolicyApiUrl = <?= json_encode($uploadPolicyApiUrl, JSON_UNESCAPED_UNICODE) ?>;
|
||||
|
||||
@@ -202,7 +212,8 @@ $basePickerAccept = 'image/jpeg,image/png,image/gif,image/webp,image/bmp,image/a
|
||||
|
||||
function redirectToTour(record) {
|
||||
let targetUrl = record.meta.redirectBase + encodeURIComponent(record.key);
|
||||
if (record.meta.redirectUtm) targetUrl += '&' + record.meta.redirectUtm;
|
||||
const redirectQuery = normalizeConsentRedirect(record.meta.redirectUtm);
|
||||
if (redirectQuery) targetUrl += '&' + redirectQuery;
|
||||
const shownTheme = window.ZoomzillaTheme.current();
|
||||
targetUrl += '&shown_theme=' + encodeURIComponent(shownTheme);
|
||||
window.PublicNavigationGuard.allowNavigation(() => { window.location.href = targetUrl; });
|
||||
|
||||
Reference in new issue
Block a user