File tree Expand file tree Collapse file tree 3 files changed +98
-55
lines changed
Expand file tree Collapse file tree 3 files changed +98
-55
lines changed Original file line number Diff line number Diff line change 44
55import environ
66import logfire
7+ import posthog
78import sentry_sdk
89from django .contrib .messages import constants as messages
10+ from posthog import Posthog
11+ from posthog .exception_capture import Integrations
912from sentry_sdk .integrations .django import DjangoIntegration
1013
1114BASE_DIR = Path (__file__ ).resolve ().parent .parent
4750 AWS_STORAGE_BUCKET_NAME = (str , "" ),
4851 AWS_ENDPOINT_URL = (str , "" ),
4952 S3_BUCKET = (str , "" ),
53+ POSTHOG_PROJECT_API_KEY = (str , "" ),
54+ POSTHOG_HOST = (str , "https://us.i.posthog.com" ),
5055)
5156
5257environ .Env .read_env (Path (BASE_DIR / ".env" ))
387392 "BACKEND" : "django.contrib.staticfiles.storage.StaticFilesStorage" ,
388393 },
389394 }
395+
396+ # PostHog
397+ POSTHOG_PROJECT_API_KEY = str (env ("POSTHOG_PROJECT_API_KEY" ))
398+ POSTHOG_HOST = str (env ("POSTHOG_HOST" ))
399+ if POSTHOG_PROJECT_API_KEY and POSTHOG_HOST :
400+ posthog .project_api_key = POSTHOG_PROJECT_API_KEY
401+ posthog .host = POSTHOG_HOST
402+ Posthog (
403+ api_key = POSTHOG_PROJECT_API_KEY ,
404+ host = POSTHOG_HOST ,
405+ enable_exception_autocapture = True ,
406+ exception_autocapture_integrations = [Integrations .Django ],
407+ )
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ dependencies = [
2424 " logfire[asgi,django]>=2.5.0" ,
2525 " djpress-publish-bluesky>=1.0.0" ,
2626 " django-storages[s3]>=1.14.6" ,
27+ " posthog>=4.4.0" ,
2728]
2829
2930[tool .curlylint .rules ]
You can’t perform that action at this time.
0 commit comments