Skip to content

Remove analytics attribute handling from sdk-react Contentlet component #33947

@oidacra

Description

@oidacra

Description

Remove analytics attribute handling from Contentlet.tsx in sdk-react to reuse UVE (Universal Visual Editor) analytics attributes. Currently, the component has conditional logic that only renders analytics attributes when isAnalyticsActive && !isDevMode.

This task involves:

  1. Remove the useIsAnalyticsActive hook - No longer needed since analytics will always be active
  2. Remove conditional logic from analyticsAttributes useMemo - Analytics attributes should always be applied
  3. Simplify the component - Analytics attributes from UVE will always be rendered, not conditionally

Key Change: Analytics attributes (provided by getDotAnalyticsAttributes from UVE) will always render, regardless of Edit Mode or analytics enabled state. This ensures consistent analytics tracking and removes unnecessary complexity.

Acceptance Criteria

  • Remove useIsAnalyticsActive hook import and usage
  • Remove conditional check isAnalyticsActive && !isDevMode from analyticsAttributes useMemo
  • Remove conditional check isAnalyticsActive && !isDevMode from containerClassName useMemo
  • Analytics attributes are always rendered (no conditional logic)
  • Analytics class dotcms-contentlet is always applied
  • No regression in UVE functionality
  • Unit tests updated and passing

Priority

Medium - This is a refactoring task to improve code maintainability and ensure consistent analytics behavior.

Additional Context

Technology: Front-end (React/TypeScript SDK)

Files affected:

  • core-web/libs/sdk/react/src/lib/next/components/Contentlet/Contentlet.tsx

Current behavior: Analytics attributes only render when isAnalyticsActive && !isDevMode
New behavior: Analytics attributes always render (reusing UVE's getDotAnalyticsAttributes)

Related work: This aligns with the overall strategy to consolidate analytics functionality and reduce code duplication across the SDK and UVE.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Current Sprint Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions