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:
parent
6699431cbc
commit
39859e10ed
|
@ -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)
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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!,
|
||||
|
|
Loading…
Reference in New Issue