Added events for viewing a production application and unpublishing

This commit is contained in:
Dean 2022-04-20 11:08:06 +01:00
parent d94ff81e0e
commit 1eff790fe8
6 changed files with 33 additions and 11 deletions

View File

@ -35,6 +35,7 @@ export const Events = {
CREATED: "budibase:app_created",
PUBLISHED: "budibase:app_published",
UNPUBLISHED: "budibase:app_unpublished",
VIEW_PUBLISHED: "budibase:view_published_app",
},
ANALYTICS: {
OPT_IN: "budibase:analytics_opt_in",
@ -50,3 +51,9 @@ export const Events = {
SAVED: "budibase:sso_saved",
},
}
export const EventSource = {
PORTAL: "portal",
URL: "url",
NOTIFICATION: "notification",
}

View File

@ -7,7 +7,7 @@
Layout,
} from "@budibase/bbui"
import { API } from "api"
import analytics, { Events } from "analytics"
import analytics, { Events, EventSource } from "analytics"
import { store } from "builderStore"
import { ProgressCircle } from "@budibase/bbui"
import CopyInput from "components/common/inputs/CopyInput.svelte"
@ -49,6 +49,10 @@
const viewApp = () => {
if (published) {
analytics.captureEvent(Events.APP.VIEW_PUBLISHED, {
appId: $store.appId,
eventSource: EventSource.PORTAL,
})
window.open(publishedUrl, "_blank")
}
}

View File

@ -90,11 +90,6 @@
</div>
<ActionMenu align="right">
<Icon hoverable slot="control" name="More" dataCy="app-row-actions-menu" />
{#if app.deployed}
<MenuItem on:click={() => viewApp(app)} icon="GlobeOutline">
View published app
</MenuItem>
{/if}
{#if app.lockedYou}
<MenuItem on:click={() => releaseLock(app)} icon="LockOpen">
Release lock

View File

@ -25,6 +25,7 @@
import { onMount, onDestroy } from "svelte"
import { processStringSync } from "@budibase/string-templates"
import { checkIncomingDeploymentStatus } from "components/deploy/utils"
import analytics, { Events, EventSource } from "analytics"
export let application
@ -73,6 +74,10 @@
}
const viewApp = () => {
analytics.captureEvent(Events.APP.VIEW_PUBLISHED, {
appId: selectedApp.appId,
eventSource: EventSource.PORTAL,
})
if (selectedApp.url) {
window.open(`/app${selectedApp.url}`)
} else {
@ -168,6 +173,9 @@
return
}
try {
analytics.captureEvent(Events.APP.UNPUBLISHED, {
appId: selectedApp.appId,
})
await API.unpublishApp(selectedApp.prodId)
await apps.load()
notifications.success("App unpublished successfully")

View File

@ -28,7 +28,7 @@
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
import AppRow from "components/start/AppRow.svelte"
import { AppStatus } from "constants"
import analytics, { Events } from "analytics"
import analytics, { Events, EventSource } from "analytics"
import Logo from "assets/bb-space-man.svg"
let sortBy = "name"
@ -167,6 +167,10 @@
}
const viewApp = app => {
analytics.captureEvent(Events.APP.VIEW_PUBLISHED, {
appId: app.appId,
eventSource: EventSource.PORTAL,
})
if (app.url) {
window.open(`/app${app.url}`)
} else {
@ -209,6 +213,9 @@
return
}
try {
analytics.captureEvent(Events.APP.UNPUBLISHED, {
appId: selectedApp.appId,
})
await API.unpublishApp(selectedApp.prodId)
await apps.load()
notifications.success("App unpublished successfully")

View File

@ -351,19 +351,20 @@ exports.revertClient = async ctx => {
exports.delete = async ctx => {
let appId = ctx.params.appId
let isUnpublish = ctx.query && ctx.query.unpublish
if (ctx.query && ctx.query.unpublish) {
if (isUnpublish) {
appId = getProdAppID(appId)
}
const db = ctx.query.unpublish ? getProdAppDB() : getAppDB()
const db = isUnpublish ? getProdAppDB() : getAppDB()
const result = await db.destroy()
/* istanbul ignore next */
if (!env.isTest() && !ctx.query.unpublish) {
if (!env.isTest() && !isUnpublish) {
await deleteApp(appId)
}
if (ctx.query && ctx.query.unpublish) {
if (isUnpublish) {
await cleanupAutomations(appId)
}
// make sure the app/role doesn't stick around after the app has been deleted