Skip to content

Commit

Permalink
chore: heartbeat env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Bas950 committed Dec 21, 2024
1 parent 7fcf4ae commit 207fb12
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions apps/worker/src/v4/fields/heartbeat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,21 @@ export async function resolver(

// * Use Redis Hash with 'service' in the key to store heartbeat data
const redisKey = `pmd-api.heartbeatUpdates.${params.identifier}`;
await redis.hset(redisKey, {
service: params.presence?.service,
version: params.presence?.version,
language: params.presence?.language,
since: params.presence?.since.toString(),
extension_version: params.extension.version,
extension_language: params.extension.language,
extension_connected_app: params.extension.connected?.app?.toString(),
extension_connected_discord:
params.extension.connected?.discord?.toString(),
ip_address: ip
});
await redis.expire(redisKey, 300);
if (process.env.HEARTBEATS !== "false") {
await redis.hset(redisKey, {
service: params.presence?.service,
version: params.presence?.version,
language: params.presence?.language,
since: params.presence?.since.toString(),
extension_version: params.extension.version,
extension_language: params.extension.language,
extension_connected_app: params.extension.connected?.app?.toString(),
extension_connected_discord:
params.extension.connected?.discord?.toString(),
ip_address: ip
});
await redis.expire(redisKey, 300);
}

return {
__typename: "HeartbeatResult",
Expand Down

0 comments on commit 207fb12

Please sign in to comment.