Configuration reference
DatabuddyProvider, init(), the Vue <Databuddy> component and the Nuxt module take the same options. The script tag takes them as data-* attributes.
The Node client and server flags have their own options, on Node SDK and Server flags.
Browser options
skipPaths and maskPaths ignore case, decode escaped characters and collapse repeated slashes, so /Creations/abc with ["/creations/*"] is sent as /creations/*. Every URL sent drops its query and fragment; campaign parameters and ad click IDs are sent as event properties instead. To apply the same rules on your server, import maskPathname and matchesSkipPattern from @databuddy/sdk/node.
Configure the script tag
The script tag uses the older flat names. To load the tracker from npm instead, call init() with the options above.
Functions can't go in attributes. Set consent, beforeSend, filter or a cleanUrl function on window.databuddyConfig before the script loads. consentCookie can go there too, in place of data-consent-cookie.
Load the pinned scripts from your own domain
If your Content Security Policy only allows scripts from your own origin, rewrite a path to the CDN and point cdnUrl at it. The SDK keeps loading the same pinned files and integrity hashes from there as you upgrade.
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
async rewrites() {
return [{ source: "/x/:path*", destination: "https://cdn.databuddy.cc/:path*" }];
},
};
export default nextConfig;<DatabuddyProvider cdnUrl="/x" />The rewrite must pass files through unchanged, or the integrity check blocks them. Events still go to apiUrl, so allow https://basket.databuddy.cc in connect-src, or proxy it too.
Filter or edit events before they're sent
beforeSend gets each event after paths are masked and URLs cleaned. event.type names its shape, and checking it narrows the type. Edit the event in place to send less, or return false to drop it. A hook that throws drops the event.
import { init } from "@databuddy/sdk";
init({
clientId: "your-client-id",
beforeSend: (event) => {
if (event.type === "error") delete event.stack;
if (event.type === "outgoing_link") event.text = "";
return true;
},
});Every event also has eventId, timestamp, anonymousId and sessionId. beforeSend, filter and maskPaths don't apply to session replays, which mask page text and typed input but keep the page's structure and class names. Leave replay off if your privacy policy forbids that.
Related
How is this guide?