-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added API Key to Fire Function #89
Added API Key to Fire Function #89
Conversation
This pull request has been linked to Shortcut Story #50473: Decision SDK Fire Function Not Working. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some tests, but I'm not familiar with them, If it's easy to add coverage there for this feature, it might be helpful
src/client.ts
Outdated
@@ -335,7 +341,7 @@ class PixelClient { | |||
method: 'GET', | |||
headers: { | |||
'X-Adzerk-Sdk-Version': this._versionString, | |||
'X-Kevel-ApiKey': additionalOpts?.apiKey, | |||
'X-Kevel-ApiKey': additionalOpts?.apiKey ?? this._options?.apiKey, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not very familiar with the Decision API. The only thing I worry about here is that for the Decision client, we only include the header if it is present, but here, we are including the header in every request, with a null value if it is not present. I'm wondering if it might be safer to only include the header if the apikey is found?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a comment from Ash to help the user experience. I'll roll it back to original functionality for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I like the fallback from additionalOpts to this._options. I'm just afraid of sending X-Kevel-ApiKey: null
rather than not sending the header at all if apikey is not set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It diverges against establshed behaviour, we could roll this, but we'd have to announce it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about something like:
if (additionalOpts?.apiKey) {
opts.headers['X-Kevel-ApiKey'] = additionalOpts.apiKey;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't actually the topic, but good suggestion as fetch actually still sends something even if set to undefined and null. Have updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was actually what I was trying to suggest, but Akira is a better communicator than me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhhhhhh, I get it now. Sorry @vkurup that's clearly my misread.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh, no worries! It's a 2 way street and both of ours have had heavy traffic on them recently
…pi key." This reverts commit 4858f8d.
Allows for authenticated requests.