{"id":29259427,"url":"https://github.com/th3n00bc0d3r/ngx-amplitude","last_synced_at":"2026-06-12T20:32:27.564Z","repository":{"id":262620989,"uuid":"887836464","full_name":"th3n00bc0d3r/ngx-amplitude","owner":"th3n00bc0d3r","description":"`ngx-amplitude` is an Angular library that provides an easy-to-use interface for integrating [Amplitude](https://amplitude.com) analytics into your Angular 18+ standalone applications. It includes a global initialization module and a service for logging events.","archived":false,"fork":false,"pushed_at":"2024-11-13T11:20:56.000Z","size":138,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-24T00:46:09.751Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/th3n00bc0d3r.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-13T11:19:54.000Z","updated_at":"2025-07-24T14:37:49.000Z","dependencies_parsed_at":"2024-11-13T12:26:11.378Z","dependency_job_id":"40522b2d-3951-423b-8aa7-8944596b7764","html_url":"https://github.com/th3n00bc0d3r/ngx-amplitude","commit_stats":null,"previous_names":["th3n00bc0d3r/ngx-amplitube"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/th3n00bc0d3r/ngx-amplitude","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/th3n00bc0d3r%2Fngx-amplitude","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/th3n00bc0d3r%2Fngx-amplitude/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/th3n00bc0d3r%2Fngx-amplitude/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/th3n00bc0d3r%2Fngx-amplitude/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/th3n00bc0d3r","download_url":"https://codeload.github.com/th3n00bc0d3r/ngx-amplitude/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/th3n00bc0d3r%2Fngx-amplitude/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34262155,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-12T02:00:06.859Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-04T07:00:51.756Z","updated_at":"2026-06-12T20:32:27.557Z","avatar_url":"https://github.com/th3n00bc0d3r.png","language":"HTML","funding_links":[],"categories":["Development Utilities"],"sub_categories":["Analytics"],"readme":"# ngx-amplitude\n\n`ngx-amplitude` is an Angular library that provides an easy-to-use interface for integrating [Amplitude](https://amplitude.com) analytics into your Angular 18+ standalone applications. It includes a global initialization module and a service for logging events.\n\n## Features\n- **Easy Setup**: Initialize Amplitude with a single line of configuration.\n- **Environment Check**: Automatically initializes Amplitude only in production environments.\n- **Event Logging**: Use the `AmplitudeService` to log events with custom properties.\n- **Standalone Configuration**: Supports Angular's standalone setup with a dedicated `provideAmplitude()` function.\n\n---\n\n## Installation\n\nTo install `ngx-amplitude` in your Angular project, run:\n\n```bash\nnpm install ngx-amplitude @amplitude/analytics-browser\n```\n\n---\n\n## Usage\n\n### 1a. Import `AmplitudeModule` and Initialize Amplitude for Standalone\n\nFor Angular standalone applications, use the `provideAmplitude()` function to initialize Amplitude globally:\n\n#### In `app.config.ts` or `maint.ts`:\n\n```typescript\nimport { bootstrapApplication } from '@angular/platform-browser';\nimport { provideRouter } from '@angular/router';\nimport { AppComponent } from './app/app.component';\nimport { provideAmplitude } from 'ngx-amplitude';\n\nbootstrapApplication(AppComponent, {\n  providers: [\n    provideRouter([]),\n    provideAmplitude('YOUR_API_KEY') // Replace 'YOUR_API_KEY' with your Amplitude API key\n  ]\n}).catch(err =\u003e console.error(err));\n```\n\n- **Note**: Replace `'YOUR_API_KEY'` with your actual Amplitude API key.\n- **Environment Check**: The `provideAmplitude()` function ensures that Amplitude is only initialized in production mode, based on the `environment.production` setting.\n\n---\n\n### 1b. Import `AmplitudeModule` and Initialize Amplitude for non-standalone\n\nImport `AmplitudeModule` in your `main.ts` file and provide your Amplitude API key:\n\n```typescript\nimport { bootstrapApplication } from '@angular/platform-browser';\nimport { provideRouter } from '@angular/router';\nimport { AppComponent } from './app/app.component';\nimport { AmplitudeModule } from 'ngx-amplitude';\n\nbootstrapApplication(AppComponent, {\n  providers: [\n    provideRouter([]),\n    AmplitudeModule.forRoot('YOUR_API_KEY') // Replace 'YOUR_API_KEY' with your Amplitude API key\n  ]\n}).catch(err =\u003e console.error(err));\n```\n\n\n### 2. Use `AmplitudeService` to Log Events\n\nInject `AmplitudeService` into your components or services and use it to log events:\n\n```typescript\nimport { Component } from '@angular/core';\nimport { AmplitudeService } from 'ngx-amplitude';\n\n@Component({\n  selector: 'app-root',\n  templateUrl: './app.component.html',\n  styleUrls: ['./app.component.css'],\n  standalone: true,\n})\nexport class AppComponent {\n  constructor(private amplitudeService: AmplitudeService) {}\n\n  trackButtonClick(): void {\n    this.amplitudeService.logEvent('Button Clicked', { buttonName: 'Submit' });\n  }\n}\n```\n\n### Logging Events\n- **logEvent(eventName: string, eventProperties?: Record\u003cstring, any\u003e)**:\n  - `eventName`: The name of the event you want to log.\n  - `eventProperties`: An optional object containing properties to attach to the event.\n\n---\n\n\n## Development\n\n### Building the Library\n\nTo build the library, run:\n\n```bash\nng build ngx-amplitude\n```\n\n### Publishing to npm\n\n1. Navigate to the `dist/ngx-amplitude` folder:\n   ```bash\n   cd dist/ngx-amplitude\n   ```\n2. Publish the library:\n   ```bash\n   npm publish --access public\n   ```\n\n---\n\n## Contributing\n\nContributions are welcome! If you have suggestions or bug reports, please open an issue or create a pull request.\n\n---\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n---\n\n## Acknowledgments\n\n- [Amplitude Analytics](https://amplitude.com) for providing the analytics platform.\n- The Angular community for their continued support and contributions.\n\n---\n\n### About `provideAmplitude()`\n\nThe `provideAmplitude()` function is a custom provider designed for Angular standalone applications. It initializes Amplitude globally and conditionally, based on the `environment.production` flag.\n\n- **Usage**: Add `provideAmplitude('YOUR_API_KEY')` to your `providers` array in `main.ts`.\n- **Environment Check**: Ensures that analytics tracking is only enabled in production, preventing unnecessary data collection during development.\n\nBy using `provideAmplitude()`, you can seamlessly integrate Amplitude analytics into your Angular 18+ standalone projects with a clean and efficient setup.\n\n---","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fth3n00bc0d3r%2Fngx-amplitude","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fth3n00bc0d3r%2Fngx-amplitude","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fth3n00bc0d3r%2Fngx-amplitude/lists"}