-
Notifications
You must be signed in to change notification settings - Fork 160
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
feat: add user-agent
to templates
#507
Conversation
…to feat-add-user-agent
@everly-gif are you working on these? |
@stnguyen90 I think the SDK version makes sense in the user-agent. |
@@ -43,6 +43,7 @@ class ClientIO extends ClientBase with ClientMixin { | |||
'x-sdk-platform': '{{ sdk.platform }}', | |||
'x-sdk-language': '{{ language.name | caseLower }}', | |||
'x-sdk-version': '{{ sdk.version }}', | |||
'user-agent' : '{{spec.title | caseUcfirst}}{{ language.name | caseUcfirst }}SDK/({{Platform.operatingSystem}}; {{Platform.operatingSystemVersion}})', |
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.
Missing sdk version.
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.
updated
templates/go/client.go.twig
Outdated
@@ -65,6 +65,7 @@ func NewClient() Client { | |||
headers := map[string]string{ | |||
{% for key,header in spec.global.defaultHeaders %} | |||
"{{key}}" : "{{header}}", | |||
"user-agent" : "{{spec.title | caseUcfirst}}{{ language.name | caseUcfirst }}SDK/{{ sdk.version }}", |
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.
In go, you can use runtime.GOOS
:
package main
import (
"fmt"
"runtime"
)
func main() {
s := fmt.Sprintf("(%s;%s)", runtime.GOOS, runtime.GOARCH)
fmt.Println(s)
}
outputs:
(linux;amd64)
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.
updated
templates/node/lib/client.js.twig
Outdated
@@ -11,6 +12,7 @@ class Client { | |||
this.headers = { | |||
'accept-encoding': '*', | |||
'content-type': '', | |||
'user-agent' : `{{spec.title | caseUcfirst}}{{language.name | caseUcFirst}}SDK/{{ sdk.version }} (${os.type()} ${os.version()}; ${os.arch()})`, |
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.
should the ; be after the os type rather than after the version?
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.
updated
src/SDK/Language/PHP.php
Outdated
}) | ||
}), | ||
new TwigFilter('deviceInfo', function ($value) { | ||
return php_uname('s') . ';' . php_uname('v') . ';' . php_uname('m'); |
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.
For PHP, every value is only separated by ;
and no spaces. This isn't consistent between the various user agents.
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 part is just os name, type and arch separated by ;
same as other SDKs?
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.
The other SDKs have it separated by ;
(extra space) rather than just ;
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.
got it updated
@lohanidamodar Do we want to update the client SDKs |
Only difference will be, in the client we want to use the package info of the app instead of SDK/version right. That's intended. For server side SDKs apps package, version is no much of importance |
src/SDK/Language/PHP.php
Outdated
}) | ||
}), | ||
new TwigFilter('deviceInfo', function ($value) { | ||
return php_uname('s') . ';' . php_uname('v') . ';' . php_uname('m'); |
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.
The other SDKs have it separated by ;
(extra space) rather than just ;
True makes sense 👌 |
Co-authored-by: Jake Barnby <jakeb994@gmail.com>
src/SDK/Language/PHP.php
Outdated
}) | ||
}), | ||
new TwigFilter('deviceInfo', function ($value) { | ||
return php_uname('s') . ';' . php_uname('v') . ';' . php_uname('m'); |
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.
got it updated
add
user-agent
to templates