Skip to content

Commit db27cb9

Browse files
committed
♻️ add logging for return values from adapters
1 parent 45371c4 commit db27cb9

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/models/controller.model.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ export class Controller {
183183
throw new ServerError(400, "Invalid contact provided by adapter");
184184
}
185185

186+
infoLogger(
187+
"createContact",
188+
`Contact with id ${contact.id} created`,
189+
apiKey
190+
);
191+
186192
const sanitizedContact: Contact = sanitizeContact(contact, locale);
187193

188194
if (this.adapter.getToken && req.providerConfig) {
@@ -253,6 +259,12 @@ export class Controller {
253259
throw new ServerError(400, "Invalid contact provided by adapter");
254260
}
255261

262+
infoLogger(
263+
"createContact",
264+
`Contact with id ${contact.id} updated`,
265+
apiKey
266+
);
267+
256268
const sanitizedContact: Contact = sanitizeContact(contact, locale);
257269

258270
if (this.adapter.getToken && req.providerConfig) {
@@ -320,6 +332,12 @@ export class Controller {
320332
}
321333
res.status(200).send();
322334

335+
infoLogger(
336+
"createContact",
337+
`Contact with id ${contactId} deleted`,
338+
apiKey
339+
);
340+
323341
if (this.contactCache) {
324342
const contacts = await this.contactCache.get(apiKey);
325343
if (Array.isArray(contacts)) {
@@ -597,6 +615,12 @@ export class Controller {
597615
req.body
598616
);
599617

618+
infoLogger(
619+
"handleCallEvent",
620+
`CallEvent with refId ${integrationCallEventRef} created!`,
621+
providerConfig.apiKey
622+
);
623+
600624
infoLogger("handleCallEvent", `END`, providerConfig.apiKey);
601625
res.status(200).send(integrationCallEventRef);
602626
} catch (error) {
@@ -647,6 +671,14 @@ export class Controller {
647671
const entitiesWithCallLogReferences =
648672
await this.adapter.createCallLogsForEntities(providerConfig, req.body);
649673

674+
entitiesWithCallLogReferences.forEach(({ id, logId }) =>
675+
infoLogger(
676+
"createCallLogForEntities",
677+
`CallEvent with logId ${logId} created for id ${id}`,
678+
providerConfig?.apiKey
679+
)
680+
);
681+
650682
infoLogger("createCallLogForEntities", `END`, providerConfig?.apiKey);
651683
res.status(200).send(entitiesWithCallLogReferences);
652684
} catch (error) {

0 commit comments

Comments
 (0)