@prodantix/sdk 0.1.0 → 0.2.0-beta.358

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.
@@ -1,160 +0,0 @@
1
- type JsonPrimitive = string | number | boolean | null;
2
- type JsonValue = JsonPrimitive | JsonValue[] | {
3
- [key: string]: JsonValue;
4
- };
5
- type EventProperties = Record<string, JsonValue>;
6
- interface EventContext {
7
- locale?: string;
8
- os?: string;
9
- sdk?: string;
10
- sdk_version?: string;
11
- }
12
- interface EventEnvelope {
13
- context?: EventContext;
14
- distinct_id: string;
15
- event_id: string;
16
- event_name: string;
17
- properties: EventProperties;
18
- schema_version: 1;
19
- session_id?: string;
20
- timestamp: string;
21
- }
22
- interface EventBatch {
23
- api_key?: string;
24
- events: EventEnvelope[];
25
- sent_at: string;
26
- }
27
- interface FlagsResponse {
28
- flags: Record<string, boolean>;
29
- }
30
- interface InboxMessage {
31
- body: string;
32
- createdAt: string;
33
- id: string;
34
- read: boolean;
35
- title: string;
36
- }
37
- interface InboxResponse {
38
- messages: InboxMessage[];
39
- }
40
- interface Clock {
41
- now(): Date;
42
- }
43
- interface IdFactory {
44
- uuid(): string;
45
- }
46
- interface StorageAdapter {
47
- getItem(key: string): string | null;
48
- removeItem(key: string): void;
49
- setItem(key: string, value: string): void;
50
- }
51
- interface TransportRequest {
52
- body: EventBatch;
53
- projectKey: string;
54
- url: string;
55
- }
56
- interface Transport {
57
- send(request: TransportRequest): Promise<void>;
58
- }
59
- interface ProdantixConfig {
60
- apiKey: string;
61
- autocapture?: boolean;
62
- clock?: Clock;
63
- defaultProperties?: EventProperties | (() => EventProperties);
64
- flagsHost?: string;
65
- flushAt?: number;
66
- flushIntervalMs?: number;
67
- host: string;
68
- ids?: IdFactory;
69
- locale?: string;
70
- maxQueueSize?: number;
71
- maxRetries?: number;
72
- onError?: (error: unknown) => void;
73
- os?: string;
74
- requestTimeoutMs?: number;
75
- sdkName?: string;
76
- sdkVersion?: string;
77
- storage?: StorageAdapter;
78
- transport?: Transport;
79
- }
80
-
81
- interface LocalFlagContext {
82
- attributes?: EventProperties;
83
- properties?: EventProperties;
84
- }
85
- interface CaptureOptions {
86
- properties?: EventProperties;
87
- sessionId?: string;
88
- timestamp?: Date;
89
- }
90
- /**
91
- * The profile keys the platform itself understands.
92
- *
93
- * They are ordinary properties on the wire; the only thing that makes them
94
- * special is the `$` prefix, which is how this platform marks a name it owns
95
- * rather than one the caller chose. Passing them through `traits` means never
96
- * having to remember whether the console reads `email` or `$email`: an
97
- * unprefixed `email` is a property of your own and stays one, and would never
98
- * reach the Email column.
99
- */
100
- interface PersonTraits {
101
- avatar?: string;
102
- email?: string;
103
- name?: string;
104
- phone?: string;
105
- }
106
- interface IdentifyOptions {
107
- /** Arbitrary profile properties your own code defines. */
108
- set?: EventProperties;
109
- /** The reserved traits the console renders as fields. */
110
- traits?: PersonTraits;
111
- }
112
- declare class ProdantixClient {
113
- private readonly config;
114
- private readonly identity;
115
- private readonly queue;
116
- private readonly transport;
117
- private readonly flagsClient;
118
- private readonly messagesClient;
119
- private readonly context;
120
- private flushTimer?;
121
- private flushing;
122
- private cachedFlags?;
123
- private cachedSnapshot?;
124
- constructor(config: ProdantixConfig);
125
- get distinctId(): string;
126
- get anonymousId(): string;
127
- capture(eventName: string, options?: CaptureOptions): void;
128
- identify(distinctId: string, options?: IdentifyOptions): void;
129
- alias(alias: string): void;
130
- group(groupType: string, groupKey: string, properties?: EventProperties): void;
131
- setPersonProperties(set?: EventProperties, setOnce?: EventProperties): void;
132
- /**
133
- * Attach the reserved traits to whoever is current, without an identify.
134
- *
135
- * This does NOT make the person identified: only `identify()` does that, so a
136
- * trait set on an anonymous visitor leaves them anonymous and carrying an
137
- * address, which is exactly what a newsletter signup before login looks like.
138
- */
139
- setPersonTraits(traits: PersonTraits): void;
140
- getAllFlags(): Promise<Record<string, boolean>>;
141
- isFeatureEnabled(key: string): Promise<boolean>;
142
- getCachedFlag(key: string): boolean | undefined;
143
- getLocalFlags(context?: LocalFlagContext): Promise<Record<string, boolean>>;
144
- isFeatureEnabledLocal(key: string, context?: LocalFlagContext): Promise<boolean>;
145
- private flagSnapshot;
146
- getInbox(): Promise<InboxMessage[]>;
147
- markMessageRead(messageId: string): Promise<void>;
148
- flush(): Promise<void>;
149
- reset(): void;
150
- shutdown(): Promise<void>;
151
- private enqueue;
152
- private persistQueue;
153
- private restoreQueue;
154
- private startTimer;
155
- private stopTimer;
156
- private persistKey;
157
- }
158
- declare function createClient(config: ProdantixConfig): ProdantixClient;
159
-
160
- export { type CaptureOptions as C, type EventBatch as E, type FlagsResponse as F, type InboxMessage as I, type JsonValue as J, type LocalFlagContext as L, ProdantixClient as P, type StorageAdapter as S, type Transport as T, type Clock as a, type EventContext as b, type EventEnvelope as c, type EventProperties as d, type IdFactory as e, type IdentifyOptions as f, type InboxResponse as g, type ProdantixConfig as h, type TransportRequest as i, createClient as j };
@@ -1,160 +0,0 @@
1
- type JsonPrimitive = string | number | boolean | null;
2
- type JsonValue = JsonPrimitive | JsonValue[] | {
3
- [key: string]: JsonValue;
4
- };
5
- type EventProperties = Record<string, JsonValue>;
6
- interface EventContext {
7
- locale?: string;
8
- os?: string;
9
- sdk?: string;
10
- sdk_version?: string;
11
- }
12
- interface EventEnvelope {
13
- context?: EventContext;
14
- distinct_id: string;
15
- event_id: string;
16
- event_name: string;
17
- properties: EventProperties;
18
- schema_version: 1;
19
- session_id?: string;
20
- timestamp: string;
21
- }
22
- interface EventBatch {
23
- api_key?: string;
24
- events: EventEnvelope[];
25
- sent_at: string;
26
- }
27
- interface FlagsResponse {
28
- flags: Record<string, boolean>;
29
- }
30
- interface InboxMessage {
31
- body: string;
32
- createdAt: string;
33
- id: string;
34
- read: boolean;
35
- title: string;
36
- }
37
- interface InboxResponse {
38
- messages: InboxMessage[];
39
- }
40
- interface Clock {
41
- now(): Date;
42
- }
43
- interface IdFactory {
44
- uuid(): string;
45
- }
46
- interface StorageAdapter {
47
- getItem(key: string): string | null;
48
- removeItem(key: string): void;
49
- setItem(key: string, value: string): void;
50
- }
51
- interface TransportRequest {
52
- body: EventBatch;
53
- projectKey: string;
54
- url: string;
55
- }
56
- interface Transport {
57
- send(request: TransportRequest): Promise<void>;
58
- }
59
- interface ProdantixConfig {
60
- apiKey: string;
61
- autocapture?: boolean;
62
- clock?: Clock;
63
- defaultProperties?: EventProperties | (() => EventProperties);
64
- flagsHost?: string;
65
- flushAt?: number;
66
- flushIntervalMs?: number;
67
- host: string;
68
- ids?: IdFactory;
69
- locale?: string;
70
- maxQueueSize?: number;
71
- maxRetries?: number;
72
- onError?: (error: unknown) => void;
73
- os?: string;
74
- requestTimeoutMs?: number;
75
- sdkName?: string;
76
- sdkVersion?: string;
77
- storage?: StorageAdapter;
78
- transport?: Transport;
79
- }
80
-
81
- interface LocalFlagContext {
82
- attributes?: EventProperties;
83
- properties?: EventProperties;
84
- }
85
- interface CaptureOptions {
86
- properties?: EventProperties;
87
- sessionId?: string;
88
- timestamp?: Date;
89
- }
90
- /**
91
- * The profile keys the platform itself understands.
92
- *
93
- * They are ordinary properties on the wire; the only thing that makes them
94
- * special is the `$` prefix, which is how this platform marks a name it owns
95
- * rather than one the caller chose. Passing them through `traits` means never
96
- * having to remember whether the console reads `email` or `$email`: an
97
- * unprefixed `email` is a property of your own and stays one, and would never
98
- * reach the Email column.
99
- */
100
- interface PersonTraits {
101
- avatar?: string;
102
- email?: string;
103
- name?: string;
104
- phone?: string;
105
- }
106
- interface IdentifyOptions {
107
- /** Arbitrary profile properties your own code defines. */
108
- set?: EventProperties;
109
- /** The reserved traits the console renders as fields. */
110
- traits?: PersonTraits;
111
- }
112
- declare class ProdantixClient {
113
- private readonly config;
114
- private readonly identity;
115
- private readonly queue;
116
- private readonly transport;
117
- private readonly flagsClient;
118
- private readonly messagesClient;
119
- private readonly context;
120
- private flushTimer?;
121
- private flushing;
122
- private cachedFlags?;
123
- private cachedSnapshot?;
124
- constructor(config: ProdantixConfig);
125
- get distinctId(): string;
126
- get anonymousId(): string;
127
- capture(eventName: string, options?: CaptureOptions): void;
128
- identify(distinctId: string, options?: IdentifyOptions): void;
129
- alias(alias: string): void;
130
- group(groupType: string, groupKey: string, properties?: EventProperties): void;
131
- setPersonProperties(set?: EventProperties, setOnce?: EventProperties): void;
132
- /**
133
- * Attach the reserved traits to whoever is current, without an identify.
134
- *
135
- * This does NOT make the person identified: only `identify()` does that, so a
136
- * trait set on an anonymous visitor leaves them anonymous and carrying an
137
- * address, which is exactly what a newsletter signup before login looks like.
138
- */
139
- setPersonTraits(traits: PersonTraits): void;
140
- getAllFlags(): Promise<Record<string, boolean>>;
141
- isFeatureEnabled(key: string): Promise<boolean>;
142
- getCachedFlag(key: string): boolean | undefined;
143
- getLocalFlags(context?: LocalFlagContext): Promise<Record<string, boolean>>;
144
- isFeatureEnabledLocal(key: string, context?: LocalFlagContext): Promise<boolean>;
145
- private flagSnapshot;
146
- getInbox(): Promise<InboxMessage[]>;
147
- markMessageRead(messageId: string): Promise<void>;
148
- flush(): Promise<void>;
149
- reset(): void;
150
- shutdown(): Promise<void>;
151
- private enqueue;
152
- private persistQueue;
153
- private restoreQueue;
154
- private startTimer;
155
- private stopTimer;
156
- private persistKey;
157
- }
158
- declare function createClient(config: ProdantixConfig): ProdantixClient;
159
-
160
- export { type CaptureOptions as C, type EventBatch as E, type FlagsResponse as F, type InboxMessage as I, type JsonValue as J, type LocalFlagContext as L, ProdantixClient as P, type StorageAdapter as S, type Transport as T, type Clock as a, type EventContext as b, type EventEnvelope as c, type EventProperties as d, type IdFactory as e, type IdentifyOptions as f, type InboxResponse as g, type ProdantixConfig as h, type TransportRequest as i, createClient as j };