procore-oss / backstage-plugin-announcements

Announcements Plugin for Backstage
https://procore-oss.github.io/backstage-plugin-announcements/
MIT License
27 stars 21 forks source link

πŸš€ Feature: Tracking or stats of announcements #418

Open skeletonz28 opened 1 month ago

skeletonz28 commented 1 month ago

πŸ”– Feature description

Possibility of being able to view how many times the announcement was viewed If possible, able to see a percentage of active users who haven't/have read the announcement, as it is easy to click the X to close the banner vs clicking on the announcement to view the details

🎀 Context

We have started using this feature to broadcast when we have released updates and when we will be in maintenance mode. We would like to see if the news is being viewed as we now have a way of stating to the user that we have communicated this on the platform alongside our other forms of communications Good stat to keep track of how valuable the data is being presented to the user. Able to point out how news is received within the deployed environment Able to keep track of how often announcements are read, leading to users being kept aware of changes/releases within the environment

✌️ Possible Implementation

If using a database, maybe adding a view count table or column for each announcement. If able to, similar to how Backstage Insights keeps track of how often a template was run, could use a similar method to keep track Unsure if this would result in duplicate views if 1 users repeatedly views 1 announcement

πŸ‘€ Have you spent some time to check if this feature request has been raised before?

Are you willing to submit PR?

None

kurtaking commented 2 days ago

If using a database, maybe adding a view count table or column for each announcement.

We'd probably be fine with adding a new view_count column.

async incrementViewCount(id: string): Promise<void> {
  await this.db('announcements')
    .where('id', id)
    .increment('view_count', 1);
}

Unsure if this would result in duplicate views if 1 users repeatedly views 1 announcement

One option would be to introduce a new table that stores the announcementId and reference to the user (think we would want that to be userEntityRef).

async incrementUniqueViewCount(announcementId: string, userEntityRef: string): Promise<void> {
  const exists = await this.db('announcement_views')
    .where({ announcement_id: announcementId, user_ref: userEntityRef })
    .first();

  if (!exists) {
    await this.db('announcement_views').insert({ announcement_id: announcementId, user_ref: userEntityRef });
  }

  await this.incrementViewCount(announcementId);
}

Let me know if you are interested in contributing this feature.