zesty-io / manager-ui

Content platform powering enterprise websites and applications
https://www.zesty.io
Other
38 stars 5 forks source link

Activity Log: Published Activity is not appearing for a Content Item #2377

Closed zcolah closed 4 months ago

zcolah commented 7 months ago

Describe the bug I have published an article multiple times over the last 14 days in the Zesty 2022 Marketing Instance. I wanted to review the activity log today for this item and noticed that there were 0 publish logs. I am not sure why this is the case because this article is live which means it should have at least 1 publish present and I know for sure I have edit it, saved it and published it multiple times after that as well.

One key observation @theofficialnar and I made was that the Scheduled for Publish action does appear despite the Published action not appearing.

This is a very important issue to look into as it concerns multiple key customers of ours who need this feature to be working perfectly.

Content Item Link: https://8-aaeffee09b-7w6v22.manager.zesty.io/content/6-45a908-qfw88c/7-a4f6c6bdc5-kkztvh/

Activity Log Link: https://8-aaeffee09b-7w6v22.manager.zesty.io/reports/activity-log/resources/7-a4f6c6bdc5-kkztvh?from=2023-11-04&to=2023-12-04&action=4

Screenshot: CleanShot 2023-12-04 at 14 46 08

finnar-bin commented 7 months ago

@markelmad need your input on this, I tried checking and whenever a content item is published now, despite the request payload being correct it is being tagged as a "Scheduled publish" on activity log. image

As per my checking, on the frontend we differentiate publish types by checking if the word "scheduled" exists on the action.meta.message from the response of /audits. Reference: https://github.com/zesty-io/manager-ui/blob/1fd5f14aa1ecb9d5391b519b995c290d80b6670a/src/shell/services/instance.ts#L132C11-L136C31

The code above was never changed and was last touched 16 months ago that's why I am wondering if there were any changes made to how the action.meta.message is generated since right now, the message says "Published Item XXXX-ZUID-XXXX scheduled for 2023-12-06T05:05:08Z" even if I did a Publish now and not a scheduled publish making us not have a way to distinguish the 2 publish types.

zcolah commented 7 months ago

@theofficialnar I am potentially wondering if this is tied to the Content Title Bar update we made as our Publish button also acts as a schedule button in one use case. @agalin920 any thoughts on the same?

finnar-bin commented 7 months ago

@zcolah when I checked the request payload it is still being sent as publishAt: "now" when clicking the publish button which I'm assuming is the expected behavior when doing a non-scheduled publish. But correct me if I'm wrong @agalin920 and @markelmad .

finnar-bin commented 7 months ago

@markelmad just wanted to follow up on this.

zcolah commented 7 months ago

@markelmad @theofficialnar I got some more context from @shrunyan on this issue. Apparently no content item ever gets a published action. If the item gets published, it always gets a scheduled action instead.

finnar-bin commented 7 months ago

@zcolah so if that's the case then wouldn't that mean this bug has been there since activity log was made? Now I'm wondering how we can differentiate a publish now from a scheduled publish in the activity log, wouldn't it make sense to just remove the "Published" action filter?

markelmad commented 6 months ago

@theofficialnar The Audit log always has a message with the word 'scheduled' on it whether it is being published now or scheduled. Since you mentioned you only check for existing 'scheduled' strings from the message, I guess the fix could be done on how the message is constructed within the audit logging. I'll dig deeper into this and see if we really need to have the fix within the audit part or it could be within the publishing part (which would be more tedious work). I'll give updates once I have some answers. ANd I believe we should not remove the 'Published' action filter.

@theofficialnar you are using 'scheduled' keyword and 'published' keyword for this to distinguish?

finnar-bin commented 6 months ago

@markelmad Currently it only checks if the word "scheduled" is present on action.meta.message to determine if it's a publish now or a scheduled action.

zcolah commented 6 months ago

@markelmad @theofficialnar @shrunyan @ardeay Would love to hear your thoughts on what I have written down below.

I have an idea for the situation where we make no changes to the back-end where "both schedule and publish actions are marked as scheduled".

What if on the front end we write some logic where we display:

1. Published Action: If the schedule action was within the same minute as the scheduled for time 2. Scheduled Action: If the schedule action was more than a minute before the scheduled for time (technically this would be an else statement, not if).

This helps with the data integrity issue as the user is now aware of when the item was published vs scheduled.

There is one drawback to this solution These changes would not appear on the PDF report that is generated as that would still be relying on the back end API. Of course we can write similar logic and make similar changes for the PDF report generation system as well.

I would recommend we do this for displaying all of the past actions. This way no update needs to be made to the database.

I do recommend we investigate a much better long term solution for future actions, so we do not need to do this workaround. In the long term ideally, when the user clicks on the publish button, a publish action should be logged in the back end, and when the user clicks on the schedule button, a schedule action should be logged in the back end.

finnar-bin commented 4 months ago

@markelmad is there any particular reason why recently the logs response seem to have changed?

I found a publish action log dated Nov 30, 2022 which has 2 publish actions log both created at the same time, one says scheduled while the other just says published. image

But currently whenever a user publishes something either via publish now or scheduled publish it now only returns one log which always says "scheduled" even if it was not scheduled. image

In the meantime, a quick fix as suggested by @agalin920 which is to check if the createdAt/happenedAt log is the same as the datetime on the action message, it would be treated as a "Published" action has been created (https://github.com/zesty-io/manager-ui/pull/2570) but a long term fix would be probably be ideal.