@yeskunall/astro-umami
Version:
Add Umami Analytics to your Astro website
74 lines (71 loc) • 2.46 kB
TypeScript
import { AstroIntegration } from 'astro';
type OptionalExceptFor<T, K extends keyof T> = {
[P in keyof T]: P extends K ? T[P] : T[P] | undefined;
} & Pick<T, K>;
interface UmamiOptions {
/**
* Umami tracks all events and pageviews for you automatically. Override this behavior if you plan on using [tracker functions](https://umami.is/docs/tracker-functions).
*
@default true
*/
autotrack?: boolean;
/**
* Specify a [function](https://umami.is/docs/tracker-configuration#data-before-send) that will be called before data is sent.
*/
beforeSendHandler?: string;
/**
* If you want the tracker to only run on specific domains, add them to this list.
*
* @example ["mywebsite.com", "mywebsite2.com"]
*/
domains?: string[];
/**
* Respect a visitor’s [Do Not Track](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/doNotTrack) browser setting.
*/
doNotTrack?: boolean;
/**
*
* The endpoint where your Umami instance is located.
*
* @default https://cloud.umami.is
* @example https://umami-on.fly.dev
*/
endpointUrl?: string;
/**
* Set this if you don’t want to collect the hash value from the URL.
*/
excludeHash?: boolean;
/**
* Set this if you don’t want to collect search parameters from the URL.
*/
excludeSearch?: boolean;
/**
* Override the location where your analytics data is sent.
*/
hostUrl?: string;
/**
* The unique ID of your [website](https://umami.is/docs/add-a-website).
*/
id: string;
/**
* Collect events under a specific tag. These events can be filtered in the dashboard by the specific tag.
*/
tag?: string;
/**
* Assign a custom name to the tracker script.
*
* @default script.js
* @see [https://umami.is/docs/environment-variables](https://umami.is/docs/environment-variables)
*/
trackerScriptName?: string;
}
interface Options extends UmamiOptions {
/**
* Serve the tracking script using [Partytown](https://partytown.qwik.dev/).
*
* @see [https://docs.astro.build/en/guides/integrations-guide/partytown/](https://docs.astro.build/en/guides/integrations-guide/partytown/)
*/
withPartytown?: boolean;
}
declare function umamiIntegration(options: OptionalExceptFor<Options, "id">): AstroIntegration;
export { umamiIntegration as default };