upstream #1
							
								
								
									
										18
									
								
								components/analytics/Posthog.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								components/analytics/Posthog.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,18 @@ | ||||
| import Script from 'next/script' | ||||
|  | ||||
| import siteMetadata from '@/data/siteMetadata' | ||||
|  | ||||
| const PosthogScript = () => { | ||||
|   return ( | ||||
|     <> | ||||
|       <Script strategy="lazyOnload" id="posthog-script"> | ||||
|         {` | ||||
|             !function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]); | ||||
|             posthog.init('${siteMetadata.analytics.posthogAnalyticsId}',{api_host:'https://app.posthog.com'}) | ||||
|         `} | ||||
|       </Script> | ||||
|     </> | ||||
|   ) | ||||
| } | ||||
|  | ||||
| export default PosthogScript | ||||
| @@ -2,6 +2,7 @@ import GA from './GoogleAnalytics' | ||||
| import Plausible from './Plausible' | ||||
| import SimpleAnalytics from './SimpleAnalytics' | ||||
| import Umami from './Umami' | ||||
| import Posthog from './Posthog' | ||||
| import siteMetadata from '@/data/siteMetadata' | ||||
|  | ||||
| const isProduction = process.env.NODE_ENV === 'production' | ||||
| @@ -13,6 +14,7 @@ const Analytics = () => { | ||||
|       {isProduction && siteMetadata.analytics.simpleAnalytics && <SimpleAnalytics />} | ||||
|       {isProduction && siteMetadata.analytics.umamiWebsiteId && <Umami />} | ||||
|       {isProduction && siteMetadata.analytics.googleAnalyticsId && <GA />} | ||||
|       {isProduction && siteMetadata.analytics.posthogAnalyticsId && <Posthog />} | ||||
|     </> | ||||
|   ) | ||||
| } | ||||
|   | ||||
| @@ -25,6 +25,7 @@ const siteMetadata = { | ||||
|     simpleAnalytics: false, // true or false | ||||
|     umamiWebsiteId: '', // e.g. 123e4567-e89b-12d3-a456-426614174000 | ||||
|     googleAnalyticsId: '', // e.g. UA-000000-2 or G-XXXXXXX | ||||
|     posthogAnalyticsId: '', // posthog.init e.g. phc_5yXvArzvRdqtZIsHkEm3Fkkhm3d0bEYUXCaFISzqPSQ | ||||
|   }, | ||||
|   newsletter: { | ||||
|     // supports mailchimp, buttondown, convertkit, klaviyo, revue, emailoctopus | ||||
|   | ||||
		Reference in New Issue
	
	Block a user