@stacksjs/analytics 0.74.67 → 0.74.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AnalyticsHeadTag } from './shared';
|
|
2
|
+
/**
|
|
3
|
+
* Build the AnalyticsHQ head tags. Values are raw; escaping happens when the
|
|
4
|
+
* tags are rendered.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getAnalyticsHqHead(config: AnalyticsHqConfig): AnalyticsHeadTag[];
|
|
7
|
+
/**
|
|
8
|
+
* Generate the AnalyticsHQ tracking script tag.
|
|
9
|
+
*/
|
|
10
|
+
export declare function generateAnalyticsHqScript(config: AnalyticsHqConfig): string;
|
|
11
|
+
/** The hosted script, used when `scriptUrl` is not set. */
|
|
12
|
+
export declare const ANALYTICSHQ_DEFAULT_SCRIPT: 'https://analyticshq.org/script.js';
|
|
13
|
+
export declare interface AnalyticsHqConfig {
|
|
14
|
+
siteId: string
|
|
15
|
+
scriptUrl?: string
|
|
16
|
+
respectDnt?: boolean
|
|
17
|
+
vitals?: boolean
|
|
18
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{renderHeadTags}from"./shared";export const ANALYTICSHQ_DEFAULT_SCRIPT="https://analyticshq.org/script.js";export function getAnalyticsHqHead(config){if(!config.siteId)return[];const attributes={src:config.scriptUrl||ANALYTICSHQ_DEFAULT_SCRIPT,"data-site":config.siteId,defer:""};if(config.respectDnt===!1)attributes["data-respect-dnt"]="false";if(config.vitals===!1)attributes["data-vitals"]="false";return[["script",attributes]]}export function generateAnalyticsHqScript(config){const tags=getAnalyticsHqHead(config);if(!tags.length)return"";return`<!-- Stacks AnalyticsHQ -->
|
|
2
|
+
${renderHeadTags(tags)}`}
|
package/dist/drivers/index.d.ts
CHANGED
package/dist/drivers/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./fathom";export*from"./google-analytics";export*from"./plausible";export*from"./self-hosted";export*from"./shared";
|
|
1
|
+
export*from"./analyticshq";export*from"./fathom";export*from"./google-analytics";export*from"./plausible";export*from"./self-hosted";export*from"./shared";
|
package/dist/registry.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getFathomAnalyticsHead}from"./drivers/fathom";import{getGoogleAnalyticsHead}from"./drivers/google-analytics";import{getPlausibleAnalyticsHead}from"./drivers/plausible";import{getSelfHostedAnalyticsHead}from"./drivers/self-hosted";import{renderHeadTags}from"./drivers/shared";export const ANALYTICS_DRIVERS=["google-analytics","fathom","plausible","self-hosted"];export function isAnalyticsDriver(value){return typeof value==="string"&&ANALYTICS_DRIVERS.includes(value)}function misconfigured(driver,key,field){return Error(`Analytics driver "${driver}" is selected but not configured: set \`drivers.${key}.${field}\` in config/analytics.ts, or change \`driver\`.`)}export function getAnalyticsHead(config){const driver=config.driver;if(!driver)return[];if(!isAnalyticsDriver(driver))throw Error(`Unknown analytics driver "${String(driver)}". Available drivers: ${ANALYTICS_DRIVERS.join(", ")}.`);switch(driver){case"google-analytics":{const options=config.drivers?.googleAnalytics;if(!options?.trackingId)throw misconfigured(driver,"googleAnalytics","trackingId");return getGoogleAnalyticsHead(options)}case"fathom":{const options=config.drivers?.fathom;if(!options?.siteId)throw misconfigured(driver,"fathom","siteId");return getFathomAnalyticsHead(options)}case"plausible":{const options=config.drivers?.plausible;if(!options?.domain)throw misconfigured(driver,"plausible","domain");return getPlausibleAnalyticsHead(options)}case"self-hosted":{const options=config.drivers?.selfHosted;if(!options?.siteId)throw misconfigured(driver,"selfHosted","siteId");if(!options.apiEndpoint)throw misconfigured(driver,"selfHosted","apiEndpoint");return getSelfHostedAnalyticsHead(options)}default:throw Error(`Analytics driver "${String(driver)}" has no implementation.`)}}export function generateAnalyticsScript(config){const tags=getAnalyticsHead(config);if(!tags.length)return"";return renderHeadTags(tags)}
|
|
1
|
+
import{getAnalyticsHqHead}from"./drivers/analyticshq";import{getFathomAnalyticsHead}from"./drivers/fathom";import{getGoogleAnalyticsHead}from"./drivers/google-analytics";import{getPlausibleAnalyticsHead}from"./drivers/plausible";import{getSelfHostedAnalyticsHead}from"./drivers/self-hosted";import{renderHeadTags}from"./drivers/shared";export const ANALYTICS_DRIVERS=["google-analytics","fathom","plausible","self-hosted","analyticshq"];export function isAnalyticsDriver(value){return typeof value==="string"&&ANALYTICS_DRIVERS.includes(value)}function misconfigured(driver,key,field){return Error(`Analytics driver "${driver}" is selected but not configured: set \`drivers.${key}.${field}\` in config/analytics.ts, or change \`driver\`.`)}export function getAnalyticsHead(config){const driver=config.driver;if(!driver)return[];if(!isAnalyticsDriver(driver))throw Error(`Unknown analytics driver "${String(driver)}". Available drivers: ${ANALYTICS_DRIVERS.join(", ")}.`);switch(driver){case"google-analytics":{const options=config.drivers?.googleAnalytics;if(!options?.trackingId)throw misconfigured(driver,"googleAnalytics","trackingId");return getGoogleAnalyticsHead(options)}case"fathom":{const options=config.drivers?.fathom;if(!options?.siteId)throw misconfigured(driver,"fathom","siteId");return getFathomAnalyticsHead(options)}case"plausible":{const options=config.drivers?.plausible;if(!options?.domain)throw misconfigured(driver,"plausible","domain");return getPlausibleAnalyticsHead(options)}case"self-hosted":{const options=config.drivers?.selfHosted;if(!options?.siteId)throw misconfigured(driver,"selfHosted","siteId");if(!options.apiEndpoint)throw misconfigured(driver,"selfHosted","apiEndpoint");return getSelfHostedAnalyticsHead(options)}case"analyticshq":{const options=config.drivers?.analyticshq;if(!options?.siteId)throw misconfigured(driver,"analyticshq","siteId");return getAnalyticsHqHead(options)}default:throw Error(`Analytics driver "${String(driver)}" has no implementation.`)}}export function generateAnalyticsScript(config){const tags=getAnalyticsHead(config);if(!tags.length)return"";return renderHeadTags(tags)}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/analytics",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.74.
|
|
5
|
+
"version": "0.74.69",
|
|
6
6
|
"description": "Stacks Analytics. Privacy-friendly.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"prepublishOnly": "bun run build"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@stacksjs/database": "0.74.
|
|
55
|
-
"@stacksjs/types": "0.74.
|
|
54
|
+
"@stacksjs/database": "0.74.69",
|
|
55
|
+
"@stacksjs/types": "0.74.69"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"better-dx": "^0.2.24"
|