Skip to content

Commit d6c3009

Browse files
committed
Utilize a unique ID for activity logs to improve rendering perf
1 parent e878015 commit d6c3009

File tree

5 files changed

+8
-2
lines changed

5 files changed

+8
-2
lines changed

app/Transformers/Api/Client/ActivityLogTransformer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ public function getResourceName(): string
1818
public function transform(ActivityLog $model): array
1919
{
2020
return [
21+
// This is not for security, it is only to provide a unique identifier to
22+
// the front-end for each entry to improve rendering performance since there
23+
// is nothing else sufficiently unique to key off at this point.
24+
'id' => sha1($model->id),
2125
'batch' => $model->batch,
2226
'event' => $model->event,
2327
'is_api' => !is_null($model->api_key_id),

resources/scripts/api/definitions/user/models.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ interface SSHKey extends Model {
2020
}
2121

2222
interface ActivityLog extends Model<'actor'> {
23+
id: string;
2324
batch: UUID | null;
2425
event: string;
2526
ip: string | null;

resources/scripts/api/definitions/user/transformers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export default class Transformers {
3131
const { actor } = attributes.relationships || {};
3232

3333
return {
34+
id: attributes.id,
3435
batch: attributes.batch,
3536
event: attributes.event,
3637
ip: attributes.ip,

resources/scripts/components/dashboard/activity/ActivityLogContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default () => {
4949
) : (
5050
<div className={'bg-gray-700'}>
5151
{data?.items.map((activity) => (
52-
<ActivityLogEntry key={activity.timestamp.toString() + activity.event} activity={activity}>
52+
<ActivityLogEntry key={activity.id} activity={activity}>
5353
{typeof activity.properties.useragent === 'string' && (
5454
<Tooltip content={activity.properties.useragent} placement={'top'}>
5555
<span>

resources/scripts/components/server/ServerActivityLogContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default () => {
5252
) : (
5353
<div className={'bg-gray-700'}>
5454
{data?.items.map((activity) => (
55-
<ActivityLogEntry key={activity.timestamp.toString() + activity.event} activity={activity}>
55+
<ActivityLogEntry key={activity.id} activity={activity}>
5656
<span />
5757
</ActivityLogEntry>
5858
))}

0 commit comments

Comments
 (0)