Skip to content

feat: [Nt 2734] merge both use personalization and use analytics into use optimization#178

Merged
Lotfi Anwar L Arif (Lotfi-Arif) merged 4 commits intomainfrom
NT-2734-merge-both-use-personalization-and-use-analytics-into-use-optimization
Mar 19, 2026
Merged

feat: [Nt 2734] merge both use personalization and use analytics into use optimization#178
Lotfi Anwar L Arif (Lotfi-Arif) merged 4 commits intomainfrom
NT-2734-merge-both-use-personalization-and-use-analytics-into-use-optimization

Conversation

@Lotfi-Arif
Copy link
Copy Markdown
Contributor

@Lotfi-Arif Lotfi Anwar L Arif (Lotfi-Arif) commented Mar 18, 2026

Aligned the React web SDK API with the intended SDK surface by making useOptimization() the main high-level hook for tracking and entry resolution, while adding useOptimizationContext() for readiness/error state and useOptimizedEntry() as the public personalization hook. Also updated OptimizationProvider to support injected SDK instances, refactored OptimizedEntry onto the new hook, refreshed docs/tests, and verified format, lint, typecheck, and unit tests all pass.

- Update hooks and providers to use the new context shape, add
  useAnalytics and usePersonalization helpers, and introduce
  OptimizationSdk type for improved type safety.
@Lotfi-Arif Lotfi Anwar L Arif (Lotfi-Arif) changed the title Nt 2734 merge both use personalization and use analytics into use optimization feat: [Nt 2734] merge both use personalization and use analytics into use optimization Mar 18, 2026
@Lotfi-Arif Lotfi Anwar L Arif (Lotfi-Arif) marked this pull request as ready for review March 18, 2026 16:28
Copy link
Copy Markdown
Collaborator

@phobetron Charles Hudson (phobetron) Mar 19, 2026

Choose a reason for hiding this comment

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

These types all seem redundant. I'm thinking we should figure out how to eliminate the need for this file altogether. And if we need a type for something that is defined concretely, we can simply say typeof Something, unless that something isn't intended to be inlined in the generated bundle at all, but I think that's not likely for these types here.

Comment thread packages/web/frameworks/react-web-sdk/src/hooks/useOptimization.ts Outdated
Comment thread packages/web/frameworks/react-web-sdk/src/hooks/useOptimization.ts Outdated
Comment thread packages/web/frameworks/react-web-sdk/src/hooks/useOptimization.ts Outdated
Comment thread packages/web/frameworks/react-web-sdk/src/hooks/useOptimization.ts Outdated
Comment thread packages/web/frameworks/react-web-sdk/src/hooks/useOptimization.ts Outdated
Comment thread packages/web/frameworks/react-web-sdk/src/test/optimizationTestUtils.ts Outdated
@phobetron
Copy link
Copy Markdown
Collaborator

Make sure to fix those linter issues

Move all personalization components and tests to a new
optimized-entry directory. Update imports and types to reference
OptimizationContext instead of the removed types module. Remove
legacy Personalization test files and types.
Refactor personalization components to optimized-entry directory

Move OptimizedEntry and related files from personalization to
optimized-entry.
Update imports and types to reference new location. Remove obsolete
tests and
types.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think the tests (and test setup/utils) could use a lot of trimming, but other than that, everything looks great!

@Lotfi-Arif Lotfi Anwar L Arif (Lotfi-Arif) merged commit e711228 into main Mar 19, 2026
29 checks passed
@Lotfi-Arif Lotfi Anwar L Arif (Lotfi-Arif) deleted the NT-2734-merge-both-use-personalization-and-use-analytics-into-use-optimization branch March 19, 2026 12:42
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.

2 participants