Skip to content

Commit

Permalink
add logging statements
Browse files Browse the repository at this point in the history
  • Loading branch information
YazeedAlKhalaf committed Feb 2, 2025
1 parent c1d841d commit 6d614a6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions wasapp/src/services/whatsapp/whatsapp_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class WhatsappService {
customerId: string,
phoneNumber: string | null
): Promise<string | null> {
console.log(`[DEBUG - wasapp service] started initialize`);
const client = new Client({
authStrategy: new RemoteAuth({
store: new MongoStore({ mongoose: this.mongooseConn }),
Expand All @@ -55,6 +56,7 @@ export class WhatsappService {
],
},
});
console.log(`[DEBUG - wasapp service] created client object :D`);

this.clientsDetails.set(customerId, {
client: client,
Expand All @@ -63,18 +65,29 @@ export class WhatsappService {
name: null,
pairingCode: null,
});
console.log(
`[DEBUG - wasapp service] set the client in the clientsDetails`
);

this.setupClientEvents(client, customerId, phoneNumber);
console.log(`[DEBUG - wasapp service] finished setupClientEvents`);
await client.initialize();
console.log(`[DEBUG - wasapp service] finished client.initialize`);

if (phoneNumber !== null) {
try {
console.log(`[DEBUG - wasapp service] started requestPairingCode`);
const pairingCode = await client.requestPairingCode(phoneNumber, true);
console.log(`[DEBUG - wasapp service] finished requestPairingCode`);
this.updateClientDetails(customerId, {
status: "WAITING_FOR_PAIRING",
pairingCode: pairingCode,
phoneNumber: phoneNumber,
});

console.log(
`[DEBUG - wasapp service] finished initialize with pairing code`
);
return pairingCode;
} catch (error) {
console.log(
Expand All @@ -86,6 +99,8 @@ export class WhatsappService {
}
}

console.log(`[DEBUG - wasapp service] finished initialize with null`);

return null;
}

Expand Down

0 comments on commit 6d614a6

Please sign in to comment.