Skip to content

Commit 4aaeaf9

Browse files
authored
fix: skip bot members from stint inference and lfid enrichment (CM-1260) (#4227)
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
1 parent c1dbdd6 commit 4aaeaf9

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

  • services

services/apps/data_sink_worker/src/service/member.service.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,10 @@ export default class MemberService extends LoggerBase {
502502
}
503503
}
504504

505+
const isBotMember = this.botDetectionService.isFlaggedAsBot(
506+
attributes as Record<string, unknown>,
507+
)
508+
505509
const emailIdentities = data.identities.filter(
506510
(i) => i.type === MemberIdentityType.EMAIL && i.verified,
507511
)
@@ -514,6 +518,7 @@ export default class MemberService extends LoggerBase {
514518
orgPromiseCache,
515519
effectiveMemberId,
516520
activityTimestamp,
521+
isBotMember,
517522
),
518523
this.log,
519524
'memberService -> create -> assignOrganizationByEmailDomain',
@@ -693,7 +698,11 @@ export default class MemberService extends LoggerBase {
693698
}
694699
}
695700

696-
if (this.botDetectionService.isFlaggedAsBot(toUpdate.attributes)) {
701+
const isBotMember = this.botDetectionService.isFlaggedAsBot(
702+
original.attributes as Record<string, unknown>,
703+
)
704+
705+
if (isBotMember) {
697706
this.log.debug({ memberId: id }, 'Skipping organization creation for bot member')
698707
return effectiveMemberId !== id ? effectiveMemberId : undefined
699708
}
@@ -752,6 +761,7 @@ export default class MemberService extends LoggerBase {
752761
orgPromiseCache,
753762
effectiveMemberId,
754763
activityTimestamp,
764+
isBotMember,
755765
),
756766
this.log,
757767
'memberService -> update -> assignOrganizationByEmailDomain',
@@ -807,6 +817,7 @@ export default class MemberService extends LoggerBase {
807817
orgPromiseCache?: Map<string, Promise<string | undefined>>,
808818
memberId?: string,
809819
activityTimestamp?: string,
820+
isBotMember = false,
810821
): Promise<IOrganizationIdSource[]> {
811822
const orgService = new OrganizationService(this.store, this.log)
812823
const organizations: IOrganizationIdSource[] = []
@@ -866,7 +877,8 @@ export default class MemberService extends LoggerBase {
866877
id: orgId,
867878
source: orgSource,
868879
})
869-
if (memberId && activityTimestamp) {
880+
881+
if (memberId && activityTimestamp && !isBotMember) {
870882
await this.bufferMemberOrganizationActivityDates(memberId, orgId, activityTimestamp)
871883
}
872884
}

services/libs/data-access-layer/src/old/apps/members_enrichment_worker/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ export async function fetchMembersForLFIDEnrichment(db: DbStore, limit: number,
198198
(mi.type = 'email' and mi.verified)
199199
)
200200
AND members."deletedAt" IS NULL
201+
AND coalesce((members.attributes -> 'isBot' ->> 'default')::boolean, false) = false
202+
AND coalesce((members.attributes -> 'isOrganization' ->> 'default')::boolean, false) = false
201203
${idFilter}
202204
GROUP BY members.id
203205
ORDER BY members.id desc

0 commit comments

Comments
 (0)