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(notifications): new notification pattern #651

Merged
merged 23 commits into from
Feb 2, 2025
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5d3880c
fix(components): fix CustomSelect filteredOption computed
e11sy Jan 25, 2025
9e79c76
imp(components): RadioButtonGroup descriptions presentation improved
e11sy Jan 25, 2025
e649da7
feat(components): added NotificationAddRule form for SEEN_MORE setting
e11sy Jan 25, 2025
77239b8
chore(i18n): update dictionaries
e11sy Jan 25, 2025
3bf101d
types(notifications): update notification types
e11sy Jan 25, 2025
55d7cd5
chore(storybook): change ReceiveTypes from ALL to SEEN_MORE
e11sy Jan 25, 2025
fa78667
types(project-notifications): add threshold types
e11sy Jan 25, 2025
8f6d3f4
chore(i18n): update dictionaries
e11sy Jan 25, 2025
cd8d0fb
chore(i18n): update translation usage
e11sy Jan 25, 2025
b7f0a7e
fix(components): add notification rule form watchers
e11sy Jan 25, 2025
c50c826
fix(components): fix slot position in RadioButtonGroup
e11sy Jan 25, 2025
a94df9e
chore(graphql): update schemas
e11sy Jan 25, 2025
59b5045
chore(): migrate from enum to map
e11sy Jan 25, 2025
a4f591c
chore(): remove redundant logs
e11sy Jan 25, 2025
9b7caa8
imp(styles): improve create rule form styles
e11sy Feb 1, 2025
bc1a41d
imp(notifications): add channels endpoint validation in create rule form
e11sy Feb 1, 2025
4eca02a
fix(notifications): fix build
e11sy Feb 1, 2025
86d1ddc
feat(notifications): add graphql mutation for deletion of the rule
e11sy Feb 1, 2025
b97281e
imp(i18n): improve seen more label naming
e11sy Feb 1, 2025
ce63fa0
chore(): lint fix
e11sy Feb 1, 2025
1193d3a
imp(add-rule): do not overuse hardcoded number
e11sy Feb 1, 2025
83cb094
update from main
e11sy Feb 1, 2025
160b6a3
chore() eslint fix
e11sy Feb 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ input CreateProjectNotificationsRuleInput {
"""Words to exclude from notification"""
excluding: [String!]! = []

"""Treshold to be reached to send notification"""
threshold: Int = 100

"""Treshold period in milliseconds"""
thresholdPeriod: Int = 3600000

"""Notification channels to recieve events"""
channels: NotificationsChannelsInput!
}
Expand Down
4 changes: 4 additions & 0 deletions src/analytics/amplitude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export const Analytics = {
* @param userId - user identifier
*/
setUserId: (userId: string): void => {
if (!isRegistered) {
return;
}

return setUserId(userId);
},
};
9 changes: 9 additions & 0 deletions src/api/fragments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ export const PROJECT_NOTIFICATIONS_RULE_FRAGMENT = `
isEnabled
}
}
threshold
thresholdPeriod
}
`;

export const PROJECT_NOTIFICATIONS_RULE_POINTER_FRAGMENT = `
fragment ProjectNotificationRulePointer on ProjectNotificationRulePointer {
id
projectId
}
`;

Expand Down
13 changes: 13 additions & 0 deletions src/api/projects/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
MUTATION_UPDATE_LAST_VISIT,
MUTATION_CREATE_PROJECT_NOTIFY_RULE,
MUTATION_UPDATE_PROJECT_NOTIFY_RULE,
MUTATION_REMOVE_PROJECT_NOTIFY_RULE,
MUTATION_REMOVE_PROJECT,
MUTATION_TOGGLE_ENABLED_STATE_OF_A_PROJECT_NOTIFY_RULE,
QUERY_CHART_DATA, MUTATION_GENERATE_NEW_INTEGRATION_TOKEN
Expand Down Expand Up @@ -114,6 +115,18 @@ export async function updateProjectNotificationsRule(payload) {
})).updateProjectNotificationsRule;
}

/**
* Send request for removing specific project notifications rule
*
* @param {ProjectNotificationRulePointer} payload - update rule payload
* @returns {Promise<ProjectNotificationsRule>}
*/
export async function removeProjectNotificationsRule(payload) {
return (await api.callOld(MUTATION_REMOVE_PROJECT_NOTIFY_RULE, {
input: payload,
})).removeProjectNotificationsRule;
}

/**
* Send request for updating specific project notifications rule
*
Expand Down
13 changes: 13 additions & 0 deletions src/api/projects/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,19 @@ export const MUTATION_UPDATE_PROJECT_NOTIFY_RULE = `
${PROJECT_NOTIFICATIONS_RULE_FRAGMENT}
`;

// language=GraphQL
export const MUTATION_REMOVE_PROJECT_NOTIFY_RULE = `
mutation ( $input: ProjectNotificationRulePointer! ) {
deleteProjectNotificationsRule(
input: $input
) {
...ProjectNotificationsRule
}
}

${PROJECT_NOTIFICATIONS_RULE_FRAGMENT}
`;

// language=GraphQL
export const MUTATION_REMOVE_PROJECT = `
mutation removeProject($projectId: ID!) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/forms/CustomSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default {
},
computed: {
filteredOption() {
return this.options.filter(opt => opt !== this.value);
return this.options.filter(opt => opt.id !== this.value.id);
},
},
methods: {
Expand Down
9 changes: 8 additions & 1 deletion src/components/forms/RadioButtonGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,15 @@
v-if="option.description"
class="radio-button-group__option-description"
>
{{ option.description }}
<div v-if="option.description !== undefined">
{{ option.description }}
</div>
</div>
<slot
v-else
name="description"
:option="option"
/>
</div>

<UiRadio
Expand Down
4 changes: 2 additions & 2 deletions src/components/modals/PaymentDetailsDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ export default Vue.extend({
const newCardOption: CustomSelectOption = {
id: NEW_CARD_ID,
value: NEW_CARD_ID,
name: this.$t('billing.paymentDetails.newCard') as string
name: this.$t('billing.paymentDetails.newCard') as string,
};

if (!cards) {
Expand Down Expand Up @@ -592,7 +592,7 @@ export default Vue.extend({
amount = AMOUNT_FOR_CARD_VALIDATION;
}

const method = this.isOnlyCardValidationNeeded ? 'auth' : 'charge'
const method = this.isOnlyCardValidationNeeded ? 'auth' : 'charge';

widget.pay(method,
{
Expand Down
10 changes: 10 additions & 0 deletions src/components/project/settings/Notifications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
:project-id="project.id"
:enable-editing="userCanEdit"
@editClicked="editRule"
@removeClicked="removeRule"
/>
</section>
</div>
Expand Down Expand Up @@ -154,6 +155,15 @@ export default Vue.extend({
this.addRuleOpened = true;
},

removeRule(ruleId: string): void {
this.$store.dispatch('REMOVE_NOTIFICATIONS_RULE', {
projectId: this.project.id,
ruleId,
});

this.$forceUpdate();
},

/**
* Close and clear add rule form
*/
Expand Down
Loading
Loading