Use Application Insights to view all REST API requests per user - asp.net-web-api

We are developing a WebApi2 application. Users can use the REST API using their specific API key. I am investigating how to setup Application Insights to be able to see the usage of the REST API endpoints per user.
I have been experimenting with using telemetryclient.TrackPageview(endpoint-ID) and telemetryclient.TrackEvent(endpoint-ID), but I am not sure if this is the right way to go. And how should I pass the user-ID (API-key) in the tracking call? As telemetryclient.Context.User.Id? Or using properties or some other way? I would like to be able to use the user-ID to aggregate/segment the pageviews/events that were registered for that particular user. Any ideas are welcome!

I'd suggest using the built in properties, like context.user.id whenever possible, and then custom properties after that.
Currently in the portal, from the search view you can then find an item for any user, then use the "related items" to view "all telemetry for this user" to see all of the items.
Then can use the App Analytics portal to do queries (click the "analytics" button toolbar in the overview blade for your resource azure portal to go to the AA site for that resource), and that service lets you write much richer queries.
in those queries, it's easiest to group/filter on the "built in" properties, for custom properties you have to write a little bit more complicated queries to parse the values out of custom code.

Related

Google Analytics Report Integration with java application

I have a java application where users with different roles logged in and perform various activities. I am tracking each user with their useid and Roles and creating custom reports in Google analytics through GTM. In reports i am displaying which user with what roles logged in how many times which date visited etc.I GA i created custom reports which gives charts and table.Charts which GA is giving is as below.
In my java spring application in admin section i want to display the above graph. Please suggest me the steps and action i need to follow to integrate GA reports graph to my java application.
Regards,
Prabhash Mishra
GA4 has a reporting API You can use that to pull the data. It may be quite uncomfortable to pull the data via it, so there's another option. You can seamlessly export your data to BQ then ETL it from there using some public libraries for working with BQ.
Going the BQ route will result in way easier debugging since you'd see how the data really looks like directly in BQ.

REST API design for keyword based query

I am trying to architect a REST API design to give the best results to users based on keywords. User will have the option to select keywords (Like 'new', 'top rated', 'open now') and the REST API shall return the best result sets based on the selected keyword.
This is somewhat similar to how Google Maps is implemented. (See the image in the link below for reference) - User can select 'Open now' and 'Top rated', and Google shows the top rated stores that are open.
https://www.reddit.com/r/GoogleMaps/comments/j07cf1/does_anyone_else_find_the_google_maps_search/
I am using Spring as our backend framework and I am lost and not sure where to start. I believe the SQL query should be constructed based on selected user keywords but not sure if this is the right way to do it.
Can anyone familiar with this subject share some ideas on this?
you could use spring boot backed micro services to perform this. you may want to have an api business services (REST endpoint) that interacts with your client and then a core service (REST endpoint) to interact with your DB
You can take the benefit of framework like graphql etc.

Enable / disable functionalities for users on Ms Teams custom App

I'm planning to build a custom application for Ms Teams and I wanted the app to have an 'Administration' context, reserved for some users, with charts and records management that the rest of the users wouldn't be able to see. Is there a way to accomplish this?
Is it possible to hide tabs depending on a user profile? Is there another way to accomplish this on teams?
Tks
Inside your tab you can do whatever you want - it's just a custom web app/page. The only "restriction" aside from a normal web app, is that it must implement the Teams javascript library - see here for more. However, once you've implemented that library, you can get the Teams context, which includes the user's Azure AD Id and also UPN, and you could use one or both of those to do a lookup against your database, determine the user's role, and show/hide UI elements accordingly.
However, I think you might be asking about whether the entire Tab -itself- (i.e. even the tab item inside the Teams client) can be hidden from other users. To do this, an option is to use a "private channel", just for the relevant users, and pin the tab inside there only.

Add cart functionality to API or to Client?

I am creating an e-commerce API using the Django Rest Framework. The API will handle the following areas:
Databases
User Registration
Permissions
Orders/Payments
There's still one area in which I'm not quite sure how to implement in my project. It's the cart functionality. Would it be better to implement it on the client-side (ex: React/Ember) or on the server-side (i.e. API)?
One scenario that confused me is if the user is logged in in different platforms (ex: Website and mobile app). I want the user to have the same cart on mulitple platforms.
In that particular use case, if you want cart persistence then it must be backend. The reason for this is one being able to have a single source of truth. The phone app and the web app cannot talk to each other unless they have some sort of "common ground" between them.
That's where the API comes in. It will allow both ends to speak to each other by having the API as the single source of truth. See my terrible diagram for a visual.

integrating third party application with Dynamics CRM

I'm trying to integrate third party application with the dynamics CRM.
Authenticate the Dynamics User > Importing all the users data into third party application is my target.
But I'm unable to find the proper way to do this. I have gone through the developer docs but didn't find the solution. Can anyone please help me with this ?
Thanks for the clarification. You can get the Web API URL from Settings > Customization > Developer Resources > Instance Web API.
It will be something like:
https://myOrg.api.crm.dynamics.com/api/data/v9.1/
Using that URL you can query the system and get JSON results.
Going to the root URL will give you the collection name (a.k.a. EntitySetName) of all the entities in the system (which for users is systemusers).
Generally the EntitySetName will be the plural of the entity (i.e. just add 's'), but there are some quirky rules for making plurals so its best to confirm the entity set name via the API or a tool like XrmToolbox's Metadata Browser.
The most basic query for users would be:
https://myOrg.api.crm.dynamics.com/api/data/v9.1/systemusers
It will return all fields of all users.
To get a set of fields:
https://myOrg.api.crm.dynamics.com/api/data/v9.1/systemusers?$select=salutation,fullname,jobtitle,createdon,internalemailaddress
To add a couple filters:
https://myOrg.api.crm.dynamics.com/api/data/v9.1/systemusers?$select=salutation,fullname,jobtitle,createdon,internalemailaddress&$filter=isdisabled%20eq%20false%20and%20address1_line1%20ne%20null
Of course you have to do this with Java's XmlHttpRequest. When querying data you can use HTTP GET.
To test the above queries quickly you can simply login to the D365 web client then paste a query into the browser's address bar.
You may also want to check out Jason Lattimer's CRMRESTBuilder. While it doesn't build Java, it gives you a UI to create JavaScript XmlHttpRequests, which you can then translate to Java.
And here's some Microsoft documentation on querying the Web API.

Resources