Skip to content

Segment Analytics for Angular 20+. A continuation of work from `ngx-segment-analytics`.

License

Notifications You must be signed in to change notification settings

behdi/ngx-segment-community

Repository files navigation

ngx-segment-community

npm version MIT License

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.

📦 Installation

npm install ngx-segment-community

🔄 Migration from ngx-segment-analytics

If you are upgrading from the abandoned ngx-segment-analytics package, the process is a simple drop-in replacement.

  1. Uninstall the old library:
npm uninstall ngx-segment-analytics
  1. Install the new library:
npm install ngx-segment-community
  1. Update your imports: Perform a global find-and-replace in your IDE:
  • Find: from 'ngx-segment-analytics'
  • Replace: from 'ngx-segment-community'

🚀 Usage

The API is identical to the original library.

1. Import the Module

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",
      }),
    ),
  ],
};

2. Track Events

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'
    });
  }
}

📄 License

MIT © [Behnam Sajadifar] (Based on work by OpenDecide)

About

Segment Analytics for Angular 20+. A continuation of work from `ngx-segment-analytics`.

Resources

License

Stars

Watchers

Forks

Packages

No packages published