api#326 Числовые UTM и новый шум каждого перехода
This commit is contained in:
1 parent
f30742c2fb
commit
81e189ca67
16 files changed
+303
-160
No files matched your search
+4
-14
@@ -3,9 +3,9 @@ require_once __DIR__ . '/browser-upload.php';
|
||||
require __DIR__ . '/upload-error.php';
|
||||
echo '<script>', require __DIR__ . '/navigation-guard.php', '</script>';
|
||||
echo '<script>', require __DIR__ . '/upload-recovery.php', '</script>';
|
||||
echo '<script>', require __DIR__ . '/utm-handoff.php', '</script>';
|
||||
|
||||
$errorMessage = Yii::t('app', 'Возникла ошибка');
|
||||
$utmJson = json_encode($UTM ?? [], JSON_UNESCAPED_UNICODE);
|
||||
|
||||
$createApiUrl = ($apiHost ?? '') . '/api/images/public/create';
|
||||
$uploadPolicyApiUrl = ($apiHost ?? '') . '/api/images/public/upload-policy';
|
||||
@@ -70,19 +70,9 @@ $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 utmDigits = <?= json_encode($redirect_digits ?? [], JSON_UNESCAPED_UNICODE) ?>;
|
||||
const createApiUrl = <?= json_encode($createApiUrl, JSON_UNESCAPED_UNICODE) ?>;
|
||||
const uploadPolicyApiUrl = <?= json_encode($uploadPolicyApiUrl, JSON_UNESCAPED_UNICODE) ?>;
|
||||
|
||||
@@ -118,7 +108,7 @@ $basePickerAccept = 'image/jpeg,image/png,image/gif,image/webp,image/bmp,image/a
|
||||
let leavingUploadPage = false;
|
||||
let uploadAttempt = 0;
|
||||
const recovery = window.ZoomzillaUploadRecovery.create({scope: 'preland', target: createApiUrl});
|
||||
const metadata = () => ({actionUrl: createApiUrl, redirectBase: redirectUrlBase, redirectUtm: redirectUrlUtm});
|
||||
const metadata = () => ({actionUrl: createApiUrl, redirectBase: redirectUrlBase, redirectUtm: redirectUrlUtm, utmDigits: {...utmDigits}});
|
||||
const clearRecovery = () => recovery.clear().catch(() => {});
|
||||
let uploadDots = 1;
|
||||
let uploadDotsTimer = null;
|
||||
@@ -213,7 +203,7 @@ $basePickerAccept = 'image/jpeg,image/png,image/gif,image/webp,image/bmp,image/a
|
||||
|
||||
function redirectToTour(record) {
|
||||
let targetUrl = record.meta.redirectBase + encodeURIComponent(record.key);
|
||||
const redirectQuery = normalizeConsentRedirect(record.meta.redirectUtm);
|
||||
const redirectQuery = window.ZoomzillaUtmHandoff.query(record.meta, utmDigits);
|
||||
if (redirectQuery) targetUrl += '&' + redirectQuery;
|
||||
const shownTheme = window.ZoomzillaTheme.current();
|
||||
targetUrl += '&shown_theme=' + encodeURIComponent(shownTheme);
|
||||
|
||||
Reference in new issue
Block a user