Developer forum

Forum » Feature requests » Add download criteria to smart search

Add download criteria to smart search

Manon Wekking
Reply

Hey,

I've got a question from a customer who wants to see which of the users downloaded a specific file. This file is protected, not everyone can download is, so they want to keep an eye on what's happening with the file and by whom. I first tried to make a report, but I can see specific interactions and filter on specific interactions (like file download) but I can't map them to an user (I can however trace it to a session id, but I don't think there's a way to relate this to an user). Then I tried to create a smart search. In the smart search I can find all users who visited a certain page, and I can check if someone clicked on a specific link in an e-mail campaign, but I can't select an option for a specific link or download in the site. Would it be possible to add this to the list of interactions? Or perhaps there's another way I am unaware off and then I'll have to move this request.

Thanks in advance for the consideration.

Kind regards,

Manon Wekking


Replies

 
Nicolai Pedersen
Reply

I've added this as a feature request.

Until then you can create a custom field on the user, and set that to a value from a notification subscriber when the file is downloaded.

I.e. Dynamicweb.Notifications.Standard.Application.BeginRequest - check if the file is being downloaded and if the user is logged in - if so, add the information you need on the custom fields and they can be searched.

BR Nicolai

 

namespace Dynamicweb.Examples.CSharp.Notifications.Standard
{
    [Dynamicweb.Extensibility.Subscribe(Dynamicweb.Notifications.Standard.Application.BeginRequest)]
    public class ApplicationBeginRequestObserver : Dynamicweb.Extensibility.NotificationSubscriber
    {
        public override void OnNotify(string notification, Dynamicweb.Extensibility.NotificationArgs args)
        {
            if (args == null)
                return;

            if (!(args is Dynamicweb.Notifications.Standard.Application.BeginRequestArgs))
                return;

            Dynamicweb.Notifications.Standard.Application.BeginRequestArgs item = (Dynamicweb.Notifications.Standard.Application.BeginRequestArgs)args;
            System.Web.HttpApplication app = (System.Web.HttpApplication)item.sender;

            if (app.Context.Request.Cookies == null || app.Context.Request.Cookies.Count == 0)
                return;

            const string name = "my-custom-cookie";

            //Adding cookie
            System.Web.HttpCookie cookie = app.Context.Request.Cookies[name];
            if (cookie == null)
                app.Context.Response.Cookies.Add(new System.Web.HttpCookie(name, "hello!"));

        }
    }
}

 
Manon Wekking
Reply

Hey Nicolai,

I'm not a developer myself, I do some configuration and I can change some templating, but that's as far as my knowledge goes. So I could see if one of our developers could use this. I did try to understand the code though, but I am not really sure how this would work? In the code where would I tell it, it should watch the specific file (say for example the file is /Files/test.txt, where would I define it in the snippet?

Also you say I should add a custom field, but in the snippet I don't see you adding something to a field, I just see you add something to a cookie? Or is that the way a custom field gets filled?

Sorry for the perhaps stupid questions, just seeing if I understand correctly.

Thanks for your help so far!

Kind regards,

Manon