@lessonkit/core 0.3.0 → 0.4.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/README.md +1 -1
- package/dist/index.cjs +10 -3
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +9 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ Core types and runtime primitives shared across LessonKit packages.
|
|
|
12
12
|
npm install @lessonkit/core
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
## What’s inside (0.
|
|
15
|
+
## What’s inside (0.4.0)
|
|
16
16
|
|
|
17
17
|
- Telemetry event types (`TelemetryEvent`)
|
|
18
18
|
- A minimal tracking client (`createTrackingClient`) with optional batching
|
package/dist/index.cjs
CHANGED
|
@@ -25,6 +25,8 @@ __export(index_exports, {
|
|
|
25
25
|
nowIso: () => nowIso
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(index_exports);
|
|
28
|
+
|
|
29
|
+
// src/trackingClient.ts
|
|
28
30
|
function createTrackingClient(opts) {
|
|
29
31
|
const sink = opts?.sink;
|
|
30
32
|
const batchSink = opts?.batchSink;
|
|
@@ -75,6 +77,7 @@ function createTrackingClient(opts) {
|
|
|
75
77
|
});
|
|
76
78
|
};
|
|
77
79
|
intervalId = flushIntervalMs > 0 ? globalThis.setInterval(flush, flushIntervalMs) : void 0;
|
|
80
|
+
intervalId?.unref?.();
|
|
78
81
|
return {
|
|
79
82
|
track: (event) => {
|
|
80
83
|
if (disposed) return;
|
|
@@ -93,14 +96,18 @@ function createTrackingClient(opts) {
|
|
|
93
96
|
}
|
|
94
97
|
};
|
|
95
98
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
+
|
|
100
|
+
// src/ids.ts
|
|
99
101
|
function createSessionId() {
|
|
100
102
|
const g = globalThis;
|
|
101
103
|
if (g.crypto?.randomUUID) return g.crypto.randomUUID();
|
|
102
104
|
return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 11)}`;
|
|
103
105
|
}
|
|
106
|
+
|
|
107
|
+
// src/time.ts
|
|
108
|
+
function nowIso() {
|
|
109
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
110
|
+
}
|
|
104
111
|
// Annotate the CommonJS export names for ESM import in node:
|
|
105
112
|
0 && (module.exports = {
|
|
106
113
|
createSessionId,
|
package/dist/index.d.cts
CHANGED
|
@@ -24,6 +24,7 @@ type TrackingClient = {
|
|
|
24
24
|
flush?: () => void;
|
|
25
25
|
dispose?: () => void;
|
|
26
26
|
};
|
|
27
|
+
|
|
27
28
|
declare function createTrackingClient(opts?: {
|
|
28
29
|
sink?: TelemetrySink;
|
|
29
30
|
batch?: {
|
|
@@ -33,7 +34,9 @@ declare function createTrackingClient(opts?: {
|
|
|
33
34
|
};
|
|
34
35
|
batchSink?: TelemetryBatchSink;
|
|
35
36
|
}): TrackingClient;
|
|
36
|
-
|
|
37
|
+
|
|
37
38
|
declare function createSessionId(): string;
|
|
38
39
|
|
|
40
|
+
declare function nowIso(): string;
|
|
41
|
+
|
|
39
42
|
export { type CourseId, type LessonId, type TelemetryBatchSink, type TelemetryEvent, type TelemetryEventName, type TelemetrySink, type TelemetryUser, type TrackingClient, createSessionId, createTrackingClient, nowIso };
|
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ type TrackingClient = {
|
|
|
24
24
|
flush?: () => void;
|
|
25
25
|
dispose?: () => void;
|
|
26
26
|
};
|
|
27
|
+
|
|
27
28
|
declare function createTrackingClient(opts?: {
|
|
28
29
|
sink?: TelemetrySink;
|
|
29
30
|
batch?: {
|
|
@@ -33,7 +34,9 @@ declare function createTrackingClient(opts?: {
|
|
|
33
34
|
};
|
|
34
35
|
batchSink?: TelemetryBatchSink;
|
|
35
36
|
}): TrackingClient;
|
|
36
|
-
|
|
37
|
+
|
|
37
38
|
declare function createSessionId(): string;
|
|
38
39
|
|
|
40
|
+
declare function nowIso(): string;
|
|
41
|
+
|
|
39
42
|
export { type CourseId, type LessonId, type TelemetryBatchSink, type TelemetryEvent, type TelemetryEventName, type TelemetrySink, type TelemetryUser, type TrackingClient, createSessionId, createTrackingClient, nowIso };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/trackingClient.ts
|
|
2
2
|
function createTrackingClient(opts) {
|
|
3
3
|
const sink = opts?.sink;
|
|
4
4
|
const batchSink = opts?.batchSink;
|
|
@@ -49,6 +49,7 @@ function createTrackingClient(opts) {
|
|
|
49
49
|
});
|
|
50
50
|
};
|
|
51
51
|
intervalId = flushIntervalMs > 0 ? globalThis.setInterval(flush, flushIntervalMs) : void 0;
|
|
52
|
+
intervalId?.unref?.();
|
|
52
53
|
return {
|
|
53
54
|
track: (event) => {
|
|
54
55
|
if (disposed) return;
|
|
@@ -67,14 +68,18 @@ function createTrackingClient(opts) {
|
|
|
67
68
|
}
|
|
68
69
|
};
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
71
|
+
|
|
72
|
+
// src/ids.ts
|
|
73
73
|
function createSessionId() {
|
|
74
74
|
const g = globalThis;
|
|
75
75
|
if (g.crypto?.randomUUID) return g.crypto.randomUUID();
|
|
76
76
|
return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 11)}`;
|
|
77
77
|
}
|
|
78
|
+
|
|
79
|
+
// src/time.ts
|
|
80
|
+
function nowIso() {
|
|
81
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
82
|
+
}
|
|
78
83
|
export {
|
|
79
84
|
createSessionId,
|
|
80
85
|
createTrackingClient,
|