h1v3 0.17.0 → 0.18.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/dist/browser/client/event-store.js +23 -9
- package/package.json +1 -1
- package/src/index.js +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { timeId } from "./id.js";
|
|
2
2
|
|
|
3
|
-
const newEventId = eventType => `${timeId()}-${eventType}`;
|
|
3
|
+
export const newEventId = eventType => `${timeId()}-${eventType}`;
|
|
4
4
|
|
|
5
5
|
export const PROJECTIONS = "_p";
|
|
6
6
|
export const EVENTS = "_e";
|
|
@@ -43,18 +43,32 @@ export function eventStore(database, authentication, path) {
|
|
|
43
43
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
|
|
47
|
+
async function recordForId({ type, payload, id }) {
|
|
48
|
+
|
|
49
|
+
const meta = {
|
|
50
|
+
when: new Date().toISOString(),
|
|
51
|
+
uid: authentication.auth?.currentUser?.uid
|
|
52
|
+
};
|
|
53
|
+
const data = { type, payload, meta };
|
|
54
|
+
const path = `${eventsPath}/${id}`;
|
|
55
|
+
await set(ref(db, path), data);
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
46
59
|
return {
|
|
47
60
|
|
|
48
61
|
async record(eventType, payload) {
|
|
49
62
|
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
const id = newEventId(eventType);
|
|
64
|
+
await recordForId({ type: eventType, payload, id });
|
|
65
|
+
return id;
|
|
66
|
+
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
async recordWithId({ type, payload, id }) {
|
|
70
|
+
|
|
71
|
+
await recordForId({ type, payload, id });
|
|
58
72
|
|
|
59
73
|
},
|
|
60
74
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -5,10 +5,10 @@ export * from "./configuration/configure-metadata-endpoint.js";
|
|
|
5
5
|
export * from "./configuration/configure-o11y-store.js";
|
|
6
6
|
|
|
7
7
|
export const passThroughView = {
|
|
8
|
-
"?": (view,
|
|
8
|
+
"?": (view, payload, { eventId }) => {
|
|
9
9
|
|
|
10
10
|
view.events = view.events || {};
|
|
11
|
-
view.events[
|
|
11
|
+
view.events[eventId] = payload;
|
|
12
12
|
return view;
|
|
13
13
|
|
|
14
14
|
}
|