Skip to content

Conversation

pd-redis
Copy link
Collaborator

If the event is triggered by accepting consents, reason is install, if it is because of sso\social-login\oauth reasons, appropriate strategy is sent google | github | sso. One last place where analytics is being enabled is in OAuthAgreement.tsx, where reason is sent as oauth-agreement

If the event is triggered by accepting consents, reason is `install`, if it is because of `sso\social login\oauth` reasons, appropriate strategy is sent `google | github | sso`.
One last place where analytics is being enabled is in OAuthAgreement.tsx, where reason is sent as `oauth-agreement`
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR adds support for including a reason when the analytics permission event is triggered. It updates both the API DTO and service layers as well as multiple UI components and Redux actions to consistently propagate a new analyticsReason parameter.

  • Added analyticsReason property with validation in the settings DTO.
  • Updated UI components and Redux actions to pass a reason for enabling analytics.
  • Modified API services and event emitters to include the reason in analytics permission events.

Reviewed Changes

File Description
redisinsight/api/src/modules/settings/dto/settings.dto.ts Added an optional analyticsReason field with validation and API documentation.
redisinsight/ui/src/components/consents-settings/ConsentsSettings.tsx Updated consent logic to include analyticsReason when dispatching settings updates.
redisinsight/api/src/modules/settings/models/agreements.interface.ts Added a new field requiredText to IAgreement for richer agreement spec support.
redisinsight/ui/src/components/oauth/shared/oauth-agreement/OAuthAgreement.tsx Updated analytics action dispatch with a specific reason ('oauth-agreement').
redisinsight/ui/src/slices/user/user-settings.ts Updated error handling to cast errors as AxiosError and modified enableUserAnalyticsAction to accept a reason parameter.
redisinsight/ui/src/components/oauth/shared/oauth-form/OAuthForm.tsx Modified analytics action dispatch to pass the selected auth strategy as the reason.
redisinsight/api/src/modules/settings/settings.analytics.ts Propagated the reason parameter to analytics event emission.
redisinsight/api/src/modules/settings/settings.service.ts Updated settings update flow to destructure and pass analyticsReason from the DTO to agreement updates.

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

redisinsight/ui/src/slices/user/user-settings.ts:187

  • [nitpick] The function now accepts a reason parameter with a default empty string. Consider adding documentation or comments to clarify the acceptable values and usage context for the reason parameter to aid future maintenance.
export function enableUserAnalyticsAction(reason = '') {

const handleCheck = (e: ChangeEvent<HTMLInputElement>) => {
if (e.target.checked) {
dispatch(enableUserAnalyticsAction())
dispatch(enableUserAnalyticsAction('oauth-agreement'))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you thing about extracting these in something like AnalyticsReason?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extracted

})
@IsOptional()
@IsString()
analyticsReason?: string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't find any other usage, but there's a IsIn decorator that can provide validation on predefined set of values. And we can use a enum for it:

@IsIn(Object.values(AnalyticsReason)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

@pd-redis pd-redis requested a review from pawelangelow March 11, 2025 14:40
KIvanow
KIvanow previously approved these changes Mar 21, 2025
@KIvanow KIvanow merged commit 280c5fb into main Mar 25, 2025
15 checks passed
@KIvanow KIvanow deleted the fe/feature/RI-6864-enhance-ANALYTICS_PERMISSION branch March 25, 2025 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants