Don't fetch account for identifyTenantGroup posthog event (#15092)

* Don't fetch account for identifyTenantGroup posthog event

* Support self hosted

* Fix types
This commit is contained in:
melohagan 2024-11-29 13:12:13 +00:00 committed by GitHub
parent 6699431cbc
commit 39859e10ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 27 deletions

View File

@ -121,7 +121,7 @@ const identifyInstallationGroup = async (
const identifyTenantGroup = async (
tenantId: string,
account: Account | undefined,
hosting: Hosting,
timestamp?: string | number
): Promise<void> => {
const id = await getEventTenantId(tenantId)
@ -129,26 +129,12 @@ const identifyTenantGroup = async (
const installationId = await getInstallationId()
const environment = getDeploymentEnvironment()
let hosting: Hosting
let profession: string | undefined
let companySize: string | undefined
if (account) {
profession = account.profession
companySize = account.size
hosting = account.hosting
} else {
hosting = getHostingFromEnv()
}
const group: TenantGroup = {
id,
type,
hosting,
environment,
installationId,
profession,
companySize,
}
await identifyGroup(group, timestamp)

View File

@ -9,11 +9,12 @@ import {
db as dbUtils,
} from "@budibase/backend-core"
import {
QuotaUsage,
CloudAccount,
App,
TenantBackfillSucceededEvent,
CloudAccount,
Event,
Hosting,
QuotaUsage,
TenantBackfillSucceededEvent,
User,
} from "@budibase/types"
import env from "../../../environment"
@ -125,7 +126,7 @@ export const run = async (db: any) => {
try {
await events.identification.identifyTenantGroup(
tenantId,
account,
env.SELF_HOSTED ? Hosting.SELF : Hosting.CLOUD,
timestamp
)
} catch (e) {

View File

@ -6,12 +6,12 @@ import {
AddSSoUserRequest,
BulkUserRequest,
BulkUserResponse,
CloudAccount,
CreateAdminUserRequest,
CreateAdminUserResponse,
Ctx,
DeleteInviteUserRequest,
DeleteInviteUsersRequest,
Hosting,
InviteUserRequest,
InviteUsersRequest,
InviteUsersResponse,
@ -26,7 +26,6 @@ import {
UserIdentifier,
} from "@budibase/types"
import {
accounts,
users,
cache,
ErrorCode,
@ -192,12 +191,10 @@ export const adminUser = async (
lastName: familyName,
})
// events
let account: CloudAccount | undefined
if (!env.SELF_HOSTED && !env.DISABLE_ACCOUNT_PORTAL) {
account = await accounts.getAccountByTenantId(tenantId)
}
await events.identification.identifyTenantGroup(tenantId, account)
await events.identification.identifyTenantGroup(
tenantId,
env.SELF_HOSTED ? Hosting.SELF : Hosting.CLOUD
)
ctx.body = {
_id: finalUser._id!,