{"version":3,"sources":["../../src/third-parties/posthog.ts"],"sourcesContent":["import { posthog } from 'posthog-js';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\nconst metrics = ['CLS', 'FCP', 'FID', 'INP', 'LCP', 'TTFB'];\n\nexport function sendPosthogEvent<T extends EventName>(\n  name: TrackName<T>,\n  properties?: TrackProperties<T>\n) {\n  if (metrics.includes(name)) return;\n  if (window.location.host.includes('127.0.0.1')) return;\n  if (window.location.host.includes('localhost')) return;\n\n  posthog.capture(name, properties);\n  if (name === 'logout') {\n    posthog.reset();\n  }\n}\n\nexport function setPosthogUser({ user_id, distinct_id, data }: UpdateVisitorDTO) {\n  if (!distinct_id && !user_id) return;\n  posthog.identify(distinct_id ?? user_id, { email: getFirst(data?.email) });\n}\n"],"mappings":";AAAA,SAAS,eAAe;AAExB,SAAS,gBAAgB;AAGzB,IAAM,UAAU,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,MAAM;AAEnD,SAAS,iBACd,MACA,YACA;AACA,MAAI,QAAQ,SAAS,IAAI,EAAG;AAC5B,MAAI,OAAO,SAAS,KAAK,SAAS,WAAW,EAAG;AAChD,MAAI,OAAO,SAAS,KAAK,SAAS,WAAW,EAAG;AAEhD,UAAQ,QAAQ,MAAM,UAAU;AAChC,MAAI,SAAS,UAAU;AACrB,YAAQ,MAAM;AAAA,EAChB;AACF;AAEO,SAAS,eAAe,EAAE,SAAS,aAAa,KAAK,GAAqB;AAC/E,MAAI,CAAC,eAAe,CAAC,QAAS;AAC9B,UAAQ,SAAS,eAAe,SAAS,EAAE,OAAO,SAAS,6BAAM,KAAK,EAAE,CAAC;AAC3E;","names":[]}