Skip to content

Commit cd25cbc

Browse files
committed
Add setUseragent (closes snowplow#87)
1 parent c5c79f2 commit cd25cbc

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

src/main/java/com/snowplowanalytics/snowplow/tracker/Subject.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ public void setIpAddress(String ipAddress) {
102102
this.standardPairs.put(Parameter.IP_ADDRESS, ipAddress);
103103
}
104104

105+
/**
106+
* User inputted useragent for the
107+
* subject.
108+
*
109+
* @param useragent a useragent
110+
*/
111+
public void setUseragent(String useragent) {
112+
this.standardPairs.put(Parameter.USERAGENT, useragent);
113+
}
114+
105115
/**
106116
* Gets the Subject pairs.
107117
*

src/main/java/com/snowplowanalytics/snowplow/tracker/constants/Parameter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class Parameter {
3838
public static final String TIMEZONE = "tz";
3939
public static final String LANGUAGE = "lang";
4040
public static final String IP_ADDRESS = "ip";
41+
public static final String USERAGENT = "ua";
4142

4243
// Page View
4344
public static final String PAGE_URL = "url";

src/test/java/com/snowplowanalytics/snowplow/tracker/SubjectTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ public void testSetIpAddress() throws Exception {
7171
assertEquals("127.0.0.1", subject.getSubject().get("ip"));
7272
}
7373

74+
@Test
75+
public void testSetUseragent() throws Exception {
76+
Subject subject = new Subject();
77+
subject.setUseragent("useragent");
78+
assertEquals("useragent", subject.getSubject().get("ua"));
79+
}
80+
7481
@Test
7582
public void testGetSubject() throws Exception {
7683
Subject subject = new Subject();

0 commit comments

Comments
 (0)