Enable capturing events for certain setting changes, and track usage of side panels inside table blocks

This commit is contained in:
Andrew Kingston 2022-11-29 18:28:26 +00:00
parent a0776ac73a
commit 86fc2217a1
3 changed files with 16 additions and 4 deletions

View File

@ -1,5 +1,6 @@
export const Events = { export const Events = {
COMPONENT_CREATED: "component:created", COMPONENT_CREATED: "component:created",
COMPONENT_UPDATED: "component:updated",
APP_VIEW_PUBLISHED: "app:view_published", APP_VIEW_PUBLISHED: "app:view_published",
} }

View File

@ -6,6 +6,7 @@
import ResetFieldsButton from "components/design/settings/controls/ResetFieldsButton.svelte" import ResetFieldsButton from "components/design/settings/controls/ResetFieldsButton.svelte"
import EjectBlockButton from "components/design/settings/controls/EjectBlockButton.svelte" import EjectBlockButton from "components/design/settings/controls/EjectBlockButton.svelte"
import { getComponentForSetting } from "components/design/settings/componentSettings" import { getComponentForSetting } from "components/design/settings/componentSettings"
import analytics, { Events } from "analytics"
export let componentDefinition export let componentDefinition
export let componentInstance export let componentInstance
@ -44,9 +45,18 @@
return sections return sections
} }
const updateSetting = async (key, value) => { const updateSetting = async (setting, value) => {
try { try {
await store.actions.components.updateSetting(key, value) await store.actions.components.updateSetting(setting.key, value)
// Send event if required
if (setting.sendEvents) {
analytics.captureEvent(Events.COMPONENT_UPDATED, {
name: componentInstance._component,
setting: setting.key,
value,
})
}
} catch (error) { } catch (error) {
notifications.error("Error updating component prop") notifications.error("Error updating component prop")
} }
@ -113,7 +123,7 @@
label="Name" label="Name"
key="_instanceName" key="_instanceName"
value={componentInstance._instanceName} value={componentInstance._instanceName}
onChange={val => updateSetting("_instanceName", val)} onChange={val => updateSetting({ key: "_instanceName" }, val)}
/> />
{/if} {/if}
{#each section.settings as setting (setting.key)} {#each section.settings as setting (setting.key)}
@ -126,7 +136,7 @@
value={componentInstance[setting.key]} value={componentInstance[setting.key]}
defaultValue={setting.defaultValue} defaultValue={setting.defaultValue}
nested={setting.nested} nested={setting.nested}
onChange={val => updateSetting(setting.key, val)} onChange={val => updateSetting(setting, val)}
highlighted={$store.highlightedSettingKey === setting.key} highlighted={$store.highlightedSettingKey === setting.key}
info={setting.info} info={setting.info}
props={{ props={{

View File

@ -4546,6 +4546,7 @@
{ {
"type": "radio", "type": "radio",
"key": "clickBehaviour", "key": "clickBehaviour",
"sendEvents": true,
"defaultValue": "actions", "defaultValue": "actions",
"info": "Details side panel is only compatible with internal or SQL tables", "info": "Details side panel is only compatible with internal or SQL tables",
"options": [ "options": [