Skip to content

Commit

Permalink
Merge pull request #126 from radarlabs/track-verified-updates
Browse files Browse the repository at this point in the history
Track verified updates
  • Loading branch information
nickpatrick authored Sep 19, 2023
2 parents cac786a + e3c9cc7 commit 0c2cf27
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 6 deletions.
6 changes: 6 additions & 0 deletions demo/views/track-verified.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@
console.log(user);
console.log(events);
if (!location) {
$('#map').hide();
$('#response-details').hide();
return;
}
$('#map').show();
if (!map) {
map = Radar.ui.map({
Expand Down
4 changes: 2 additions & 2 deletions 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.1.7",
"version": "4.1.8",
"description": "Web Javascript SDK for Radar, location infrastructure for mobile and web apps.",
"homepage": "https://radar.com",
"type": "module",
Expand Down
5 changes: 4 additions & 1 deletion src/api/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,14 @@ class VerifyAPI {
encrypted,
};

let userAgent = navigator.userAgent;
const windows = userAgent && userAgent.toLowerCase().includes('windows');

const response: any = await Http.request({
method: 'GET',
path: 'verify',
data: body,
host: 'https://radar-verify.com:52516',
host: windows ? 'http://localhost:52516' : 'https://radar-verify.com:52516',
});

const { user, events, token } = response;
Expand Down
2 changes: 1 addition & 1 deletion src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class RadarError extends Error {

constructor(message: string) {
super(message);
this.status = ''; // to be overridden (support for leagcy status)
this.status = ''; // to be overridden (support for legacy status)
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
RadarBadRequestError,
RadarDesktopAppError,
RadarForbiddenError,
RadarLocationError,
RadarLocationPermissionsError,
RadarNotFoundError,
RadarPaymentRequiredError,
RadarPublishableKeyError,
Expand Down Expand Up @@ -96,6 +98,15 @@ class Http {
return reject(new RadarServerError(response));
}

const error = response?.meta?.error;
if (error === 'ERROR_PERMISSIONS') {
return reject(new RadarLocationPermissionsError('Location permissions not granted.'));
} else if (error === 'ERROR_LOCATION') {
return reject(new RadarLocationError('Could not determine location.'));
} else if (error === 'ERROR_NETWORK') {
return reject(new RadarTimeoutError());
}

if (xhr.status == 200) {
return resolve(response);
}
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.1.7';
export default '4.1.8';

0 comments on commit 0c2cf27

Please sign in to comment.