как собирать информацию о сайтах для анонимных - PullRequest
0 голосов
/ 29 ноября 2018

Мне нужно получить информацию о ядре сайта, полученную от анонимных пользователей, чтобы он мог ее экспортировать или отказаться - [GDPR]

любая идея об идентификаторе контакта для анонимного пользователя!

Ответы [ 2 ]

0 голосов
/ 02 декабря 2018

Способ сделать это зависит от версии sitecore.

Относительно анонимного пользователя - если пользователь действительно анонимный, то вам действительно нужно беспокоиться о GDPR (мой взгляд).Но иногда мы сопоставляем электронную почту пользователя и конфиденциальную личную информацию с анонимным пользователем, используя формы или WFFM.Вы можете использовать адрес электронной почты этого пользователя для запроса xDB ( идентификаторы контактов ), чтобы получить contact и contactID.Затем сбросьте информацию.

Также: обратите внимание, что на основе конфигурации действия сохранения WFFFM анонимный пользователь будет хранить в основной базе данных и списке контактов.

0 голосов
/ 29 ноября 2018

Чтобы забыть пользователя, вы можете использовать следующий код.Он выполнит функцию ExecuteRightToBeForgotten для контакта и очистит его данные.

Забудьте пользователя

public bool ForgetUser()
{
    var id = _contactIdentificationRepository.GetContactId();
    if (id == null)
    {
        return false;
    }

    var contactReference = new IdentifiedContactReference(id.Source, id.Identifier);

    using (var client = _contactIdentificationRepository.CreateContext())
    {
        var contact = client.Get(contactReference, new ContactExpandOptions());
        if (contact != null)
        {
            client.ExecuteRightToBeForgotten(contact);
            client.Submit();
        }
    }

    return false;
}

Подделайте некоторые данные

public void FakeUserInfo()
{
    var contactReference = _contactIdentificationRepository.GetContactReference();

    using (var client = SitecoreXConnectClientConfiguration.GetClient())
    {
        // we can have 1 to many facets
        // PersonalInformation.DefaultFacetKey
        // EmailAddressList.DefaultFacetKey
        // Avatar.DefaultFacetKey
        // PhoneNumberList.DefaultFacetKey
        // AddressList.DefaultFacetKey
        // plus custom ones
        var facets = new List<string> { PersonalInformation.DefaultFacetKey };

        // get the contact
        var contact = client.Get(contactReference, new ContactExpandOptions(facets.ToArray()));

        // pull the facet from the contact (if it exists)
        var facet = contact.GetFacet<PersonalInformation>(PersonalInformation.DefaultFacetKey);

        // if it exists, change it, else make a new one
        if (facet != null)
        {
            facet.FirstName = $"Myrtle-{DateTime.Now.Date.ToString(CultureInfo.InvariantCulture)}";
            facet.LastName = $"McSitecore-{DateTime.Now.Date.ToString(CultureInfo.InvariantCulture)}";

            // set the facet on the client connection
            client.SetFacet(contact, PersonalInformation.DefaultFacetKey, facet);
        }
        else
        {
            // make a new one
            var personalInfoFacet = new PersonalInformation()
            {
                FirstName = "Myrtle",
                LastName = "McSitecore"
            };

            // set the facet on the client connection
            client.SetFacet(contact, PersonalInformation.DefaultFacetKey, personalInfoFacet);
        }

        if (contact != null)
        {
            // submit the changes to xConnect
            client.Submit();

            // reset the contact
            _contactIdentificationRepository.Manager.RemoveFromSession(Analytics.Tracker.Current.Contact.ContactId);
            Analytics.Tracker.Current.Session.Contact = _contactIdentificationRepository.Manager.LoadContact(Analytics.Tracker.Current.Contact.ContactId);
        }
    }
}

ContactIdentificationRepository

using System.Linq;
using Sitecore.Analytics;
using Sitecore.Analytics.Model;
using Sitecore.Analytics.Tracking;
using Sitecore.Configuration;
using Sitecore.XConnect;
using Sitecore.XConnect.Client.Configuration;

namespace Sitecore.Foundation.Accounts.Repositories
{
    public class ContactIdentificationRepository
    {
        private readonly ContactManager contactManager;

        public ContactManager Manager => contactManager;

        public ContactIdentificationRepository()
        {
            contactManager = Factory.CreateObject("tracking/contactManager", true) as ContactManager;
        }

        public IdentifiedContactReference GetContactReference()
        {
            // get the contact id from the current contact
            var id = GetContactId();

            // if the contact is new or has no identifiers
            var anon = Tracker.Current.Contact.IsNew || Tracker.Current.Contact.Identifiers.Count == 0;

            // if the user is anon, get the xD.Tracker identifier, else get the one we found
            return anon
                ? new IdentifiedContactReference(Sitecore.Analytics.XConnect.DataAccess.Constants.IdentifierSource, Tracker.Current.Contact.ContactId.ToString("N"))
                : new IdentifiedContactReference(id.Source, id.Identifier);
        }

        public Analytics.Model.Entities.ContactIdentifier GetContactId()
        {
            if (Tracker.Current?.Contact == null)
            {
                return null;
            }
            if (Tracker.Current.Contact.IsNew)
            {
                // write the contact to xConnect so we can work with it
                this.SaveContact();
            }

            return Tracker.Current.Contact.Identifiers.FirstOrDefault();
        }

        public void SaveContact()
        {
            // we need the contract to be saved to xConnect. It is only in session now
            Tracker.Current.Contact.ContactSaveMode = ContactSaveMode.AlwaysSave;
            this.contactManager.SaveContactToCollectionDb(Tracker.Current.Contact);
        }

        public IXdbContext CreateContext()
        {
            return SitecoreXConnectClientConfiguration.GetClient();
        }
    }
}
...