Skip to content

Commit

Permalink
Merge pull request #162 from radarlabs/track-once-callback
Browse files Browse the repository at this point in the history
fix return, bump version
  • Loading branch information
nickpatrick authored May 13, 2024
2 parents 0c2f659 + 985842f commit 27130c7
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 36 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Radar.initialize('prj_test_pk_...', { /* options */ });
Add the following script in your `html` file
```html
<script src="https://js.radar.com/v4.2.0/radar.min.js"></script>
<script src="https://js.radar.com/v4.2.1/radar.min.js"></script>
```

Then initialize the Radar SDK
Expand All @@ -73,8 +73,8 @@ To create a map, first initialize the Radar SDK with your publishable key. Then
```html
<html>
<head>
<link href="https://js.radar.com/v4.2.0/radar.css" rel="stylesheet">
<script src="https://js.radar.com/v4.2.0/radar.min.js"></script>
<link href="https://js.radar.com/v4.2.1/radar.css" rel="stylesheet">
<script src="https://js.radar.com/v4.2.1/radar.min.js"></script>
</head>

<body>
Expand All @@ -98,8 +98,8 @@ To create an autocomplete input, first initialize the Radar SDK with your publis
```html
<html>
<head>
<link href="https://js.radar.com/v4.2.0/radar.css" rel="stylesheet">
<script src="https://js.radar.com/v4.2.0/radar.min.js"></script>
<link href="https://js.radar.com/v4.2.1/radar.css" rel="stylesheet">
<script src="https://js.radar.com/v4.2.1/radar.min.js"></script>
</head>

<body>
Expand Down Expand Up @@ -130,8 +130,8 @@ To power [geofencing](https://radar.com/documentation/geofencing/overview) exper
```html
<html>
<head>
<link href="https://js.radar.com/v4.2.0/radar.css" rel="stylesheet">
<script src="https://js.radar.com/v4.2.0/radar.min.js"></script>
<link href="https://js.radar.com/v4.2.1/radar.css" rel="stylesheet">
<script src="https://js.radar.com/v4.2.1/radar.min.js"></script>
</head>

<body>
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "radar-sdk-js",
"version": "4.2.0",
"version": "4.2.1",
"description": "Web Javascript SDK for Radar, location infrastructure for mobile and web apps.",
"homepage": "https://radar.com",
"type": "module",
Expand Down
52 changes: 26 additions & 26 deletions src/api/track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ class TrackAPI {
}),
};

const token = await signJWT(payload, dk);
const reqToken = await signJWT(payload, dk);

response = await Http.request({
host,
method: 'POST',
path: 'track',
data: {
token,
token: reqToken,
},
headers: {
'X-Radar-Body-Is-Token': 'true',
Expand All @@ -160,33 +160,33 @@ class TrackAPI {
sclVal,
cslVal,
};
}

let { user, events, token, expiresAt } = response;
const location = { latitude, longitude, accuracy };
let passed;
let expiresIn;
if (expiresAt) {
expiresAt = new Date(expiresAt);
passed = user?.fraud?.passed && user?.country?.passed && user?.state?.passed;
expiresIn = (expiresAt.getTime() - Date.now()) / 1000;
}

const trackRes = {
user,
events,
location,
token,
expiresAt,
expiresIn,
passed,
} as RadarTrackVerifiedResponse;

if (options.debug) {
trackRes.response = response;
}
let { user, events, token, expiresAt } = response;
const location = { latitude, longitude, accuracy };
let passed;
let expiresIn;
if (expiresAt) {
expiresAt = new Date(expiresAt);
passed = user?.fraud?.passed && user?.country?.passed && user?.state?.passed;
expiresIn = (expiresAt.getTime() - Date.now()) / 1000;
}

return trackRes;
const trackRes = {
user,
events,
location,
token,
expiresAt,
expiresIn,
passed,
} as RadarTrackVerifiedResponse;

if (options.debug) {
trackRes.response = response;
}

return trackRes;
}

response = await Http.request({
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default '4.2.0';
export default '4.2.1';

0 comments on commit 27130c7

Please sign in to comment.