Skip to content

Commit

Permalink
feat: add dashboard link log message (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-yarmosh authored Oct 31, 2024
1 parent b2d4164 commit 6d0dbcc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/helper/adoption-status-handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { scopedLogger } from '../lib/logger.js';

const logger = scopedLogger('api:connect:adoption');

export const adoptionStatusHandler = async ({ isAdopted }: { isAdopted: boolean }): Promise<void> => {
if (!isAdopted) {
logger.info(`You can register this probe at https://dash.globalping.io to earn extra measurement credits.`);
}
};
4 changes: 2 additions & 2 deletions src/helper/alt-ips-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ export const apiConnectAltIpsHandler = async ({ token, socketId, ip }: { token:
const uniqIps = _(allIps).uniq().value();

if (uniqIps.length === 1) {
logger.info(`IP address of the probe: ${uniqIps[0]}`);
logger.info(`IP address of the probe: ${uniqIps[0]}.`);
} else {
logger.info(`IP addresses of the probe: ${uniqIps.join(', ')}`);
logger.info(`IP addresses of the probe: ${uniqIps.join(', ')}.`);
}
};

Expand Down
2 changes: 2 additions & 0 deletions src/probe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { scopedLogger } from './lib/logger.js';
import { initErrorHandler } from './helper/api-error-handler.js';
import { apiConnectLocationHandler } from './helper/api-connect-handler.js';
import { apiConnectAltIpsHandler } from './helper/alt-ips-handler.js';
import { adoptionStatusHandler } from './helper/adoption-status-handler.js';
import { dnsCmd, DnsCommand } from './command/dns-command.js';
import { pingCmd, PingCommand } from './command/ping-command.js';
import { traceCmd, TracerouteCommand } from './command/traceroute-command.js';
Expand Down Expand Up @@ -112,6 +113,7 @@ function connect () {
.on('disconnect', errorHandler.handleDisconnect)
.on('connect_error', errorHandler.connectError)
.on('api:connect:location', apiConnectLocationHandler(socket))
.on('api:connect:adoption', adoptionStatusHandler)
.on('api:connect:alt-ips-token', apiConnectAltIpsHandler)
.on('probe:measurement:request', (data: MeasurementRequest) => {
const status = statusManager.getStatus();
Expand Down

0 comments on commit 6d0dbcc

Please sign in to comment.