Skip to content

Commit

Permalink
Add Sentry (mainmatter#417)
Browse files Browse the repository at this point in the history
* add sentry

* don't enable sentry locally
  • Loading branch information
marcoow authored May 9, 2019
1 parent d8bb2e6 commit 463ddd3
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ node_modules
dist
.eslintcache
package-lock.json
.netlify/

# YARD artifacts
.yardoc
Expand Down
33 changes: 33 additions & 0 deletions lib/sentry/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'use strict';

module.exports = {
name: require('./package').name,

isDevelopingAddon() {
return true;
},

contentFor(type) {
if (type === 'body-pre-app-bundle') {
let { SENTRY_DSN, SENTRY_ENV } = process.env;
if (SENTRY_DSN) {
let options = {
dsn: SENTRY_DSN,
};
if (SENTRY_ENV) {
options.environment = SENTRY_ENV;
}
return `
<script src="https://browser.sentry-cdn.com/5.2.0/bundle.min.js" crossorigin="anonymous"></script>
<script>
Sentry.init(${JSON.stringify(options)});
</script>
`;
} else {
return '';
}
} else {
return '';
}
},
};
6 changes: 6 additions & 0 deletions lib/sentry/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "sentry",
"keywords": [
"ember-addon"
]
}
11 changes: 11 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[build]
command = "yarn run build"
publish = "dist"

[context.production.environment]
SENTRY_DSN = "https://[email protected]/1456103"
SENTRY_ENV = "production"

[context.deploy-preview.environment]
SENTRY_DSN = "https://[email protected]/1456103"
SENTRY_ENV = "deploy-preview"
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,15 @@
"paths": [
"lib/generate-blog-components",
"lib/generate-calendar",
"lib/inject-routes"
"lib/inject-routes",
"lib/sentry"
]
},
"prettier": {
"printWidth": 120,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all"
}
},
"dependencies": {}
}
1 change: 1 addition & 0 deletions src/ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
{{content-for "body"}}

<div id="app"></div>
{{content-for "body-pre-app-bundle"}}
<script src="{{rootURL}}app.js"></script>

{{content-for "body-footer"}}
Expand Down

0 comments on commit 463ddd3

Please sign in to comment.