From ac48840f651517c428f770c0b71efcd06a76f5a6 Mon Sep 17 00:00:00 2001 From: Rafael Audibert <32079912+rafaeelaudibert@users.noreply.github.com> Date: Tue, 21 Oct 2025 17:52:32 -0300 Subject: [PATCH] feat: Better document CSP Tracking (#13328) --- contents/docs/advanced/content-security-policy.md | 7 +++++++ contents/docs/csp-tracking/index.mdx | 4 +++- src/hooks/useFeatureOwnership.tsx | 7 ++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/contents/docs/advanced/content-security-policy.md b/contents/docs/advanced/content-security-policy.md index a7009c46c..568a6242f 100644 --- a/contents/docs/advanced/content-security-policy.md +++ b/contents/docs/advanced/content-security-policy.md @@ -100,6 +100,13 @@ Our client SDKs (where appropriate) will take care of selecting the correct doma | `us.posthog.com` | US PostHog app domain (used by the Toolbar) | | `app.posthog.com` | Legacy ingestion endpoint | +## Keeping track of your CSP violations + +You can [send reports of CSP rule violations](/docs/csp-tracking) to PostHog, which is useful for +* warning when your website is under certain kinds of attack +* debugging problems when adding external scripts/media/etc to your site +* being confident that changes to your site haven't broken the loading of any resources + ## Troubleshooting / FAQ diff --git a/contents/docs/csp-tracking/index.mdx b/contents/docs/csp-tracking/index.mdx index fe60c844f..0c566e9c4 100644 --- a/contents/docs/csp-tracking/index.mdx +++ b/contents/docs/csp-tracking/index.mdx @@ -1,5 +1,5 @@ --- -title: CSP Tracking +title: CSP Tracking (Beta) sidebar: Docs showTitle: true --- @@ -12,6 +12,8 @@ You can send reports of CSP rule violations to PostHog, which is useful for * debugging problems when adding external scripts/media/etc to your site * being confident that changes to your site haven't broken the loading of any resources +> **Note:** CSP Tracking is currently in beta. Give feedback by [raising an issue](https://github.com/PostHog/posthog/issues/new?labels=feature%2Fcsp-tracking). + ## Where do I start? ### Create a new dashboard using the CSP template diff --git a/src/hooks/useFeatureOwnership.tsx b/src/hooks/useFeatureOwnership.tsx index b30180532..575db4a1b 100644 --- a/src/hooks/useFeatureOwnership.tsx +++ b/src/hooks/useFeatureOwnership.tsx @@ -96,6 +96,11 @@ const FEATURE_DATA: Record = { owner: ['platform-features'], label: 'feature/comments', }, + 'csp-tracking': { + feature: 'CSP tracking', + owner: ['web-analytics'], + label: 'feature/csp-tracking', + }, 'currency-rate-dataset': { feature: 'Currency rate dataset', owner: ['revenue-analytics'], @@ -425,7 +430,7 @@ const FEATURE_DATA: Record = { }, } -export const useFeatureOwnership = ({ teamSlug }: { teamSlug?: string } = {}) => { +export const useFeatureOwnership = ({ teamSlug }: { teamSlug?: string } = {}): { features: Feature[] } => { const features = Object.entries(FEATURE_DATA).reduce((acc, [key, feature]) => { const featureWithSlug: Feature = { ...feature,