fix: Lead-Anlage - ungueltiges createdAt-Attribut entfernt (+temp log)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -84,15 +84,24 @@ export async function createAcquisitionTicket(customer, user) {
|
|||||||
|
|
||||||
/** Legt einen Lead an (nur Unternehmen + E-Mail) und erstellt das Akquise-Ticket. */
|
/** Legt einen Lead an (nur Unternehmen + E-Mail) und erstellt das Akquise-Ticket. */
|
||||||
export async function createLead({ company, email }, user) {
|
export async function createLead({ company, email }, user) {
|
||||||
const now = new Date().toISOString()
|
let customer
|
||||||
const customer = await databases.createDocument(DATABASE_ID, COLLECTIONS.CUSTOMERS, ID.unique(), {
|
try {
|
||||||
|
customer = await databases.createDocument(DATABASE_ID, COLLECTIONS.CUSTOMERS, ID.unique(), {
|
||||||
name: company,
|
name: company,
|
||||||
companyName: company,
|
companyName: company,
|
||||||
email: email || '',
|
email: email || '',
|
||||||
customerStatus: 'lead',
|
customerStatus: 'lead',
|
||||||
createdAt: now,
|
updatedAt: new Date().toISOString(),
|
||||||
updatedAt: now,
|
|
||||||
})
|
})
|
||||||
|
// #region agent log
|
||||||
|
fetch('http://127.0.0.1:7284/ingest/0747da40-b90b-4354-9b84-c9b550a81ec9', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '693b5f' }, body: JSON.stringify({ sessionId: '693b5f', runId: 'post-fix', hypothesisId: 'A', location: 'leads.js:createLead', message: 'lead created ok', data: { id: customer.$id }, timestamp: Date.now() }) }).catch(() => {})
|
||||||
|
// #endregion
|
||||||
|
} catch (err) {
|
||||||
|
// #region agent log
|
||||||
|
fetch('http://127.0.0.1:7284/ingest/0747da40-b90b-4354-9b84-c9b550a81ec9', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '693b5f' }, body: JSON.stringify({ sessionId: '693b5f', runId: 'post-fix', hypothesisId: 'A', location: 'leads.js:createLead', message: 'lead create FAILED', data: { error: String(err && err.message) }, timestamp: Date.now() }) }).catch(() => {})
|
||||||
|
// #endregion
|
||||||
|
throw err
|
||||||
|
}
|
||||||
let ticket = null
|
let ticket = null
|
||||||
try {
|
try {
|
||||||
ticket = await createAcquisitionTicket(customer, user)
|
ticket = await createAcquisitionTicket(customer, user)
|
||||||
|
|||||||
Reference in New Issue
Block a user