PageSourceSearch

https://app.sellermate.ai/assets/amc-custom-attribution-MtG_CI2E.js

js sellermate.ai collected 2026-10-05 12:36:33 UTC 9,934 bytes, 1 lines download raw bytes

1import{y as e,x as nt,cE as it,j as t,T as j,B as y,N as Q,f0 as tt,b as V,u as rt,c as lt,X as ct}from"./index-Ypozs0vX.js";import"./index-Za-nke9D.js";import{R as pt}from"./ReportTables-nKUesL88.js";import{S as et}from"./index-011gqqKf.js";import"./constants-lGGiuA6w.js";import{H as dt}from"./index-Nz0VxxO9.js";import{C as ut}from"./chip-tab-selector-9nFZxSGY.js";import{E as mt}from"./pill-select-sx-7TKH6sCK.js";import{c as q,u as gt,a as St,g as ht,b as ft}from"./custom-attribution-lhJpYSKn.js";import{u as xt,I as Ct,d as vt}from"./export-csv-03PJnov3.js";import{u as At,s as bt}from"./path-to-conversion-lqSqXXF3.js";import{C as jt}from"./index-NPnseDS0.js";import{D as yt}from"./index-2JRCa3Yw.js";import{M as Mt,f as Lt}from"./month-select-xWluIrgE.js";import{c as st,b as wt,d as It}from"./account-JysxOWce.js";import"./react-error-boundary.esm-HIhRa8BR.js";import"./DataGridPro-zl3cM6FL.js";import"./index-Ul3OjKpc.js";import"./useGridApiContext-ZQgV-IKW.js";import"./Checkbox-HJ3IUwy4.js";import"./SwitchBase-qvPxkoHk.js";import"./Skeleton--t-Z7OgK.js";import"./LinearProgress-r-h_7pxb.js";import"./FirstPage-wgytJ0r_.js";import"./TableCell-ZTG1gmDP.js";import"./FormControlLabel-giL-2lEN.js";import"./useThemeProps-ERKQ9jSZ.js";import"./date-range-picker-SEPrxtX4.js";import"./Switch-FpMGFEqp.js";import"./currency-symbol--NGSXlcy.js";import"./AutoAwesome-gdfomUyY.js";import"./Dashboard-_g65tsM9.js";import"./InfoOutlined-rLFmhss_.js";import"./FileDownloadOutlined-S21bDIo3.js";import"./amc-endpoints-EsoDI8FV.js";import"./KeyboardArrowDown-hgyBospT.js";import"./ContentCopy-0ND6HgJS.js";import"./Check-etZc4D-6.js";import"./DatePicker-d_Rle9-N.js";import"./refType-XE2PmDF1.js";import"./ImportantNoteDialog-hVj9-yJH.js";import"./usePortfolioList-kRw9ht9y.js";import"./useCampaign-n3KeSJTP.js";import"./useQuery-QZOsBHtM.js";import"./ModularFilterSelect-dgm5Jz9F.js";import"./Search-4O5dMA_A.js";import"./date-range-picker-field-DN_viYNb.js";import"./Event-fF8QT8-Z.js";import"./useGridApiRef-wrqM6ZeV.js";import"./index-YXW0eYuP.js";const X={selectedSaCampaignIds:[],selectedDspOrderIds:[],activeTotal:0,activeSaCount:0,activeDspCount:0,overCap:!1,cap:5e3};function Tt(l){const[h,g]=e.useState(X),[n,f]=e.useState(!1),[T,M]=e.useState(!1),o=e.useCallback(async()=>{if(l){f(!0);try{const s=await q.getCustomAttributionSelection();g({...X,...(s==null?void 0:s.data)??{}})}catch{g(X)}finally{f(!1)}}},[l]);e.useEffect(()=>{o()},[o]);const c=e.useCallback(async(s,x)=>{var i,m;M(!0);try{return await q.saveCustomAttributionSelection({selectedSaCampaignIds:s,selectedDspOrderIds:x}),await o(),{ok:!0}}catch(p){return{ok:!1,error:((m=(i=p==null?void 0:p.response)==null?void 0:i.data)==null?void 0:m.message)||"Failed to save campaign selection"}}finally{M(!1)}},[o]);return{selection:h,isLoading:n,saving:T,refetch:o,save:c}}function Et({accountId:l,countryCode:h,currencyCode:g,selection:n,saving:f,onSave:T}){const M=nt(),o=it(),c=n.cap||5e3,[s,x]=e.useState([]),[i,m]=e.useState([]),[p,E]=e.useState(!1),[D,O]=e.useState(!1),[R,d]=e.useState(null),[P,C]=e.useState(!1),z=e.useRef([]);e.useEffect(()=>{x(n.selectedSaCampaignIds||[]),m(n.selectedDspOrderIds||[])},[n]);const v=s.length+i.length,w=v>c,I=!!n.updatedAt,H=n.selectedSaCampaignIds||[],$=n.selectedDspOrderIds||[],B=(r,u)=>r.length===u.length&&[...r].sort().join(",")===[...u].sort().join(","),_=!B(s,H)||!B(i,$);e.useEffect(()=>{d(null)},[s,i]);const U=()=>{var r,u,A,b;z.current=((b=(A=(u=(r=o.getState())==null?void 0:r.app)==null?void 0:u.dspCampaignFilter)==null?void 0:A[l])==null?void 0:b.orderIds)??[],M(tt({amazonAccountId:l,orderIds:i})),O(!0)},W=()=>{var u,A,b,k;const r=((k=(b=(A=(u=o.getState())==null?void 0:u.app)==null?void 0:A.dspCampaignFilter)==null?void 0:b[l])==null?void 0:k.orderIds)??i;m(r),M(tt({amazonAccountId:l,orderIds:z.current})),O(!1)},N=async()=>{d(null),C(!1);const r=await T(s,i);r.ok?C(!0):d(r.error||"Failed to save")},L=r=>t.jsxs(y,{sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"wrap"},children:[t.jsxs(V,{size:"small",variant:"outlined",onClick:()=>E(!0),children:["Sponsored Ads Campaigns (",s.length.toLocaleStr
1ing()," / ",c.toLocaleString(),")"]}),n.activeDspCount>0&&t.jsxs(V,{size:"small",variant:"outlined",onClick:U,children:["DSP Campaigns (",i.length.toLocaleString(),")"]}),r&&t.jsx(V,{size:"small",variant:"contained",onClick:N,disabled:f||v===0||w,children:f?"Saving…":"Save selection"})]}),F=t.jsxs(t.Fragment,{children:[v===0&&t.jsx(j,{variant:"caption",color:"error",children:"Select at least one campaign to run Custom Attribution."}),w&&t.jsxs(j,{variant:"caption",color:"error",children:["Remove ",(v-c).toLocaleString()," to get under the ",c.toLocaleString()," limit."]}),P&&!_&&!w&&t.jsx(j,{variant:"caption",color:"success.main",children:"Saved — the next Custom Attribution sync will use these campaigns."}),R&&t.jsx(j,{variant:"caption",color:"error",children:R})]});return t.jsxs(y,{sx:{mb:2},children:[I?t.jsxs(Q,{severity:"success",sx:{alignItems:"center"},action:L(_),children:[t.jsxs(j,{variant:"caption",color:"text.secondary",sx:{fontWeight:600},children:["Custom Attribution runs on ",v.toLocaleString()," selected campaign",v===1?"":"s"," (of ",c.toLocaleString()," max)."]}),(_||P||R)&&t.jsx(y,{sx:{mt:1,display:"flex",gap:1.5,flexWrap:"wrap"},children:F})]}):t.jsxs(Q,{severity:w?"error":"warning",sx:{alignItems:"center"},action:L(!0),children:[t.jsxs(j,{variant:"body2",sx:{fontWeight:600},children:["This account has ",n.activeTotal.toLocaleString()," active campaigns — more than the ",c.toLocaleString()," Custom Attribution supports."]}),t.jsxs(j,{variant:"caption",color:"text.secondary",children:["Select up to ",c.toLocaleString()," campaigns to run Custom Attribution. Reports stay paused until a selection is saved."]}),t.jsx(y,{sx:{mt:1,display:"flex",gap:1.5,flexWrap:"wrap"},children:F})]}),p&&t.jsx(jt,{open:p,handleClose:()=>E(!1),amazonAccountId:l,countryCode:h,currencyCode:g,selectedCampaignList_:s,setSelectedCampaignList_:x,campaignSelectionLimit:Math.max(0,c-i.length),bulkCampaignSelector:!0}),D&&t.jsx(yt,{open:D,handleClose:W,amazonAccountId:l,currencyCode:g,countryCode:h})]})}const ot=[{field:"conversions",sort:"desc"}],Z=[{value:"LAST_TOUCH",label:"Last Touch",tooltip:"100% credit to the most recent touchpoint before purchase"},{value:"FIRST_TOUCH",label:"First Touch",tooltip:"100% credit to the earliest touchpoint"},{value:"LINEAR",label:"Linear",tooltip:"credit split equally across every touched campaign"},{value:"POSITION",label:"Position 30/70",tooltip:"30% to the first touch, 70% to the last"}];function we(){var u,A,b,k,Y;const l=rt(lt),h=((u=l.selectedAmazonAccount)==null?void 0:u.countryCode)||"US",g=((A=l.selectedAmazonAccount)==null?void 0:A.currencyCode)||"USD",n=((b=l.selectedAmazonAccount)==null?void 0:b._id)||"",{selection:f,saving:T,save:M}=Tt(n),[o,c]=e.useState("LAST_TOUCH"),[s,x]=e.useState(""),[i,m]=e.useState({page:0,pageSize:st}),[p,E]=e.useState(ot),[D,O]=e.useState({items:[]}),{instances:R,instanceId:d,setInstanceId:P}=xt(),{months:C,isLoading:z}=gt(d);e.useEffect(()=>{if(!C.length){x("");return}x(a=>a&&C.includes(a)?a:C[0])},[C]),e.useEffect(()=>{m(a=>({...a,page:0})),E(ot),O({items:[]})},[o,s,d]);const{data:v,total:w,totals:I,isLoading:H}=St({model:o,month:s,page:i.page,pageSize:i.pageSize,sortModel:p,filterModel:D,instanceId:d}),$=e.useMemo(()=>ht(g,h),[g,h]),B=e.useMemo(()=>I?{id:"TOTAL",campaign:"Total",...I}:{},[I]),_=!!I,U=a=>{E(a),m(S=>({...S,page:0}))},W=At(a=>{O(a),m(S=>({...S,page:0}))},`${o}-${s}-${d}`),N=e.useRef(null),[L,F]=e.useState(!1),r=async()=>{var a;if(!(L||!s))try{F(!0);const S=p==null?void 0:p[0],J=bt(D),at={...d?{instanceId:d}:{},...S!=null&&S.field?{sortBy:S.field,sortOrder:S.sort==="asc"?"asc":"desc"}:{},...J?{filterModel:J}:{}},G=await q.getAMCCustomAttribution(o,s,at),K=((a=G==null?void 0:G.data)==null?void 0:a.rows)??[];vt(`custom-attribution_${o.toLowerCase()}_${s||"latest"}`,$,K,ft(K,o))}finally{F(!1)}};return t.jsxs(t.Fragment,{children:[t.jsx(et,{sx:{mb:"16px"},children:t.jsx(dt,{title:"Custom Attribution",subtitle:"Re-attribute on-Amazon purchases across your DSP and Sponsored campaigns under four rules — Last, First, Linear and Position — to see how each campaign's credit changes with the model.",beta:!0})}),t.jsx(y,{sx:{mt:1.5}}),t.jsxs(et,{sx:{p:"16px"},children:[t.jsxs(y,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:1,mb:2},children:[t.jsx(ut,{options:Z,value:o,onChange:c}),t.jsxs(y,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(Ct,{instances:R,instanceId:d,onChange:P}),t.jsx(Mt,{months:C,month:s,monthsLoading:z,onChange:x}),t.jsx(mt,{onClick:r,disabled:L||!s,loading:L,title:L?"Exporting…":"Export CSV"})]})]}),f.overCap&&n&&t.jsx(Et,{accountId:n,countryCode:h,currencyCode:g,selection:f,saving:T,onSave:M}),t.jsx(pt,{rows:v,columns:$,tableTitle:"Custom Attribution",loading:H||z,skeletonLoader:!0,pinColumns:{left:["campaign"],right:[]},getRowHeight:()=>40,columnHeaderHeight:42,showCellVerticalBorder:!0,showColumnVerticalBorder:!0,density:"standard",fullScreenEnabled:!1,disableRowSelectionOnClick:!0,disableMultipleRowSelection:!0,isFullheight:!0,apiRef:N,isSummaryRow:_,pinnedRows:B,dataGridSx:wt,paginationMode:"server",sortingMode:"server",filterMode:"server",paginationModel:i,onPaginationModelChange:m,rowCount:w,sortModel:p,setSortModel:U,onFilterModelChange:W,pageSizeOptions:It,pageSize:st},`${o}-${s}`),t.jsxs(y,{sx:{display:"flex",alignItems:"center",gap:.75,mt:1,px:.5,flexWrap:"wrap"}
1,children:[t.jsx(ct,{sx:{fontSize:14,color:"text.disabled"}}),t.jsx(j,{variant:"caption",color:"text.disabled",children:s?`Showing ${Lt(s)} · ${(k=Z.find(a=>a.value===o))==null?void 0:k.label} · ${(Y=Z.find(a=>a.value===o))==null?void 0:Y.tooltip} · on-Amazon purchases (14-day lookback)`:"No synced months yet for this account."})]})]})]})}export{we as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.