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

feat: be able to group slack notifications by feature flag tag #1472

Merged
merged 17 commits into from
Jan 29, 2025

Conversation

cre8ivejp
Copy link
Member

@cre8ivejp cre8ivejp commented Jan 22, 2025

Fix of #1230

Thins done

  • Added feature_flag_tags column to subscription table
  • Implemented then changes to support feature_flag_tags field in the subscription APIs
  • Implemented to check if the feature flag tags match the subscription tags. If so, it will send the notification
  • Updated e2e and unit tests

This pull request introduces the concept of featureFlagTags to the subscription feature in the notification service. The changes include updates to the API definitions, database schema, validation logic, and various parts of the notification service to support the new featureFlagTags field.

API and Schema Updates:

  • Added featureFlagTags to multiple definitions in api-description/web-api.swagger.yaml. [1] [2] [3] [4]
  • Updated the subscription table to include a feature_flag_tags column and populated it with an empty array in migration/mysql/20250122261736_update_subscription_table.sql.

Service and Validation Logic:

  • Updated the NewSubscription function and related methods in pkg/notification/domain/subscription.go to handle featureFlagTags. [1] [2]
  • Added validation logic to ensure featureFlagTags are only saved if the Feature source type is present in pkg/notification/api/validation.go. [1] [2] [3]

Command Handling and Localization:

  • Introduced a new command UpdateSubscriptionFeatureFlagTagsCommand and its handler in pkg/notification/command/subscription.go.
  • Added localization support for feature flag tags updates in pkg/locale/localizedata/en.yaml, pkg/locale/localizedata/ja.yaml, and pkg/locale/localizer.go. [1] [2] [3]

Test and Miscellaneous Updates:

  • Updated test cases and other parts of the notification service to accommodate the new featureFlagTags field. [1] [2] [3]

These changes ensure that the notification service can now handle feature flag tags within subscriptions, providing more granular control over notification settings.

@cre8ivejp cre8ivejp force-pushed the feat-slack-tags branch 5 times, most recently from 8d2dff7 to 890be22 Compare January 22, 2025 12:35
@cre8ivejp cre8ivejp changed the title chore: add feature_flag_tags field to the proto files feat: be able to group slack notifications by feature flag tag Jan 22, 2025
@cre8ivejp cre8ivejp force-pushed the feat-slack-tags branch 5 times, most recently from 64e27f8 to b243d57 Compare January 28, 2025 06:46
Comment on lines +225 to +226
// When a flag changes it must be checked before sending notifications
func (s *sender) checkForFeatureDomainEvent(
Copy link
Member Author

Choose a reason for hiding this comment

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

This function handles the domain events to ensure that they are from the FEATURE entity.
Also, it checks if there are tags in the subscription and if the tags configured in the flag match the tags configured in the subscription.

@@ -53,4 +53,5 @@ message Subscription {
string name = 7;
string environment_id = 8;
string environment_name = 9;
repeated string feature_flag_tags = 10;
Copy link
Member Author

Choose a reason for hiding this comment

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

This field will hold the tags that will be used to send the notifications.

@cre8ivejp cre8ivejp requested review from Ubisoft-potato and kentakozuka and removed request for kentakozuka January 28, 2025 06:46
@cre8ivejp cre8ivejp marked this pull request as ready for review January 28, 2025 06:46
@cre8ivejp cre8ivejp removed the request for review from kentakozuka January 28, 2025 06:47
Comment on lines +129 to +133
// Check if the subcription tag is configured in the feature flag
// If not, we skip the notification
if !send {
continue
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Here is where we decide whether to send the notification.

Comment on lines +98 to +99
// We should only save the tags if the Feature source type is in the list
if req.FeatureFlagTags != nil {
Copy link
Member Author

Choose a reason for hiding this comment

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

Because the feature_flags_tags belongs to the Feature notification policy, we must validate it.

Copy link
Collaborator

@Ubisoft-potato Ubisoft-potato left a comment

Choose a reason for hiding this comment

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

The backend code looks good! 👍

cre8ivejp and others added 8 commits January 29, 2025 19:01
Signed-off-by: Alessandro Yuichi Okimoto <[email protected]>
Signed-off-by: Alessandro Yuichi Okimoto <[email protected]>
Signed-off-by: Alessandro Yuichi Okimoto <[email protected]>
Signed-off-by: Alessandro Yuichi Okimoto <[email protected]>
@cre8ivejp cre8ivejp merged commit fcd92d2 into main Jan 29, 2025
17 checks passed
@cre8ivejp cre8ivejp deleted the feat-slack-tags branch January 29, 2025 10:34
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