@stacksee/analytics 0.4.3 → 0.4.5
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/dist/base.provider-AfFL5W_P.js +19 -0
- package/dist/client-RZPcOfAk.js +86 -0
- package/dist/client.d.ts +68 -2
- package/dist/client.js +576 -10
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -14
- package/dist/providers/client.js +6 -0
- package/dist/{src/providers/index.d.ts → providers/server.d.ts} +0 -2
- package/dist/providers/server.js +6 -0
- package/dist/{providers.js → server-CMRw9K0d.js} +2 -5
- package/dist/server.d.ts +38 -2
- package/dist/server.js +18 -14
- package/package.json +8 -4
- package/readme.md +11 -5
- package/dist/client-CyvENC-f.js +0 -577
- package/dist/client-MwIAm9fk.js +0 -96
- package/dist/environment-Bnc8FqHv.js +0 -6
- package/dist/providers.d.ts +0 -2
- package/dist/src/client.d.ts +0 -68
- package/dist/src/index.d.ts +0 -5
- package/dist/src/server.d.ts +0 -38
- package/dist/test/base-provider.test.d.ts +0 -1
- package/dist/test/client-analytics.test.d.ts +0 -1
- package/dist/test/events.test.d.ts +0 -1
- package/dist/test/index.test.d.ts +0 -1
- package/dist/test/mock-provider.d.ts +0 -34
- package/dist/test/providers.test.d.ts +0 -1
- package/dist/test/server-analytics.test.d.ts +0 -1
- package/dist/test/server.test.d.ts +0 -1
- package/dist/test/utils.test.d.ts +0 -1
- /package/dist/{src/adapters → adapters}/client/browser-analytics.d.ts +0 -0
- /package/dist/{src/adapters → adapters}/server/server-analytics.d.ts +0 -0
- /package/dist/{src/client → client}/index.d.ts +0 -0
- /package/dist/{src/core → core}/events/index.d.ts +0 -0
- /package/dist/{src/core → core}/events/types.d.ts +0 -0
- /package/dist/{src/providers → providers}/base.provider.d.ts +0 -0
- /package/dist/{src/providers → providers}/client.d.ts +0 -0
- /package/dist/{src/providers → providers}/posthog/client.d.ts +0 -0
- /package/dist/{src/providers → providers}/posthog/server.d.ts +0 -0
- /package/dist/{src/server → server}/index.d.ts +0 -0
- /package/dist/{src/utils → utils}/environment.d.ts +0 -0
package/dist/src/client.d.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { BrowserAnalytics } from './adapters/client/browser-analytics.js';
|
|
2
|
-
import { AnalyticsProvider } from './core/events/types.js';
|
|
3
|
-
import { EventMapFromCollection } from './core/events/index.js';
|
|
4
|
-
type DefaultEventMap = Record<string, Record<string, unknown>>;
|
|
5
|
-
export interface ClientAnalyticsConfig {
|
|
6
|
-
providers?: AnalyticsProvider[];
|
|
7
|
-
debug?: boolean;
|
|
8
|
-
enabled?: boolean;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Initialize analytics for the browser
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* import { createClientAnalytics } from '@stacksee/analytics/client';
|
|
16
|
-
* import { PostHogClientProvider } from '@stacksee/analytics/providers/posthog';
|
|
17
|
-
* import { AppEvents } from './events';
|
|
18
|
-
*
|
|
19
|
-
* const analytics = createClientAnalytics<typeof AppEvents>({
|
|
20
|
-
* providers: [
|
|
21
|
-
* new PostHogClientProvider({
|
|
22
|
-
* apiKey: 'your-api-key',
|
|
23
|
-
* host: 'https://app.posthog.com'
|
|
24
|
-
* })
|
|
25
|
-
* ],
|
|
26
|
-
* debug: true,
|
|
27
|
-
* enabled: true
|
|
28
|
-
* });
|
|
29
|
-
*
|
|
30
|
-
* // Now event names and properties are fully typed!
|
|
31
|
-
* analytics.track('user_signed_up', {
|
|
32
|
-
* userId: 'user-123',
|
|
33
|
-
* email: 'user@example.com',
|
|
34
|
-
* plan: 'pro'
|
|
35
|
-
* });
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export declare function createClientAnalytics<TEvents = never>(config: ClientAnalyticsConfig): BrowserAnalytics<EventMapFromCollection<TEvents>>;
|
|
39
|
-
export { createClientAnalytics as createAnalytics };
|
|
40
|
-
/**
|
|
41
|
-
* Get the current analytics instance
|
|
42
|
-
*/
|
|
43
|
-
export declare function getAnalytics(): BrowserAnalytics<DefaultEventMap>;
|
|
44
|
-
/**
|
|
45
|
-
* Convenience function to track events
|
|
46
|
-
*/
|
|
47
|
-
export declare function track(eventName: string, properties: Record<string, unknown>): Promise<void>;
|
|
48
|
-
/**
|
|
49
|
-
* Convenience function to identify users
|
|
50
|
-
*/
|
|
51
|
-
export declare function identify(userId: string, traits?: Record<string, unknown>): void;
|
|
52
|
-
/**
|
|
53
|
-
* Convenience function to track page views
|
|
54
|
-
*/
|
|
55
|
-
export declare function pageView(properties?: Record<string, unknown>): void;
|
|
56
|
-
/**
|
|
57
|
-
* Convenience function to track page leave events
|
|
58
|
-
*/
|
|
59
|
-
export declare function pageLeave(properties?: Record<string, unknown>): void;
|
|
60
|
-
/**
|
|
61
|
-
* Convenience function to reset user session
|
|
62
|
-
*/
|
|
63
|
-
export declare function reset(): void;
|
|
64
|
-
/**
|
|
65
|
-
* Reset the analytics instance (for testing purposes)
|
|
66
|
-
* @internal
|
|
67
|
-
*/
|
|
68
|
-
export declare function resetAnalyticsInstance(): void;
|
package/dist/src/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export type { EventCategory, BaseEvent, EventContext, AnalyticsProvider, AnalyticsConfig, } from './core/events/types.js';
|
|
2
|
-
export type { CreateEventDefinition, ExtractEventNames, ExtractEventPropertiesFromCollection, EventCollection, AnyEventName, AnyEventProperties, EventMapFromCollection, } from './core/events/index.js';
|
|
3
|
-
export { createAnalytics as createClientAnalytics, getAnalytics, track as trackClient, identify as identifyClient, pageView as pageViewClient, pageLeave as pageLeaveClient, reset as resetClient, type ClientAnalyticsConfig, } from './client.js';
|
|
4
|
-
export { BaseAnalyticsProvider, PostHogClientProvider, type PostHogConfig, } from './providers/client.js';
|
|
5
|
-
export { BrowserAnalytics } from './adapters/client/browser-analytics.js';
|
package/dist/src/server.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { ServerAnalytics } from './adapters/server/server-analytics.js';
|
|
2
|
-
import { AnalyticsProvider } from './core/events/types.js';
|
|
3
|
-
import { EventMapFromCollection } from './core/events/index.js';
|
|
4
|
-
export interface ServerAnalyticsConfig {
|
|
5
|
-
providers?: AnalyticsProvider[];
|
|
6
|
-
debug?: boolean;
|
|
7
|
-
enabled?: boolean;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Create a server analytics instance
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* import { createServerAnalytics } from '@stacksee/analytics/server';
|
|
15
|
-
* import { PostHogServerProvider } from '@stacksee/analytics/providers/posthog';
|
|
16
|
-
* import { AppEvents } from './events';
|
|
17
|
-
*
|
|
18
|
-
* const analytics = createServerAnalytics<typeof AppEvents>({
|
|
19
|
-
* providers: [
|
|
20
|
-
* new PostHogServerProvider({
|
|
21
|
-
* apiKey: process.env.POSTHOG_API_KEY,
|
|
22
|
-
* host: process.env.POSTHOG_HOST
|
|
23
|
-
* })
|
|
24
|
-
* ],
|
|
25
|
-
* debug: true,
|
|
26
|
-
* enabled: true
|
|
27
|
-
* });
|
|
28
|
-
*
|
|
29
|
-
* // Now event names and properties are fully typed!
|
|
30
|
-
* await analytics.track('user_signed_up', {
|
|
31
|
-
* userId: 'user-123',
|
|
32
|
-
* email: 'user@example.com',
|
|
33
|
-
* plan: 'pro'
|
|
34
|
-
* }, { userId: 'user-123' });
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export declare function createServerAnalytics<TEvents = never>(config: ServerAnalyticsConfig): ServerAnalytics<EventMapFromCollection<TEvents>>;
|
|
38
|
-
export { ServerAnalytics };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { BaseAnalyticsProvider } from '../src/providers/base.provider';
|
|
2
|
-
import { BaseEvent, EventContext } from '../src/core/events/types';
|
|
3
|
-
export declare class MockAnalyticsProvider extends BaseAnalyticsProvider {
|
|
4
|
-
name: string;
|
|
5
|
-
private initialized;
|
|
6
|
-
calls: {
|
|
7
|
-
initialize: number;
|
|
8
|
-
identify: Array<{
|
|
9
|
-
userId: string;
|
|
10
|
-
traits?: Record<string, unknown>;
|
|
11
|
-
}>;
|
|
12
|
-
track: Array<{
|
|
13
|
-
event: BaseEvent;
|
|
14
|
-
context?: EventContext;
|
|
15
|
-
}>;
|
|
16
|
-
pageView: Array<{
|
|
17
|
-
properties?: Record<string, unknown>;
|
|
18
|
-
context?: EventContext;
|
|
19
|
-
}>;
|
|
20
|
-
pageLeave: Array<{
|
|
21
|
-
properties?: Record<string, unknown>;
|
|
22
|
-
context?: EventContext;
|
|
23
|
-
}>;
|
|
24
|
-
reset: number;
|
|
25
|
-
};
|
|
26
|
-
initialize(): void;
|
|
27
|
-
identify(userId: string, traits?: Record<string, unknown>): void;
|
|
28
|
-
track(event: BaseEvent, context?: EventContext): void;
|
|
29
|
-
pageView(properties?: Record<string, unknown>, context?: EventContext): void;
|
|
30
|
-
pageLeave(properties?: Record<string, unknown>, context?: EventContext): void;
|
|
31
|
-
reset(): void;
|
|
32
|
-
clearCalls(): void;
|
|
33
|
-
isInitialized(): boolean;
|
|
34
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|