From 0d674955ea1597340de0b0cc75886c821703e83e Mon Sep 17 00:00:00 2001 From: Dipak Parmar Date: Mon, 6 May 2024 15:15:53 -0700 Subject: [PATCH] feat: add support for `data-exclude-search` (#53) Signed-off-by: Dipak Parmar --- README.MD | 7 ++++--- src/index.ts | 10 +++++++--- src/options.ts | 3 ++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README.MD b/README.MD index 6bd6bb4..f7a0e46 100644 --- a/README.MD +++ b/README.MD @@ -31,7 +31,7 @@ pnpm install @dipakparmar/docusaurus-plugin-umami ``` or with bun: - + ```bash bun install @dipakparmar/docusaurus-plugin-umami ``` @@ -71,12 +71,13 @@ Accepted fields: | ----------------- | --------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `websiteID` | `string` | **Required** | The unique website ID from your Umami Analytics. | | `analyticsDomain` | `string` | **Required** | Your domain of where Umami Analytics is hosted. | -| `scriptName` | `string` | `script.js` | Name of your custom tracker script. | +| `scriptName` | `string` | `script.js` | Name of your custom tracker script. | | `dataHostURL` | `string` | | By default, Umami will send data to wherever the script is located. You can override this to send data to another location. | | `dataAutoTrack` | `boolean` | | By default, Umami tracks all pageviews and events for you automatically. You can disable this behavior and track events yourself using the tracker functions. | -| `dataDoNotTrack` | `boolean` | | Configure Umami to respect the visitor's Do Not Track setting. | +| `dataDoNotTrack` | `boolean` | | Configure Umami to respect the visitor's Do Not Track setting. | | `dataCache` | `boolean` | | If you get a lot of pageviews from the same user, for example in a forum website, you can cache some data to improve the performance of the tracking script. | | `dataDomains` | `string` | | If you want the tracker to only run on specific domains, you can add them to your tracker script. This is a comma delimited list of domain names. Helps if you are working in a staging/development environment. | +| `dataExcludeSearch` | `boolean` | false | Configure the tracker to not record query parameters. |URL. | diff --git a/src/index.ts b/src/index.ts index 3f95de5..3c4dc05 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,10 +1,11 @@ -import { Joi } from "@docusaurus/utils-validation"; import type { LoadContext, - Plugin, OptionValidationContext, + Plugin, } from "@docusaurus/types"; -import type { PluginOptions, Options } from "./options"; +import type { Options, PluginOptions } from "./options"; + +import { Joi } from "@docusaurus/utils-validation"; export default function pluginUmami( context: LoadContext, @@ -19,6 +20,7 @@ export default function pluginUmami( dataDoNotTrack, dataCache, dataDomains, + dataExcludeSearch } = options; const isProd = process.env.NODE_ENV === "production"; @@ -55,6 +57,7 @@ export default function pluginUmami( ...(dataDoNotTrack && { "data-do-not-track": dataDoNotTrack }), ...(dataCache && { "data-cache": dataCache }), ...(dataDomains && { "data-domains": dataDomains }), + ...(dataExcludeSearch && { "data-exclude-search": dataExcludeSearch }) }, }, ], @@ -72,6 +75,7 @@ const pluginOptionsSchema = Joi.object({ dataDoNotTrack: Joi.boolean().default(false), dataCache: Joi.boolean().default(false), dataDomains: Joi.string(), + dataExcludeSearch: Joi.boolean().default(false) }); export function validateOptions({ diff --git a/src/options.ts b/src/options.ts index a1a4e13..7fd2158 100644 --- a/src/options.ts +++ b/src/options.ts @@ -7,6 +7,7 @@ export type PluginOptions = { dataDoNotTrack: boolean; dataCache: boolean; dataDomains: string; + dataExcludeSearch: boolean; }; -export type Options = Partial; \ No newline at end of file +export type Options = Partial;