GoogleCloudPlatform / stackdriver-errors-js

Client-side JavaScript exception reporting library for Cloud Error Reporting
https://cloud.google.com/error-reporting/
Apache License 2.0
362 stars 54 forks source link

StackTrace is not defined #19

Closed baktun14 closed 7 years ago

baktun14 commented 7 years ago

image

I tried to quickly connect and test and got this error. I'm using webpack/react and used it like this.

var StackdriverErrorReporter = require("stackdriver-errors-js").StackdriverErrorReporter;

export function initErrorLogging() {
  const errorHandler = new StackdriverErrorReporter();
  errorHandler.start({
    key: STACKDRIVER_API_KEY,
    projectId: GCP_PROJECT_ID,
    //service: '<my-service>',              // (optional)
    //version: '<my-service-version>'       // (optional)
  });
}

I suppose you could include StackTrace as a dependency.

steren commented 7 years ago

If you load the stackdriver-errors.jsfile, this one assumes that the stacktrace-js module has been loaded.

I never tested this module with webpack. Feel free to add more install details to the README and send fixes.

baktun14 commented 7 years ago

I never worked with the gulp workflow so I don't really how to get this working properly :(

steren commented 7 years ago

Does importing the stacktrace-js module solve the issue?

baktun14 commented 7 years ago

I haven't tried sorry.. I didn't know stackdriver had it's own api so I'll just write a few lines to report the errors. Thanks anyways!

steren commented 7 years ago

As you want. But technically, those few lines will be https://github.com/GoogleCloudPlatform/stackdriver-errors-js/blob/master/stackdriver-errors.js

wclr commented 6 years ago

@steren How this stacktrace-js should be imported?

require('stacktrace-js')
const { StackdriverErrorReporter } = require('stackdriver-errors-js')

window.addEventListener('DOMContentLoaded', function () {
  window.errorHandler = new StackdriverErrorReporter();
  window..errorHandler.start({

  })
})

gives an error: image

steren commented 6 years ago

When you do require('stacktrace-js'), does it exposes a global StackTrace object? This is what is expected by stackdriver-errors.js