Skip to content

feat(content-preview): forward clientName prop to Preview options#4586

Merged
mergify[bot] merged 2 commits into
box:masterfrom
ahorowitz123:PREVIEW-326-forward-client-name
May 22, 2026
Merged

feat(content-preview): forward clientName prop to Preview options#4586
mergify[bot] merged 2 commits into
box:masterfrom
ahorowitz123:PREVIEW-326-forward-client-name

Conversation

@ahorowitz123
Copy link
Copy Markdown
Contributor

@ahorowitz123 ahorowitz123 commented May 21, 2026

Summary

Accepts a new optional clientName prop on <ContentPreview> and threads it into previewOptions so the underlying box-content-preview library can tag emitted preview_metric / preview_error events with the host application name. Lets monitoring dashboards split traffic by host (EUA vs preview-client).

This is a Phase 2 follow-up to #4542 which added the four other monitoring-dimension props (accessPattern, previewMode, sharedLinkAuth, preloadStatus). Same forwarding pattern, just one more prop.

Why

EUA and preview-client both render <ContentPreview>. Without clientName, the underlying preview library can't distinguish which app called it. This unblocks "EUA vs preview-client" panels in the Preview Performance Monitoring dashboards

Implementation

  • src/elements/content-preview/ContentPreview.js:
    • Added clientName?: string to the Props type
    • Destructured clientName in loadPreview
    • Passed it through to previewOptions alongside the existing four monitoring dimensions
  • src/elements/content-preview/__tests__/ContentPreview.test.js: extended the existing monitoring-dimensions tests to cover clientName (forwarded when supplied, undefined when omitted)

Test plan

  • Unit test: clientName forwards to preview.show() options when supplied — passes
  • Unit test: option is undefined when prop omitted — passes
  • Full ContentPreview test suite passes (149 tests)
  • ESLint clean on touched files
  • No changes to existing behavior when host omits the prop

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • ContentPreview accepts an optional client name parameter to include host-supplied monitoring info in previews.
  • Tests

    • Unit tests updated to verify the client name is forwarded when provided and omitted when not supplied.

Review Change Stack

@ahorowitz123 ahorowitz123 requested review from a team as code owners May 21, 2026 21:52
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 21, 2026

Walkthrough

The PR adds an optional clientName prop to ContentPreview and forwards it into the previewOptions passed to Box.Preview().show() during initialization. Unit tests are updated to assert the prop is forwarded when present and undefined when omitted.

Changes

Add clientName monitoring dimension to ContentPreview

Layer / File(s) Summary
Add clientName prop and forward to preview options
src/elements/content-preview/ContentPreview.js, src/elements/content-preview/__tests__/ContentPreview.test.js
Props type gains optional clientName?: string field; loadPreview destructures and forwards clientName into previewOptions passed to Box.Preview().show(); tests verify the prop is included in preview options when provided and undefined when omitted.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • box/box-ui-elements#4542: Adds clientName as a monitoring dimension to preview options in loadPreview, directly aligned with this PR's prop forwarding pattern.
  • box/box-ui-elements#4452: Modifies preview initialization timing for loadPreview/preview.show, intersecting with this PR's changes to preview options.

Suggested labels

ready-to-merge

Suggested reviewers

  • jackiejou
  • jmcbgaston

Poem

🐰 Through props and options the client name hops in,
Carried to preview where monitoring begins.
Tests nod and check each pathway and bend,
A tiny prop journey, from start to end.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: adding a clientName prop and forwarding it to Preview options.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Description check ✅ Passed The PR description comprehensively covers all required sections: summary, rationale, implementation details, and test plan with verification checkmarks.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Adds an optional clientName prop on <ContentPreview> that's threaded
into previewOptions so the underlying box-content-preview library can
tag emitted events with the host application name. Lets monitoring
dashboards split traffic by host (EUA vs preview-client).

Mirrors the four monitoring-dimension props added in PR box#4542
(accessPattern, previewMode, sharedLinkAuth, preloadStatus). When
omitted, the prop flows through as undefined — same no-op default
behavior.

Companion PRs:
- box-content-preview: emit client_name on every event (PREVIEW-325)
- EndUserApp: pass clientName='enduserapp' (PREVIEW-327)
- preview-client: pass clientName='preview-client' (PREVIEW-328)
- monitoring/analytics-schemas: declare client_name field (PREVIEW-324)
- data-platform: extract client_name as Zephyr metric tag (PREVIEW-323)

JIRA: PREVIEW-326
Umbrella: PREVIEW-322
Epic: WEBAPP-53337

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ahorowitz123 ahorowitz123 force-pushed the PREVIEW-326-forward-client-name branch from 7f14ada to 5d2a6ff Compare May 22, 2026 15:52
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 22, 2026

Merge Queue Status

  • Entered queue2026-05-22 19:24 UTC · Rule: Automatic strict merge
  • Checks passed · in-place
  • Merged2026-05-22 19:37 UTC · at 1fbdb458239e4a2642651f6e704572dd71b1e008 · squash

This pull request spent 12 minutes 25 seconds in the queue, including 11 minutes 58 seconds running CI.

Required conditions to merge

@mergify mergify Bot merged commit 1dfadde into box:master May 22, 2026
9 of 10 checks passed
@mergify mergify Bot removed the queued label May 22, 2026
@ahorowitz123 ahorowitz123 deleted the PREVIEW-326-forward-client-name branch May 22, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants