-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(headless): expose user action controller in insight bundle and a…
…dd logOpenUser analytics action (#4296) [SFINT-5640](https://coveord.atlassian.net/browse/SFINT-5640) ### IN THIS PR: - Added `logOpenUserActions` analytics event - Exposed the User actions controller in the insight bundle - Added unit tests for the `logOpenUserActions` action Tests: <img width="769" alt="image" src="https://github.com/user-attachments/assets/89bd185f-a3de-46b8-a015-3d5099c04a8f"> [SFINT-5640]: https://coveord.atlassian.net/browse/SFINT-5640?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
- Loading branch information
1 parent
fb1a93c
commit 2299887
Showing
9 changed files
with
134 additions
and
2 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
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
54 changes: 54 additions & 0 deletions
54
packages/headless/src/features/insight-user-actions/insight-user-actions-loader.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,54 @@ | ||
import {PayloadAction, AsyncThunkAction} from '@reduxjs/toolkit'; | ||
import {AsyncThunkInsightOptions} from '../../api/service/insight/insight-api-client'; | ||
import {CoreEngine} from '../../app/engine'; | ||
import {insightUserActionsReducer as insightUserActions} from '../../features/insight-user-actions/insight-user-actions-slice'; | ||
import { | ||
registerUserActions, | ||
fetchUserActions, | ||
RegisterUserActionsPayload, | ||
StateNeededByFetchUserActions, | ||
FetchUserActionsThunkReturn, | ||
} from './insight-user-actions-actions'; | ||
|
||
export type {RegisterUserActionsPayload}; | ||
export interface InsightUserActionsActionCreators { | ||
/** | ||
* Registers the user actions for a given user ID, ticket creation date, and excluded custom actions. | ||
* | ||
* @param payload - The action creator payload. | ||
* @returns A dispatchable action. | ||
*/ | ||
registerUserActions( | ||
payload: RegisterUserActionsPayload | ||
): PayloadAction<RegisterUserActionsPayload>; | ||
|
||
/** | ||
* Fetches the user actions. | ||
* | ||
* @param userId - The user ID to fetch actions for. | ||
* @returns A dispatchable action. | ||
*/ | ||
fetchUserActions( | ||
userId: string | ||
): AsyncThunkAction< | ||
FetchUserActionsThunkReturn, | ||
string, | ||
AsyncThunkInsightOptions<StateNeededByFetchUserActions> | ||
>; | ||
} | ||
|
||
/** | ||
* Loads the `InsightUserActions` reducer and returns possible action creators. | ||
* @param engine - The headless engine. | ||
* @returns An object holding the action creators. | ||
*/ | ||
export function loadInsightUserActionsActions( | ||
engine: CoreEngine | ||
): InsightUserActionsActionCreators { | ||
engine.addReducers({insightUserActions}); | ||
|
||
return { | ||
registerUserActions, | ||
fetchUserActions, | ||
}; | ||
} |
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