@grandgular/logrocket-angular
v0.1.0
Published
Angular 18–21 SSR-safe DI companion for the official LogRocket Web SDK: provideLogRocket, LogRocketService, privacy helpers, optional user-flow labels, and @grandgular/logrocket-angular/testing (community-maintained).
Maintainers
Readme
@grandgular/logrocket-angular
Community-maintained companion to the official logrocket Web SDK (not an official LogRocket product). Same integration idea as logrocket-react: install the Web SDK, initialize recording, then use Angular helpers—provideLogRocket for standalone/DI wiring, LogRocketService, privacy directives, optional user-flow labels (data-lr-name), typed init options, sanitizers, and @grandgular/logrocket-angular/testing for no-op DI in unit tests. SSR-safe: the adapter does not load the SDK on the server.
Full documentation (recipes, consent/CMP, lazy routes, troubleshooting): repository README.
Install
npm add @grandgular/logrocket-angular logrocketPeer dependencies: @angular/core, @angular/common, rxjs, logrocket.
Quickstart
// app.config.ts
import { ApplicationConfig } from '@angular/core';
import { provideLogRocket } from '@grandgular/logrocket-angular';
export const appConfig: ApplicationConfig = {
providers: [
provideLogRocket({
appId: 'your/app-id',
enabled: !['localhost'].includes(location.hostname),
privacy: { preset: 'balanced' },
initOptions: {
release: '1.2.3',
shouldCaptureIP: false,
},
}),
],
};Async config factory:
provideLogRocket(async () => {
const cfg = await fetch('/api/logrocket-config').then((r) => r.json());
return {
appId: cfg.appId,
enabled: cfg.enabled,
initOptions: { release: cfg.release },
};
});For manual init after consent, use initMode: 'manual' and call inject(LogRocketService).init() when ready—see the full README.
Compatibility
| | Intended range |
| --- | --- |
| Angular | >=18 <22 (see peerDependencies in this package) |
| logrocket (Web SDK) | ^8 |
| Node (consumers / tooling) | >=20 |
Testing (@grandgular/logrocket-angular/testing)
import { TestBed } from '@angular/core/testing';
import { provideNoOpLogRocket } from '@grandgular/logrocket-angular/testing';
beforeEach(() => {
TestBed.configureTestingModule({
providers: [provideNoOpLogRocket()],
});
});Security & support
- Security: SECURITY.md
- Issues: GitHub Issues
License
MIT
