fix(utm): заменить публичную chob на banch (#327)
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
08febba368
commit
965eb2e6a5
12 files changed
+58
-33
No files matched your search
@@ -4,14 +4,14 @@ declare(strict_types=1);
|
||||
|
||||
function prelandUtmEnums(): array
|
||||
{
|
||||
return ['theme'=>['1'=>'dark','2'=>'light'], 'reg'=>['1'=>'before','2'=>'after'], 'chob'=>['1'=>'b','2'=>'a'], 'focus'=>['1'=>'face','2'=>'center']];
|
||||
return ['theme'=>['1'=>'dark','2'=>'light'], 'reg'=>['1'=>'before','2'=>'after'], 'banch'=>['1'=>'b','2'=>'a'], 'focus'=>['1'=>'face','2'=>'center']];
|
||||
}
|
||||
|
||||
/** Совместимость host-config при доставке кода до точечной миграции. */
|
||||
function prelandNumericUtmConfig(array $config): array
|
||||
{
|
||||
$settings = is_array($config['utm'] ?? null) ? $config['utm'] : [];
|
||||
foreach (['registration'=>'reg','bchoice'=>'chob'] as $old=>$new) {
|
||||
foreach (['registration'=>'reg','chob'=>'banch','bchoice'=>'banch'] as $old=>$new) {
|
||||
if (!isset($settings[$new]) && isset($settings[$old])) $settings[$new] = $settings[$old];
|
||||
unset($settings[$old]);
|
||||
}
|
||||
@@ -36,15 +36,15 @@ function prelandNumericUtmConfig(array $config): array
|
||||
function prelandResolveUtm(array $query, array $config): array
|
||||
{
|
||||
$config=prelandNumericUtmConfig($config);
|
||||
$defaults=['indpic'=>'1','theme'=>'2','degr'=>'1','reg'=>'2','chob'=>'2','tp'=>'1','cons'=>'2','focus'=>'1'];
|
||||
$defaults=['indpic'=>'1','theme'=>'2','degr'=>'1','reg'=>'2','banch'=>'2','tp'=>'1','cons'=>'2','focus'=>'1'];
|
||||
$enums=prelandUtmEnums(); $digits=[]; $context=$query;
|
||||
foreach (['registration','bchoice','chb'] as $old) unset($context[$old]);
|
||||
foreach (['registration','bchoice','chob','chb'] as $old) unset($context[$old]);
|
||||
foreach ($defaults as $key=>$fallback) {
|
||||
unset($context[$key]);
|
||||
$settings=$config['utm'][$key] ?? [];
|
||||
$valid=static fn($digit): bool => preg_match('/^[1-9]$/D',(string)$digit)===1
|
||||
&& (!isset($enums[$key]) || isset($enums[$key][$digit]))
|
||||
&& (in_array($key,['cons','theme','reg','chob','focus'],true) || isset($settings['weights'][$digit]));
|
||||
&& (in_array($key,['cons','theme','reg','banch','focus'],true) || isset($settings['weights'][$digit]));
|
||||
$default=(string)($settings['default'] ?? $fallback);
|
||||
if (!$valid($default)) $default=$fallback;
|
||||
$value=$query[$key] ?? null;
|
||||
@@ -81,7 +81,7 @@ function prelandResolveUtm(array $query, array $config): array
|
||||
}
|
||||
if (!$valid($digit ?? '')) $digit=$default;
|
||||
$digits[$key]=$digit;
|
||||
$internal=['reg'=>'registration','chob'=>'bchoice'][$key] ?? $key;
|
||||
$internal=['reg'=>'registration','banch'=>'bchoice'][$key] ?? $key;
|
||||
$context[$internal]=$enums[$key][$digit] ?? $digit;
|
||||
}
|
||||
return ['digits'=>$digits,'context'=>$context];
|
||||
|
||||
Reference in new issue
Block a user