-
Notifications
You must be signed in to change notification settings - Fork 4
Add geoip javascript client guide #87
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
Jest Coverage
|
Visit the preview URL for this PR (updated for commit c68a015): https://dev-maxmind-com--pr87-geoip-js-ns65qotw.web.app (expires Mon, 01 Feb 2021 21:42:21 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice work! 📝 Just a few comments to look at.
convenient, there are some caveats with its usage as some browser settings and | ||
add-ons (such as ad blockers) may prevent the GeoIP2 JavaScript API from | ||
successfully calling the web services, as well as unexpected usage spikes that | ||
you may want to monitor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a pretty long sentence. I think it can be broken up for clarity. Particularly it's not 100% clear how "as well as unexpected usage spikes that you may want to monitor." fits in. I think maybe it means:
While it is convenient, there are some caveats with its usage. Some browser settings and
add-ons (such as ad blockers) may prevent the GeoIP2 JavaScript API from
successfully calling the web services. Additionally, there may be unexpected usage spikes which
you may want to monitor.
Probably also worth noting why usage might spike.
In order to use this service, the following JavaScript must be included in your | ||
page. | ||
|
||
**Do not download this JavaScript file and load it from your server(s)!** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's clear to me why this shouldn't be done, but maybe a note to clarify what the consequences are.
|
||
| Option | Description | | ||
| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | | ||
| `geoip2.country(onSuccess, onError, options)` | Calls the GeoIP2 Precision: Country endpoint using the routable IP address associated with the machine on which it is running. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if the product names should be quoted or emphasized here. Having that colon in the description without additional context is a bit confusing.
|
||
All of the functions take the same 3 arguments: | ||
|
||
* If successful, this function calls the `onSuccess`. The first parameter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
calls the
onSuccess
.
It feels like a word is missing here.
Explorer 8, this is implemented as a non-enumerable property using | ||
`defineProperty`. | ||
|
||
* If there is an error, the function calls the `onError` with the error object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the function calls the
onError
This also feels like it has a word missing, but maybe I'm just not getting the JS lingo. I think it needs a trailing period?
|
||
* The optional `options` parameter is an object containing flags for the | ||
|
||
service. This parameter is reserved for future use. There are no options at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be a line break above?
|
||
```json | ||
{ | ||
"city": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spacing of this left curly brace is kind of odd.
|
||
```js | ||
// demo.js | ||
var fillInPage = (function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use two spaces to condense the indention a bit? We are using two spaces in the html block above this as well as in the json block below this.
|
||
```json | ||
{ | ||
"city": ..., |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a huge deal, perhaps more of a personal preference. Generally, I'm not a fan of aligning properties like this. It makes maintaining a little harder when the widest property changes.
| (none) | 406 Not Acceptable | Your request included an `Accept-Charset` header that is not supported. `UTF-8` is the only acceptable character set. | | ||
| (none) | 415 Unsupported Media Type | Your request included an `Accept` header that is not supported. The web service cannot return content of that type. | | ||
| (none) | 503 Service Not Available | There is a problem with the web service server. You can try this request again later. | | ||
| Code | HTTP Status | Error | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like we are going to end up having a table very similar to this on a lot of pages, with some variance based on 400 requests. We don't have to abstract this now, but it might be worth starting to think about it.
"names": {} | ||
}, | ||
"country": ..., | ||
"continent": ..., |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General style question. For the ellipses that are property values, should we encase them in an enclosure that can identify their type?
Examples: "..."
, [...]
, {...}
.
var fillInPage = (function() { | ||
var updateCityText = function(geoipResponse) { | ||
|
||
/* It's possible that we won't have any names for this city. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super nitpicky, but examples of most multiline comments in popular styleguides typically utilize a linebreak after the opening /*
and a *
on each additional line.
Some reasoning from Google – "subsequent lines must start with * aligned with the * on the previous line, to make comments obvious with no extra context."
updateCityText(geoipResponse); | ||
}; | ||
|
||
/* If we get an error we will display an error message*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can change this to a //
comment since it is a single line. If not, then a space needs to be added between message
and the closing */
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
No description provided.