Skip to content

Commit

Permalink
Add notifications' events
Browse files Browse the repository at this point in the history
  • Loading branch information
Bardin08 committed Jun 2, 2024
1 parent c05e641 commit 2f14e92
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using Trumpee.MassTransit.Messages.Analytics.Notifications.Payloads;

namespace Trumpee.MassTransit.Messages.Analytics.Notifications;

/// <summary>
/// Provides methods to create notification-related analytics events.
/// </summary>
public static class Notification
{
/// <summary>
/// Creates an analytics event indicating that a notification has been created.
/// </summary>
/// <param name="source">The source of the event.</param>
/// <param name="notificationId">The ID of the notification.</param>
/// <returns>An analytics event indicating the notification has been created.</returns>
public static AnalyticsEvent<NotificationCreatedPayload> Created(
string source, string notificationId)
{
var payload = new NotificationCreatedPayload
{
NotificationId = notificationId
};

const string actionName = "NotificationCreated";
return AnalyticsEvent<NotificationCreatedPayload>.Create(
streamId: notificationId,
action: actionName,
source: source,
payload: payload);
}

/// <summary>
/// Creates an analytics event indicating that a notification has been sent.
/// </summary>
/// <param name="source">The source of the event.</param>
/// <param name="notificationId">The ID of the notification.</param>
/// <returns>An analytics event indicating the notification has been sent.</returns>
public static AnalyticsEvent<NotificationSent> Sent(
string source, string notificationId)
{
var payload = new NotificationSent
{
NotificationId = notificationId
};

const string actionName = "NotificationSent";
return AnalyticsEvent<NotificationSent>.Create(
streamId: notificationId,
action: actionName,
source: source,
payload: payload);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Trumpee.MassTransit.Messages.Analytics.Notifications.Payloads;

/// <summary>
/// Represents the payload for a notification created event.
/// </summary>
public record NotificationCreatedPayload
{
/// <summary>
/// Gets or sets the ID of the notification.
/// </summary>
public required string NotificationId { get; init; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Trumpee.MassTransit.Messages.Analytics.Notifications.Payloads;

/// <summary>
/// Represents the payload for a notification sent event.
/// </summary>
public class NotificationSent
{
/// <summary>
/// Gets or sets the ID of the notification.
/// </summary>
public required string NotificationId { get; set; }
}

0 comments on commit 2f14e92

Please sign in to comment.