@outlit/node 0.1.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/LICENSE +201 -0
- package/dist/index.d.mts +104 -0
- package/dist/index.d.ts +104 -0
- package/dist/index.js +250 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +228 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { ServerTrackOptions, ServerIdentifyOptions } from '@outlit/core';
|
|
2
|
+
export { IngestResponse, ServerIdentifyOptions, ServerTrackOptions, TrackerConfig } from '@outlit/core';
|
|
3
|
+
|
|
4
|
+
interface OutlitOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Your Outlit public key.
|
|
7
|
+
*/
|
|
8
|
+
publicKey: string;
|
|
9
|
+
/**
|
|
10
|
+
* API host URL.
|
|
11
|
+
* @default "https://app.outlit.ai"
|
|
12
|
+
*/
|
|
13
|
+
apiHost?: string;
|
|
14
|
+
/**
|
|
15
|
+
* How often to flush events (in milliseconds).
|
|
16
|
+
* @default 10000 (10 seconds)
|
|
17
|
+
*/
|
|
18
|
+
flushInterval?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Maximum number of events to batch before flushing.
|
|
21
|
+
* @default 100
|
|
22
|
+
*/
|
|
23
|
+
maxBatchSize?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Request timeout in milliseconds.
|
|
26
|
+
* @default 10000 (10 seconds)
|
|
27
|
+
*/
|
|
28
|
+
timeout?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Outlit server-side tracking client.
|
|
32
|
+
*
|
|
33
|
+
* Unlike the browser SDK, this requires identity (email or userId) for all calls.
|
|
34
|
+
* Anonymous tracking is not supported server-side.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* import { Outlit } from '@outlit/tracker-node'
|
|
39
|
+
*
|
|
40
|
+
* const outlit = new Outlit({ publicKey: 'pk_xxx' })
|
|
41
|
+
*
|
|
42
|
+
* // Track a custom event
|
|
43
|
+
* outlit.track({
|
|
44
|
+
* email: 'user@example.com',
|
|
45
|
+
* eventName: 'subscription_created',
|
|
46
|
+
* properties: { plan: 'pro' }
|
|
47
|
+
* })
|
|
48
|
+
*
|
|
49
|
+
* // Identify/update user
|
|
50
|
+
* outlit.identify({
|
|
51
|
+
* email: 'user@example.com',
|
|
52
|
+
* userId: 'usr_123',
|
|
53
|
+
* traits: { name: 'John Doe' }
|
|
54
|
+
* })
|
|
55
|
+
*
|
|
56
|
+
* // Flush before shutdown (important for serverless)
|
|
57
|
+
* await outlit.flush()
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
declare class Outlit {
|
|
61
|
+
private transport;
|
|
62
|
+
private queue;
|
|
63
|
+
private flushTimer;
|
|
64
|
+
private flushInterval;
|
|
65
|
+
private isShutdown;
|
|
66
|
+
constructor(options: OutlitOptions);
|
|
67
|
+
/**
|
|
68
|
+
* Track a custom event.
|
|
69
|
+
*
|
|
70
|
+
* Requires either `email` or `userId` to identify the user.
|
|
71
|
+
*
|
|
72
|
+
* @throws Error if neither email nor userId is provided
|
|
73
|
+
*/
|
|
74
|
+
track(options: ServerTrackOptions): void;
|
|
75
|
+
/**
|
|
76
|
+
* Identify or update a user.
|
|
77
|
+
*
|
|
78
|
+
* Requires either `email` or `userId` to identify the user.
|
|
79
|
+
*
|
|
80
|
+
* @throws Error if neither email nor userId is provided
|
|
81
|
+
*/
|
|
82
|
+
identify(options: ServerIdentifyOptions): void;
|
|
83
|
+
/**
|
|
84
|
+
* Flush all pending events immediately.
|
|
85
|
+
*
|
|
86
|
+
* Important: Call this before your serverless function exits!
|
|
87
|
+
*/
|
|
88
|
+
flush(): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Shutdown the client gracefully.
|
|
91
|
+
*
|
|
92
|
+
* Flushes remaining events and stops the flush timer.
|
|
93
|
+
*/
|
|
94
|
+
shutdown(): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Get the number of events waiting to be sent.
|
|
97
|
+
*/
|
|
98
|
+
get queueSize(): number;
|
|
99
|
+
private startFlushTimer;
|
|
100
|
+
private sendEvents;
|
|
101
|
+
private ensureNotShutdown;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export { Outlit, type OutlitOptions };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { ServerTrackOptions, ServerIdentifyOptions } from '@outlit/core';
|
|
2
|
+
export { IngestResponse, ServerIdentifyOptions, ServerTrackOptions, TrackerConfig } from '@outlit/core';
|
|
3
|
+
|
|
4
|
+
interface OutlitOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Your Outlit public key.
|
|
7
|
+
*/
|
|
8
|
+
publicKey: string;
|
|
9
|
+
/**
|
|
10
|
+
* API host URL.
|
|
11
|
+
* @default "https://app.outlit.ai"
|
|
12
|
+
*/
|
|
13
|
+
apiHost?: string;
|
|
14
|
+
/**
|
|
15
|
+
* How often to flush events (in milliseconds).
|
|
16
|
+
* @default 10000 (10 seconds)
|
|
17
|
+
*/
|
|
18
|
+
flushInterval?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Maximum number of events to batch before flushing.
|
|
21
|
+
* @default 100
|
|
22
|
+
*/
|
|
23
|
+
maxBatchSize?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Request timeout in milliseconds.
|
|
26
|
+
* @default 10000 (10 seconds)
|
|
27
|
+
*/
|
|
28
|
+
timeout?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Outlit server-side tracking client.
|
|
32
|
+
*
|
|
33
|
+
* Unlike the browser SDK, this requires identity (email or userId) for all calls.
|
|
34
|
+
* Anonymous tracking is not supported server-side.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* import { Outlit } from '@outlit/tracker-node'
|
|
39
|
+
*
|
|
40
|
+
* const outlit = new Outlit({ publicKey: 'pk_xxx' })
|
|
41
|
+
*
|
|
42
|
+
* // Track a custom event
|
|
43
|
+
* outlit.track({
|
|
44
|
+
* email: 'user@example.com',
|
|
45
|
+
* eventName: 'subscription_created',
|
|
46
|
+
* properties: { plan: 'pro' }
|
|
47
|
+
* })
|
|
48
|
+
*
|
|
49
|
+
* // Identify/update user
|
|
50
|
+
* outlit.identify({
|
|
51
|
+
* email: 'user@example.com',
|
|
52
|
+
* userId: 'usr_123',
|
|
53
|
+
* traits: { name: 'John Doe' }
|
|
54
|
+
* })
|
|
55
|
+
*
|
|
56
|
+
* // Flush before shutdown (important for serverless)
|
|
57
|
+
* await outlit.flush()
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
declare class Outlit {
|
|
61
|
+
private transport;
|
|
62
|
+
private queue;
|
|
63
|
+
private flushTimer;
|
|
64
|
+
private flushInterval;
|
|
65
|
+
private isShutdown;
|
|
66
|
+
constructor(options: OutlitOptions);
|
|
67
|
+
/**
|
|
68
|
+
* Track a custom event.
|
|
69
|
+
*
|
|
70
|
+
* Requires either `email` or `userId` to identify the user.
|
|
71
|
+
*
|
|
72
|
+
* @throws Error if neither email nor userId is provided
|
|
73
|
+
*/
|
|
74
|
+
track(options: ServerTrackOptions): void;
|
|
75
|
+
/**
|
|
76
|
+
* Identify or update a user.
|
|
77
|
+
*
|
|
78
|
+
* Requires either `email` or `userId` to identify the user.
|
|
79
|
+
*
|
|
80
|
+
* @throws Error if neither email nor userId is provided
|
|
81
|
+
*/
|
|
82
|
+
identify(options: ServerIdentifyOptions): void;
|
|
83
|
+
/**
|
|
84
|
+
* Flush all pending events immediately.
|
|
85
|
+
*
|
|
86
|
+
* Important: Call this before your serverless function exits!
|
|
87
|
+
*/
|
|
88
|
+
flush(): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Shutdown the client gracefully.
|
|
91
|
+
*
|
|
92
|
+
* Flushes remaining events and stops the flush timer.
|
|
93
|
+
*/
|
|
94
|
+
shutdown(): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Get the number of events waiting to be sent.
|
|
97
|
+
*/
|
|
98
|
+
get queueSize(): number;
|
|
99
|
+
private startFlushTimer;
|
|
100
|
+
private sendEvents;
|
|
101
|
+
private ensureNotShutdown;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export { Outlit, type OutlitOptions };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
Outlit: () => Outlit
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(src_exports);
|
|
26
|
+
|
|
27
|
+
// src/client.ts
|
|
28
|
+
var import_core = require("@outlit/core");
|
|
29
|
+
|
|
30
|
+
// src/queue.ts
|
|
31
|
+
var EventQueue = class {
|
|
32
|
+
queue = [];
|
|
33
|
+
maxSize;
|
|
34
|
+
onFlush;
|
|
35
|
+
isFlushing = false;
|
|
36
|
+
constructor(options) {
|
|
37
|
+
this.maxSize = options.maxSize ?? 100;
|
|
38
|
+
this.onFlush = options.onFlush;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Add an event to the queue.
|
|
42
|
+
* Triggers flush if queue reaches max size.
|
|
43
|
+
*/
|
|
44
|
+
async enqueue(event) {
|
|
45
|
+
this.queue.push(event);
|
|
46
|
+
if (this.queue.length >= this.maxSize) {
|
|
47
|
+
await this.flush();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Flush all events in the queue.
|
|
52
|
+
*/
|
|
53
|
+
async flush() {
|
|
54
|
+
if (this.isFlushing || this.queue.length === 0) return;
|
|
55
|
+
this.isFlushing = true;
|
|
56
|
+
const events = [...this.queue];
|
|
57
|
+
this.queue = [];
|
|
58
|
+
try {
|
|
59
|
+
await this.onFlush(events);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
this.queue = [...events, ...this.queue];
|
|
62
|
+
throw error;
|
|
63
|
+
} finally {
|
|
64
|
+
this.isFlushing = false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get the number of events in the queue.
|
|
69
|
+
*/
|
|
70
|
+
get size() {
|
|
71
|
+
return this.queue.length;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Check if the queue is currently flushing.
|
|
75
|
+
*/
|
|
76
|
+
get flushing() {
|
|
77
|
+
return this.isFlushing;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// src/transport.ts
|
|
82
|
+
var HttpTransport = class {
|
|
83
|
+
apiHost;
|
|
84
|
+
publicKey;
|
|
85
|
+
timeout;
|
|
86
|
+
constructor(options) {
|
|
87
|
+
this.apiHost = options.apiHost;
|
|
88
|
+
this.publicKey = options.publicKey;
|
|
89
|
+
this.timeout = options.timeout ?? 1e4;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Send events to the ingest API.
|
|
93
|
+
*/
|
|
94
|
+
async send(payload) {
|
|
95
|
+
const url = `${this.apiHost}/api/i/v1/${this.publicKey}/events`;
|
|
96
|
+
const controller = new AbortController();
|
|
97
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
98
|
+
try {
|
|
99
|
+
const response = await fetch(url, {
|
|
100
|
+
method: "POST",
|
|
101
|
+
headers: {
|
|
102
|
+
"Content-Type": "application/json"
|
|
103
|
+
},
|
|
104
|
+
body: JSON.stringify(payload),
|
|
105
|
+
signal: controller.signal
|
|
106
|
+
});
|
|
107
|
+
if (!response.ok) {
|
|
108
|
+
const errorBody = await response.text().catch(() => "Unknown error");
|
|
109
|
+
throw new Error(`HTTP ${response.status}: ${errorBody}`);
|
|
110
|
+
}
|
|
111
|
+
return await response.json();
|
|
112
|
+
} catch (error) {
|
|
113
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
114
|
+
throw new Error(`Request timed out after ${this.timeout}ms`);
|
|
115
|
+
}
|
|
116
|
+
throw error;
|
|
117
|
+
} finally {
|
|
118
|
+
clearTimeout(timeoutId);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// src/client.ts
|
|
124
|
+
var Outlit = class {
|
|
125
|
+
transport;
|
|
126
|
+
queue;
|
|
127
|
+
flushTimer = null;
|
|
128
|
+
flushInterval;
|
|
129
|
+
isShutdown = false;
|
|
130
|
+
constructor(options) {
|
|
131
|
+
const apiHost = options.apiHost ?? import_core.DEFAULT_API_HOST;
|
|
132
|
+
this.flushInterval = options.flushInterval ?? 1e4;
|
|
133
|
+
this.transport = new HttpTransport({
|
|
134
|
+
apiHost,
|
|
135
|
+
publicKey: options.publicKey,
|
|
136
|
+
timeout: options.timeout
|
|
137
|
+
});
|
|
138
|
+
this.queue = new EventQueue({
|
|
139
|
+
maxSize: options.maxBatchSize ?? 100,
|
|
140
|
+
onFlush: async (events) => {
|
|
141
|
+
await this.sendEvents(events);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
this.startFlushTimer();
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Track a custom event.
|
|
148
|
+
*
|
|
149
|
+
* Requires either `email` or `userId` to identify the user.
|
|
150
|
+
*
|
|
151
|
+
* @throws Error if neither email nor userId is provided
|
|
152
|
+
*/
|
|
153
|
+
track(options) {
|
|
154
|
+
this.ensureNotShutdown();
|
|
155
|
+
(0, import_core.validateServerIdentity)(options.email, options.userId);
|
|
156
|
+
const event = (0, import_core.buildCustomEvent)({
|
|
157
|
+
url: `server://${options.email ?? options.userId}`,
|
|
158
|
+
timestamp: options.timestamp,
|
|
159
|
+
eventName: options.eventName,
|
|
160
|
+
properties: {
|
|
161
|
+
...options.properties,
|
|
162
|
+
// Include identity in properties for server-side resolution
|
|
163
|
+
__email: options.email ?? null,
|
|
164
|
+
__userId: options.userId ?? null
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
this.queue.enqueue(event);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Identify or update a user.
|
|
171
|
+
*
|
|
172
|
+
* Requires either `email` or `userId` to identify the user.
|
|
173
|
+
*
|
|
174
|
+
* @throws Error if neither email nor userId is provided
|
|
175
|
+
*/
|
|
176
|
+
identify(options) {
|
|
177
|
+
this.ensureNotShutdown();
|
|
178
|
+
(0, import_core.validateServerIdentity)(options.email, options.userId);
|
|
179
|
+
const event = (0, import_core.buildIdentifyEvent)({
|
|
180
|
+
url: `server://${options.email ?? options.userId}`,
|
|
181
|
+
email: options.email,
|
|
182
|
+
userId: options.userId,
|
|
183
|
+
traits: options.traits
|
|
184
|
+
});
|
|
185
|
+
this.queue.enqueue(event);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Flush all pending events immediately.
|
|
189
|
+
*
|
|
190
|
+
* Important: Call this before your serverless function exits!
|
|
191
|
+
*/
|
|
192
|
+
async flush() {
|
|
193
|
+
await this.queue.flush();
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Shutdown the client gracefully.
|
|
197
|
+
*
|
|
198
|
+
* Flushes remaining events and stops the flush timer.
|
|
199
|
+
*/
|
|
200
|
+
async shutdown() {
|
|
201
|
+
if (this.isShutdown) return;
|
|
202
|
+
this.isShutdown = true;
|
|
203
|
+
if (this.flushTimer) {
|
|
204
|
+
clearInterval(this.flushTimer);
|
|
205
|
+
this.flushTimer = null;
|
|
206
|
+
}
|
|
207
|
+
await this.flush();
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Get the number of events waiting to be sent.
|
|
211
|
+
*/
|
|
212
|
+
get queueSize() {
|
|
213
|
+
return this.queue.size;
|
|
214
|
+
}
|
|
215
|
+
// ============================================
|
|
216
|
+
// INTERNAL METHODS
|
|
217
|
+
// ============================================
|
|
218
|
+
startFlushTimer() {
|
|
219
|
+
if (this.flushTimer) return;
|
|
220
|
+
this.flushTimer = setInterval(() => {
|
|
221
|
+
this.flush().catch((error) => {
|
|
222
|
+
console.error("[Outlit] Flush error:", error);
|
|
223
|
+
});
|
|
224
|
+
}, this.flushInterval);
|
|
225
|
+
if (this.flushTimer.unref) {
|
|
226
|
+
this.flushTimer.unref();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
async sendEvents(events) {
|
|
230
|
+
if (events.length === 0) return;
|
|
231
|
+
const payload = {
|
|
232
|
+
source: "server",
|
|
233
|
+
events
|
|
234
|
+
// visitorId is intentionally omitted for server events
|
|
235
|
+
};
|
|
236
|
+
await this.transport.send(payload);
|
|
237
|
+
}
|
|
238
|
+
ensureNotShutdown() {
|
|
239
|
+
if (this.isShutdown) {
|
|
240
|
+
throw new Error(
|
|
241
|
+
"[Outlit] Client has been shutdown. Create a new instance to continue tracking."
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
247
|
+
0 && (module.exports = {
|
|
248
|
+
Outlit
|
|
249
|
+
});
|
|
250
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/client.ts","../src/queue.ts","../src/transport.ts"],"sourcesContent":["// Main export\nexport { Outlit } from \"./client\"\nexport type { OutlitOptions } from \"./client\"\n\n// Re-export useful types from core\nexport type {\n ServerTrackOptions,\n ServerIdentifyOptions,\n TrackerConfig,\n IngestResponse,\n} from \"@outlit/core\"\n","import {\n DEFAULT_API_HOST,\n type IngestPayload,\n type ServerIdentifyOptions,\n type ServerTrackOptions,\n type TrackerEvent,\n buildCustomEvent,\n buildIdentifyEvent,\n validateServerIdentity,\n} from \"@outlit/core\"\nimport { EventQueue } from \"./queue\"\nimport { HttpTransport } from \"./transport\"\n\n// ============================================\n// OUTLIT CLIENT\n// ============================================\n\nexport interface OutlitOptions {\n /**\n * Your Outlit public key.\n */\n publicKey: string\n\n /**\n * API host URL.\n * @default \"https://app.outlit.ai\"\n */\n apiHost?: string\n\n /**\n * How often to flush events (in milliseconds).\n * @default 10000 (10 seconds)\n */\n flushInterval?: number\n\n /**\n * Maximum number of events to batch before flushing.\n * @default 100\n */\n maxBatchSize?: number\n\n /**\n * Request timeout in milliseconds.\n * @default 10000 (10 seconds)\n */\n timeout?: number\n}\n\n/**\n * Outlit server-side tracking client.\n *\n * Unlike the browser SDK, this requires identity (email or userId) for all calls.\n * Anonymous tracking is not supported server-side.\n *\n * @example\n * ```typescript\n * import { Outlit } from '@outlit/tracker-node'\n *\n * const outlit = new Outlit({ publicKey: 'pk_xxx' })\n *\n * // Track a custom event\n * outlit.track({\n * email: 'user@example.com',\n * eventName: 'subscription_created',\n * properties: { plan: 'pro' }\n * })\n *\n * // Identify/update user\n * outlit.identify({\n * email: 'user@example.com',\n * userId: 'usr_123',\n * traits: { name: 'John Doe' }\n * })\n *\n * // Flush before shutdown (important for serverless)\n * await outlit.flush()\n * ```\n */\nexport class Outlit {\n private transport: HttpTransport\n private queue: EventQueue\n private flushTimer: ReturnType<typeof setInterval> | null = null\n private flushInterval: number\n private isShutdown = false\n\n constructor(options: OutlitOptions) {\n const apiHost = options.apiHost ?? DEFAULT_API_HOST\n this.flushInterval = options.flushInterval ?? 10000\n\n this.transport = new HttpTransport({\n apiHost,\n publicKey: options.publicKey,\n timeout: options.timeout,\n })\n\n this.queue = new EventQueue({\n maxSize: options.maxBatchSize ?? 100,\n onFlush: async (events) => {\n await this.sendEvents(events)\n },\n })\n\n // Start flush timer\n this.startFlushTimer()\n }\n\n /**\n * Track a custom event.\n *\n * Requires either `email` or `userId` to identify the user.\n *\n * @throws Error if neither email nor userId is provided\n */\n track(options: ServerTrackOptions): void {\n this.ensureNotShutdown()\n validateServerIdentity(options.email, options.userId)\n\n const event = buildCustomEvent({\n url: `server://${options.email ?? options.userId}`,\n timestamp: options.timestamp,\n eventName: options.eventName,\n properties: {\n ...options.properties,\n // Include identity in properties for server-side resolution\n __email: options.email ?? null,\n __userId: options.userId ?? null,\n },\n })\n\n this.queue.enqueue(event)\n }\n\n /**\n * Identify or update a user.\n *\n * Requires either `email` or `userId` to identify the user.\n *\n * @throws Error if neither email nor userId is provided\n */\n identify(options: ServerIdentifyOptions): void {\n this.ensureNotShutdown()\n validateServerIdentity(options.email, options.userId)\n\n const event = buildIdentifyEvent({\n url: `server://${options.email ?? options.userId}`,\n email: options.email,\n userId: options.userId,\n traits: options.traits,\n })\n\n this.queue.enqueue(event)\n }\n\n /**\n * Flush all pending events immediately.\n *\n * Important: Call this before your serverless function exits!\n */\n async flush(): Promise<void> {\n await this.queue.flush()\n }\n\n /**\n * Shutdown the client gracefully.\n *\n * Flushes remaining events and stops the flush timer.\n */\n async shutdown(): Promise<void> {\n if (this.isShutdown) return\n\n this.isShutdown = true\n\n if (this.flushTimer) {\n clearInterval(this.flushTimer)\n this.flushTimer = null\n }\n\n await this.flush()\n }\n\n /**\n * Get the number of events waiting to be sent.\n */\n get queueSize(): number {\n return this.queue.size\n }\n\n // ============================================\n // INTERNAL METHODS\n // ============================================\n\n private startFlushTimer(): void {\n if (this.flushTimer) return\n\n this.flushTimer = setInterval(() => {\n this.flush().catch((error) => {\n console.error(\"[Outlit] Flush error:\", error)\n })\n }, this.flushInterval)\n\n // Don't block process exit\n if (this.flushTimer.unref) {\n this.flushTimer.unref()\n }\n }\n\n private async sendEvents(events: TrackerEvent[]): Promise<void> {\n if (events.length === 0) return\n\n // For server events, we don't use visitorId - the API resolves identity\n // directly from the event data (email/userId)\n const payload: IngestPayload = {\n source: \"server\",\n events,\n // visitorId is intentionally omitted for server events\n }\n\n await this.transport.send(payload)\n }\n\n private ensureNotShutdown(): void {\n if (this.isShutdown) {\n throw new Error(\n \"[Outlit] Client has been shutdown. Create a new instance to continue tracking.\",\n )\n }\n }\n}\n","import type { TrackerEvent } from \"@outlit/core\"\n\n// ============================================\n// EVENT QUEUE\n// ============================================\n\nexport interface QueueOptions {\n maxSize?: number\n onFlush: (events: TrackerEvent[]) => Promise<void>\n}\n\nexport class EventQueue {\n private queue: TrackerEvent[] = []\n private maxSize: number\n private onFlush: (events: TrackerEvent[]) => Promise<void>\n private isFlushing = false\n\n constructor(options: QueueOptions) {\n this.maxSize = options.maxSize ?? 100\n this.onFlush = options.onFlush\n }\n\n /**\n * Add an event to the queue.\n * Triggers flush if queue reaches max size.\n */\n async enqueue(event: TrackerEvent): Promise<void> {\n this.queue.push(event)\n\n if (this.queue.length >= this.maxSize) {\n await this.flush()\n }\n }\n\n /**\n * Flush all events in the queue.\n */\n async flush(): Promise<void> {\n if (this.isFlushing || this.queue.length === 0) return\n\n this.isFlushing = true\n const events = [...this.queue]\n this.queue = []\n\n try {\n await this.onFlush(events)\n } catch (error) {\n // Re-add events to queue on failure\n this.queue = [...events, ...this.queue]\n throw error\n } finally {\n this.isFlushing = false\n }\n }\n\n /**\n * Get the number of events in the queue.\n */\n get size(): number {\n return this.queue.length\n }\n\n /**\n * Check if the queue is currently flushing.\n */\n get flushing(): boolean {\n return this.isFlushing\n }\n}\n","import type { IngestPayload, IngestResponse } from \"@outlit/core\"\n\n// ============================================\n// HTTP TRANSPORT\n// ============================================\n\nexport interface TransportOptions {\n apiHost: string\n publicKey: string\n timeout?: number\n}\n\nexport class HttpTransport {\n private apiHost: string\n private publicKey: string\n private timeout: number\n\n constructor(options: TransportOptions) {\n this.apiHost = options.apiHost\n this.publicKey = options.publicKey\n this.timeout = options.timeout ?? 10000\n }\n\n /**\n * Send events to the ingest API.\n */\n async send(payload: IngestPayload): Promise<IngestResponse> {\n const url = `${this.apiHost}/api/i/v1/${this.publicKey}/events`\n\n const controller = new AbortController()\n const timeoutId = setTimeout(() => controller.abort(), this.timeout)\n\n try {\n const response = await fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(payload),\n signal: controller.signal,\n })\n\n if (!response.ok) {\n const errorBody = await response.text().catch(() => \"Unknown error\")\n throw new Error(`HTTP ${response.status}: ${errorBody}`)\n }\n\n return (await response.json()) as IngestResponse\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n throw new Error(`Request timed out after ${this.timeout}ms`)\n }\n throw error\n } finally {\n clearTimeout(timeoutId)\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBASO;;;ACEA,IAAM,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AAA,MAC9C,CAAC;AAAA,IACH,GAAG,KAAK,aAAa;AAGrB,QAAI,KAAK,WAAW,OAAO;AACzB,WAAK,WAAW,MAAM;AAAA,IACxB;AAAA,EACF;AAAA,EAEA,MAAc,WAAW,QAAuC;AAC9D,QAAI,OAAO,WAAW,EAAG;AAIzB,UAAM,UAAyB;AAAA,MAC7B,QAAQ;AAAA,MACR;AAAA;AAAA,IAEF;AAEA,UAAM,KAAK,UAAU,KAAK,OAAO;AAAA,EACnC;AAAA,EAEQ,oBAA0B;AAChC,QAAI,KAAK,YAAY;AACnB,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
// src/client.ts
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_API_HOST,
|
|
4
|
+
buildCustomEvent,
|
|
5
|
+
buildIdentifyEvent,
|
|
6
|
+
validateServerIdentity
|
|
7
|
+
} from "@outlit/core";
|
|
8
|
+
|
|
9
|
+
// src/queue.ts
|
|
10
|
+
var EventQueue = class {
|
|
11
|
+
queue = [];
|
|
12
|
+
maxSize;
|
|
13
|
+
onFlush;
|
|
14
|
+
isFlushing = false;
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this.maxSize = options.maxSize ?? 100;
|
|
17
|
+
this.onFlush = options.onFlush;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Add an event to the queue.
|
|
21
|
+
* Triggers flush if queue reaches max size.
|
|
22
|
+
*/
|
|
23
|
+
async enqueue(event) {
|
|
24
|
+
this.queue.push(event);
|
|
25
|
+
if (this.queue.length >= this.maxSize) {
|
|
26
|
+
await this.flush();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Flush all events in the queue.
|
|
31
|
+
*/
|
|
32
|
+
async flush() {
|
|
33
|
+
if (this.isFlushing || this.queue.length === 0) return;
|
|
34
|
+
this.isFlushing = true;
|
|
35
|
+
const events = [...this.queue];
|
|
36
|
+
this.queue = [];
|
|
37
|
+
try {
|
|
38
|
+
await this.onFlush(events);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
this.queue = [...events, ...this.queue];
|
|
41
|
+
throw error;
|
|
42
|
+
} finally {
|
|
43
|
+
this.isFlushing = false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get the number of events in the queue.
|
|
48
|
+
*/
|
|
49
|
+
get size() {
|
|
50
|
+
return this.queue.length;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Check if the queue is currently flushing.
|
|
54
|
+
*/
|
|
55
|
+
get flushing() {
|
|
56
|
+
return this.isFlushing;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// src/transport.ts
|
|
61
|
+
var HttpTransport = class {
|
|
62
|
+
apiHost;
|
|
63
|
+
publicKey;
|
|
64
|
+
timeout;
|
|
65
|
+
constructor(options) {
|
|
66
|
+
this.apiHost = options.apiHost;
|
|
67
|
+
this.publicKey = options.publicKey;
|
|
68
|
+
this.timeout = options.timeout ?? 1e4;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Send events to the ingest API.
|
|
72
|
+
*/
|
|
73
|
+
async send(payload) {
|
|
74
|
+
const url = `${this.apiHost}/api/i/v1/${this.publicKey}/events`;
|
|
75
|
+
const controller = new AbortController();
|
|
76
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
77
|
+
try {
|
|
78
|
+
const response = await fetch(url, {
|
|
79
|
+
method: "POST",
|
|
80
|
+
headers: {
|
|
81
|
+
"Content-Type": "application/json"
|
|
82
|
+
},
|
|
83
|
+
body: JSON.stringify(payload),
|
|
84
|
+
signal: controller.signal
|
|
85
|
+
});
|
|
86
|
+
if (!response.ok) {
|
|
87
|
+
const errorBody = await response.text().catch(() => "Unknown error");
|
|
88
|
+
throw new Error(`HTTP ${response.status}: ${errorBody}`);
|
|
89
|
+
}
|
|
90
|
+
return await response.json();
|
|
91
|
+
} catch (error) {
|
|
92
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
93
|
+
throw new Error(`Request timed out after ${this.timeout}ms`);
|
|
94
|
+
}
|
|
95
|
+
throw error;
|
|
96
|
+
} finally {
|
|
97
|
+
clearTimeout(timeoutId);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// src/client.ts
|
|
103
|
+
var Outlit = class {
|
|
104
|
+
transport;
|
|
105
|
+
queue;
|
|
106
|
+
flushTimer = null;
|
|
107
|
+
flushInterval;
|
|
108
|
+
isShutdown = false;
|
|
109
|
+
constructor(options) {
|
|
110
|
+
const apiHost = options.apiHost ?? DEFAULT_API_HOST;
|
|
111
|
+
this.flushInterval = options.flushInterval ?? 1e4;
|
|
112
|
+
this.transport = new HttpTransport({
|
|
113
|
+
apiHost,
|
|
114
|
+
publicKey: options.publicKey,
|
|
115
|
+
timeout: options.timeout
|
|
116
|
+
});
|
|
117
|
+
this.queue = new EventQueue({
|
|
118
|
+
maxSize: options.maxBatchSize ?? 100,
|
|
119
|
+
onFlush: async (events) => {
|
|
120
|
+
await this.sendEvents(events);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
this.startFlushTimer();
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Track a custom event.
|
|
127
|
+
*
|
|
128
|
+
* Requires either `email` or `userId` to identify the user.
|
|
129
|
+
*
|
|
130
|
+
* @throws Error if neither email nor userId is provided
|
|
131
|
+
*/
|
|
132
|
+
track(options) {
|
|
133
|
+
this.ensureNotShutdown();
|
|
134
|
+
validateServerIdentity(options.email, options.userId);
|
|
135
|
+
const event = buildCustomEvent({
|
|
136
|
+
url: `server://${options.email ?? options.userId}`,
|
|
137
|
+
timestamp: options.timestamp,
|
|
138
|
+
eventName: options.eventName,
|
|
139
|
+
properties: {
|
|
140
|
+
...options.properties,
|
|
141
|
+
// Include identity in properties for server-side resolution
|
|
142
|
+
__email: options.email ?? null,
|
|
143
|
+
__userId: options.userId ?? null
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
this.queue.enqueue(event);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Identify or update a user.
|
|
150
|
+
*
|
|
151
|
+
* Requires either `email` or `userId` to identify the user.
|
|
152
|
+
*
|
|
153
|
+
* @throws Error if neither email nor userId is provided
|
|
154
|
+
*/
|
|
155
|
+
identify(options) {
|
|
156
|
+
this.ensureNotShutdown();
|
|
157
|
+
validateServerIdentity(options.email, options.userId);
|
|
158
|
+
const event = buildIdentifyEvent({
|
|
159
|
+
url: `server://${options.email ?? options.userId}`,
|
|
160
|
+
email: options.email,
|
|
161
|
+
userId: options.userId,
|
|
162
|
+
traits: options.traits
|
|
163
|
+
});
|
|
164
|
+
this.queue.enqueue(event);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Flush all pending events immediately.
|
|
168
|
+
*
|
|
169
|
+
* Important: Call this before your serverless function exits!
|
|
170
|
+
*/
|
|
171
|
+
async flush() {
|
|
172
|
+
await this.queue.flush();
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Shutdown the client gracefully.
|
|
176
|
+
*
|
|
177
|
+
* Flushes remaining events and stops the flush timer.
|
|
178
|
+
*/
|
|
179
|
+
async shutdown() {
|
|
180
|
+
if (this.isShutdown) return;
|
|
181
|
+
this.isShutdown = true;
|
|
182
|
+
if (this.flushTimer) {
|
|
183
|
+
clearInterval(this.flushTimer);
|
|
184
|
+
this.flushTimer = null;
|
|
185
|
+
}
|
|
186
|
+
await this.flush();
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Get the number of events waiting to be sent.
|
|
190
|
+
*/
|
|
191
|
+
get queueSize() {
|
|
192
|
+
return this.queue.size;
|
|
193
|
+
}
|
|
194
|
+
// ============================================
|
|
195
|
+
// INTERNAL METHODS
|
|
196
|
+
// ============================================
|
|
197
|
+
startFlushTimer() {
|
|
198
|
+
if (this.flushTimer) return;
|
|
199
|
+
this.flushTimer = setInterval(() => {
|
|
200
|
+
this.flush().catch((error) => {
|
|
201
|
+
console.error("[Outlit] Flush error:", error);
|
|
202
|
+
});
|
|
203
|
+
}, this.flushInterval);
|
|
204
|
+
if (this.flushTimer.unref) {
|
|
205
|
+
this.flushTimer.unref();
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
async sendEvents(events) {
|
|
209
|
+
if (events.length === 0) return;
|
|
210
|
+
const payload = {
|
|
211
|
+
source: "server",
|
|
212
|
+
events
|
|
213
|
+
// visitorId is intentionally omitted for server events
|
|
214
|
+
};
|
|
215
|
+
await this.transport.send(payload);
|
|
216
|
+
}
|
|
217
|
+
ensureNotShutdown() {
|
|
218
|
+
if (this.isShutdown) {
|
|
219
|
+
throw new Error(
|
|
220
|
+
"[Outlit] Client has been shutdown. Create a new instance to continue tracking."
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
export {
|
|
226
|
+
Outlit
|
|
227
|
+
};
|
|
228
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/client.ts","../src/queue.ts","../src/transport.ts"],"sourcesContent":["import {\n DEFAULT_API_HOST,\n type IngestPayload,\n type ServerIdentifyOptions,\n type ServerTrackOptions,\n type TrackerEvent,\n buildCustomEvent,\n buildIdentifyEvent,\n validateServerIdentity,\n} from \"@outlit/core\"\nimport { EventQueue } from \"./queue\"\nimport { HttpTransport } from \"./transport\"\n\n// ============================================\n// OUTLIT CLIENT\n// ============================================\n\nexport interface OutlitOptions {\n /**\n * Your Outlit public key.\n */\n publicKey: string\n\n /**\n * API host URL.\n * @default \"https://app.outlit.ai\"\n */\n apiHost?: string\n\n /**\n * How often to flush events (in milliseconds).\n * @default 10000 (10 seconds)\n */\n flushInterval?: number\n\n /**\n * Maximum number of events to batch before flushing.\n * @default 100\n */\n maxBatchSize?: number\n\n /**\n * Request timeout in milliseconds.\n * @default 10000 (10 seconds)\n */\n timeout?: number\n}\n\n/**\n * Outlit server-side tracking client.\n *\n * Unlike the browser SDK, this requires identity (email or userId) for all calls.\n * Anonymous tracking is not supported server-side.\n *\n * @example\n * ```typescript\n * import { Outlit } from '@outlit/tracker-node'\n *\n * const outlit = new Outlit({ publicKey: 'pk_xxx' })\n *\n * // Track a custom event\n * outlit.track({\n * email: 'user@example.com',\n * eventName: 'subscription_created',\n * properties: { plan: 'pro' }\n * })\n *\n * // Identify/update user\n * outlit.identify({\n * email: 'user@example.com',\n * userId: 'usr_123',\n * traits: { name: 'John Doe' }\n * })\n *\n * // Flush before shutdown (important for serverless)\n * await outlit.flush()\n * ```\n */\nexport class Outlit {\n private transport: HttpTransport\n private queue: EventQueue\n private flushTimer: ReturnType<typeof setInterval> | null = null\n private flushInterval: number\n private isShutdown = false\n\n constructor(options: OutlitOptions) {\n const apiHost = options.apiHost ?? DEFAULT_API_HOST\n this.flushInterval = options.flushInterval ?? 10000\n\n this.transport = new HttpTransport({\n apiHost,\n publicKey: options.publicKey,\n timeout: options.timeout,\n })\n\n this.queue = new EventQueue({\n maxSize: options.maxBatchSize ?? 100,\n onFlush: async (events) => {\n await this.sendEvents(events)\n },\n })\n\n // Start flush timer\n this.startFlushTimer()\n }\n\n /**\n * Track a custom event.\n *\n * Requires either `email` or `userId` to identify the user.\n *\n * @throws Error if neither email nor userId is provided\n */\n track(options: ServerTrackOptions): void {\n this.ensureNotShutdown()\n validateServerIdentity(options.email, options.userId)\n\n const event = buildCustomEvent({\n url: `server://${options.email ?? options.userId}`,\n timestamp: options.timestamp,\n eventName: options.eventName,\n properties: {\n ...options.properties,\n // Include identity in properties for server-side resolution\n __email: options.email ?? null,\n __userId: options.userId ?? null,\n },\n })\n\n this.queue.enqueue(event)\n }\n\n /**\n * Identify or update a user.\n *\n * Requires either `email` or `userId` to identify the user.\n *\n * @throws Error if neither email nor userId is provided\n */\n identify(options: ServerIdentifyOptions): void {\n this.ensureNotShutdown()\n validateServerIdentity(options.email, options.userId)\n\n const event = buildIdentifyEvent({\n url: `server://${options.email ?? options.userId}`,\n email: options.email,\n userId: options.userId,\n traits: options.traits,\n })\n\n this.queue.enqueue(event)\n }\n\n /**\n * Flush all pending events immediately.\n *\n * Important: Call this before your serverless function exits!\n */\n async flush(): Promise<void> {\n await this.queue.flush()\n }\n\n /**\n * Shutdown the client gracefully.\n *\n * Flushes remaining events and stops the flush timer.\n */\n async shutdown(): Promise<void> {\n if (this.isShutdown) return\n\n this.isShutdown = true\n\n if (this.flushTimer) {\n clearInterval(this.flushTimer)\n this.flushTimer = null\n }\n\n await this.flush()\n }\n\n /**\n * Get the number of events waiting to be sent.\n */\n get queueSize(): number {\n return this.queue.size\n }\n\n // ============================================\n // INTERNAL METHODS\n // ============================================\n\n private startFlushTimer(): void {\n if (this.flushTimer) return\n\n this.flushTimer = setInterval(() => {\n this.flush().catch((error) => {\n console.error(\"[Outlit] Flush error:\", error)\n })\n }, this.flushInterval)\n\n // Don't block process exit\n if (this.flushTimer.unref) {\n this.flushTimer.unref()\n }\n }\n\n private async sendEvents(events: TrackerEvent[]): Promise<void> {\n if (events.length === 0) return\n\n // For server events, we don't use visitorId - the API resolves identity\n // directly from the event data (email/userId)\n const payload: IngestPayload = {\n source: \"server\",\n events,\n // visitorId is intentionally omitted for server events\n }\n\n await this.transport.send(payload)\n }\n\n private ensureNotShutdown(): void {\n if (this.isShutdown) {\n throw new Error(\n \"[Outlit] Client has been shutdown. Create a new instance to continue tracking.\",\n )\n }\n }\n}\n","import type { TrackerEvent } from \"@outlit/core\"\n\n// ============================================\n// EVENT QUEUE\n// ============================================\n\nexport interface QueueOptions {\n maxSize?: number\n onFlush: (events: TrackerEvent[]) => Promise<void>\n}\n\nexport class EventQueue {\n private queue: TrackerEvent[] = []\n private maxSize: number\n private onFlush: (events: TrackerEvent[]) => Promise<void>\n private isFlushing = false\n\n constructor(options: QueueOptions) {\n this.maxSize = options.maxSize ?? 100\n this.onFlush = options.onFlush\n }\n\n /**\n * Add an event to the queue.\n * Triggers flush if queue reaches max size.\n */\n async enqueue(event: TrackerEvent): Promise<void> {\n this.queue.push(event)\n\n if (this.queue.length >= this.maxSize) {\n await this.flush()\n }\n }\n\n /**\n * Flush all events in the queue.\n */\n async flush(): Promise<void> {\n if (this.isFlushing || this.queue.length === 0) return\n\n this.isFlushing = true\n const events = [...this.queue]\n this.queue = []\n\n try {\n await this.onFlush(events)\n } catch (error) {\n // Re-add events to queue on failure\n this.queue = [...events, ...this.queue]\n throw error\n } finally {\n this.isFlushing = false\n }\n }\n\n /**\n * Get the number of events in the queue.\n */\n get size(): number {\n return this.queue.length\n }\n\n /**\n * Check if the queue is currently flushing.\n */\n get flushing(): boolean {\n return this.isFlushing\n }\n}\n","import type { IngestPayload, IngestResponse } from \"@outlit/core\"\n\n// ============================================\n// HTTP TRANSPORT\n// ============================================\n\nexport interface TransportOptions {\n apiHost: string\n publicKey: string\n timeout?: number\n}\n\nexport class HttpTransport {\n private apiHost: string\n private publicKey: string\n private timeout: number\n\n constructor(options: TransportOptions) {\n this.apiHost = options.apiHost\n this.publicKey = options.publicKey\n this.timeout = options.timeout ?? 10000\n }\n\n /**\n * Send events to the ingest API.\n */\n async send(payload: IngestPayload): Promise<IngestResponse> {\n const url = `${this.apiHost}/api/i/v1/${this.publicKey}/events`\n\n const controller = new AbortController()\n const timeoutId = setTimeout(() => controller.abort(), this.timeout)\n\n try {\n const response = await fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(payload),\n signal: controller.signal,\n })\n\n if (!response.ok) {\n const errorBody = await response.text().catch(() => \"Unknown error\")\n throw new Error(`HTTP ${response.status}: ${errorBody}`)\n }\n\n return (await response.json()) as IngestResponse\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n throw new Error(`Request timed out after ${this.timeout}ms`)\n }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B,QAAI,KAAK,WAAY;AAErB,SAAK,aAAa,YAAY,MAAM;AAClC,WAAK,MAAM,EAAE,MAAM,CAAC,UAAU;AAC5B,gBAAQ,MAAM,yBAAyB,KAAK;AAAA,MAC9C,CAAC;AAAA,IACH,GAAG,KAAK,aAAa;AAGrB,QAAI,KAAK,WAAW,OAAO;AACzB,WAAK,WAAW,MAAM;AAAA,IACxB;AAAA,EACF;AAAA,EAEA,MAAc,WAAW,QAAuC;AAC9D,QAAI,OAAO,WAAW,EAAG;AAIzB,UAAM,UAAyB;AAAA,MAC7B,QAAQ;AAAA,MACR;AAAA;AAAA,IAEF;AAEA,UAAM,KAAK,UAAU,KAAK,OAAO;AAAA,EACnC;AAAA,EAEQ,oBAA0B;AAChC,QAAI,KAAK,YAAY;AACnB,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@outlit/node",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Outlit server-side tracking SDK for Node.js",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "Outlit AI",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/OutlitAI/outlit-sdk.git",
|
|
10
|
+
"directory": "packages/node"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/OutlitAI/outlit-sdk/issues"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/OutlitAI/outlit-sdk#readme",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"outlit",
|
|
18
|
+
"analytics",
|
|
19
|
+
"tracking",
|
|
20
|
+
"sdk",
|
|
21
|
+
"node",
|
|
22
|
+
"server"
|
|
23
|
+
],
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"module": "./dist/index.mjs",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"import": "./dist/index.mjs",
|
|
34
|
+
"require": "./dist/index.js",
|
|
35
|
+
"default": "./dist/index.mjs"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist"
|
|
40
|
+
],
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=18.0.0"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@outlit/core": "0.1.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"tsup": "^8.0.1",
|
|
49
|
+
"typescript": "^5.3.3",
|
|
50
|
+
"@outlit/typescript-config": "0.0.0"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsup",
|
|
54
|
+
"dev": "tsup --watch",
|
|
55
|
+
"clean": "rm -rf dist .turbo node_modules",
|
|
56
|
+
"lint": "biome check . --write",
|
|
57
|
+
"format": "biome format --write .",
|
|
58
|
+
"typecheck": "tsc --noEmit"
|
|
59
|
+
}
|
|
60
|
+
}
|