
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
@bigbinary/neeto-activities-frontend
Advanced tools
A repo acts as the source of truth for the new nano's structure, configs, data etc.
The nano that manages backend structure for activities.
create_table :neeto_activities_engine_activities, id: :uuid do |t|
# Parent association for the activity, example: Ticket
t.references :trackable, polymorphic: true, index: true, type: :uuid
# Performer of the activity, example: User
t.references :performer, polymorphic: true, type: :uuid
# Unique key per activity that can be used in translations to render on UI
t.string :key
# Any additional details that might be helpful for building the translations or debugging purpose
t.jsonb :metadata, default: {}
t.timestamps
end
Check an example of an activity generated for updating the ticket status in neetoDesk.
#<NeetoActivitiesEngine::Activity:0x000000013237f158> {
:id => "d0458158-68d1-423f-b364-d22a8916f6d0",
:key => "activity.ticket.update.status",
:trackable_type => "Ticket",
:trackable_id => "c5104a50-2eff-49a3-accb-f2fa8f4fc1f7",
:performer_type => "User",
:performer_id => "b028d29e-f40a-4c09-9222-357cfe84e2c3",
:created_at => Mon, 30 Oct 2023 10:23:26.705884000 UTC +00:00,
:updated_at => Mon, 30 Oct 2023 10:23:26.705884000 UTC +00:00,
:metadata => {
"new_value" => "trash",
"old_value" => "open"
}
}
We have a concern that can be included in the models that need to track the activities, this concern adds associations and a helper method that allows creating activities easily.
Refer: NeetoActivitiesEngine::Trackable
Example:
class User
include NeetoActivitiesEngine::Trackable
after_save :log_account_block_activity!, if: :blocked?
private
def log_account_block_activity!
old_value, new_value = saved_change_to_blocked_at
key = new_value ? "activity.user.blocked" : "activity.user.unblocked"
metadata = { performer_name: User.current&.name }
log_activity!(key:, metadata:, performer: User.current)
end
end
neetoDesk needs many custom activities for tickets, in order to achieve it, we have created another concern that works on top of the above concern.
Refer: app/models/concerns/trackable/tickets.rb
Usage:
class Ticket
include NeetoActivitiesEngine::Trackable
include Trackable::Tickets # Depends on NeetoActivitiesEngine::Trackable
end
Using User.current
is not a good practice,
it also does not fit in all the places.
Example: In neetoDesk, Automation rules can update tickets,
here the performer is Automation::Rule
not User
.
To get around this problem, we have activity_performer
attr_accessor.
class Ticket
include NeetoActivitiesEngine::Trackable
after_save :log_status_activity!, if: :saved_change_to_status?
private
def log_status_activity!
old_value, new_value = saved_change_to_status
key = "activity.ticket.status.update"
metadata = { old_value:, new_value: }
log_activity!(key: , metadata:, performer: activity_performer)
end
end
ticket.activity_performer = Automation::Rule.first
ticket.update(status: :closed)
Occationally, the business logic demands to skip the activity.
For this, we have added skip_activity
attr_accessor in the concern.
Example: Assume that you want to skip the activities when you update the ticket from Rails console.
class Ticket
include NeetoActivitiesEngine::Trackable
after_save :log_status_activity!, if: :saved_change_to_status?
private
def log_status_activity!
old_value, new_value = saved_change_to_status
key = "activity.ticket.status.update"
metadata = { old_value:, new_value: }
log_activity!(key: , metadata:, performer: activity_performer)
end
end
# rails c
ticket.skip_activity = true
ticket.update(status: :closed)
FAQs
A repo acts as the source of truth for the new nano's structure, configs, data etc.
The npm package @bigbinary/neeto-activities-frontend receives a total of 5 weekly downloads. As such, @bigbinary/neeto-activities-frontend popularity was classified as not popular.
We found that @bigbinary/neeto-activities-frontend demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.