diff --git a/services/collector/src/tracking/device-enrichment.service.ts b/services/collector/src/tracking/device-enrichment.service.ts index 6a3e024..adbe6f9 100644 --- a/services/collector/src/tracking/device-enrichment.service.ts +++ b/services/collector/src/tracking/device-enrichment.service.ts @@ -1,6 +1,6 @@ -import { Injectable } from '@nestjs/common'; +import { Injectable, Logger, OnModuleInit } from '@nestjs/common'; import * as crypto from 'crypto'; -import * as geoip from 'geoip-lite'; +import geoip from 'geoip-lite'; import type { OrganizationType, ResponseTier, ProxyType } from '@lilith/gov-detection'; import { GovDetectionService } from './gov-detection.service'; @@ -66,9 +66,20 @@ interface ParsedUserAgent { } @Injectable() -export class DeviceEnrichmentService { +export class DeviceEnrichmentService implements OnModuleInit { + private readonly logger = new Logger(DeviceEnrichmentService.name); + constructor(private readonly govDetection: GovDetectionService) {} + onModuleInit() { + const test = geoip.lookup('8.8.8.8'); + if (test?.country) { + this.logger.log(`GeoIP operational — test lookup returned ${test.country}`); + } else { + this.logger.error('GeoIP NOT WORKING — test lookup for 8.8.8.8 returned null. Country data will be unavailable.'); + } + } + /** * Enrich device data from User-Agent, IP, and client data * NOTE: IP address is NOT stored - only used for geo lookup, then discarded