api#347: передавать и настраивать UTM part без ссылки в Preland
This commit is contained in:
1 parent
94619432a3
commit
0d350ed14b
23 files changed
+126
-47
No files matched your search
@@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
function prelandUtmEnums(): array
|
||||
{
|
||||
return ['theme'=>['1'=>'dark','2'=>'light'], 'reg'=>['1'=>'before','2'=>'after'], 'banch'=>['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'], 'part'=>['1'=>'1','2'=>'2']];
|
||||
}
|
||||
|
||||
/** Совместимость host-config при доставке кода до точечной миграции. */
|
||||
@@ -36,7 +36,7 @@ function prelandNumericUtmConfig(array $config): array
|
||||
function prelandResolveUtm(array $query, array $config): array
|
||||
{
|
||||
$config=prelandNumericUtmConfig($config);
|
||||
$defaults=['indpic'=>'1','theme'=>'2','degr'=>'1','reg'=>'2','banch'=>'2','tp'=>'1','cons'=>'2','focus'=>'1'];
|
||||
$defaults=['indpic'=>'1','theme'=>'2','degr'=>'1','reg'=>'2','banch'=>'2','tp'=>'1','cons'=>'2','focus'=>'1','part'=>'1'];
|
||||
$enums=prelandUtmEnums(); $digits=[]; $context=$query;
|
||||
foreach (['registration','bchoice','chob','chb'] as $old) unset($context[$old]);
|
||||
foreach ($defaults as $key=>$fallback) {
|
||||
@@ -44,7 +44,7 @@ function prelandResolveUtm(array $query, array $config): array
|
||||
$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','banch','focus'],true) || isset($settings['weights'][$digit]));
|
||||
&& (in_array($key,['cons','theme','reg','banch','focus','part'],true) || isset($settings['weights'][$digit]));
|
||||
$default=(string)($settings['default'] ?? $fallback);
|
||||
if (!$valid($default)) $default=$fallback;
|
||||
$value=$query[$key] ?? null;
|
||||
|
||||
Reference in new issue
Block a user