|
1 | 1 | # MaxMind Device Tracking Add-On |
2 | 2 |
|
| 3 | +A thin loader package for MaxMind's [minFraud device tracking](https://dev.maxmind.com/minfraud/track-devices) |
| 4 | +system. This package dynamically loads the device fingerprinting module from |
| 5 | +MaxMind's servers at runtime, ensuring you always get the latest version without |
| 6 | +updating the npm package. |
| 7 | + |
| 8 | +The package itself contains no fingerprinting logic — it validates inputs, loads |
| 9 | +the remote module, and returns the tracking token. |
| 10 | + |
3 | 11 | ## Installation |
4 | 12 |
|
5 | 13 | ```bash |
6 | 14 | npm install @maxmind/device-tracking |
7 | 15 | ``` |
8 | 16 |
|
9 | | -## License |
| 17 | +## Usage |
| 18 | + |
| 19 | +```typescript |
| 20 | +import { trackDevice } from '@maxmind/device-tracking'; |
| 21 | + |
| 22 | +const result = await trackDevice({ accountId: 123456 }); |
| 23 | +console.log(result.trackingToken); |
| 24 | +``` |
| 25 | + |
| 26 | +### Ad-blocker bypass |
| 27 | + |
| 28 | +If you proxy MaxMind's device tracking through your own subdomain (to avoid |
| 29 | +ad-blockers), pass the `host` option. The module will be loaded from your |
| 30 | +custom host, and the host value is passed to the remote module for its own use: |
| 31 | + |
| 32 | +```typescript |
| 33 | +const result = await trackDevice({ |
| 34 | + accountId: 123456, |
| 35 | + host: 'tracking.yourdomain.com', |
| 36 | +}); |
| 37 | +``` |
| 38 | + |
| 39 | +### Disable WebGL hash |
| 40 | + |
| 41 | +For performance or compatibility, you can disable WebGL hash collection: |
| 42 | + |
| 43 | +```typescript |
| 44 | +const result = await trackDevice({ |
| 45 | + accountId: 123456, |
| 46 | + disableWebglHash: true, |
| 47 | +}); |
| 48 | +``` |
| 49 | + |
| 50 | +## API reference |
| 51 | + |
| 52 | +### `trackDevice(options: TrackDeviceOptions): Promise<TrackResult>` |
| 53 | + |
| 54 | +Loads the device tracking module (if not already cached) and collects a device |
| 55 | +fingerprint. |
| 56 | + |
| 57 | +### `TrackDeviceOptions` |
10 | 58 |
|
11 | | -Licensed under either of |
| 59 | +| Property | Type | Required | Description | |
| 60 | +| ------------------ | --------- | -------- | ----------------------------------------------- | |
| 61 | +| `accountId` | `number` | Yes | Your MaxMind account ID (positive integer) | |
| 62 | +| `host` | `string` | No | Custom hostname for ad-blocker bypass | |
| 63 | +| `disableWebglHash` | `boolean` | No | Disable WebGL hash collection | |
12 | 64 |
|
13 | | -- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or |
14 | | - https://www.apache.org/licenses/LICENSE-2.0) |
15 | | -- MIT license ([LICENSE-MIT](LICENSE-MIT) or |
16 | | - https://opensource.org/licenses/MIT) |
| 65 | +### `TrackResult` |
17 | 66 |
|
18 | | -at your option. |
| 67 | +| Property | Type | Description | |
| 68 | +| --------------- | -------- | ------------------------------ | |
| 69 | +| `trackingToken` | `string` | Opaque device tracking token | |
0 commit comments