identify user in builder

This commit is contained in:
Martin McKeaveney 2020-07-13 18:09:32 +01:00
parent ab13ecad1f
commit 970317ef08
3 changed files with 5 additions and 3 deletions

View File

@ -180,8 +180,8 @@ export default {
"process.env.NODE_ENV": JSON.stringify( "process.env.NODE_ENV": JSON.stringify(
production ? "production" : "development" production ? "production" : "development"
), ),
"process.env.POSTHOG_TOKEN": process.env.POSTHOG_TOKEN, "process.env.POSTHOG_TOKEN": JSON.stringify(process.env.POSTHOG_TOKEN),
"process.env.POSTHOG_URL": process.env.POSTHOG_URL, "process.env.POSTHOG_URL": JSON.stringify(process.env.POSTHOG_URL)
}), }),
svelte({ svelte({

View File

@ -11,7 +11,7 @@ export const initialise = async () => {
try { try {
if (process.env.NODE_ENV === "production") { if (process.env.NODE_ENV === "production") {
posthog.init(process.env.POSTHOG_TOKEN, { posthog.init(process.env.POSTHOG_TOKEN, {
api_host: process.env.POSTHOG_URL, api_host: process.env.POSTHOG_URL
}) })
} }
} catch (err) { } catch (err) {

View File

@ -2,12 +2,14 @@
import { Input, Button } from "@budibase/bbui" import { Input, Button } from "@budibase/bbui"
import { store } from "builderStore" import { store } from "builderStore"
import api from "builderStore/api" import api from "builderStore/api"
import posthog from "posthog-js"
let keys = { budibase: "", sendGrid: "" } let keys = { budibase: "", sendGrid: "" }
async function updateKey([key, value]) { async function updateKey([key, value]) {
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 }
} }