Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CORL-2147] Track queue sort change events into metrics #3594

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CLIENT_EVENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ createComment.error
- <a href="#loginPrompt">loginPrompt</a>
- <a href="#openSortMenu">openSortMenu</a>
- <a href="#openStory">openStory</a>
- <a href="#queueSortChanged">queueSortChanged</a>
- <a href="#rejectComment">rejectComment</a>
- <a href="#removeCommentReaction">removeCommentReaction</a>
- <a href="#removeUserIgnore">removeUserIgnore</a>
Expand Down Expand Up @@ -352,6 +353,18 @@ createComment.error
};
}
```
- <a id="queueSortChanged">**queueSortChanged**</a>: This event is emitted when the viewer changes the moderation queue sort.
```ts
{
success: {
sortOrder: string;
};
error: {
message: string;
code?: string | undefined;
};
}
```
- <a id="rejectComment">**rejectComment.success**, **rejectComment.error**</a>: This event is emitted when the viewer rejects a comment.
```ts
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { MOD_QUEUE_SORT_ORDER } from "coral-admin/constants";
import { CoralContext } from "coral-framework/lib/bootstrap";
import { createMutation, LOCAL_ID } from "coral-framework/lib/relay";
import { GQLCOMMENT_SORT_RL } from "coral-framework/schema";
import { QueueSortChangedEvent } from "coral-stream/events";

export interface Input {
sortOrder: GQLCOMMENT_SORT_RL;
Expand All @@ -17,6 +18,10 @@ export async function commit(
// Set in local storage
await context.localStorage.setItem(MOD_QUEUE_SORT_ORDER, input.sortOrder);

// Track event
const sortChangedEvent = QueueSortChangedEvent.begin(context.eventEmitter);
sortChangedEvent.success({ sortOrder: input.sortOrder });

// Set in Relay
return commitLocalUpdate(environment, (store) => {
const localRecord = store.get(LOCAL_ID);
Expand Down
14 changes: 14 additions & 0 deletions src/core/client/stream/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,3 +622,17 @@ export const CancelAccountDeletionEvent = createViewerNetworkEvent<{
code?: string;
};
}>("cancelAccountDeletionEvent");

/**
* This event is emitted when the viewer changes the moderation
* queue sort.
*/
export const QueueSortChangedEvent = createViewerEvent<{
success: {
sortOrder: string;
};
error: {
message: string;
code?: string;
};
}>("queueSortChangedEvent");