-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #150 from AlphadayHQ/dev
v2.1.0 — Activity logs + multiple dep updates
- Loading branch information
Showing
21 changed files
with
368 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: npm # See documentation for possible values | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "weekly" | ||
day: "friday" | ||
time: "05:00" | ||
timezone: UTC | ||
open-pull-requests-limit: 3 | ||
versioning-strategy: increase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { useSendActivityLogMutation } from "src/api/services"; | ||
import { | ||
EActivityLogEventTypes, | ||
EActivityLogObjectTypes, | ||
} from "src/api/services/activity-log/types"; | ||
import { ECookieChoice } from "src/api/types"; | ||
import { Logger } from "../utils/logging"; | ||
|
||
interface IActivityLogger { | ||
logCookieChoice: (choice: ECookieChoice) => void; | ||
logViewVisited: (id: number) => void; | ||
logKeywordSelected: (id: number) => void; | ||
} | ||
|
||
export const useActivityLogger = (): IActivityLogger => { | ||
const [sendActivityLog] = useSendActivityLogMutation(); | ||
|
||
const logViewVisited = (viewId: number) => { | ||
sendActivityLog({ | ||
event_type: EActivityLogEventTypes.ViewVisited, | ||
object_type: 3, | ||
object_id: viewId, | ||
}) | ||
.unwrap() | ||
.then((resp) => | ||
Logger.debug( | ||
"useActivityLogger::logVisitedView: updated view activity log", | ||
resp | ||
) | ||
) | ||
.catch((err) => | ||
Logger.error( | ||
"useActivityLogger::logVisitedView: error updating view activity log", | ||
err | ||
) | ||
); | ||
}; | ||
|
||
const logCookieChoice = (choice: ECookieChoice) => { | ||
sendActivityLog({ | ||
event_type: EActivityLogEventTypes.CookieChoiceSet, | ||
data: { | ||
choice, | ||
}, | ||
}) | ||
.unwrap() | ||
.then((resp) => | ||
Logger.debug( | ||
"useActivityLogger::logCookieChoice: updated cookie activity log", | ||
resp | ||
) | ||
) | ||
.catch((err) => | ||
Logger.error( | ||
"useActivityLogger::logCookieChoice: error updating cookie activity log", | ||
err | ||
) | ||
); | ||
}; | ||
|
||
const logKeywordSelected = (keywordId: number) => { | ||
sendActivityLog({ | ||
event_type: EActivityLogEventTypes.KeywordSelected, | ||
object_id: keywordId, | ||
object_type: EActivityLogObjectTypes.Keyword, | ||
}) | ||
.unwrap() | ||
.then((resp) => | ||
Logger.debug( | ||
"useActivityLogger::logKeywordSelected: updated keyword activity log", | ||
resp | ||
) | ||
) | ||
.catch((err) => | ||
Logger.error( | ||
"useActivityLogger::logKeywordSelected: error updating keyword activity log", | ||
err | ||
) | ||
); | ||
}; | ||
|
||
return { | ||
logViewVisited, | ||
logCookieChoice, | ||
logKeywordSelected, | ||
}; | ||
}; |
24 changes: 24 additions & 0 deletions
24
packages/frontend/src/api/services/activity-log/activityEndpoints.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import CONFIG from "../../../config/config"; | ||
import { alphadayApi } from "../alphadayApi"; | ||
import { TActivityLogRequest, TActivityLogResponse } from "./types"; | ||
|
||
const API_CONFIG = CONFIG.API.DEFAULT; | ||
const { ACTIVITY_LOG } = API_CONFIG.ROUTES; | ||
|
||
const activityLogsApi = alphadayApi.injectEndpoints({ | ||
endpoints: (builder) => ({ | ||
sendActivityLog: builder.mutation< | ||
TActivityLogResponse, | ||
TActivityLogRequest | ||
>({ | ||
query: (request) => ({ | ||
url: `${ACTIVITY_LOG.BASE}${ACTIVITY_LOG.DEFAULT}`, | ||
method: "POST", | ||
body: request, | ||
}), | ||
}), | ||
}), | ||
overrideExisting: false, | ||
}); | ||
|
||
export const { useSendActivityLogMutation } = activityLogsApi; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
export enum EActivityLogEventTypes { | ||
ViewVisited = "VIEW_VISITED", | ||
WidgetInteraction = "WIDGET_INTERACTION", // Placeholder, TBD | ||
KeywordSelected = "KEYWORD_SELECTED", | ||
CookieChoiceSet = "COOKIE_CHOICE_SET", | ||
} | ||
|
||
export enum EActivityLogObjectTypes { | ||
Keyword = 1, | ||
Widget, | ||
View, | ||
} | ||
|
||
export type TKeywordActivityLog = { | ||
event_type: EActivityLogEventTypes.KeywordSelected; | ||
object_type: EActivityLogObjectTypes.Keyword; | ||
object_id: number; | ||
data?: JSONValue; | ||
}; | ||
|
||
export type TWidgetActivityLog = { | ||
event_type: EActivityLogEventTypes.WidgetInteraction; | ||
object_type: EActivityLogObjectTypes.Widget; | ||
object_id: number; | ||
data?: JSONValue; | ||
}; | ||
|
||
export type TViewActivityLog = { | ||
event_type: EActivityLogEventTypes.ViewVisited; | ||
object_type: EActivityLogObjectTypes.View; | ||
object_id: number; | ||
data?: JSONValue; | ||
}; | ||
|
||
export type TCookieActivityLog = { | ||
event_type: EActivityLogEventTypes.CookieChoiceSet; | ||
data: JSONValue; | ||
}; | ||
|
||
export type TRemoteActivityLog = | ||
| TKeywordActivityLog | ||
| TWidgetActivityLog | ||
| TViewActivityLog | ||
| TCookieActivityLog; | ||
|
||
export type TActivityLogRequest = TRemoteActivityLog; | ||
export type TActivityLogResponse = TRemoteActivityLog; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.