@@ -90,40 +90,29 @@ export const environment = {
90
90
91
91
For Angular applications using standalone components, import and configure BugSplat directly in your ` main.ts ` file:
92
92
93
+ [ main.ts] ( https://github.com/BugSplat-Git/bugsplat-ng/blob/22fa88dc642294f1a6240a0a1bf4b4acd16f727d/projects/my-angular-crasher/src/main.ts#L6-L29 )
93
94
``` typescript
94
- import { BugSplatLogger , BugSplatLogLevel , BugSplatModule } from ' bugsplat-ng' ;
95
+ import { BugSplatModule } from ' bugsplat-ng' ;
95
96
96
97
bootstrapApplication (AppComponent , {
97
98
providers: [
98
- // Required
99
99
importProvidersFrom (
100
100
BugSplatModule .initializeApp (environment .bugsplat )
101
- ),
102
- // Optional
103
- {
104
- provide: ErrorHandler ,
105
- useClass: MyAngularErrorHandler
106
- },
107
- {
108
- provide: BugSplatLogger ,
109
- useValue: new BugSplatLogger (BugSplatLogLevel .info , console )
110
- }
101
+ )
111
102
]
112
103
})
113
104
.catch (err => console .log (err ));
114
105
```
115
106
116
107
Alternatively, add an import for ` BugSplatModule ` to your ` AppModule ` :
117
108
118
- [ app.module.ts] ( hhttps://github.com/BugSplat-Git/bugsplat-ng/blob/8c12d9b3544f2b618491467e6c40d84b6139eb2a/src/app/app.module.ts#L4-31 )
119
109
``` typescript
120
110
import { BugSplatModule } from ' bugsplat-ng' ;
121
111
122
112
@NgModule ({
123
113
imports: [
124
114
BugSplatModule .initializeApp (environment .bugsplat )
125
- ],
126
- ...
115
+ ]
127
116
})
128
117
```
129
118
@@ -174,43 +163,50 @@ BugSplat.getObservable(): Observable<BugSplatPostEvent>; // Observable that emit
174
163
async BugSplat .post (error ): Promise < void > ; // Post an Error object to BugSplat manually from within a try/catch
175
164
```
176
165
177
- In your AppModule's NgModule definition , add a provider for your new ErrorHandler:
166
+ In either ` bootstrapApplication ` or ` NgModule ` , add a provider for your new ` ErrorHandler ` :
178
167
179
- [ app.module. ts] ( https://github.com/BugSplat-Git/bugsplat-ng/blob/master/src/app/app.module.ts )
168
+ [ main. ts] ( https://github.com/BugSplat-Git/bugsplat-ng/blob/22fa88dc642294f1a6240a0a1bf4b4acd16f727d/projects/my-angular-crasher/src/main.ts#L6-L29 )
180
169
``` typescript
181
- import { ErrorHandler , NgModule } from ' @angular/core' ;
170
+ import { BugSplatModule } from ' bugsplat-ng' ;
171
+ import { MyAngularErrorHandler } from ' ./app/my-angular-error-handler' ;
182
172
183
- @ NgModule ( {
173
+ bootstrapApplication ( AppComponent , {
184
174
providers: [
175
+ importProvidersFrom (
176
+ BugSplatModule .initializeApp (environment .bugsplat )
177
+ ),
185
178
{
186
179
provide: ErrorHandler ,
187
180
useClass: MyAngularErrorHandler
188
181
}
189
182
]
190
- ...
191
183
})
184
+ .catch (err => console .log (err ));
192
185
```
193
186
194
187
You can also configure BugSplat's logging preferences and provide your own logging implementation. Create a provider for BugSplatLogger with useValue set to a new instance of BugSplatLogger. Pass one of the BugSplatLogLevel options as the first parameter to BugSplatLogger. You can provide an instance of your own custom logger as the second parameter granted it has an error, warn, info, and log methods. If no custom logger is provided, the console will be used:
195
188
196
- [ app.module. ts] ( https://github.com/BugSplat-Git/bugsplat-ng/blob/master/src/app/app.module.ts )
189
+ [ main. ts] ( https://github.com/BugSplat-Git/bugsplat-ng/blob/22fa88dc642294f1a6240a0a1bf4b4acd16f727d/projects/my-angular-crasher/src/main.ts#L6-L29 )
197
190
``` typescript
198
- import { ErrorHandler , NgModule } from ' @angular/core' ;
199
191
import { BugSplatLogger , BugSplatLogLevel , BugSplatModule } from ' bugsplat-ng' ;
192
+ import { MyAngularErrorHandler } from ' ./app/my-angular-error-handler' ;
200
193
201
- @ NgModule ( {
194
+ bootstrapApplication ( AppComponent , {
202
195
providers: [
196
+ importProvidersFrom (
197
+ BugSplatModule .initializeApp (environment .bugsplat )
198
+ ),
203
199
{
204
200
provide: ErrorHandler ,
205
- useClass: BugSplatErrorHandler
201
+ useClass: MyAngularErrorHandler
206
202
},
207
203
{
208
204
provide: BugSplatLogger ,
209
205
useValue: new BugSplatLogger (BugSplatLogLevel .Log )
210
206
}
211
- ],
212
- ...
207
+ ]
213
208
})
209
+ .catch (err => console .log (err ));
214
210
```
215
211
216
212
## 🗺 Source Maps
0 commit comments