Google Static Map API - Exceed usage limit detection - google-maps

According to the documentation requesting a map from Google (via the Static Map API) when you have exceeded the usage limit displays an 'error' image. This is okay I guess but what I really want to do is detect the error so I can log something meaningful and alert the team.
Does anybody know if anything is returned in the RequestHeader to confirm this error. I can see from the documentation there is an 'X-Staticmap-API-Warning' key but its unclear if this is populated in this case.
Of course we'll be monitoring the usage via the Developer Console, but it would be good if we didn't have to rely on our customers reporting a problem should we see a spike.
Thanks in advance...

The HTTP-status of the image will be 403 when you see the error-image.
But that wouldn't help you much, because an <img/> doesn't have a property which gives you the HTTP-status.
Possible solution(works when the static map does have a size different to 100x100 ):
The error-image does have a size of 100x100, observe the onload-event and when the naturalWidth and naturalHeight is 100, do something:
<img src="staticmapurl"
onload="if(this.naturalWidth==this.naturalHeight==100){/*do something*/}"
/>
But note: there is also a quota for users, when google returns the error-image it must not be related to the quota of your project

Related

Autodesk Construction Cloud API

According to the autodeskissue.pngautodeskissue.png is from the ‘https://forge.autodesk.com/en/docs/acc/v1/reference/http/issues-issue-types-GET/’, as the photo shown there is ‘subtypes’ data in the response, but my response come from ‘my.png’my.png, there is no ‘subtypes’, so I wondering the issue is it still in beta mode, or is it I doing wrong?
To get subtypes, you need to add the query parameters include=subtypes. e.g.
https://developer.api.autodesk.com/construction/issues/v1/projects/:projectId/issue-types?include=subtypes

WebRTC getUserMedia deviceId constraint is not supported

I am trying to get device Id from user by using WebRTC API navigator.mediaDevices.getUserMedia. But the function throws an OverconstrainedError which has constraint property inside says deviceId. This means something was wrong with the deviceId.
However, I don't see any reason for browser to can't get device ID. Actually I haven't experienced this issue before.
Do you have any idea what would be the reason? Would it be because of the camera or is it all about the browser?
Not exactly sure what you are passing as contraints to the gUM but if you look at this code on github ( https://webrtc.github.io/samples/src/content/devices/input-output/ ), it provides a good example of toggling various media inputs and you can see in the source (or step through the code in the debugger) what the constraints are set to and how they get the deviceId - note this is not my code but is part of the webRTC samples.

Logging service allowing simple <img/> interface

I'm looking to do some dead-simple logging from a web app (client-side) to some remote service/endpoint. Sure, I could roll my own, but for the purpose of this task, let's assume I want an existing service like Logentries/Splunk/Logstash so that my viewers can still log debugging info if my backend goes down.
Most logging services offer an API where I can import some <script/> onto my page and then use an API like LE.log('string', data); [Logentries example]. However that pulls in a JS dependency and uses cross-domain XHR for probably well-founded reasons (like URI length limitations).
My question is if anyone can point me to a service that will let me send simple query params to a "pixel" endpoint (similar to how Google Analytics does it). Something like:
<script>
new Image().src = 'http://something.io/pixel/log/<API_TOKEN>?some_data=1234';
</script>
-- or, in pure HTML --
<img src="http://something.io/pixel/log/<API_TOKEN>?some_data=1234" style="display:none" />
I'd assume some of the big names in the logging-as-a-service space would have something like this but I've not found anything (or it's too specific to turn up any search results).
This would not be for analytics so much as error logging, debugging, etc. Fire-and-forget sort of stuff.
Any advice appreciated.
It's possible to do this with Logentries, they offer a pixel tracker.
They require that data is sent in a base64 encoding, but that's quite simple in Javascript.
From their documentation:
var encoded = encodeURIComponent(btoa("Log message"));
This data can then be used in a pixel tracker like this:
<img src="https://js.logentries.com/v1/logs/{API-TOKEN}?e={ENCODED_DATA}/">

How to know each TAB data usage in Chrome?

Is it possible to know the data/bandwidth usage of each tab opened ?. Is there any API for this ?.
I want to make a chrome extension based on this. Any pointers would be helpful.
What I exactly want to do is:
Show a small counter beside the tab name/page title.
The counter should update itself every 5-10 seconds.
It should show the amount of data/bandwidth consumed by the tab.
chrome://net-internals/#export.
This shows the overall bandwidth usage once the event starts ? Can I get this tab wise ?. Any API for this ?.
Is this possible in Chrome ?. I found this in Firefox as an add-on(tab-data).
Link: https://addons.mozilla.org/en-us/firefox/addon/tab-data/
Chrome API says that you can use chrome.processes.getProcessIdForTab(integer tabId, function callback) to get the process id of the tab, and then getProcessInfo − chrome.processes.getProcessInfo(integer or array of integer processIds, boolean includeMemory, function callback) to get the memory usage and other stuff.
Look at the link for more detailed info
Here there's a question on this topic: Programmatically get memory usage in Chrome

AWS S3 returns 403 intermittently even for valid resources

I store thumbnail profile pictures of users on S3 and I need to show several (~10) profile pictures at the same time. However the request throws a 403 for about a few of those images. When I retry it errors on some other images. The images shown/not shown are never consistent. What could be the reason for this? Is there a cap on the number of requests and if there is, what would be the best practice in this case?
403 Status code is Forbidden. You will get this code if you try to access a file that has not been set to public without access keys. You may also get this code if the file is owned by another user and you dont have permission to access it.