-
Notifications
You must be signed in to change notification settings - Fork 35
Added device model and brand to user_agent output #77
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
package org.logstash.uaparser; | ||
|
||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Device parsed data class | ||
|
@@ -27,7 +28,44 @@ | |
*/ | ||
final class Device { | ||
|
||
public static String fromMap(Map<String, String> m) { | ||
return m.get("family"); | ||
public final String family; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems that the uap-java does not have these changes: so this was written from scratch or copied from somewhere else? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kares this was written from scratch (similar to the OS class). I did not find a reference in the java class that it was from the uap-java project. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that you pointed me to it - there is a PR ua-parser/uap-java#37 in the uap-java project that asks for same functionality but it hasn't seen action since early 2020. If I had seen it, I would have mentioned it. |
||
public final String brand; | ||
public final String model; | ||
|
||
Device(String family, String brand, String model) { | ||
this.family = family; | ||
this.brand = brand; | ||
this.model = model; | ||
} | ||
|
||
public static Device fromMap(Map<String, String> m) { | ||
return new Device(m.get("family"), m.get("brand"), m.get("model")); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == this) return true; | ||
if (!(other instanceof Device)) return false; | ||
Device o = (Device) other; | ||
return ((this.family != null && this.family.equals(o.family)) || Objects.equals(this.family, o.family)) && | ||
((this.brand != null && this.brand.equals(o.brand)) || Objects.equals(this.brand, o.brand)) && | ||
((this.model != null && this.model.equals(o.model)) || Objects.equals(this.model, o.model)) ; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int h = family == null ? 0 : family.hashCode(); | ||
h += brand == null ? 0 : brand.hashCode(); | ||
h += model == null ? 0 : model.hashCode(); | ||
return h; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("{\"family\": %s, \"brand\": %s, \"model\": %s}", | ||
family == null ? "" : family, | ||
brand == null ? "" : brand, | ||
model == null ? "" : model | ||
); | ||
} | ||
} |
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.
these are going to be problematic as ATM ECS (1.11) only supports
user_agent.device.name
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.
@kares is there an "experimental" switch that could enable this behavior? Such that it is still compliant?