Skip to content

init#659

Merged
alexanderkirtzel merged 3 commits into
mainfrom
658-walker-init
May 28, 2026
Merged

init#659
alexanderkirtzel merged 3 commits into
mainfrom
658-walker-init

Conversation

@alexanderkirtzel
Copy link
Copy Markdown
Collaborator

@alexanderkirtzel alexanderkirtzel commented May 27, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Fixed walker init so it correctly initializes a given scope (element(s) or document), rescans for initialization tags, and emits load events for SPA/infinite-scroll scenarios.
  • Documentation

    • Updated usage example for walker init to show passing a DOM scope directly.
  • Tests

    • Added tests covering walker commands and a regression to ensure command coverage.

Review Change Stack

@alexanderkirtzel alexanderkirtzel linked an issue May 27, 2026 that may be closed by this pull request
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

Important

Review skipped

Too many files!

This PR contains 168 files, which is 18 over the limit of 150.

To get a review, narrow the scope:
• coderabbit review --type committed # exclude uncommitted changes
• coderabbit review --dir # limit to a subdirectory
• coderabbit review --base # compare against a closer base

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 302cb3a8-d4e2-4603-8c58-d92ec2ff4cda

📥 Commits

Reviewing files that changed from the base of the PR and between 62316c5 and dc7a52a.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (168)
  • apps/cli/CHANGELOG.md
  • apps/cli/package.json
  • apps/demos/react/CHANGELOG.md
  • apps/demos/react/package.json
  • apps/demos/storybook/CHANGELOG.md
  • apps/demos/storybook/package.json
  • apps/explorer/CHANGELOG.md
  • apps/explorer/package.json
  • apps/quickstart/CHANGELOG.md
  • apps/quickstart/package.json
  • apps/storybook-addon/CHANGELOG.md
  • apps/storybook-addon/package.json
  • apps/walkerjs/CHANGELOG.md
  • apps/walkerjs/package.json
  • packages/cli/CHANGELOG.md
  • packages/cli/package.json
  • packages/collector/CHANGELOG.md
  • packages/collector/package.json
  • packages/config/CHANGELOG.md
  • packages/config/package.json
  • packages/core/CHANGELOG.md
  • packages/core/package.json
  • packages/destinations/demo/CHANGELOG.md
  • packages/destinations/demo/package.json
  • packages/mcps/mcp/CHANGELOG.md
  • packages/mcps/mcp/package.json
  • packages/mcps/source-browser/CHANGELOG.md
  • packages/mcps/source-browser/package.json
  • packages/server/core/CHANGELOG.md
  • packages/server/core/package.json
  • packages/server/destinations/amplitude/CHANGELOG.md
  • packages/server/destinations/amplitude/package.json
  • packages/server/destinations/api/CHANGELOG.md
  • packages/server/destinations/api/package.json
  • packages/server/destinations/aws/CHANGELOG.md
  • packages/server/destinations/aws/package.json
  • packages/server/destinations/bing/CHANGELOG.md
  • packages/server/destinations/bing/package.json
  • packages/server/destinations/criteo/CHANGELOG.md
  • packages/server/destinations/criteo/package.json
  • packages/server/destinations/customerio/CHANGELOG.md
  • packages/server/destinations/customerio/package.json
  • packages/server/destinations/datamanager/CHANGELOG.md
  • packages/server/destinations/datamanager/package.json
  • packages/server/destinations/file/CHANGELOG.md
  • packages/server/destinations/file/package.json
  • packages/server/destinations/gcp/CHANGELOG.md
  • packages/server/destinations/gcp/package.json
  • packages/server/destinations/hubspot/CHANGELOG.md
  • packages/server/destinations/hubspot/package.json
  • packages/server/destinations/kafka/CHANGELOG.md
  • packages/server/destinations/kafka/package.json
  • packages/server/destinations/klaviyo/CHANGELOG.md
  • packages/server/destinations/klaviyo/package.json
  • packages/server/destinations/linkedin/CHANGELOG.md
  • packages/server/destinations/linkedin/package.json
  • packages/server/destinations/meta/CHANGELOG.md
  • packages/server/destinations/meta/package.json
  • packages/server/destinations/mixpanel/CHANGELOG.md
  • packages/server/destinations/mixpanel/package.json
  • packages/server/destinations/mparticle/CHANGELOG.md
  • packages/server/destinations/mparticle/package.json
  • packages/server/destinations/pinterest/CHANGELOG.md
  • packages/server/destinations/pinterest/package.json
  • packages/server/destinations/posthog/CHANGELOG.md
  • packages/server/destinations/posthog/package.json
  • packages/server/destinations/reddit/CHANGELOG.md
  • packages/server/destinations/reddit/package.json
  • packages/server/destinations/redis/CHANGELOG.md
  • packages/server/destinations/redis/package.json
  • packages/server/destinations/rudderstack/CHANGELOG.md
  • packages/server/destinations/rudderstack/package.json
  • packages/server/destinations/segment/CHANGELOG.md
  • packages/server/destinations/segment/package.json
  • packages/server/destinations/slack/CHANGELOG.md
  • packages/server/destinations/slack/package.json
  • packages/server/destinations/snapchat/CHANGELOG.md
  • packages/server/destinations/snapchat/package.json
  • packages/server/destinations/sqlite/CHANGELOG.md
  • packages/server/destinations/sqlite/package.json
  • packages/server/destinations/tiktok/CHANGELOG.md
  • packages/server/destinations/tiktok/package.json
  • packages/server/destinations/twitter/CHANGELOG.md
  • packages/server/destinations/twitter/package.json
  • packages/server/sources/aws/CHANGELOG.md
  • packages/server/sources/aws/package.json
  • packages/server/sources/express/CHANGELOG.md
  • packages/server/sources/express/package.json
  • packages/server/sources/fetch/CHANGELOG.md
  • packages/server/sources/fetch/package.json
  • packages/server/sources/gcp/CHANGELOG.md
  • packages/server/sources/gcp/package.json
  • packages/server/stores/fs/CHANGELOG.md
  • packages/server/stores/fs/package.json
  • packages/server/stores/gcs/CHANGELOG.md
  • packages/server/stores/gcs/package.json
  • packages/server/stores/s3/CHANGELOG.md
  • packages/server/stores/s3/package.json
  • packages/server/stores/sheets/CHANGELOG.md
  • packages/server/stores/sheets/package.json
  • packages/server/transformers/bot/CHANGELOG.md
  • packages/server/transformers/bot/package.json
  • packages/server/transformers/file/CHANGELOG.md
  • packages/server/transformers/file/package.json
  • packages/server/transformers/fingerprint/CHANGELOG.md
  • packages/server/transformers/fingerprint/package.json
  • packages/transformers/demo/CHANGELOG.md
  • packages/transformers/demo/package.json
  • packages/transformers/ga4/CHANGELOG.md
  • packages/transformers/ga4/package.json
  • packages/web/core/CHANGELOG.md
  • packages/web/core/package.json
  • packages/web/destinations/amplitude/CHANGELOG.md
  • packages/web/destinations/amplitude/package.json
  • packages/web/destinations/api/CHANGELOG.md
  • packages/web/destinations/api/package.json
  • packages/web/destinations/clarity/CHANGELOG.md
  • packages/web/destinations/clarity/package.json
  • packages/web/destinations/d8a/CHANGELOG.md
  • packages/web/destinations/d8a/package.json
  • packages/web/destinations/fullstory/CHANGELOG.md
  • packages/web/destinations/fullstory/package.json
  • packages/web/destinations/gtag/CHANGELOG.md
  • packages/web/destinations/gtag/package.json
  • packages/web/destinations/heap/CHANGELOG.md
  • packages/web/destinations/heap/package.json
  • packages/web/destinations/hotjar/CHANGELOG.md
  • packages/web/destinations/hotjar/package.json
  • packages/web/destinations/linkedin/CHANGELOG.md
  • packages/web/destinations/linkedin/package.json
  • packages/web/destinations/matomo/CHANGELOG.md
  • packages/web/destinations/matomo/package.json
  • packages/web/destinations/meta/CHANGELOG.md
  • packages/web/destinations/meta/package.json
  • packages/web/destinations/mixpanel/CHANGELOG.md
  • packages/web/destinations/mixpanel/package.json
  • packages/web/destinations/optimizely/CHANGELOG.md
  • packages/web/destinations/optimizely/package.json
  • packages/web/destinations/pinterest/CHANGELOG.md
  • packages/web/destinations/pinterest/package.json
  • packages/web/destinations/piwikpro/CHANGELOG.md
  • packages/web/destinations/piwikpro/package.json
  • packages/web/destinations/plausible/CHANGELOG.md
  • packages/web/destinations/plausible/package.json
  • packages/web/destinations/posthog/CHANGELOG.md
  • packages/web/destinations/posthog/package.json
  • packages/web/destinations/segment/CHANGELOG.md
  • packages/web/destinations/segment/package.json
  • packages/web/destinations/snowplow/CHANGELOG.md
  • packages/web/destinations/snowplow/package.json
  • packages/web/destinations/tiktok/CHANGELOG.md
  • packages/web/destinations/tiktok/package.json
  • packages/web/sources/browser/CHANGELOG.md
  • packages/web/sources/browser/package.json
  • packages/web/sources/cmps/cookiefirst/CHANGELOG.md
  • packages/web/sources/cmps/cookiefirst/package.json
  • packages/web/sources/cmps/cookiepro/CHANGELOG.md
  • packages/web/sources/cmps/cookiepro/package.json
  • packages/web/sources/cmps/usercentrics/CHANGELOG.md
  • packages/web/sources/cmps/usercentrics/package.json
  • packages/web/sources/dataLayer/CHANGELOG.md
  • packages/web/sources/dataLayer/package.json
  • packages/web/sources/demo/CHANGELOG.md
  • packages/web/sources/demo/package.json
  • packages/web/sources/session/CHANGELOG.md
  • packages/web/sources/session/package.json
  • website/CHANGELOG.md
  • website/package.json

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR implements the walker init command to perform actual DOM-scoped initialization work, replacing previous no-op behavior. It adds an optional initScope hook to Context, normalizes walker init arguments to Element/Document scopes, invokes the hook per scope, wires an initScope trigger into the browser translationContext, and adds tests and docs.

Changes

walker init command implementation

Layer / File(s) Summary
Type contract and scope normalization logic
packages/web/sources/browser/src/types/index.ts, packages/web/sources/browser/src/translation.ts
Context interface gains optional initScope hook; translateToCoreCollector intercepts walker init, normalizes scope data using normalizeInitScopes and isDomScope, invokes context.initScope per scope, and returns createPushResult({ ok: true }).
Trigger registration in initialization pipeline
packages/web/sources/browser/src/index.ts
initScopeTrigger is imported and registered in translationContext under initScope, wiring the scope handler into the browser source lifecycle.
Command test suites and coverage enforcement
packages/web/sources/browser/src/__tests__/commands.test.ts, packages/web/sources/browser/src/__tests__/command-coverage.test.ts
New tests validate walker init with single/array scopes, document fallback, dynamic injection, and repeated invocation; additional suites cover walker destination and walker hook; coverage test asserts all walker commands appear in tests.
Documentation and release notes
website/docs/sources/web/browser/index.mdx, .changeset/walker-init-fix.md
Example updated to pass a DOM element directly to walker init; changeset documents the fix enabling re-scan of data-elb* within scope and firing load triggers.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • elbwalker/walkerOS#602: Updates walker init call sites to pass DOM elements directly instead of scope-wrapped objects, aligning with this PR's argument normalization behavior.

Poem

🐰 I hop through DOMs both near and far,
I scan for data-elb beneath each star,
I call the hooks and fire the loads anew,
For SPAs and scrolls I leap right through,
Tests and notes in my little paw — huzzah!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'init' is vague and generic, referring only to a function name without indicating what specific work or fix is being implemented for the walker init functionality. Use a more descriptive title that captures the main change, such as 'Implement walker init scope re-scanning' or 'Fix walker init to perform DOM element initialization'.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 658-walker-init

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/web/sources/browser/src/translation.ts`:
- Around line 147-150: The isDomScope type guard is too permissive by checking
only for 'body' or 'tagName' keys; update it to reliably detect real DOM nodes
by verifying the runtime types instead (e.g., use instanceof Element or
instanceof Document when available, and as a fallback check nodeType === 1 for
elements or nodeType === 9 for documents). Modify the isDomScope function to
first ensure value is non-null object and then return true only when it
satisfies the robust DOM checks (Element/Document instanceof or nodeType checks)
so plain objects with tagName/body properties no longer pass as DOM scopes.

In `@website/docs/sources/web/browser/index.mdx`:
- Around line 92-93: The example calls elb('walker init',
document.querySelector('`#app`')) without guarding for a null DOM node; change the
snippet so you first query the element (document.querySelector('`#app`')) and only
pass it to elb('walker init', element) if the element is non-null (otherwise
fall back to omitting the element or using a safe default), ensuring the example
is null-safe and does not silently no-op when '`#app`' is missing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dc813866-cd9c-405f-a6ef-2b67ef9b6754

📥 Commits

Reviewing files that changed from the base of the PR and between 30dbaf3 and b506f2c.

📒 Files selected for processing (7)
  • .changeset/walker-init-fix.md
  • packages/web/sources/browser/src/__tests__/command-coverage.test.ts
  • packages/web/sources/browser/src/__tests__/commands.test.ts
  • packages/web/sources/browser/src/index.ts
  • packages/web/sources/browser/src/translation.ts
  • packages/web/sources/browser/src/types/index.ts
  • website/docs/sources/web/browser/index.mdx

Comment thread packages/web/sources/browser/src/translation.ts
Comment on lines +92 to 93
elb('walker init', document.querySelector('#app'));
elb('product view', { id: 'P123' }); // Also tracks events`}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Make the example null-safe to avoid silent no-op.

document.querySelector('#app') may be null; guarding it keeps the snippet reliable for users.

💡 Proposed fix
-// Browser source elb: Enhanced with DOM commands
-elb('walker init', document.querySelector('`#app`'));
+// Browser source elb: Enhanced with DOM commands
+const appRoot = document.querySelector('`#app`');
+if (appRoot) elb('walker init', appRoot);
 elb('product view', { id: 'P123' }); // Also tracks events
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@website/docs/sources/web/browser/index.mdx` around lines 92 - 93, The example
calls elb('walker init', document.querySelector('`#app`')) without guarding for a
null DOM node; change the snippet so you first query the element
(document.querySelector('`#app`')) and only pass it to elb('walker init', element)
if the element is non-null (otherwise fall back to omitting the element or using
a safe default), ensuring the example is null-safe and does not silently no-op
when '`#app`' is missing.

@github-actions
Copy link
Copy Markdown
Contributor

Preview deployed

https://walkeros-io.b-cdn.net/preview/pr-659/

@github-actions
Copy link
Copy Markdown
Contributor

🚀 Stable release published

Packages

Install: npm i @walkeros/core@latest

🐳 Docker images published

  • walkeros/flow:4.1.2 (:latest)
  • walkeros/cli:4.1.2 (:latest)

Docker: docker pull walkeros/flow:latest

@alexanderkirtzel alexanderkirtzel merged commit 88579cd into main May 28, 2026
1 check passed
@alexanderkirtzel alexanderkirtzel deleted the 658-walker-init branch May 28, 2026 09:04
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.

walker init

1 participant