@strapi/plugin-sentry 4.6.0-beta.1 → 4.6.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +32 -12
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -68,10 +68,7 @@ try {
68
68
  // Your code here
69
69
  } catch (error) {
70
70
  // Either send a simple error
71
- strapi
72
- .plugin('sentry')
73
- .service('sentry')
74
- .sendError(error);
71
+ strapi.plugin('sentry').service('sentry').sendError(error);
75
72
 
76
73
  // Or send an error with a customized Sentry scope
77
74
  strapi
@@ -92,15 +89,39 @@ Use it if you need direct access to the Sentry instance, which should already al
92
89
  **Example**
93
90
 
94
91
  ```js
95
- const sentryInstance = strapi
96
- .plugin('sentry')
97
- .service('sentry')
98
- .getInstance();
92
+ const sentryInstance = strapi.plugin('sentry').service('sentry').getInstance();
93
+ ```
94
+
95
+ ## Disabling for non-production environments
96
+
97
+ If the `dsn` property is set to a nil value (`null` or `undefined`) while `enabled` is true, the Sentry plugin will be available to use in the running Strapi instance, but the service will not actually send errors to Sentry. That allows you to write code that runs on every environment without additional checks, but only send errors to Sentry in production.
98
+
99
+ When you start Strapi with a nil `dsn` config property, the plugin will print a warning:
100
+ `info: @strapi/plugin-sentry is disabled because no Sentry DSN was provided`
101
+
102
+ You can make use of that by using the `env` utility to set the `dsn` config property depending on the environment.
103
+
104
+ **Example**
105
+
106
+ `./config/plugins.js`
107
+
108
+ ```js
109
+ module.exports = ({ env }) => ({
110
+ // ...
111
+ sentry: {
112
+ enabled: true,
113
+ config: {
114
+ // Only set `dsn` property in production
115
+ dsn: env('NODE_ENV') === 'production' ? env('SENTRY_DSN') : null,
116
+ },
117
+ },
118
+ // ...
119
+ });
99
120
  ```
100
121
 
101
- ## Disabling
122
+ ## Disabling altogether
102
123
 
103
- This plugin can be disabled in the plugins configuration file. With the `env` utility, it is also possible to disable it depending on the environment.
124
+ Like every other plugin, you can also disable this plugin in the plugins configuration file. This will cause `strapi.plugins('sentry')` to return undefined.
104
125
 
105
126
  **Example**
106
127
 
@@ -110,8 +131,7 @@ This plugin can be disabled in the plugins configuration file. With the `env` ut
110
131
  module.exports = ({ env }) => ({
111
132
  // ...
112
133
  sentry: {
113
- // Only enable Sentry in production
114
- enabled: env('NODE_ENV') === 'production',
134
+ enabled: false,
115
135
  },
116
136
  // ...
117
137
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/plugin-sentry",
3
- "version": "4.6.0-beta.1",
3
+ "version": "4.6.0-beta.2",
4
4
  "description": "Send Strapi error events to Sentry",
5
5
  "repository": {
6
6
  "type": "git",
@@ -39,5 +39,5 @@
39
39
  "description": "Send Strapi error events to Sentry.",
40
40
  "kind": "plugin"
41
41
  },
42
- "gitHead": "2c0bcabdf0bf2a269fed50c6f23ba777845968a0"
42
+ "gitHead": "b852090f931cd21868c4016f24db2f9fdfc7a7ab"
43
43
  }