feat(admin): независимые именованные UTM-наборы
This commit is contained in:
1 parent
941a4f01aa
commit
94619432a3
16 files changed
+220
-114
No files matched your search
@@ -0,0 +1,8 @@
|
||||
// Источник старых регрессий заменён независимым UTM-снимком. Доменные поля в POST не передаются.
|
||||
module.exports=async function choosePreset(page,id){
|
||||
const state=await page.request.get('/api/state').then(r=>r.json());
|
||||
const read=await page.request.get('/api/config?target='+id).then(r=>r.json()),utm={};
|
||||
for(const marker of ['indpic','theme','degr','reg','banch','tp','cons','focus']){const aliases=marker==='reg'?['reg','registration']:marker==='banch'?['banch','chob','bchoice']:[marker];const key=aliases.find(k=>Object.hasOwn(read.config.utm||{},k));if(key)utm[marker]={default:read.config.utm[key].default,weights:read.config.utm[key].weights};}
|
||||
const response=await page.request.post('/api/utm-presets',{headers:{'X-CSRF-Token':state.csrf},data:{name:'UI-'+Date.now()+'-'+Math.random(),utm}}),saved=await response.json();
|
||||
if(!saved.ok)throw Error(saved.error);await page.locator('#preset-reload').click();await page.waitForFunction(id=>[...document.querySelector('#copy-source').options].some(o=>o.value===id),saved.preset.id);await page.locator('#copy-source').selectOption(saved.preset.id);return saved.preset.id;
|
||||
};
|
||||
Reference in new issue
Block a user