Comments (10)
You can either:
- clear the local storage, or
- call
Countly._internals.clearQueue()
or - use another app namespace, or
- wait for the queue to reach the limit and older requests will be removed
from countly-sdk-web.
Is there a way i can capture the error response inside the app. so that i can go ahead and clear the queue.
I don't want to clear the queue because i may loose logs from previous session.
from countly-sdk-web.
This is not something that is likely to happen in production, so no need to try to automate it (how many times you would change app_key in production)
and even if it did, if app_key changes then you can just deploy update using new namespace so it has clear storage.
or another workaround is to create another app in countly with incorrect app key that you had and let it consume the data
from countly-sdk-web.
If this ever does happen in production, you could really be in trouble.
Would it not make sense for the SDK to be robust enough to recognize this situation and deal with it gracefully? A 400 response indicates that the request that was made should not be repeated and be expected to succeed. However, by the status code alone, you won't know why. But if the server response would include some JSON saying why it failed, in this case a bad app key, shouldn't that be enough to invalidate all the events in the queue that carry that app key?
from countly-sdk-web.
We cannot make that assumption on behalf of clients
maybe they accidentally changed app_key and will change it back and don't want to lose queued data
If something is deleted it should be explicitly deleted by the client's actions, not SDK (at least those are the general guidelines)
from countly-sdk-web.
However I have another idea for a potential solution, but it is on more larger scale (changing the SDK development guide flow, meaning it should propagate to all SDKs not just web SDK) and can't figure out proper migration yet
but it would be something around having separate namespace storages based on app_key
so if app_key is different it has completely different new clean storage, and older app_key storage remains intact in case it will be used again.
from countly-sdk-web.
That would be idle.
I am reporting the problem because, we have faced this issue.
We have deployed the app with incorrect app key then realized the requests are failing with 400 because of incorrect app key.
Correcting the app key has no effect because sdk was trying to use old app key, in my case the queue is no emptied even after an hour.
from countly-sdk-web.
as I said, the current fix would be redeploying app with the new namespace for storage
http://countly.github.io/countly-sdk-web/Countly.html#.init
from countly-sdk-web.
Or if it is a completely new and clean app on Countly side, simply changing app_key to the one you used would also be an option
from countly-sdk-web.
I have also just spent a day trying to work out what was happening with this same issue. This was in development, but to find the answer I ended up having to debug Countly Code.
An improvement would be for sendXmlHttpRequest ->
xhr.onreadystatechange = function () {
if (this.readyState === 4 && this.status >= 200 && this.status < 300) {
if (typeof callback === 'function') { callback(false, params, this.responseText); }
} else if (this.readyState === 4) {
log("Failed Server XML HTTP request", this.status);
if (typeof callback === "function") { callback(true, params); }
}
};
To return this.status to the call back.
xhr.onreadystatechange = function () {
if (this.readyState === 4 && this.status >= 200 && this.status < 300) {
if (typeof callback === 'function') { callback(false, params, this.responseText); }
} else if (this.readyState === 4) {
log("Failed Server XML HTTP request", this.status);
if (typeof callback === "function") { callback(true, params,this.status); }
}
};
Then in the callback:
sendXmlHttpRequest(Countly.url + apiPath, params, function(err, params, response){
console.log("Request Finished", params, err, response);
if (err) {
if(response==400){
console.log("jhop Request failed, ignore it")
//remove first item from queue
requestQueue.shift();
} else {
failTimeout = getTimestamp() + failTimeoutAmount;
}
}
This means that if the server returns 400 (server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). Then the the rest of the messages are not blocked and lost, due to something they are never likely to recover from. One incorrect message on the queue means the rest of the data is unrecoverable. the above approach means the rest of the data on the queue can be received.
You could also configure a setting to turn this feature off if that is required.
from countly-sdk-web.
Related Issues (20)
- Do you offer a notification service for web HOT 2
- Element is Not Defined With React Integrations HOT 1
- Countly installs a non-compliant polyfill for Element.closest HOT 8
- Lighthouse error "Registers an unload listener" from the tracking script HOT 1
- Pass user agent with all requests HOT 1
- [Security Issue] Semi-persistent DOM XSS HOT 2
- How to integrate this sdk with βAnt Design Proβ? HOT 2
- Bug: Countly doesn't correctly remove consent for custom groups. HOT 3
- version inconsistencies HOT 2
- It is not possible to cancel the timed event HOT 5
- Session duration issues HOT 2
- Shipping Countly In a WebWorker Context HOT 11
- Device ID not used for the queued queries when disabling offline mode HOT 1
- Can not work when the salt on Countly server is set HOT 5
- China map is displayed incorrectly HOT 1
- After using "opt_out" method, "opt_In" method does not work properly without reloading the browser screen. HOT 2
- send json string to countly HOT 2
- Source maps
- Uncaught TypeError: Converting circular structure to JSON HOT 4
- CORS issue with Next.js and countly-sdk-web HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from countly-sdk-web.