@lessonkit/xapi 0.5.0 → 0.6.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 +2 -2
- package/dist/index.cjs +18 -0
- package/dist/index.js +18 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# `@lessonkit/xapi`
|
|
2
2
|
|
|
3
|
-
[](https://github.com/eddiethedean/lessonkit/actions/workflows/ci.yml)
|
|
4
4
|
[](https://www.npmjs.com/package/@lessonkit/xapi)
|
|
5
5
|
[](../../LICENSE)
|
|
6
6
|
|
|
@@ -29,7 +29,7 @@ xapi.completeLesson({ lessonId: "phishing-101", durationMs: 1500, success: true,
|
|
|
29
29
|
|
|
30
30
|
Prefer mapping from telemetry: `telemetryEventToXAPIStatement(event)` (canonical object URNs).
|
|
31
31
|
|
|
32
|
-
## Notes (0.
|
|
32
|
+
## Notes (0.6.0)
|
|
33
33
|
|
|
34
34
|
- `createXAPIClient` requires `courseId` for lifecycle helpers; React uses the mapper after each `track()`.
|
|
35
35
|
- If the transport throws/rejects, statements are queued in-memory.
|
package/dist/index.cjs
CHANGED
|
@@ -172,17 +172,35 @@ function statementFor(objectId, verb, timestamp, extra) {
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
// src/client.ts
|
|
175
|
+
function isDevEnvironment() {
|
|
176
|
+
const g = globalThis;
|
|
177
|
+
return typeof g.process !== "undefined" && g.process.env?.NODE_ENV !== "production";
|
|
178
|
+
}
|
|
175
179
|
function createXAPIClient(opts) {
|
|
176
180
|
const transport = opts?.transport;
|
|
177
181
|
const courseId = opts?.courseId;
|
|
178
182
|
const queue = opts?.queue ?? createInMemoryXAPIQueue();
|
|
183
|
+
let warnedNoTransport = false;
|
|
184
|
+
let warnedTransportFailure = false;
|
|
179
185
|
const sendOrQueue = (statement) => {
|
|
180
186
|
if (!transport) {
|
|
181
187
|
queue.enqueue(statement);
|
|
188
|
+
if (isDevEnvironment() && !warnedNoTransport) {
|
|
189
|
+
warnedNoTransport = true;
|
|
190
|
+
console.warn(
|
|
191
|
+
"[lessonkit] xAPI statements are queued but no transport is configured; pass config.xapi.transport or config.xapi.client"
|
|
192
|
+
);
|
|
193
|
+
}
|
|
182
194
|
return;
|
|
183
195
|
}
|
|
184
196
|
void Promise.resolve().then(() => transport(statement)).catch(() => {
|
|
185
197
|
queue.enqueue(statement);
|
|
198
|
+
if (isDevEnvironment() && !warnedTransportFailure) {
|
|
199
|
+
warnedTransportFailure = true;
|
|
200
|
+
console.warn(
|
|
201
|
+
"[lessonkit] xAPI transport failed; statement re-queued. Check your LRS endpoint or transport implementation."
|
|
202
|
+
);
|
|
203
|
+
}
|
|
186
204
|
});
|
|
187
205
|
};
|
|
188
206
|
const emit = (event) => {
|
package/dist/index.js
CHANGED
|
@@ -144,17 +144,35 @@ function statementFor(objectId, verb, timestamp, extra) {
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
// src/client.ts
|
|
147
|
+
function isDevEnvironment() {
|
|
148
|
+
const g = globalThis;
|
|
149
|
+
return typeof g.process !== "undefined" && g.process.env?.NODE_ENV !== "production";
|
|
150
|
+
}
|
|
147
151
|
function createXAPIClient(opts) {
|
|
148
152
|
const transport = opts?.transport;
|
|
149
153
|
const courseId = opts?.courseId;
|
|
150
154
|
const queue = opts?.queue ?? createInMemoryXAPIQueue();
|
|
155
|
+
let warnedNoTransport = false;
|
|
156
|
+
let warnedTransportFailure = false;
|
|
151
157
|
const sendOrQueue = (statement) => {
|
|
152
158
|
if (!transport) {
|
|
153
159
|
queue.enqueue(statement);
|
|
160
|
+
if (isDevEnvironment() && !warnedNoTransport) {
|
|
161
|
+
warnedNoTransport = true;
|
|
162
|
+
console.warn(
|
|
163
|
+
"[lessonkit] xAPI statements are queued but no transport is configured; pass config.xapi.transport or config.xapi.client"
|
|
164
|
+
);
|
|
165
|
+
}
|
|
154
166
|
return;
|
|
155
167
|
}
|
|
156
168
|
void Promise.resolve().then(() => transport(statement)).catch(() => {
|
|
157
169
|
queue.enqueue(statement);
|
|
170
|
+
if (isDevEnvironment() && !warnedTransportFailure) {
|
|
171
|
+
warnedTransportFailure = true;
|
|
172
|
+
console.warn(
|
|
173
|
+
"[lessonkit] xAPI transport failed; statement re-queued. Check your LRS endpoint or transport implementation."
|
|
174
|
+
);
|
|
175
|
+
}
|
|
158
176
|
});
|
|
159
177
|
};
|
|
160
178
|
const emit = (event) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lessonkit/xapi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "xAPI statement generation primitives for LessonKit.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"lint": "echo \"(no lint configured yet)\""
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@lessonkit/core": "0.
|
|
48
|
+
"@lessonkit/core": "0.6.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"tsup": "^8.5.0",
|