Skip to content
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
2 changes: 1 addition & 1 deletion packages/tracker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class Databuddy extends BaseTracker {
}
const scrollCleanup = initScrollDepthTracking(this);
this.cleanupFns.push(scrollCleanup);
if (this.options.trackInteractions) {
if (this.options.trackInteractions !== false) {
const interactionCleanup = initInteractionTracking(this);
this.cleanupFns.push(interactionCleanup);
}
Expand Down
44 changes: 44 additions & 0 deletions packages/tracker/tests/interactions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,50 @@ const SLOW_NAVIGATIONS = [
];

test.describe("interaction frustration signals", () => {
async function rageClickUnresponsiveButton(page: Page) {
await page.click("button", { clickCount: 3 });
return page.evaluate(
() => (window.__tracker as BaseTracker).rageClickCount
);
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

test("interaction tracking is on without any configuration", async ({
page,
}) => {
await page.goto("/test");
await page.evaluate(() => {
document.body.innerHTML = `<button type="button" aria-label="pay">Pay</button>`;
window.databuddyConfig = {
clientId: "test-interactions-default",
ignoreBotDetection: true,
};
});
await page.addScriptTag({ url: "/dist/databuddy-debug.js" });
await expect
.poll(() => page.evaluate(() => Boolean(window.__tracker)))
.toBeTruthy();
expect(await rageClickUnresponsiveButton(page)).toBe(1);
});

test('data-track-interactions="false" turns interaction tracking off', async ({
page,
}) => {
await page.goto("/test");
await page.evaluate(() => {
document.body.innerHTML = `<button type="button" aria-label="pay">Pay</button>`;
const script = document.createElement("script");
script.src = "/dist/databuddy-debug.js";
script.dataset.clientId = "test-interactions-opt-out";
script.dataset.ignoreBotDetection = "true";
script.dataset.trackInteractions = "false";
document.head.append(script);
});
await expect
.poll(() => page.evaluate(() => Boolean(window.__tracker)))
.toBeTruthy();
expect(await rageClickUnresponsiveButton(page)).toBe(0);
});

for (const { name, markup, act } of ORDINARY_CLICKS) {
test(`${name} is neither a rage nor a dead click`, async ({ page }) => {
await loadFixture(page, markup);
Expand Down
Loading