Skip to content

Commit

Permalink
1.0.0-rc.3
Browse files Browse the repository at this point in the history
* Allow disabling Sentry for specific functions by settings `sentry: false` in
  the `serverless.yml`.
* Added support for the [Serverless Offline Plugin](https://github.com/dherault/serverless-offline).
  • Loading branch information
Andre Rabold committed Jul 6, 2017
1 parent 62e4691 commit f4b160f
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 36 deletions.
23 changes: 17 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,16 +268,17 @@ plugins:
custom:
sentry:
dsn: https://xxxx:[email protected]/zzzz # URL provided by Sentry
organization: my-sentry-organziation
project: my-sentry-project
authToken: my-sentry-api-key
release: git
captureTimeoutWarnings: false # disable timeout warnings globally for all functions
functions:
HelloWorld:
handler: hello.handler
FuncFoo:
handler: Foo.handler
description: Hello World
sentry:
captureErrors: false # Disable error capturing for this specific function only
captureTimeoutWarnings: true # Turn timeout warnings back on
FuncBar:
handler: Bar.handler
sentry: false # completely turn off Sentry reporting
```


Expand Down Expand Up @@ -327,9 +328,19 @@ the rest of your code. This is typically not what you want. Make sure to pass
in the Raven instance during initialization of the `RavenLambdaWrapper` as shown
in the examples above.

### Raven throws an uncaught error: Cannot read property 'user' of undefined
Raven is not initialized properly. If you're running in a local environment try
setting the `filterLocal` option to `false`.


## Version History

### 1.0.0-rc.3

* Allow disabling Sentry for specific functions by settings `sentry: false` in
the `serverless.yml`.
* Added support for the [Serverless Offline Plugin](https://github.com/dherault/serverless-offline).

### 1.0.0-rc.2

* Fixed an issue with the plugin not being initialized properly when deploying
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "serverless-sentry",
"version": "1.0.0-rc.2",
"version": "1.0.0-rc.3",
"description": "Serverless Sentry Plugin - Automatically send errors and exceptions to Sentry (https://sentry.io)",
"main": "src/index.js",
"author": "Andre Rabold",
Expand Down
57 changes: 29 additions & 28 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,29 @@ class Sentry {
this._provider = this._serverless.getProvider("aws");

this.hooks = {
"before:package:initialize": this.beforePackageInitialize.bind(this),
"after:package:initialize": this.afterPackageInitialize.bind(this),
"before:deploy:deploy": this.beforeDeployDeploy.bind(this),
"after:deploy:deploy": this.afterDeployDeploy.bind(this)
"before:package:initialize": () => BbPromise.bind(this)
.then(this.validate),

"after:package:initialize": () => BbPromise.bind(this)
.then(this.setRelease)
.then(this.instrumentFunctions),

"before:deploy:deploy": () => BbPromise.bind(this)
.then(this.validate),

"after:deploy:deploy": () => BbPromise.bind(this)
.then(this.createSentryRelease)
.then(this.deploySentryRelease),

"before:offline:start": () => BbPromise.bind(this)
.then(this.validate)
.then(this.setRelease)
.then(this.instrumentFunctions),

"before:offline:start:init": () => BbPromise.bind(this)
.then(this.validate)
.then(this.setRelease)
.then(this.instrumentFunctions)
};

this.configPlugin();
Expand Down Expand Up @@ -72,28 +91,6 @@ class Sentry {
});
}

beforePackageInitialize() {
return BbPromise.bind(this)
.then(this.validate);
}

afterPackageInitialize() {
return BbPromise.bind(this)
.then(this.setRelease)
.then(this.instrumentFunctions);
}

beforeDeployDeploy() {
return BbPromise.bind(this)
.then(this.validate);
}

afterDeployDeploy() {
return BbPromise.bind(this)
.then(this.createSentryRelease)
.then(this.deploySentryRelease);
}

instrumentFunctions() {
// Get functions
const allFunctions = this._serverless.service.getAllFunctions();
Expand All @@ -102,7 +99,7 @@ class Sentry {
return BbPromise.map(allFunctions, functionName => this._serverless.service.getFunction(functionName))
.filter(functionObject => {
// Check if function should be instrumented
return (_.get(functionObject, "sentry", true) === true);
return (_.get(functionObject, "sentry", true) !== false);
})
.then(functionObjects => {
if (!functionObjects.length) {
Expand All @@ -114,7 +111,11 @@ class Sentry {
}

instrumentFunction(functionObject) {
const sentryConfig = _.assign({}, this.sentry, _.get(functionObject, "sentry"));
const sentryConfig = _.clone(this.sentry);
const localConfig = _.get(functionObject, "sentry");
if (_.isPlainObject(localConfig)) {
_.assign(sentryConfig, localConfig);
}

if (_.has(sentryConfig, "dsn")) {
_.set(functionObject, "environment.SENTRY_DSN", sentryConfig.dsn);
Expand Down

0 comments on commit f4b160f

Please sign in to comment.