@kitbase/analytics-angular 0.1.6

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 ADDED
@@ -0,0 +1,332 @@
1
+ # @kitbase/analytics-angular
2
+
3
+ Angular integration for the Kitbase Analytics SDK.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @kitbase/analytics-angular
9
+ # or
10
+ pnpm add @kitbase/analytics-angular
11
+ # or
12
+ yarn add @kitbase/analytics-angular
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ### Option 1: Direct — just call `init()`
18
+
19
+ No Angular DI needed. Call `init()` anywhere (e.g. `main.ts`, a component, a service):
20
+
21
+ ```typescript
22
+ import { init } from '@kitbase/analytics-angular';
23
+
24
+ const kitbase = init({ sdkKey: 'your-api-key' });
25
+
26
+ // Track events
27
+ kitbase.track({ channel: 'ui', event: 'Button Clicked' });
28
+
29
+ // Identify users
30
+ kitbase.identify({ userId: 'user-123', traits: { email: 'user@example.com' } });
31
+ ```
32
+
33
+ You can retrieve the instance later with `getInstance()`:
34
+
35
+ ```typescript
36
+ import { getInstance } from '@kitbase/analytics-angular';
37
+
38
+ const kitbase = getInstance();
39
+ kitbase?.track({ channel: 'ui', event: 'Page Loaded' });
40
+ ```
41
+
42
+ ### Option 2: Angular DI — `provideKitbaseAnalytics()` + `inject()`
43
+
44
+ Register the provider in your app config, then inject it in any component or service:
45
+
46
+ ```typescript
47
+ // app.config.ts
48
+ import { ApplicationConfig } from '@angular/core';
49
+ import { provideKitbaseAnalytics } from '@kitbase/analytics-angular';
50
+
51
+ export const appConfig: ApplicationConfig = {
52
+ providers: [
53
+ provideKitbaseAnalytics({
54
+ sdkKey: 'your-sdk-key',
55
+ debug: true,
56
+ }),
57
+ ],
58
+ };
59
+ ```
60
+
61
+ ```typescript
62
+ // component.ts
63
+ import { Component, inject } from '@angular/core';
64
+ import { KitbaseAnalyticsService } from '@kitbase/analytics-angular';
65
+
66
+ @Component({
67
+ selector: 'app-button',
68
+ template: '<button (click)="onClick()">Click me</button>',
69
+ })
70
+ export class ButtonComponent {
71
+ private kitbase = inject(KitbaseAnalyticsService);
72
+
73
+ onClick() {
74
+ this.kitbase.track({
75
+ channel: 'ui',
76
+ event: 'Button Clicked',
77
+ tags: { button_id: 'cta' },
78
+ });
79
+ }
80
+ }
81
+ ```
82
+
83
+ ## Configuration
84
+
85
+ ```typescript
86
+ init({
87
+ // Required
88
+ sdkKey: 'your-api-key',
89
+
90
+ // Optional
91
+ debug: true,
92
+ baseUrl: 'https://api.kitbase.dev',
93
+
94
+ analytics: {
95
+ autoTrackPageViews: true, // track route changes automatically
96
+ autoTrackOutboundLinks: true, // track external link clicks
97
+ autoTrackClicks: true, // track button/link/input clicks + data-kb-track-click
98
+ autoTrackScrollDepth: true, // track max scroll depth per page
99
+ autoTrackVisibility: true, // track visibility duration via data attributes
100
+ autoTrackWebVitals: false, // track Core Web Vitals (LCP, CLS, INP, FCP, TTFB)
101
+ autoDetectFrustration: true, // detect rage clicks and dead clicks
102
+ },
103
+
104
+ offline: {
105
+ enabled: true, // queue events when offline
106
+ maxQueueSize: 1000,
107
+ flushInterval: 30000,
108
+ flushBatchSize: 50,
109
+ maxRetries: 3,
110
+ },
111
+ });
112
+ ```
113
+
114
+ Page views, clicks, outbound links, scroll depth, and visibility duration are tracked automatically by default. The core SDK intercepts `history.pushState`/`popstate`, so no Angular Router integration is needed.
115
+
116
+ ## Data Attribute Events
117
+
118
+ Track events from HTML using data attributes — no JavaScript needed. Works in Angular, React, or vanilla HTML.
119
+
120
+ ### Click Tracking
121
+
122
+ Fire a named event when a user clicks an element:
123
+
124
+ ```html
125
+ <!-- Basic -->
126
+ <button data-kb-track-click="CTA Clicked">Sign Up Now</button>
127
+
128
+ <!-- With custom channel -->
129
+ <button data-kb-track-click="Add to Cart" data-kb-click-channel="ecommerce">
130
+ Add to Cart
131
+ </button>
132
+ ```
133
+
134
+ | Attribute | Required | Default | Description |
135
+ |-----------|----------|---------|-------------|
136
+ | `data-kb-track-click` | Yes | — | Event name to fire |
137
+ | `data-kb-click-channel` | No | `'engagement'` | Channel for the event |
138
+
139
+ Elements with `data-kb-track-click` skip the generic auto-click tracking to avoid double-counting. Disable with `autoTrackClicks: false`.
140
+
141
+ ### Visibility Duration
142
+
143
+ Track how long elements are visible in the viewport:
144
+
145
+ ```html
146
+ <!-- Basic -->
147
+ <section data-kb-track-visibility="Pricing Section Viewed">...</section>
148
+
149
+ <!-- With optional channel and threshold -->
150
+ <div
151
+ data-kb-track-visibility="Hero Banner Viewed"
152
+ data-kb-visibility-channel="marketing"
153
+ data-kb-visibility-threshold="0.5"
154
+ >...</div>
155
+ ```
156
+
157
+ | Attribute | Required | Default | Description |
158
+ |-----------|----------|---------|-------------|
159
+ | `data-kb-track-visibility` | Yes | — | Event name to fire |
160
+ | `data-kb-visibility-channel` | No | `'engagement'` | Channel for the event |
161
+ | `data-kb-visibility-threshold` | No | `0.5` | IntersectionObserver threshold (0–1) |
162
+
163
+ When the element leaves the viewport, navigates away, or is removed from the DOM, the SDK fires an event with `duration_seconds` and `duration_ms` tags.
164
+
165
+ Dynamically added elements (e.g. from Angular `@if` or `*ngIf`) are picked up automatically via MutationObserver. Disable with `autoTrackVisibility: false`.
166
+
167
+ ## Web Vitals
168
+
169
+ Track [Core Web Vitals](https://web.dev/vitals/) by enabling `autoTrackWebVitals`:
170
+
171
+ ```typescript
172
+ init({
173
+ sdkKey: 'your-api-key',
174
+ analytics: {
175
+ autoTrackWebVitals: true,
176
+ },
177
+ });
178
+ ```
179
+
180
+ The SDK collects all 5 metrics (LCP, CLS, INP, FCP, TTFB) and sends them as a single `web_vitals` event. Metrics are sent once per page load with a 30-second timeout. Only collected metrics are included. See the [core SDK README](../core/README.md#web-vitals) for full details.
181
+
182
+ ## API Reference
183
+
184
+ ### Event Tracking
185
+
186
+ | Method | Description |
187
+ |--------|-------------|
188
+ | `track(options)` | Track a custom event |
189
+ | `trackPageView(options?)` | Track a page view |
190
+ | `trackRevenue(options)` | Track a revenue event |
191
+ | `trackOutboundLink(options)` | Track an outbound link click |
192
+ | `trackClick(tags)` | Track a click event |
193
+
194
+ ### User Identification
195
+
196
+ | Method | Description |
197
+ |--------|-------------|
198
+ | `identify(options)` | Identify a user with traits |
199
+ | `getUserId()` | Get the identified user ID |
200
+ | `reset()` | Reset user identity |
201
+
202
+ ### Super Properties
203
+
204
+ | Method | Description |
205
+ |--------|-------------|
206
+ | `register(properties)` | Set super properties (included in all events) |
207
+ | `registerOnce(properties)` | Set super properties only if not already set |
208
+ | `unregister(key)` | Remove a super property |
209
+ | `getSuperProperties()` | Get all super properties |
210
+ | `clearSuperProperties()` | Clear all super properties |
211
+
212
+ ### Time Events
213
+
214
+ | Method | Description |
215
+ |--------|-------------|
216
+ | `timeEvent(eventName)` | Start timing an event |
217
+ | `cancelTimeEvent(eventName)` | Cancel timing an event |
218
+ | `getTimedEvents()` | List all active timed events |
219
+ | `getEventDuration(eventName)` | Get elapsed time in ms |
220
+
221
+ ### Plugin System
222
+
223
+ | Method | Description |
224
+ |--------|-------------|
225
+ | `use(plugin)` | Register a plugin |
226
+ | `getPlugins()` | Get names of all registered plugins |
227
+
228
+ ### Debug
229
+
230
+ | Method | Description |
231
+ |--------|-------------|
232
+ | `setDebugMode(enabled)` | Toggle debug logging |
233
+ | `isDebugMode()` | Check if debug mode is on |
234
+ | `shutdown()` | Shutdown the SDK and cleanup |
235
+ | `getInstance()` | Get the underlying KitbaseAnalytics instance |
236
+
237
+ ## Examples
238
+
239
+ ### Track Events
240
+
241
+ ```typescript
242
+ kitbase.track({
243
+ channel: 'ecommerce',
244
+ event: 'Add to Cart',
245
+ tags: { product_id: 'sku-123', price: 29.99 },
246
+ });
247
+ ```
248
+
249
+ ### Identify Users
250
+
251
+ ```typescript
252
+ await kitbase.identify({
253
+ userId: user.id,
254
+ traits: { email: user.email, plan: user.plan },
255
+ });
256
+
257
+ // On logout
258
+ kitbase.reset();
259
+ ```
260
+
261
+ ### Track Duration
262
+
263
+ ```typescript
264
+ // Start timer
265
+ kitbase.timeEvent('Video Watched');
266
+
267
+ // ... user watches video ...
268
+
269
+ // Track event — $duration tag is automatically included
270
+ kitbase.track({
271
+ channel: 'engagement',
272
+ event: 'Video Watched',
273
+ tags: { video_id: 'abc' },
274
+ });
275
+ ```
276
+
277
+ ### Track Revenue
278
+
279
+ ```typescript
280
+ kitbase.trackRevenue({
281
+ amount: 19.99,
282
+ currency: 'USD',
283
+ tags: { plan: 'pro', cycle: 'monthly' },
284
+ });
285
+ ```
286
+
287
+ ### Plugins
288
+
289
+ ```typescript
290
+ import { KitbaseAnalyticsService, WebVitalsPlugin } from '@kitbase/analytics-angular';
291
+
292
+ @Component({
293
+ selector: 'app-root',
294
+ template: '<router-outlet />',
295
+ })
296
+ export class AppComponent {
297
+ private kitbase = inject(KitbaseAnalyticsService);
298
+
299
+ constructor() {
300
+ this.kitbase.use(new WebVitalsPlugin());
301
+ console.log('Active plugins:', this.kitbase.getPlugins());
302
+ }
303
+ }
304
+ ```
305
+
306
+ ### Re-exported Types
307
+
308
+ All types, errors, and utilities from `@kitbase/analytics` are re-exported:
309
+
310
+ ```typescript
311
+ import {
312
+ type KitbaseConfig,
313
+ type TrackOptions,
314
+ type KitbasePlugin,
315
+ KitbaseError,
316
+ ValidationError,
317
+ } from '@kitbase/analytics-angular';
318
+ ```
319
+
320
+ ## Running the Example App
321
+
322
+ ```bash
323
+ cd examples
324
+ pnpm install
325
+ pnpm start
326
+ ```
327
+
328
+ Opens at `http://localhost:4200` with an interactive dashboard to test all SDK features.
329
+
330
+ ## License
331
+
332
+ MIT
package/dist/README.md ADDED
@@ -0,0 +1,332 @@
1
+ # @kitbase/analytics-angular
2
+
3
+ Angular integration for the Kitbase Analytics SDK.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @kitbase/analytics-angular
9
+ # or
10
+ pnpm add @kitbase/analytics-angular
11
+ # or
12
+ yarn add @kitbase/analytics-angular
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ### Option 1: Direct — just call `init()`
18
+
19
+ No Angular DI needed. Call `init()` anywhere (e.g. `main.ts`, a component, a service):
20
+
21
+ ```typescript
22
+ import { init } from '@kitbase/analytics-angular';
23
+
24
+ const kitbase = init({ sdkKey: 'your-api-key' });
25
+
26
+ // Track events
27
+ kitbase.track({ channel: 'ui', event: 'Button Clicked' });
28
+
29
+ // Identify users
30
+ kitbase.identify({ userId: 'user-123', traits: { email: 'user@example.com' } });
31
+ ```
32
+
33
+ You can retrieve the instance later with `getInstance()`:
34
+
35
+ ```typescript
36
+ import { getInstance } from '@kitbase/analytics-angular';
37
+
38
+ const kitbase = getInstance();
39
+ kitbase?.track({ channel: 'ui', event: 'Page Loaded' });
40
+ ```
41
+
42
+ ### Option 2: Angular DI — `provideKitbaseAnalytics()` + `inject()`
43
+
44
+ Register the provider in your app config, then inject it in any component or service:
45
+
46
+ ```typescript
47
+ // app.config.ts
48
+ import { ApplicationConfig } from '@angular/core';
49
+ import { provideKitbaseAnalytics } from '@kitbase/analytics-angular';
50
+
51
+ export const appConfig: ApplicationConfig = {
52
+ providers: [
53
+ provideKitbaseAnalytics({
54
+ sdkKey: 'your-sdk-key',
55
+ debug: true,
56
+ }),
57
+ ],
58
+ };
59
+ ```
60
+
61
+ ```typescript
62
+ // component.ts
63
+ import { Component, inject } from '@angular/core';
64
+ import { KitbaseAnalyticsService } from '@kitbase/analytics-angular';
65
+
66
+ @Component({
67
+ selector: 'app-button',
68
+ template: '<button (click)="onClick()">Click me</button>',
69
+ })
70
+ export class ButtonComponent {
71
+ private kitbase = inject(KitbaseAnalyticsService);
72
+
73
+ onClick() {
74
+ this.kitbase.track({
75
+ channel: 'ui',
76
+ event: 'Button Clicked',
77
+ tags: { button_id: 'cta' },
78
+ });
79
+ }
80
+ }
81
+ ```
82
+
83
+ ## Configuration
84
+
85
+ ```typescript
86
+ init({
87
+ // Required
88
+ sdkKey: 'your-api-key',
89
+
90
+ // Optional
91
+ debug: true,
92
+ baseUrl: 'https://api.kitbase.dev',
93
+
94
+ analytics: {
95
+ autoTrackPageViews: true, // track route changes automatically
96
+ autoTrackOutboundLinks: true, // track external link clicks
97
+ autoTrackClicks: true, // track button/link/input clicks + data-kb-track-click
98
+ autoTrackScrollDepth: true, // track max scroll depth per page
99
+ autoTrackVisibility: true, // track visibility duration via data attributes
100
+ autoTrackWebVitals: false, // track Core Web Vitals (LCP, CLS, INP, FCP, TTFB)
101
+ autoDetectFrustration: true, // detect rage clicks and dead clicks
102
+ },
103
+
104
+ offline: {
105
+ enabled: true, // queue events when offline
106
+ maxQueueSize: 1000,
107
+ flushInterval: 30000,
108
+ flushBatchSize: 50,
109
+ maxRetries: 3,
110
+ },
111
+ });
112
+ ```
113
+
114
+ Page views, clicks, outbound links, scroll depth, and visibility duration are tracked automatically by default. The core SDK intercepts `history.pushState`/`popstate`, so no Angular Router integration is needed.
115
+
116
+ ## Data Attribute Events
117
+
118
+ Track events from HTML using data attributes — no JavaScript needed. Works in Angular, React, or vanilla HTML.
119
+
120
+ ### Click Tracking
121
+
122
+ Fire a named event when a user clicks an element:
123
+
124
+ ```html
125
+ <!-- Basic -->
126
+ <button data-kb-track-click="CTA Clicked">Sign Up Now</button>
127
+
128
+ <!-- With custom channel -->
129
+ <button data-kb-track-click="Add to Cart" data-kb-click-channel="ecommerce">
130
+ Add to Cart
131
+ </button>
132
+ ```
133
+
134
+ | Attribute | Required | Default | Description |
135
+ |-----------|----------|---------|-------------|
136
+ | `data-kb-track-click` | Yes | — | Event name to fire |
137
+ | `data-kb-click-channel` | No | `'engagement'` | Channel for the event |
138
+
139
+ Elements with `data-kb-track-click` skip the generic auto-click tracking to avoid double-counting. Disable with `autoTrackClicks: false`.
140
+
141
+ ### Visibility Duration
142
+
143
+ Track how long elements are visible in the viewport:
144
+
145
+ ```html
146
+ <!-- Basic -->
147
+ <section data-kb-track-visibility="Pricing Section Viewed">...</section>
148
+
149
+ <!-- With optional channel and threshold -->
150
+ <div
151
+ data-kb-track-visibility="Hero Banner Viewed"
152
+ data-kb-visibility-channel="marketing"
153
+ data-kb-visibility-threshold="0.5"
154
+ >...</div>
155
+ ```
156
+
157
+ | Attribute | Required | Default | Description |
158
+ |-----------|----------|---------|-------------|
159
+ | `data-kb-track-visibility` | Yes | — | Event name to fire |
160
+ | `data-kb-visibility-channel` | No | `'engagement'` | Channel for the event |
161
+ | `data-kb-visibility-threshold` | No | `0.5` | IntersectionObserver threshold (0–1) |
162
+
163
+ When the element leaves the viewport, navigates away, or is removed from the DOM, the SDK fires an event with `duration_seconds` and `duration_ms` tags.
164
+
165
+ Dynamically added elements (e.g. from Angular `@if` or `*ngIf`) are picked up automatically via MutationObserver. Disable with `autoTrackVisibility: false`.
166
+
167
+ ## Web Vitals
168
+
169
+ Track [Core Web Vitals](https://web.dev/vitals/) by enabling `autoTrackWebVitals`:
170
+
171
+ ```typescript
172
+ init({
173
+ sdkKey: 'your-api-key',
174
+ analytics: {
175
+ autoTrackWebVitals: true,
176
+ },
177
+ });
178
+ ```
179
+
180
+ The SDK collects all 5 metrics (LCP, CLS, INP, FCP, TTFB) and sends them as a single `web_vitals` event. Metrics are sent once per page load with a 30-second timeout. Only collected metrics are included. See the [core SDK README](../core/README.md#web-vitals) for full details.
181
+
182
+ ## API Reference
183
+
184
+ ### Event Tracking
185
+
186
+ | Method | Description |
187
+ |--------|-------------|
188
+ | `track(options)` | Track a custom event |
189
+ | `trackPageView(options?)` | Track a page view |
190
+ | `trackRevenue(options)` | Track a revenue event |
191
+ | `trackOutboundLink(options)` | Track an outbound link click |
192
+ | `trackClick(tags)` | Track a click event |
193
+
194
+ ### User Identification
195
+
196
+ | Method | Description |
197
+ |--------|-------------|
198
+ | `identify(options)` | Identify a user with traits |
199
+ | `getUserId()` | Get the identified user ID |
200
+ | `reset()` | Reset user identity |
201
+
202
+ ### Super Properties
203
+
204
+ | Method | Description |
205
+ |--------|-------------|
206
+ | `register(properties)` | Set super properties (included in all events) |
207
+ | `registerOnce(properties)` | Set super properties only if not already set |
208
+ | `unregister(key)` | Remove a super property |
209
+ | `getSuperProperties()` | Get all super properties |
210
+ | `clearSuperProperties()` | Clear all super properties |
211
+
212
+ ### Time Events
213
+
214
+ | Method | Description |
215
+ |--------|-------------|
216
+ | `timeEvent(eventName)` | Start timing an event |
217
+ | `cancelTimeEvent(eventName)` | Cancel timing an event |
218
+ | `getTimedEvents()` | List all active timed events |
219
+ | `getEventDuration(eventName)` | Get elapsed time in ms |
220
+
221
+ ### Plugin System
222
+
223
+ | Method | Description |
224
+ |--------|-------------|
225
+ | `use(plugin)` | Register a plugin |
226
+ | `getPlugins()` | Get names of all registered plugins |
227
+
228
+ ### Debug
229
+
230
+ | Method | Description |
231
+ |--------|-------------|
232
+ | `setDebugMode(enabled)` | Toggle debug logging |
233
+ | `isDebugMode()` | Check if debug mode is on |
234
+ | `shutdown()` | Shutdown the SDK and cleanup |
235
+ | `getInstance()` | Get the underlying KitbaseAnalytics instance |
236
+
237
+ ## Examples
238
+
239
+ ### Track Events
240
+
241
+ ```typescript
242
+ kitbase.track({
243
+ channel: 'ecommerce',
244
+ event: 'Add to Cart',
245
+ tags: { product_id: 'sku-123', price: 29.99 },
246
+ });
247
+ ```
248
+
249
+ ### Identify Users
250
+
251
+ ```typescript
252
+ await kitbase.identify({
253
+ userId: user.id,
254
+ traits: { email: user.email, plan: user.plan },
255
+ });
256
+
257
+ // On logout
258
+ kitbase.reset();
259
+ ```
260
+
261
+ ### Track Duration
262
+
263
+ ```typescript
264
+ // Start timer
265
+ kitbase.timeEvent('Video Watched');
266
+
267
+ // ... user watches video ...
268
+
269
+ // Track event — $duration tag is automatically included
270
+ kitbase.track({
271
+ channel: 'engagement',
272
+ event: 'Video Watched',
273
+ tags: { video_id: 'abc' },
274
+ });
275
+ ```
276
+
277
+ ### Track Revenue
278
+
279
+ ```typescript
280
+ kitbase.trackRevenue({
281
+ amount: 19.99,
282
+ currency: 'USD',
283
+ tags: { plan: 'pro', cycle: 'monthly' },
284
+ });
285
+ ```
286
+
287
+ ### Plugins
288
+
289
+ ```typescript
290
+ import { KitbaseAnalyticsService, WebVitalsPlugin } from '@kitbase/analytics-angular';
291
+
292
+ @Component({
293
+ selector: 'app-root',
294
+ template: '<router-outlet />',
295
+ })
296
+ export class AppComponent {
297
+ private kitbase = inject(KitbaseAnalyticsService);
298
+
299
+ constructor() {
300
+ this.kitbase.use(new WebVitalsPlugin());
301
+ console.log('Active plugins:', this.kitbase.getPlugins());
302
+ }
303
+ }
304
+ ```
305
+
306
+ ### Re-exported Types
307
+
308
+ All types, errors, and utilities from `@kitbase/analytics` are re-exported:
309
+
310
+ ```typescript
311
+ import {
312
+ type KitbaseConfig,
313
+ type TrackOptions,
314
+ type KitbasePlugin,
315
+ KitbaseError,
316
+ ValidationError,
317
+ } from '@kitbase/analytics-angular';
318
+ ```
319
+
320
+ ## Running the Example App
321
+
322
+ ```bash
323
+ cd examples
324
+ pnpm install
325
+ pnpm start
326
+ ```
327
+
328
+ Opens at `http://localhost:4200` with an interactive dashboard to test all SDK features.
329
+
330
+ ## License
331
+
332
+ MIT
@@ -0,0 +1,215 @@
1
+ import { makeEnvironmentProviders } from '@angular/core';
2
+ import { init } from '@kitbase/analytics';
3
+ export * from '@kitbase/analytics';
4
+
5
+ /**
6
+ * Angular integration for Kitbase Analytics SDK
7
+ *
8
+ * Two ways to use:
9
+ *
10
+ * **1. Direct usage — just call `init()`:**
11
+ * ```typescript
12
+ * import { init } from '@kitbase/analytics-angular';
13
+ *
14
+ * const kitbase = init({ sdkKey: 'your-api-key' });
15
+ * kitbase.track({ channel: 'ui', event: 'Button Clicked' });
16
+ * ```
17
+ *
18
+ * **2. Angular DI — use `provideKitbaseAnalytics()` + `inject()`:**
19
+ * ```typescript
20
+ * // app.config.ts
21
+ * import { provideKitbaseAnalytics } from '@kitbase/analytics-angular';
22
+ *
23
+ * export const appConfig = {
24
+ * providers: [
25
+ * provideKitbaseAnalytics({ sdkKey: 'your-api-key' }),
26
+ * ],
27
+ * };
28
+ *
29
+ * // component.ts
30
+ * import { KitbaseAnalyticsService } from '@kitbase/analytics-angular';
31
+ *
32
+ * export class MyComponent {
33
+ * private kitbase = inject(KitbaseAnalyticsService);
34
+ *
35
+ * onClick() {
36
+ * this.kitbase.track({ channel: 'ui', event: 'Button Clicked' });
37
+ * }
38
+ * }
39
+ * ```
40
+ *
41
+ * @packageDocumentation
42
+ */
43
+ /**
44
+ * KitbaseAnalytics service for Angular applications.
45
+ *
46
+ * This abstract class serves as both the DI token and the type definition.
47
+ * Use `inject(KitbaseAnalyticsService)` in your components.
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * @Component({
52
+ * selector: 'app-button',
53
+ * template: '<button (click)="onClick()">Click me</button>',
54
+ * })
55
+ * export class ButtonComponent {
56
+ * private kitbase = inject(KitbaseAnalyticsService);
57
+ *
58
+ * onClick() {
59
+ * this.kitbase.track({
60
+ * channel: 'ui',
61
+ * event: 'Button Clicked',
62
+ * tags: { button_id: 'cta' },
63
+ * });
64
+ * }
65
+ * }
66
+ * ```
67
+ */
68
+ class KitbaseAnalyticsService {
69
+ }
70
+ class KitbaseAnalyticsServiceImpl extends KitbaseAnalyticsService {
71
+ kitbase;
72
+ constructor(config) {
73
+ super();
74
+ this.kitbase = init(config);
75
+ }
76
+ getInstance() {
77
+ return this.kitbase;
78
+ }
79
+ shutdown() {
80
+ this.kitbase.shutdown();
81
+ }
82
+ // Event Tracking
83
+ track(options) {
84
+ return this.kitbase.track(options);
85
+ }
86
+ trackPageView(options) {
87
+ return this.kitbase.trackPageView(options);
88
+ }
89
+ trackRevenue(options) {
90
+ return this.kitbase.trackRevenue(options);
91
+ }
92
+ trackOutboundLink(options) {
93
+ return this.kitbase.trackOutboundLink(options);
94
+ }
95
+ trackClick(tags) {
96
+ return this.kitbase.trackClick(tags);
97
+ }
98
+ // User Identification
99
+ identify(options) {
100
+ return this.kitbase.identify(options);
101
+ }
102
+ getUserId() {
103
+ return this.kitbase.getUserId();
104
+ }
105
+ reset() {
106
+ this.kitbase.reset();
107
+ }
108
+ // Super Properties
109
+ register(properties) {
110
+ this.kitbase.register(properties);
111
+ }
112
+ registerOnce(properties) {
113
+ this.kitbase.registerOnce(properties);
114
+ }
115
+ unregister(key) {
116
+ this.kitbase.unregister(key);
117
+ }
118
+ getSuperProperties() {
119
+ return this.kitbase.getSuperProperties();
120
+ }
121
+ clearSuperProperties() {
122
+ this.kitbase.clearSuperProperties();
123
+ }
124
+ // Time Events
125
+ timeEvent(eventName) {
126
+ this.kitbase.timeEvent(eventName);
127
+ }
128
+ cancelTimeEvent(eventName) {
129
+ this.kitbase.cancelTimeEvent(eventName);
130
+ }
131
+ getTimedEvents() {
132
+ return this.kitbase.getTimedEvents();
133
+ }
134
+ getEventDuration(eventName) {
135
+ return this.kitbase.getEventDuration(eventName);
136
+ }
137
+ // Debug & Utilities
138
+ setDebugMode(enabled) {
139
+ this.kitbase.setDebugMode(enabled);
140
+ }
141
+ isDebugMode() {
142
+ return this.kitbase.isDebugMode();
143
+ }
144
+ // Plugin System
145
+ use(plugin) {
146
+ this.kitbase.use(plugin);
147
+ }
148
+ getPlugins() {
149
+ return this.kitbase.getPlugins();
150
+ }
151
+ }
152
+ // ============================================================
153
+ // Provider Function (Standalone API)
154
+ // ============================================================
155
+ /**
156
+ * Provide KitbaseAnalytics analytics for standalone Angular applications.
157
+ *
158
+ * Page views, clicks, outbound links, and scroll depth are tracked automatically
159
+ * by the core SDK (it intercepts history.pushState/popstate), so no additional
160
+ * Angular Router integration is needed.
161
+ *
162
+ * @example
163
+ * ```typescript
164
+ * // main.ts
165
+ * import { provideKitbaseAnalytics } from '@kitbase/analytics-angular';
166
+ *
167
+ * bootstrapApplication(AppComponent, {
168
+ * providers: [
169
+ * provideKitbaseAnalytics({
170
+ * sdkKey: 'your-api-key',
171
+ * debug: true,
172
+ * }),
173
+ * ],
174
+ * });
175
+ * ```
176
+ *
177
+ * @example
178
+ * ```typescript
179
+ * // With offline mode — events are queued locally in IndexedDB
180
+ * // and automatically sent when back online.
181
+ * bootstrapApplication(AppComponent, {
182
+ * providers: [
183
+ * provideKitbaseAnalytics({
184
+ * sdkKey: 'your-api-key',
185
+ * offline: {
186
+ * enabled: true,
187
+ * maxQueueSize: 1000, // max events to store (default: 1000)
188
+ * flushInterval: 30000, // flush every 30s (default: 30000)
189
+ * flushBatchSize: 50, // events per batch (default: 50)
190
+ * maxRetries: 3, // retry attempts (default: 3)
191
+ * },
192
+ * }),
193
+ * ],
194
+ * });
195
+ * ```
196
+ */
197
+ function provideKitbaseAnalytics(config) {
198
+ // Create the instance eagerly so auto-tracking (clicks, page views,
199
+ // scroll depth, outbound links) is set up at bootstrap time.
200
+ const instance = new KitbaseAnalyticsServiceImpl(config);
201
+ const providers = [
202
+ {
203
+ provide: KitbaseAnalyticsService,
204
+ useValue: instance,
205
+ },
206
+ ];
207
+ return makeEnvironmentProviders(providers);
208
+ }
209
+
210
+ /**
211
+ * Generated bundle index. Do not edit.
212
+ */
213
+
214
+ export { KitbaseAnalyticsService, provideKitbaseAnalytics };
215
+ //# sourceMappingURL=kitbase-analytics-angular.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kitbase-analytics-angular.mjs","sources":["../../src/index.ts","../../src/kitbase-analytics-angular.ts"],"sourcesContent":["/**\n * Angular integration for Kitbase Analytics SDK\n *\n * Two ways to use:\n *\n * **1. Direct usage — just call `init()`:**\n * ```typescript\n * import { init } from '@kitbase/analytics-angular';\n *\n * const kitbase = init({ sdkKey: 'your-api-key' });\n * kitbase.track({ channel: 'ui', event: 'Button Clicked' });\n * ```\n *\n * **2. Angular DI — use `provideKitbaseAnalytics()` + `inject()`:**\n * ```typescript\n * // app.config.ts\n * import { provideKitbaseAnalytics } from '@kitbase/analytics-angular';\n *\n * export const appConfig = {\n * providers: [\n * provideKitbaseAnalytics({ sdkKey: 'your-api-key' }),\n * ],\n * };\n *\n * // component.ts\n * import { KitbaseAnalyticsService } from '@kitbase/analytics-angular';\n *\n * export class MyComponent {\n * private kitbase = inject(KitbaseAnalyticsService);\n *\n * onClick() {\n * this.kitbase.track({ channel: 'ui', event: 'Button Clicked' });\n * }\n * }\n * ```\n *\n * @packageDocumentation\n */\n\nimport {\n Provider,\n makeEnvironmentProviders,\n EnvironmentProviders,\n} from '@angular/core';\nimport {\n init,\n getInstance,\n type KitbaseAnalytics,\n type KitbaseConfig,\n type TrackOptions,\n type TrackResponse,\n type PageViewOptions,\n type RevenueOptions,\n type IdentifyOptions,\n type Tags,\n type TagValue,\n type AnalyticsConfig,\n type KitbasePlugin,\n} from '@kitbase/analytics';\n\n// Re-export everything from core\nexport * from '@kitbase/analytics';\n\n/**\n * KitbaseAnalytics service for Angular applications.\n *\n * This abstract class serves as both the DI token and the type definition.\n * Use `inject(KitbaseAnalyticsService)` in your components.\n *\n * @example\n * ```typescript\n * @Component({\n * selector: 'app-button',\n * template: '<button (click)=\"onClick()\">Click me</button>',\n * })\n * export class ButtonComponent {\n * private kitbase = inject(KitbaseAnalyticsService);\n *\n * onClick() {\n * this.kitbase.track({\n * channel: 'ui',\n * event: 'Button Clicked',\n * tags: { button_id: 'cta' },\n * });\n * }\n * }\n * ```\n */\nexport abstract class KitbaseAnalyticsService {\n /** Get the underlying KitbaseAnalytics instance for advanced usage */\n abstract getInstance(): KitbaseAnalytics;\n\n /** Shutdown the client and cleanup resources */\n abstract shutdown(): void;\n\n // Event Tracking\n abstract track(options: TrackOptions): Promise<TrackResponse | void>;\n abstract trackPageView(options?: PageViewOptions): Promise<TrackResponse | void>;\n abstract trackRevenue(options: RevenueOptions): Promise<TrackResponse | void>;\n abstract trackOutboundLink(options: { url: string; text?: string }): Promise<TrackResponse | void>;\n abstract trackClick(tags: Tags): Promise<TrackResponse | void>;\n\n // User Identification\n abstract identify(options: IdentifyOptions): Promise<void>;\n abstract getUserId(): string | null;\n abstract reset(): void;\n\n // Super Properties\n abstract register(properties: Tags): void;\n abstract registerOnce(properties: Tags): void;\n abstract unregister(key: string): void;\n abstract getSuperProperties(): Tags;\n abstract clearSuperProperties(): void;\n\n // Time Events\n abstract timeEvent(eventName: string): void;\n abstract cancelTimeEvent(eventName: string): void;\n abstract getTimedEvents(): string[];\n abstract getEventDuration(eventName: string): number | null;\n\n // Debug & Utilities\n abstract setDebugMode(enabled: boolean): void;\n abstract isDebugMode(): boolean;\n\n // Plugin System\n abstract use(plugin: KitbasePlugin): void;\n abstract getPlugins(): string[];\n}\n\nclass KitbaseAnalyticsServiceImpl extends KitbaseAnalyticsService {\n private kitbase: KitbaseAnalytics;\n\n constructor(config: KitbaseConfig) {\n super();\n this.kitbase = init(config);\n }\n\n getInstance(): KitbaseAnalytics {\n return this.kitbase;\n }\n\n shutdown(): void {\n this.kitbase.shutdown();\n }\n\n // Event Tracking\n track(options: TrackOptions): Promise<TrackResponse | void> {\n return this.kitbase.track(options);\n }\n\n trackPageView(options?: PageViewOptions): Promise<TrackResponse | void> {\n return this.kitbase.trackPageView(options);\n }\n\n trackRevenue(options: RevenueOptions): Promise<TrackResponse | void> {\n return this.kitbase.trackRevenue(options);\n }\n\n trackOutboundLink(options: { url: string; text?: string }): Promise<TrackResponse | void> {\n return this.kitbase.trackOutboundLink(options);\n }\n\n trackClick(tags: Tags): Promise<TrackResponse | void> {\n return this.kitbase.trackClick(tags);\n }\n\n // User Identification\n identify(options: IdentifyOptions): Promise<void> {\n return this.kitbase.identify(options);\n }\n\n getUserId(): string | null {\n return this.kitbase.getUserId();\n }\n\n reset(): void {\n this.kitbase.reset();\n }\n\n // Super Properties\n register(properties: Tags): void {\n this.kitbase.register(properties);\n }\n\n registerOnce(properties: Tags): void {\n this.kitbase.registerOnce(properties);\n }\n\n unregister(key: string): void {\n this.kitbase.unregister(key);\n }\n\n getSuperProperties(): Tags {\n return this.kitbase.getSuperProperties();\n }\n\n clearSuperProperties(): void {\n this.kitbase.clearSuperProperties();\n }\n\n // Time Events\n timeEvent(eventName: string): void {\n this.kitbase.timeEvent(eventName);\n }\n\n cancelTimeEvent(eventName: string): void {\n this.kitbase.cancelTimeEvent(eventName);\n }\n\n getTimedEvents(): string[] {\n return this.kitbase.getTimedEvents();\n }\n\n getEventDuration(eventName: string): number | null {\n return this.kitbase.getEventDuration(eventName);\n }\n\n // Debug & Utilities\n setDebugMode(enabled: boolean): void {\n this.kitbase.setDebugMode(enabled);\n }\n\n isDebugMode(): boolean {\n return this.kitbase.isDebugMode();\n }\n\n // Plugin System\n use(plugin: KitbasePlugin): void {\n this.kitbase.use(plugin);\n }\n\n getPlugins(): string[] {\n return this.kitbase.getPlugins();\n }\n}\n\n// ============================================================\n// Provider Function (Standalone API)\n// ============================================================\n\n/**\n * Provide KitbaseAnalytics analytics for standalone Angular applications.\n *\n * Page views, clicks, outbound links, and scroll depth are tracked automatically\n * by the core SDK (it intercepts history.pushState/popstate), so no additional\n * Angular Router integration is needed.\n *\n * @example\n * ```typescript\n * // main.ts\n * import { provideKitbaseAnalytics } from '@kitbase/analytics-angular';\n *\n * bootstrapApplication(AppComponent, {\n * providers: [\n * provideKitbaseAnalytics({\n * sdkKey: 'your-api-key',\n * debug: true,\n * }),\n * ],\n * });\n * ```\n *\n * @example\n * ```typescript\n * // With offline mode — events are queued locally in IndexedDB\n * // and automatically sent when back online.\n * bootstrapApplication(AppComponent, {\n * providers: [\n * provideKitbaseAnalytics({\n * sdkKey: 'your-api-key',\n * offline: {\n * enabled: true,\n * maxQueueSize: 1000, // max events to store (default: 1000)\n * flushInterval: 30000, // flush every 30s (default: 30000)\n * flushBatchSize: 50, // events per batch (default: 50)\n * maxRetries: 3, // retry attempts (default: 3)\n * },\n * }),\n * ],\n * });\n * ```\n */\nexport function provideKitbaseAnalytics(config: KitbaseConfig): EnvironmentProviders {\n // Create the instance eagerly so auto-tracking (clicks, page views,\n // scroll depth, outbound links) is set up at bootstrap time.\n const instance = new KitbaseAnalyticsServiceImpl(config);\n\n const providers: Provider[] = [\n {\n provide: KitbaseAnalyticsService,\n useValue: instance,\n },\n ];\n\n return makeEnvironmentProviders(providers);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"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"}
@@ -0,0 +1,143 @@
1
+ import { EnvironmentProviders } from '@angular/core';
2
+ import { KitbaseAnalytics, TrackOptions, TrackResponse, PageViewOptions, RevenueOptions, Tags, IdentifyOptions, KitbasePlugin, KitbaseConfig } from '@kitbase/analytics';
3
+ export * from '@kitbase/analytics';
4
+
5
+ /**
6
+ * Angular integration for Kitbase Analytics SDK
7
+ *
8
+ * Two ways to use:
9
+ *
10
+ * **1. Direct usage — just call `init()`:**
11
+ * ```typescript
12
+ * import { init } from '@kitbase/analytics-angular';
13
+ *
14
+ * const kitbase = init({ sdkKey: 'your-api-key' });
15
+ * kitbase.track({ channel: 'ui', event: 'Button Clicked' });
16
+ * ```
17
+ *
18
+ * **2. Angular DI — use `provideKitbaseAnalytics()` + `inject()`:**
19
+ * ```typescript
20
+ * // app.config.ts
21
+ * import { provideKitbaseAnalytics } from '@kitbase/analytics-angular';
22
+ *
23
+ * export const appConfig = {
24
+ * providers: [
25
+ * provideKitbaseAnalytics({ sdkKey: 'your-api-key' }),
26
+ * ],
27
+ * };
28
+ *
29
+ * // component.ts
30
+ * import { KitbaseAnalyticsService } from '@kitbase/analytics-angular';
31
+ *
32
+ * export class MyComponent {
33
+ * private kitbase = inject(KitbaseAnalyticsService);
34
+ *
35
+ * onClick() {
36
+ * this.kitbase.track({ channel: 'ui', event: 'Button Clicked' });
37
+ * }
38
+ * }
39
+ * ```
40
+ *
41
+ * @packageDocumentation
42
+ */
43
+
44
+ /**
45
+ * KitbaseAnalytics service for Angular applications.
46
+ *
47
+ * This abstract class serves as both the DI token and the type definition.
48
+ * Use `inject(KitbaseAnalyticsService)` in your components.
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * @Component({
53
+ * selector: 'app-button',
54
+ * template: '<button (click)="onClick()">Click me</button>',
55
+ * })
56
+ * export class ButtonComponent {
57
+ * private kitbase = inject(KitbaseAnalyticsService);
58
+ *
59
+ * onClick() {
60
+ * this.kitbase.track({
61
+ * channel: 'ui',
62
+ * event: 'Button Clicked',
63
+ * tags: { button_id: 'cta' },
64
+ * });
65
+ * }
66
+ * }
67
+ * ```
68
+ */
69
+ declare abstract class KitbaseAnalyticsService {
70
+ /** Get the underlying KitbaseAnalytics instance for advanced usage */
71
+ abstract getInstance(): KitbaseAnalytics;
72
+ /** Shutdown the client and cleanup resources */
73
+ abstract shutdown(): void;
74
+ abstract track(options: TrackOptions): Promise<TrackResponse | void>;
75
+ abstract trackPageView(options?: PageViewOptions): Promise<TrackResponse | void>;
76
+ abstract trackRevenue(options: RevenueOptions): Promise<TrackResponse | void>;
77
+ abstract trackOutboundLink(options: {
78
+ url: string;
79
+ text?: string;
80
+ }): Promise<TrackResponse | void>;
81
+ abstract trackClick(tags: Tags): Promise<TrackResponse | void>;
82
+ abstract identify(options: IdentifyOptions): Promise<void>;
83
+ abstract getUserId(): string | null;
84
+ abstract reset(): void;
85
+ abstract register(properties: Tags): void;
86
+ abstract registerOnce(properties: Tags): void;
87
+ abstract unregister(key: string): void;
88
+ abstract getSuperProperties(): Tags;
89
+ abstract clearSuperProperties(): void;
90
+ abstract timeEvent(eventName: string): void;
91
+ abstract cancelTimeEvent(eventName: string): void;
92
+ abstract getTimedEvents(): string[];
93
+ abstract getEventDuration(eventName: string): number | null;
94
+ abstract setDebugMode(enabled: boolean): void;
95
+ abstract isDebugMode(): boolean;
96
+ abstract use(plugin: KitbasePlugin): void;
97
+ abstract getPlugins(): string[];
98
+ }
99
+ /**
100
+ * Provide KitbaseAnalytics analytics for standalone Angular applications.
101
+ *
102
+ * Page views, clicks, outbound links, and scroll depth are tracked automatically
103
+ * by the core SDK (it intercepts history.pushState/popstate), so no additional
104
+ * Angular Router integration is needed.
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * // main.ts
109
+ * import { provideKitbaseAnalytics } from '@kitbase/analytics-angular';
110
+ *
111
+ * bootstrapApplication(AppComponent, {
112
+ * providers: [
113
+ * provideKitbaseAnalytics({
114
+ * sdkKey: 'your-api-key',
115
+ * debug: true,
116
+ * }),
117
+ * ],
118
+ * });
119
+ * ```
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * // With offline mode — events are queued locally in IndexedDB
124
+ * // and automatically sent when back online.
125
+ * bootstrapApplication(AppComponent, {
126
+ * providers: [
127
+ * provideKitbaseAnalytics({
128
+ * sdkKey: 'your-api-key',
129
+ * offline: {
130
+ * enabled: true,
131
+ * maxQueueSize: 1000, // max events to store (default: 1000)
132
+ * flushInterval: 30000, // flush every 30s (default: 30000)
133
+ * flushBatchSize: 50, // events per batch (default: 50)
134
+ * maxRetries: 3, // retry attempts (default: 3)
135
+ * },
136
+ * }),
137
+ * ],
138
+ * });
139
+ * ```
140
+ */
141
+ declare function provideKitbaseAnalytics(config: KitbaseConfig): EnvironmentProviders;
142
+
143
+ export { KitbaseAnalyticsService, provideKitbaseAnalytics };
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@kitbase/analytics-angular",
3
+ "version": "0.1.6",
4
+ "description": "Angular integration for Kitbase Analytics SDK",
5
+ "type": "module",
6
+ "module": "./dist/fesm2022/kitbase-analytics-angular.mjs",
7
+ "typings": "./dist/index.d.ts",
8
+ "exports": {
9
+ "./package.json": {
10
+ "default": "./package.json"
11
+ },
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "default": "./dist/fesm2022/kitbase-analytics-angular.mjs"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "sideEffects": false,
21
+ "keywords": [
22
+ "kitbase",
23
+ "analytics",
24
+ "tracking",
25
+ "angular",
26
+ "service"
27
+ ],
28
+ "author": "",
29
+ "license": "MIT",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/scr2em/kitbase-sdk.git",
33
+ "directory": "customEvents/typescript/packages/angular"
34
+ },
35
+ "peerDependencies": {
36
+ "@angular/common": ">=17.0.0",
37
+ "@angular/core": ">=17.0.0"
38
+ },
39
+ "dependencies": {
40
+ "@kitbase/analytics": "0.1.6"
41
+ },
42
+ "devDependencies": {
43
+ "@angular/common": "^20.0.0",
44
+ "@angular/compiler": "^20.0.0",
45
+ "@angular/compiler-cli": "^20.0.0",
46
+ "@angular/core": "^20.0.0",
47
+ "ng-packagr": "^20.0.0",
48
+ "typescript": "^5.8.0",
49
+ "vitest": "^1.2.0"
50
+ },
51
+ "scripts": {
52
+ "build": "ng-packagr -p ng-package.json",
53
+ "test": "vitest run",
54
+ "lint": "eslint src",
55
+ "clean": "rm -rf dist"
56
+ }
57
+ }