alexa / alexa-skills-kit-sdk-for-nodejs

The Alexa Skills Kit SDK for Node.js helps you get a skill up and running quickly, letting you focus on skill logic instead of boilerplate code.
Apache License 2.0
3.12k stars 736 forks source link

feat: add UserAgentManager #657

Closed breedloj closed 3 years ago

breedloj commented 3 years ago

Description

Adds a static UserAgentManager which manages environment level SDK user agent information. User agent component registration and full user agent string retrieval is encapsulated by this new class rather than being registered and computed at the CustomSkill layer.

The manager does not allow for duplicate user agent components and only computes an updated user agent string once per valid component addition. At request time, the precomputed value is used rather than the existing approach which required reconstruction per request.

Motivation and Context

The primary motivation for this change is to allow other frameworks that are designed for use with the SDK, but may not directly be configured on the SDK instance itself, to register themselves with user agent components. With this singleton manager approach, such components can directly append a user agent component at runtime/request execution.

Testing

Added tests for the UserAgentManager and an additional test for CustomSkill. Existing tests continue to pass.

Types of changes

Checklist

License