Skip to content

Commit 4af6685

Browse files
committed
feat: log EpicGames GraphQL responses
Refs: #36
1 parent 4c70b97 commit 4af6685

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/crons/EpicGames.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { MessageEmbed } from 'discord.js';
22
import got from 'got';
3+
import { Logger } from 'pino';
34

45
import { Cron, findTextChannelByName } from '../framework';
56

@@ -19,7 +20,7 @@ export default new Cron({
1920
'Vérifie tous les jours à 17h00 (Paris) si Epic Games offre un jeu (promotion gratuite) et alerte dans #jeux',
2021
schedule: '0 17 * * *',
2122
async handle(context) {
22-
const games = await getOfferedGames(context.date);
23+
const games = await getOfferedGames(context.date, context.logger);
2324
if (!games) {
2425
return;
2526
}
@@ -142,7 +143,10 @@ const oneDay = 1000 * 60 * 60 * 24;
142143
* were offered between the previous and current cron execution, returns them.
143144
* @param now - Current date. Comes from cron schedule.
144145
*/
145-
async function getOfferedGames(now: Date): Promise<Game[] | null> {
146+
async function getOfferedGames(
147+
now: Date,
148+
logger: Logger,
149+
): Promise<Game[] | null> {
146150
const { body } = await got<EpicGamesProducts>(
147151
'https://www.epicgames.com/graphql',
148152
{
@@ -158,6 +162,9 @@ async function getOfferedGames(now: Date): Promise<Game[] | null> {
158162
responseType: 'json',
159163
},
160164
);
165+
166+
logger.info({ data: body.data }, 'Offered games GraphQL response');
167+
161168
const catalog = body.data.Catalog.searchStore;
162169

163170
if (catalog.paging.total === 0) {

0 commit comments

Comments
 (0)