Skip to content

Conversation

sameerank
Copy link
Contributor

@sameerank sameerank commented Nov 27, 2024


labels: mergeable

Fixes: #issue

Motivation and Context

I was running a script to try out the init function and saw the following exception thrown when I invoked init with a pre-existing SDK key.

Error during initialization test: Error: Unable to parse Event ingestion URL from SDK key
    at newDefaultEventDispatcher (/.../js-client-sdk/node_modules/@eppo/js-client-sdk-common/src/events/default-event-dispatcher.ts:138:11)

I think the SDK should continue to support old keys, or at least handle the exception so it doesn't get thrown outside the SDK's scope

Description

Here, I propose wrapping the event dispatcher instantiation with a try-catch. Other approaches, like handling this in js-client-sdk-common, may be valid too

How has this been tested?

Copy link
Contributor

@aarsilv aarsilv left a comment

Choose a reason for hiding this comment

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

Big fan of SDK failure modes, thanks for thinking through this!


// e.g. newDefaultEventDispatcher throws an error if it cannot parse a valid event ingestion URL from the SDK key
try {
instance.setEventDispatcher(newEventDispatcher(apiKey));
Copy link
Contributor

Choose a reason for hiding this comment

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

fixed in Eppo-exp/js-sdk-common#143 to no longer throw
I'd vote removing this try/catch since it should never throw after that change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. I'll close this out

@sameerank sameerank closed this Nov 27, 2024
@sameerank sameerank deleted the sameeran/init-should-not-require-event-ingestion-url-in-sdk-key branch November 27, 2024 18:24
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.

3 participants