commit
69a1361d11
|
@ -3,6 +3,8 @@ import posthog from "posthog-js"
|
||||||
import api from "builderStore/api"
|
import api from "builderStore/api"
|
||||||
|
|
||||||
let analyticsEnabled
|
let analyticsEnabled
|
||||||
|
const posthogConfigured = process.env.POSTHOG_TOKEN && process.env.POSTHOG_URL
|
||||||
|
const sentryConfigured = process.env.SENTRY_DSN
|
||||||
|
|
||||||
async function activate() {
|
async function activate() {
|
||||||
if (analyticsEnabled === undefined) {
|
if (analyticsEnabled === undefined) {
|
||||||
|
@ -13,18 +15,19 @@ async function activate() {
|
||||||
analyticsEnabled = (await response.json()) === true
|
analyticsEnabled = (await response.json()) === true
|
||||||
}
|
}
|
||||||
if (!analyticsEnabled) return
|
if (!analyticsEnabled) return
|
||||||
Sentry.init({ dsn: process.env.SENTRY_DSN })
|
if (sentryConfigured) Sentry.init({ dsn: process.env.SENTRY_DSN })
|
||||||
if (!process.env.POSTHOG_TOKEN) return
|
if (posthogConfigured) {
|
||||||
posthog.init(process.env.POSTHOG_TOKEN, {
|
posthog.init(process.env.POSTHOG_TOKEN, {
|
||||||
api_host: process.env.POSTHOG_URL,
|
api_host: process.env.POSTHOG_URL,
|
||||||
})
|
})
|
||||||
posthog.set_config({ persistence: "cookie" })
|
posthog.set_config({ persistence: "cookie" })
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function identify(id) {
|
function identify(id) {
|
||||||
if (!analyticsEnabled) return
|
if (!analyticsEnabled || !id) return
|
||||||
if (!id) return
|
if (posthogConfigured) posthog.identify(id)
|
||||||
posthog.identify(id)
|
if (sentryConfigured)
|
||||||
Sentry.configureScope(scope => {
|
Sentry.configureScope(scope => {
|
||||||
scope.setUser({ id: id })
|
scope.setUser({ id: id })
|
||||||
})
|
})
|
||||||
|
|
|
@ -37,7 +37,9 @@
|
||||||
if (keys.userId) {
|
if (keys.userId) {
|
||||||
hasKey = true
|
hasKey = true
|
||||||
analytics.identify(keys.userId)
|
analytics.identify(keys.userId)
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if (!keys.budibase) {
|
||||||
showCreateAppModal()
|
showCreateAppModal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue