diff --git a/demo/views/track-verified.hbs b/demo/views/track-verified.hbs index 25bb53ec..e59bbcfb 100644 --- a/demo/views/track-verified.hbs +++ b/demo/views/track-verified.hbs @@ -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({ diff --git a/package-lock.json b/package-lock.json index ae31ac4f..c2a469db 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "radar-sdk-js", - "version": "4.1.7", + "version": "4.1.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "radar-sdk-js", - "version": "4.1.5-beta.0", + "version": "4.1.8", "license": "ISC", "dependencies": { "@types/geojson": "^7946.0.10" diff --git a/package.json b/package.json index fa999832..9867dbd9 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/api/verify.ts b/src/api/verify.ts index 2096f8ad..34ff6bee 100644 --- a/src/api/verify.ts +++ b/src/api/verify.ts @@ -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; diff --git a/src/errors.ts b/src/errors.ts index a627f53d..878db152 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -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) } } diff --git a/src/http.ts b/src/http.ts index 35b20a80..2848a271 100644 --- a/src/http.ts +++ b/src/http.ts @@ -6,6 +6,8 @@ import { RadarBadRequestError, RadarDesktopAppError, RadarForbiddenError, + RadarLocationError, + RadarLocationPermissionsError, RadarNotFoundError, RadarPaymentRequiredError, RadarPublishableKeyError, @@ -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); } diff --git a/src/version.ts b/src/version.ts index 478dd8b8..ce743592 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export default '4.1.7'; +export default '4.1.8';