Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
CHANGELOG
=========

8.4.0
------------------

* Added the input `/device/tracking_token`. This is the token generated by
the [Device Tracking Add-on](https://dev.maxmind.com/minfraud/track-devices)
for explicit device linking. You may provide this by providing
`trackingToken` to `Device`.

8.3.0 (2026-01-20)
------------------

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ try {
transaction = new minFraud.Transaction({
device: new minFraud.Device({
ipAddress: "81.2.69.160",
trackingToken: "abc123",
}),
event: new minFraud.Event({
party: minFraud.Constants.EventParty.Customer,
Expand Down
8 changes: 8 additions & 0 deletions src/request/device.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,12 @@ describe('Device()', () => {
});
}).not.toThrow();
});

it('sets trackingToken correctly', () => {
const device = new Device({
ipAddress: '1.1.1.1',
trackingToken: 'abc123',
});
expect(device.trackingToken).toBe('abc123');
});
Comment on lines +31 to +37

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The test plan mentions that the new trackingToken field serializes to tracking_token, but this is not covered in the tests. To ensure the serialization works as expected and to prevent future regressions, it would be valuable to add a test case that verifies this behavior. This test would likely involve the Transaction class and could be placed in transaction.spec.ts if that's more appropriate.

Here's an example of what such a test could look like:

import Transaction from '../transaction';

it('serializes device with tracking_token', () => {
  const transaction = new Transaction({
    device: new Device({
      ipAddress: '1.1.1.1',
      trackingToken: 'abc123',
    }),
  });

  const result = JSON.parse(transaction.toString());
  expect(result.device.tracking_token).toBe('abc123');
});

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT, this is a pre-existing issue for all the request tests in this library.

});
7 changes: 7 additions & 0 deletions src/request/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ interface DeviceProps {
* identifies a visitor's session on the site.
*/
sessionId?: string;
/**
* The tracking token from the Device Tracking Add-on for explicit device
* linking.
*/
trackingToken?: string;
}

/**
Expand All @@ -42,6 +47,8 @@ export default class Device implements DeviceProps {
public sessionAge?: number;
/** @inheritDoc DeviceProps.sessionId */
public sessionId?: string;
/** @inheritDoc DeviceProps.trackingToken */
public trackingToken?: string;

public constructor(device: DeviceProps) {
if (device.ipAddress != null && isIP(device.ipAddress) === 0) {
Expand Down