@stacksee/analytics 0.5.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/readme.md CHANGED
@@ -5,6 +5,7 @@ A highly typed, zero-dependency, provider-agnostic analytics library for TypeScr
5
5
  ## Table of Contents
6
6
 
7
7
  - [Features](#features)
8
+ - [Providers](#providers)
8
9
  - [Installation](#installation)
9
10
  - [Quick Start](#quick-start)
10
11
  - [1. Define Your Events](#1-define-your-events)
@@ -44,6 +45,35 @@ A highly typed, zero-dependency, provider-agnostic analytics library for TypeScr
44
45
  - 🌎 **Edge ready**: The server client is compatible with edge runtime (e.g. Cloudflare Workers, Vercel Edge functions)
45
46
  - 🔧 **Extensible**: Simple interface to add new providers
46
47
 
48
+ ## Providers
49
+
50
+ The library includes built-in support for popular analytics services, with more coming soon:
51
+
52
+ ### Official Providers
53
+
54
+ | Provider | Type | Documentation |
55
+ |----------|------|---------------|
56
+ | **PostHog** | Product Analytics | [docs/providers/posthog.md](./docs/providers/posthog.md) |
57
+ | **Bento** | Email Marketing & Events | [docs/providers/bento.md](./docs/providers/bento.md) |
58
+ | **Pirsch** | Privacy-Focused Web Analytics | [docs/providers/pirsch.md](./docs/providers/pirsch.md) |
59
+
60
+ ### Community & Custom Providers
61
+
62
+ Want to use a different analytics service? Check out our guide:
63
+
64
+ **[Creating Custom Providers →](./docs/providers/custom-providers.md)**
65
+
66
+ You can easily create providers for:
67
+ - Google Analytics
68
+ - Mixpanel
69
+ - Amplitude
70
+ - Segment
71
+ - Customer.io
72
+ - Loops
73
+ - Any analytics service with a JavaScript SDK
74
+
75
+ **[View all provider documentation →](./docs/providers/)**
76
+
47
77
  ## Installation
48
78
 
49
79
  ```bash
@@ -51,8 +81,16 @@ pnpm install @stacksee/analytics
51
81
 
52
82
  # For PostHog support
53
83
  pnpm install posthog-js posthog-node
84
+
85
+ # For Bento support (server-side only)
86
+ pnpm install @bentonow/bento-node-sdk
87
+
88
+ # For Pirsch support
89
+ pnpm install pirsch-sdk
54
90
  ```
55
91
 
92
+ > **See also:** [Provider Documentation](./docs/providers/) for detailed setup guides for each provider.
93
+
56
94
  ## Quick Start
57
95
 
58
96
  ### 1. Define Your Events
@@ -705,32 +743,21 @@ export const appEvents = {
705
743
 
706
744
  ### Adding Custom Providers
707
745
 
708
- Implement the `AnalyticsProvider` interface to add support for other analytics services:
746
+ Want to integrate with a different analytics service? See our comprehensive guide:
747
+
748
+ **[Creating Custom Providers →](./docs/providers/custom-providers.md)**
749
+
750
+ Quick example:
709
751
 
710
752
  ```typescript
711
753
  import { BaseAnalyticsProvider, BaseEvent, EventContext } from '@stacksee/analytics';
712
754
 
713
755
  export class GoogleAnalyticsProvider extends BaseAnalyticsProvider {
714
756
  name = 'GoogleAnalytics';
715
- private measurementId: string;
716
-
717
- constructor(config: { measurementId: string; debug?: boolean; enabled?: boolean }) {
718
- super({ debug: config.debug, enabled: config.enabled });
719
- this.measurementId = config.measurementId;
720
- }
721
-
722
- async initialize(): Promise<void> {
723
- // Initialize GA
724
- }
725
-
726
- track(event: BaseEvent, context?: EventContext): void {
727
- // Send event to GA
728
- }
729
-
730
- identify(userId: string, traits?: Record<string, unknown>): void {
731
- // Set user properties in GA
732
- }
733
757
 
758
+ async initialize(): Promise<void> { /* Initialize GA */ }
759
+ track(event: BaseEvent, context?: EventContext): void { /* Track event */ }
760
+ identify(userId: string, traits?: Record<string, unknown>): void { /* Identify user */ }
734
761
  // ... implement other required methods
735
762
  }
736
763
  ```
@@ -738,9 +765,9 @@ export class GoogleAnalyticsProvider extends BaseAnalyticsProvider {
738
765
  Then use it as a plugin in your configuration:
739
766
 
740
767
  ```typescript
741
- const analytics = await createClientAnalytics<typeof AppEvents>({
768
+ const analytics = createClientAnalytics<typeof AppEvents>({
742
769
  providers: [
743
- new PostHogClientProvider({ apiKey: 'xxx' }),
770
+ new PostHogClientProvider({ token: 'xxx' }),
744
771
  new GoogleAnalyticsProvider({ measurementId: 'xxx' })
745
772
  ]
746
773
  });