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

fix: Prevent excessive konnector alerts notifications #2516

Merged

Conversation

taratatach
Copy link
Member

### ✨ Features

* Don't notify users about very old konnector run failures (i.e. older than 7 days and 15 minutes which is the maximum delay between the last failure and the scheduled 7 days reminder).

### 🐛 Bug Fixes

* Prevent scheduling `konnectorAlerts` triggers in the past which would be executed right away by `cozy-stack` ending up sending multiple notifications to the user about the failed konnector run.

### 🔧 Tech

*

We don't want users to be notified (neither by e-mail nor push
notifications) when a konnector failed a long time ago since there's
no real need for a quick action from their part and we want to avoid
spamming them with lots of notifications at the same time.

@taratatach taratatach self-assigned this Oct 3, 2022
@taratatach taratatach force-pushed the fix/prevent-excessive-konnector-alerts-notifications branch from aacbb2d to 74f5aa5 Compare October 3, 2022 14:55
@bundlemon
Copy link

bundlemon bot commented Oct 3, 2022

BundleMon

Files updated (1)
Status Path Size Limits
konnectorAlerts.js
1.06MB (+456B +0.04%) -
Unchanged files (47)
Status Path Size Limits
screenshots/fr/screenshot4.png
1.29MB -
screenshots/en/screenshot4.png
1.28MB -
screenshots/fr/screenshot5.png
1.17MB -
screenshots/en/screenshot5.png
1.17MB -
vendors.bundle.js
1.15MB -
onOperationOrBillCreate.js
1.08MB -
categorization.js
1.07MB -
recurrence.js
1.06MB -
budgetAlerts.js
1.04MB -
stats.js
492.38KB -
linkMyselfToAccounts.js
458.06KB -
autogroups.js
458.02KB -
screenshots/fr/screenshot1.png
330.32KB -
screenshots/en/screenshot1.png
311.39KB -
screenshots/fr/screenshot2.png
264.27KB -
screenshots/en/screenshot2.png
256.24KB -
screenshots/fr/screenshot3.png
246.98KB -
screenshots/en/screenshot3.png
243.76KB -
main.bundle.js
190.42KB -
img/veepee-info.43d778410d97b8e73b4eb07bb4631
d74.png
173.24KB -
img/[email protected]
9fcda5.png
167.13KB -
img/ameli-side.7173251188c5fe0d8d54e265f8426a
89.png
115.29KB -
cozy-bar.bundle.js
36.01KB -
vendors-banks.(hash).(hash).min.css
31.61KB -
img/veepee.9d3db3d18a5534582eba5b9fdbddb8bf.p
ng
25.01KB -
img/transfer-error.81739cda73db9309b4f58bf975
ee3856.jpg
24.69KB -
main-banks.(hash).min.css
17.02KB -
img/transfer-done.952c792c91ee5a8b70e025e85bf
4938a.jpg
13.95KB -
icon-banks.jpg
8.09KB -
img/icon-banks.3b21dff3d03e7f0b319fb93b5c5417
84.jpg
8.09KB -
img/search-illu.4536cb0962f2010e397bb96aeed5b
415.svg
4.48KB -
img/timeline_desktop_fr.8a2f9796b9d34fdc21eec
489d2f16db1.svg
3.94KB -
img/timeline_mobile_fr.e42a3b60dcefcdbae40e44
9c49c01d83.svg
3.83KB -
img/timeline_mobile_en.0f4ace6755128e27a825e0
31b0480a71.svg
3.66KB -
img/timeline_desktop_en.8ed0e7248216da5fb042e
30314036a39.svg
3.51KB -
mesinfos/favicon-32x32.png
1.39KB -
mesinfos/favicon.ico
1.19KB -
mesinfos/favicon-16x16.png
1.11KB -
index.html
1.11KB -
img/NoAccount.5cd307dbe22ac700d2f570f2c33487e
3.svg
1021B -
mesinfos/icon-bank.svg
645B -
img/pie-demo.5d713502666ac766dddccd37e34b0089
.svg
449B -
icon-banks.svg
363B -
img/icon-banks.243ad1303538aa7a966910c6269d52
7d.svg
363B -
favicon-32x32.png
242B -
public/safari-pinned-tab.svg
229B -
favicon-16x16.png
216B -

Total files change +456B 0%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@taratatach taratatach force-pushed the fix/prevent-excessive-konnector-alerts-notifications branch from 74f5aa5 to 90b4fce Compare October 4, 2022 07:53
@taratatach taratatach requested a review from Crash-- October 4, 2022 10:47
Copy link
Contributor

@JF-Cozy JF-Cozy left a comment

Choose a reason for hiding this comment

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

j'ai fait quelques remarques concernant quelques libs, histoire de simplifier le code ici en passant par date-fns, et d’homogénéiser avec les autres app via mockdate.

Je te laisse libre de voir si c'est pertinent ou pas

package.json Outdated Show resolved Hide resolved
@@ -115,3 +121,24 @@ export const fetchRelatedFuturAtTriggers = async (client, id) => {

return data
}

export const timeAgo = ({
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: est-ce qu'on a regardé dans date-fns s'il y a un équivalent ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Non, je n'ai pas regardé, je ne savais pas qu'il y avait ce module. On pourrait même remplacer isOlderThan j'imagine. Je vais regarder.

Copy link
Contributor

Choose a reason for hiding this comment

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

attention par contre à la version utilisée de la lib

Copy link
Member Author

Choose a reason for hiding this comment

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

Oui, il n'ya pas la fonction add dans la version actuelle donc je vais passer à la dernière version (je suis en train de mettre à jour les imports dont la manière de faire a visiblement changé).

Copy link
Contributor

Choose a reason for hiding this comment

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

attention au peerdep des libs. Peut-être que cette version est nécessaire pour harvest par exemple

Copy link
Member Author

Choose a reason for hiding this comment

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

harvest déclare sa propre dépendance à date-fns. Je serais par ailleurs surpris qu'un tel changement puisse être un breaking change pour d'autres dépendances de Banks. Ce serait amha un gros problème d'architecture.

Copy link
Member Author

Choose a reason for hiding this comment

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

Je suis retourné plus ou moins à l'état avant la mise à jour de date-fns puisque cela pose des soucis avec nos autres bibliothèques.
J'ai mis la mise à jour dans une autre PR : #2522

src/targets/services/konnectorAlerts/helpers.js Outdated Show resolved Hide resolved
@taratatach taratatach force-pushed the fix/prevent-excessive-konnector-alerts-notifications branch 5 times, most recently from f0adb0d to 94e5117 Compare October 11, 2022 09:59
  We don't want users to be notified (neither by e-mail nor push
  notifications) when a konnector failed a long time ago since there's
  no real need for a quick action from their part.
  This will be particularly useful when activating these notifications
  for a large audience.

  To achieve that result, we create a specific reason not to notify that
  we should not ignore via the `forcedIgnored` argument of the service.

  We set the limit to 7 days and 15 minutes after the last failure as
  this is the maximum delay we can wait for before triggering the
  service to send the last reminder notification to the user. Setting
  the limit below this would prevent that last notification to be sent.
  When a konnector fails for an actionnable reason (i.e. the user has
  the power to fix the underlying issue), we send a notification after
  the konnector has run and schedule 2 `konnectorAlerts` triggers 3 days
  and 7 days after to send notifications again in case the konnector is
  still failing to run.

  However, we set the starting point of these delays not at the moment
  when the `konnectorAlerts` service runs for the first time but at the
  moment the konnector failed for the last time. This date will always
  be in the past but it can be quite old thus generating reminders
  scheduled dates very close to the moment the service ran first and
  sent a notification to the user. It can even be in the past in which
  case `cozy-stack` will execute the trigger immediately after it is
  scheduled.
  In both situations, the user gets spammed with notifications.

  To prevent these, we will now make sure the reminders are scheduled to
  be sent at least 2 days after the moment the service first ran.
@taratatach taratatach force-pushed the fix/prevent-excessive-konnector-alerts-notifications branch from 94e5117 to fe27012 Compare October 11, 2022 10:14
@taratatach taratatach requested a review from JF-Cozy October 11, 2022 10:28
@taratatach taratatach merged commit 779b824 into master Oct 12, 2022
@taratatach taratatach deleted the fix/prevent-excessive-konnector-alerts-notifications branch October 12, 2022 07:43
JF-Cozy pushed a commit that referenced this pull request Oct 14, 2022
```

* Don't notify users about very old konnector run failures (i.e. older than 7 days and 15 minutes which is the maximum delay between the last failure and the scheduled 7 days reminder).

* Prevent scheduling `konnectorAlerts` triggers in the past which would be executed right away by `cozy-stack` ending up sending multiple notifications to the user about the failed konnector run.

*
```

We don't want users to be notified (neither by e-mail nor push
notifications) when a konnector failed a long time ago since there's
no real need for a quick action from their part and we want to avoid
spamming them with lots of notifications at the same time.
taratatach added a commit that referenced this pull request Dec 5, 2022
```
### ✨ Features

* Don't notify users about very old konnector run failures (i.e. older than 7 days and 15 minutes which is the maximum delay between the last failure and the scheduled 7 days reminder). (#2516)

### 🐛 Bug Fixes

* Prevent scheduling `konnectorAlerts` triggers in the past which would be executed right away by `cozy-stack` ending up sending multiple notifications to the user about the failed konnector run. (#2516)
* Prevent service call loops by only updating transactions for which we've updated the associated recurrence. (#2429)

### 🔧 Tech

* Run recurrence service only if flag is set (#2451)
```
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