Skip to content
Closed
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
5 changes: 5 additions & 0 deletions .changeset/add-make-edge-event.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fingerprint/node-sdk": minor
---

Add `makeEdgeEvent()` to collect Automation Intelligence via `POST /v4/edge`
Comment on lines +1 to +5
2 changes: 1 addition & 1 deletion example/getEvent.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ try {
const event = await client.getEvent(eventId, { ruleset_id: rulesetId })
console.log(JSON.stringify(event, null, 2))

if (rulesetId && event.rule_action) {
if (rulesetId && event.source === 'device' && event.rule_action) {
const { type, ruleset_id, rule_id, rule_expression } = event.rule_action
console.log(`Rule action: ${type} (ruleset: ${ruleset_id}, rule: ${rule_id}, expression: ${rule_expression})`)

Expand Down
45 changes: 45 additions & 0 deletions example/makeEdgeEvent.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// @ts-check
import { FingerprintServerApiClient, Region, RequestError } from '@fingerprint/node-sdk'
import { config } from 'dotenv'
config()

const apiKey = process.env.API_KEY
const envRegion = process.env.REGION

if (!apiKey) {
console.error('API key not defined')
process.exit(1)
}

/** @type {Region} */
let region = Region.Global
if (envRegion === 'eu') {
region = Region.EU
} else if (envRegion === 'ap') {
region = Region.AP
}

const client = new FingerprintServerApiClient({ region, apiKey })

try {
const event = await client.makeEdgeEvent({
method: 'GET',
url: 'https://example.com/login',
ipv4_address: '34.162.244.71',
headers: [
{ name: 'Host', value: 'example.com' },
{ name: 'User-Agent', value: 'Mozilla/5.0' },
{ name: 'Authorization', value: '' },
],
})
console.log(JSON.stringify(event, null, 2))
} catch (error) {
if (error instanceof RequestError) {
console.log(`error ${error.statusCode}: `, error.message)
// You can also access the raw response
console.log(error.response.statusText)
} else {
console.log('unknown error: ', error)
}
process.exit(1)
}
15 changes: 15 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,21 @@ client
.then((events) => {
console.log(events)
})

// Collect Automation Intelligence for a request intercepted at the edge
client
.makeEdgeEvent({
method: 'GET',
Comment on lines +111 to +114
url: 'https://example.com/login',
ipv4_address: '34.162.244.71',
headers: [
{ name: 'Host', value: 'example.com' },
{ name: 'User-Agent', value: 'Mozilla/5.0' },
],
})
.then((event) => {
console.log(event.event_id, event.bot_info)
})
```

See the [Examples](https://github.com/fingerprintjs/node-sdk/tree/main/example) folder for more detailed examples.
Expand Down
Loading
Loading