Skip to content

Commit

Permalink
Sending notification logs
Browse files Browse the repository at this point in the history
  • Loading branch information
adamfraser committed Aug 20, 2024
1 parent 12f6871 commit 65a5e85
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
13 changes: 6 additions & 7 deletions indexer/packages/notifications/src/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ export async function sendFirebaseMessage(
try {
const result = await sendMulticast(message);
if (result?.failureCount && result?.failureCount > 0) {
logger.info({
at: 'notifications#firebase',
message: `Failed to send Firebase message: ${JSON.stringify(message)}`,
result,
address,
notificationType: notification.type,
});
throw new Error('Failed to send Firebase message');
}
} catch (error) {
Expand All @@ -69,6 +62,12 @@ export async function sendFirebaseMessage(
throw new Error('Failed to send Firebase message');
} finally {
// stats.timing(`${config.SERVICE_NAME}.send_firebase_message.timing`, Date.now() - start);
logger.info({
at: 'notifications#firebase',
message: 'Firebase message sent succesfully',
address,
notificationType: notification.type,
});
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { logger } from '@dydxprotocol-indexer/base';
import {
createNotification,
NotificationDynamicFieldKey,
Expand All @@ -23,6 +24,11 @@ export async function sendOrderFilledNotification(

const token = await TokenTable.findAll({ address: subaccount.address, limit: 1 }, []);
if (token.length === 0) {
logger.info({
at: 'ender#notification-functions',
message: 'No token found for address',
address: subaccount.address,
});
return;
}
const notification = createNotification(
Expand All @@ -33,6 +39,11 @@ export async function sendOrderFilledNotification(
[NotificationDynamicFieldKey.AVERAGE_PRICE]: order.price,
},
);
logger.info({
at: 'ender#notification-functions',
message: 'Sending firebase message',
notificationType: notification.type,
});
await sendFirebaseMessage(subaccount.address, notification);
}

Expand Down

0 comments on commit 65a5e85

Please sign in to comment.