Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/add-gizmo-analytics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'pliny': minor
---

Add Gizmo Analytics as a new provider in the `Analytics` component. Cookieless, GDPR-friendly tracker; no consent banner required. Configured via `gizmoAnalytics: { gizmoPublicKey: '...' }` in `AnalyticsConfig`.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Pliny provides out of the box components to enhance your static site:
- Umami Analytics
- Posthog
- Microsoft Clarity
- Gizmo Analytics
- Comments
- Disqus
- Giscus
Expand Down
28 changes: 28 additions & 0 deletions packages/pliny/src/analytics/Gizmo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Script from 'next/script'

/**
* Props for the Gizmo Analytics component.
*
* Gizmo is a cookieless web analytics service — no cookies, no
* localStorage, no fingerprinting, no consent banner required.
* https://gizmoanalytics.io
*/
export interface GizmoProps {
/** The public API key for your Gizmo site. Starts with `ak_public_`. */
gizmoPublicKey: string
/** Source URL for the Gizmo tracker script. Defaults to the hosted CDN. */
src?: string
}

/**
* A React component that integrates Gizmo Analytics via a script tag.
*
* @param props - The props for the Gizmo component.
* @returns A Script element with the Gizmo analytics tracker.
*/
export const Gizmo = ({
src = 'https://gizmoanalytics.io/script.js',
gizmoPublicKey,
}: GizmoProps) => {
return <Script async defer src={src} data-key={gizmoPublicKey} />
}
11 changes: 8 additions & 3 deletions packages/pliny/src/analytics/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { SimpleAnalytics, SimpleAnalyticsProps } from './SimpleAnalytics.js'
import { Umami, UmamiProps } from './Umami'
import { Posthog, PosthogProps } from './Posthog'
import { Clarity, ClarityProps } from './MicrosoftClarity'
import { Gizmo, GizmoProps } from './Gizmo'

declare global {
interface Window {
Expand All @@ -21,6 +22,7 @@ export interface AnalyticsConfig {
posthogAnalytics?: PosthogProps
simpleAnalytics?: SimpleAnalyticsProps
clarityAnalytics?: ClarityProps
gizmoAnalytics?: GizmoProps
}

/**
Expand All @@ -41,7 +43,7 @@ export interface AnalyticsProps {
const isProduction = process.env.NODE_ENV === 'production'

/**
* Supports Plausible, Simple Analytics, Umami, Posthog or Google Analytics.
* Supports Plausible, Simple Analytics, Umami, Posthog, Google Analytics, or Gizmo.
* All components default to the hosted service, but can be configured to use a self-hosted
* or proxied version of the script by providing the `src` / `apiHost` props.
*
Expand Down Expand Up @@ -71,10 +73,13 @@ export const Analytics = ({ analyticsConfig }: AnalyticsProps) => {
{isProduction && analyticsConfig.clarityAnalytics && (
<Clarity {...analyticsConfig.clarityAnalytics} />
)}
{isProduction && analyticsConfig.gizmoAnalytics && (
<Gizmo {...analyticsConfig.gizmoAnalytics} />
)}
</>
)
}

export { GA, Plausible, SimpleAnalytics, Umami, Posthog, Clarity }
export { GA, Plausible, SimpleAnalytics, Umami, Posthog, Clarity, Gizmo }

export type { GoogleAnalyticsProps, PlausibleProps, UmamiProps, PosthogProps, SimpleAnalyticsProps, ClarityProps }
export type { GoogleAnalyticsProps, PlausibleProps, UmamiProps, PosthogProps, SimpleAnalyticsProps, ClarityProps, GizmoProps }