Skip to content

Commit

Permalink
feat: add support for data-exclude-search (#53)
Browse files Browse the repository at this point in the history
Signed-off-by: Dipak Parmar <hi@dipak.tech>
  • Loading branch information
dipakparmar authored May 6, 2024
1 parent db4286a commit 0d67495
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
7 changes: 4 additions & 3 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pnpm install @dipakparmar/docusaurus-plugin-umami
```

or with bun:

```bash
bun install @dipakparmar/docusaurus-plugin-umami
```
Expand Down Expand Up @@ -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. |

</small>

Expand Down
10 changes: 7 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -19,6 +20,7 @@ export default function pluginUmami(
dataDoNotTrack,
dataCache,
dataDomains,
dataExcludeSearch
} = options;
const isProd = process.env.NODE_ENV === "production";

Expand Down Expand Up @@ -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 })
},
},
],
Expand All @@ -72,6 +75,7 @@ const pluginOptionsSchema = Joi.object<PluginOptions>({
dataDoNotTrack: Joi.boolean().default(false),
dataCache: Joi.boolean().default(false),
dataDomains: Joi.string(),
dataExcludeSearch: Joi.boolean().default(false)
});

export function validateOptions({
Expand Down
3 changes: 2 additions & 1 deletion src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type PluginOptions = {
dataDoNotTrack: boolean;
dataCache: boolean;
dataDomains: string;
dataExcludeSearch: boolean;
};

export type Options = Partial<PluginOptions>;
export type Options = Partial<PluginOptions>;

0 comments on commit 0d67495

Please sign in to comment.