Enhance eBay extension logging and account management features

- Added detailed logging for various actions in the background script and content script to improve debugging capabilities.
- Updated the account management flow to include the last updated timestamp and sales data.
- Refined the parsing logic to ensure accurate extraction of seller statistics from eBay profiles.
- Improved error handling in the parsing process to provide more informative responses in case of failures.
This commit is contained in:
2026-01-21 23:01:09 +01:00
parent 0012a10249
commit 636ca1341c
6 changed files with 1114 additions and 129 deletions

View File

@@ -102,15 +102,14 @@ export const AccountsPage = () => {
// Shop-Name und account_sells können auch leer sein (optional)
updatePayload.account_shop_name = parsedData.shopName || null;
updatePayload.account_sells = parsedData.stats?.itemsSold ?? null;
// #region agent log
fetch('http://127.0.0.1:7242/ingest/246fe132-ecc5-435f-bd9c-fe5e8e26089d',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'AccountsPage.jsx:93',message:'handleRefreshAccount: update payload',data:{payload:updatePayload},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});
// #endregion
// account_status wird weggelassen (wie beim Erstellen)
// Grund: Schema-Konflikt - Enum-Feld akzeptiert weder String noch Array im Update
// TODO: Schema in Appwrite prüfen und korrigieren, dann account_status wieder hinzufügen
// Setze account_updated_at auf aktuelle Zeit
updatePayload.account_updated_at = new Date().toISOString();
await updateManagedAccount(accountId, updatePayload);
// Accounts-Liste neu laden (in-place Update)
@@ -206,9 +205,6 @@ export const AccountsPage = () => {
// Payload aus parsedData zusammenstellen
const accountSellsValue = parsedData.stats?.itemsSold ?? null;
// #region agent log
fetch('http://127.0.0.1:7242/ingest/246fe132-ecc5-435f-bd9c-fe5e8e26089d',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'AccountsPage.jsx:193',message:'handleFormSubmit: parsedData before save',data:{hasStats:!!parsedData.stats,itemsSold:parsedData.stats?.itemsSold,accountSellsValue},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});
// #endregion
const newAccount = await createManagedAccount(authUser.$id, {
account_url: formData.account_url.trim(),
account_platform_account_id: parsedData.sellerId,
@@ -247,7 +243,7 @@ export const AccountsPage = () => {
"Platform Account ID",
"Market",
"Account URL",
"Status",
"Sales",
"Last Scan",
...(showAdvanced ? ["Owner User ID"] : []),
"Action",
@@ -310,12 +306,15 @@ export const AccountsPage = () => {
);
}
if (col === "Status") {
return row.account_status || "-";
if (col === "Sales") {
const sales = row.account_sells;
if (sales === null || sales === undefined) return "-";
// Format number with thousand separators
return new Intl.NumberFormat("de-DE").format(sales);
}
if (col === "Last Scan") {
const lastScan = row.account_last_scan_at;
const lastScan = row.account_updated_at;
if (!lastScan) return "-";
try {
const date = new Date(lastScan);
@@ -400,9 +399,9 @@ export const AccountsPage = () => {
</div>
<div>
<span className="font-medium text-[var(--text)]">
Status (Auto)
Sales (Auto)
</span>
: Wird automatisch auf "active" gesetzt. Du musst nichts eingeben.
: Anzahl der verkauften Artikel wird automatisch aus dem eBay-Profil gelesen.
</div>
</div>
<div className="mt-4 rounded-lg border border-[var(--line)] bg-white/2 p-3 text-xs text-[var(--muted)]">
@@ -602,16 +601,16 @@ export const AccountsPage = () => {
<div>
<label className="mb-1.5 block text-xs font-medium text-[var(--muted)]">
Status (Auto)
Sales (Auto)
</label>
<input
type="text"
value={parsedData.status}
value={parsedData.stats?.itemsSold ? new Intl.NumberFormat("de-DE").format(parsedData.stats.itemsSold) : "-"}
readOnly
className="w-full rounded-lg border border-neutral-200 bg-white px-3 py-2 text-sm text-[var(--text)] opacity-75 dark:bg-neutral-900 dark:border-neutral-700"
/>
<p className="mt-1 text-xs text-[var(--muted)]">
Interner Status. Normalerweise "active".
Gesamtzahl der verkauften Artikel.
</p>
</div>
</div>