The community-maintained successor to ngx-segment-analytics. This library updates the original codebase to support Angular 20+ (including v21+) while preserving the exact same API.
npm install ngx-segment-communityIf you are upgrading from the abandoned ngx-segment-analytics package, the
process is a simple drop-in replacement.
- Uninstall the old library:
npm uninstall ngx-segment-analytics
- Install the new library:
npm install ngx-segment-community
- Update your imports: Perform a global find-and-replace in your IDE:
- Find:
from 'ngx-segment-analytics' - Replace:
from 'ngx-segment-community'
The API is identical to the original library.
In your app.config.ts (or app.module.ts):
import { SegmentModule } from "ngx-segment-community";
export const appConfig: ApplicationConfig = {
providers: [
importProvidersFrom(
SegmentModule.forRoot({
apiKey: "YOUR_SEGMENT_WRITE_KEY",
}),
),
],
};Inject SegmentService into your components:
import { Component, inject } from '@angular/core';
import { SegmentService } from 'ngx-segment-community';
@Component({ ... })
export class AppComponent {
private segment = inject(SegmentService);
trackUser() {
this.segment.track('Button Clicked', {
button_name: 'signup_header'
});
}
}MIT © [Behnam Sajadifar] (Based on work by OpenDecide)