|
1 | 1 | # Ember-cli-deploy-sentry |
2 | 2 |
|
3 | | -> An ember-cli-deploy-plugin to upload javascript sourcemaps to sentry. |
| 3 | +> An ember-cli-deploy-plugin to upload javascript sourcemaps to [Sentry][1]. |
4 | 4 |
|
5 | 5 | <hr/> |
6 | 6 | **WARNING: This plugin is only compatible with ember-cli-deploy versions >= 0.5.0** |
7 | | -WIP: will push updates soon |
8 | 7 | <hr/> |
9 | 8 |
|
| 9 | +## What is an ember-cli-deploy plugin? |
10 | 10 |
|
| 11 | +A plugin is an addon that can be executed as a part of the ember-cli-deploy pipeline. A plugin will implement one or more of the ember-cli-deploy's pipeline hooks. |
| 12 | + |
| 13 | +For more information on what plugins are and how they work, please refer to the [Plugin Documentation][10]. |
| 14 | + |
| 15 | +## Quick Start |
| 16 | +To get up and running quickly, do the following: |
| 17 | + |
| 18 | +- Ensure [ember-cli-deploy-build][11] is installed and configured. |
| 19 | + |
| 20 | +- Install this plugin |
| 21 | + |
| 22 | +```bash |
| 23 | +$ ember install ember-cli-deploy-sentry |
| 24 | +``` |
| 25 | + |
| 26 | +- Place the following configuration into `config/deploy.js` |
| 27 | + |
| 28 | +```javascript |
| 29 | +ENV.sentry { |
| 30 | + publicUrl: 'https://your.awesome.site', |
| 31 | + sentryUrl: 'https://sentry.your.awesome.site', |
| 32 | + sentryOrganizationSlug: 'AwesomeOrg', |
| 33 | + sentryProjectSlug: 'AwesomeProject', |
| 34 | + sentryApiKey: 'awesomeApiKey' |
| 35 | +} |
| 36 | +``` |
| 37 | +- Integrate [raven-js][2] in your page |
| 38 | + |
| 39 | +It's important to initialize the client with `release` as the `revisionKey`. |
| 40 | +You will probably need to either write the `revisionKey` into your `index.html` file at build time or when serving it. |
| 41 | + |
| 42 | +For example add this to your `index.html` and dynamically replace the `$REVISION` string with `revisionKey`: |
| 43 | +```html |
| 44 | +<meta name="revision" content="$REVISION"> |
| 45 | +``` |
| 46 | + |
| 47 | +Then when you setup [raven-js][2] you can retrieve it like so: |
| 48 | + |
| 49 | +```javascript |
| 50 | +Raven.config({ |
| 51 | + release: $("meta[name='revision']").attr('content') |
| 52 | +}); |
| 53 | +``` |
| 54 | + |
| 55 | +- Run the pipeline |
| 56 | + |
| 57 | +```bash |
| 58 | +$ ember deploy |
| 59 | +``` |
| 60 | + |
| 61 | +## Installation |
| 62 | +Run the following command in your terminal: |
| 63 | + |
| 64 | +```bash |
| 65 | +ember install ember-cli-deploy-sentry |
| 66 | +``` |
| 67 | + |
| 68 | +For general information on how to setup [Sentry][1] and [raven-js][2] you probably want to check out the official [Sentry Documentation][3] especially on [Sourcemaps][4]. |
| 69 | + |
| 70 | +## ember-cli-deploy Hooks Implemented |
| 71 | + |
| 72 | +For detailed information on what plugin hooks are and how they work, please refer to the [Plugin Documentation][10]. |
| 73 | + |
| 74 | +- `configure` |
| 75 | +- `upload` |
| 76 | +- `didDeploy` |
| 77 | + |
| 78 | +## Configuration Options |
| 79 | + |
| 80 | +For detailed information on how configuration of plugins works, please refer to the [Plugin Documentation][10]. |
| 81 | + |
| 82 | +### publicUrl |
| 83 | + |
| 84 | +The public url to the root of your website. |
| 85 | + |
| 86 | +*Required* |
| 87 | + |
| 88 | +### sentryUrl |
| 89 | + |
| 90 | +The url of the sentry installation that `ember-cli-deploy-sentry` shall upload sourcemaps and javascript files to. |
| 91 | +If you are deploying in your local network, keep in mind you might need to use the local hostname/IP address. |
| 92 | + |
| 93 | +*Required* |
| 94 | + |
| 95 | +### sentryOrganizationSlug |
| 96 | + |
| 97 | +The slug of the organization you want to upload sourcemaps for. |
| 98 | +You can specify this in organization settings in sentry. |
| 99 | + |
| 100 | +*Required* |
| 101 | + |
| 102 | +### sentryProjectSlug |
| 103 | + |
| 104 | +The slug of the project you want to upload sourcemaps for. |
| 105 | +You can specify this in project settings in sentry. |
| 106 | + |
| 107 | +*Required* |
| 108 | + |
| 109 | +### sentryApiKey |
| 110 | + |
| 111 | +An api key you can create in your organization settings. Make sure it has the `project:write` privilege. |
| 112 | + |
| 113 | +*Required* |
| 114 | + |
| 115 | +### distDir |
| 116 | + |
| 117 | +The root directory that all files matching the `filePattern` will be uploaded from. By default, this option will use the `distDir` property of the deployment context. |
| 118 | + |
| 119 | +*Default:* `context.distDir` |
| 120 | + |
| 121 | +### didDeployMessage |
| 122 | + |
| 123 | +A message that will be displayed after the distDir has been copied to destDir. |
| 124 | + |
| 125 | +*Default:* |
| 126 | + |
| 127 | +```javascript |
| 128 | + didDeployMessage: function(context){ |
| 129 | + return "Uploaded sourcemaps to sentry release: " |
| 130 | + + this.readConfig('sentryUrl') |
| 131 | + + '/' |
| 132 | + + this.readConfig('sentryOrganizationSlug') |
| 133 | + + '/' |
| 134 | + + this.readConfig('sentryProjectSlug') |
| 135 | + + '/releases/' |
| 136 | + + this.readConfig('revisionKey') |
| 137 | + + '/'; |
| 138 | + } |
| 139 | +``` |
| 140 | + |
| 141 | +### filePattern |
| 142 | + |
| 143 | +`minimatch` expression that is used to determine which files should be uploaded from the `distDir`. |
| 144 | + |
| 145 | +*Default:* `/**/*.{js,map}` |
| 146 | + |
| 147 | +### revisionKey |
| 148 | + |
| 149 | +The revision string that is used to create releases in sentry. |
| 150 | +```javascript |
| 151 | + revisionKey: function(context) { |
| 152 | + return context.revisionData && context.revisionData.revisionKey; |
| 153 | + } |
| 154 | +``` |
| 155 | + |
| 156 | +## Prerequisites |
| 157 | + |
| 158 | +The following properties are expected to be present on the deployment `context` object: |
| 159 | + |
| 160 | +- `distDir` (provided by [ember-cli-deploy-build][11]) |
| 161 | +- `revisionData.revisionKey` (provided by [ember-cli-deploy-revision-data][12]) |
| 162 | + |
| 163 | +## Running Tests |
| 164 | + |
| 165 | +- `npm test` |
| 166 | + |
| 167 | +## TODO |
| 168 | + |
| 169 | +- Tests ... right? |
| 170 | +- use `context.distFiles` from [ember-cli-deploy-build][11] instead globbing distDir again? |
| 171 | +- automatically setup raven-js? If you want this, let me know. |
| 172 | + |
| 173 | +### State |
| 174 | + |
| 175 | +It works. We use it in production at [Hatchet](https://hatchet.is). |
| 176 | + |
| 177 | + |
| 178 | +[1]: https://getsentry.com "Sentry" |
| 179 | +[2]: https://github.com/getsentry/raven-js "raven-js" |
| 180 | +[3]: https://docs.getsentry.com/on-premise/clients/javascript/ "Sentry Documentation for Javascript clients" |
| 181 | +[4]: https://docs.getsentry.com/on-premise/clients/javascript/sourcemaps/ "Sentry Documentation for Javascript Sourcemaps" |
| 182 | + |
| 183 | +[10]: http://ember-cli.github.io/ember-cli-deploy/plugins "Plugin Documentation" |
| 184 | +[11]: https://github.com/zapnito/ember-cli-deploy-build "ember-cli-deploy-build" |
| 185 | +[12]: https://github.com/zapnito/ember-cli-deploy-revision-data "ember-cli-deploy-revision-data" |
0 commit comments