protected override async Task SaveUserActionAsync( UserRegisteredEvent data, MobileAppType?mobileAppType, long channelAttributesId, AttributionDataHashes attributionDataHashes, CancellationToken cancellation) { if (mobileAppType == null) { var userAction = new UserAction { UserId = data.UserId, Type = UserActionType.UserRegistered, ActionDateTimeUtc = data.Context.Timestamp, ObjectType = ObjectType.User, ObjectId = data.UserId, ObjectGuid = data.UserGuid, InitiatorId = data.Context.Initiator?.Id, InitiatorType = data.Context.Initiator?.Type, ChannelAttributesId = channelAttributesId, ActualHash = attributionDataHashes.ActualHash, LingeringHash = attributionDataHashes.LingeringHash }; await _userActionManager.SaveUserActionAsync(userAction); } }
protected override async Task SaveUserActionAsync( TaskCreatedEvent data, MobileAppType?mobileAppType, long channelAttributesId, AttributionDataHashes attributionDataHashes, CancellationToken cancellation) { if (mobileAppType != null) { // обрабатываем создание заданий только из веба return; } var userAction = new UserAction { UserId = data.NewTaskEntity.CreatorId, Type = UserActionType.TaskCreated, ActionDateTimeUtc = data.Context.Timestamp, ObjectType = ObjectType.Task, ObjectId = data.NewTaskEntity.Id, ObjectGuid = data.NewTaskEntity.Attributes?.TaskGuid, InitiatorId = data.Context.Initiator?.Id, InitiatorType = data.Context.Initiator?.Type, ChannelAttributesId = channelAttributesId, ActualHash = attributionDataHashes.ActualHash, LingeringHash = attributionDataHashes.LingeringHash }; await _userActionManager.SaveUserActionAsync(userAction); }
public override async Task ProcessMessageAsync(IReceivedMessage <TBody> message, CancellationToken cancellation) { try { var data = message.Body; if (data?.Context == null) { Logger.LogError($"Message body is incorrect\n{nameof(data)}: {{@message:j}}", data); message.Nack(); return; } if (data.Context?.WebContext == null) { message.Ack(); } var mobileAppType = GetMobileAppType(data.Context.ClientType); var attributionHashes = new AttributionDataHashes( data.Context.WebContext?.AttributionDataHash, data.Context.WebContext?.AttributionDataLingeringHash); var channelAttributesId = await _channelAttributesManager.GetChannelAttributesIdAsync(attributionHashes.ActualHash); await SaveUserActionAsync(message.Body, mobileAppType, channelAttributesId, attributionHashes, cancellation); message.Ack(); } catch (Exception ex) { Logger.LogError(0, ex, "Unexpected error:\nMessage: {@message:j}", message.Body); message.Requeue(); } }
protected abstract Task SaveUserActionAsync( TBody data, MobileAppType?mobileAppType, long channelAttributesId, AttributionDataHashes attributionDataHashes, CancellationToken cancellation);