@blipit/react-native 0.3.0 → 0.5.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/BlipitReactNative.podspec +23 -0
- package/CHANGELOG.md +13 -11
- package/README.md +111 -6
- package/android/build.gradle +32 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/io/blipit/reactnative/BlipitNuggetsModule.kt +79 -0
- package/android/src/main/java/io/blipit/reactnative/BlipitNuggetsPackage.kt +12 -0
- package/dist/index.cjs +792 -138
- package/dist/index.d.cts +137 -11
- package/dist/index.d.ts +137 -11
- package/dist/index.js +703 -48
- package/ios/BlipitNuggets.m +13 -0
- package/ios/BlipitNuggets.swift +69 -0
- package/ios/PrivacyInfo.xcprivacy +39 -0
- package/package.json +7 -4
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/index.ts
|
|
@@ -32,23 +22,434 @@ var index_exports = {};
|
|
|
32
22
|
__export(index_exports, {
|
|
33
23
|
BlipitReporter: () => BlipitReporter,
|
|
34
24
|
DEFAULT_ENDPOINT: () => DEFAULT_ENDPOINT,
|
|
25
|
+
ErrorBoundary: () => ErrorBoundary,
|
|
35
26
|
VERSION: () => VERSION,
|
|
36
|
-
addBreadcrumb: () =>
|
|
37
|
-
captureException: () =>
|
|
38
|
-
captureMessage: () =>
|
|
27
|
+
addBreadcrumb: () => addBreadcrumb,
|
|
28
|
+
captureException: () => captureException,
|
|
29
|
+
captureMessage: () => captureMessage,
|
|
39
30
|
captureSecurity: () => captureSecurity,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
31
|
+
endFlow: () => endFlow,
|
|
32
|
+
flowStep: () => flowStep,
|
|
33
|
+
flush: () => flush,
|
|
34
|
+
hasReplayConsent: () => hasReplayConsent,
|
|
35
|
+
init: () => init,
|
|
36
|
+
isEnabled: () => isEnabled,
|
|
37
|
+
lastEventId: () => lastEventId,
|
|
38
|
+
reportReady: () => reportReady,
|
|
39
|
+
setEnabled: () => setEnabled,
|
|
40
|
+
setReplayConsent: () => setReplayConsent,
|
|
41
|
+
setTag: () => setTag,
|
|
42
|
+
setUser: () => setUser,
|
|
45
43
|
showReport: () => showReport,
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
startFlow: () => startFlow,
|
|
45
|
+
trackNavigation: () => trackNavigation2,
|
|
46
|
+
wrap: () => wrap
|
|
48
47
|
});
|
|
49
48
|
module.exports = __toCommonJS(index_exports);
|
|
50
|
-
var
|
|
51
|
-
|
|
49
|
+
var import_react_native3 = require("react-native");
|
|
50
|
+
|
|
51
|
+
// src/nuggets.ts
|
|
52
|
+
var VERSION = "0.5.0";
|
|
53
|
+
var SDK_NAME = "@blipit/react-native";
|
|
54
|
+
var DEFAULT_ENDPOINT = "https://in.blipit.io";
|
|
55
|
+
var CATEGORIES = /* @__PURE__ */ new Set(["ui.click", "ui.input", "navigation", "http", "console", "query", "custom"]);
|
|
56
|
+
var CRUMB_LEVELS = /* @__PURE__ */ new Set(["error", "warning", "info", "debug"]);
|
|
57
|
+
var TAG_KEY = /[^a-zA-Z0-9_.-]/g;
|
|
58
|
+
var SENSITIVE = /\b((?:[a-zA-Z0-9_-]*(?:token|key|password|secret|auth|session|passwd|api)[a-zA-Z0-9_-]*)=)[^&\s"']+/gi;
|
|
59
|
+
var QUEUE_MAX = 30;
|
|
60
|
+
var truncate = (v, max) => v.length > max ? v.slice(0, max) : v;
|
|
61
|
+
var scrub = (text2) => text2.replace(SENSITIVE, "$1[redacted]");
|
|
62
|
+
function uuid32() {
|
|
63
|
+
let out = "";
|
|
64
|
+
for (let i = 0; i < 32; i++) out += Math.floor(Math.random() * 16).toString(16);
|
|
65
|
+
return `${out.slice(0, 12)}4${out.slice(13, 16)}${"89ab"[Math.floor(Math.random() * 4)]}${out.slice(17)}`;
|
|
66
|
+
}
|
|
67
|
+
var HERMES = /^\s*at (?:(.+?) \()?(?:address at )?(.+?):(\d+):(\d+)\)?\s*$/;
|
|
68
|
+
var JSC = /^\s*(?:(.*?)@)?(.+?):(\d+):(\d+)\s*$/;
|
|
69
|
+
function parseStack(stack) {
|
|
70
|
+
if (!stack) return [];
|
|
71
|
+
const frames = [];
|
|
72
|
+
for (const line of stack.split("\n")) {
|
|
73
|
+
const m = HERMES.exec(line) ?? (/^\s*at /.test(line) ? null : JSC.exec(line));
|
|
74
|
+
if (!m) continue;
|
|
75
|
+
const file = m[2].replace(/\?.*$/, "");
|
|
76
|
+
const frame = { filename: truncate(file, 1024), lineno: Number(m[3]), colno: Number(m[4]), in_app: !/node_modules|\[native code\]/.test(file) };
|
|
77
|
+
if (m[1]) frame.function = truncate(m[1], 512);
|
|
78
|
+
frames.push(frame);
|
|
79
|
+
}
|
|
80
|
+
return frames.reverse().slice(-128);
|
|
81
|
+
}
|
|
82
|
+
function cleanCrumb(c, at) {
|
|
83
|
+
const ts = typeof c.timestamp === "number" ? new Date(c.timestamp < 1e12 ? c.timestamp * 1e3 : c.timestamp).toISOString() : c.timestamp ?? at;
|
|
84
|
+
const out = { timestamp: ts, category: c.category && CATEGORIES.has(c.category) ? c.category : "custom" };
|
|
85
|
+
if (c.message) out.message = truncate(scrub(String(c.message)), 1024);
|
|
86
|
+
if (c.level && CRUMB_LEVELS.has(c.level)) out.level = c.level;
|
|
87
|
+
if (c.data && typeof c.data === "object") out.data = typeof c.data.url === "string" ? { ...c.data, url: scrub(c.data.url) } : c.data;
|
|
88
|
+
return out;
|
|
89
|
+
}
|
|
90
|
+
var Nuggets = class {
|
|
91
|
+
endpoint;
|
|
92
|
+
key;
|
|
93
|
+
user;
|
|
94
|
+
tags = {};
|
|
95
|
+
lastEventId;
|
|
96
|
+
enabled;
|
|
97
|
+
onError;
|
|
98
|
+
crumbs = [];
|
|
99
|
+
queue = [];
|
|
100
|
+
captured = /* @__PURE__ */ new WeakSet();
|
|
101
|
+
timer;
|
|
102
|
+
sending;
|
|
103
|
+
pausedUntil = 0;
|
|
104
|
+
fetcher;
|
|
105
|
+
now;
|
|
106
|
+
options;
|
|
107
|
+
constructor(options) {
|
|
108
|
+
this.options = options;
|
|
109
|
+
this.endpoint = (options.endpoint ?? DEFAULT_ENDPOINT).replace(/\/api\/v1\/events.*$/, "").replace(/\/+$/, "");
|
|
110
|
+
this.key = options.key;
|
|
111
|
+
this.enabled = options.enabled !== false;
|
|
112
|
+
this.fetcher = options.fetch ?? ((...a) => fetch(...a));
|
|
113
|
+
this.now = options.now ?? Date.now;
|
|
114
|
+
try {
|
|
115
|
+
const saved = JSON.parse(options.store?.load() ?? "[]");
|
|
116
|
+
if (Array.isArray(saved)) this.queue = saved.slice(-QUEUE_MAX);
|
|
117
|
+
} catch {
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
get pending() {
|
|
121
|
+
return this.queue.length;
|
|
122
|
+
}
|
|
123
|
+
url(path) {
|
|
124
|
+
return `${this.endpoint}${path}`;
|
|
125
|
+
}
|
|
126
|
+
setEnabled(on) {
|
|
127
|
+
this.enabled = on;
|
|
128
|
+
if (!on) {
|
|
129
|
+
this.queue = [];
|
|
130
|
+
this.crumbs = [];
|
|
131
|
+
this.persist();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
setUser(user) {
|
|
135
|
+
if (!user) return void (this.user = void 0);
|
|
136
|
+
const u = {};
|
|
137
|
+
if (user.id !== void 0 && user.id !== null) u.id = truncate(String(user.id), 128);
|
|
138
|
+
if (user.email) u.email = truncate(user.email, 256);
|
|
139
|
+
if (user.username) u.username = truncate(user.username, 128);
|
|
140
|
+
this.user = Object.keys(u).length ? u : void 0;
|
|
141
|
+
}
|
|
142
|
+
setTag(key, value) {
|
|
143
|
+
const k = truncate(String(key).replace(TAG_KEY, "_"), 64);
|
|
144
|
+
if (k && (k in this.tags || Object.keys(this.tags).length < 32)) this.tags[k] = truncate(String(value), 256);
|
|
145
|
+
}
|
|
146
|
+
addBreadcrumb(crumb) {
|
|
147
|
+
if (!this.enabled) return;
|
|
148
|
+
this.crumbs.push(cleanCrumb(crumb, new Date(this.now()).toISOString()));
|
|
149
|
+
const max = Math.min(this.options.maxBreadcrumbs ?? 50, 100);
|
|
150
|
+
while (this.crumbs.length > max) this.crumbs.shift();
|
|
151
|
+
}
|
|
152
|
+
captureException(error, handled = true, level = "error") {
|
|
153
|
+
if (error && typeof error === "object") {
|
|
154
|
+
if (this.captured.has(error)) return void 0;
|
|
155
|
+
this.captured.add(error);
|
|
156
|
+
}
|
|
157
|
+
const err = error instanceof Error ? error : new Error(typeof error === "string" ? error : safeJson(error));
|
|
158
|
+
const exception = { type: truncate(err.name || "Error", 256), value: truncate(scrub(err.message || String(err)), 4096), handled };
|
|
159
|
+
const frames = parseStack(err.stack);
|
|
160
|
+
if (frames.length) exception.stacktrace = { frames };
|
|
161
|
+
return this.capture({ exception, level });
|
|
162
|
+
}
|
|
163
|
+
captureMessage(message, level = "info") {
|
|
164
|
+
return this.capture({ message: truncate(scrub(String(message)), 8192), level });
|
|
165
|
+
}
|
|
166
|
+
captureSecurity(kind, message, level, security) {
|
|
167
|
+
return this.capture({ message: truncate(message, 8192), level, ...security ? { security } : {}, tags: { "security.kind": truncate(kind, 256) } }, false);
|
|
168
|
+
}
|
|
169
|
+
capture(partial, filter = true) {
|
|
170
|
+
if (!this.enabled) return void 0;
|
|
171
|
+
if (filter && this.options.sampleRate !== void 0 && Math.random() >= this.options.sampleRate) return void 0;
|
|
172
|
+
const text2 = partial.exception?.value ?? partial.message ?? "";
|
|
173
|
+
if (filter && (this.options.ignoreErrors ?? []).some((p) => typeof p === "string" ? text2.includes(p) : p.test(text2))) return void 0;
|
|
174
|
+
let event = {
|
|
175
|
+
event_id: uuid32(),
|
|
176
|
+
timestamp: new Date(this.now()).toISOString(),
|
|
177
|
+
platform: "react-native",
|
|
178
|
+
level: "error",
|
|
179
|
+
environment: this.options.environment ?? "production",
|
|
180
|
+
sdk: { name: SDK_NAME, version: VERSION },
|
|
181
|
+
...partial
|
|
182
|
+
};
|
|
183
|
+
if (this.options.release) event.release = truncate(this.options.release, 256);
|
|
184
|
+
if (this.user) event.user = { ...this.user };
|
|
185
|
+
const tags = { ...this.tags, ...partial.tags };
|
|
186
|
+
if (Object.keys(tags).length) event.tags = tags;
|
|
187
|
+
if (this.crumbs.length) event.breadcrumbs = [...this.crumbs];
|
|
188
|
+
const contexts2 = this.options.contexts?.();
|
|
189
|
+
if (contexts2 && Object.keys(contexts2).length) event.contexts = contexts2;
|
|
190
|
+
if (this.options.beforeSend) {
|
|
191
|
+
const out = this.options.beforeSend(event);
|
|
192
|
+
if (!out) return void 0;
|
|
193
|
+
event = out;
|
|
194
|
+
}
|
|
195
|
+
this.enqueue(event);
|
|
196
|
+
this.lastEventId = event.event_id;
|
|
197
|
+
if (event.exception) this.onError?.(!event.exception.handled);
|
|
198
|
+
return event.event_id;
|
|
199
|
+
}
|
|
200
|
+
enqueue(event) {
|
|
201
|
+
if (!this.enabled) return false;
|
|
202
|
+
this.queue.push(event);
|
|
203
|
+
while (this.queue.length > QUEUE_MAX) this.queue.shift();
|
|
204
|
+
this.persist();
|
|
205
|
+
this.schedule(1e3);
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
persist() {
|
|
209
|
+
try {
|
|
210
|
+
this.options.store?.save(JSON.stringify(this.queue));
|
|
211
|
+
} catch {
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
schedule(ms) {
|
|
215
|
+
if (this.timer) return;
|
|
216
|
+
this.timer = setTimeout(() => {
|
|
217
|
+
this.timer = void 0;
|
|
218
|
+
void this.flush();
|
|
219
|
+
}, Math.max(ms, this.pausedUntil - this.now()));
|
|
220
|
+
this.timer.unref?.();
|
|
221
|
+
}
|
|
222
|
+
async flush() {
|
|
223
|
+
while (this.sending) await this.sending;
|
|
224
|
+
this.sending = this.drain().finally(() => this.sending = void 0);
|
|
225
|
+
return this.sending;
|
|
226
|
+
}
|
|
227
|
+
async drain() {
|
|
228
|
+
while (this.queue.length && this.enabled && this.now() >= this.pausedUntil) {
|
|
229
|
+
const event = this.queue[0];
|
|
230
|
+
const verdict = await this.send(event);
|
|
231
|
+
if (verdict === "retry") return this.schedule(3e4);
|
|
232
|
+
if (verdict === "wait") return this.schedule(0);
|
|
233
|
+
if (this.queue[0] === event) this.queue.shift();
|
|
234
|
+
this.persist();
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
post(path, body) {
|
|
238
|
+
return this.fetcher(this.url(path), { method: "POST", headers: { "Content-Type": "application/json", "X-Blipit-Key": this.key }, body: JSON.stringify(body) });
|
|
239
|
+
}
|
|
240
|
+
async send(event) {
|
|
241
|
+
try {
|
|
242
|
+
const res = await this.post("/api/v1/events", event);
|
|
243
|
+
if (res.status === 429) {
|
|
244
|
+
const header = Number(res.headers?.get?.("retry-after"));
|
|
245
|
+
let seconds = Number.isFinite(header) && header > 0 ? header : 0;
|
|
246
|
+
if (!seconds) {
|
|
247
|
+
try {
|
|
248
|
+
seconds = Number(JSON.parse(await res.text()).retry_after) || 60;
|
|
249
|
+
} catch {
|
|
250
|
+
seconds = 60;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
this.pausedUntil = this.now() + Math.min(seconds, 3600) * 1e3;
|
|
254
|
+
return "wait";
|
|
255
|
+
}
|
|
256
|
+
if (res.status >= 500) return "retry";
|
|
257
|
+
if (res.status >= 400 && this.options.debug) console.warn("[blipit] event rejected", res.status);
|
|
258
|
+
return "done";
|
|
259
|
+
} catch {
|
|
260
|
+
return "retry";
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
var RANK = { ok: 0, errored: 1, crashed: 2 };
|
|
265
|
+
var Session = class {
|
|
266
|
+
sid = "";
|
|
267
|
+
started = "";
|
|
268
|
+
status = "ok";
|
|
269
|
+
errors = 0;
|
|
270
|
+
core;
|
|
271
|
+
release;
|
|
272
|
+
environment;
|
|
273
|
+
constructor(core2, release, environment) {
|
|
274
|
+
this.core = core2;
|
|
275
|
+
this.release = release;
|
|
276
|
+
this.environment = environment;
|
|
277
|
+
}
|
|
278
|
+
start() {
|
|
279
|
+
if (this.sid) return;
|
|
280
|
+
this.sid = uuid32();
|
|
281
|
+
this.started = (/* @__PURE__ */ new Date()).toISOString();
|
|
282
|
+
this.status = "ok";
|
|
283
|
+
this.errors = 0;
|
|
284
|
+
this.send(false);
|
|
285
|
+
}
|
|
286
|
+
end() {
|
|
287
|
+
if (!this.sid) return;
|
|
288
|
+
this.send(true);
|
|
289
|
+
this.sid = "";
|
|
290
|
+
}
|
|
291
|
+
markError(unhandled) {
|
|
292
|
+
if (!this.sid) return;
|
|
293
|
+
this.errors += 1;
|
|
294
|
+
const next = unhandled ? "crashed" : "errored";
|
|
295
|
+
if (RANK[next] <= RANK[this.status]) return;
|
|
296
|
+
this.status = next;
|
|
297
|
+
this.send(false);
|
|
298
|
+
}
|
|
299
|
+
send(ending) {
|
|
300
|
+
if (!this.core.enabled) return;
|
|
301
|
+
const did = this.core.user?.id ?? this.core.user?.email;
|
|
302
|
+
const status = this.status === "ok" && ending ? "exited" : this.status;
|
|
303
|
+
this.core.post("/api/v1/sessions", { sid: this.sid, did, status, errors: this.errors, started: this.started, release: this.release, environment: this.environment }).catch(() => void 0);
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
function safeJson(v) {
|
|
307
|
+
try {
|
|
308
|
+
return JSON.stringify(v) ?? String(v);
|
|
309
|
+
} catch {
|
|
310
|
+
return String(v);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// src/instrument.ts
|
|
315
|
+
var done = /* @__PURE__ */ new WeakSet();
|
|
316
|
+
function instrument(core2, g = globalThis) {
|
|
317
|
+
if (done.has(g)) return;
|
|
318
|
+
done.add(g);
|
|
319
|
+
const eu = g.ErrorUtils;
|
|
320
|
+
if (eu?.setGlobalHandler) {
|
|
321
|
+
const prev = eu.getGlobalHandler?.();
|
|
322
|
+
eu.setGlobalHandler((error, isFatal) => {
|
|
323
|
+
const c = core2();
|
|
324
|
+
c?.captureException(error, false, isFatal ? "fatal" : "error");
|
|
325
|
+
if (isFatal) void c?.flush();
|
|
326
|
+
prev?.(error, isFatal);
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
const onUnhandled = (_id, reason) => void core2()?.captureException(reason, false);
|
|
330
|
+
if (g.HermesInternal?.enablePromiseRejectionTracker) {
|
|
331
|
+
g.HermesInternal.enablePromiseRejectionTracker({ allRejections: true, onUnhandled });
|
|
332
|
+
} else {
|
|
333
|
+
try {
|
|
334
|
+
require("promise/setimmediate/rejection-tracking").enable({ allRejections: true, onUnhandled });
|
|
335
|
+
} catch {
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
for (const level of ["warn", "error"]) {
|
|
339
|
+
const original = g.console[level];
|
|
340
|
+
if (typeof original !== "function") continue;
|
|
341
|
+
g.console[level] = (...args) => {
|
|
342
|
+
const message = truncate(args.map((a) => typeof a === "string" ? a : a instanceof Error ? a.message : json(a)).join(" "), 1024);
|
|
343
|
+
if (!message.startsWith("[blipit]")) core2()?.addBreadcrumb({ category: "console", level: level === "warn" ? "warning" : "error", message });
|
|
344
|
+
original.apply(g.console, args);
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
const proto = g.XMLHttpRequest?.prototype;
|
|
348
|
+
if (proto?.open && proto.send) {
|
|
349
|
+
const open = proto.open;
|
|
350
|
+
const send = proto.send;
|
|
351
|
+
proto.open = function(method, url, ...rest) {
|
|
352
|
+
this._blipit = [String(method).toUpperCase(), String(url)];
|
|
353
|
+
return open.call(this, method, url, ...rest);
|
|
354
|
+
};
|
|
355
|
+
proto.send = function(...args) {
|
|
356
|
+
const meta = this._blipit;
|
|
357
|
+
const c = core2();
|
|
358
|
+
if (c && meta && !meta[1].startsWith(c.endpoint)) {
|
|
359
|
+
const start = Date.now();
|
|
360
|
+
this.addEventListener?.("loadend", () => {
|
|
361
|
+
const status = this.status;
|
|
362
|
+
const url = meta[1].replace(/[?#].*$/, "");
|
|
363
|
+
c.addBreadcrumb({
|
|
364
|
+
category: "http",
|
|
365
|
+
level: !status || status >= 400 ? "error" : "info",
|
|
366
|
+
message: `${meta[0]} ${url} -> ${status || "network error"}`,
|
|
367
|
+
data: { url, method: meta[0], status_code: status || void 0, duration_ms: Date.now() - start }
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
return send.apply(this, args);
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
function trackNavigation(core2, ref) {
|
|
376
|
+
let last;
|
|
377
|
+
const seen = () => {
|
|
378
|
+
const name = ref.getCurrentRoute()?.name;
|
|
379
|
+
if (!name || name === last) return;
|
|
380
|
+
core2()?.addBreadcrumb({ category: "navigation", message: `Navigated to ${name}`, data: { from: last, to: name } });
|
|
381
|
+
last = name;
|
|
382
|
+
};
|
|
383
|
+
seen();
|
|
384
|
+
return ref.addListener("state", seen);
|
|
385
|
+
}
|
|
386
|
+
function json(v) {
|
|
387
|
+
try {
|
|
388
|
+
return JSON.stringify(v) ?? String(v);
|
|
389
|
+
} catch {
|
|
390
|
+
return String(v);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// src/native.ts
|
|
395
|
+
var import_react_native = require("react-native");
|
|
396
|
+
var bridge = () => import_react_native.NativeModules.BlipitNuggets;
|
|
397
|
+
function nativeInfo() {
|
|
398
|
+
const b = bridge();
|
|
399
|
+
try {
|
|
400
|
+
return b?.getConstants?.() ?? b ?? {};
|
|
401
|
+
} catch {
|
|
402
|
+
return {};
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
function nativeStore() {
|
|
406
|
+
const b = bridge();
|
|
407
|
+
if (!b?.save || !b.load) return void 0;
|
|
408
|
+
return {
|
|
409
|
+
load: () => {
|
|
410
|
+
try {
|
|
411
|
+
return b.load();
|
|
412
|
+
} catch {
|
|
413
|
+
return null;
|
|
414
|
+
}
|
|
415
|
+
},
|
|
416
|
+
save: (data) => void b.save(data)
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
function defaultRelease(info) {
|
|
420
|
+
if (!info.appId || !info.appVersion) return void 0;
|
|
421
|
+
return `${info.appId}@${info.appVersion}${info.appBuild ? `+${info.appBuild}` : ""}`;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// src/boundary.ts
|
|
425
|
+
var import_react = require("react");
|
|
426
|
+
var report = () => void 0;
|
|
427
|
+
function setBoundaryReporter(fn) {
|
|
428
|
+
report = fn;
|
|
429
|
+
}
|
|
430
|
+
var ErrorBoundary = class extends import_react.Component {
|
|
431
|
+
state = { error: null };
|
|
432
|
+
static getDerivedStateFromError(error) {
|
|
433
|
+
return { error };
|
|
434
|
+
}
|
|
435
|
+
componentDidCatch(error) {
|
|
436
|
+
const id = report(error);
|
|
437
|
+
this.props.onError?.(error, id);
|
|
438
|
+
}
|
|
439
|
+
resetError = () => this.setState({ error: null });
|
|
440
|
+
render() {
|
|
441
|
+
if (this.state.error === null) return this.props.children ?? null;
|
|
442
|
+
const { fallback } = this.props;
|
|
443
|
+
if (typeof fallback === "function") return fallback({ error: this.state.error, resetError: this.resetError });
|
|
444
|
+
if (fallback === void 0) throw this.state.error;
|
|
445
|
+
return fallback;
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
function wrap(Root, options = {}) {
|
|
449
|
+
const Wrapped = (props) => (0, import_react.createElement)(ErrorBoundary, options, (0, import_react.createElement)(Root, props));
|
|
450
|
+
Wrapped.displayName = `Blipit(${Root.displayName ?? Root.name ?? "App"})`;
|
|
451
|
+
return Wrapped;
|
|
452
|
+
}
|
|
52
453
|
|
|
53
454
|
// src/report-strings.ts
|
|
54
455
|
var REPORT_STRINGS = {
|
|
@@ -469,16 +870,23 @@ var ReportClient = class {
|
|
|
469
870
|
this.key = key;
|
|
470
871
|
this.fetcher = fetcher;
|
|
471
872
|
}
|
|
472
|
-
async call(path,
|
|
473
|
-
const res = await this.fetcher(`${this.endpoint}${path}`, { ...
|
|
873
|
+
async call(path, init2) {
|
|
874
|
+
const res = await this.fetcher(`${this.endpoint}${path}`, { ...init2, headers: { "X-Blipit-Key": this.key, ...init2.headers } });
|
|
474
875
|
const text2 = await res.text();
|
|
475
876
|
if (!res.ok) throw new Error(`Blipit returned ${res.status}`);
|
|
476
877
|
return text2;
|
|
477
878
|
}
|
|
879
|
+
async settings() {
|
|
880
|
+
return JSON.parse(await this.call("/api/v1/feedback/settings", { method: "GET" }));
|
|
881
|
+
}
|
|
882
|
+
async event(body) {
|
|
883
|
+
const res = await this.fetcher(`${this.endpoint}/api/v1/events`, { method: "POST", headers: { "X-Blipit-Key": this.key, "Content-Type": "application/json" }, body: JSON.stringify(body) });
|
|
884
|
+
return res.ok || res.status >= 400 && res.status < 500 && res.status !== 408 && res.status !== 429;
|
|
885
|
+
}
|
|
478
886
|
async send(body) {
|
|
479
|
-
const
|
|
480
|
-
if (typeof
|
|
481
|
-
return { id: String(
|
|
887
|
+
const json2 = JSON.parse(await this.call("/api/v1/feedback", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) }));
|
|
888
|
+
if (typeof json2.upload_token !== "string") throw new Error("Blipit returned no upload token");
|
|
889
|
+
return { id: String(json2.id), token: json2.upload_token, ref: typeof json2.ref === "string" ? json2.ref : null };
|
|
482
890
|
}
|
|
483
891
|
async uploadScreenshot(receipt, data, type) {
|
|
484
892
|
await this.call(`/api/v1/feedback/${encodeURIComponent(receipt.id)}/screenshot?position=0`, { method: "POST", headers: { "Content-Type": type, "X-Blipit-Upload": receipt.token }, body: data });
|
|
@@ -524,9 +932,144 @@ function zoomAround(zoom, pan, next, focal, view, image) {
|
|
|
524
932
|
}
|
|
525
933
|
var strokeFor = (image) => Math.max(4, image.width / 130);
|
|
526
934
|
|
|
935
|
+
// src/stuck.ts
|
|
936
|
+
var STARTUP = "startup";
|
|
937
|
+
function limitsFrom(value) {
|
|
938
|
+
const v = value;
|
|
939
|
+
if (!v || typeof v.startup_ms !== "number" || typeof v.flow_ms !== "number") return null;
|
|
940
|
+
return { startupMs: v.startup_ms, flowMs: v.flow_ms };
|
|
941
|
+
}
|
|
942
|
+
function cleanName(value, max) {
|
|
943
|
+
if (typeof value !== "string") return null;
|
|
944
|
+
const clean = value.replace(/\s+/g, " ").trim().slice(0, max);
|
|
945
|
+
return clean || null;
|
|
946
|
+
}
|
|
947
|
+
var FlowWatch = class {
|
|
948
|
+
open = /* @__PURE__ */ new Map();
|
|
949
|
+
foreground = false;
|
|
950
|
+
start(name, now) {
|
|
951
|
+
this.open.delete(name);
|
|
952
|
+
this.open.set(name, { step: null, spent: 0, since: this.foreground ? now : null });
|
|
953
|
+
}
|
|
954
|
+
step(name, step) {
|
|
955
|
+
const flow = this.open.get(name);
|
|
956
|
+
if (!flow) return false;
|
|
957
|
+
flow.step = step;
|
|
958
|
+
return true;
|
|
959
|
+
}
|
|
960
|
+
end(name) {
|
|
961
|
+
return this.open.delete(name);
|
|
962
|
+
}
|
|
963
|
+
get empty() {
|
|
964
|
+
return this.open.size === 0;
|
|
965
|
+
}
|
|
966
|
+
setForeground(on, now) {
|
|
967
|
+
if (on === this.foreground) return;
|
|
968
|
+
this.foreground = on;
|
|
969
|
+
for (const flow of this.open.values()) {
|
|
970
|
+
if (on) flow.since = now;
|
|
971
|
+
else {
|
|
972
|
+
flow.spent += now - (flow.since ?? now);
|
|
973
|
+
flow.since = null;
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
due(now, limits) {
|
|
978
|
+
if (!limits) return [];
|
|
979
|
+
const out = [];
|
|
980
|
+
for (const [name, flow] of this.open) {
|
|
981
|
+
const waited = flow.spent + (flow.since === null ? 0 : now - flow.since);
|
|
982
|
+
const limit = name === STARTUP ? limits.startupMs : limits.flowMs;
|
|
983
|
+
if (limit > 0 && waited >= limit) {
|
|
984
|
+
out.push({ name, step: flow.step, waitedMs: waited });
|
|
985
|
+
this.open.delete(name);
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
return out;
|
|
989
|
+
}
|
|
990
|
+
};
|
|
991
|
+
var hex = (n) => Array.from({ length: n }, () => Math.floor(Math.random() * 16).toString(16)).join("");
|
|
992
|
+
function stuckEvent(flow, trail, info, at = /* @__PURE__ */ new Date()) {
|
|
993
|
+
const kind = flow.name === STARTUP ? "startup" : "flow";
|
|
994
|
+
const stuck2 = { kind, waited_ms: Math.round(flow.waitedMs) };
|
|
995
|
+
if (kind === "flow") stuck2.flow = flow.name;
|
|
996
|
+
if (flow.step) stuck2.step = flow.step;
|
|
997
|
+
return {
|
|
998
|
+
event_id: hex(32),
|
|
999
|
+
timestamp: at.toISOString(),
|
|
1000
|
+
platform: "react-native",
|
|
1001
|
+
level: "warning",
|
|
1002
|
+
message: `stuck: ${kind} ${kind === "flow" ? flow.name : kind}`,
|
|
1003
|
+
stuck: stuck2,
|
|
1004
|
+
contexts: { os: { name: info.os, version: info.osVersion } },
|
|
1005
|
+
sdk: { name: "@blipit/react-native", version: info.version },
|
|
1006
|
+
...trail.length ? { breadcrumbs: trail } : {},
|
|
1007
|
+
...info.release ? { release: info.release } : {},
|
|
1008
|
+
...info.environment ? { environment: info.environment } : {}
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
1011
|
+
function createStuck(transport, info, clock = Date.now) {
|
|
1012
|
+
const watch = new FlowWatch();
|
|
1013
|
+
const trail = [];
|
|
1014
|
+
const pending = [];
|
|
1015
|
+
let limits = null;
|
|
1016
|
+
let fetchedAt = -Infinity;
|
|
1017
|
+
let timer = null;
|
|
1018
|
+
const crumb = (message) => {
|
|
1019
|
+
trail.push({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), category: "custom", message });
|
|
1020
|
+
if (trail.length > 30) trail.shift();
|
|
1021
|
+
};
|
|
1022
|
+
const fetchLimits = () => {
|
|
1023
|
+
fetchedAt = clock();
|
|
1024
|
+
transport.settings().then((s2) => limits = limitsFrom(s2?.stuck) ?? limits, () => void 0);
|
|
1025
|
+
};
|
|
1026
|
+
const flush2 = () => {
|
|
1027
|
+
for (const body of pending.splice(0)) {
|
|
1028
|
+
transport.event(body).then(
|
|
1029
|
+
(ok) => !ok && pending.length < 10 && pending.push(body),
|
|
1030
|
+
() => pending.length < 10 && pending.push(body)
|
|
1031
|
+
);
|
|
1032
|
+
}
|
|
1033
|
+
};
|
|
1034
|
+
const tick = () => {
|
|
1035
|
+
if (!limits && clock() - fetchedAt > 6e4) fetchLimits();
|
|
1036
|
+
for (const flow of watch.due(clock(), limits)) if (pending.length < 10) pending.push(stuckEvent(flow, trail.slice(), info));
|
|
1037
|
+
flush2();
|
|
1038
|
+
if (watch.empty && timer) {
|
|
1039
|
+
clearInterval(timer);
|
|
1040
|
+
timer = null;
|
|
1041
|
+
}
|
|
1042
|
+
};
|
|
1043
|
+
const schedule = () => {
|
|
1044
|
+
if (!timer) timer = setInterval(tick, 1e3);
|
|
1045
|
+
};
|
|
1046
|
+
return {
|
|
1047
|
+
tick,
|
|
1048
|
+
get limits() {
|
|
1049
|
+
return limits;
|
|
1050
|
+
},
|
|
1051
|
+
setForeground(on) {
|
|
1052
|
+
watch.setForeground(on, clock());
|
|
1053
|
+
if (on) schedule();
|
|
1054
|
+
},
|
|
1055
|
+
start(name) {
|
|
1056
|
+
if (!limits && clock() - fetchedAt > 6e4) fetchLimits();
|
|
1057
|
+
watch.start(name, clock());
|
|
1058
|
+
crumb(`flow ${name} started`);
|
|
1059
|
+
schedule();
|
|
1060
|
+
},
|
|
1061
|
+
step(name, step) {
|
|
1062
|
+
if (watch.step(name, step)) crumb(`flow ${name}: ${step}`);
|
|
1063
|
+
},
|
|
1064
|
+
end(name) {
|
|
1065
|
+
if (watch.end(name)) crumb(`flow ${name} finished`);
|
|
1066
|
+
}
|
|
1067
|
+
};
|
|
1068
|
+
}
|
|
1069
|
+
|
|
527
1070
|
// src/reporter.tsx
|
|
528
|
-
var
|
|
529
|
-
var
|
|
1071
|
+
var import_react2 = require("react");
|
|
1072
|
+
var import_react_native2 = require("react-native");
|
|
530
1073
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
531
1074
|
var C = { navy: "#0B1A3A", card: "#1A2135", brand: "#3882F6", muted: "#98A6BE", mark: "#FF3B30", danger: "#FF7A6E", white: "#FFFFFF" };
|
|
532
1075
|
var opener = null;
|
|
@@ -554,14 +1097,14 @@ var languages = () => {
|
|
|
554
1097
|
}
|
|
555
1098
|
};
|
|
556
1099
|
function BlipitReporter({ children, showButton = false }) {
|
|
557
|
-
const lang = (0,
|
|
1100
|
+
const lang = (0, import_react2.useMemo)(() => pickLang(languages()), []);
|
|
558
1101
|
const t = (key) => text(key, lang);
|
|
559
|
-
const [stage, setStage] = (0,
|
|
560
|
-
const [shot, setShot] = (0,
|
|
561
|
-
const [flat, setFlat] = (0,
|
|
562
|
-
const [notice, setNotice] = (0,
|
|
563
|
-
const shapes = (0,
|
|
564
|
-
(0,
|
|
1102
|
+
const [stage, setStage] = (0, import_react2.useState)("closed");
|
|
1103
|
+
const [shot, setShot] = (0, import_react2.useState)(null);
|
|
1104
|
+
const [flat, setFlat] = (0, import_react2.useState)(null);
|
|
1105
|
+
const [notice, setNotice] = (0, import_react2.useState)(null);
|
|
1106
|
+
const shapes = (0, import_react2.useRef)([]);
|
|
1107
|
+
(0, import_react2.useEffect)(() => {
|
|
565
1108
|
opener = () => {
|
|
566
1109
|
shapes.current = [];
|
|
567
1110
|
setShot(null);
|
|
@@ -580,7 +1123,7 @@ function BlipitReporter({ children, showButton = false }) {
|
|
|
580
1123
|
try {
|
|
581
1124
|
if (!shooter) throw new Error("react-native-view-shot is not installed");
|
|
582
1125
|
const uri = await shooter.captureScreen({ format: "jpg", quality: 0.9, result: "tmpfile" });
|
|
583
|
-
const size = await new Promise((ok, fail) =>
|
|
1126
|
+
const size = await new Promise((ok, fail) => import_react_native2.Image.getSize(uri, (width, height) => ok({ width, height }), fail));
|
|
584
1127
|
setShot({ uri, ...size });
|
|
585
1128
|
setStage("editor");
|
|
586
1129
|
} catch (err) {
|
|
@@ -589,17 +1132,17 @@ function BlipitReporter({ children, showButton = false }) {
|
|
|
589
1132
|
setStage("details");
|
|
590
1133
|
}
|
|
591
1134
|
};
|
|
592
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1135
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.View, { style: { flex: 1 }, children: [
|
|
593
1136
|
children,
|
|
594
|
-
showButton && stage === "closed" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
595
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
596
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1137
|
+
showButton && stage === "closed" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.Pressable, { accessibilityRole: "button", accessibilityLabel: t("title"), onPress: () => opener?.(), style: ({ pressed }) => [s.fab, pressed && { opacity: 0.85 }], children: [
|
|
1138
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: s.fabIcon, children: "!" }),
|
|
1139
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: s.fabText, children: t("title") })
|
|
597
1140
|
] }) : null,
|
|
598
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
599
|
-
stage === "choice" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1141
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Modal, { visible: stage !== "closed", animationType: "none", presentationStyle: "fullScreen", onRequestClose: () => setStage(stage === "details" && shot ? "editor" : stage === "choice" ? "closed" : "choice"), statusBarTranslucent: false, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.SafeAreaView, { style: [s.screen, { direction: lang === "ar" ? "rtl" : import_react_native2.I18nManager.isRTL ? "rtl" : "ltr" }], children: [
|
|
1142
|
+
stage === "choice" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.View, { style: s.pad, children: [
|
|
600
1143
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Bar, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BarButton, { label: t("close"), glyph: "\u2715", onPress: () => setStage("closed") }) }),
|
|
601
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
602
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1144
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.View, { style: s.center, children: [
|
|
1145
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: s.h1, children: t("mHow") }),
|
|
603
1146
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card, { title: t("mShot"), glyph: "\u25CE", onPress: capture }),
|
|
604
1147
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
605
1148
|
Card,
|
|
@@ -644,42 +1187,42 @@ function BlipitReporter({ children, showButton = false }) {
|
|
|
644
1187
|
] });
|
|
645
1188
|
}
|
|
646
1189
|
function Bar({ children }) {
|
|
647
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1190
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: s.bar, children });
|
|
648
1191
|
}
|
|
649
1192
|
function BarButton({ label, glyph, onPress }) {
|
|
650
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
651
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
652
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1193
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.Pressable, { accessibilityRole: "button", accessibilityLabel: label, onPress, style: s.barButton, hitSlop: 6, children: [
|
|
1194
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: s.glyph, children: glyph }),
|
|
1195
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: s.barText, numberOfLines: 1, children: label })
|
|
653
1196
|
] });
|
|
654
1197
|
}
|
|
655
1198
|
function Primary({ label, onPress, disabled }) {
|
|
656
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1199
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Pressable, { accessibilityRole: "button", accessibilityLabel: label, accessibilityState: { disabled }, disabled, onPress, style: [s.primary, disabled && { opacity: 0.6 }], children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: s.primaryText, children: label }) });
|
|
657
1200
|
}
|
|
658
1201
|
function Card({ title, glyph, onPress }) {
|
|
659
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
660
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
661
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1202
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.Pressable, { accessibilityRole: "button", accessibilityLabel: title, onPress, style: ({ pressed }) => [s.card, pressed && { opacity: 0.85 }], children: [
|
|
1203
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: s.cardGlyph, children: glyph }),
|
|
1204
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: s.cardText, children: title })
|
|
662
1205
|
] });
|
|
663
1206
|
}
|
|
664
1207
|
function Editor({ shot, shapes, t, onBack, onNext }) {
|
|
665
|
-
const [view, setView] = (0,
|
|
666
|
-
const [zoom, setZoom] = (0,
|
|
667
|
-
const [pan, setPan] = (0,
|
|
668
|
-
const [tool, setTool] = (0,
|
|
669
|
-
const [current, setCurrent] = (0,
|
|
670
|
-
const [, redraw] = (0,
|
|
671
|
-
const [busy, setBusy] = (0,
|
|
672
|
-
const box = (0,
|
|
673
|
-
const content = (0,
|
|
674
|
-
const live = (0,
|
|
1208
|
+
const [view, setView] = (0, import_react2.useState)({ width: 0, height: 0, x: 0, y: 0 });
|
|
1209
|
+
const [zoom, setZoom] = (0, import_react2.useState)(1);
|
|
1210
|
+
const [pan, setPan] = (0, import_react2.useState)({ x: 0, y: 0 });
|
|
1211
|
+
const [tool, setTool] = (0, import_react2.useState)("pen");
|
|
1212
|
+
const [current, setCurrent] = (0, import_react2.useState)(null);
|
|
1213
|
+
const [, redraw] = (0, import_react2.useState)(0);
|
|
1214
|
+
const [busy, setBusy] = (0, import_react2.useState)(false);
|
|
1215
|
+
const box = (0, import_react2.useRef)(null);
|
|
1216
|
+
const content = (0, import_react2.useRef)(null);
|
|
1217
|
+
const live = (0, import_react2.useRef)({ zoom, pan, view, tool, current, gesture: null, lastTap: 0, moved: false });
|
|
675
1218
|
live.current.zoom = zoom;
|
|
676
1219
|
live.current.pan = pan;
|
|
677
1220
|
live.current.view = view;
|
|
678
1221
|
live.current.tool = tool;
|
|
679
1222
|
const image = { width: shot.width, height: shot.height };
|
|
680
1223
|
const local = (e) => e.nativeEvent.touches.map((touch) => ({ x: touch.pageX - live.current.view.x, y: touch.pageY - live.current.view.y }));
|
|
681
|
-
const responder = (0,
|
|
682
|
-
() =>
|
|
1224
|
+
const responder = (0, import_react2.useMemo)(
|
|
1225
|
+
() => import_react_native2.PanResponder.create({
|
|
683
1226
|
onStartShouldSetPanResponder: () => true,
|
|
684
1227
|
onMoveShouldSetPanResponder: () => true,
|
|
685
1228
|
onPanResponderTerminationRequest: () => false,
|
|
@@ -780,22 +1323,22 @@ function Editor({ shot, shapes, t, onBack, onNext }) {
|
|
|
780
1323
|
["rect", t("rect"), "\u25A2"],
|
|
781
1324
|
["arrow", t("arrow"), "\u2197"]
|
|
782
1325
|
];
|
|
783
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1326
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.View, { style: { flex: 1 }, children: [
|
|
784
1327
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Bar, { children: [
|
|
785
1328
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(BarButton, { label: t("mBack"), glyph: "\u2039", onPress: onBack }),
|
|
786
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1329
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: { flex: 1 } }),
|
|
787
1330
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconButton, { label: t("mZoomOut"), glyph: "\u2212", onPress: () => zoomBy(1 / 1.5) }),
|
|
788
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1331
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.Text, { style: s.zoom, children: [
|
|
789
1332
|
Math.round(zoom * 100),
|
|
790
1333
|
"%"
|
|
791
1334
|
] }),
|
|
792
1335
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconButton, { label: t("mZoomIn"), glyph: "+", onPress: () => zoomBy(1.5) }),
|
|
793
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
794
|
-
busy ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1336
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: { flex: 1 } }),
|
|
1337
|
+
busy ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.ActivityIndicator, { color: C.white, style: { marginHorizontal: 8 } }) : null,
|
|
795
1338
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Primary, { label: t("mNext"), onPress: next, disabled: busy })
|
|
796
1339
|
] }),
|
|
797
1340
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
798
|
-
|
|
1341
|
+
import_react_native2.View,
|
|
799
1342
|
{
|
|
800
1343
|
ref: box,
|
|
801
1344
|
style: s.stage,
|
|
@@ -805,13 +1348,13 @@ function Editor({ shot, shapes, t, onBack, onNext }) {
|
|
|
805
1348
|
setView((v) => ({ ...v, width: w, height: h }));
|
|
806
1349
|
},
|
|
807
1350
|
...responder.panHandlers,
|
|
808
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
809
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1351
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.View, { ref: content, collapsable: false, style: { position: "absolute", left: o.x, top: o.y, width: shot.width * scale, height: shot.height * scale }, pointerEvents: "none", children: [
|
|
1352
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Image, { source: { uri: shot.uri }, style: import_react_native2.StyleSheet.absoluteFill, resizeMode: "stretch" }),
|
|
810
1353
|
[...shapes.current, ...current ? [current] : []].map((shape, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Mark, { shape, scale, width: width * scale }, i))
|
|
811
1354
|
] })
|
|
812
1355
|
}
|
|
813
1356
|
),
|
|
814
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1357
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.View, { style: s.tools, children: [
|
|
815
1358
|
tools.map(([id, label, glyph]) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolButton, { label, glyph, on: tool === id, onPress: () => setTool(id) }, id)),
|
|
816
1359
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
817
1360
|
ToolButton,
|
|
@@ -844,12 +1387,12 @@ function Mark({ shape, scale, width }) {
|
|
|
844
1387
|
const ay = a2.y * scale;
|
|
845
1388
|
const len = Math.hypot(b2.x * scale - ax, b2.y * scale - ay);
|
|
846
1389
|
const angle = Math.atan2(b2.y * scale - ay, b2.x * scale - ax);
|
|
847
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1390
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: { position: "absolute", left: ax + (b2.x * scale - ax - len) / 2, top: ay + (b2.y * scale - ay) / 2 - width / 2, width: len, height: width, borderRadius: width / 2, backgroundColor: C.mark, transform: [{ rotate: `${angle}rad` }] } }, key);
|
|
848
1391
|
};
|
|
849
1392
|
const a = shape.points[0];
|
|
850
1393
|
const b = shape.points[shape.points.length - 1];
|
|
851
1394
|
if (shape.tool === "rect") {
|
|
852
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1395
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: { position: "absolute", left: Math.min(a.x, b.x) * scale, top: Math.min(a.y, b.y) * scale, width: Math.abs(b.x - a.x) * scale, height: Math.abs(b.y - a.y) * scale, borderWidth: width, borderColor: C.mark } });
|
|
853
1396
|
}
|
|
854
1397
|
if (shape.tool === "arrow") {
|
|
855
1398
|
const angle = Math.atan2(b.y - a.y, b.x - a.x);
|
|
@@ -860,20 +1403,20 @@ function Mark({ shape, scale, width }) {
|
|
|
860
1403
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: shape.points.slice(1).map((p, i) => line(shape.points[i], p, i)) });
|
|
861
1404
|
}
|
|
862
1405
|
function IconButton({ label, glyph, onPress }) {
|
|
863
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1406
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Pressable, { accessibilityRole: "button", accessibilityLabel: label, onPress, style: s.icon, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: s.iconText, children: glyph }) });
|
|
864
1407
|
}
|
|
865
1408
|
function ToolButton({ label, glyph, on, onPress }) {
|
|
866
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
867
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
868
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1409
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.Pressable, { accessibilityRole: "button", accessibilityLabel: label, accessibilityState: { selected: !!on }, onPress, style: [s.tool, on && { backgroundColor: C.brand }], children: [
|
|
1410
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: [s.toolGlyph, { color: on ? C.white : C.muted }], children: glyph }),
|
|
1411
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: [s.toolText, { color: on ? C.white : C.muted }], numberOfLines: 1, children: label })
|
|
869
1412
|
] });
|
|
870
1413
|
}
|
|
871
1414
|
function Details({ t, lang, shot, flat, shapes, notice, onBack, onDone }) {
|
|
872
|
-
const [title, setTitle] = (0,
|
|
873
|
-
const [message, setMessage] = (0,
|
|
874
|
-
const [email, setEmail] = (0,
|
|
875
|
-
const [status, setStatus] = (0,
|
|
876
|
-
const [busy, setBusy] = (0,
|
|
1415
|
+
const [title, setTitle] = (0, import_react2.useState)("");
|
|
1416
|
+
const [message, setMessage] = (0, import_react2.useState)("");
|
|
1417
|
+
const [email, setEmail] = (0, import_react2.useState)("");
|
|
1418
|
+
const [status, setStatus] = (0, import_react2.useState)(notice ? { text: notice, error: true } : { text: "", error: false });
|
|
1419
|
+
const [busy, setBusy] = (0, import_react2.useState)(false);
|
|
877
1420
|
const image = flat ?? shot;
|
|
878
1421
|
const submit = async () => {
|
|
879
1422
|
if (busy || !config) return;
|
|
@@ -894,8 +1437,8 @@ function Details({ t, lang, shot, flat, shapes, notice, onBack, onDone }) {
|
|
|
894
1437
|
uploaded = false;
|
|
895
1438
|
}
|
|
896
1439
|
}
|
|
897
|
-
const
|
|
898
|
-
setStatus({ text: uploaded ?
|
|
1440
|
+
const done2 = receipt.ref ? t("sentRef").replace("{ref}", receipt.ref) : t("sentTitle");
|
|
1441
|
+
setStatus({ text: uploaded ? done2 : `${done2} \xB7 ${t("noShot")}`, error: !uploaded });
|
|
899
1442
|
setTimeout(onDone, 1600);
|
|
900
1443
|
} catch {
|
|
901
1444
|
setStatus({ text: t("error"), error: true });
|
|
@@ -903,25 +1446,25 @@ function Details({ t, lang, shot, flat, shapes, notice, onBack, onDone }) {
|
|
|
903
1446
|
setBusy(false);
|
|
904
1447
|
}
|
|
905
1448
|
};
|
|
906
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1449
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.KeyboardAvoidingView, { style: { flex: 1 }, behavior: import_react_native2.Platform.OS === "ios" ? "padding" : void 0, children: [
|
|
907
1450
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Bar, { children: [
|
|
908
1451
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(BarButton, { label: t("mBack"), glyph: "\u2039", onPress: () => !busy && onBack() }),
|
|
909
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
910
|
-
busy ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1452
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: { flex: 1 } }),
|
|
1453
|
+
busy ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.ActivityIndicator, { color: C.white, style: { marginHorizontal: 10 } }) : null,
|
|
911
1454
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Primary, { label: t("send"), onPress: submit, disabled: busy })
|
|
912
1455
|
] }),
|
|
913
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
914
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
915
|
-
image ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
916
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
917
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
918
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
919
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1456
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.ScrollView, { contentContainerStyle: { padding: 20, paddingTop: 8, gap: 12 }, keyboardShouldPersistTaps: "handled", children: [
|
|
1457
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: s.h2, children: t("title") }),
|
|
1458
|
+
image ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Image, { source: { uri: image.uri }, style: s.preview, resizeMode: "contain", accessibilityIgnoresInvertColors: true }) : null,
|
|
1459
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.TextInput, { value: title, onChangeText: setTitle, placeholder: t("fTitle"), placeholderTextColor: C.muted, style: s.input, accessibilityLabel: t("fTitle") }),
|
|
1460
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.TextInput, { value: message, onChangeText: setMessage, placeholder: t("fDesc"), placeholderTextColor: C.muted, style: [s.input, { minHeight: 120, textAlignVertical: "top" }], multiline: true, accessibilityLabel: t("fDesc") }),
|
|
1461
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.TextInput, { value: email, onChangeText: setEmail, placeholder: t("email"), placeholderTextColor: C.muted, style: s.input, keyboardType: "email-address", autoCapitalize: "none", autoCorrect: false, accessibilityLabel: t("email") }),
|
|
1462
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { accessibilityLiveRegion: "polite", style: { color: status.error ? C.danger : C.muted, fontSize: 14 }, children: status.text })
|
|
920
1463
|
] })
|
|
921
1464
|
] });
|
|
922
1465
|
}
|
|
923
|
-
var s =
|
|
924
|
-
screen: { flex: 1, backgroundColor: C.navy, paddingTop:
|
|
1466
|
+
var s = import_react_native2.StyleSheet.create({
|
|
1467
|
+
screen: { flex: 1, backgroundColor: C.navy, paddingTop: import_react_native2.Platform.OS === "android" ? import_react_native2.StatusBar.currentHeight ?? 0 : 0 },
|
|
925
1468
|
pad: { flex: 1, paddingHorizontal: 20 },
|
|
926
1469
|
center: { flex: 1, justifyContent: "center", gap: 14 },
|
|
927
1470
|
h1: { color: C.white, fontSize: 24, fontWeight: "700", marginBottom: 8 },
|
|
@@ -951,30 +1494,14 @@ var s = import_react_native.StyleSheet.create({
|
|
|
951
1494
|
});
|
|
952
1495
|
|
|
953
1496
|
// src/index.ts
|
|
954
|
-
var
|
|
955
|
-
var DEFAULT_ENDPOINT = "https://in.blipit.io";
|
|
956
|
-
var VERSION = "0.3.0";
|
|
957
|
-
var PACKAGE = { name: "npm:@blipit/react-native", version: VERSION };
|
|
958
|
-
function withIdentity(user) {
|
|
959
|
-
return (event, hint) => {
|
|
960
|
-
try {
|
|
961
|
-
const sdk = event.sdk ??= {};
|
|
962
|
-
const packages = sdk.packages ?? [];
|
|
963
|
-
if (!packages.some((p) => p?.name === PACKAGE.name)) sdk.packages = [...packages, { ...PACKAGE }];
|
|
964
|
-
} catch {
|
|
965
|
-
}
|
|
966
|
-
return user ? user(event, hint) : event;
|
|
967
|
-
};
|
|
968
|
-
}
|
|
969
|
-
function dsn(key, project, endpoint = DEFAULT_ENDPOINT) {
|
|
970
|
-
const host = endpoint.split("://").pop().replace(/\/+$/, "");
|
|
971
|
-
const scheme = endpoint.startsWith("http://") ? "http" : "https";
|
|
972
|
-
return `${scheme}://${key}@${host}/${project}`;
|
|
973
|
-
}
|
|
1497
|
+
var SECURITY_KINDS = ["login_failed", "login_succeeded", "login_blocked", "password_reset_requested", "privilege_granted"];
|
|
974
1498
|
var MISSING_KEY = "[blipit] Blipit.init got no key, so Blipit is off and nothing is sent. Pass the project's public key (app.blipit.io, Keys); with Expo, check that EXPO_PUBLIC_BLIPIT_KEY is set at build time.";
|
|
975
1499
|
var MISSING_PROJECT = "[blipit] Blipit.init got no project id, so Blipit is off and nothing is sent. Pass project with the id from the project's Keys page at app.blipit.io.";
|
|
976
|
-
|
|
977
|
-
|
|
1500
|
+
var core;
|
|
1501
|
+
var session;
|
|
1502
|
+
var appState;
|
|
1503
|
+
function init(options) {
|
|
1504
|
+
const { key, publicKey, project, endpoint, waitForReady, ...rest } = options ?? {};
|
|
978
1505
|
const k = (key ?? publicKey ?? "").trim();
|
|
979
1506
|
if (!k) {
|
|
980
1507
|
console.warn(MISSING_KEY);
|
|
@@ -984,18 +1511,85 @@ function init2(options) {
|
|
|
984
1511
|
console.warn(MISSING_PROJECT);
|
|
985
1512
|
return false;
|
|
986
1513
|
}
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
1514
|
+
const info = nativeInfo();
|
|
1515
|
+
const release = rest.release ?? defaultRelease(info);
|
|
1516
|
+
const base = endpoint ?? DEFAULT_ENDPOINT;
|
|
1517
|
+
session?.end();
|
|
1518
|
+
appState?.remove();
|
|
1519
|
+
core = new Nuggets({ ...rest, key: k, endpoint: base, release, store: nativeStore(), contexts: () => contexts(info.model, info.osVersion) });
|
|
1520
|
+
const c = core;
|
|
1521
|
+
setBoundaryReporter((error) => c.captureException(error, false));
|
|
1522
|
+
instrument(() => core);
|
|
1523
|
+
const native = rest.enableNative !== false ? bridge() : void 0;
|
|
1524
|
+
try {
|
|
1525
|
+
native?.start(k, String(project), rest.environment ?? null, release ?? null, c.endpoint);
|
|
1526
|
+
} catch {
|
|
1527
|
+
}
|
|
1528
|
+
session = release && rest.autoSessionTracking !== false ? new Session(c, release, rest.environment ?? "production") : void 0;
|
|
1529
|
+
c.onError = (unhandled) => session?.markError(unhandled);
|
|
1530
|
+
if (c.enabled) session?.start();
|
|
1531
|
+
appState = import_react_native3.AppState?.addEventListener?.("change", (state) => {
|
|
1532
|
+
if (state === "active") {
|
|
1533
|
+
if (c.enabled) session?.start();
|
|
1534
|
+
void c.flush();
|
|
1535
|
+
} else if (state === "background") {
|
|
1536
|
+
session?.end();
|
|
1537
|
+
void c.flush();
|
|
1538
|
+
}
|
|
993
1539
|
});
|
|
994
|
-
|
|
1540
|
+
void c.flush();
|
|
1541
|
+
const reports = new ReportClient(base, k);
|
|
1542
|
+
configureReporter(reports, () => deviceContext(release));
|
|
1543
|
+
reportClient = reports;
|
|
1544
|
+
if (!stuck) {
|
|
1545
|
+
stuck = createStuck(
|
|
1546
|
+
{
|
|
1547
|
+
settings: () => reportClient ? reportClient.settings() : Promise.resolve(null),
|
|
1548
|
+
event: async (body) => (core?.enqueue(body), true)
|
|
1549
|
+
},
|
|
1550
|
+
{ release, environment: rest.environment, os: import_react_native3.Platform.OS, osVersion: info.osVersion ?? String(import_react_native3.Platform.Version), version: VERSION }
|
|
1551
|
+
);
|
|
1552
|
+
try {
|
|
1553
|
+
stuck.setForeground(import_react_native3.AppState.currentState !== "background");
|
|
1554
|
+
import_react_native3.AppState.addEventListener("change", (state) => stuck?.setForeground(state !== "background"));
|
|
1555
|
+
} catch {
|
|
1556
|
+
stuck.setForeground(true);
|
|
1557
|
+
}
|
|
1558
|
+
if (waitForReady) stuck.start(STARTUP);
|
|
1559
|
+
}
|
|
1560
|
+
if (rest.debug) console.log(`[blipit] ${SDK_NAME}@${VERSION} initialized`);
|
|
995
1561
|
return true;
|
|
996
1562
|
}
|
|
1563
|
+
var stuck = null;
|
|
1564
|
+
var reportClient;
|
|
1565
|
+
function reportReady() {
|
|
1566
|
+
stuck?.end(STARTUP);
|
|
1567
|
+
}
|
|
1568
|
+
function startFlow(name) {
|
|
1569
|
+
const flow = cleanName(name, 64);
|
|
1570
|
+
if (flow) stuck?.start(flow);
|
|
1571
|
+
}
|
|
1572
|
+
function flowStep(name, step) {
|
|
1573
|
+
const flow = cleanName(name, 64);
|
|
1574
|
+
const s2 = cleanName(step, 128);
|
|
1575
|
+
if (flow && s2) stuck?.step(flow, s2);
|
|
1576
|
+
}
|
|
1577
|
+
function endFlow(name) {
|
|
1578
|
+
const flow = cleanName(name, 64);
|
|
1579
|
+
if (flow) stuck?.end(flow);
|
|
1580
|
+
}
|
|
1581
|
+
function contexts(model, osVersion) {
|
|
1582
|
+
const { width, height } = import_react_native3.Dimensions.get("window");
|
|
1583
|
+
const engine = globalThis.HermesInternal ? "hermes" : "jsc";
|
|
1584
|
+
const rn = import_react_native3.Platform.constants?.reactNativeVersion;
|
|
1585
|
+
return {
|
|
1586
|
+
os: { name: import_react_native3.Platform.OS, version: osVersion ?? String(import_react_native3.Platform.Version) },
|
|
1587
|
+
device: { ...model ? { model } : {}, screen: `${Math.round(width)}x${Math.round(height)}` },
|
|
1588
|
+
runtime: { name: engine, ...rn ? { version: `react-native ${rn.major}.${rn.minor}.${rn.patch}` } : {} }
|
|
1589
|
+
};
|
|
1590
|
+
}
|
|
997
1591
|
function deviceContext(release) {
|
|
998
|
-
const { width, height, scale } =
|
|
1592
|
+
const { width, height, scale } = import_react_native3.Dimensions.get("window");
|
|
999
1593
|
let language = "";
|
|
1000
1594
|
let timezone = "";
|
|
1001
1595
|
try {
|
|
@@ -1006,11 +1600,17 @@ function deviceContext(release) {
|
|
|
1006
1600
|
}
|
|
1007
1601
|
return {
|
|
1008
1602
|
platform: "react-native",
|
|
1009
|
-
sdk: { name:
|
|
1603
|
+
sdk: { name: `npm:${SDK_NAME}`, version: VERSION },
|
|
1010
1604
|
...release ? { app: { release } } : {},
|
|
1011
|
-
device: { os:
|
|
1605
|
+
device: { os: import_react_native3.Platform.OS, os_version: String(import_react_native3.Platform.Version), screen: `${Math.round(width)}x${Math.round(height)}`, dpr: scale, language, timezone, touch: true }
|
|
1012
1606
|
};
|
|
1013
1607
|
}
|
|
1608
|
+
function captureException(error) {
|
|
1609
|
+
return core?.captureException(error, true);
|
|
1610
|
+
}
|
|
1611
|
+
function captureMessage(message, level = "info") {
|
|
1612
|
+
return core?.captureMessage(message, level);
|
|
1613
|
+
}
|
|
1014
1614
|
function captureSecurity(kind, actor, details = {}) {
|
|
1015
1615
|
const context = { kind, actor };
|
|
1016
1616
|
const extra = { outcome: details.outcome, actor_id: details.actorId, ip: details.ip, user_agent: details.userAgent, target: details.target };
|
|
@@ -1018,27 +1618,81 @@ function captureSecurity(kind, actor, details = {}) {
|
|
|
1018
1618
|
if (v !== void 0 && v !== null) context[k] = v;
|
|
1019
1619
|
}
|
|
1020
1620
|
const level = kind === "login_failed" || kind === "login_blocked" ? "warning" : "info";
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1621
|
+
return core?.captureSecurity(kind, `${kind} for ${actor}`, level, SECURITY_KINDS.includes(kind) && actor ? context : void 0);
|
|
1622
|
+
}
|
|
1623
|
+
function setUser(user) {
|
|
1624
|
+
core?.setUser(user);
|
|
1625
|
+
const u = core?.user;
|
|
1626
|
+
try {
|
|
1627
|
+
bridge()?.setUser(u?.id ?? null, u?.email ?? null, u?.username ?? null);
|
|
1628
|
+
} catch {
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
function setTag(key, value) {
|
|
1632
|
+
core?.setTag(key, value);
|
|
1633
|
+
try {
|
|
1634
|
+
bridge()?.setTag(key, String(value));
|
|
1635
|
+
} catch {
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
function addBreadcrumb(crumb) {
|
|
1639
|
+
core?.addBreadcrumb(crumb);
|
|
1640
|
+
}
|
|
1641
|
+
async function flush(timeout = 2e3) {
|
|
1642
|
+
if (!core) return true;
|
|
1643
|
+
const c = core;
|
|
1644
|
+
let timer;
|
|
1645
|
+
const late = new Promise((r) => timer = setTimeout(() => r(false), timeout));
|
|
1646
|
+
const ok = await Promise.race([c.flush().then(() => c.pending === 0), late]);
|
|
1647
|
+
clearTimeout(timer);
|
|
1648
|
+
return ok;
|
|
1649
|
+
}
|
|
1650
|
+
function setEnabled(on) {
|
|
1651
|
+
if (!core) return;
|
|
1652
|
+
core.setEnabled(on);
|
|
1653
|
+
if (on) session?.start();
|
|
1654
|
+
else session?.end();
|
|
1655
|
+
}
|
|
1656
|
+
var isEnabled = () => core?.enabled ?? false;
|
|
1657
|
+
var lastEventId = () => core?.lastEventId;
|
|
1658
|
+
function setReplayConsent(granted) {
|
|
1659
|
+
try {
|
|
1660
|
+
bridge()?.setReplayConsent(granted);
|
|
1661
|
+
} catch {
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
function hasReplayConsent() {
|
|
1665
|
+
try {
|
|
1666
|
+
return bridge()?.hasReplayConsent() === true;
|
|
1667
|
+
} catch {
|
|
1668
|
+
return false;
|
|
1669
|
+
}
|
|
1026
1670
|
}
|
|
1671
|
+
var trackNavigation2 = (ref) => trackNavigation(() => core, ref);
|
|
1027
1672
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1028
1673
|
0 && (module.exports = {
|
|
1029
1674
|
BlipitReporter,
|
|
1030
1675
|
DEFAULT_ENDPOINT,
|
|
1676
|
+
ErrorBoundary,
|
|
1031
1677
|
VERSION,
|
|
1032
1678
|
addBreadcrumb,
|
|
1033
1679
|
captureException,
|
|
1034
1680
|
captureMessage,
|
|
1035
1681
|
captureSecurity,
|
|
1036
|
-
|
|
1682
|
+
endFlow,
|
|
1683
|
+
flowStep,
|
|
1037
1684
|
flush,
|
|
1685
|
+
hasReplayConsent,
|
|
1038
1686
|
init,
|
|
1687
|
+
isEnabled,
|
|
1688
|
+
lastEventId,
|
|
1689
|
+
reportReady,
|
|
1690
|
+
setEnabled,
|
|
1691
|
+
setReplayConsent,
|
|
1039
1692
|
setTag,
|
|
1040
1693
|
setUser,
|
|
1041
1694
|
showReport,
|
|
1042
|
-
|
|
1695
|
+
startFlow,
|
|
1696
|
+
trackNavigation,
|
|
1043
1697
|
wrap
|
|
1044
1698
|
});
|