diff --git a/charts/budibase/templates/worker-service-deployment.yaml b/charts/budibase/templates/worker-service-deployment.yaml index 6367ceecff..73bb26dad9 100644 --- a/charts/budibase/templates/worker-service-deployment.yaml +++ b/charts/budibase/templates/worker-service-deployment.yaml @@ -93,6 +93,10 @@ spec: value: {{ .Values.globals.selfHosted | quote }} - name: SENTRY_DSN value: {{ .Values.globals.sentryDSN }} + - name: ENABLE_ANALYTICS + value: {{ .Values.globals.enableAnalytics | quote }} + - name: POSTHOG_TOKEN + value: {{ .Values.globals.posthogToken }} - name: ACCOUNT_PORTAL_URL value: {{ .Values.globals.accountPortalUrl | quote }} - name: ACCOUNT_PORTAL_API_KEY diff --git a/charts/budibase/values.yaml b/charts/budibase/values.yaml index b04a8f242f..455d3251a8 100644 --- a/charts/budibase/values.yaml +++ b/charts/budibase/values.yaml @@ -89,7 +89,7 @@ affinity: {} globals: appVersion: "latest" budibaseEnv: PRODUCTION - enableAnalytics: true + enableAnalytics: "1" sentryDSN: "" posthogToken: "phc_fg5I3nDOf6oJVMHSaycEhpPdlgS8rzXG2r6F2IpxCHS" logLevel: info diff --git a/lerna.json b/lerna.json index 2853b2e2df..080372bc14 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.0.200-alpha.3", + "version": "1.0.206", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index daaa7580d3..04d50eff1a 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/backend-core", - "version": "1.0.200-alpha.3", + "version": "1.0.206", "description": "Budibase backend core libraries used in server and worker", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", @@ -13,6 +13,7 @@ "license": "GPL-3.0", "scripts": { "prebuild": "rimraf dist/", + "prepack": "cp package.json dist", "build": "tsc -p tsconfig.build.json", "build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput", "test": "jest", @@ -56,7 +57,7 @@ ] }, "devDependencies": { - "@budibase/types": "^1.0.200-alpha.3", + "@budibase/types": "^1.0.206", "@shopify/jest-koa-mocks": "3.1.5", "@types/jest": "27.5.1", "@types/koa": "2.0.52", diff --git a/packages/backend-core/src/events/identification.ts b/packages/backend-core/src/events/identification.ts index b8800bfd12..a29a6821cd 100644 --- a/packages/backend-core/src/events/identification.ts +++ b/packages/backend-core/src/events/identification.ts @@ -14,7 +14,6 @@ import { CloudAccount, UserIdentity, InstallationGroup, - isSelfHostAccount, UserContext, Group, } from "@budibase/types" @@ -36,6 +35,7 @@ const pkg = require("../../package.json") */ export const getCurrentIdentity = async (): Promise => { let identityContext = identityCtx.getIdentity() + const environment = getDeploymentEnvironment() let identityType @@ -47,36 +47,47 @@ export const getCurrentIdentity = async (): Promise => { if (identityType === IdentityType.INSTALLATION) { const installationId = await getInstallationId() + const hosting = getHostingFromEnv() return { id: formatDistinctId(installationId, identityType), + hosting, type: identityType, installationId, + environment, } } else if (identityType === IdentityType.TENANT) { const installationId = await getInstallationId() const tenantId = await getEventTenantId(context.getTenantId()) + const hosting = getHostingFromEnv() return { id: formatDistinctId(tenantId, identityType), type: identityType, + hosting, installationId, tenantId, + environment, } } else if (identityType === IdentityType.USER) { const userContext = identityContext as UserContext const tenantId = await getEventTenantId(context.getTenantId()) - let installationId: string | undefined + const installationId = await getInstallationId() - // self host account users won't have installation - if (!userContext.account || !isSelfHostAccount(userContext.account)) { - installationId = await getInstallationId() + const account = userContext.account + let hosting + if (account) { + hosting = account.hosting + } else { + hosting = getHostingFromEnv() } return { id: userContext._id, type: identityType, + hosting, installationId, tenantId, + environment, } } else { throw new Error("Unknown identity type") @@ -91,12 +102,14 @@ export const identifyInstallationGroup = async ( const type = IdentityType.INSTALLATION const hosting = getHostingFromEnv() const version = pkg.version + const environment = getDeploymentEnvironment() const group: InstallationGroup = { id, type, hosting, version, + environment, } await identifyGroup(group, timestamp) @@ -112,6 +125,8 @@ export const identifyTenantGroup = async ( ): Promise => { const id = await getEventTenantId(tenantId) const type = IdentityType.TENANT + const installationId = await getInstallationId() + const environment = getDeploymentEnvironment() let hosting: Hosting let profession: string | undefined @@ -129,6 +144,8 @@ export const identifyTenantGroup = async ( id, type, hosting, + environment, + installationId, profession, companySize, } @@ -154,10 +171,13 @@ export const identifyUser = async ( const verified = account && account?.budibaseUserId === user._id ? account.verified : false const installationId = await getInstallationId() + const hosting = account ? account.hosting : getHostingFromEnv() + const environment = getDeploymentEnvironment() const identity: UserIdentity = { id, type, + hosting, installationId, tenantId, verified, @@ -165,6 +185,7 @@ export const identifyUser = async ( providerType, builder, admin, + environment, } await identify(identity, timestamp) @@ -177,6 +198,9 @@ export const identifyAccount = async (account: Account) => { let providerType = isSSOAccount(account) ? account.providerType : undefined const verified = account.verified const accountHolder = true + const hosting = account.hosting + const installationId = await getInstallationId() + const environment = getDeploymentEnvironment() if (isCloudAccount(account)) { if (account.budibaseUserId) { @@ -188,10 +212,13 @@ export const identifyAccount = async (account: Account) => { const identity: UserIdentity = { id, type, + hosting, + installationId, tenantId, providerType, verified, accountHolder, + environment, } await identify(identity) @@ -211,6 +238,14 @@ export const identifyGroup = async ( await processors.identifyGroup(group, timestamp) } +const getDeploymentEnvironment = () => { + if (env.isDev()) { + return "development" + } else { + return env.DEPLOYMENT_ENVIRONMENT + } +} + const getHostingFromEnv = () => { return env.SELF_HOSTED ? Hosting.SELF : Hosting.CLOUD } diff --git a/packages/backend-core/src/events/processors/AnalyticsProcessor.ts b/packages/backend-core/src/events/processors/AnalyticsProcessor.ts index 30928abc8d..2ee7a02afa 100644 --- a/packages/backend-core/src/events/processors/AnalyticsProcessor.ts +++ b/packages/backend-core/src/events/processors/AnalyticsProcessor.ts @@ -7,14 +7,17 @@ import PosthogProcessor from "./PosthogProcessor" /** * Events that are always captured. */ -const EVENT_WHITELIST = [Event.VERSION_UPGRADED, Event.VERSION_DOWNGRADED] +const EVENT_WHITELIST = [ + Event.INSTALLATION_VERSION_UPGRADED, + Event.INSTALLATION_VERSION_DOWNGRADED, +] const IDENTITY_WHITELIST = [IdentityType.INSTALLATION, IdentityType.TENANT] export default class AnalyticsProcessor implements EventProcessor { posthog: PosthogProcessor | undefined constructor() { - if (env.POSTHOG_TOKEN) { + if (env.POSTHOG_TOKEN && !env.isTest()) { this.posthog = new PosthogProcessor(env.POSTHOG_TOKEN) } } diff --git a/packages/backend-core/src/events/processors/PosthogProcessor.ts b/packages/backend-core/src/events/processors/PosthogProcessor.ts index 5b6a267569..67407fdd5c 100644 --- a/packages/backend-core/src/events/processors/PosthogProcessor.ts +++ b/packages/backend-core/src/events/processors/PosthogProcessor.ts @@ -23,7 +23,8 @@ export default class PosthogProcessor implements EventProcessor { ): Promise { properties.version = pkg.version properties.service = env.SERVICE - properties.environment = env.DEPLOYMENT_ENVIRONMENT + properties.environment = identity.environment + properties.hosting = identity.hosting const appId = context.getAppId() if (appId) { diff --git a/packages/backend-core/src/events/publishers/index.ts b/packages/backend-core/src/events/publishers/index.ts index 48b2387c5a..65785d4d8b 100644 --- a/packages/backend-core/src/events/publishers/index.ts +++ b/packages/backend-core/src/events/publishers/index.ts @@ -15,5 +15,5 @@ export * as table from "./table" export * as serve from "./serve" export * as user from "./user" export * as view from "./view" -export * as version from "./version" +export * as installation from "./installation" export * as backfill from "./backfill" diff --git a/packages/backend-core/src/events/publishers/version.ts b/packages/backend-core/src/events/publishers/installation.ts similarity index 53% rename from packages/backend-core/src/events/publishers/version.ts rename to packages/backend-core/src/events/publishers/installation.ts index 1c96ed629f..ef27935210 100644 --- a/packages/backend-core/src/events/publishers/version.ts +++ b/packages/backend-core/src/events/publishers/installation.ts @@ -1,11 +1,11 @@ import { publishEvent } from "../events" import { Event, VersionCheckedEvent, VersionChangeEvent } from "@budibase/types" -export async function checked(version: string) { +export async function versionChecked(version: string) { const properties: VersionCheckedEvent = { currentVersion: version, } - await publishEvent(Event.VERSION_CHECKED, properties) + await publishEvent(Event.INSTALLATION_VERSION_CHECKED, properties) } export async function upgraded(from: string, to: string) { @@ -14,7 +14,7 @@ export async function upgraded(from: string, to: string) { to, } - await publishEvent(Event.VERSION_UPGRADED, properties) + await publishEvent(Event.INSTALLATION_VERSION_UPGRADED, properties) } export async function downgraded(from: string, to: string) { @@ -22,5 +22,10 @@ export async function downgraded(from: string, to: string) { from, to, } - await publishEvent(Event.VERSION_DOWNGRADED, properties) + await publishEvent(Event.INSTALLATION_VERSION_DOWNGRADED, properties) +} + +export async function firstStartup() { + const properties = {} + await publishEvent(Event.INSTALLATION_FIRST_STARTUP, properties) } diff --git a/packages/backend-core/src/installation.ts b/packages/backend-core/src/installation.ts index e95698b336..da9b6c5b76 100644 --- a/packages/backend-core/src/installation.ts +++ b/packages/backend-core/src/installation.ts @@ -84,9 +84,9 @@ export const checkInstallVersion = async (): Promise => { }, async () => { if (isUpgrade) { - await events.version.upgraded(currentVersion, newVersion) + await events.installation.upgraded(currentVersion, newVersion) } else if (isDowngrade) { - await events.version.downgraded(currentVersion, newVersion) + await events.installation.downgraded(currentVersion, newVersion) } } ) diff --git a/packages/backend-core/tests/utilities/mocks/events.js b/packages/backend-core/tests/utilities/mocks/events.js index d2f8f363a1..a4055cc5ea 100644 --- a/packages/backend-core/tests/utilities/mocks/events.js +++ b/packages/backend-core/tests/utilities/mocks/events.js @@ -55,7 +55,7 @@ jest.spyOn(events.org, "logoUpdated") jest.spyOn(events.org, "platformURLUpdated") jest.spyOn(events.org, "analyticsOptOut") -jest.spyOn(events.version, "checked") +jest.spyOn(events.installation, "versionChecked") jest.spyOn(events.query, "created") jest.spyOn(events.query, "updated") diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 6cd0561492..61710954d8 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "1.0.200-alpha.3", + "version": "1.0.206", "license": "MPL-2.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", @@ -38,7 +38,7 @@ ], "dependencies": { "@adobe/spectrum-css-workflow-icons": "^1.2.1", - "@budibase/string-templates": "^1.0.200-alpha.3", + "@budibase/string-templates": "^1.0.206", "@spectrum-css/actionbutton": "^1.0.1", "@spectrum-css/actiongroup": "^1.0.1", "@spectrum-css/avatar": "^3.0.2", diff --git a/packages/builder/package.json b/packages/builder/package.json index 34dc7e85d4..5a08d88de0 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "1.0.200-alpha.3", + "version": "1.0.206", "license": "GPL-3.0", "private": true, "scripts": { @@ -69,10 +69,10 @@ } }, "dependencies": { - "@budibase/bbui": "^1.0.200-alpha.3", - "@budibase/client": "^1.0.200-alpha.3", - "@budibase/frontend-core": "^1.0.200-alpha.3", - "@budibase/string-templates": "^1.0.200-alpha.3", + "@budibase/bbui": "^1.0.206", + "@budibase/client": "^1.0.206", + "@budibase/frontend-core": "^1.0.206", + "@budibase/string-templates": "^1.0.206", "@sentry/browser": "5.19.1", "@spectrum-css/page": "^3.0.1", "@spectrum-css/vars": "^3.0.1", diff --git a/packages/cli/package.json b/packages/cli/package.json index 1d501529ed..9309f264f4 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "1.0.200-alpha.3", + "version": "1.0.206", "description": "Budibase CLI, for developers, self hosting and migrations.", "main": "src/index.js", "bin": { diff --git a/packages/client/package.json b/packages/client/package.json index 0c0547904e..4dcccf985d 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "1.0.200-alpha.3", + "version": "1.0.206", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -19,9 +19,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "^1.0.200-alpha.3", - "@budibase/frontend-core": "^1.0.200-alpha.3", - "@budibase/string-templates": "^1.0.200-alpha.3", + "@budibase/bbui": "^1.0.206", + "@budibase/frontend-core": "^1.0.206", + "@budibase/string-templates": "^1.0.206", "@spectrum-css/button": "^3.0.3", "@spectrum-css/card": "^3.0.3", "@spectrum-css/divider": "^1.0.3", diff --git a/packages/frontend-core/package.json b/packages/frontend-core/package.json index 5d5d16f7ec..9f76613cf4 100644 --- a/packages/frontend-core/package.json +++ b/packages/frontend-core/package.json @@ -1,12 +1,12 @@ { "name": "@budibase/frontend-core", - "version": "1.0.200-alpha.3", + "version": "1.0.206", "description": "Budibase frontend core libraries used in builder and client", "author": "Budibase", "license": "MPL-2.0", "svelte": "src/index.js", "dependencies": { - "@budibase/bbui": "^1.0.200-alpha.3", + "@budibase/bbui": "^1.0.206", "lodash": "^4.17.21", "svelte": "^3.46.2" } diff --git a/packages/server/package.json b/packages/server/package.json index 73b9281df2..20e4529352 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "1.0.200-alpha.3", + "version": "1.0.206", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -77,10 +77,10 @@ "license": "GPL-3.0", "dependencies": { "@apidevtools/swagger-parser": "10.0.3", - "@budibase/backend-core": "^1.0.200-alpha.3", - "@budibase/client": "^1.0.200-alpha.3", - "@budibase/pro": "1.0.200-alpha.3", - "@budibase/string-templates": "^1.0.200-alpha.3", + "@budibase/backend-core": "^1.0.206", + "@budibase/client": "^1.0.206", + "@budibase/pro": "1.0.206", + "@budibase/string-templates": "^1.0.206", "@bull-board/api": "3.7.0", "@bull-board/koa": "3.9.4", "@elastic/elasticsearch": "7.10.0", @@ -151,7 +151,7 @@ "@babel/core": "7.17.4", "@babel/preset-env": "7.16.11", "@budibase/standard-components": "^0.9.139", - "@budibase/types": "^1.0.200-alpha.3", + "@budibase/types": "^1.0.206", "@jest/test-sequencer": "24.9.0", "@types/apidoc": "0.50.0", "@types/bson": "4.2.0", diff --git a/packages/server/src/api/controllers/dev.js b/packages/server/src/api/controllers/dev.js index 8e4c597e38..3c5835ac21 100644 --- a/packages/server/src/api/controllers/dev.js +++ b/packages/server/src/api/controllers/dev.js @@ -131,5 +131,5 @@ exports.getBudibaseVersion = async ctx => { ctx.body = { version, } - await events.version.checked(version) + await events.installation.versionChecked(version) } diff --git a/packages/server/src/api/controllers/static/index.js b/packages/server/src/api/controllers/static/index.js index d21e38f879..28295499b2 100644 --- a/packages/server/src/api/controllers/static/index.js +++ b/packages/server/src/api/controllers/static/index.js @@ -17,7 +17,6 @@ const { attachmentsRelativeURL } = require("../../../utilities") const { DocumentTypes, isDevAppID } = require("../../../db/utils") const { getAppDB, getAppId } = require("@budibase/backend-core/context") const AWS = require("aws-sdk") -const AWS_REGION = env.AWS_REGION ? env.AWS_REGION : "eu-west-1" const { events } = require("@budibase/backend-core") async function prepareUpload({ s3Key, bucket, metadata, file }) { @@ -42,7 +41,9 @@ async function prepareUpload({ s3Key, bucket, metadata, file }) { exports.serveBuilder = async function (ctx) { let builderPath = resolve(TOP_LEVEL_PATH, "builder") await send(ctx, ctx.file, { root: builderPath }) - await events.serve.servedBuilder() + if (!ctx.file.includes("assets/")) { + await events.serve.servedBuilder() + } } exports.uploadFile = async function (ctx) { @@ -128,6 +129,7 @@ exports.getSignedUploadURL = async function (ctx) { // Determine type of datasource and generate signed URL let signedUrl let publicUrl + const awsRegion = datasource?.config?.region || "eu-west-1" if (datasource.source === "S3") { const { bucket, key } = ctx.request.body || {} if (!bucket || !key) { @@ -136,7 +138,7 @@ exports.getSignedUploadURL = async function (ctx) { } try { const s3 = new AWS.S3({ - region: AWS_REGION, + region: awsRegion, accessKeyId: datasource?.config?.accessKeyId, secretAccessKey: datasource?.config?.secretAccessKey, apiVersion: "2006-03-01", @@ -144,7 +146,7 @@ exports.getSignedUploadURL = async function (ctx) { }) const params = { Bucket: bucket, Key: key } signedUrl = s3.getSignedUrl("putObject", params) - publicUrl = `https://${bucket}.s3.${AWS_REGION}.amazonaws.com/${key}` + publicUrl = `https://${bucket}.s3.${awsRegion}.amazonaws.com/${key}` } catch (error) { ctx.throw(400, error) } diff --git a/packages/server/src/api/routes/tests/dev.spec.js b/packages/server/src/api/routes/tests/dev.spec.js index 8dee3fd418..db6bad11f4 100644 --- a/packages/server/src/api/routes/tests/dev.spec.js +++ b/packages/server/src/api/routes/tests/dev.spec.js @@ -33,8 +33,8 @@ describe("/dev", () => { .expect(200) expect(res.body.version).toBe(version) - expect(events.version.checked).toBeCalledTimes(1) - expect(events.version.checked).toBeCalledWith(version) + expect(events.installation.versionChecked).toBeCalledTimes(1) + expect(events.installation.versionChecked).toBeCalledWith(version) }) }) }) \ No newline at end of file diff --git a/packages/server/src/automations/steps/executeQuery.js b/packages/server/src/automations/steps/executeQuery.js index 99c2c40783..156df504e9 100644 --- a/packages/server/src/automations/steps/executeQuery.js +++ b/packages/server/src/automations/steps/executeQuery.js @@ -72,7 +72,7 @@ exports.run = async function ({ inputs, appId, emitter }) { }) try { - await queryController.executeV1(ctx) + await queryController.executeV2(ctx) const { data, ...rest } = ctx.body return { response: data, diff --git a/packages/server/src/integrations/firebase.ts b/packages/server/src/integrations/firebase.ts index e95bda8d46..8ed08befeb 100644 --- a/packages/server/src/integrations/firebase.ts +++ b/packages/server/src/integrations/firebase.ts @@ -66,7 +66,6 @@ module Firebase { "==", "<", "<=", - "==", "!=", ">=", ">", diff --git a/packages/server/src/migrations/functions/backfill/app.ts b/packages/server/src/migrations/functions/backfill/app.ts index 0f53e4d0ad..476344e7b0 100644 --- a/packages/server/src/migrations/functions/backfill/app.ts +++ b/packages/server/src/migrations/functions/backfill/app.ts @@ -20,6 +20,7 @@ const handleError = (e: any, errors?: any) => { } return } + console.trace(e) throw e } diff --git a/packages/server/src/migrations/functions/backfill/app/queries.ts b/packages/server/src/migrations/functions/backfill/app/queries.ts index e07dec8c06..b2ea31c19c 100644 --- a/packages/server/src/migrations/functions/backfill/app/queries.ts +++ b/packages/server/src/migrations/functions/backfill/app/queries.ts @@ -22,10 +22,23 @@ export const backfill = async (appDb: any, timestamp: string | number) => { const queries: Query[] = await getQueries(appDb) for (const query of queries) { - const datasource: Datasource = await getDatasource( - appDb, - query.datasourceId - ) + let datasource: Datasource + + try { + datasource = await getDatasource(appDb, query.datasourceId) + } catch (e: any) { + // handle known bug where a datasource has been deleted + // and the query has not + if (e.status === 404) { + datasource = { + _id: query.datasourceId, + source: "unknown", + } + } else { + throw e + } + } + await events.query.created(datasource, query, timestamp) } diff --git a/packages/server/src/migrations/functions/backfill/global.ts b/packages/server/src/migrations/functions/backfill/global.ts index cac38b8066..5dd812d6ea 100644 --- a/packages/server/src/migrations/functions/backfill/global.ts +++ b/packages/server/src/migrations/functions/backfill/global.ts @@ -14,6 +14,7 @@ import { App, TenantBackfillSucceededEvent, Event, + User, } from "@budibase/types" import env from "../../../environment" import { DEFAULT_TIMESTAMP } from "." @@ -94,8 +95,24 @@ export const run = async (db: any) => { const totals: any = {} const errors: any = [] + let allUsers: User[] = [] try { - const installTimestamp = await getInstallTimestamp(db) + allUsers = await users.getUsers(db) + } catch (e: any) { + handleError(e, errors) + } + + if (!allUsers || allUsers.length === 0) { + // first time startup - we don't need to backfill anything + // tenant will be identified when admin user is created + if (env.SELF_HOSTED) { + await events.installation.firstStartup() + } + return + } + + try { + const installTimestamp = await getInstallTimestamp(db, allUsers) if (installTimestamp) { timestamp = installTimestamp } @@ -175,20 +192,25 @@ export const isComplete = async (): Promise => { } export const getInstallTimestamp = async ( - globalDb: any + globalDb: any, + allUsers?: User[] ): Promise => { - const allUsers = await users.getUsers(globalDb) + if (!allUsers) { + allUsers = await users.getUsers(globalDb) + } // get the oldest user timestamp - const timestamps = allUsers - .map(user => user.createdAt) - .filter(timestamp => !!timestamp) - .sort( - (a, b) => - new Date(a as number).getTime() - new Date(b as number).getTime() - ) + if (allUsers) { + const timestamps = allUsers + .map(user => user.createdAt) + .filter(timestamp => !!timestamp) + .sort( + (a, b) => + new Date(a as number).getTime() - new Date(b as number).getTime() + ) - if (timestamps.length) { - return timestamps[0] + if (timestamps.length) { + return timestamps[0] + } } } diff --git a/packages/server/src/migrations/index.ts b/packages/server/src/migrations/index.ts index ebba4f420d..494740d1d9 100644 --- a/packages/server/src/migrations/index.ts +++ b/packages/server/src/migrations/index.ts @@ -104,7 +104,6 @@ export const migrate = async (options?: MigrationOptions) => { const migrateWithLock = async (options?: MigrationOptions) => { // get a new lock client - const redlock = await redis.clients.getMigrationsRedlock() // lock for 15 minutes const ttl = 1000 * 60 * 15 diff --git a/packages/server/src/migrations/tests/index.spec.ts b/packages/server/src/migrations/tests/index.spec.ts index ca30fbca06..faaefe3d61 100644 --- a/packages/server/src/migrations/tests/index.spec.ts +++ b/packages/server/src/migrations/tests/index.spec.ts @@ -23,6 +23,8 @@ const clearMigrations = async () => { } } +jest.setTimeout(10000) + describe("migrations", () => { const config = new TestConfig() diff --git a/packages/server/yarn.lock b/packages/server/yarn.lock index 14dc041cfe..b9f7f81a5b 100644 --- a/packages/server/yarn.lock +++ b/packages/server/yarn.lock @@ -1094,10 +1094,10 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@1.0.200-alpha.0": - version "1.0.200-alpha.0" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.200-alpha.0.tgz#2fd1e1cc71c07891fd66e37ceaab2cffb0df1106" - integrity sha512-CZPPuj+WIDTxLVbrv/B4J4rQiNnkRBs3ZWK2AvlVlY9knWuM034MKHPK3YaeQdVofZqkTOfWKZp6KFRroC304g== +"@budibase/backend-core@1.0.201-alpha.4": + version "1.0.201-alpha.4" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.201-alpha.4.tgz#51fda5838e9c51c88c85204ad867811e49b7d34c" + integrity sha512-5oQMfKPDMpB4x5MzGgOtWFIPzc7RG/uu+rSe65PVwWfp77bDa3kxtCtC1p6vtJuPlb4GYrHqGLtr7WePbJf4fA== dependencies: "@techpass/passport-openidconnect" "0.3.2" aws-sdk "2.1030.0" @@ -1175,12 +1175,12 @@ svelte-flatpickr "^3.2.3" svelte-portal "^1.0.0" -"@budibase/pro@1.0.200-alpha.0": - version "1.0.200-alpha.0" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.200-alpha.0.tgz#68adc9a61a1b975a990e1a4d4ddf5dba69fc038c" - integrity sha512-GxIxvBjCO7kQxFwASKtGC57C2cAN3oiHU+tTCb57qKtp63GdP1z+iqDLtUEOIXXume9bC1xxTD/LSBMziTrHKg== +"@budibase/pro@1.0.201-alpha.4": + version "1.0.201-alpha.4" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.201-alpha.4.tgz#5b92dc7a4bb2004bcd43339c863430ea640e0b74" + integrity sha512-fsDlE8O4Y4JpZI3NwBoN8udX4cEx7/ebZ41Q7qD5VwA6Q2niapRcX0MvDmGdjDSVECG+NJU1uqCdg5cDq1Odxw== dependencies: - "@budibase/backend-core" "1.0.200-alpha.0" + "@budibase/backend-core" "1.0.201-alpha.4" node-fetch "^2.6.1" "@budibase/standard-components@^0.9.139": @@ -14327,4 +14327,4 @@ z-schema@^5.0.1: zlib@1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/zlib/-/zlib-1.0.5.tgz#6e7c972fc371c645a6afb03ab14769def114fcc0" - integrity sha1-bnyXL8NxxkWmr7A6sUdp3vEU/MA= + integrity sha512-40fpE2II+Cd3k8HWTWONfeKE2jL+P42iWJ1zzps5W51qcTsOUKM5Q5m2PFb0CLxlmFAaUuUdJGc3OfZy947v0w== diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index 11929875cf..58cb0324bd 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "1.0.200-alpha.3", + "version": "1.0.206", "description": "Handlebars wrapper for Budibase templating.", "main": "src/index.cjs", "module": "dist/bundle.mjs", diff --git a/packages/types/package.json b/packages/types/package.json index 0091c7c54f..074661da38 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/types", - "version": "1.0.200-alpha.3", + "version": "1.0.206", "description": "Budibase types", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/types/src/sdk/events/event.ts b/packages/types/src/sdk/events/event.ts index 6c1a37e264..5dc1707fa7 100644 --- a/packages/types/src/sdk/events/event.ts +++ b/packages/types/src/sdk/events/event.ts @@ -1,3 +1,5 @@ +import { Hosting } from "../hosting" + export enum Event { // USER USER_CREATED = "user:created", @@ -37,10 +39,11 @@ export enum Event { ORG_LOGO_UPDATED = "org:info:logo:updated", ORG_PLATFORM_URL_UPDATED = "org:platformurl:updated", - // VERSIONS - VERSION_CHECKED = "version:checked", - VERSION_UPGRADED = "version:upgraded", - VERSION_DOWNGRADED = "version:downgraded", + // INSTALLATION + INSTALLATION_VERSION_CHECKED = "installation:version:checked", + INSTALLATION_VERSION_UPGRADED = "installation:version:upgraded", + INSTALLATION_VERSION_DOWNGRADED = "installation:version:downgraded", + INSTALLATION_FIRST_STARTUP = "installation:firstStartup", // ORG / ANALYTICS ANALYTICS_OPT_OUT = "analytics:opt:out", @@ -157,6 +160,7 @@ export interface BaseEvent { appId?: string installationId?: string tenantId?: string + hosting?: Hosting } export type RowImportFormat = "csv" diff --git a/packages/types/src/sdk/events/identification.ts b/packages/types/src/sdk/events/identification.ts index 1b9c43d2e7..3f4e7ec9d4 100644 --- a/packages/types/src/sdk/events/identification.ts +++ b/packages/types/src/sdk/events/identification.ts @@ -10,6 +10,8 @@ export enum GroupType { export interface Group { id: string type: IdentityType + environment: string + hosting: Hosting } export interface TenantGroup extends Group { @@ -17,12 +19,11 @@ export interface TenantGroup extends Group { // as we don't have this at the user level profession?: string // only available in cloud companySize?: string // only available in cloud - hosting: Hosting // need hosting at the tenant level for cloud self host accounts + installationId: string } export interface InstallationGroup extends Group { version: string - hosting: Hosting } // IDENTITIES @@ -36,6 +37,8 @@ export enum IdentityType { export interface Identity { id: string type: IdentityType + hosting: Hosting + environment: string installationId?: string tenantId?: string } diff --git a/packages/worker/package.json b/packages/worker/package.json index cc4e39e441..3b8e0f7d6c 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "1.0.200-alpha.3", + "version": "1.0.206", "description": "Budibase background service", "main": "src/index.ts", "repository": { @@ -34,9 +34,9 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/backend-core": "^1.0.200-alpha.3", - "@budibase/pro": "1.0.200-alpha.3", - "@budibase/string-templates": "^1.0.200-alpha.3", + "@budibase/backend-core": "^1.0.206", + "@budibase/pro": "1.0.206", + "@budibase/string-templates": "^1.0.206", "@koa/router": "8.0.8", "@sentry/node": "6.17.7", "@techpass/passport-openidconnect": "0.3.2", @@ -66,7 +66,7 @@ "server-destroy": "1.0.1" }, "devDependencies": { - "@budibase/types": "^1.0.200-alpha.3", + "@budibase/types": "^1.0.206", "@types/jest": "26.0.23", "@types/koa": "2.13.4", "@types/koa-router": "7.4.4", diff --git a/packages/worker/yarn.lock b/packages/worker/yarn.lock index 2c278dea6a..194ca3f061 100644 --- a/packages/worker/yarn.lock +++ b/packages/worker/yarn.lock @@ -291,10 +291,10 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@1.0.200-alpha.0": - version "1.0.200-alpha.0" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.200-alpha.0.tgz#2fd1e1cc71c07891fd66e37ceaab2cffb0df1106" - integrity sha512-CZPPuj+WIDTxLVbrv/B4J4rQiNnkRBs3ZWK2AvlVlY9knWuM034MKHPK3YaeQdVofZqkTOfWKZp6KFRroC304g== +"@budibase/backend-core@1.0.201-alpha.4": + version "1.0.201-alpha.4" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.201-alpha.4.tgz#51fda5838e9c51c88c85204ad867811e49b7d34c" + integrity sha512-5oQMfKPDMpB4x5MzGgOtWFIPzc7RG/uu+rSe65PVwWfp77bDa3kxtCtC1p6vtJuPlb4GYrHqGLtr7WePbJf4fA== dependencies: "@techpass/passport-openidconnect" "0.3.2" aws-sdk "2.1030.0" @@ -322,12 +322,12 @@ uuid "8.3.2" zlib "1.0.5" -"@budibase/pro@1.0.200-alpha.0": - version "1.0.200-alpha.0" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.200-alpha.0.tgz#68adc9a61a1b975a990e1a4d4ddf5dba69fc038c" - integrity sha512-GxIxvBjCO7kQxFwASKtGC57C2cAN3oiHU+tTCb57qKtp63GdP1z+iqDLtUEOIXXume9bC1xxTD/LSBMziTrHKg== +"@budibase/pro@1.0.201-alpha.4": + version "1.0.201-alpha.4" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.201-alpha.4.tgz#5b92dc7a4bb2004bcd43339c863430ea640e0b74" + integrity sha512-fsDlE8O4Y4JpZI3NwBoN8udX4cEx7/ebZ41Q7qD5VwA6Q2niapRcX0MvDmGdjDSVECG+NJU1uqCdg5cDq1Odxw== dependencies: - "@budibase/backend-core" "1.0.200-alpha.0" + "@budibase/backend-core" "1.0.201-alpha.4" node-fetch "^2.6.1" "@cspotcode/source-map-consumer@0.8.0":