Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for data-exclude-search #53

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>;
Loading