No sooner you initialize the client you can send transaction using the next method.

You have to pass as entry parameters the Transaction ID and the User ID.

client
    .sendTransaction(transactionID, userID)

And that is all. Every time the method is called it will send a transaction.

Full example

The following code is a very simple example to test the SDK

test.js

import { LBFraudSDK, LBFraudSDKEnvironment } from 'https://lbfraud-web-sdk.s3.eu-west-3.amazonaws.com/release/0.1.4/LBFraud-SDK-Web.modern.js';

const client = new LBFraudSDK({
  apiKey: 'api-key',
  environment: LBFraudSDKEnvironment.Testing
});

const myButton = document.getElementById('myButton');

function setListener() {
  
  myButton.onclick = function(){
    const transactionID = document.getElementById('transactionId').value;
    const userID = document.getElementById('userId').value;
    client
    .sendTransaction(transactionID, userID)
    .then((success) => {console.log(success)})
    .catch((errorMsg) => {
      console.log(errorMsg)
      });
  }
}

window.onload=function(){
  setListener()
}

index.html

<!DOCTYPE html>
<html>
  <head>
    <title>Web SDK test</title>
  </head>
  <body>
    <label for="transactionId">Transaction ID:</label>
    <input type="text" id="transactionId" name="transactionId">
    
    <label for="userId">User ID:</label>
    <input type="text" id="userId" name="userId">
    
    <button id="myButton">Send transaction</button>
    
    <script type="module" src="test.js"></script>
  </body>
</html>

Additional documentation

To properly use the SDK, it is necessary to activate the location permission.

In Safari if your browser doesn´t show the modal to allow it, it is necessary to activate it, for this follow the following steps:

  • On your Mac, choose Apple menu > System Settings, click Privacy & Safety in the sidebar, and click Location Services on the right.
    Metrics Fraud
  • Turn on Location Services for Safari in the list to the right.
    Metrics Fraud