merge
This commit is contained in:
commit
016f49ac5a
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": "0.1.21",
|
"version": "0.1.23",
|
||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
"packages": [
|
"packages": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
|
|
|
@ -14,6 +14,7 @@ rimraf.sync(homedir)
|
||||||
|
|
||||||
process.env.BUDIBASE_API_KEY = "6BE826CB-6B30-4AEC-8777-2E90464633DE"
|
process.env.BUDIBASE_API_KEY = "6BE826CB-6B30-4AEC-8777-2E90464633DE"
|
||||||
process.env.NODE_ENV = "cypress"
|
process.env.NODE_ENV = "cypress"
|
||||||
|
process.env.ENABLE_ANALYTICS = "false"
|
||||||
|
|
||||||
initialiseBudibase({ dir: homedir, clientId: "cypress-test" })
|
initialiseBudibase({ dir: homedir, clientId: "cypress-test" })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/builder",
|
"name": "@budibase/builder",
|
||||||
"version": "0.1.21",
|
"version": "0.1.23",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -64,7 +64,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/bbui": "^1.34.6",
|
"@budibase/bbui": "^1.34.6",
|
||||||
"@budibase/client": "^0.1.21",
|
"@budibase/client": "^0.1.23",
|
||||||
"@budibase/colorpicker": "^1.0.1",
|
"@budibase/colorpicker": "^1.0.1",
|
||||||
"@fortawesome/fontawesome-free": "^5.14.0",
|
"@fortawesome/fontawesome-free": "^5.14.0",
|
||||||
"@sentry/browser": "5.19.1",
|
"@sentry/browser": "5.19.1",
|
||||||
|
@ -75,7 +75,7 @@
|
||||||
"fast-sort": "^2.2.0",
|
"fast-sort": "^2.2.0",
|
||||||
"lodash": "^4.17.13",
|
"lodash": "^4.17.13",
|
||||||
"mustache": "^4.0.1",
|
"mustache": "^4.0.1",
|
||||||
"posthog-js": "1.3.1",
|
"posthog-js": "1.4.5",
|
||||||
"shortid": "^2.2.15",
|
"shortid": "^2.2.15",
|
||||||
"svelte-loading-spinners": "^0.1.1",
|
"svelte-loading-spinners": "^0.1.1",
|
||||||
"svelte-portal": "^0.1.0",
|
"svelte-portal": "^0.1.0",
|
||||||
|
|
|
@ -158,6 +158,10 @@ export default {
|
||||||
find: "constants",
|
find: "constants",
|
||||||
replacement: path.resolve(projectRootDir, "src/constants"),
|
replacement: path.resolve(projectRootDir, "src/constants"),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
find: "analytics",
|
||||||
|
replacement: path.resolve(projectRootDir, "src/analytics"),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
customResolver,
|
customResolver,
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -1,25 +1,71 @@
|
||||||
import * as Sentry from "@sentry/browser"
|
import * as Sentry from "@sentry/browser"
|
||||||
import posthog from "posthog-js"
|
import posthog from "posthog-js"
|
||||||
|
import api from "builderStore/api"
|
||||||
|
|
||||||
function activate() {
|
let analyticsEnabled
|
||||||
Sentry.init({ dsn: process.env.SENTRY_DSN })
|
const posthogConfigured = process.env.POSTHOG_TOKEN && process.env.POSTHOG_URL
|
||||||
if (!process.env.POSTHOG_TOKEN) return
|
const sentryConfigured = process.env.SENTRY_DSN
|
||||||
posthog.init(process.env.POSTHOG_TOKEN, {
|
|
||||||
api_host: process.env.POSTHOG_URL,
|
async function activate() {
|
||||||
})
|
if (analyticsEnabled === undefined) {
|
||||||
|
// only the server knows the true NODE_ENV
|
||||||
|
// this was an issue as NODE_ENV = 'cypress' on the server,
|
||||||
|
// but 'production' on the client
|
||||||
|
const response = await api.get("/api/analytics")
|
||||||
|
analyticsEnabled = (await response.json()) === true
|
||||||
|
}
|
||||||
|
if (!analyticsEnabled) return
|
||||||
|
if (sentryConfigured) Sentry.init({ dsn: process.env.SENTRY_DSN })
|
||||||
|
if (posthogConfigured) {
|
||||||
|
posthog.init(process.env.POSTHOG_TOKEN, {
|
||||||
|
api_host: process.env.POSTHOG_URL,
|
||||||
|
})
|
||||||
|
posthog.set_config({ persistence: "cookie" })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function identify(id) {
|
||||||
|
if (!analyticsEnabled || !id) return
|
||||||
|
if (posthogConfigured) posthog.identify(id)
|
||||||
|
if (sentryConfigured)
|
||||||
|
Sentry.configureScope(scope => {
|
||||||
|
scope.setUser({ id: id })
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function identifyByApiKey(apiKey) {
|
||||||
|
if (!analyticsEnabled) return true
|
||||||
|
const response = await fetch(
|
||||||
|
`https://03gaine137.execute-api.eu-west-1.amazonaws.com/prod/account/id?api_key=${apiKey.trim()}`
|
||||||
|
)
|
||||||
|
|
||||||
|
if (response.status === 200) {
|
||||||
|
const id = await response.json()
|
||||||
|
|
||||||
|
await api.put("/api/keys/userId", { value: id })
|
||||||
|
identify(id)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
function captureException(err) {
|
function captureException(err) {
|
||||||
|
if (!analyticsEnabled) return
|
||||||
Sentry.captureException(err)
|
Sentry.captureException(err)
|
||||||
|
captureEvent("Error", { error: err.message ? err.message : err })
|
||||||
}
|
}
|
||||||
|
|
||||||
function captureEvent(event) {
|
function captureEvent(eventName, props = {}) {
|
||||||
if (!process.env.POSTHOG_TOKEN) return
|
if (!analyticsEnabled || !process.env.POSTHOG_TOKEN) return
|
||||||
posthog.capture(event)
|
props.sourceApp = "builder"
|
||||||
|
posthog.capture(eventName, props)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
activate,
|
activate,
|
||||||
|
identify,
|
||||||
|
identifyByApiKey,
|
||||||
captureException,
|
captureException,
|
||||||
captureEvent,
|
captureEvent,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { getStore } from "./store"
|
import { getStore } from "./store"
|
||||||
import { getBackendUiStore } from "./store/backend"
|
import { getBackendUiStore } from "./store/backend"
|
||||||
import { getAutomationStore } from "./store/automation/"
|
import { getAutomationStore } from "./store/automation/"
|
||||||
import analytics from "../analytics"
|
import analytics from "analytics"
|
||||||
|
|
||||||
export const store = getStore()
|
export const store = getStore()
|
||||||
export const backendUiStore = getBackendUiStore()
|
export const backendUiStore = getBackendUiStore()
|
||||||
|
@ -9,9 +9,8 @@ export const automationStore = getAutomationStore()
|
||||||
|
|
||||||
export const initialise = async () => {
|
export const initialise = async () => {
|
||||||
try {
|
try {
|
||||||
if (process.env.NODE_ENV === "production") {
|
analytics.activate()
|
||||||
analytics.activate()
|
analytics.captureEvent("Builder Started")
|
||||||
}
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import { fetchComponentLibDefinitions } from "../loadComponentLibraries"
|
||||||
import { buildCodeForScreens } from "../buildCodeForScreens"
|
import { buildCodeForScreens } from "../buildCodeForScreens"
|
||||||
import { generate_screen_css } from "../generate_css"
|
import { generate_screen_css } from "../generate_css"
|
||||||
import { insertCodeMetadata } from "../insertCodeMetadata"
|
import { insertCodeMetadata } from "../insertCodeMetadata"
|
||||||
|
import analytics from "analytics"
|
||||||
import { uuid } from "../uuid"
|
import { uuid } from "../uuid"
|
||||||
import {
|
import {
|
||||||
selectComponent as _selectComponent,
|
selectComponent as _selectComponent,
|
||||||
|
@ -308,7 +309,9 @@ const addChildComponent = store => (componentToAdd, presetProps = {}) => {
|
||||||
|
|
||||||
state.currentView = "component"
|
state.currentView = "component"
|
||||||
state.currentComponentInfo = newComponent.props
|
state.currentComponentInfo = newComponent.props
|
||||||
|
analytics.captureEvent("Added Component", {
|
||||||
|
name: newComponent.props._component,
|
||||||
|
})
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
import { notifier } from "builderStore/store/notifications"
|
import { notifier } from "builderStore/store/notifications"
|
||||||
import ActionButton from "components/common/ActionButton.svelte"
|
import ActionButton from "components/common/ActionButton.svelte"
|
||||||
import { Input } from "@budibase/bbui"
|
import { Input } from "@budibase/bbui"
|
||||||
|
import analytics from "analytics"
|
||||||
|
|
||||||
export let onClosed
|
export let onClosed
|
||||||
|
|
||||||
|
@ -19,6 +20,7 @@
|
||||||
})
|
})
|
||||||
onClosed()
|
onClosed()
|
||||||
notifier.success(`Automation ${name} created.`)
|
notifier.success(`Automation ${name} created.`)
|
||||||
|
analytics.captureEvent("Automation Created", { name })
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import { automationStore } from "builderStore"
|
import { automationStore } from "builderStore"
|
||||||
|
import analytics from "analytics"
|
||||||
|
|
||||||
export let blockDefinition
|
export let blockDefinition
|
||||||
export let stepId
|
export let stepId
|
||||||
|
@ -12,6 +13,9 @@
|
||||||
stepId,
|
stepId,
|
||||||
type: blockType,
|
type: blockType,
|
||||||
})
|
})
|
||||||
|
analytics.captureEvent("Added Automation Block", {
|
||||||
|
name: blockDefinition.name,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
import { backendUiStore } from "builderStore"
|
import { backendUiStore } from "builderStore"
|
||||||
import { notifier } from "builderStore/store/notifications"
|
import { notifier } from "builderStore/store/notifications"
|
||||||
import CreateEditRecord from "../modals/CreateEditRecord.svelte"
|
import CreateEditRecord from "../modals/CreateEditRecord.svelte"
|
||||||
|
import analytics from "analytics"
|
||||||
|
|
||||||
const CALCULATIONS = [
|
const CALCULATIONS = [
|
||||||
{
|
{
|
||||||
|
@ -35,6 +36,7 @@
|
||||||
function saveView() {
|
function saveView() {
|
||||||
backendUiStore.actions.views.save(view)
|
backendUiStore.actions.views.save(view)
|
||||||
notifier.success(`View ${view.name} saved.`)
|
notifier.success(`View ${view.name} saved.`)
|
||||||
|
analytics.captureEvent("Added View Calculate", { field: view.field })
|
||||||
dropdown.hide()
|
dropdown.hide()
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -50,14 +52,14 @@
|
||||||
<div class="input-group-row">
|
<div class="input-group-row">
|
||||||
<p>The</p>
|
<p>The</p>
|
||||||
<Select secondary thin bind:value={view.calculation}>
|
<Select secondary thin bind:value={view.calculation}>
|
||||||
<option value={null} />
|
<option value="">Choose an option</option>
|
||||||
{#each CALCULATIONS as calculation}
|
{#each CALCULATIONS as calculation}
|
||||||
<option value={calculation.key}>{calculation.name}</option>
|
<option value={calculation.key}>{calculation.name}</option>
|
||||||
{/each}
|
{/each}
|
||||||
</Select>
|
</Select>
|
||||||
<p>of</p>
|
<p>of</p>
|
||||||
<Select secondary thin bind:value={view.field}>
|
<Select secondary thin bind:value={view.field}>
|
||||||
<option value={null} />
|
<option value="">Choose an option</option>
|
||||||
{#each fields as field}
|
{#each fields as field}
|
||||||
<option value={field}>{field}</option>
|
<option value={field}>{field}</option>
|
||||||
{/each}
|
{/each}
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
<Popover bind:this={dropdown} {anchor} align="left">
|
<Popover bind:this={dropdown} {anchor} align="left">
|
||||||
<h5>Export Format</h5>
|
<h5>Export Format</h5>
|
||||||
<Select secondary thin bind:value={exportFormat}>
|
<Select secondary thin bind:value={exportFormat}>
|
||||||
|
<option value={''}>Select an option</option>
|
||||||
{#each FORMATS as format}
|
{#each FORMATS as format}
|
||||||
<option value={format.key}>{format.name}</option>
|
<option value={format.key}>{format.name}</option>
|
||||||
{/each}
|
{/each}
|
||||||
|
@ -66,6 +67,5 @@
|
||||||
margin-top: var(--spacing-l);
|
margin-top: var(--spacing-l);
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
gap: var(--spacing-s);
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
import { backendUiStore } from "builderStore"
|
import { backendUiStore } from "builderStore"
|
||||||
import { notifier } from "builderStore/store/notifications"
|
import { notifier } from "builderStore/store/notifications"
|
||||||
import CreateEditRecord from "../modals/CreateEditRecord.svelte"
|
import CreateEditRecord from "../modals/CreateEditRecord.svelte"
|
||||||
|
import analytics from "analytics"
|
||||||
|
|
||||||
const CONDITIONS = [
|
const CONDITIONS = [
|
||||||
{
|
{
|
||||||
|
@ -63,6 +64,9 @@
|
||||||
backendUiStore.actions.views.save(view)
|
backendUiStore.actions.views.save(view)
|
||||||
notifier.success(`View ${view.name} saved.`)
|
notifier.success(`View ${view.name} saved.`)
|
||||||
dropdown.hide()
|
dropdown.hide()
|
||||||
|
analytics.captureEvent("Added View Filter", {
|
||||||
|
filters: JSON.stringify(view.filters),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeFilter(idx) {
|
function removeFilter(idx) {
|
||||||
|
@ -102,17 +106,20 @@
|
||||||
<p>Where</p>
|
<p>Where</p>
|
||||||
{:else}
|
{:else}
|
||||||
<Select secondary thin bind:value={filter.conjunction}>
|
<Select secondary thin bind:value={filter.conjunction}>
|
||||||
|
<option value="">Choose an option</option>
|
||||||
{#each CONJUNCTIONS as conjunction}
|
{#each CONJUNCTIONS as conjunction}
|
||||||
<option value={conjunction.key}>{conjunction.name}</option>
|
<option value={conjunction.key}>{conjunction.name}</option>
|
||||||
{/each}
|
{/each}
|
||||||
</Select>
|
</Select>
|
||||||
{/if}
|
{/if}
|
||||||
<Select secondary thin bind:value={filter.key}>
|
<Select secondary thin bind:value={filter.key}>
|
||||||
|
<option value="">Choose an option</option>
|
||||||
{#each fields as field}
|
{#each fields as field}
|
||||||
<option value={field}>{field}</option>
|
<option value={field}>{field}</option>
|
||||||
{/each}
|
{/each}
|
||||||
</Select>
|
</Select>
|
||||||
<Select secondary thin bind:value={filter.condition}>
|
<Select secondary thin bind:value={filter.condition}>
|
||||||
|
<option value="">Choose an option</option>
|
||||||
{#each CONDITIONS as condition}
|
{#each CONDITIONS as condition}
|
||||||
<option value={condition.key}>{condition.name}</option>
|
<option value={condition.key}>{condition.name}</option>
|
||||||
{/each}
|
{/each}
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
<div class="input-group-row">
|
<div class="input-group-row">
|
||||||
<p>Group By</p>
|
<p>Group By</p>
|
||||||
<Select secondary thin bind:value={view.groupBy}>
|
<Select secondary thin bind:value={view.groupBy}>
|
||||||
<option value={false} />
|
<option value="">Choose an option</option>
|
||||||
{#each fields as field}
|
{#each fields as field}
|
||||||
<option value={field}>{field}</option>
|
<option value={field}>{field}</option>
|
||||||
{/each}
|
{/each}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
import { backendUiStore } from "builderStore"
|
import { backendUiStore } from "builderStore"
|
||||||
import { notifier } from "builderStore/store/notifications"
|
import { notifier } from "builderStore/store/notifications"
|
||||||
import CreateEditRecord from "../modals/CreateEditRecord.svelte"
|
import CreateEditRecord from "../modals/CreateEditRecord.svelte"
|
||||||
|
import analytics from "analytics"
|
||||||
|
|
||||||
let anchor
|
let anchor
|
||||||
let dropdown
|
let dropdown
|
||||||
|
@ -37,6 +38,7 @@
|
||||||
})
|
})
|
||||||
notifier.success(`View ${name} created`)
|
notifier.success(`View ${name} created`)
|
||||||
dropdown.hide()
|
dropdown.hide()
|
||||||
|
analytics.captureEvent("View Created", { name })
|
||||||
$goto(`../../../view/${name}`)
|
$goto(`../../../view/${name}`)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
import { backendUiStore } from "builderStore"
|
import { backendUiStore } from "builderStore"
|
||||||
import { notifier } from "builderStore/store/notifications"
|
import { notifier } from "builderStore/store/notifications"
|
||||||
import { DropdownMenu, Button, Icon, Input, Select } from "@budibase/bbui"
|
import { DropdownMenu, Button, Icon, Input, Select } from "@budibase/bbui"
|
||||||
|
import analytics from "analytics"
|
||||||
|
|
||||||
export let table
|
export let table
|
||||||
|
|
||||||
|
@ -19,6 +20,7 @@
|
||||||
$goto(`./model/${model._id}`)
|
$goto(`./model/${model._id}`)
|
||||||
name = ""
|
name = ""
|
||||||
dropdown.hide()
|
dropdown.hide()
|
||||||
|
analytics.captureEvent("Table Created", { name })
|
||||||
}
|
}
|
||||||
|
|
||||||
const onClosed = () => {
|
const onClosed = () => {
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
name="Name"
|
name="Name"
|
||||||
placeholder="Username" />
|
placeholder="Username" />
|
||||||
<Select disabled={!editMode} bind:value={user.accessLevelId} thin>
|
<Select disabled={!editMode} bind:value={user.accessLevelId} thin>
|
||||||
|
<option value="">Choose an option</option>
|
||||||
<option value="ADMIN">Admin</option>
|
<option value="ADMIN">Admin</option>
|
||||||
<option value="POWER_USER">Power User</option>
|
<option value="POWER_USER">Power User</option>
|
||||||
</Select>
|
</Select>
|
||||||
|
|
|
@ -3,13 +3,21 @@
|
||||||
import { store } from "builderStore"
|
import { store } from "builderStore"
|
||||||
import api from "builderStore/api"
|
import api from "builderStore/api"
|
||||||
import posthog from "posthog-js"
|
import posthog from "posthog-js"
|
||||||
|
import analytics from "analytics"
|
||||||
|
|
||||||
let keys = { budibase: "", sendGrid: "" }
|
let keys = { budibase: "", sendGrid: "" }
|
||||||
|
|
||||||
async function updateKey([key, value]) {
|
async function updateKey([key, value]) {
|
||||||
|
if (key === "budibase") {
|
||||||
|
const isValid = await analytics.identifyByApiKey(value)
|
||||||
|
if (!isValid) {
|
||||||
|
// TODO: add validation message
|
||||||
|
keys = { ...keys }
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
const response = await api.put(`/api/keys/${key}`, { value })
|
const response = await api.put(`/api/keys/${key}`, { value })
|
||||||
const res = await response.json()
|
const res = await response.json()
|
||||||
if (key === "budibase") posthog.identify(value)
|
|
||||||
keys = { ...keys, ...res }
|
keys = { ...keys, ...res }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +25,8 @@
|
||||||
async function fetchKeys() {
|
async function fetchKeys() {
|
||||||
const response = await api.get(`/api/keys/`)
|
const response = await api.get(`/api/keys/`)
|
||||||
const res = await response.json()
|
const res = await response.json()
|
||||||
|
// dont want this to ever be editable, as its fetched based on Api Key
|
||||||
|
if (res.userId) delete res.userId
|
||||||
keys = res
|
keys = res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,7 @@
|
||||||
name="Password"
|
name="Password"
|
||||||
placeholder="Password" />
|
placeholder="Password" />
|
||||||
<Select bind:value={accessLevelId} thin>
|
<Select bind:value={accessLevelId} thin>
|
||||||
|
<option value="">Choose an option</option>
|
||||||
<option value="ADMIN">Admin</option>
|
<option value="ADMIN">Admin</option>
|
||||||
<option value="POWER_USER">Power User</option>
|
<option value="POWER_USER">Power User</option>
|
||||||
</Select>
|
</Select>
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
import { getContext } from "svelte"
|
import { getContext } from "svelte"
|
||||||
import { fade } from "svelte/transition"
|
import { fade } from "svelte/transition"
|
||||||
import { post } from "builderStore/api"
|
import { post } from "builderStore/api"
|
||||||
import analytics from "../../analytics"
|
import analytics from "analytics"
|
||||||
|
|
||||||
const { open, close } = getContext("simple-modal")
|
const { open, close } = getContext("simple-modal")
|
||||||
//Move this to context="module" once svelte-forms is updated so that it can bind to stores correctly
|
//Move this to context="module" once svelte-forms is updated so that it can bind to stores correctly
|
||||||
|
@ -23,12 +23,34 @@
|
||||||
export let hasKey
|
export let hasKey
|
||||||
export let template
|
export let template
|
||||||
|
|
||||||
|
let isApiKeyValid
|
||||||
|
let lastApiKey
|
||||||
|
let fetchApiKeyPromise
|
||||||
|
const validateApiKey = async apiKey => {
|
||||||
|
if (!apiKey) return false
|
||||||
|
|
||||||
|
// make sure we only fetch once, unless API Key is changed
|
||||||
|
if (isApiKeyValid === undefined || apiKey !== lastApiKey) {
|
||||||
|
lastApiKey = apiKey
|
||||||
|
// svelte reactivity was causing a requst to get fired mutiple times
|
||||||
|
// so, we make everything await the same promise, if one exists
|
||||||
|
if (!fetchApiKeyPromise) {
|
||||||
|
fetchApiKeyPromise = analytics.identifyByApiKey(apiKey)
|
||||||
|
}
|
||||||
|
isApiKeyValid = await fetchApiKeyPromise
|
||||||
|
fetchApiKeyPromise = undefined
|
||||||
|
}
|
||||||
|
return isApiKeyValid
|
||||||
|
}
|
||||||
|
|
||||||
let submitting = false
|
let submitting = false
|
||||||
let errors = {}
|
let errors = {}
|
||||||
let validationErrors = {}
|
let validationErrors = {}
|
||||||
let validationSchemas = [
|
let validationSchemas = [
|
||||||
{
|
{
|
||||||
apiKey: string().required("Please enter your API key."),
|
apiKey: string()
|
||||||
|
.required("Please enter your API key.")
|
||||||
|
.test("valid-apikey", "This API key is invalid", validateApiKey),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
applicationName: string().required("Your application must have a name."),
|
applicationName: string().required("Your application must have a name."),
|
||||||
|
@ -124,7 +146,7 @@
|
||||||
template,
|
template,
|
||||||
})
|
})
|
||||||
const appJson = await appResp.json()
|
const appJson = await appResp.json()
|
||||||
analytics.captureEvent("web_app_created", {
|
analytics.captureEvent("App Created", {
|
||||||
name,
|
name,
|
||||||
appId: appJson._id,
|
appId: appJson._id,
|
||||||
template,
|
template,
|
||||||
|
@ -163,6 +185,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractErrors({ inner }) {
|
function extractErrors({ inner }) {
|
||||||
|
if (!inner) return {}
|
||||||
return inner.reduce((acc, err) => {
|
return inner.reduce((acc, err) => {
|
||||||
return { ...acc, [err.path]: err.message }
|
return { ...acc, [err.path]: err.message }
|
||||||
}, {})
|
}, {})
|
||||||
|
|
|
@ -1,139 +0,0 @@
|
||||||
<script>
|
|
||||||
import { Button, Select } from "@budibase/bbui"
|
|
||||||
import StateBindingCascader from "./StateBindingCascader.svelte"
|
|
||||||
import { find, map, keys, reduce, keyBy } from "lodash/fp"
|
|
||||||
import { pipe } from "components/common/core"
|
|
||||||
import {
|
|
||||||
EVENT_TYPE_MEMBER_NAME,
|
|
||||||
allHandlers,
|
|
||||||
} from "components/common/eventHandlers"
|
|
||||||
import { store } from "builderStore"
|
|
||||||
|
|
||||||
export let handler
|
|
||||||
export let onCreate
|
|
||||||
export let onChanged
|
|
||||||
export let onRemoved
|
|
||||||
|
|
||||||
export let index
|
|
||||||
export let newHandler
|
|
||||||
|
|
||||||
let eventOptions
|
|
||||||
let handlerType
|
|
||||||
let parameters = []
|
|
||||||
|
|
||||||
$: eventOptions = allHandlers()
|
|
||||||
|
|
||||||
$: {
|
|
||||||
if (handler) {
|
|
||||||
handlerType = handler[EVENT_TYPE_MEMBER_NAME]
|
|
||||||
parameters = Object.entries(handler.parameters).map(([name, value]) => ({
|
|
||||||
name,
|
|
||||||
value,
|
|
||||||
}))
|
|
||||||
} else {
|
|
||||||
// Empty Handler
|
|
||||||
handlerType = ""
|
|
||||||
parameters = []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handlerChanged = (type, params) => {
|
|
||||||
const handlerParams = {}
|
|
||||||
for (let param of params) {
|
|
||||||
handlerParams[param.name] = param.value
|
|
||||||
}
|
|
||||||
|
|
||||||
const updatedHandler = {
|
|
||||||
[EVENT_TYPE_MEMBER_NAME]: type,
|
|
||||||
parameters: handlerParams,
|
|
||||||
}
|
|
||||||
|
|
||||||
onChanged(updatedHandler, index)
|
|
||||||
}
|
|
||||||
|
|
||||||
const handlerTypeChanged = e => {
|
|
||||||
const handlerType = eventOptions.find(
|
|
||||||
handler => handler.name === e.target.value
|
|
||||||
)
|
|
||||||
const defaultParams = handlerType.parameters.map(param => ({
|
|
||||||
name: param,
|
|
||||||
value: "",
|
|
||||||
}))
|
|
||||||
|
|
||||||
handlerChanged(handlerType.name, defaultParams)
|
|
||||||
}
|
|
||||||
|
|
||||||
const onParameterChanged = index => e => {
|
|
||||||
const value = e.target ? e.target.value : e
|
|
||||||
const newParams = [...parameters]
|
|
||||||
newParams[index].value = value
|
|
||||||
handlerChanged(handlerType, newParams)
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="type-selector-container {newHandler && 'new-handler'}">
|
|
||||||
<div class="handler-controls">
|
|
||||||
<div class="handler-option">
|
|
||||||
<span>Action</span>
|
|
||||||
<Select value={handlerType} on:change={handlerTypeChanged}>
|
|
||||||
<option />
|
|
||||||
{#each eventOptions as option}
|
|
||||||
<option value={option.name}>{option.name}</option>
|
|
||||||
{/each}
|
|
||||||
</Select>
|
|
||||||
</div>
|
|
||||||
{#if parameters}
|
|
||||||
<br />
|
|
||||||
{#each parameters as parameter, idx}
|
|
||||||
<StateBindingCascader on:change={onParameterChanged(idx)} {parameter} />
|
|
||||||
{/each}
|
|
||||||
{/if}
|
|
||||||
{#if parameters.length > 0}
|
|
||||||
<div class="button-container">
|
|
||||||
{#if newHandler}
|
|
||||||
<Button primary thin on:click={onCreate}>Add Action</Button>
|
|
||||||
{:else}
|
|
||||||
<Button outline thin on:click={onRemoved}>Remove Action</Button>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.type-selector-container {
|
|
||||||
display: grid;
|
|
||||||
grid-gap: 20px;
|
|
||||||
width: 100%;
|
|
||||||
background: rgba(223, 223, 223, 0.5);
|
|
||||||
border: 1px solid #dfdfdf;
|
|
||||||
margin-bottom: 18px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.handler-option {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.new-handler {
|
|
||||||
background: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.handler-controls {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
grid-gap: 20px;
|
|
||||||
padding: 22px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.button-container {
|
|
||||||
display: grid;
|
|
||||||
justify-items: end;
|
|
||||||
}
|
|
||||||
|
|
||||||
span {
|
|
||||||
font-size: 18px;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -4,7 +4,7 @@
|
||||||
import { notifier } from "builderStore/store/notifications"
|
import { notifier } from "builderStore/store/notifications"
|
||||||
import api from "builderStore/api"
|
import api from "builderStore/api"
|
||||||
import Spinner from "components/common/Spinner.svelte"
|
import Spinner from "components/common/Spinner.svelte"
|
||||||
import analytics from "../../../analytics"
|
import analytics from "analytics"
|
||||||
|
|
||||||
let deployed = false
|
let deployed = false
|
||||||
let loading = false
|
let loading = false
|
||||||
|
@ -26,10 +26,13 @@
|
||||||
notifier.success(`Your Deployment is Complete.`)
|
notifier.success(`Your Deployment is Complete.`)
|
||||||
deployed = true
|
deployed = true
|
||||||
loading = false
|
loading = false
|
||||||
analytics.captureEvent("web_app_deployment", {
|
analytics.captureEvent("Deployed App", {
|
||||||
appId,
|
appId,
|
||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
analytics.captureEvent("Deploy App Failed", {
|
||||||
|
appId,
|
||||||
|
})
|
||||||
analytics.captureException(err)
|
analytics.captureException(err)
|
||||||
notifier.danger("Deployment unsuccessful. Please try again later.")
|
notifier.danger("Deployment unsuccessful. Please try again later.")
|
||||||
loading = false
|
loading = false
|
||||||
|
|
|
@ -9,20 +9,24 @@
|
||||||
import CreateAppModal from "components/start/CreateAppModal.svelte"
|
import CreateAppModal from "components/start/CreateAppModal.svelte"
|
||||||
import TemplateList from "components/start/TemplateList.svelte"
|
import TemplateList from "components/start/TemplateList.svelte"
|
||||||
import { Button } from "@budibase/bbui"
|
import { Button } from "@budibase/bbui"
|
||||||
|
import analytics from "analytics"
|
||||||
|
|
||||||
let hasKey
|
let hasKey
|
||||||
|
|
||||||
async function fetchKeys() {
|
async function fetchKeys() {
|
||||||
const response = await api.get(`/api/keys/`)
|
const response = await api.get(`/api/keys/`)
|
||||||
const res = await response.json()
|
return await response.json()
|
||||||
return res.budibase
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkIfKeysAndApps() {
|
async function checkIfKeysAndApps() {
|
||||||
const key = await fetchKeys()
|
const keys = await fetchKeys()
|
||||||
if (key) {
|
const apps = await getApps()
|
||||||
|
if (keys.userId) {
|
||||||
hasKey = true
|
hasKey = true
|
||||||
} else {
|
analytics.identify(keys.userId)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!keys.budibase) {
|
||||||
showCreateAppModal()
|
showCreateAppModal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4847,9 +4847,10 @@ posix-character-classes@^0.1.0:
|
||||||
version "0.1.1"
|
version "0.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"
|
resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"
|
||||||
|
|
||||||
posthog-js@1.3.1:
|
posthog-js@1.4.5:
|
||||||
version "1.3.1"
|
version "1.4.5"
|
||||||
resolved "https://registry.yarnpkg.com/posthog-js/-/posthog-js-1.3.1.tgz#970acec1423eaa5dba0d2603410c9c70294e16da"
|
resolved "https://registry.yarnpkg.com/posthog-js/-/posthog-js-1.4.5.tgz#b16235afe47938bd71eaed4ede3790c8b910ed71"
|
||||||
|
integrity sha512-Rzc5/DpuX55BqwNEbZB0tLav1gEinnr5H+82cbLiMtXLADlxmCwZiEaVXcC3XOqW0x8bcAEehicx1TbpfBamzA==
|
||||||
|
|
||||||
prelude-ls@~1.1.2:
|
prelude-ls@~1.1.2:
|
||||||
version "1.1.2"
|
version "1.1.2"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "budibase",
|
"name": "budibase",
|
||||||
"version": "0.1.21",
|
"version": "0.1.23",
|
||||||
"description": "Budibase CLI",
|
"description": "Budibase CLI",
|
||||||
"repository": "https://github.com/Budibase/Budibase",
|
"repository": "https://github.com/Budibase/Budibase",
|
||||||
"homepage": "https://www.budibase.com",
|
"homepage": "https://www.budibase.com",
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
"author": "Budibase",
|
"author": "Budibase",
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/server": "^0.1.21",
|
"@budibase/server": "^0.1.23",
|
||||||
"@inquirer/password": "^0.0.6-alpha.0",
|
"@inquirer/password": "^0.0.6-alpha.0",
|
||||||
"chalk": "^2.4.2",
|
"chalk": "^2.4.2",
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/client",
|
"name": "@budibase/client",
|
||||||
"version": "0.1.21",
|
"version": "0.1.23",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"main": "dist/budibase-client.js",
|
"main": "dist/budibase-client.js",
|
||||||
"module": "dist/budibase-client.esm.mjs",
|
"module": "dist/budibase-client.esm.mjs",
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import api from "../api"
|
||||||
import renderTemplateString from "./renderTemplateString"
|
import renderTemplateString from "./renderTemplateString"
|
||||||
|
|
||||||
export const EVENT_TYPE_MEMBER_NAME = "##eventHandlerType"
|
export const EVENT_TYPE_MEMBER_NAME = "##eventHandlerType"
|
||||||
|
@ -5,6 +6,9 @@ export const EVENT_TYPE_MEMBER_NAME = "##eventHandlerType"
|
||||||
export const eventHandlers = routeTo => {
|
export const eventHandlers = routeTo => {
|
||||||
const handlers = {
|
const handlers = {
|
||||||
"Navigate To": param => routeTo(param && param.url),
|
"Navigate To": param => routeTo(param && param.url),
|
||||||
|
"Create Record": api.createRecord,
|
||||||
|
"Update Record": api.updateRecord,
|
||||||
|
"Trigger Workflow": api.triggerWorkflow,
|
||||||
}
|
}
|
||||||
|
|
||||||
// when an event is called, this is what gets run
|
// when an event is called, this is what gets run
|
||||||
|
|
|
@ -17,3 +17,4 @@ LOG_LEVEL=error
|
||||||
DEPLOYMENT_CREDENTIALS_URL="https://dt4mpwwap8.execute-api.eu-west-1.amazonaws.com/prod/"
|
DEPLOYMENT_CREDENTIALS_URL="https://dt4mpwwap8.execute-api.eu-west-1.amazonaws.com/prod/"
|
||||||
DEPLOYMENT_DB_URL="https://couchdb.budi.live:5984"
|
DEPLOYMENT_DB_URL="https://couchdb.budi.live:5984"
|
||||||
SENTRY_DSN=https://a34ae347621946bf8acded18e5b7d4b8@o420233.ingest.sentry.io/5338131
|
SENTRY_DSN=https://a34ae347621946bf8acded18e5b7d4b8@o420233.ingest.sentry.io/5338131
|
||||||
|
ENABLE_ANALYTICS="true"
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/server",
|
"name": "@budibase/server",
|
||||||
"version": "0.1.21",
|
"version": "0.1.23",
|
||||||
"description": "Budibase Web Server",
|
"description": "Budibase Web Server",
|
||||||
"main": "src/electron.js",
|
"main": "src/electron.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
"author": "Michael Shanks",
|
"author": "Michael Shanks",
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/client": "^0.1.21",
|
"@budibase/client": "^0.1.23",
|
||||||
"@koa/router": "^8.0.0",
|
"@koa/router": "^8.0.0",
|
||||||
"@sendgrid/mail": "^7.1.1",
|
"@sendgrid/mail": "^7.1.1",
|
||||||
"@sentry/node": "^5.19.2",
|
"@sentry/node": "^5.19.2",
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
exports.isEnabled = async function(ctx) {
|
||||||
|
ctx.body = JSON.stringify(process.env.ENABLE_ANALYTICS === "true")
|
||||||
|
}
|
|
@ -8,6 +8,7 @@ exports.fetch = async function(ctx) {
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
budibase: process.env.BUDIBASE_API_KEY,
|
budibase: process.env.BUDIBASE_API_KEY,
|
||||||
sendgrid: process.env.SENDGRID_API_KEY,
|
sendgrid: process.env.SENDGRID_API_KEY,
|
||||||
|
userId: process.env.USERID_API_KEY,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ const {
|
||||||
accesslevelRoutes,
|
accesslevelRoutes,
|
||||||
apiKeysRoutes,
|
apiKeysRoutes,
|
||||||
templatesRoutes,
|
templatesRoutes,
|
||||||
|
analyticsRoutes,
|
||||||
} = require("./routes")
|
} = require("./routes")
|
||||||
|
|
||||||
const router = new Router()
|
const router = new Router()
|
||||||
|
@ -113,6 +114,9 @@ router.use(accesslevelRoutes.allowedMethods())
|
||||||
router.use(apiKeysRoutes.routes())
|
router.use(apiKeysRoutes.routes())
|
||||||
router.use(apiKeysRoutes.allowedMethods())
|
router.use(apiKeysRoutes.allowedMethods())
|
||||||
|
|
||||||
|
router.use(analyticsRoutes.routes())
|
||||||
|
router.use(analyticsRoutes.allowedMethods())
|
||||||
|
|
||||||
router.use(staticRoutes.routes())
|
router.use(staticRoutes.routes())
|
||||||
router.use(staticRoutes.allowedMethods())
|
router.use(staticRoutes.allowedMethods())
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
const Router = require("@koa/router")
|
||||||
|
const authorized = require("../../middleware/authorized")
|
||||||
|
const { BUILDER } = require("../../utilities/accessLevels")
|
||||||
|
const controller = require("../controllers/analytics")
|
||||||
|
|
||||||
|
const router = Router()
|
||||||
|
|
||||||
|
router.get("/api/analytics", authorized(BUILDER), controller.isEnabled)
|
||||||
|
|
||||||
|
module.exports = router
|
|
@ -14,6 +14,7 @@ const accesslevelRoutes = require("./accesslevel")
|
||||||
const deployRoutes = require("./deploy")
|
const deployRoutes = require("./deploy")
|
||||||
const apiKeysRoutes = require("./apikeys")
|
const apiKeysRoutes = require("./apikeys")
|
||||||
const templatesRoutes = require("./templates")
|
const templatesRoutes = require("./templates")
|
||||||
|
const analyticsRoutes = require("./analytics")
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
deployRoutes,
|
deployRoutes,
|
||||||
|
@ -32,4 +33,5 @@ module.exports = {
|
||||||
accesslevelRoutes,
|
accesslevelRoutes,
|
||||||
apiKeysRoutes,
|
apiKeysRoutes,
|
||||||
templatesRoutes,
|
templatesRoutes,
|
||||||
|
analyticsRoutes,
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
"dev:builder": "rollup -cw"
|
"dev:builder": "rollup -cw"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@budibase/client": "^0.1.21",
|
"@budibase/client": "^0.1.23",
|
||||||
"@rollup/plugin-commonjs": "^11.1.0",
|
"@rollup/plugin-commonjs": "^11.1.0",
|
||||||
"lodash": "^4.17.15",
|
"lodash": "^4.17.15",
|
||||||
"rollup": "^1.11.0",
|
"rollup": "^1.11.0",
|
||||||
|
@ -31,14 +31,13 @@
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"svelte"
|
"svelte"
|
||||||
],
|
],
|
||||||
"version": "0.1.21",
|
"version": "0.1.23",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"gitHead": "284cceb9b703c38566c6e6363c022f79a08d5691",
|
"gitHead": "284cceb9b703c38566c6e6363c022f79a08d5691",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@beyonk/svelte-googlemaps": "^2.2.0",
|
"@beyonk/svelte-googlemaps": "^2.2.0",
|
||||||
"@budibase/bbui": "^1.34.6",
|
|
||||||
"@fortawesome/fontawesome-free": "^5.14.0",
|
|
||||||
"@budibase/bbui": "^1.34.2",
|
"@budibase/bbui": "^1.34.2",
|
||||||
|
"@fortawesome/fontawesome-free": "^5.14.0",
|
||||||
"britecharts": "^2.16.1",
|
"britecharts": "^2.16.1",
|
||||||
"d3-selection": "^1.4.2",
|
"d3-selection": "^1.4.2",
|
||||||
"fast-sort": "^2.2.0",
|
"fast-sort": "^2.2.0",
|
||||||
|
|
Loading…
Reference in New Issue