@debugkit/dashboard 0.0.0-stage → 0.3.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/.env.example +30 -0
- package/dist/client/assets/_authed-BDx4Txp7.js +7 -0
- package/dist/client/assets/_authed-D6P9RBN1.js +1 -0
- package/dist/client/assets/charts-Covhtva2.js +55 -0
- package/dist/client/assets/index-BKQXehfa.js +12 -0
- package/dist/client/assets/issues._fingerprint-DtAqk0rC.js +1 -0
- package/dist/client/assets/login-Da8b3hjR.js +1 -0
- package/dist/client/assets/styles-CZZRuG1z.css +2 -0
- package/dist/client/assets/ui-DnKidKVi.js +1 -0
- package/dist/server/assets/_authed-BjmBAX3l.js +482 -0
- package/dist/server/assets/_authed-x9Ku8dyL.js +40 -0
- package/dist/server/assets/_tanstack-start-manifest_v-CY7PP5UB.js +40 -0
- package/dist/server/assets/charts-CNlV7Pga.js +221 -0
- package/dist/server/assets/demo-DTdlXNgj.js +333 -0
- package/dist/server/assets/dynamodb-DejcakaF.js +187 -0
- package/dist/server/assets/empty-plugin-adapters-BsRz-CQL.js +4 -0
- package/dist/server/assets/firestore-BH-gx9no.js +112 -0
- package/dist/server/assets/fns-CgB12FUN.js +31 -0
- package/dist/server/assets/fns-Yg8sT1Cb.js +87 -0
- package/dist/server/assets/issues._fingerprint-C2EdByPH.js +255 -0
- package/dist/server/assets/login-BMGNYcxB.js +107 -0
- package/dist/server/assets/memory-4DwW5cTO.js +59 -0
- package/dist/server/assets/queries-DIVV-5j6.js +4274 -0
- package/dist/server/assets/rollups-JXbazRNh.js +22 -0
- package/dist/server/assets/router-D2L7-BwF.js +222 -0
- package/dist/server/assets/src-D5jyi_C4.js +235 -0
- package/dist/server/assets/start-t09PGpZL.js +3 -0
- package/dist/server/assets/ui-Lv-KcOoP.js +131 -0
- package/dist/server/server.js +7825 -0
- package/package.json +52 -3
- package/scripts/hash-password.mjs +17 -0
- package/server.mjs +50 -0
- package/README.md +0 -3
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Area, AreaChart, Bar, BarChart, CartesianGrid, Cell, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
|
|
4
|
+
// src/components/charts.tsx
|
|
5
|
+
var SEV_COLOR = {
|
|
6
|
+
critical: "var(--sev-critical)",
|
|
7
|
+
high: "var(--sev-high)",
|
|
8
|
+
medium: "var(--sev-medium)",
|
|
9
|
+
low: "var(--sev-low)"
|
|
10
|
+
};
|
|
11
|
+
var axis = {
|
|
12
|
+
stroke: "var(--muted)",
|
|
13
|
+
fontSize: 11,
|
|
14
|
+
tickLine: false,
|
|
15
|
+
axisLine: false
|
|
16
|
+
};
|
|
17
|
+
var tooltipStyle = {
|
|
18
|
+
contentStyle: {
|
|
19
|
+
background: "var(--panel)",
|
|
20
|
+
border: "1px solid var(--border)",
|
|
21
|
+
borderRadius: 8,
|
|
22
|
+
fontSize: 12,
|
|
23
|
+
color: "var(--text)"
|
|
24
|
+
},
|
|
25
|
+
labelStyle: { color: "var(--muted)" },
|
|
26
|
+
cursor: { fill: "var(--panel-2)" }
|
|
27
|
+
};
|
|
28
|
+
/** Recharts measures the DOM, so render a same-size placeholder during SSR. */
|
|
29
|
+
function ClientOnly({ height, children }) {
|
|
30
|
+
const [ready, setReady] = useState(false);
|
|
31
|
+
useEffect(() => setReady(true), []);
|
|
32
|
+
return /* @__PURE__ */ jsx("div", {
|
|
33
|
+
style: { height },
|
|
34
|
+
children: ready ? children : null
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
var shortDay = (d) => (/* @__PURE__ */ new Date(`${d}T00:00:00Z`)).toLocaleDateString(void 0, {
|
|
38
|
+
month: "short",
|
|
39
|
+
day: "numeric",
|
|
40
|
+
timeZone: "UTC"
|
|
41
|
+
});
|
|
42
|
+
function TrendChart({ data }) {
|
|
43
|
+
return /* @__PURE__ */ jsx(ClientOnly, {
|
|
44
|
+
height: 220,
|
|
45
|
+
children: /* @__PURE__ */ jsx(ResponsiveContainer, {
|
|
46
|
+
width: "100%",
|
|
47
|
+
height: "100%",
|
|
48
|
+
children: /* @__PURE__ */ jsxs(AreaChart, {
|
|
49
|
+
data,
|
|
50
|
+
margin: {
|
|
51
|
+
top: 8,
|
|
52
|
+
right: 8,
|
|
53
|
+
bottom: 0,
|
|
54
|
+
left: -16
|
|
55
|
+
},
|
|
56
|
+
accessibilityLayer: true,
|
|
57
|
+
children: [
|
|
58
|
+
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", {
|
|
59
|
+
id: "errFill",
|
|
60
|
+
x1: "0",
|
|
61
|
+
y1: "0",
|
|
62
|
+
x2: "0",
|
|
63
|
+
y2: "1",
|
|
64
|
+
children: [/* @__PURE__ */ jsx("stop", {
|
|
65
|
+
offset: "0%",
|
|
66
|
+
stopColor: "var(--chart-errors)",
|
|
67
|
+
stopOpacity: .35
|
|
68
|
+
}), /* @__PURE__ */ jsx("stop", {
|
|
69
|
+
offset: "100%",
|
|
70
|
+
stopColor: "var(--chart-errors)",
|
|
71
|
+
stopOpacity: 0
|
|
72
|
+
})]
|
|
73
|
+
}) }),
|
|
74
|
+
/* @__PURE__ */ jsx(CartesianGrid, {
|
|
75
|
+
vertical: false,
|
|
76
|
+
stroke: "var(--chart-grid)"
|
|
77
|
+
}),
|
|
78
|
+
/* @__PURE__ */ jsx(XAxis, {
|
|
79
|
+
dataKey: "day",
|
|
80
|
+
tickFormatter: shortDay,
|
|
81
|
+
...axis,
|
|
82
|
+
minTickGap: 16
|
|
83
|
+
}),
|
|
84
|
+
/* @__PURE__ */ jsx(YAxis, {
|
|
85
|
+
allowDecimals: false,
|
|
86
|
+
...axis
|
|
87
|
+
}),
|
|
88
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
89
|
+
...tooltipStyle,
|
|
90
|
+
labelFormatter: (d) => shortDay(String(d))
|
|
91
|
+
}),
|
|
92
|
+
/* @__PURE__ */ jsx(Area, {
|
|
93
|
+
type: "monotone",
|
|
94
|
+
dataKey: "errors",
|
|
95
|
+
name: "Errors",
|
|
96
|
+
stroke: "var(--chart-errors)",
|
|
97
|
+
strokeWidth: 2,
|
|
98
|
+
fill: "url(#errFill)"
|
|
99
|
+
})
|
|
100
|
+
]
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function FlowChart({ data, onSelect }) {
|
|
106
|
+
const rows = data.slice(0, 8);
|
|
107
|
+
const height = Math.max(120, rows.length * 34 + 24);
|
|
108
|
+
return /* @__PURE__ */ jsx(ClientOnly, {
|
|
109
|
+
height,
|
|
110
|
+
children: /* @__PURE__ */ jsx(ResponsiveContainer, {
|
|
111
|
+
width: "100%",
|
|
112
|
+
height: "100%",
|
|
113
|
+
children: /* @__PURE__ */ jsxs(BarChart, {
|
|
114
|
+
data: rows,
|
|
115
|
+
layout: "vertical",
|
|
116
|
+
margin: {
|
|
117
|
+
top: 0,
|
|
118
|
+
right: 16,
|
|
119
|
+
bottom: 0,
|
|
120
|
+
left: 0
|
|
121
|
+
},
|
|
122
|
+
accessibilityLayer: true,
|
|
123
|
+
children: [
|
|
124
|
+
/* @__PURE__ */ jsx(CartesianGrid, {
|
|
125
|
+
horizontal: false,
|
|
126
|
+
stroke: "var(--chart-grid)"
|
|
127
|
+
}),
|
|
128
|
+
/* @__PURE__ */ jsx(XAxis, {
|
|
129
|
+
type: "number",
|
|
130
|
+
allowDecimals: false,
|
|
131
|
+
...axis
|
|
132
|
+
}),
|
|
133
|
+
/* @__PURE__ */ jsx(YAxis, {
|
|
134
|
+
type: "category",
|
|
135
|
+
dataKey: "flow",
|
|
136
|
+
width: 130,
|
|
137
|
+
...axis,
|
|
138
|
+
tick: {
|
|
139
|
+
fill: "var(--text)",
|
|
140
|
+
fontSize: 12
|
|
141
|
+
}
|
|
142
|
+
}),
|
|
143
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
144
|
+
...tooltipStyle,
|
|
145
|
+
formatter: (v) => [v, "Errors (24h)"]
|
|
146
|
+
}),
|
|
147
|
+
/* @__PURE__ */ jsx(Bar, {
|
|
148
|
+
dataKey: "errors24h",
|
|
149
|
+
name: "Errors (24h)",
|
|
150
|
+
radius: [
|
|
151
|
+
0,
|
|
152
|
+
4,
|
|
153
|
+
4,
|
|
154
|
+
0
|
|
155
|
+
],
|
|
156
|
+
barSize: 18,
|
|
157
|
+
cursor: onSelect ? "pointer" : void 0,
|
|
158
|
+
onClick: (d) => d.payload?.flow && onSelect?.(d.payload.flow),
|
|
159
|
+
children: rows.map((r) => /* @__PURE__ */ jsx(Cell, { fill: SEV_COLOR[r.severity] }, r.flow))
|
|
160
|
+
})
|
|
161
|
+
]
|
|
162
|
+
})
|
|
163
|
+
})
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function HourlyChart({ data }) {
|
|
167
|
+
const label = (h) => (/* @__PURE__ */ new Date(`${h}:00:00Z`)).toLocaleString(void 0, {
|
|
168
|
+
hour: "2-digit",
|
|
169
|
+
day: "numeric",
|
|
170
|
+
month: "short"
|
|
171
|
+
});
|
|
172
|
+
return /* @__PURE__ */ jsx(ClientOnly, {
|
|
173
|
+
height: 180,
|
|
174
|
+
children: /* @__PURE__ */ jsx(ResponsiveContainer, {
|
|
175
|
+
width: "100%",
|
|
176
|
+
height: "100%",
|
|
177
|
+
children: /* @__PURE__ */ jsxs(BarChart, {
|
|
178
|
+
data,
|
|
179
|
+
margin: {
|
|
180
|
+
top: 8,
|
|
181
|
+
right: 8,
|
|
182
|
+
bottom: 0,
|
|
183
|
+
left: -16
|
|
184
|
+
},
|
|
185
|
+
accessibilityLayer: true,
|
|
186
|
+
children: [
|
|
187
|
+
/* @__PURE__ */ jsx(CartesianGrid, {
|
|
188
|
+
vertical: false,
|
|
189
|
+
stroke: "var(--chart-grid)"
|
|
190
|
+
}),
|
|
191
|
+
/* @__PURE__ */ jsx(XAxis, {
|
|
192
|
+
dataKey: "hour",
|
|
193
|
+
tickFormatter: (h) => (/* @__PURE__ */ new Date(`${h}:00:00Z`)).toLocaleTimeString(void 0, { hour: "2-digit" }),
|
|
194
|
+
...axis,
|
|
195
|
+
minTickGap: 24
|
|
196
|
+
}),
|
|
197
|
+
/* @__PURE__ */ jsx(YAxis, {
|
|
198
|
+
allowDecimals: false,
|
|
199
|
+
...axis
|
|
200
|
+
}),
|
|
201
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
202
|
+
...tooltipStyle,
|
|
203
|
+
labelFormatter: (h) => label(String(h)),
|
|
204
|
+
formatter: (v) => [v, "Occurrences"]
|
|
205
|
+
}),
|
|
206
|
+
/* @__PURE__ */ jsx(Bar, {
|
|
207
|
+
dataKey: "count",
|
|
208
|
+
fill: "var(--chart-errors)",
|
|
209
|
+
radius: [
|
|
210
|
+
3,
|
|
211
|
+
3,
|
|
212
|
+
0,
|
|
213
|
+
0
|
|
214
|
+
]
|
|
215
|
+
})
|
|
216
|
+
]
|
|
217
|
+
})
|
|
218
|
+
})
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
export { HourlyChart as n, TrendChart as r, FlowChart as t };
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { MemoryStore } from "./memory-4DwW5cTO.js";
|
|
2
|
+
import { n as ingest } from "./src-D5jyi_C4.js";
|
|
3
|
+
// src/server/demo.ts
|
|
4
|
+
/**
|
|
5
|
+
* Builds a realistic 14-day dataset for a fictional app by pushing synthetic SDK
|
|
6
|
+
* envelopes through the real ingest pipeline (so fingerprints/rollups are genuine).
|
|
7
|
+
*/
|
|
8
|
+
async function seedDemo() {
|
|
9
|
+
const store = new MemoryStore();
|
|
10
|
+
const rand = mulberry32(42);
|
|
11
|
+
const pick = (xs) => xs[Math.floor(rand() * xs.length)];
|
|
12
|
+
const keys = { pk_demo: "megaton-native" };
|
|
13
|
+
const now = Date.now();
|
|
14
|
+
let seq = 0;
|
|
15
|
+
const devices = [
|
|
16
|
+
{
|
|
17
|
+
os: {
|
|
18
|
+
name: "android",
|
|
19
|
+
version: "14"
|
|
20
|
+
},
|
|
21
|
+
device: {
|
|
22
|
+
model: "SM-S918B",
|
|
23
|
+
manufacturer: "samsung",
|
|
24
|
+
type: "phone"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
os: {
|
|
29
|
+
name: "android",
|
|
30
|
+
version: "14"
|
|
31
|
+
},
|
|
32
|
+
device: {
|
|
33
|
+
model: "Pixel 8",
|
|
34
|
+
manufacturer: "Google",
|
|
35
|
+
type: "phone"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
os: {
|
|
40
|
+
name: "android",
|
|
41
|
+
version: "13"
|
|
42
|
+
},
|
|
43
|
+
device: {
|
|
44
|
+
model: "SM-A546E",
|
|
45
|
+
manufacturer: "samsung",
|
|
46
|
+
type: "phone"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
os: {
|
|
51
|
+
name: "ios",
|
|
52
|
+
version: "18.1"
|
|
53
|
+
},
|
|
54
|
+
device: {
|
|
55
|
+
model: "iPhone 15",
|
|
56
|
+
manufacturer: "Apple",
|
|
57
|
+
type: "phone"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
os: {
|
|
62
|
+
name: "ios",
|
|
63
|
+
version: "17.6"
|
|
64
|
+
},
|
|
65
|
+
device: {
|
|
66
|
+
model: "iPhone 13",
|
|
67
|
+
manufacturer: "Apple",
|
|
68
|
+
type: "phone"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
];
|
|
72
|
+
const networks = [
|
|
73
|
+
"wifi",
|
|
74
|
+
"cellular",
|
|
75
|
+
"cellular"
|
|
76
|
+
];
|
|
77
|
+
const stack = (fn, file, line) => `Error\n at ${fn} (/app/src/${file}:${line}:17)\n at onPress (/app/src/components/Button.tsx:31:9)\n at /app/node_modules/react-native/Libraries/Pressability/Pressability.js:704:17`;
|
|
78
|
+
const scenarios = [
|
|
79
|
+
{
|
|
80
|
+
flow: "auth.login",
|
|
81
|
+
step: "submit_otp",
|
|
82
|
+
weight: (dayAgo, d, v) => v === "2.4.0" && d.os.name === "android" && d.os.version === "14" ? dayAgo <= 3 ? 9 : 0 : .05,
|
|
83
|
+
error: () => ({
|
|
84
|
+
name: "TypeError",
|
|
85
|
+
message: "Cannot read property 'accessToken' of undefined",
|
|
86
|
+
stack: stack("handleOtpResponse", "screens/auth/OtpScreen.tsx", 88)
|
|
87
|
+
}),
|
|
88
|
+
crumbs: [
|
|
89
|
+
{
|
|
90
|
+
category: "navigation",
|
|
91
|
+
message: "Login → OtpScreen"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
category: "ui",
|
|
95
|
+
message: "Tapped Verify"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
category: "network",
|
|
99
|
+
message: "POST /v2/auth/otp/verify → 200 (412ms)"
|
|
100
|
+
}
|
|
101
|
+
],
|
|
102
|
+
fatal: true
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
flow: "checkout.payment",
|
|
106
|
+
step: "create_intent",
|
|
107
|
+
weight: (_d, dev) => dev.os.name === "ios" ? .6 : .9,
|
|
108
|
+
error: () => ({
|
|
109
|
+
name: "NetworkError",
|
|
110
|
+
message: `Request timed out after ${pick([
|
|
111
|
+
15e3,
|
|
112
|
+
2e4,
|
|
113
|
+
3e4
|
|
114
|
+
])}ms`,
|
|
115
|
+
stack: stack("createPaymentIntent", "services/payments.ts", 54)
|
|
116
|
+
}),
|
|
117
|
+
crumbs: [{
|
|
118
|
+
category: "navigation",
|
|
119
|
+
message: "Cart → Checkout"
|
|
120
|
+
}, {
|
|
121
|
+
category: "network",
|
|
122
|
+
message: "POST /v1/payments/intent → timed out (30000ms)",
|
|
123
|
+
level: "error"
|
|
124
|
+
}],
|
|
125
|
+
request: {
|
|
126
|
+
method: "POST",
|
|
127
|
+
url: "/v1/payments/intent",
|
|
128
|
+
message: "POST /v1/payments/intent timed out"
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
flow: "feed.load",
|
|
133
|
+
step: "parse",
|
|
134
|
+
weight: () => .35,
|
|
135
|
+
error: () => ({
|
|
136
|
+
name: "SyntaxError",
|
|
137
|
+
message: "JSON Parse error: Unexpected token '<'",
|
|
138
|
+
stack: stack("loadFeed", "features/feed/useFeed.ts", 23)
|
|
139
|
+
}),
|
|
140
|
+
crumbs: [{
|
|
141
|
+
category: "network",
|
|
142
|
+
message: "GET /v1/feed → 502 (2210ms)",
|
|
143
|
+
level: "error"
|
|
144
|
+
}],
|
|
145
|
+
request: {
|
|
146
|
+
method: "GET",
|
|
147
|
+
url: "/v1/feed",
|
|
148
|
+
status: 502,
|
|
149
|
+
message: "GET /v1/feed responded 502"
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
flow: "profile.update",
|
|
154
|
+
step: "upload_avatar",
|
|
155
|
+
weight: () => .12,
|
|
156
|
+
error: () => ({
|
|
157
|
+
name: "Error",
|
|
158
|
+
message: "Image exceeds 10MB limit",
|
|
159
|
+
stack: stack("uploadAvatar", "features/profile/avatar.ts", 41)
|
|
160
|
+
})
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
flow: "auth.session",
|
|
164
|
+
step: "refresh",
|
|
165
|
+
weight: (dayAgo) => dayAgo > 7 ? .6 : .08,
|
|
166
|
+
error: () => ({
|
|
167
|
+
name: "AuthError",
|
|
168
|
+
message: "401 Unauthorized: refresh token expired",
|
|
169
|
+
stack: stack("refreshSession", "services/auth/session.ts", 112)
|
|
170
|
+
})
|
|
171
|
+
}
|
|
172
|
+
];
|
|
173
|
+
const successFlows = [
|
|
174
|
+
"auth.login",
|
|
175
|
+
"checkout.payment",
|
|
176
|
+
"feed.load",
|
|
177
|
+
"profile.update"
|
|
178
|
+
];
|
|
179
|
+
for (let dayAgo = 13; dayAgo >= 0; dayAgo--) {
|
|
180
|
+
const version = dayAgo <= 3 ? pick([
|
|
181
|
+
"2.4.0",
|
|
182
|
+
"2.4.0",
|
|
183
|
+
"2.4.0",
|
|
184
|
+
"2.3.1"
|
|
185
|
+
]) : pick([
|
|
186
|
+
"2.3.1",
|
|
187
|
+
"2.3.1",
|
|
188
|
+
"2.3.0"
|
|
189
|
+
]);
|
|
190
|
+
for (let s = 0; s < 70; s++) {
|
|
191
|
+
const ts = (/* @__PURE__ */ new Date(now - dayAgo * 864e5 - Math.floor(rand() * 864e5))).toISOString();
|
|
192
|
+
const dev = pick(devices);
|
|
193
|
+
const appVersion = rand() < .85 ? version : "2.3.1";
|
|
194
|
+
const events = [];
|
|
195
|
+
const userId = `user_${Math.floor(rand() * 400)}`;
|
|
196
|
+
const id = () => `evt_${(seq++).toString().padStart(10, "0")}`;
|
|
197
|
+
let crashed = false;
|
|
198
|
+
for (const sc of scenarios) {
|
|
199
|
+
const w = sc.weight(dayAgo, dev, appVersion);
|
|
200
|
+
let n = Math.floor(w) + (rand() < w % 1 ? 1 : 0);
|
|
201
|
+
while (n-- > 0) {
|
|
202
|
+
const err = sc.error();
|
|
203
|
+
if (sc.request) {
|
|
204
|
+
const r = sc.request;
|
|
205
|
+
events.push({
|
|
206
|
+
type: "error",
|
|
207
|
+
id: id(),
|
|
208
|
+
ts,
|
|
209
|
+
flow: sc.flow,
|
|
210
|
+
handled: true,
|
|
211
|
+
tags: { source: "network" },
|
|
212
|
+
error: {
|
|
213
|
+
name: r.status ? "HttpError" : "NetworkError",
|
|
214
|
+
message: r.message
|
|
215
|
+
},
|
|
216
|
+
request: {
|
|
217
|
+
method: r.method,
|
|
218
|
+
url: r.url,
|
|
219
|
+
status: r.status,
|
|
220
|
+
durationMs: r.status ? 2210 : 3e4
|
|
221
|
+
},
|
|
222
|
+
breadcrumbs: (sc.crumbs ?? []).map((c) => ({
|
|
223
|
+
ts,
|
|
224
|
+
level: c.level ?? "info",
|
|
225
|
+
...c
|
|
226
|
+
}))
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
if (sc.fatal) crashed = true;
|
|
230
|
+
events.push({
|
|
231
|
+
type: "error",
|
|
232
|
+
id: `evt_${(seq++).toString().padStart(10, "0")}`,
|
|
233
|
+
ts,
|
|
234
|
+
flow: sc.flow,
|
|
235
|
+
step: sc.step,
|
|
236
|
+
handled: !sc.fatal,
|
|
237
|
+
...sc.fatal ? { severity: "critical" } : {},
|
|
238
|
+
error: err,
|
|
239
|
+
breadcrumbs: (sc.crumbs ?? []).map((c) => ({
|
|
240
|
+
ts,
|
|
241
|
+
level: c.level ?? "info",
|
|
242
|
+
...c
|
|
243
|
+
}))
|
|
244
|
+
});
|
|
245
|
+
events.push({
|
|
246
|
+
type: "event",
|
|
247
|
+
id: `evt_${(seq++).toString().padStart(10, "0")}`,
|
|
248
|
+
ts,
|
|
249
|
+
name: `${sc.flow}.${sc.step}`,
|
|
250
|
+
flow: sc.flow,
|
|
251
|
+
step: sc.step,
|
|
252
|
+
outcome: "failure"
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
for (const flow of successFlows) if (rand() < .55) events.push({
|
|
257
|
+
type: "event",
|
|
258
|
+
id: `evt_${(seq++).toString().padStart(10, "0")}`,
|
|
259
|
+
ts,
|
|
260
|
+
name: `${flow}.complete`,
|
|
261
|
+
flow,
|
|
262
|
+
outcome: "success"
|
|
263
|
+
});
|
|
264
|
+
events.unshift({
|
|
265
|
+
type: "session",
|
|
266
|
+
id: id(),
|
|
267
|
+
ts,
|
|
268
|
+
status: "started"
|
|
269
|
+
});
|
|
270
|
+
if (crashed) events.push({
|
|
271
|
+
type: "session",
|
|
272
|
+
id: id(),
|
|
273
|
+
ts,
|
|
274
|
+
status: "errored"
|
|
275
|
+
}, {
|
|
276
|
+
type: "session",
|
|
277
|
+
id: id(),
|
|
278
|
+
ts,
|
|
279
|
+
status: "crashed"
|
|
280
|
+
});
|
|
281
|
+
if (events.length > 100) events.length = 100;
|
|
282
|
+
const env = {
|
|
283
|
+
sdk: {
|
|
284
|
+
name: "@debugkit/sdk",
|
|
285
|
+
version: "0.1.0"
|
|
286
|
+
},
|
|
287
|
+
context: {
|
|
288
|
+
app: {
|
|
289
|
+
id: "megaton-native",
|
|
290
|
+
version: appVersion,
|
|
291
|
+
build: appVersion.replace(/\./g, "") + "0",
|
|
292
|
+
environment: "production"
|
|
293
|
+
},
|
|
294
|
+
...dev,
|
|
295
|
+
runtime: {
|
|
296
|
+
name: "react-native",
|
|
297
|
+
version: "0.79",
|
|
298
|
+
engine: "hermes"
|
|
299
|
+
},
|
|
300
|
+
network: { type: pick(networks) },
|
|
301
|
+
locale: "en-ZA",
|
|
302
|
+
timezone: "Africa/Johannesburg"
|
|
303
|
+
},
|
|
304
|
+
user: {
|
|
305
|
+
id: userId,
|
|
306
|
+
anonymousId: `anon_${userId}`
|
|
307
|
+
},
|
|
308
|
+
session: {
|
|
309
|
+
id: `sess_${seq}`,
|
|
310
|
+
startedAt: ts
|
|
311
|
+
},
|
|
312
|
+
events
|
|
313
|
+
};
|
|
314
|
+
const out = await ingest(JSON.stringify(env), "pk_demo", {
|
|
315
|
+
store,
|
|
316
|
+
keys,
|
|
317
|
+
now: () => new Date(Date.parse(ts) + 1e3)
|
|
318
|
+
});
|
|
319
|
+
if (out.status !== 202) throw new Error(`demo seed rejected: ${JSON.stringify(out.body)}`);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return store;
|
|
323
|
+
}
|
|
324
|
+
function mulberry32(seed) {
|
|
325
|
+
return () => {
|
|
326
|
+
seed |= 0;
|
|
327
|
+
seed = seed + 1831565813 | 0;
|
|
328
|
+
let t = Math.imul(seed ^ seed >>> 15, 1 | seed);
|
|
329
|
+
t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
|
|
330
|
+
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
export { seedDemo };
|