I'm building some very basic analytics for in-house WinJS apps. Take this to mean that a 3rd-party analytics solution would both overkill and/or unworkable and/or against the 3rd-party providers terms of use as they generally disallow capturing personally identifiable information about the user, and in this case that is a business requirement.
The thing I'm trying to do is determine how much time is spent in multiple apps, and in areas within certain areas of the app. For this I obviously need to know when they enter and leave.
All the documentation I've found says to use the WinJS.Application.oncheckpoint event or the Windows.UI.WebUI.WebUIApplication.onsuspending event, which really seem to be two access points into the same basic concept. The problem is this doesn't accurately reflect when the user leaves the app! Suspend seems to happen only after the user has switched to another app, plus about 10 seconds ...... if the system feels like it.
If the user simply hits the Windows key to go out to the Start Screen and just sits there, the app continues to run indefinitely (calls to setInterval are able to affect state) even though the app cannot be seen!
I understand this is a bit of an edge case, but is there any more reliable way to tell when the user can't see the app, for lack of a better definition?
Notes:
I did look at the Cordova 2.7 code for Windows 8 and they are using the checkpoint event to drive the Cordova pause event.
App Visibility section on Application lifecycle seem to address this. This means registering for `msvisibilitychange' event, to know when user moved away and moved back to your app.
default.js:
document.addEventListener('msvisibilitychange', function ()
{
console.log('visibility changed');
console.log(document.visibilityState); // 'hidden' or 'visible'
});
In addition, suspending, resuming and activated events also needs to be handled.
default.js:
Windows.UI.WebUI.WebUIApplication.onsuspending = function ()
{
console.log('suspending');
}
Windows.UI.WebUI.WebUIApplication.onresuming= function ()
{
console.log('resuming');
}
Needless to say, that nuance of ordering, and/or event being absent cases needs to be handled. For example - if the user moves away and comes back quickly, visibilitychange event will be received. whereas if user does not come back suspending event may come after some time. if the app is not terminated, it may be followed by resuming event. otherwise, activated event.
regards spending time on specific pages, page ready and unload method should work. unload() will not get called if the app is suspended or terminated.
https://developer.mozilla.org/en-US/docs/Web/Reference/Events/visibilitychange
Use the visibility change event to recognize when the user can no longer see the app.
Related
I have been using Firebase Analytics for my apps and I like it.
Currently I have 300 events set up on one of my apps.
I learned that the max number of events we can have is 500.
What would happen if # of events exceeds 500 on Firebase Analytics?
Would it just stop logging new event? (501st event)
Or is there any better way to avoid it?
I will appreciate your advice!
Extra events are dropped. A firebase_error event is logged with a firebase_error parameter which indicates the error code. See this documentation for more information.
There's no other way to avoid it, but to manage your event logging implementation properly. Note that event in Google Analytics for Firebase is equivalent to the user's interaction within your app.
I would not suggest to create or log an event with incremental index, prefix or suffix in the name. You may also want to use the event parameter.
For example, you have a login page (with authentication methods of using Facebook, Google or Username/Password) and you'd like to track what is the most commonly used by the users. With this, you could log a custom event with the name of "user_login" and a parameter or login_method. After this, add the parameter in the custom parameter reporting to see the counts.
Hope this helps :)
Just for clarification because this confused us and there is no clear documentation on this:
The 500 events limit is per user per day and not per project globally. So events are only dropped after a single user uses more than 500 unique events per day, everyone else will continue to log events.
So if you have more than 500 events thats fine, you dont need to replace them you just need to remove them from your current app from being logged and use new ones, then this user will never use the old events and it does not count towards his 500 event limit.
I have developed an web app using angular which connects with spotify and enables customers in my bar to add songs to the current playlist.
To do so I am calling the spotify API to get the current track, where i start a timeout using the time left of the currently playing song. Once this ends, I call the method again, as well as calling a request to get the playlist.
Currently using this method, it will make a few requests every few minutes.
To make it more accurate and update more readily, I want to make this timeout every ten seconds.Is this bad practice, and will it slow the app down or is this recommended?
if it is requesting more than one every time probably you need to make a little research about bubbling.
Shortly; probably your method is connected to a button and when the user clicked it, button calls the method. And also somewhere in your code you calling that method again (probably in a parent form element). when you click on a button that is inside a form, you also click to that form too so it calls both methods of form and button. In your case both of the same function so your method runs two times.
I'm trying to use webhooks to get notifications for changes in a user's Box account. One thing I don't see is an option to get a webhook notification when an item is renamed. Is it possible to get a notification for rename? I see that RENAME is available via the event API, is it preferable to use the event API? I saw another stackoverflow question asking about webhook vs event (Box webhooks deprecated in favor of long polling?) and the answer said webhooks are still valid, but didn't really comment on webhook vs event.
I'd prefer webhooks since they are a close fit to how I get changes for Dropbox accounts but it appears from the docs that event has more information/options. Also, it seems it's possible to miss a Box webhook notification which could create an inconsistent state between Box the model in my application.
Which to choose?
Many thanks!
I don't believe it's possible to get a WebHook notification when an item is renamed.
The choice between WebHooks and events really depends on what you're building. WebHooks are generally easier to use, but the events stream can give you more power. In your case, you'll probably need to use events so you can be notified of a renames.
It's also worth noting that if your application really depends on staying in sync with the state of Box, you're better off using the events stream. It lets you specify a last known position in the stream so that you can catch up on any missed events if your application goes offline.
I would like to know what is the clean & correct way to notify my WP8 app that the ChannelUri has changed?
I read that i need to handle this in the ChannelUpdatedUri method. But i have a few queries here. Doesn't this require my app to be running all the time?
Second query is suppose i use ChannelUpdatedUri to listen for changes to the Uri. If there is a change will the app be notified as soon as it launches? Or will it be notified at a later time?
The trouble is if the app is not notified on launch then there is a possibility that it may re-register for a new channel uri before ChannelUpdatedUri is invoked. Isnt it?
Please help!
You'll only get notified of a change in the ChannelUri when you have the listener attached and the app running.
The best approach is to always check for the current Uri and pass it to the server when the app starts. You could leave the listener attached for the lifetime of your app and get a new one if it's lost while the app is running but in reality it's far more likely that the channel will be dropped/disconnected when the phone isn't in use.
There is, of course, the scenario where a channelUri may expire when the app isn't in use but the utility of the app is primarily around sending notifications. Obviously you need the user to restart the app to get a new connection but you can't tell them to restart the app.
This is a generic problem: how do you tell someone that you can't talk to them?
The reality of this situation is that if you really need to tell someone to launch the app again you'll need another way to do it.
Unfortunately, it's not possible to get an updated channelUri from a background agent, but you could query your backend to see if you need one and then raise a toast to the user to prompt them to reopen the app. Or you could just update the tile from the agent when this happens.
Alternatively you'll need to send them the prompt in another way (e.g. email or SMS?) but this is reliant on you capturing and securely storing these details.
There is no perfect solution to this scenario other than creating an app that the user opens regularly regardless of whether there are notifications or not and simply having the notifications as an extra feature.
As I am testing out one of the HTML5 features - geolocation for my project,
I realized that users can close the prompt without allowing or denying it,
that defeats the whole purpose of the prompt.
And because in my project I want to dynamically display data to users depending on user's location, this can't be done, simply because without knowing user's response,
it doesn't trigger any of the two callbacks - success / error.
so I started searching to see if there's any solution to this,
and a lot of suggestions to this is to set timeout,
I tried and everything works perfectly.
However, one small flaw here is tho, by the time it hits the timeout expiration,
all the data are already displayed, and when i say all, i mean EVERYTHING,
because there's no location detected.
So I came up with two solutions that might work,
1) create a custom geolocation prompt that forces users to allow/deny location to be shared,
and pass the response to browser to set the location preference
2) pause page-load (stop stuff from being rendered) and wait till it hits the timeout expiration or it gets response from users
Does anyone have any idea how to implement one of these two solutions?
PS: sorry if this isn't unclear to you, i know my english sucks, but I can explain in more details.
Thanks guys!
You shouldn't be able to use a custom Geolocation prompt if your project is browser based, because malicious developers could use the method to trick the user. Also, since the Geolocation API is an asynchronous event, it's going to continue loading the rest of the page while it waits.
What I recommend is to use a conditional statement instead with an else clause. This way, your script functions should only execute after location has been shared, and you have a fall back on what should happen if no geolocation information is provided (which I highly recommend as situations will occur when the data isn't provided).
Example of the conditional statement to check for geolocation information using JS:
if (navigator.geolocation) {
// code to run if there is geolocation information
}
else{
// code to run if no geolocation info is given to the browser
}