
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
ngx-segment-analytics
Advanced tools
This Angular module provides an API for Segment using the analytics.js
official library.
To install this library, run:
$ npm install --save ngx-segment-analytics
Add the SegmentModule
to your Angular AppModule
:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
// Import the Segment module
import { SegmentModule } from 'ngx-segment-analytics';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
// Segment Importation
SegmentModule.forRoot({ apiKey: 'YOUR_WRITE_APIKEY', debug: true, loadOnInitialization: true })
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
You can use the SegmentService
in any constructor as a injected service :
import { Component, OnInit } from '@angular/core';
import { SegmentService } from 'ngx-segment-analytics';
@Component({
selector: 'hero',
templateUrl: './hero.component.html',
styleUrls: ['./hero.component.css']
})
export class HeroComponent implements OnInit {
constructor(private segment: SegmentService) { }
public ngOnInit() {
this.segment.track('load an hero')
.then(() => console.log("Event sended"));
}
}
A full documentation is available here
This API is compatible with analytics.js
but returns Promises
instead of taking callbacks
in parameters.
load(apiKey: string, options: any);
get plugins: {[pluginName :string]: SegmentPlugin};
identify(userId?: string, traits?: any, options?: any): Promise<SegmentService>;
track(event: string, properties?: any, options?: any): Promise<SegmentService>;
page(category?: string, name?: string, properties?: any, options?: any): Promise<SegmentService>;
group(groupId: string, traits?: any): Promise<SegmentService>;
alias(userId: string, previousId?: string, options?: any): Promise<SegmentService>;
ready(): Promise<SegmentService>;
user(): any;
id(): any;
traits(): any;
reset(): void;
debug(enabled?: boolean): void;
on(method: string, callback: (event?: string, properties?: any, options?: any) => any): void;
trackLink(elements: HTMLElement | HTMLElement[], event: string | Function, properties?: Object | Function): void;
trackForm(forms: HTMLElement | HTMLElement[], event: string | Function, properties?: Object | Function): void;
timeout(timeout: number): void;
To lint all *.ts
files:
$ npm run lint
To generate all *.js
, *.d.ts
and *.metadata.json
files:
$ npm run build
To publish on npmjs registry :
$ npm publish dist
MIT ©2017 OpenDecide
FAQs
Segment Analytics for Angular
The npm package ngx-segment-analytics receives a total of 2,807 weekly downloads. As such, ngx-segment-analytics popularity was classified as popular.
We found that ngx-segment-analytics demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.