Skip to content

Commit 7ec6f98

Browse files
oschwaldclaude
andcommitted
Add trackingToken to Device request object
This adds the optional trackingToken field to the Device request object for explicit device linking via the Device Tracking Add-on. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9562c50 commit 7ec6f98

File tree

7 files changed

+42
-2
lines changed

7 files changed

+42
-2
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
CHANGELOG
22
=========
33

4+
4.2.0
5+
------------------
6+
7+
* Added `trackingToken` to the `Device` request object. This is the token
8+
generated by the
9+
[Device Tracking Add-on](https://dev.maxmind.com/minfraud/track-devices)
10+
for explicit device linking.
11+
412
4.1.0 (2026-01-20)
513
------------------
614

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ Transaction request = new Transaction.Builder(
144144
.acceptLanguage("en-US")
145145
.sessionAge(3600.6)
146146
.sessionId("foobar")
147+
.trackingToken("abc123")
147148
.userAgent("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36")
148149
.build()
149150
).account(

src/main/java/com/maxmind/minfraud/request/Device.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ public final class Device extends AbstractModel {
1313
private final String acceptLanguage;
1414
private final Double sessionAge;
1515
private final String sessionId;
16+
private final String trackingToken;
1617

1718
private Device(Device.Builder builder) {
1819
ipAddress = builder.ipAddress;
1920
userAgent = builder.userAgent;
2021
acceptLanguage = builder.acceptLanguage;
2122
sessionAge = builder.sessionAge;
2223
sessionId = builder.sessionId;
24+
trackingToken = builder.trackingToken;
2325
}
2426

2527
/**
@@ -32,6 +34,7 @@ public static final class Builder {
3234
String acceptLanguage;
3335
Double sessionAge;
3436
String sessionId;
37+
String trackingToken;
3538

3639
/**
3740
* Constructor for the {@code Device.Builder} class
@@ -100,6 +103,16 @@ public Device.Builder sessionId(String sessionId) {
100103
return this;
101104
}
102105

106+
/**
107+
* @param val The tracking token generated by the Device Tracking Add-on
108+
* for explicit device linking.
109+
* @return The builder object.
110+
*/
111+
public Device.Builder trackingToken(String val) {
112+
trackingToken = val;
113+
return this;
114+
}
115+
103116
/**
104117
* @return An instance of {@code Device} created from the fields set on this builder.
105118
*/
@@ -140,6 +153,14 @@ public String sessionId() {
140153
return sessionId;
141154
}
142155

156+
/**
157+
* @return The tracking token.
158+
*/
159+
@JsonProperty("tracking_token")
160+
public String trackingToken() {
161+
return trackingToken;
162+
}
163+
143164
/**
144165
* @return The IP address used in the transaction.
145166
*/

src/test/java/com/maxmind/minfraud/request/DeviceTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,11 @@ public void testSessionId() {
6161
var device = new Builder(ip).sessionId(id).build();
6262
assertEquals(id, device.sessionId());
6363
}
64+
65+
@Test
66+
public void testTrackingToken() {
67+
var token = "abc123";
68+
var device = new Builder(ip).trackingToken(token).build();
69+
assertEquals(token, device.trackingToken());
70+
}
6471
}

src/test/java/com/maxmind/minfraud/request/RequestTestHelper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ private static Transaction makeTransaction(Email e) throws Exception {
5353
.sessionAge(3600.5)
5454
.sessionId("foobar")
5555
.acceptLanguage("en-US,en;q=0.8")
56+
.trackingToken("tst_abc123")
5657
.build()
5758
)
5859
.event(

src/test/resources/test-data/full-request-email-md5.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
"user_agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36",
9494
"session_age": 3600.5,
9595
"session_id": "foobar",
96-
"accept_language": "en-US,en;q=0.8"
96+
"accept_language": "en-US,en;q=0.8",
97+
"tracking_token": "tst_abc123"
9798
}
9899
}

src/test/resources/test-data/full-request.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
"user_agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36",
9494
"session_age": 3600.5,
9595
"session_id": "foobar",
96-
"accept_language": "en-US,en;q=0.8"
96+
"accept_language": "en-US,en;q=0.8",
97+
"tracking_token": "tst_abc123"
9798
}
9899
}

0 commit comments

Comments
 (0)