@@ -18,7 +18,19 @@ export const syncWithLighthouse = async (orgId: number) => {
1818 where : { orgId } ,
1919 } ) ;
2020
21- const [ userCount , repoCount ] = await Promise . all ( [
21+ const now = Date . now ( ) ;
22+ const DAY_MS = 24 * 60 * 60 * 1000 ;
23+ const dauCutoff = new Date ( now - 1 * DAY_MS ) ;
24+ const wauCutoff = new Date ( now - 7 * DAY_MS ) ;
25+ const mauCutoff = new Date ( now - 30 * DAY_MS ) ;
26+
27+ const [
28+ userCount ,
29+ repoCount ,
30+ dauCount ,
31+ wauCount ,
32+ mauCount ,
33+ ] = await Promise . all ( [
2234 __unsafePrisma . userToOrg . count ( {
2335 where : {
2436 orgId,
@@ -29,6 +41,24 @@ export const syncWithLighthouse = async (orgId: number) => {
2941 orgId,
3042 } ,
3143 } ) ,
44+ __unsafePrisma . user . count ( {
45+ where : {
46+ orgs : { some : { orgId } } ,
47+ lastActiveAt : { gte : dauCutoff } ,
48+ } ,
49+ } ) ,
50+ __unsafePrisma . user . count ( {
51+ where : {
52+ orgs : { some : { orgId } } ,
53+ lastActiveAt : { gte : wauCutoff } ,
54+ } ,
55+ } ) ,
56+ __unsafePrisma . user . count ( {
57+ where : {
58+ orgs : { some : { orgId } } ,
59+ lastActiveAt : { gte : mauCutoff } ,
60+ } ,
61+ } ) ,
3262 ] ) ;
3363
3464 const activationCode = license ?. activationCode
@@ -40,6 +70,9 @@ export const syncWithLighthouse = async (orgId: number) => {
4070 version : SOURCEBOT_VERSION ,
4171 userCount,
4272 repoCount,
73+ dauCount,
74+ wauCount,
75+ mauCount,
4376 deploymentType : inferDeploymentType ( ) ,
4477 isTelemetryEnabled : env . SOURCEBOT_TELEMETRY_DISABLED === 'false' ,
4578 ...( activationCode && { activationCode } ) ,
0 commit comments