Skip to content

Add Java version to user agent #36

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

Merged
merged 2 commits into from
Sep 21, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion api/src/main/java/com/messagebird/MessageBirdServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class MessageBirdServiceImpl implements MessageBirdService {
private final String accessKey;
private final String serviceUrl;
private final String clientVersion = "2.0.0";
private final String userAgentString = "MessageBird/Java ApiClient/" + clientVersion;
private final String userAgentString;
private Proxy proxy = null;

public MessageBirdServiceImpl(final String accessKey, final String serviceUrl) {
Expand All @@ -57,6 +57,18 @@ public MessageBirdServiceImpl(final String accessKey, final String serviceUrl) {
}
this.accessKey = accessKey;
this.serviceUrl = serviceUrl;
this.userAgentString = determineUserAgentString();
}

private String determineUserAgentString() {
double javaVersion = DEFAULT_JAVA_VERSION;
try {
javaVersion = getVersion();
} catch (GeneralException e) {
// Do nothing: leave the version at its default.
}

return String.format("MessageBird Java/%s ApiClient/%s", javaVersion, clientVersion);
}

/**
Expand Down