Skip to content

Commit

Permalink
feat(analytics): track News clicks on Notifications window (#5160)
Browse files Browse the repository at this point in the history
  • Loading branch information
blackxored authored Oct 15, 2024
1 parent a39c467 commit be9f2c7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/components-react/windows/notifications/News.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ import styles from './News.m.less';
import { useRealmObject } from 'components-react/hooks/realm';

export default function News() {
const { WindowsService, SettingsService, NavigationService, AnnouncementsService } = Services;
const {
WindowsService,
SettingsService,
NavigationService,
AnnouncementsService,
UsageStatisticsService,
} = Services;

const newsItems = useRealmObject(AnnouncementsService.currentAnnouncements).news;

Expand All @@ -23,6 +29,8 @@ export default function News() {

function handleClick(item: IAnnouncementsInfo) {
return () => {
AnnouncementsService.actions.closeNews(item.id);

if (item.linkTarget === 'slobs') {
if (item.link === 'Settings') {
SettingsService.showSettings(item.params?.category);
Expand Down
15 changes: 15 additions & 0 deletions app/services/announcements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,21 @@ export class AnnouncementsService extends Service {
}
}

async closeNews(newsId: number) {
const endpoint = 'api/v5/slobs/announcement/close';
const req = this.formRequest(endpoint, {
method: 'POST',
headers: new Headers({ 'Content-Type': 'application/json' }),
body: JSON.stringify({
clientId: this.userService.getLocalUserId(),
announcementId: newsId,
clickType: 'action',
}),
});

return jfetch(req);
}

async closeBanner(clickType: 'action' | 'dismissal') {
const endpoint = 'api/v5/slobs/announcement/close';
const req = this.formRequest(endpoint, {
Expand Down

0 comments on commit be9f2c7

Please sign in to comment.