Skip to content

v0.3.6 - #18

Merged
Ret2Hell merged 3 commits into
mainfrom
chore/refactor-validation
Apr 25, 2026
Merged

Ret2Hell merged 3 commits into
mainfrom
chore/refactor-validation

Conversation

@Ret2Hell

@Ret2Hell Ret2Hell commented Apr 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added explicit opt-in tracking for clickable elements and strengthened form opt-out handling.
  • Bug Fixes

    • Improved runtime compatibility by using global environment references.
    • Enhanced reliability of page view, scroll depth, and time-on-page tracking (sentinel handling, event listeners, URL reading).
    • Better handling when browser globals are absent.
  • Chores

    • Refactored configuration validation for clearer, maintainable checks.
  • Tests

    • Added/expanded tests to cover opt-in/out behavior and global environment scenarios.

@coderabbitai

coderabbitai Bot commented Apr 25, 2026 •

Copy link
Copy Markdown
ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Free

Run ID: 8ebb3622-064c-4151-83fd-410968e24215

📥 Commits

Reviewing files that changed from the base of the PR and between 08946fd and f69a9a4.

📒 Files selected for processing (1)
  • packages/core/src/transport/queue.ts

📝 Walkthrough

Walkthrough

Refactors global access from window/document to globalThis across autocapture, event, and transport modules; switches DOM attribute checks to dataset; refactors config validation into helper functions; updates tests/mocks for globalThis scenarios; small ESLint regex literal change.

Changes

Cohort / File(s) Summary
ESLint Configuration
eslint.config.mjs
Replaces a heavily escaped regex string with a String.raw template literal preserving the same pattern.
Autocapture — Click
packages/core/src/autocapture/click.test.ts, packages/core/src/autocapture/click.ts
Attribute detection changed from hasAttribute() to dataset checks for tracking/ignore; whitespace normalization uses replaceAll(); hostname reference uses globalThis.location.hostname.
Autocapture — Form
packages/core/src/autocapture/form.test.ts, packages/core/src/autocapture/form.ts
Form submit opt-out now checks form.dataset.analyticsIgnore (defined) instead of hasAttribute(); adds test for explicit "true" ignore value.
Autocapture — Page View
packages/core/src/autocapture/page-view.test.ts, packages/core/src/autocapture/page-view.ts
Reads location and registers popstate via globalThis; tests stub top-level location and global event listener functions.
Autocapture — Scroll Depth
packages/core/src/autocapture/scroll-depth.test.ts, packages/core/src/autocapture/scroll-depth.ts
IntersectionObserver mocked as constructor-style function; sentinel milestone stored/read via dataset.analyticsSentinel; sentinel removal uses Element.remove(); milestone parsing uses Number.parseInt().
Autocapture — Time on Page
packages/core/src/autocapture/time-on-page.test.ts, packages/core/src/autocapture/time-on-page.ts
pagehide event wiring and test dispatch switched from window to globalThis.
Config — Device / Index / Validator
packages/core/src/config/device.ts, packages/core/src/config/index.ts, packages/core/src/config/validator.ts
readUserAgent uses explicit navigator guard; type re-export now references './types'; validate() refactored into helper validators (e.g., validateEndpoint, validateFlushInterval, validateBooleanField, validateAutocapture, validateAdapters).
Events — Event Builder
packages/core/src/events/event-builder.test.ts, packages/core/src/events/event-builder.ts
URL/UTM reading uses globalThis.location.href; tests stub globalThis.location and test behavior when location is undefined.
Tracker
packages/core/src/tracker.test.ts, packages/core/src/tracker.ts
Consolidates type-only imports; test environment adds top-level location global stub to match globalThis usage.
Transport — Queue
packages/core/src/transport/queue.ts
Unload/visibility listener registration now guards globalThis.document/globalThis.window; attaches pagehide via globalThis.window and no-ops when globals are missing.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 I hopped from window to globalThis in a blink,
Datasets now whisper where attributes link,
Validators split into tidy small stacks,
Tests learned new globals and tightened their tracks,
A nibble of change—then back to my snack 🥕


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud

Copy link
Copy Markdown

@Ret2Hell
Ret2Hell merged commit 34067e7 into main Apr 25, 2026
3 of 4 checks passed
@Ret2Hell
Ret2Hell deleted the chore/refactor-validation branch April 25, 2026 17:48
@Ret2Hell Ret2Hell changed the title Refactor Validation v0.3.6 Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant