mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-29 19:56:18 +00:00
Attempt to fix false user multiplication in analytics (#6980)
This commit is contained in:
parent
c0021bbe7c
commit
1192e23d18
@ -2,7 +2,7 @@ import { AnalyticProvider } from "@hcengineering/analytics"
|
|||||||
import posthog from 'posthog-js'
|
import posthog from 'posthog-js'
|
||||||
|
|
||||||
export class PosthogAnalyticProvider implements AnalyticProvider {
|
export class PosthogAnalyticProvider implements AnalyticProvider {
|
||||||
init (config: Record<string, any>): boolean {
|
init(config: Record<string, any>): boolean {
|
||||||
if (config.POSTHOG_API_KEY !== undefined && config.POSTHOG_API_KEY !== '' && config.POSTHOG_HOST !== null) {
|
if (config.POSTHOG_API_KEY !== undefined && config.POSTHOG_API_KEY !== '' && config.POSTHOG_HOST !== null) {
|
||||||
posthog.init(config.POSTHOG_API_KEY, { api_host: config.POSTHOG_HOST })
|
posthog.init(config.POSTHOG_API_KEY, { api_host: config.POSTHOG_HOST })
|
||||||
return true
|
return true
|
||||||
@ -11,15 +11,17 @@ export class PosthogAnalyticProvider implements AnalyticProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setUser(email: string): void {
|
setUser(email: string): void {
|
||||||
posthog.identify(email, { email: email })
|
if (!posthog._isIdentified()) {
|
||||||
|
posthog.identify(email, { email: email })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setTag(key: string, value: string): void {
|
setTag(key: string, value: string): void {
|
||||||
posthog.setPersonProperties({ [key]: value })
|
posthog.setPersonProperties({ [key]: value })
|
||||||
}
|
}
|
||||||
setWorkspace(ws: string): void {
|
setWorkspace(ws: string): void {
|
||||||
this.setTag('workspace', ws)
|
this.setTag('workspace', ws)
|
||||||
posthog.group('workspace', ws, {
|
posthog.group('workspace', ws, {
|
||||||
name: `${ws}`
|
name: `${ws}`
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
logout(): void {
|
logout(): void {
|
||||||
|
Loading…
Reference in New Issue
Block a user