@stacksjs/stx
Version:
A performant UI Framework. Powered by Bun.
40 lines • 1.11 kB
TypeScript
import type { CustomDirective, StxOptions } from './types';
/**
* Analytics Module
*
* Provides automatic analytics script injection for various providers:
* - Fathom Analytics (privacy-focused)
* - Google Analytics (GA4)
* - Plausible Analytics (privacy-focused, open source)
* - Self-hosted analytics (using dynamodb-tooling)
* - Custom analytics scripts
*
* ## Configuration
*
* Analytics can be configured in `stx.config.ts`:
* ```typescript
* export default {
* analytics: {
* enabled: true,
* driver: 'fathom',
* fathom: {
* siteId: 'ABCDEFGH',
* honorDnt: true,
* }
* }
* }
* ```
*/
/**
* Generate analytics tracking script based on configuration
*/
export declare function generateAnalyticsScript(options: StxOptions): string;
/**
* Inject analytics script into HTML
* Scripts are injected just before </head> for optimal loading
*/
export declare function injectAnalytics(html: string, options: StxOptions): string;
/**
* Custom @analytics directive for explicit placement
*/
export declare const analyticsDirective: CustomDirective;