Skip to content

Commit 7e06dfc

Browse files
committed
chore: improve readme
1 parent 22fa88d commit 7e06dfc

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

README.md

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -90,40 +90,29 @@ export const environment = {
9090

9191
For Angular applications using standalone components, import and configure BugSplat directly in your `main.ts` file:
9292

93+
[main.ts](https://github.com/BugSplat-Git/bugsplat-ng/blob/22fa88dc642294f1a6240a0a1bf4b4acd16f727d/projects/my-angular-crasher/src/main.ts#L6-L29)
9394
```typescript
94-
import { BugSplatLogger, BugSplatLogLevel, BugSplatModule } from 'bugsplat-ng';
95+
import { BugSplatModule } from 'bugsplat-ng';
9596

9697
bootstrapApplication(AppComponent, {
9798
providers: [
98-
// Required
9999
importProvidersFrom(
100100
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+
)
111102
]
112103
})
113104
.catch(err => console.log(err));
114105
```
115106

116107
Alternatively, add an import for `BugSplatModule` to your `AppModule`:
117108

118-
[app.module.ts](hhttps://github.com/BugSplat-Git/bugsplat-ng/blob/8c12d9b3544f2b618491467e6c40d84b6139eb2a/src/app/app.module.ts#L4-31)
119109
```typescript
120110
import { BugSplatModule } from 'bugsplat-ng';
121111

122112
@NgModule({
123113
imports: [
124114
BugSplatModule.initializeApp(environment.bugsplat)
125-
],
126-
...
115+
]
127116
})
128117
```
129118

@@ -174,43 +163,50 @@ BugSplat.getObservable(): Observable<BugSplatPostEvent>; // Observable that emit
174163
async BugSplat.post(error): Promise<void>; // Post an Error object to BugSplat manually from within a try/catch
175164
```
176165

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`:
178167

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)
180169
```typescript
181-
import { ErrorHandler, NgModule } from '@angular/core';
170+
import { BugSplatModule } from 'bugsplat-ng';
171+
import { MyAngularErrorHandler } from './app/my-angular-error-handler';
182172

183-
@NgModule({
173+
bootstrapApplication(AppComponent, {
184174
providers: [
175+
importProvidersFrom(
176+
BugSplatModule.initializeApp(environment.bugsplat)
177+
),
185178
{
186179
provide: ErrorHandler,
187180
useClass: MyAngularErrorHandler
188181
}
189182
]
190-
...
191183
})
184+
.catch(err => console.log(err));
192185
```
193186

194187
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:
195188

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)
197190
```typescript
198-
import { ErrorHandler, NgModule } from '@angular/core';
199191
import { BugSplatLogger, BugSplatLogLevel, BugSplatModule } from 'bugsplat-ng';
192+
import { MyAngularErrorHandler } from './app/my-angular-error-handler';
200193

201-
@NgModule({
194+
bootstrapApplication(AppComponent, {
202195
providers: [
196+
importProvidersFrom(
197+
BugSplatModule.initializeApp(environment.bugsplat)
198+
),
203199
{
204200
provide: ErrorHandler,
205-
useClass: BugSplatErrorHandler
201+
useClass: MyAngularErrorHandler
206202
},
207203
{
208204
provide: BugSplatLogger,
209205
useValue: new BugSplatLogger(BugSplatLogLevel.Log)
210206
}
211-
],
212-
...
207+
]
213208
})
209+
.catch(err => console.log(err));
214210
```
215211

216212
## 🗺 Source Maps

0 commit comments

Comments
 (0)