Remove ui events except for component created and view published app

This commit is contained in:
Rory Powell 2022-06-06 12:51:22 +01:00
parent 0a726be4bb
commit 6fbb5afeec
27 changed files with 15 additions and 169 deletions

View File

@ -1,57 +1,6 @@
export const Events = { export const Events = {
// TODO: Remove most UI events COMPONENT_CREATED: "component:created",
BUILDER: { APP_VIEW_PUBLISHED: "app:view_published",
STARTED: "Builder Started",
},
COMPONENT: {
CREATED: "Added Component",
},
DATASOURCE: {
CREATED: "Datasource Created",
UPDATED: "Datasource Updated",
},
QUERIES: {
REST: "REST Queries Imported",
},
TABLE: {
CREATED: "Table Created",
},
VIEW: {
CREATED: "View Created",
ADDED_FILTER: "Added View Filter",
ADDED_CALCULATE: "Added View Calculate",
},
SCREEN: {
CREATED: "Screen Created",
CREATE_ROLE_UPDATED: "Changed Role On Screen Creation",
},
AUTOMATION: {
CREATED: "Automation Created",
SAVED: "Automation Saved",
BLOCK_ADDED: "Added Automation Block",
},
NPS: {
SUBMITTED: "budibase:feedback_submitted",
},
APP: {
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",
OPT_OUT: "budibase:analytics_opt_out",
},
USER: {
INVITE: "budibase:portal_user_invite",
},
SMTP: {
SAVED: "budibase:smtp_saved",
},
SSO: {
SAVED: "budibase:sso_saved",
},
} }
export const EventSource = { export const EventSource = {

View File

@ -11,7 +11,6 @@ const posthog = new PosthogClient(
const sentry = new SentryClient(process.env.SENTRY_DSN) const sentry = new SentryClient(process.env.SENTRY_DSN)
const intercom = new IntercomClient(process.env.INTERCOM_TOKEN) const intercom = new IntercomClient(process.env.INTERCOM_TOKEN)
// TODO: Remove most UI events
class AnalyticsHub { class AnalyticsHub {
constructor() { constructor() {
this.clients = [posthog, sentry, intercom] this.clients = [posthog, sentry, intercom]
@ -25,11 +24,8 @@ class AnalyticsHub {
} }
} }
identify(id, metadata) { identify(id) {
posthog.identify(id) posthog.identify(id)
if (metadata) {
posthog.updateUser(metadata)
}
sentry.identify(id) sentry.identify(id)
} }
@ -46,10 +42,6 @@ class AnalyticsHub {
intercom.show(user) intercom.show(user)
} }
submitFeedback(values) {
posthog.npsFeedback(values)
}
async logout() { async logout() {
posthog.logout() posthog.logout()
intercom.logout() intercom.logout()

View File

@ -1,6 +1,5 @@
import { datasources, tables } from "../stores/backend" import { datasources, tables } from "../stores/backend"
import { IntegrationNames } from "../constants/backend" import { IntegrationNames } from "../constants/backend"
import analytics, { Events } from "../analytics"
import { get } from "svelte/store" import { get } from "svelte/store"
import cloneDeep from "lodash/cloneDeepWith" import cloneDeep from "lodash/cloneDeepWith"
@ -31,10 +30,6 @@ export async function saveDatasource(config, skipFetch = false) {
// update the tables incase data source plus // update the tables incase data source plus
await tables.fetch() await tables.fetch()
await datasources.select(resp._id) await datasources.select(resp._id)
analytics.captureEvent(Events.DATASOURCE.CREATED, {
name: resp.name,
source: resp.source,
})
return resp return resp
} }

View File

@ -2,7 +2,6 @@ import { writable } from "svelte/store"
import { API } from "api" import { API } from "api"
import Automation from "./Automation" import Automation from "./Automation"
import { cloneDeep } from "lodash/fp" import { cloneDeep } from "lodash/fp"
import analytics, { Events } from "analytics"
const initialAutomationState = { const initialAutomationState = {
automations: [], automations: [],
@ -125,9 +124,6 @@ const automationActions = store => ({
state.selectedBlock = newBlock state.selectedBlock = newBlock
return state return state
}) })
analytics.captureEvent(Events.AUTOMATION.BLOCK_ADDED, {
name: block.name,
})
}, },
toggleFieldControl: value => { toggleFieldControl: value => {
store.update(state => { store.update(state => {

View File

@ -426,7 +426,7 @@ export const getFrontendStore = () => {
}) })
// Log event // Log event
analytics.captureEvent(Events.COMPONENT.CREATED, { analytics.captureEvent(Events.COMPONENT_CREATED, {
name: componentInstance._component, name: componentInstance._component,
}) })

View File

@ -11,7 +11,6 @@
Body, Body,
Icon, Icon,
} from "@budibase/bbui" } from "@budibase/bbui"
import analytics, { Events } from "analytics"
let name let name
let selectedTrigger let selectedTrigger
@ -47,7 +46,6 @@
notifications.success(`Automation ${name} created`) notifications.success(`Automation ${name} created`)
$goto(`./${$automationStore.selectedAutomation.automation._id}`) $goto(`./${$automationStore.selectedAutomation.automation._id}`)
analytics.captureEvent(Events.AUTOMATION.CREATED, { name })
} catch (error) { } catch (error) {
notifications.error("Error creating automation") notifications.error("Error creating automation")
} }

View File

@ -2,7 +2,6 @@
import { automationStore } from "builderStore" import { automationStore } from "builderStore"
import { notifications } from "@budibase/bbui" import { notifications } from "@budibase/bbui"
import { Icon, Input, ModalContent, Modal } from "@budibase/bbui" import { Icon, Input, ModalContent, Modal } from "@budibase/bbui"
import analytics, { Events } from "analytics"
let name let name
let error = "" let error = ""
@ -27,7 +26,6 @@
} }
await automationStore.actions.save(updatedAutomation) await automationStore.actions.save(updatedAutomation)
notifications.success(`Automation ${name} updated successfully`) notifications.success(`Automation ${name} updated successfully`)
analytics.captureEvent(Events.AUTOMATION.SAVED, { name })
hide() hide()
} catch (error) { } catch (error) {
notifications.error("Error saving automation") notifications.error("Error saving automation")

View File

@ -1,7 +1,6 @@
<script> <script>
import { Select, Label, notifications, ModalContent } from "@budibase/bbui" import { Select, Label, notifications, ModalContent } from "@budibase/bbui"
import { tables, views } from "stores/backend" import { tables, views } from "stores/backend"
import analytics, { Events } from "analytics"
import { FIELDS } from "constants/backend" import { FIELDS } from "constants/backend"
const CALCULATIONS = [ const CALCULATIONS = [
@ -41,7 +40,6 @@
try { try {
views.save(view) views.save(view)
notifications.success(`View ${view.name} saved`) notifications.success(`View ${view.name} saved`)
analytics.captureEvent(Events.VIEW.ADDED_CALCULATE, { field: view.field })
} catch (error) { } catch (error) {
notifications.error("Error saving view") notifications.error("Error saving view")
} }

View File

@ -3,7 +3,6 @@
import { goto } from "@roxi/routify" import { goto } from "@roxi/routify"
import { views as viewsStore } from "stores/backend" import { views as viewsStore } from "stores/backend"
import { tables } from "stores/backend" import { tables } from "stores/backend"
import analytics, { Events } from "analytics"
let name let name
let field let field
@ -22,7 +21,6 @@
field, field,
}) })
notifications.success(`View ${name} created`) notifications.success(`View ${name} created`)
analytics.captureEvent(Events.VIEW.CREATED, { name })
$goto(`../../view/${name}`) $goto(`../../view/${name}`)
} catch (error) { } catch (error) {
notifications.error("Error creating view") notifications.error("Error creating view")

View File

@ -11,7 +11,6 @@
Icon, Icon,
} from "@budibase/bbui" } from "@budibase/bbui"
import { tables, views } from "stores/backend" import { tables, views } from "stores/backend"
import analytics, { Events } from "analytics"
const CONDITIONS = [ const CONDITIONS = [
{ {
@ -75,9 +74,6 @@
try { try {
views.save(view) views.save(view)
notifications.success(`View ${view.name} saved`) notifications.success(`View ${view.name} saved`)
analytics.captureEvent(Events.VIEW.ADDED_FILTER, {
filters: JSON.stringify(view.filters),
})
} catch (error) { } catch (error) {
notifications.error("Error saving view") notifications.error("Error saving view")
} }

View File

@ -11,7 +11,6 @@
TextArea, TextArea,
Dropzone, Dropzone,
} from "@budibase/bbui" } from "@budibase/bbui"
import analytics, { Events } from "analytics"
import { datasources, queries } from "stores/backend" import { datasources, queries } from "stores/backend"
import { writable } from "svelte/store" import { writable } from "svelte/store"
@ -72,11 +71,6 @@
} }
notifications.success(`Imported successfully.`) notifications.success(`Imported successfully.`)
analytics.captureEvent(Events.QUERIES.REST.IMPORTED, {
importType: lastTouched,
newDatasource: createDatasource,
})
return true return true
} catch (error) { } catch (error) {
notifications.error("Error importing queries") notifications.error("Error importing queries")

View File

@ -2,7 +2,6 @@
import { datasources } from "stores/backend" import { datasources } from "stores/backend"
import { notifications } from "@budibase/bbui" import { notifications } from "@budibase/bbui"
import { Input, ModalContent, Modal } from "@budibase/bbui" import { Input, ModalContent, Modal } from "@budibase/bbui"
import analytics, { Events } from "analytics"
let error = "" let error = ""
let modal let modal
@ -35,7 +34,6 @@
} }
await datasources.save(updatedDatasource) await datasources.save(updatedDatasource)
notifications.success(`Datasource ${name} updated successfully.`) notifications.success(`Datasource ${name} updated successfully.`)
analytics.captureEvent(Events.DATASOURCE.UPDATED, updatedDatasource)
hide() hide()
} }
</script> </script>

View File

@ -11,7 +11,6 @@
Layout, Layout,
} from "@budibase/bbui" } from "@budibase/bbui"
import TableDataImport from "../TableDataImport.svelte" import TableDataImport from "../TableDataImport.svelte"
import analytics, { Events } from "analytics"
import { buildAutoColumn, getAutoColumnInformation } from "builderStore/utils" import { buildAutoColumn, getAutoColumnInformation } from "builderStore/utils"
$: tableNames = $tables.list.map(table => table.name) $: tableNames = $tables.list.map(table => table.name)
@ -59,7 +58,6 @@
try { try {
table = await tables.save(newTable) table = await tables.save(newTable)
notifications.success(`Table ${name} created successfully.`) notifications.success(`Table ${name} created successfully.`)
analytics.captureEvent(Events.TABLE.CREATED, { name })
// Navigate to new table // Navigate to new table
const currentUrl = $url() const currentUrl = $url()

View File

@ -31,9 +31,6 @@
published = await API.deployAppChanges() published = await API.deployAppChanges()
analytics.captureEvent(Events.APP.PUBLISHED, {
appId: $store.appId,
})
if (typeof onOk === "function") { if (typeof onOk === "function") {
await onOk() await onOk()
} }
@ -49,7 +46,7 @@
const viewApp = () => { const viewApp = () => {
if (published) { if (published) {
analytics.captureEvent(Events.APP.VIEW_PUBLISHED, { analytics.captureEvent(Events.APP_VIEW_PUBLISHED, {
appId: $store.appId, appId: $store.appId,
eventSource: EventSource.PORTAL, eventSource: EventSource.PORTAL,
}) })

View File

@ -57,7 +57,7 @@
} }
const viewApp = () => { const viewApp = () => {
analytics.captureEvent(Events.APP.VIEW_PUBLISHED, { analytics.captureEvent(Events.APP_VIEW_PUBLISHED, {
appId: selectedApp.appId, appId: selectedApp.appId,
eventSource: EventSource.PORTAL, eventSource: EventSource.PORTAL,
}) })
@ -79,9 +79,6 @@
return return
} }
try { try {
analytics.captureEvent(Events.APP.UNPUBLISHED, {
appId: selectedApp.appId,
})
await API.unpublishApp(selectedApp.prodId) await API.unpublishApp(selectedApp.prodId)
await apps.load() await apps.load()
notifications.success("App unpublished successfully") notifications.success("App unpublished successfully")

View File

@ -12,7 +12,6 @@
} from "@budibase/bbui" } from "@budibase/bbui"
import ScreenDetailsModal from "../ScreenDetailsModal.svelte" import ScreenDetailsModal from "../ScreenDetailsModal.svelte"
import sanitizeUrl from "builderStore/store/screenTemplates/utils/sanitizeUrl" import sanitizeUrl from "builderStore/store/screenTemplates/utils/sanitizeUrl"
import analytics, { Events } from "analytics"
import { makeComponentUnique } from "builderStore/componentUtils" import { makeComponentUnique } from "builderStore/componentUtils"
export let screenId export let screenId
@ -40,13 +39,6 @@
try { try {
// Create the screen // Create the screen
await store.actions.screens.save(duplicateScreen) await store.actions.screens.save(duplicateScreen)
// Analytics
if (screen.template) {
analytics.captureEvent(Events.SCREEN.CREATED, {
template: "createFromScratch",
})
}
} catch (error) { } catch (error) {
notifications.error("Error duplicating screen") notifications.error("Error duplicating screen")
console.log(error) console.log(error)

View File

@ -5,7 +5,6 @@
import sanitizeUrl from "builderStore/store/screenTemplates/utils/sanitizeUrl" import sanitizeUrl from "builderStore/store/screenTemplates/utils/sanitizeUrl"
import { Modal, ModalContent, Select, notifications } from "@budibase/bbui" import { Modal, ModalContent, Select, notifications } from "@budibase/bbui"
import { store, selectedAccessRole } from "builderStore" import { store, selectedAccessRole } from "builderStore"
import analytics, { Events } from "analytics"
import { get } from "svelte/store" import { get } from "svelte/store"
import getTemplates from "builderStore/store/screenTemplates" import getTemplates from "builderStore/store/screenTemplates"
import { tables, roles } from "stores/backend" import { tables, roles } from "stores/backend"
@ -65,15 +64,6 @@
// Create the screen // Create the screen
await store.actions.screens.save(screen) await store.actions.screens.save(screen)
// Analytics
if (screen.template) {
analytics.captureEvent(Events.SCREEN.CREATED, {
template: screen.template,
datasource: screen.datasource,
screenAccessRole,
})
}
// Add link in layout for list screens // Add link in layout for list screens
if (screen.props._instanceName.endsWith("List")) { if (screen.props._instanceName.endsWith("List")) {
await store.actions.components.links.save( await store.actions.components.links.save(
@ -208,11 +198,6 @@
Select which level of access you want your screens to have Select which level of access you want your screens to have
<Select <Select
bind:value={screenAccessRole} bind:value={screenAccessRole}
on:change={() => {
analytics.captureEvent(Events.SCREEN.CREATE_ROLE_UPDATED, {
screenAccessRole,
})
}}
label="Access" label="Access"
getOptionLabel={role => role.name} getOptionLabel={role => role.name}
getOptionValue={role => role._id} getOptionValue={role => role._id}

View File

@ -4,7 +4,6 @@
import { store, automationStore } from "builderStore" import { store, automationStore } from "builderStore"
import { API } from "api" import { API } from "api"
import { apps, admin, auth } from "stores/portal" import { apps, admin, auth } from "stores/portal"
import analytics, { Events } from "analytics"
import { onMount } from "svelte" import { onMount } from "svelte"
import { goto } from "@roxi/routify" import { goto } from "@roxi/routify"
import { createValidationStore } from "helpers/validation/yup" import { createValidationStore } from "helpers/validation/yup"
@ -103,11 +102,6 @@
// Create App // Create App
const createdApp = await API.createApp(data) const createdApp = await API.createApp(data)
analytics.captureEvent(Events.APP.CREATED, {
name: $values.name,
appId: createdApp.instance._id,
templateToUse: template,
})
// Select Correct Application/DB in prep for creating user // Select Correct Application/DB in prep for creating user
const pkg = await API.fetchAppPackage(createdApp.instance._id) const pkg = await API.fetchAppPackage(createdApp.instance._id)

View File

@ -138,12 +138,6 @@
// Create App // Create App
const createdApp = await API.createApp(data) const createdApp = await API.createApp(data)
analytics.captureEvent(Events.APP.CREATED, {
name: appName,
appId: createdApp.instance._id,
template,
fromTemplateMarketplace: true,
})
// Select Correct Application/DB in prep for creating user // Select Correct Application/DB in prep for creating user
const pkg = await API.fetchAppPackage(createdApp.instance._id) const pkg = await API.fetchAppPackage(createdApp.instance._id)
@ -169,7 +163,7 @@
} }
const viewApp = app => { const viewApp = app => {
analytics.captureEvent(Events.APP.VIEW_PUBLISHED, { analytics.captureEvent(Events.APP_VIEW_PUBLISHED, {
appId: app.appId, appId: app.appId,
eventSource: EventSource.PORTAL, eventSource: EventSource.PORTAL,
}) })
@ -215,9 +209,6 @@
return return
} }
try { try {
analytics.captureEvent(Events.APP.UNPUBLISHED, {
appId: selectedApp.appId,
})
await API.unpublishApp(selectedApp.prodId) await API.unpublishApp(selectedApp.prodId)
await apps.load() await apps.load()
notifications.success("App unpublished successfully") notifications.success("App unpublished successfully")

View File

@ -23,7 +23,6 @@
import { API } from "api" import { API } from "api"
import { organisation, admin } from "stores/portal" import { organisation, admin } from "stores/portal"
import { Helpers } from "@budibase/bbui" import { Helpers } from "@budibase/bbui"
import analytics, { Events } from "analytics"
const ConfigTypes = { const ConfigTypes = {
Google: "google", Google: "google",
@ -209,8 +208,6 @@
providers[res.type]._id = res._id providers[res.type]._id = res._id
}) })
notifications.success(`Settings saved`) notifications.success(`Settings saved`)
// todo: move to api
analytics.captureEvent(Events.SSO.SAVED)
}) })
.catch(() => { .catch(() => {
notifications.error("Failed to update auth settings") notifications.error("Failed to update auth settings")

View File

@ -16,7 +16,6 @@
import { email, admin } from "stores/portal" import { email, admin } from "stores/portal"
import { API } from "api" import { API } from "api"
import { cloneDeep } from "lodash/fp" import { cloneDeep } from "lodash/fp"
import analytics, { Events } from "analytics"
const ConfigTypes = { const ConfigTypes = {
SMTP: "smtp", SMTP: "smtp",
@ -60,7 +59,6 @@
smtpConfig._id = savedConfig._id smtpConfig._id = savedConfig._id
await admin.getChecklist() await admin.getChecklist()
notifications.success(`Settings saved`) notifications.success(`Settings saved`)
analytics.captureEvent(Events.SMTP.SAVED)
} catch (error) { } catch (error) {
notifications.error( notifications.error(
`Failed to save email settings, reason: ${error?.message || "Unknown"}` `Failed to save email settings, reason: ${error?.message || "Unknown"}`
@ -80,7 +78,6 @@
} }
await admin.getChecklist() await admin.getChecklist()
notifications.success(`Settings cleared`) notifications.success(`Settings cleared`)
analytics.captureEvent(Events.SMTP.SAVED)
} catch (error) { } catch (error) {
notifications.error( notifications.error(
`Failed to clear email settings, reason: ${error?.message || "Unknown"}` `Failed to clear email settings, reason: ${error?.message || "Unknown"}`

View File

@ -10,7 +10,6 @@
} from "@budibase/bbui" } from "@budibase/bbui"
import { createValidationStore, emailValidator } from "helpers/validation" import { createValidationStore, emailValidator } from "helpers/validation"
import { users } from "stores/portal" import { users } from "stores/portal"
import analytics, { Events } from "analytics"
export let disabled export let disabled
@ -24,7 +23,6 @@
try { try {
const res = await users.invite({ email: $email, builder, admin }) const res = await users.invite({ email: $email, builder, admin })
notifications.success(res.message) notifications.success(res.message)
analytics.captureEvent(Events.USER.INVITE, { type: selected })
} catch (error) { } catch (error) {
notifications.error("Error inviting user") notifications.error("Error inviting user")
} }

View File

@ -115,7 +115,7 @@
const viewApp = () => { const viewApp = () => {
if (isPublished) { if (isPublished) {
analytics.captureEvent(Events.APP.VIEW_PUBLISHED, { analytics.captureEvent(Events.APP_VIEW_PUBLISHED, {
appId: $store.appId, appId: $store.appId,
eventSource: EventSource.PORTAL, eventSource: EventSource.PORTAL,
}) })
@ -154,9 +154,6 @@
return return
} }
try { try {
analytics.captureEvent(Events.APP.UNPUBLISHED, {
appId: selectedApp.appId,
})
await API.unpublishApp(selectedApp.prodId) await API.unpublishApp(selectedApp.prodId)
await apps.load() await apps.load()
notifications.success("App unpublished successfully") notifications.success("App unpublished successfully")

View File

@ -57,7 +57,7 @@ export function createAuthStore() {
analytics analytics
.activate() .activate()
.then(() => { .then(() => {
analytics.identify(user._id, user) analytics.identify(user._id)
analytics.showChat({ analytics.showChat({
email: user.email, email: user.email,
created_at: (user.createdAt || Date.now()) / 1000, created_at: (user.createdAt || Date.now()) / 1000,

View File

@ -1,16 +1,10 @@
const PostHog = require("posthog-node") const PostHog = require("posthog-node")
const { const { POSTHOG_TOKEN, AnalyticsEvents } = require("../constants")
BUDIBASE_POSTHOG_URL,
BUDIBASE_POSTHOG_TOKEN,
AnalyticsEvents,
} = require("../constants")
const ConfigManager = require("../structures/ConfigManager") const ConfigManager = require("../structures/ConfigManager")
class AnalyticsClient { class AnalyticsClient {
constructor() { constructor() {
this.client = new PostHog(BUDIBASE_POSTHOG_TOKEN, { this.client = new PostHog(POSTHOG_TOKEN)
host: BUDIBASE_POSTHOG_URL,
})
this.configManager = new ConfigManager() this.configManager = new ConfigManager()
} }

View File

@ -10,11 +10,9 @@ exports.InitTypes = {
} }
exports.AnalyticsEvents = { exports.AnalyticsEvents = {
OptOut: "analytics_opt_out", OptOut: "analytics:opt:out",
OptIn: "analytics_opt_in", OptIn: "analytics:opt:in",
SelfHostInit: "hosting_init", SelfHostInit: "hosting:init",
} }
exports.BUDIBASE_POSTHOG_URL = "https://app.posthog.com" exports.POSTHOG_TOKEN = "phc_yGOn4i7jWKaCTapdGR6lfA4AvmuEQ2ijn5zAVSFYPlS"
exports.BUDIBASE_POSTHOG_TOKEN =
"phc_yGOn4i7jWKaCTapdGR6lfA4AvmuEQ2ijn5zAVSFYPlS"

View File

@ -70,7 +70,6 @@ module.exports = {
AUTOMATION_MAX_ITERATIONS: process.env.AUTOMATION_MAX_ITERATIONS, AUTOMATION_MAX_ITERATIONS: process.env.AUTOMATION_MAX_ITERATIONS,
SENDGRID_API_KEY: process.env.SENDGRID_API_KEY, SENDGRID_API_KEY: process.env.SENDGRID_API_KEY,
DYNAMO_ENDPOINT: process.env.DYNAMO_ENDPOINT, DYNAMO_ENDPOINT: process.env.DYNAMO_ENDPOINT,
POSTHOG_TOKEN: process.env.POSTHOG_TOKEN,
QUERY_THREAD_TIMEOUT: parseIntSafe(process.env.QUERY_THREAD_TIMEOUT), QUERY_THREAD_TIMEOUT: parseIntSafe(process.env.QUERY_THREAD_TIMEOUT),
SQL_MAX_ROWS: process.env.SQL_MAX_ROWS, SQL_MAX_ROWS: process.env.SQL_MAX_ROWS,
// flags // flags