Retrieving single page with slug in apostrophe-headless - apostrophe

I have been working with apostrophe-headless for a while and have worked around the issues of not being able to request pages via the RESTAPI by slug in the past. I am about to start a new installation and I want the users to be able to create new pages of various types and edit with the convenience that the standard page type allows within apostrophe-cms. That being said, any attempt that I make to set up a filter or change the cursor of apostrophe-pages to allow for slug filtering fails and I have yet to be able to request a page by anything other than _id. I have seen mentions that a page should not be requested by slug, but from an isomorphic react-based app I won't have an _id when a user goes directly to a child page. Any suggestions or help would be greatly appreciated.

Related

Azure - App Insights - how to track the logged-in Username in Auth Id?

What is the best-supported approach for tracking logged-in Usernames/Ids in App Insights telemetry?
A User with Username "JonTester1" said some Pages he visited 4 hours ago were really slow. How can I see everything JonTester1 did in App Insights to trouble shoot/know which pages he's referring to?
Seems like User Id in App Insights is some Azure-generated anonymized thing like u7gbh that Azure ties to its own idea of the same user (thru cookie?). It doesn't know about our app's usernames at all.
I've also seen a separate field in App Insights called Auth Id (or user_AuthenticatedId in some spots), which looks to sometimes have the actual username e.g. "JonTester1" filled in - but not always... And while I don't see any mention of this field in the docs, it seems promising. How is our app's code/config supposed to be setting that Auth Id to make sure every App Insights log/telemetry has it set?
Relevant MS docs:
https://learn.microsoft.com/en-us/azure/azure-monitor/app/usage-send-user-context
This looks to just copy one library Telemetry object's User Id into another... no mention of our custom, helpful Username/Id anyway... and most in-the-wild examples I see don't actually look like this, including MS docs own examples in the 3rd link below; they instead hardcode get a new TelemetryClient()
https://learn.microsoft.com/en-us/azure/azure-monitor/app/website-monitoring No mention of consistently tracking a custom Username/Id
https://learn.microsoft.com/en-us/azure/azure-monitor/app/api-custom-events-metrics#authenticated-users Shows some different helpful pieces, but still no full example. E.g. it says with only the setAuth... JS function call (still no full example of working client-side JS that tracks User) on the page, you don't need any server-side code for it to track custom User Id across both client-side and server-side telemetry sent to Azure... yet then it also shows explicit code to new up a TelemetryClient() server-side to track User Id (in the Global.asax.cs or where?)... so you do need both?
Similar SO questions, but don't connect the dots/show a full solution:
Azure Insights telemetry not showing Auth ID on all transactions
Application Insights - Tracking user and session across schemas
How is Application insight tracking the User_Id?
Display user ID in the metrics of application Insight
I'm hoping this question and answers can get this more ironed out; hopefully do a better job of documentation than the relevant MS docs...
The first link in your question lists the answer. What it does show you is how to write a custom telemetry initializer. Such an initializer lets you add or overwrite properties that will be send along any telemetry that is being send to App Insights.
Once you add it to the configuration, either in code or the config file (see the docs mentioned earlier in the answer) it will do its work without you needing to create special instances of TelemetryClient. That is why this text of you does not make sense to me:
[…] and most in-the-wild examples I see don't actually look like this, including MS docs own examples in the 3rd link below; they instead hardcode get a new TelemetryClient()
You can either overwrite the value of UserId or overwrite AuthenticatedUserId in your initializer. You can modify the code given in the docs like this:
if (requestTelemetry != null && !string.IsNullOrEmpty(requestTelemetry.Context.User.Id) &&
(string.IsNullOrEmpty(telemetry.Context.User.Id) || string.IsNullOrEmpty(telemetry.Context.Session.Id)))
{
// Set the user id on the Application Insights telemetry item.
telemetry.Context.User.AuthenticatedUserId = HttpContext.Current.User.Identity.Name;
}
You can then see the Auth Id and User Id by going to your AI resource -> Search and click an item. Make sure to press "Show All" first, otherwise the field is not displayed.
Auth Id in the screenshot below is set to the user id from the database in our example:
We access the server from azure functions as well so we set the user id server side as well since there is no client involved in such scenarios.
There is no harm in settting it in both places, javascript and server side via an initializer. That way you cover all scenario's.
You can also manually add user id to app insights by
appInsights.setAuthenticatedUserContext(userId);
See App Insights Authenticated users

Trying to create basic blog posts in Umbraco

I've been trying for hours now to add blog posts into our site through the Umbraco back office. It feels so unintuitive how everything works and I'm beginning to get very frustrated, here's what I'm trying to do/have done:
I create a document type, "BlogPost", it contains data that can be entered in a content node relating to the blog post, description, title, etc.
I create a document type, "BlogPage", as a document type to be used as a root content node, which will hold all the BlogPost content nodes, that way I can simply loop through them and render each one on our site
I go to create the BlogPost content node, and it assigns it an url of "/", which simply redirects to the home page
What I don't understand is how am I supposed to just get data that was entered in Umbraco for my view? We have an extremely stylized theme for our site, so I can't use things like Articulate, and I shouldn't have to, all I want to do is store a collection of blog posts together, pull that data from Umbraco, and load it into an ASP.NET view, but there is absolutely zero documentation or examples of how to do this online, I would be incredibly grateful if someone could point me in the right direction on how I should go about doing what I'm trying to do.
If I understand correctly you are developing a blog section on an existing website. First thing to do is inderdaad create a new documenttype for the blogpost itself and add a documenttype for the container of blogposts.
Did you create new templates for these documenttypes? You can find some documentation on templates here
Inside the template you'll want to query data from Umbraco. Information about querying data is available here
Next up is adding the newly created templates to the documenttypes and you're ready to create your content.
Make sure that for the content you create the template is set (see Properties tab), here you can also see the url Umbraco created for the content.
Did you start the Umbraco website from scratch or are you developing on an existing website? Because a blogpost should not redirect to / by default, unless it's the root node of your website. This sounds like custom functiality. Maybe a rewrite or error handling module?
Edit: Also some information on how to get started with templating in Umbraco is available here

Customizing redmine issue entry

Well, the powers that be would like Redmine to be aware of the data in one of our other systems so issues can be auto assigned to staff based on our business application's parcel id's.
Until now we had a call tracking system written from scratch. I'd like to bastardize Redmine since it comes so close to meeting all user requirements. I think if I get pointed in the right direction I can hook into Redmine some already written javascript and already existing webservices to pull the necessary data to display it on a Redmine ticket at the time of ticket creation. I know that Redmine is highly customizable, but I don't know where to begin. I already checked for existing plugins to do this and I found none.
Any help would be greatly appreciated.
I hope I understand what you want.
You can add custom_field or write a migration to add a new column to table issues and patch issue form (you can use redmine hooks http://www.redmine.org/projects/redmine/wiki/Hooks_List). I prefer second way because it does not depend on Redmine settings.
You should add in plugin a route and method into issues_controller. This action will get AJAX request with ParcelID from the view (issue form) and proxy it to external server. The response should be user email (I think only this info is common for users in Redmine and External server). The action should find appropriate user in Redmine and return user_id to the view.
Patch issue form: add new input Parcel ID and add JS code. JS code should send AJAX after ParcelID loses focus and setup Assignee if request returns user_id.
some notes:
I don't think that you will manage to communicate with external server directly (without controller) because Server can return own user_id or user_email but view will not manage to setup Assignee using this attributes.
I think it is necessary to care about performance because JS code will start at least two requests (View<->Redmine, Redmine<->External Server)
hope it helps you

Ruby on Rails Sessions for new users

We have some sharing elements of our application where we embed logging IDs into the URL's that we share out. When a user clicks that URL, we add a record to our database so we can hopefully follow them throughout the registration process. We've found that if you reset your browser and go to the link the first time, there is no session info from the controller. However, all subsequent requests then have the session. It's almost like it's getting created after the first request.
We attempted to log it via ajax on the view, but this is cumbersome in all the places we want.
Anyone know what sessions wouldn't be available in the controller on first access for a new uesr?
I think you might have code in the wrong order. You must have the session creation before any logic can my applied to it.
Hope this helps.

Associating source and search keywords with account creation

As a part of the signup process for my online application, I'm thinking of tracking the source and/or search keywords used to get to my site. This would allow me to see what advertising is working and from where with a somewhat finer grain than Google Analytics would.
I assume I could set some kind of cookie with this information when people get to my site, but I'm not sure how I would go about getting it. Is it even possible?
I'm using Rails, but a language-independent solution (or even just pointers to where to find this information) would be appreciated!
Your best bet IMO would be to use javascript to look for a cookie named "origReferrer" or something like that and if that cookie doesn't exist you should create one (with an expiry of ~24hours) and fill it with the current referrer.
That way you'll have preserved the original referrer all the way from your users first visit and when your users have completed whatever steps you want them to have completed (ie, account creation) you can read back that cookie on the server and do whatever parsing/analyzing you want.
Andy Brice explains the technique in his blog post Cookie tracking for profit and pleasure.

Resources