@@ -2,7 +2,13 @@ import { existsSync } from "fs";
22import { SINGLE_TENANT_ORG_ID } from "@/lib/constants" ;
33import { isServiceError } from "@/lib/utils" ;
44import { __unsafePrisma } from "@/prisma" ;
5- import { createLogger , decryptActivationCode , env , SOURCEBOT_VERSION } from "@sourcebot/shared" ;
5+ import {
6+ createLogger ,
7+ decryptActivationCode ,
8+ env ,
9+ SOURCEBOT_VERSION ,
10+ isValidOfflineLicenseActive
11+ } from "@sourcebot/shared" ;
612import { client } from "./client" ;
713import { ServicePingRequest } from "./types" ;
814import { ServiceErrorException } from "@/lib/serviceError" ;
@@ -83,7 +89,12 @@ export const syncWithLighthouse = async (orgId: number) => {
8389 ...( activationCode && { activationCode } ) ,
8490 } ;
8591
86- await recordServicePingInDB ( payload ) ;
92+ await recordServicePingInDB ( orgId , payload ) ;
93+
94+ if ( isValidOfflineLicenseActive ( ) ) {
95+ logger . debug ( 'Skipping service ping: active offline license detected.' ) ;
96+ return ;
97+ }
8798
8899 const response = await client . ping ( payload ) ;
89100 if ( isServiceError ( response ) ) {
@@ -175,13 +186,14 @@ const inferDeploymentType = (): string => {
175186 return 'other' ;
176187} ;
177188
178- const recordServicePingInDB = async ( payload : ServicePingRequest ) => {
189+ const recordServicePingInDB = async ( orgId : number , payload : ServicePingRequest ) => {
179190 // Strip the activation code before persisting.
180191 const { activationCode : _activationCode , ...sanitizedPayload } = payload ;
181192
182193 try {
183194 await __unsafePrisma . servicePingEvent . create ( {
184195 data : {
196+ orgId,
185197 payload : sanitizedPayload ,
186198 } ,
187199 } ) ;
0 commit comments