mitodl / micromasters

Portal for learners and course teams to access MITx Micromasters® programs
https://mm.mit.edu
BSD 3-Clause "New" or "Revised" License
28 stars 16 forks source link

CropperWrapper.js: browser detect issue #4372

Open sentry-io[bot] opened 4 years ago

sentry-io[bot] commented 4 years ago

Sentry Issue: MICROMASTERS-155

TypeError: undefined is not an object (evaluating 'M.default.name')
  at apply (./static/js/components/CropperWrapper.js:18:11)
  at dispatchEvent ([native code])
alicewriteswrongs commented 4 years ago

the issue is happening here in CropperWrapper.js:

cropperHelper = () => {
    const { updatePhotoEdit } = this.props
    let canvas
    if (this.cropper) {
      if (browser.name === "safari" || browser.name === "ios") { // <- HERE!
        canvas = this.cropper.getCroppedCanvas()
      } else {
        canvas = this.cropper.getCroppedCanvas({
          width:  512,
          height: 512

it looks like we're seeing this mainly on iOS v 12.x, so it might be that the browser detection thing we're using is out-of-date now, and upgrading it could help.

alternatively, we could try adding a defensive

if (browser && browser.name === "safari"...

type check.