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

[Analytics] fails to render when incident impactStartDate are on 1st or 2nd of January #116

Open
pizzqc opened this issue Jan 11, 2023 · 1 comment

Comments

@pizzqc
Copy link

pizzqc commented Jan 11, 2023

Plugin Version: 0.6.3
Backstage Version: 1.6.0

Starting in the new year 2023, we started having the backstage opsgenie Analytics tab to stop working and generating a bunch of undefined errors.

Digging into the code a little, we can see that a date in early January result into being classified as Week 52 of 2023 instead of Week 1. Which then leads to an issue when trying to increment the incidentsBuckets since week w52 - 2023 wasn't initialized to 0. (incidentsBuckets[week].total += 1;)

index-8e608a93.esm.js:269 Uncaught TypeError: Cannot read properties of undefined (reading 'total')
    at eval (index-8e608a93.esm.js:269:1)
    at Array.forEach (<anonymous>)
    at AnalitycsApi.incidentsByWeekAndHours (index-8e608a93.esm.js:266:1)
    at Graph$3 (index-8e608a93.esm.js:1194:1)
    at renderWithHooks (react-dom.development.js:14985:1)
    at mountIndeterminateComponent (react-dom.development.js:17811:1)
    at beginWork (react-dom.development.js:19049:1)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1)
    at invokeGuardedCallback (react-dom.development.js:4056:1)

Steps to reproduce

  1. Make sure to have an incident in OpsGenie that has an impactStartDate in early January. (i.e.: impactStartDate: "2023-01-02T03:00:38.787Z")
  2. Open the /opsgenie/analytics page

Error: Cannot read properties of undefined (reading 'total')

@pizzqc
Copy link
Author

pizzqc commented Jan 11, 2023

One easy solution could be to use week() instead of isoWeek() which might be better suited for this code logic.

the ISO week counter starts from the week with the first Thursday of the year. So, if the first day of the year is Saturday, it belongs to the last week of the previous year.

image

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

No branches or pull requests

1 participant