Is it possible to add a new tag to all current registrations efficiently? - azure

I currently have 160k active registered devices on my notification hub. Each one has a set of tags. I have added a new feature in my application and the user can turn notification on/off for this feature. We currently manage the on/off state by registering a tag. We would like to deploy this feature with everyone on by default, which means we would need to add this tag to every registration. Is it possible to do this efficiently? My current solution is taking way too long:
var result = await HubClient.GetAllRegistrationsAsync(currentToken, 100);
foreach(var r in result)
{
//get installationId from tags
var id = ...;
var installation = await HubClient.GetInstallationAsync(id);
installation.Tags.Add("newtag");
await HubClient.CreateOrUpdateInstallationAsync(installation);
}
This is taking way too long and even resulting in QuotaExceededExceptions. Is there a more efficient way of doing this? Is it possible to avoid the GetInstallationAsync call? Possibly getting all Installations directly, instead of going through the Registrations? How about updating the tags through the Registration without going through the Installation?

The short answer to your question is "no".
Does your app register its push token each time the user starts a session? If so maybe the best approach is to add the tag when each user launches the new version of the app for the first time.
Do you also have a server that keeps track of all the push registrations and user preferences? You could also update your table of all the user preferences with the new default setting, if the new feature does not depend on the user having the latest build of the mobile app.

Related

How to confirm cleverTap event push

I am using this below code inside my app, but I am not sure if the events are being pushed to my dashboard and I am not even seeing any error, how to debug clever tap events
var clevertap = {event:[], profile:[], account:[], onUserLogin:[], notifications:[], privacy:[]};
// replace with the CLEVERTAP_ACCOUNT_ID with the actual ACCOUNT ID value from your Dashboard -> Settings page
clevertap.account.push({"id": "CLEVERTAP_ACCOUNT_ID"});
clevertap.privacy.push({optOut: false}); //set the flag to true, if the user of the device opts out of sharing their data
clevertap.privacy.push({useIP: false}); //set the flag to true, if the user agrees to share their IP data
(function () {
var wzrk = document.createElement('script');
wzrk.type = 'text/javascript';
wzrk.async = true;
wzrk.src = ('https:' == document.location.protocol ? 'https://d2r1yp2w7bby2u.cloudfront.net' : 'http://static.clevertap.com') + '/js/a.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wzrk, s);
})();
I know it is a bit late, but here is my answer :
When I integrated clevertap SDK, I used to point the app to the test clevertap account and test and validate the events there. The only challenge is that you have to find your profile on the dashboard. That should be easy once you know the clevertap ID OR the profile identity(if you are setting one)by looking at the debug console using ADB(for android)
Sending events is one thing, but the actual use of that data will be by the people who analyse in on the clevertap dashboard. Therefore, this method will help you understand
How people will see that event/data on the dashboard.
If profiles have been merged incorrectly (in case of multiple users)
If there are any issues with receiving events on the clevertap side
If the event names and parameters re being received on the dashboard and are correct.
More importantly, another team member (even one who is not a developer) can help you validate events(Step 4) without him having to setup anything on his/her laptop and installing a debug build. He can just look it up on the clevertap dashboard by firing events from an app that points to the clevertap TEST account!
Apart from this, I recommend using test account for testing events. This is because it helps you keep test data separate from production data and you can completely clear TEST account from the dashboard in case the data becomes too much of a mess.
In cleverTap if the events are pushed successfully then you will get it notified in the clevertap dashboard. Segments -> Find People -> By Identity(enter the identity) -> In the profile under Activity you can see all the events that are tracked in cleveTap dashboard,so in this we can confirm.

How do I provide real time update in nodejs?

I am working on an e-commerce site. There are times where a product would no longer be available but the user would have added it to the cart or added to their saved items. How do I implement the feature such that if the product has been updated, the user would be notified as soon as possible?
I thought about doing a cron job that would check the status of the product if it still available or has been recently updated. But I do not know if that is feasible. I am open to better ideas
Thanks
Similar images are included below
What you are trying to achieve falls into real-time updates category and technically there would be more than one option to achieve this.
The chosen solution would depend on your application architecture and requirements. Meanwhile, I can suggest looking into Ably SDK for Node.js which can offer a good starter.
Here down a sample implementation where on the back-end you will be publishing messages upon item's stock reaching its limit:
// create client
var client = new Ably.Realtime('your-api-key');
// get appropriate channel
var channel = client.channels.get('product');
// publish a named (may be the product type in your case) message (you can set the quantity as the message payload
channel.publish('some-product-type', 0);
On the subscriber side, which would be your web client, you can subscribe to messages and update your UI accordingly:
// create client using same API key
var client = new Ably.Realtime('your-api-key');
// get product channel
var channel = client.channels.get('product');
// subscribe to messages and update your UI
channel.subscribe(function (message) {
const productName = message.name;
const updatedQuantity = message.data;
// update your UI or perform whatever action
});
Did a live betting app once and of course live updates are the most important part.
I suggest taking a look into websockets. The idea is pretty straight forward. On backend you emit an event let's say itemGotDisabled and on frontend you just connect to your websocket and listen to events.
You can create a custom component that will handle the logic related to webscoket events in order to have a cleaner and more organized code an you can do any type of logic you want to updated to component as easy as yourFEWebsocketInstance.onmessage = (event) => {}.
Of course it's not the only way and I am sure there are packages that implements this in an even more easy to understand and straight forward way.

Is there an anonymous ID in Actions on Google with Dialogflow?

Is there an anonymous ID in Actions on Google with Dialogflow that I can access using DialogFlow in Node.js?
I don't need to know the Google account of who is using the Action, but I do want to have a unique identifier so that the Action can know when they come back.
Google no longer provides one for you. You will have to generate one when a new user interacts with your webhook and store the generated id in their user storage object.
To identify a new user your just check if they already have an id in their user storage object. For generating the id you can use an library like uuid. https://www.npmjs.com/package/uuid
Uuidv4 is probably the one that you need if you just need a unique id for simple identifications
The original idea from Google was to leverage a field called userStorage, but this feature seems to be borked ATM.
userStorage Documentation:
https://developers.google.com/actions/assistant/save-data
Reddit thread regarding issues:
https://www.reddit.com/r/GoogleAssistantDev/comments/d88z7e/userstorage_saga_continued/
Unless something has changed (I haven't checked on userStorage since I've been busy writing a fix around it) you may be out of luck without Account Linking. Feel free to try userStorage and keep me honest as they may have remedied the situation internally.
Alternatively, if all you need is an identifier or session for a single conversation you can leverage the conversationId which will be unique until the conversation ends.
I've found a possible option...
(When working in DialogFlow in Node.js, most code is in a handler and the parameter is usually called conv. The following assumes that it is inside such a handler.)
On every single call, check for an 'existing' id in the session data and the user storage:
var id = conv.data.MyId || conv.user.storage.MyId || '';
if(!id) {
id = /* make a new Id for this user... a GUID or some other unique id */
conv.user.storage.MyId = id;
}
Once I get the Id from storage or make a new one, it is critical to reassign it to conv.data, since conv.user.storage seems to be reliably provided only on the first call!
// IMPORTANT
conv.data.MyId = id;
/* use the Id as needed */
My code looks up the Id in a firebase database to get details from their last visit.
This seems to be working, but may not be reliable.

Google API SignIn HostedDomain cleanup problem

We implement the Sign-In on iOS using the Google API in our project. Customers must have a possibility to select the HostedDomain to limit the allowed account pull to the single domain.
SignIn.SharedInstance.HostedDomain = "domainName.com";
works perfectly.
The problem is when we want to Logout the user and log in it back with unrestricted HostedDomain
SignIn.SharedInstance.HostedDomain == null; // <-Default Value
When I try to set it to
SignIn.SharedInstance.HostedDomain=string.empty;
I filter everything.
When I try to set it to null
SignIn.SharedInstance.HostedDomain=null;
I get the exception.
Calling:
SignIn.SharedInstance.Dispose();
doesn't help.
The question is: How is possible to reset the HostedDomain filtering to the initial stage - allow everything without of the app restart.
Our implementation based on Xamarin iOS native, but we see the same problem in Swift or Objective-C.
The wrapper for the Gooogle SDK we use:
Xamarin.Google.iOS.SignIn

Chrome extension - Notification

How I can send a notification for everyone that has installed my extension?
I'm using new Notification(...) but the notification is just sending for me.
Thank you for all
You will want to use the new gcm service for Push Notifications via Google Cloud Messaging Service.
Here is a tutorial on Google's Chrome Developer page.
Well, this requires a lot of work already done in the extension to be able to do that without updating the extension.
For instance, your extension can periodically look for new notices on your website.
If you need more urgency, you either need to keep WebSocket connections to your server or use some manner of push services, like gcm API that Max Worg just mentioned.
That said, to use all this you need to have the support already in place in your extension.
Okay, but suppose you don't have that support, or don't need it that often.
The usual way to do it is with an extension update, where you add a message for the users and increment a variable with the "release notes" version, so that it will only be shown once. A good idea is to use chrome.storage.sync for this, so that the user won't be annoyed multiple times.
var message = "Sup user, check this out!";
var message_version = 4; // Update this when you want to show a new one
chrome.storage.sync.get(
{message_version: 0}, // Provide default
function(data) {
if(data.message_version < message_version) {
notify(message); // TODO: implement notify()
// Alternatively, open a page with the notice with chrome.tabs.create()
chrome.storage.sync.set({message_version: message_version});
}
}
);
You can see a real-life example here (using a hybrid of localStorage and chrome.storage).

Resources