luchy 0.0.1 → 0.2.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.
@@ -0,0 +1,457 @@
1
+ /**
2
+ * This file was auto-generated by openapi-typescript.
3
+ * Do not make direct changes to the file.
4
+ */
5
+
6
+ export interface paths {
7
+ "/ingest/pageview": {
8
+ parameters: {
9
+ query?: never;
10
+ header?: never;
11
+ path?: never;
12
+ cookie?: never;
13
+ };
14
+ get?: never;
15
+ put?: never;
16
+ post: {
17
+ parameters: {
18
+ query?: never;
19
+ header?: never;
20
+ path?: never;
21
+ cookie?: never;
22
+ };
23
+ requestBody?: {
24
+ content: {
25
+ "application/json": components["schemas"]["PageviewInput"];
26
+ };
27
+ };
28
+ responses: {
29
+ /** @description Pageview tracked successfully */
30
+ 200: {
31
+ headers: {
32
+ [name: string]: unknown;
33
+ };
34
+ content: {
35
+ "application/json": components["schemas"]["SuccessResponse"];
36
+ };
37
+ };
38
+ /** @description Invalid request body or validation error */
39
+ 400: {
40
+ headers: {
41
+ [name: string]: unknown;
42
+ };
43
+ content: {
44
+ "application/json": components["schemas"]["ValidationErrorResponse"];
45
+ };
46
+ };
47
+ /** @description Internal server error */
48
+ 500: {
49
+ headers: {
50
+ [name: string]: unknown;
51
+ };
52
+ content: {
53
+ "application/json": components["schemas"]["ServerErrorResponse"];
54
+ };
55
+ };
56
+ };
57
+ };
58
+ delete?: never;
59
+ options?: never;
60
+ head?: never;
61
+ patch?: never;
62
+ trace?: never;
63
+ };
64
+ "/ingest/event": {
65
+ parameters: {
66
+ query?: never;
67
+ header?: never;
68
+ path?: never;
69
+ cookie?: never;
70
+ };
71
+ get?: never;
72
+ put?: never;
73
+ post: {
74
+ parameters: {
75
+ query?: never;
76
+ header?: never;
77
+ path?: never;
78
+ cookie?: never;
79
+ };
80
+ requestBody?: {
81
+ content: {
82
+ "application/json": components["schemas"]["EventInput"];
83
+ };
84
+ };
85
+ responses: {
86
+ /** @description Event tracked successfully */
87
+ 200: {
88
+ headers: {
89
+ [name: string]: unknown;
90
+ };
91
+ content: {
92
+ "application/json": components["schemas"]["SuccessResponse"];
93
+ };
94
+ };
95
+ /** @description Invalid request body or validation error */
96
+ 400: {
97
+ headers: {
98
+ [name: string]: unknown;
99
+ };
100
+ content: {
101
+ "application/json": components["schemas"]["ValidationErrorResponse"];
102
+ };
103
+ };
104
+ /** @description Internal server error */
105
+ 500: {
106
+ headers: {
107
+ [name: string]: unknown;
108
+ };
109
+ content: {
110
+ "application/json": components["schemas"]["ServerErrorResponse"];
111
+ };
112
+ };
113
+ };
114
+ };
115
+ delete?: never;
116
+ options?: never;
117
+ head?: never;
118
+ patch?: never;
119
+ trace?: never;
120
+ };
121
+ "/query": {
122
+ parameters: {
123
+ query?: never;
124
+ header?: never;
125
+ path?: never;
126
+ cookie?: never;
127
+ };
128
+ get?: never;
129
+ put?: never;
130
+ post: {
131
+ parameters: {
132
+ query?: never;
133
+ header?: never;
134
+ path?: never;
135
+ cookie?: never;
136
+ };
137
+ requestBody?: {
138
+ content: {
139
+ "application/json": components["schemas"]["QueryRequest"];
140
+ };
141
+ };
142
+ responses: {
143
+ /** @description Query executed successfully */
144
+ 200: {
145
+ headers: {
146
+ [name: string]: unknown;
147
+ };
148
+ content: {
149
+ "application/json": components["schemas"]["QueryResponse"];
150
+ };
151
+ };
152
+ /** @description Invalid request body or validation error */
153
+ 400: {
154
+ headers: {
155
+ [name: string]: unknown;
156
+ };
157
+ content: {
158
+ "application/json": components["schemas"]["ValidationErrorResponse"];
159
+ };
160
+ };
161
+ /** @description Internal server error */
162
+ 500: {
163
+ headers: {
164
+ [name: string]: unknown;
165
+ };
166
+ content: {
167
+ "application/json": components["schemas"]["ServerErrorResponse"];
168
+ };
169
+ };
170
+ };
171
+ };
172
+ delete?: never;
173
+ options?: never;
174
+ head?: never;
175
+ patch?: never;
176
+ trace?: never;
177
+ };
178
+ "/health": {
179
+ parameters: {
180
+ query?: never;
181
+ header?: never;
182
+ path?: never;
183
+ cookie?: never;
184
+ };
185
+ get: {
186
+ parameters: {
187
+ query?: never;
188
+ header?: never;
189
+ path?: never;
190
+ cookie?: never;
191
+ };
192
+ requestBody?: never;
193
+ responses: {
194
+ /** @description Health check endpoint */
195
+ 200: {
196
+ headers: {
197
+ [name: string]: unknown;
198
+ };
199
+ content: {
200
+ "application/json": components["schemas"]["HealthResponse"];
201
+ };
202
+ };
203
+ };
204
+ };
205
+ put?: never;
206
+ post?: never;
207
+ delete?: never;
208
+ options?: never;
209
+ head?: never;
210
+ patch?: never;
211
+ trace?: never;
212
+ };
213
+ }
214
+ export type webhooks = Record<string, never>;
215
+ export interface components {
216
+ schemas: {
217
+ /** @description Successful tracking response */
218
+ SuccessResponse: {
219
+ /**
220
+ * @description Indicates if the operation was successful
221
+ * @example true
222
+ */
223
+ success: boolean;
224
+ /**
225
+ * @description Unique session identifier
226
+ * @example session_1703123456789_abc123def
227
+ */
228
+ sessionId: string;
229
+ /**
230
+ * @description Unique pageview identifier (for pageview tracking)
231
+ * @example pageview_1703123456789_xyz789
232
+ */
233
+ pageviewId?: string;
234
+ /**
235
+ * @description Unique event identifier (for event tracking)
236
+ * @example event_1703123456789_def456
237
+ */
238
+ eventId?: string;
239
+ };
240
+ /** @description Validation error response */
241
+ ValidationErrorResponse: {
242
+ /**
243
+ * @description Error message
244
+ * @example Invalid request body
245
+ */
246
+ error: string;
247
+ /**
248
+ * @description Validation error details
249
+ * @example Required field "pathname" is missing
250
+ */
251
+ details: string;
252
+ };
253
+ /** @description Server error response */
254
+ ServerErrorResponse: {
255
+ /**
256
+ * @description Error message
257
+ * @example Internal server error
258
+ */
259
+ error: string;
260
+ /**
261
+ * @description Server error details
262
+ * @example Database connection failed
263
+ */
264
+ details: string;
265
+ };
266
+ /** @description Pageview tracking data */
267
+ PageviewInput: {
268
+ /**
269
+ * @description The pathname of the page being viewed
270
+ * @example /dashboard
271
+ */
272
+ pathname: string;
273
+ /**
274
+ * @description The referrer URL
275
+ * @example https://google.com
276
+ */
277
+ referrer?: string;
278
+ /**
279
+ * @description The user agent string
280
+ * @example Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36
281
+ */
282
+ userAgent?: string;
283
+ /**
284
+ * @description The user language preference
285
+ * @example en-US
286
+ */
287
+ language?: string;
288
+ /**
289
+ * @description The user country code
290
+ * @example US
291
+ */
292
+ country?: string;
293
+ };
294
+ /** @description Event tracking data */
295
+ EventInput: {
296
+ /**
297
+ * @description The event name
298
+ * @example button_click
299
+ */
300
+ name: string;
301
+ /**
302
+ * @description The event type/category (optional)
303
+ * @example interaction
304
+ */
305
+ type?: string;
306
+ /**
307
+ * @description The pathname where the event occurred
308
+ * @example /dashboard
309
+ */
310
+ pathname: string;
311
+ /**
312
+ * @description Event payload data
313
+ * @example {
314
+ * "button_id": "cta-button",
315
+ * "section": "hero"
316
+ * }
317
+ */
318
+ payload?: {
319
+ [key: string]: string | number | boolean;
320
+ };
321
+ /**
322
+ * @deprecated
323
+ * @description DEPRECATED — legacy alias for `payload`. Use `payload`.
324
+ * @example {
325
+ * "button_id": "cta-button"
326
+ * }
327
+ */
328
+ props?: {
329
+ [key: string]: string | number | boolean;
330
+ };
331
+ /**
332
+ * @description The user agent string
333
+ * @example Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36
334
+ */
335
+ userAgent?: string;
336
+ /**
337
+ * @description The user language preference
338
+ * @example en-US
339
+ */
340
+ language?: string;
341
+ /**
342
+ * @description The user country code
343
+ * @example US
344
+ */
345
+ country?: string;
346
+ };
347
+ /**
348
+ * Analytics Query Request
349
+ * @description Query parameters for analytics data
350
+ */
351
+ QueryRequest: {
352
+ /** @description Time range for the query */
353
+ date_range: string | {
354
+ /**
355
+ * @description Start date (ISO 8601)
356
+ * @example 2025-01-01
357
+ */
358
+ from: string;
359
+ /**
360
+ * @description End date (ISO 8601)
361
+ * @example 2025-01-31
362
+ */
363
+ to: string;
364
+ };
365
+ /** @description Timezone (e.g., America/Santo_Domingo) */
366
+ tz?: string;
367
+ /**
368
+ * @description Metrics to calculate
369
+ * @example [
370
+ * "pageviews",
371
+ * "visitors"
372
+ * ]
373
+ */
374
+ metrics: ("pageviews" | "visitors" | "sessions" | "visit:bounce_rate" | "visit:avg_duration" | "events")[];
375
+ /**
376
+ * @description Dimensions to group by
377
+ * @example [
378
+ * "event:page"
379
+ * ]
380
+ */
381
+ dimensions?: ("event:page" | "visit:country_name" | "visit:source" | "visit:referrer" | "visit:device" | "visit:browser" | "event:name")[];
382
+ /**
383
+ * @description Filters to apply
384
+ * @example []
385
+ */
386
+ filters?: (("equals" | "not_equals" | "contains" | "starts_with" | "in" | "not_in" | "between" | "is_not") | string | (string | number | string[] | number[] | string[]))[][] | (("equals" | "not_equals" | "contains" | "starts_with" | "in" | "not_in" | "between" | "is_not") | string | (string | number | string[] | number[] | string[]))[][];
387
+ /**
388
+ * @description Ordering criteria
389
+ * @example []
390
+ */
391
+ order_by?: (string | ("asc" | "desc"))[][] | (string | ("asc" | "desc"))[][];
392
+ /** @description Pagination options */
393
+ pagination?: {
394
+ /**
395
+ * @default 100
396
+ * @example 50
397
+ */
398
+ limit: number;
399
+ /**
400
+ * @default 0
401
+ * @example 0
402
+ */
403
+ offset: number;
404
+ };
405
+ /** @description Additional data to include in response */
406
+ include?: {
407
+ /** @default false */
408
+ time_labels: boolean;
409
+ /** @default false */
410
+ total_rows: boolean;
411
+ /**
412
+ * @default daily
413
+ * @enum {string}
414
+ */
415
+ granularity: "hourly" | "daily" | "weekly" | "monthly" | "yearly";
416
+ };
417
+ };
418
+ /**
419
+ * Analytics Query Response
420
+ * @description Analytics query results
421
+ */
422
+ QueryResponse: {
423
+ /** @description Query results */
424
+ results: {
425
+ dimensions: string[];
426
+ metrics: number[];
427
+ time_series?: number[];
428
+ }[];
429
+ /** @description Metadata about the query */
430
+ meta: {
431
+ time_labels?: string[];
432
+ total_rows?: number;
433
+ query: components["schemas"]["QueryRequest"];
434
+ };
435
+ };
436
+ /** @description Health check response */
437
+ HealthResponse: {
438
+ /**
439
+ * @description Health status
440
+ * @example ok
441
+ */
442
+ status: string;
443
+ /**
444
+ * @description Current timestamp in ISO format
445
+ * @example 2023-12-21T10:30:00.000Z
446
+ */
447
+ timestamp: string;
448
+ };
449
+ };
450
+ responses: never;
451
+ parameters: never;
452
+ requestBodies: never;
453
+ headers: never;
454
+ pathItems: never;
455
+ }
456
+ export type $defs = Record<string, never>;
457
+ export type operations = Record<string, never>;
@@ -0,0 +1,23 @@
1
+ export type SendEventOptions = {
2
+ endpoint: string;
3
+ apiKey: string;
4
+ data: unknown;
5
+ /**
6
+ * Notified when the send fails. The failure is still swallowed — analytics
7
+ * must never break the page or the request it is describing — but a
8
+ * server-side caller usually wants it in its logs.
9
+ */
10
+ onError?: (error: unknown) => void;
11
+ };
12
+ /**
13
+ * Sends tracking data to the Luchy API
14
+ */
15
+ export declare function sendEvent(options: SendEventOptions): Promise<void>;
16
+ /**
17
+ * Collects browser data automatically
18
+ */
19
+ export declare function collectBrowserData(): {
20
+ userAgent: string;
21
+ language: string;
22
+ };
23
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;IACd;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC,CAAC;AAEF;;GAEG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAqBxE;AAED;;GAEG;AACH,wBAAgB,kBAAkB;;;EAKjC"}
@@ -0,0 +1,26 @@
1
+ export type LuchyInitOptions = {
2
+ endpoint?: string;
3
+ apiKey: string;
4
+ trackLocalhost?: boolean;
5
+ };
6
+ export type LuchyTrackerOptions = {
7
+ autoPageviews?: boolean;
8
+ autoOutbound?: boolean;
9
+ autoEvents?: boolean;
10
+ hashRouting?: boolean;
11
+ };
12
+ export type LuchyTracker = {
13
+ trackPageview(data?: {
14
+ pathname?: string;
15
+ referrer?: string;
16
+ }): Promise<void>;
17
+ trackEvent(name: string, payload?: Record<string, string | number>, options?: {
18
+ type?: string;
19
+ }): Promise<void>;
20
+ setOptions(options: LuchyTrackerOptions): void;
21
+ };
22
+ /**
23
+ * Creates a Luchy tracker instance
24
+ */
25
+ export declare function luchy(options: LuchyInitOptions): LuchyTracker;
26
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,aAAa,CAAC,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9E,UAAU,CACR,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EACzC,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAC1B,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,UAAU,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAAC;CAChD,CAAC;AAEF;;GAEG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,gBAAgB,GAAG,YAAY,CAyW7D"}