Skip to content

💡 refactor(stateless): Add request scopes for per-request Experience options#199

Merged
Charles Hudson (phobetron) merged 1 commit intomainfrom
NT-2817_node-sdk-guide
Apr 1, 2026
Merged

💡 refactor(stateless): Add request scopes for per-request Experience options#199
Charles Hudson (phobetron) merged 1 commit intomainfrom
NT-2817_node-sdk-guide

Conversation

@phobetron
Copy link
Copy Markdown
Collaborator

@phobetron Charles Hudson (phobetron) commented Apr 1, 2026

While documenting the Node SDK, it became clear that request-specific Experience API options were being configured on the stateless SDK instance itself. That forced consumers to create a new SDK instance per incoming request just to set values such as ip, locale, plainText, or preflight, which works against the intended singleton-style usage and adds unnecessary overhead.

Move stateless event emission behind forRequest(...) so those request-bound Experience options can be set per request while reusing one SDK instance.

  • add CoreStatelessRequestScope and split shared, stateful, and stateless API config types into CoreApiConfig
  • keep stateless constructor config limited to shared API settings and pass request-bound Experience options through forRequest(...)
  • update the Node SDK, dev harness, and Node reference implementations to reuse one SDK instance and create a request scope per request
  • add unit coverage for request-bound options and refresh the core and Node docs with a new Node integration guide

[NT-2817]

@wiz-inc-38d59fb8d7
Copy link
Copy Markdown

wiz-inc-38d59fb8d7 Bot commented Apr 1, 2026

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities -
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings 5 Low
Software Management Finding Software Management Findings -
Total 5 Low

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

…options

While documenting the Node SDK, it became clear that request-specific
Experience API options were being configured on the stateless SDK instance
itself. That forced consumers to create a new SDK instance per incoming
request just to set values such as `ip`, `locale`, `plainText`, or
`preflight`, which works against the intended singleton-style usage and adds
unnecessary overhead.

Move stateless event emission behind `forRequest(...)` so those request-bound
Experience options can be set per request while reusing one SDK instance.

- add `CoreStatelessRequestScope` and split shared, stateful, and stateless
  API config types into `CoreApiConfig`
- keep stateless constructor config limited to shared API settings and pass
  request-bound Experience options through `forRequest(...)`
- update the Node SDK, dev harness, and Node reference implementations to
  reuse one SDK instance and create a request scope per request
- add unit coverage for request-bound options and refresh the core and Node
  docs with a new Node integration guide

[[NT-2817](https://contentful.atlassian.net/browse/NT-2817)]
@phobetron Charles Hudson (phobetron) merged commit f19afed into main Apr 1, 2026
31 checks passed
@phobetron Charles Hudson (phobetron) deleted the NT-2817_node-sdk-guide branch April 1, 2026 14:26
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