@blipit/react-native 0.4.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/BlipitReactNative.podspec +23 -0
- package/CHANGELOG.md +22 -12
- package/README.md +128 -11
- package/android/build.gradle +32 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/io/blipit/reactnative/BlipitNuggetsModule.kt +114 -0
- package/android/src/main/java/io/blipit/reactnative/BlipitNuggetsPackage.kt +12 -0
- package/dist/index.cjs +955 -164
- package/dist/index.d.cts +137 -11
- package/dist/index.d.ts +137 -11
- package/dist/index.js +871 -74
- package/ios/BlipitNuggets.m +15 -0
- package/ios/BlipitNuggets.swift +96 -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,27 +22,529 @@ 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
|
-
dsn: () => dsn,
|
|
41
31
|
endFlow: () => endFlow,
|
|
42
32
|
flowStep: () => flowStep,
|
|
43
|
-
flush: () =>
|
|
44
|
-
|
|
33
|
+
flush: () => flush,
|
|
34
|
+
hasReplayConsent: () => hasReplayConsent,
|
|
35
|
+
init: () => init,
|
|
36
|
+
isEnabled: () => isEnabled,
|
|
37
|
+
lastEventId: () => lastEventId,
|
|
45
38
|
reportReady: () => reportReady,
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
setEnabled: () => setEnabled,
|
|
40
|
+
setReplayConsent: () => setReplayConsent,
|
|
41
|
+
setTag: () => setTag,
|
|
42
|
+
setUser: () => setUser,
|
|
48
43
|
showReport: () => showReport,
|
|
49
44
|
startFlow: () => startFlow,
|
|
50
|
-
|
|
51
|
-
wrap: () =>
|
|
45
|
+
trackNavigation: () => trackNavigation2,
|
|
46
|
+
wrap: () => wrap
|
|
52
47
|
});
|
|
53
48
|
module.exports = __toCommonJS(index_exports);
|
|
54
|
-
var
|
|
55
|
-
|
|
49
|
+
var import_react_native3 = require("react-native");
|
|
50
|
+
|
|
51
|
+
// src/mismatch.ts
|
|
52
|
+
var blocked = false;
|
|
53
|
+
async function checkPlatformMismatch(res) {
|
|
54
|
+
if (res.status !== 409) return false;
|
|
55
|
+
let body = null;
|
|
56
|
+
try {
|
|
57
|
+
body = JSON.parse(await (typeof res.clone === "function" ? res.clone() : res).text());
|
|
58
|
+
} catch {
|
|
59
|
+
}
|
|
60
|
+
if (body?.reason !== "platform_mismatch") return false;
|
|
61
|
+
if (!blocked) {
|
|
62
|
+
blocked = true;
|
|
63
|
+
const message = typeof body.error === "string" ? body.error : "This key belongs to a Blipit project for another platform.";
|
|
64
|
+
console.error(`[blipit] BLIPIT IS NOT SENDING: ${message} Nothing more is sent with this key until the app restarts.`);
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
function guardPlatform(fetcher) {
|
|
69
|
+
return (async (...args) => {
|
|
70
|
+
if (blocked) return new Response(null, { status: 409 });
|
|
71
|
+
const res = await fetcher(...args);
|
|
72
|
+
await checkPlatformMismatch(res);
|
|
73
|
+
return res;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// src/triggers.ts
|
|
78
|
+
var TRIGGERS = ["shake", "screenshot", "two_finger", "crash"];
|
|
79
|
+
var PICKER_MAX = 3;
|
|
80
|
+
var PICKER_SIDE = 480;
|
|
81
|
+
var PICKER_SETTLE_MS = 700;
|
|
82
|
+
var PICKER_IDLE_MS = 18e4;
|
|
83
|
+
var isTrigger = (v) => typeof v === "string" && TRIGGERS.includes(v);
|
|
84
|
+
function createDebounce(gapMs = 1500, now = Date.now) {
|
|
85
|
+
let last = -Infinity;
|
|
86
|
+
return {
|
|
87
|
+
allow(open2) {
|
|
88
|
+
const t = now();
|
|
89
|
+
if (open2 || t - last < gapMs) return false;
|
|
90
|
+
last = t;
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
var parseReportButton = (json2) => !!json2 && typeof json2 === "object" && json2.report_button === true;
|
|
96
|
+
function userHeaders(user) {
|
|
97
|
+
const out = {};
|
|
98
|
+
if (user?.id) out["X-Blipit-User-Id"] = user.id;
|
|
99
|
+
if (user?.email) out["X-Blipit-User-Email"] = user.email;
|
|
100
|
+
return out;
|
|
101
|
+
}
|
|
102
|
+
function pickerSize(width, height, side = PICKER_SIDE) {
|
|
103
|
+
const scale = Math.min(1, side / Math.max(width, height, 1));
|
|
104
|
+
return { width: Math.max(1, Math.round(width * scale)), height: Math.max(1, Math.round(height * scale)) };
|
|
105
|
+
}
|
|
106
|
+
var ScreenShots = class {
|
|
107
|
+
items = [];
|
|
108
|
+
hiddenAt = 0;
|
|
109
|
+
add(shot) {
|
|
110
|
+
this.items = [shot, ...this.items.filter((s2) => s2.name !== shot.name)].slice(0, PICKER_MAX);
|
|
111
|
+
}
|
|
112
|
+
list(except) {
|
|
113
|
+
return this.items.filter((s2) => s2.name !== except);
|
|
114
|
+
}
|
|
115
|
+
clear() {
|
|
116
|
+
this.items = [];
|
|
117
|
+
}
|
|
118
|
+
background(at) {
|
|
119
|
+
this.hiddenAt = at;
|
|
120
|
+
}
|
|
121
|
+
foreground(at) {
|
|
122
|
+
if (this.hiddenAt && at - this.hiddenAt >= PICKER_IDLE_MS) this.clear();
|
|
123
|
+
this.hiddenAt = 0;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
function lastFatal(queue) {
|
|
127
|
+
for (let i = queue.length - 1; i >= 0; i--) {
|
|
128
|
+
const e = queue[i];
|
|
129
|
+
if (e?.level === "fatal" && e.exception?.handled === false && typeof e.event_id === "string" && /^[0-9a-f]{32}$/.test(e.event_id)) return e.event_id;
|
|
130
|
+
}
|
|
131
|
+
return void 0;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// src/nuggets.ts
|
|
135
|
+
var VERSION = "0.6.0";
|
|
136
|
+
var SDK_NAME = "@blipit/react-native";
|
|
137
|
+
var DEFAULT_ENDPOINT = "https://in.blipit.io";
|
|
138
|
+
var CATEGORIES = /* @__PURE__ */ new Set(["ui.click", "ui.input", "navigation", "http", "console", "query", "custom"]);
|
|
139
|
+
var CRUMB_LEVELS = /* @__PURE__ */ new Set(["error", "warning", "info", "debug"]);
|
|
140
|
+
var TAG_KEY = /[^a-zA-Z0-9_.-]/g;
|
|
141
|
+
var SENSITIVE = /\b((?:[a-zA-Z0-9_-]*(?:token|key|password|secret|auth|session|passwd|api)[a-zA-Z0-9_-]*)=)[^&\s"']+/gi;
|
|
142
|
+
var QUEUE_MAX = 30;
|
|
143
|
+
var truncate = (v, max) => v.length > max ? v.slice(0, max) : v;
|
|
144
|
+
var scrub = (text2) => text2.replace(SENSITIVE, "$1[redacted]");
|
|
145
|
+
function uuid32() {
|
|
146
|
+
let out = "";
|
|
147
|
+
for (let i = 0; i < 32; i++) out += Math.floor(Math.random() * 16).toString(16);
|
|
148
|
+
return `${out.slice(0, 12)}4${out.slice(13, 16)}${"89ab"[Math.floor(Math.random() * 4)]}${out.slice(17)}`;
|
|
149
|
+
}
|
|
150
|
+
var HERMES = /^\s*at (?:(.+?) \()?(?:address at )?(.+?):(\d+):(\d+)\)?\s*$/;
|
|
151
|
+
var JSC = /^\s*(?:(.*?)@)?(.+?):(\d+):(\d+)\s*$/;
|
|
152
|
+
function parseStack(stack) {
|
|
153
|
+
if (!stack) return [];
|
|
154
|
+
const frames = [];
|
|
155
|
+
for (const line of stack.split("\n")) {
|
|
156
|
+
const m = HERMES.exec(line) ?? (/^\s*at /.test(line) ? null : JSC.exec(line));
|
|
157
|
+
if (!m) continue;
|
|
158
|
+
const file = m[2].replace(/\?.*$/, "");
|
|
159
|
+
const frame = { filename: truncate(file, 1024), lineno: Number(m[3]), colno: Number(m[4]), in_app: !/node_modules|\[native code\]/.test(file) };
|
|
160
|
+
if (m[1]) frame.function = truncate(m[1], 512);
|
|
161
|
+
frames.push(frame);
|
|
162
|
+
}
|
|
163
|
+
return frames.reverse().slice(-128);
|
|
164
|
+
}
|
|
165
|
+
function cleanCrumb(c, at) {
|
|
166
|
+
const ts = typeof c.timestamp === "number" ? new Date(c.timestamp < 1e12 ? c.timestamp * 1e3 : c.timestamp).toISOString() : c.timestamp ?? at;
|
|
167
|
+
const out = { timestamp: ts, category: c.category && CATEGORIES.has(c.category) ? c.category : "custom" };
|
|
168
|
+
if (c.message) out.message = truncate(scrub(String(c.message)), 1024);
|
|
169
|
+
if (c.level && CRUMB_LEVELS.has(c.level)) out.level = c.level;
|
|
170
|
+
if (c.data && typeof c.data === "object") out.data = typeof c.data.url === "string" ? { ...c.data, url: scrub(c.data.url) } : c.data;
|
|
171
|
+
return out;
|
|
172
|
+
}
|
|
173
|
+
var Nuggets = class {
|
|
174
|
+
endpoint;
|
|
175
|
+
key;
|
|
176
|
+
user;
|
|
177
|
+
tags = {};
|
|
178
|
+
lastEventId;
|
|
179
|
+
crashId;
|
|
180
|
+
enabled;
|
|
181
|
+
onError;
|
|
182
|
+
crumbs = [];
|
|
183
|
+
queue = [];
|
|
184
|
+
captured = /* @__PURE__ */ new WeakSet();
|
|
185
|
+
timer;
|
|
186
|
+
sending;
|
|
187
|
+
pausedUntil = 0;
|
|
188
|
+
fetcher;
|
|
189
|
+
now;
|
|
190
|
+
options;
|
|
191
|
+
constructor(options) {
|
|
192
|
+
this.options = options;
|
|
193
|
+
this.endpoint = (options.endpoint ?? DEFAULT_ENDPOINT).replace(/\/api\/v1\/events.*$/, "").replace(/\/+$/, "");
|
|
194
|
+
this.key = options.key;
|
|
195
|
+
this.enabled = options.enabled !== false;
|
|
196
|
+
this.fetcher = guardPlatform(options.fetch ?? ((...a) => fetch(...a)));
|
|
197
|
+
this.now = options.now ?? Date.now;
|
|
198
|
+
try {
|
|
199
|
+
const saved = JSON.parse(options.store?.load() ?? "[]");
|
|
200
|
+
if (Array.isArray(saved)) this.queue = saved.slice(-QUEUE_MAX);
|
|
201
|
+
} catch {
|
|
202
|
+
}
|
|
203
|
+
this.crashId = lastFatal(this.queue);
|
|
204
|
+
}
|
|
205
|
+
get pending() {
|
|
206
|
+
return this.queue.length;
|
|
207
|
+
}
|
|
208
|
+
url(path) {
|
|
209
|
+
return `${this.endpoint}${path}`;
|
|
210
|
+
}
|
|
211
|
+
setEnabled(on) {
|
|
212
|
+
this.enabled = on;
|
|
213
|
+
if (!on) {
|
|
214
|
+
this.queue = [];
|
|
215
|
+
this.crumbs = [];
|
|
216
|
+
this.persist();
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
setUser(user) {
|
|
220
|
+
if (!user) return void (this.user = void 0);
|
|
221
|
+
const u = {};
|
|
222
|
+
if (user.id !== void 0 && user.id !== null) u.id = truncate(String(user.id), 128);
|
|
223
|
+
if (user.email) u.email = truncate(user.email, 256);
|
|
224
|
+
if (user.username) u.username = truncate(user.username, 128);
|
|
225
|
+
this.user = Object.keys(u).length ? u : void 0;
|
|
226
|
+
}
|
|
227
|
+
setTag(key, value) {
|
|
228
|
+
const k = truncate(String(key).replace(TAG_KEY, "_"), 64);
|
|
229
|
+
if (k && (k in this.tags || Object.keys(this.tags).length < 32)) this.tags[k] = truncate(String(value), 256);
|
|
230
|
+
}
|
|
231
|
+
addBreadcrumb(crumb) {
|
|
232
|
+
if (!this.enabled) return;
|
|
233
|
+
this.crumbs.push(cleanCrumb(crumb, new Date(this.now()).toISOString()));
|
|
234
|
+
const max = Math.min(this.options.maxBreadcrumbs ?? 50, 100);
|
|
235
|
+
while (this.crumbs.length > max) this.crumbs.shift();
|
|
236
|
+
}
|
|
237
|
+
captureException(error, handled = true, level = "error") {
|
|
238
|
+
if (error && typeof error === "object") {
|
|
239
|
+
if (this.captured.has(error)) return void 0;
|
|
240
|
+
this.captured.add(error);
|
|
241
|
+
}
|
|
242
|
+
const err = error instanceof Error ? error : new Error(typeof error === "string" ? error : safeJson(error));
|
|
243
|
+
const exception = { type: truncate(err.name || "Error", 256), value: truncate(scrub(err.message || String(err)), 4096), handled };
|
|
244
|
+
const frames = parseStack(err.stack);
|
|
245
|
+
if (frames.length) exception.stacktrace = { frames };
|
|
246
|
+
return this.capture({ exception, level });
|
|
247
|
+
}
|
|
248
|
+
captureMessage(message, level = "info") {
|
|
249
|
+
return this.capture({ message: truncate(scrub(String(message)), 8192), level });
|
|
250
|
+
}
|
|
251
|
+
captureSecurity(kind, message, level, security) {
|
|
252
|
+
return this.capture({ message: truncate(message, 8192), level, ...security ? { security } : {}, tags: { "security.kind": truncate(kind, 256) } }, false);
|
|
253
|
+
}
|
|
254
|
+
capture(partial, filter = true) {
|
|
255
|
+
if (!this.enabled) return void 0;
|
|
256
|
+
if (filter && this.options.sampleRate !== void 0 && Math.random() >= this.options.sampleRate) return void 0;
|
|
257
|
+
const text2 = partial.exception?.value ?? partial.message ?? "";
|
|
258
|
+
if (filter && (this.options.ignoreErrors ?? []).some((p) => typeof p === "string" ? text2.includes(p) : p.test(text2))) return void 0;
|
|
259
|
+
let event = {
|
|
260
|
+
event_id: uuid32(),
|
|
261
|
+
timestamp: new Date(this.now()).toISOString(),
|
|
262
|
+
platform: "react-native",
|
|
263
|
+
level: "error",
|
|
264
|
+
environment: this.options.environment ?? "production",
|
|
265
|
+
sdk: { name: SDK_NAME, version: VERSION },
|
|
266
|
+
...partial
|
|
267
|
+
};
|
|
268
|
+
if (this.options.release) event.release = truncate(this.options.release, 256);
|
|
269
|
+
if (this.user) event.user = { ...this.user };
|
|
270
|
+
const tags = { ...this.tags, ...partial.tags };
|
|
271
|
+
if (Object.keys(tags).length) event.tags = tags;
|
|
272
|
+
if (this.crumbs.length) event.breadcrumbs = [...this.crumbs];
|
|
273
|
+
const contexts2 = this.options.contexts?.();
|
|
274
|
+
if (contexts2 && Object.keys(contexts2).length) event.contexts = contexts2;
|
|
275
|
+
if (this.options.beforeSend) {
|
|
276
|
+
const out = this.options.beforeSend(event);
|
|
277
|
+
if (!out) return void 0;
|
|
278
|
+
event = out;
|
|
279
|
+
}
|
|
280
|
+
this.enqueue(event);
|
|
281
|
+
this.lastEventId = event.event_id;
|
|
282
|
+
if (event.exception) this.onError?.(!event.exception.handled);
|
|
283
|
+
return event.event_id;
|
|
284
|
+
}
|
|
285
|
+
enqueue(event) {
|
|
286
|
+
if (!this.enabled) return false;
|
|
287
|
+
this.queue.push(event);
|
|
288
|
+
while (this.queue.length > QUEUE_MAX) this.queue.shift();
|
|
289
|
+
this.persist();
|
|
290
|
+
this.schedule(1e3);
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
persist() {
|
|
294
|
+
try {
|
|
295
|
+
this.options.store?.save(JSON.stringify(this.queue));
|
|
296
|
+
} catch {
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
schedule(ms) {
|
|
300
|
+
if (this.timer) return;
|
|
301
|
+
this.timer = setTimeout(() => {
|
|
302
|
+
this.timer = void 0;
|
|
303
|
+
void this.flush();
|
|
304
|
+
}, Math.max(ms, this.pausedUntil - this.now()));
|
|
305
|
+
this.timer.unref?.();
|
|
306
|
+
}
|
|
307
|
+
async flush() {
|
|
308
|
+
while (this.sending) await this.sending;
|
|
309
|
+
this.sending = this.drain().finally(() => this.sending = void 0);
|
|
310
|
+
return this.sending;
|
|
311
|
+
}
|
|
312
|
+
async drain() {
|
|
313
|
+
while (this.queue.length && this.enabled && this.now() >= this.pausedUntil) {
|
|
314
|
+
const event = this.queue[0];
|
|
315
|
+
const verdict = await this.send(event);
|
|
316
|
+
if (verdict === "retry") return this.schedule(3e4);
|
|
317
|
+
if (verdict === "wait") return this.schedule(0);
|
|
318
|
+
if (this.queue[0] === event) this.queue.shift();
|
|
319
|
+
this.persist();
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
post(path, body) {
|
|
323
|
+
return this.fetcher(this.url(path), { method: "POST", headers: { "Content-Type": "application/json", "X-Blipit-Key": this.key }, body: JSON.stringify(body) });
|
|
324
|
+
}
|
|
325
|
+
async send(event) {
|
|
326
|
+
try {
|
|
327
|
+
const res = await this.post("/api/v1/events", event);
|
|
328
|
+
if (res.status === 429) {
|
|
329
|
+
const header = Number(res.headers?.get?.("retry-after"));
|
|
330
|
+
let seconds = Number.isFinite(header) && header > 0 ? header : 0;
|
|
331
|
+
if (!seconds) {
|
|
332
|
+
try {
|
|
333
|
+
seconds = Number(JSON.parse(await res.text()).retry_after) || 60;
|
|
334
|
+
} catch {
|
|
335
|
+
seconds = 60;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
this.pausedUntil = this.now() + Math.min(seconds, 3600) * 1e3;
|
|
339
|
+
return "wait";
|
|
340
|
+
}
|
|
341
|
+
if (res.status >= 500) return "retry";
|
|
342
|
+
if (res.status >= 400 && this.options.debug) console.warn("[blipit] event rejected", res.status);
|
|
343
|
+
return "done";
|
|
344
|
+
} catch {
|
|
345
|
+
return "retry";
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
var RANK = { ok: 0, errored: 1, crashed: 2 };
|
|
350
|
+
var Session = class {
|
|
351
|
+
sid = "";
|
|
352
|
+
started = "";
|
|
353
|
+
status = "ok";
|
|
354
|
+
errors = 0;
|
|
355
|
+
core;
|
|
356
|
+
release;
|
|
357
|
+
environment;
|
|
358
|
+
constructor(core2, release, environment) {
|
|
359
|
+
this.core = core2;
|
|
360
|
+
this.release = release;
|
|
361
|
+
this.environment = environment;
|
|
362
|
+
}
|
|
363
|
+
start() {
|
|
364
|
+
if (this.sid) return;
|
|
365
|
+
this.sid = uuid32();
|
|
366
|
+
this.started = (/* @__PURE__ */ new Date()).toISOString();
|
|
367
|
+
this.status = "ok";
|
|
368
|
+
this.errors = 0;
|
|
369
|
+
this.send(false);
|
|
370
|
+
}
|
|
371
|
+
end() {
|
|
372
|
+
if (!this.sid) return;
|
|
373
|
+
this.send(true);
|
|
374
|
+
this.sid = "";
|
|
375
|
+
}
|
|
376
|
+
markError(unhandled) {
|
|
377
|
+
if (!this.sid) return;
|
|
378
|
+
this.errors += 1;
|
|
379
|
+
const next = unhandled ? "crashed" : "errored";
|
|
380
|
+
if (RANK[next] <= RANK[this.status]) return;
|
|
381
|
+
this.status = next;
|
|
382
|
+
this.send(false);
|
|
383
|
+
}
|
|
384
|
+
send(ending) {
|
|
385
|
+
if (!this.core.enabled) return;
|
|
386
|
+
const did = this.core.user?.id ?? this.core.user?.email;
|
|
387
|
+
const status = this.status === "ok" && ending ? "exited" : this.status;
|
|
388
|
+
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);
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
function safeJson(v) {
|
|
392
|
+
try {
|
|
393
|
+
return JSON.stringify(v) ?? String(v);
|
|
394
|
+
} catch {
|
|
395
|
+
return String(v);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// src/instrument.ts
|
|
400
|
+
var done = /* @__PURE__ */ new WeakSet();
|
|
401
|
+
function instrument(core2, g = globalThis) {
|
|
402
|
+
if (done.has(g)) return;
|
|
403
|
+
done.add(g);
|
|
404
|
+
const eu = g.ErrorUtils;
|
|
405
|
+
if (eu?.setGlobalHandler) {
|
|
406
|
+
const prev = eu.getGlobalHandler?.();
|
|
407
|
+
eu.setGlobalHandler((error, isFatal) => {
|
|
408
|
+
const c = core2();
|
|
409
|
+
c?.captureException(error, false, isFatal ? "fatal" : "error");
|
|
410
|
+
if (isFatal) void c?.flush();
|
|
411
|
+
prev?.(error, isFatal);
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
const onUnhandled = (_id, reason) => void core2()?.captureException(reason, false);
|
|
415
|
+
if (g.HermesInternal?.enablePromiseRejectionTracker) {
|
|
416
|
+
g.HermesInternal.enablePromiseRejectionTracker({ allRejections: true, onUnhandled });
|
|
417
|
+
} else {
|
|
418
|
+
try {
|
|
419
|
+
require("promise/setimmediate/rejection-tracking").enable({ allRejections: true, onUnhandled });
|
|
420
|
+
} catch {
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
for (const level of ["warn", "error"]) {
|
|
424
|
+
const original = g.console[level];
|
|
425
|
+
if (typeof original !== "function") continue;
|
|
426
|
+
g.console[level] = (...args) => {
|
|
427
|
+
const message = truncate(args.map((a) => typeof a === "string" ? a : a instanceof Error ? a.message : json(a)).join(" "), 1024);
|
|
428
|
+
if (!message.startsWith("[blipit]")) core2()?.addBreadcrumb({ category: "console", level: level === "warn" ? "warning" : "error", message });
|
|
429
|
+
original.apply(g.console, args);
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
const proto = g.XMLHttpRequest?.prototype;
|
|
433
|
+
if (proto?.open && proto.send) {
|
|
434
|
+
const open2 = proto.open;
|
|
435
|
+
const send = proto.send;
|
|
436
|
+
proto.open = function(method, url, ...rest) {
|
|
437
|
+
this._blipit = [String(method).toUpperCase(), String(url)];
|
|
438
|
+
return open2.call(this, method, url, ...rest);
|
|
439
|
+
};
|
|
440
|
+
proto.send = function(...args) {
|
|
441
|
+
const meta = this._blipit;
|
|
442
|
+
const c = core2();
|
|
443
|
+
if (c && meta && !meta[1].startsWith(c.endpoint)) {
|
|
444
|
+
const start = Date.now();
|
|
445
|
+
this.addEventListener?.("loadend", () => {
|
|
446
|
+
const status = this.status;
|
|
447
|
+
const url = meta[1].replace(/[?#].*$/, "");
|
|
448
|
+
c.addBreadcrumb({
|
|
449
|
+
category: "http",
|
|
450
|
+
level: !status || status >= 400 ? "error" : "info",
|
|
451
|
+
message: `${meta[0]} ${url} -> ${status || "network error"}`,
|
|
452
|
+
data: { url, method: meta[0], status_code: status || void 0, duration_ms: Date.now() - start }
|
|
453
|
+
});
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
return send.apply(this, args);
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
function trackNavigation(core2, ref) {
|
|
461
|
+
let last;
|
|
462
|
+
const seen = () => {
|
|
463
|
+
const name = ref.getCurrentRoute()?.name;
|
|
464
|
+
if (!name || name === last) return;
|
|
465
|
+
core2()?.addBreadcrumb({ category: "navigation", message: `Navigated to ${name}`, data: { from: last, to: name } });
|
|
466
|
+
last = name;
|
|
467
|
+
};
|
|
468
|
+
seen();
|
|
469
|
+
return ref.addListener("state", seen);
|
|
470
|
+
}
|
|
471
|
+
function json(v) {
|
|
472
|
+
try {
|
|
473
|
+
return JSON.stringify(v) ?? String(v);
|
|
474
|
+
} catch {
|
|
475
|
+
return String(v);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// src/native.ts
|
|
480
|
+
var import_react_native = require("react-native");
|
|
481
|
+
function onNativeTrigger(handle) {
|
|
482
|
+
const b = bridge();
|
|
483
|
+
if (!b) return void 0;
|
|
484
|
+
try {
|
|
485
|
+
const sub = new import_react_native.NativeEventEmitter(b).addListener("BlipitReportTrigger", (e) => handle(e?.trigger, e?.crashId));
|
|
486
|
+
return () => sub.remove();
|
|
487
|
+
} catch {
|
|
488
|
+
return void 0;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
var bridge = () => import_react_native.NativeModules.BlipitNuggets;
|
|
492
|
+
function nativeInfo() {
|
|
493
|
+
const b = bridge();
|
|
494
|
+
try {
|
|
495
|
+
return b?.getConstants?.() ?? b ?? {};
|
|
496
|
+
} catch {
|
|
497
|
+
return {};
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
function nativeStore() {
|
|
501
|
+
const b = bridge();
|
|
502
|
+
if (!b?.save || !b.load) return void 0;
|
|
503
|
+
return {
|
|
504
|
+
load: () => {
|
|
505
|
+
try {
|
|
506
|
+
return b.load();
|
|
507
|
+
} catch {
|
|
508
|
+
return null;
|
|
509
|
+
}
|
|
510
|
+
},
|
|
511
|
+
save: (data) => void b.save(data)
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
function defaultRelease(info) {
|
|
515
|
+
if (!info.appId || !info.appVersion) return void 0;
|
|
516
|
+
return `${info.appId}@${info.appVersion}${info.appBuild ? `+${info.appBuild}` : ""}`;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// src/boundary.ts
|
|
520
|
+
var import_react = require("react");
|
|
521
|
+
var report = () => void 0;
|
|
522
|
+
function setBoundaryReporter(fn) {
|
|
523
|
+
report = fn;
|
|
524
|
+
}
|
|
525
|
+
var ErrorBoundary = class extends import_react.Component {
|
|
526
|
+
state = { error: null };
|
|
527
|
+
static getDerivedStateFromError(error) {
|
|
528
|
+
return { error };
|
|
529
|
+
}
|
|
530
|
+
componentDidCatch(error) {
|
|
531
|
+
const id = report(error);
|
|
532
|
+
this.props.onError?.(error, id);
|
|
533
|
+
}
|
|
534
|
+
resetError = () => this.setState({ error: null });
|
|
535
|
+
render() {
|
|
536
|
+
if (this.state.error === null) return this.props.children ?? null;
|
|
537
|
+
const { fallback } = this.props;
|
|
538
|
+
if (typeof fallback === "function") return fallback({ error: this.state.error, resetError: this.resetError });
|
|
539
|
+
if (fallback === void 0) throw this.state.error;
|
|
540
|
+
return fallback;
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
function wrap(Root, options = {}) {
|
|
544
|
+
const Wrapped = (props) => (0, import_react.createElement)(ErrorBoundary, options, (0, import_react.createElement)(Root, props));
|
|
545
|
+
Wrapped.displayName = `Blipit(${Root.displayName ?? Root.name ?? "App"})`;
|
|
546
|
+
return Wrapped;
|
|
547
|
+
}
|
|
56
548
|
|
|
57
549
|
// src/report-strings.ts
|
|
58
550
|
var REPORT_STRINGS = {
|
|
@@ -87,7 +579,15 @@ var REPORT_STRINGS = {
|
|
|
87
579
|
"recError": "The recording could not be made. You can still send the report.",
|
|
88
580
|
"uploadingVideo": "Uploading recording\u2026",
|
|
89
581
|
"close": "Close",
|
|
90
|
-
"noShot": "The screenshot could not be taken. You can still send the report."
|
|
582
|
+
"noShot": "The screenshot could not be taken. You can still send the report.",
|
|
583
|
+
"shotAsk": "Report a bug with this screen?",
|
|
584
|
+
"report": "Report",
|
|
585
|
+
"notNow": "Not now",
|
|
586
|
+
"crashAsk": "The app closed unexpectedly. Tell us what you were doing?",
|
|
587
|
+
"tellUs": "Tell us",
|
|
588
|
+
"pickTitle": "Which screen is the bug on?",
|
|
589
|
+
"pickNow": "Current screen",
|
|
590
|
+
"pickBefore": "Earlier screen"
|
|
91
591
|
},
|
|
92
592
|
"ar": {
|
|
93
593
|
"title": "\u0627\u0644\u0625\u0628\u0644\u0627\u063A \u0639\u0646 \u062E\u0637\u0623",
|
|
@@ -120,7 +620,15 @@ var REPORT_STRINGS = {
|
|
|
120
620
|
"recError": "\u062A\u0639\u0630\u0651\u0631 \u0625\u0646\u0634\u0627\u0621 \u0627\u0644\u062A\u0633\u062C\u064A\u0644. \u0644\u0627 \u064A\u0632\u0627\u0644 \u0628\u0625\u0645\u0643\u0627\u0646\u0643 \u0625\u0631\u0633\u0627\u0644 \u0627\u0644\u0628\u0644\u0627\u063A.",
|
|
121
621
|
"uploadingVideo": "\u062C\u0627\u0631\u064D \u0631\u0641\u0639 \u0627\u0644\u062A\u0633\u062C\u064A\u0644\u2026",
|
|
122
622
|
"close": "\u0625\u063A\u0644\u0627\u0642",
|
|
123
|
-
"noShot": "\u062A\u0639\u0630\u0651\u0631 \u0627\u0644\u062A\u0642\u0627\u0637 \u0644\u0642\u0637\u0629 \u0627\u0644\u0634\u0627\u0634\u0629. \u0644\u0627 \u064A\u0632\u0627\u0644 \u0628\u0625\u0645\u0643\u0627\u0646\u0643 \u0625\u0631\u0633\u0627\u0644 \u0627\u0644\u0628\u0644\u0627\u063A."
|
|
623
|
+
"noShot": "\u062A\u0639\u0630\u0651\u0631 \u0627\u0644\u062A\u0642\u0627\u0637 \u0644\u0642\u0637\u0629 \u0627\u0644\u0634\u0627\u0634\u0629. \u0644\u0627 \u064A\u0632\u0627\u0644 \u0628\u0625\u0645\u0643\u0627\u0646\u0643 \u0625\u0631\u0633\u0627\u0644 \u0627\u0644\u0628\u0644\u0627\u063A.",
|
|
624
|
+
"shotAsk": "\u0647\u0644 \u062A\u0631\u064A\u062F \u0627\u0644\u0625\u0628\u0644\u0627\u063A \u0639\u0646 \u062E\u0637\u0623 \u0641\u064A \u0647\u0630\u0647 \u0627\u0644\u0634\u0627\u0634\u0629\u061F",
|
|
625
|
+
"report": "\u0625\u0628\u0644\u0627\u063A",
|
|
626
|
+
"notNow": "\u0644\u064A\u0633 \u0627\u0644\u0622\u0646",
|
|
627
|
+
"crashAsk": "\u0623\u064F\u063A\u0644\u0642 \u0627\u0644\u062A\u0637\u0628\u064A\u0642 \u0628\u0634\u0643\u0644 \u063A\u064A\u0631 \u0645\u062A\u0648\u0642\u0639. \u0623\u062E\u0628\u0631\u0646\u0627 \u0628\u0645\u0627 \u0643\u0646\u062A \u062A\u0641\u0639\u0644\u0647\u061F",
|
|
628
|
+
"tellUs": "\u0623\u062E\u0628\u0631\u0646\u0627",
|
|
629
|
+
"pickTitle": "\u0641\u064A \u0623\u064A \u0634\u0627\u0634\u0629 \u064A\u0638\u0647\u0631 \u0627\u0644\u062E\u0637\u0623\u061F",
|
|
630
|
+
"pickNow": "\u0627\u0644\u0634\u0627\u0634\u0629 \u0627\u0644\u062D\u0627\u0644\u064A\u0629",
|
|
631
|
+
"pickBefore": "\u0634\u0627\u0634\u0629 \u0633\u0627\u0628\u0642\u0629"
|
|
124
632
|
},
|
|
125
633
|
"de": {
|
|
126
634
|
"title": "Fehler melden",
|
|
@@ -153,7 +661,15 @@ var REPORT_STRINGS = {
|
|
|
153
661
|
"recError": "Die Aufnahme konnte nicht erstellt werden. Sie k\xF6nnen den Bericht trotzdem senden.",
|
|
154
662
|
"uploadingVideo": "Aufnahme wird hochgeladen\u2026",
|
|
155
663
|
"close": "Schlie\xDFen",
|
|
156
|
-
"noShot": "Der Screenshot konnte nicht erstellt werden. Sie k\xF6nnen die Meldung trotzdem senden."
|
|
664
|
+
"noShot": "Der Screenshot konnte nicht erstellt werden. Sie k\xF6nnen die Meldung trotzdem senden.",
|
|
665
|
+
"shotAsk": "Einen Fehler mit diesem Bildschirm melden?",
|
|
666
|
+
"report": "Melden",
|
|
667
|
+
"notNow": "Nicht jetzt",
|
|
668
|
+
"crashAsk": "Die App wurde unerwartet beendet. M\xF6chten Sie uns sagen, was Sie gerade getan haben?",
|
|
669
|
+
"tellUs": "Erz\xE4hlen",
|
|
670
|
+
"pickTitle": "Auf welchem Bildschirm ist der Fehler?",
|
|
671
|
+
"pickNow": "Aktueller Bildschirm",
|
|
672
|
+
"pickBefore": "Fr\xFCherer Bildschirm"
|
|
157
673
|
},
|
|
158
674
|
"es": {
|
|
159
675
|
"title": "Reportar un error",
|
|
@@ -186,7 +702,15 @@ var REPORT_STRINGS = {
|
|
|
186
702
|
"recError": "No se pudo hacer la grabaci\xF3n. A\xFAn puedes enviar el informe.",
|
|
187
703
|
"uploadingVideo": "Subiendo grabaci\xF3n\u2026",
|
|
188
704
|
"close": "Cerrar",
|
|
189
|
-
"noShot": "No se pudo tomar la captura. Aun as\xED puedes enviar el reporte."
|
|
705
|
+
"noShot": "No se pudo tomar la captura. Aun as\xED puedes enviar el reporte.",
|
|
706
|
+
"shotAsk": "\xBFInformar de un error con esta pantalla?",
|
|
707
|
+
"report": "Informar",
|
|
708
|
+
"notNow": "Ahora no",
|
|
709
|
+
"crashAsk": "La aplicaci\xF3n se cerr\xF3 inesperadamente. \xBFNos cuenta qu\xE9 estaba haciendo?",
|
|
710
|
+
"tellUs": "Contarlo",
|
|
711
|
+
"pickTitle": "\xBFEn qu\xE9 pantalla est\xE1 el error?",
|
|
712
|
+
"pickNow": "Pantalla actual",
|
|
713
|
+
"pickBefore": "Pantalla anterior"
|
|
190
714
|
},
|
|
191
715
|
"fr": {
|
|
192
716
|
"title": "Signaler un bug",
|
|
@@ -219,7 +743,15 @@ var REPORT_STRINGS = {
|
|
|
219
743
|
"recError": "L\u2019enregistrement n\u2019a pas pu \xEAtre effectu\xE9. Vous pouvez quand m\xEAme envoyer le rapport.",
|
|
220
744
|
"uploadingVideo": "Envoi de l\u2019enregistrement\u2026",
|
|
221
745
|
"close": "Fermer",
|
|
222
|
-
"noShot": "La capture d\u2019\xE9cran a \xE9chou\xE9. Vous pouvez quand m\xEAme envoyer le signalement."
|
|
746
|
+
"noShot": "La capture d\u2019\xE9cran a \xE9chou\xE9. Vous pouvez quand m\xEAme envoyer le signalement.",
|
|
747
|
+
"shotAsk": "Signaler un bug avec cet \xE9cran ?",
|
|
748
|
+
"report": "Signaler",
|
|
749
|
+
"notNow": "Plus tard",
|
|
750
|
+
"crashAsk": "L\u2019application s\u2019est ferm\xE9e de fa\xE7on inattendue. Dites-nous ce que vous faisiez ?",
|
|
751
|
+
"tellUs": "Raconter",
|
|
752
|
+
"pickTitle": "Sur quel \xE9cran se trouve le bug ?",
|
|
753
|
+
"pickNow": "\xC9cran actuel",
|
|
754
|
+
"pickBefore": "\xC9cran pr\xE9c\xE9dent"
|
|
223
755
|
},
|
|
224
756
|
"it": {
|
|
225
757
|
"title": "Segnala un bug",
|
|
@@ -252,7 +784,15 @@ var REPORT_STRINGS = {
|
|
|
252
784
|
"recError": "Non \xE8 stato possibile registrare. Puoi comunque inviare la segnalazione.",
|
|
253
785
|
"uploadingVideo": "Caricamento della registrazione\u2026",
|
|
254
786
|
"close": "Chiudi",
|
|
255
|
-
"noShot": "Non \xE8 stato possibile acquisire lo screenshot. Puoi comunque inviare la segnalazione."
|
|
787
|
+
"noShot": "Non \xE8 stato possibile acquisire lo screenshot. Puoi comunque inviare la segnalazione.",
|
|
788
|
+
"shotAsk": "Segnalare un bug con questa schermata?",
|
|
789
|
+
"report": "Segnala",
|
|
790
|
+
"notNow": "Non ora",
|
|
791
|
+
"crashAsk": "L\u2019app si \xE8 chiusa in modo imprevisto. Ci dice cosa stava facendo?",
|
|
792
|
+
"tellUs": "Racconta",
|
|
793
|
+
"pickTitle": "In quale schermata si trova il bug?",
|
|
794
|
+
"pickNow": "Schermata attuale",
|
|
795
|
+
"pickBefore": "Schermata precedente"
|
|
256
796
|
},
|
|
257
797
|
"ja": {
|
|
258
798
|
"title": "\u4E0D\u5177\u5408\u3092\u5831\u544A",
|
|
@@ -285,7 +825,15 @@ var REPORT_STRINGS = {
|
|
|
285
825
|
"recError": "\u9332\u753B\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002\u30EC\u30DD\u30FC\u30C8\u306F\u305D\u306E\u307E\u307E\u9001\u4FE1\u3067\u304D\u307E\u3059\u3002",
|
|
286
826
|
"uploadingVideo": "\u9332\u753B\u3092\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u4E2D\u2026",
|
|
287
827
|
"close": "\u9589\u3058\u308B",
|
|
288
|
-
"noShot": "\u30B9\u30AF\u30EA\u30FC\u30F3\u30B7\u30E7\u30C3\u30C8\u3092\u64AE\u5F71\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002\u5831\u544A\u306F\u3053\u306E\u307E\u307E\u9001\u4FE1\u3067\u304D\u307E\u3059\u3002"
|
|
828
|
+
"noShot": "\u30B9\u30AF\u30EA\u30FC\u30F3\u30B7\u30E7\u30C3\u30C8\u3092\u64AE\u5F71\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002\u5831\u544A\u306F\u3053\u306E\u307E\u307E\u9001\u4FE1\u3067\u304D\u307E\u3059\u3002",
|
|
829
|
+
"shotAsk": "\u3053\u306E\u753B\u9762\u3067\u4E0D\u5177\u5408\u3092\u5831\u544A\u3057\u307E\u3059\u304B\uFF1F",
|
|
830
|
+
"report": "\u5831\u544A\u3059\u308B",
|
|
831
|
+
"notNow": "\u4ECA\u306F\u3057\u306A\u3044",
|
|
832
|
+
"crashAsk": "\u30A2\u30D7\u30EA\u304C\u4E88\u671F\u305B\u305A\u7D42\u4E86\u3057\u307E\u3057\u305F\u3002\u4F55\u3092\u3057\u3066\u3044\u305F\u304B\u6559\u3048\u3066\u3044\u305F\u3060\u3051\u307E\u3059\u304B\uFF1F",
|
|
833
|
+
"tellUs": "\u4F1D\u3048\u308B",
|
|
834
|
+
"pickTitle": "\u4E0D\u5177\u5408\u304C\u3042\u308B\u306E\u306F\u3069\u306E\u753B\u9762\u3067\u3059\u304B\uFF1F",
|
|
835
|
+
"pickNow": "\u73FE\u5728\u306E\u753B\u9762",
|
|
836
|
+
"pickBefore": "\u524D\u306E\u753B\u9762"
|
|
289
837
|
},
|
|
290
838
|
"nl": {
|
|
291
839
|
"title": "Bug melden",
|
|
@@ -318,7 +866,15 @@ var REPORT_STRINGS = {
|
|
|
318
866
|
"recError": "De opname kon niet worden gemaakt. Je kunt het rapport nog steeds versturen.",
|
|
319
867
|
"uploadingVideo": "Opname uploaden\u2026",
|
|
320
868
|
"close": "Sluiten",
|
|
321
|
-
"noShot": "De schermafbeelding kon niet worden gemaakt. Je kunt de melding toch versturen."
|
|
869
|
+
"noShot": "De schermafbeelding kon niet worden gemaakt. Je kunt de melding toch versturen.",
|
|
870
|
+
"shotAsk": "Een bug melden met dit scherm?",
|
|
871
|
+
"report": "Melden",
|
|
872
|
+
"notNow": "Niet nu",
|
|
873
|
+
"crashAsk": "De app is onverwacht gesloten. Vertelt u ons wat u aan het doen was?",
|
|
874
|
+
"tellUs": "Vertellen",
|
|
875
|
+
"pickTitle": "Op welk scherm zit de bug?",
|
|
876
|
+
"pickNow": "Huidig scherm",
|
|
877
|
+
"pickBefore": "Eerder scherm"
|
|
322
878
|
},
|
|
323
879
|
"pt": {
|
|
324
880
|
"title": "Reportar um erro",
|
|
@@ -351,7 +907,15 @@ var REPORT_STRINGS = {
|
|
|
351
907
|
"recError": "N\xE3o foi poss\xEDvel gravar. Voc\xEA ainda pode enviar o relat\xF3rio.",
|
|
352
908
|
"uploadingVideo": "Enviando grava\xE7\xE3o\u2026",
|
|
353
909
|
"close": "Fechar",
|
|
354
|
-
"noShot": "N\xE3o foi poss\xEDvel fazer a captura. Voc\xEA ainda pode enviar o relat\xF3rio."
|
|
910
|
+
"noShot": "N\xE3o foi poss\xEDvel fazer a captura. Voc\xEA ainda pode enviar o relat\xF3rio.",
|
|
911
|
+
"shotAsk": "Reportar um erro com esta tela?",
|
|
912
|
+
"report": "Reportar",
|
|
913
|
+
"notNow": "Agora n\xE3o",
|
|
914
|
+
"crashAsk": "O app fechou inesperadamente. Conte o que voc\xEA estava fazendo?",
|
|
915
|
+
"tellUs": "Contar",
|
|
916
|
+
"pickTitle": "Em qual tela est\xE1 o erro?",
|
|
917
|
+
"pickNow": "Tela atual",
|
|
918
|
+
"pickBefore": "Tela anterior"
|
|
355
919
|
},
|
|
356
920
|
"tr": {
|
|
357
921
|
"title": "Hata bildir",
|
|
@@ -384,7 +948,15 @@ var REPORT_STRINGS = {
|
|
|
384
948
|
"recError": "Kay\u0131t yap\u0131lamad\u0131. Raporu yine de g\xF6nderebilirsiniz.",
|
|
385
949
|
"uploadingVideo": "Kay\u0131t y\xFCkleniyor\u2026",
|
|
386
950
|
"close": "Kapat",
|
|
387
|
-
"noShot": "Ekran g\xF6r\xFCnt\xFCs\xFC al\u0131namad\u0131. Bildirimi yine de g\xF6nderebilirsiniz."
|
|
951
|
+
"noShot": "Ekran g\xF6r\xFCnt\xFCs\xFC al\u0131namad\u0131. Bildirimi yine de g\xF6nderebilirsiniz.",
|
|
952
|
+
"shotAsk": "Bu ekranla bir hata bildirilsin mi?",
|
|
953
|
+
"report": "Bildir",
|
|
954
|
+
"notNow": "\u015Eimdi de\u011Fil",
|
|
955
|
+
"crashAsk": "Uygulama beklenmedik \u015Fekilde kapand\u0131. Ne yapt\u0131\u011F\u0131n\u0131z\u0131 bize anlat\u0131r m\u0131s\u0131n\u0131z?",
|
|
956
|
+
"tellUs": "Anlat",
|
|
957
|
+
"pickTitle": "Hata hangi ekranda?",
|
|
958
|
+
"pickNow": "Ge\xE7erli ekran",
|
|
959
|
+
"pickBefore": "\xD6nceki ekran"
|
|
388
960
|
},
|
|
389
961
|
"zh": {
|
|
390
962
|
"title": "\u62A5\u544A\u95EE\u9898",
|
|
@@ -417,7 +989,15 @@ var REPORT_STRINGS = {
|
|
|
417
989
|
"recError": "\u65E0\u6CD5\u5B8C\u6210\u5F55\u5236\u3002\u4F60\u4ECD\u7136\u53EF\u4EE5\u53D1\u9001\u62A5\u544A\u3002",
|
|
418
990
|
"uploadingVideo": "\u6B63\u5728\u4E0A\u4F20\u5F55\u5236\u5185\u5BB9\u2026",
|
|
419
991
|
"close": "\u5173\u95ED",
|
|
420
|
-
"noShot": "\u65E0\u6CD5\u622A\u53D6\u5C4F\u5E55\u3002\u60A8\u4ECD\u7136\u53EF\u4EE5\u53D1\u9001\u62A5\u544A\u3002"
|
|
992
|
+
"noShot": "\u65E0\u6CD5\u622A\u53D6\u5C4F\u5E55\u3002\u60A8\u4ECD\u7136\u53EF\u4EE5\u53D1\u9001\u62A5\u544A\u3002",
|
|
993
|
+
"shotAsk": "\u8981\u7528\u6B64\u5C4F\u5E55\u62A5\u544A\u95EE\u9898\u5417\uFF1F",
|
|
994
|
+
"report": "\u62A5\u544A",
|
|
995
|
+
"notNow": "\u4EE5\u540E\u518D\u8BF4",
|
|
996
|
+
"crashAsk": "\u5E94\u7528\u610F\u5916\u5173\u95ED\u3002\u80FD\u544A\u8BC9\u6211\u4EEC\u4F60\u5F53\u65F6\u5728\u505A\u4EC0\u4E48\u5417\uFF1F",
|
|
997
|
+
"tellUs": "\u544A\u8BC9\u6211\u4EEC",
|
|
998
|
+
"pickTitle": "\u95EE\u9898\u51FA\u73B0\u5728\u54EA\u4E2A\u5C4F\u5E55\uFF1F",
|
|
999
|
+
"pickNow": "\u5F53\u524D\u5C4F\u5E55",
|
|
1000
|
+
"pickBefore": "\u4E4B\u524D\u7684\u5C4F\u5E55"
|
|
421
1001
|
}
|
|
422
1002
|
};
|
|
423
1003
|
|
|
@@ -458,6 +1038,7 @@ function feedbackBody(input) {
|
|
|
458
1038
|
};
|
|
459
1039
|
if (input.title.trim()) body.title = input.title.trim();
|
|
460
1040
|
if (input.email?.trim()) body.email = input.email.trim();
|
|
1041
|
+
if (input.eventId && /^[0-9a-f]{32}$/.test(input.eventId)) body.event_id = input.eventId;
|
|
461
1042
|
if (input.image) {
|
|
462
1043
|
const list = annotations(input.shapes ?? [], input.image.width, input.image.height);
|
|
463
1044
|
if (list.length) body.annotations = [{ position: 0, shapes: list }];
|
|
@@ -471,25 +1052,25 @@ var ReportClient = class {
|
|
|
471
1052
|
constructor(endpoint, key, fetcher = (...a) => fetch(...a)) {
|
|
472
1053
|
this.endpoint = endpoint.replace(/\/+$/, "");
|
|
473
1054
|
this.key = key;
|
|
474
|
-
this.fetcher = fetcher;
|
|
1055
|
+
this.fetcher = guardPlatform(fetcher);
|
|
475
1056
|
}
|
|
476
|
-
async call(path,
|
|
477
|
-
const res = await this.fetcher(`${this.endpoint}${path}`, { ...
|
|
1057
|
+
async call(path, init2) {
|
|
1058
|
+
const res = await this.fetcher(`${this.endpoint}${path}`, { ...init2, headers: { "X-Blipit-Key": this.key, ...init2.headers } });
|
|
478
1059
|
const text2 = await res.text();
|
|
479
1060
|
if (!res.ok) throw new Error(`Blipit returned ${res.status}`);
|
|
480
1061
|
return text2;
|
|
481
1062
|
}
|
|
482
|
-
async settings() {
|
|
483
|
-
return JSON.parse(await this.call("/api/v1/feedback/settings", { method: "GET" }));
|
|
1063
|
+
async settings(user) {
|
|
1064
|
+
return JSON.parse(await this.call("/api/v1/feedback/settings", { method: "GET", headers: userHeaders(user) }));
|
|
484
1065
|
}
|
|
485
1066
|
async event(body) {
|
|
486
1067
|
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) });
|
|
487
1068
|
return res.ok || res.status >= 400 && res.status < 500 && res.status !== 408 && res.status !== 429;
|
|
488
1069
|
}
|
|
489
1070
|
async send(body) {
|
|
490
|
-
const
|
|
491
|
-
if (typeof
|
|
492
|
-
return { id: String(
|
|
1071
|
+
const json2 = JSON.parse(await this.call("/api/v1/feedback", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) }));
|
|
1072
|
+
if (typeof json2.upload_token !== "string") throw new Error("Blipit returned no upload token");
|
|
1073
|
+
return { id: String(json2.id), token: json2.upload_token, ref: typeof json2.ref === "string" ? json2.ref : null };
|
|
493
1074
|
}
|
|
494
1075
|
async uploadScreenshot(receipt, data, type) {
|
|
495
1076
|
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 });
|
|
@@ -671,19 +1252,52 @@ function createStuck(transport, info, clock = Date.now) {
|
|
|
671
1252
|
}
|
|
672
1253
|
|
|
673
1254
|
// src/reporter.tsx
|
|
674
|
-
var
|
|
675
|
-
var
|
|
1255
|
+
var import_react2 = require("react");
|
|
1256
|
+
var import_react_native2 = require("react-native");
|
|
676
1257
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
677
1258
|
var C = { navy: "#0B1A3A", card: "#1A2135", brand: "#3882F6", muted: "#98A6BE", mark: "#FF3B30", danger: "#FF7A6E", white: "#FFFFFF" };
|
|
678
1259
|
var opener = null;
|
|
679
1260
|
var config = null;
|
|
680
|
-
|
|
681
|
-
|
|
1261
|
+
var open = false;
|
|
1262
|
+
var serverButton = false;
|
|
1263
|
+
var onServerButton = null;
|
|
1264
|
+
var currentScreen;
|
|
1265
|
+
var settle;
|
|
1266
|
+
var debounce = createDebounce();
|
|
1267
|
+
var screens = new ScreenShots();
|
|
1268
|
+
function configureReporter(client, device, o = { picker: true }) {
|
|
1269
|
+
config = { client, device, picker: o.picker };
|
|
1270
|
+
if (!o.picker) screens.clear();
|
|
682
1271
|
}
|
|
683
1272
|
function showReport() {
|
|
684
1273
|
if (!config) console.warn("[blipit] call Blipit.init before showReport");
|
|
685
1274
|
else if (!opener) console.warn("[blipit] wrap your app in <BlipitReporter> to use showReport");
|
|
686
|
-
else opener();
|
|
1275
|
+
else opener({ picker: config.picker, crashId: null });
|
|
1276
|
+
}
|
|
1277
|
+
function reportTrigger(trigger, crashId) {
|
|
1278
|
+
if (!config || !opener || !debounce.allow(open)) return;
|
|
1279
|
+
opener({ picker: false, crashId: trigger === "crash" ? crashId : null });
|
|
1280
|
+
}
|
|
1281
|
+
function setServerButton(on) {
|
|
1282
|
+
serverButton = on;
|
|
1283
|
+
onServerButton?.(on);
|
|
1284
|
+
}
|
|
1285
|
+
function noteScreen(name) {
|
|
1286
|
+
if (!name || !config?.picker) return;
|
|
1287
|
+
currentScreen = name;
|
|
1288
|
+
if (settle) clearTimeout(settle);
|
|
1289
|
+
settle = setTimeout(async () => {
|
|
1290
|
+
settle = void 0;
|
|
1291
|
+
const shooter = viewShot();
|
|
1292
|
+
if (open || !shooter || currentScreen !== name || !config?.picker) return;
|
|
1293
|
+
try {
|
|
1294
|
+
const { width, height } = import_react_native2.Dimensions.get("window");
|
|
1295
|
+
const size = pickerSize(width, height);
|
|
1296
|
+
const uri = await shooter.captureScreen({ format: "jpg", quality: 0.6, result: "data-uri", ...size });
|
|
1297
|
+
if (!open && currentScreen === name && config?.picker) screens.add({ name, uri, ...size });
|
|
1298
|
+
} catch {
|
|
1299
|
+
}
|
|
1300
|
+
}, PICKER_SETTLE_MS);
|
|
687
1301
|
}
|
|
688
1302
|
function viewShot() {
|
|
689
1303
|
try {
|
|
@@ -700,25 +1314,38 @@ var languages = () => {
|
|
|
700
1314
|
}
|
|
701
1315
|
};
|
|
702
1316
|
function BlipitReporter({ children, showButton = false }) {
|
|
703
|
-
const lang = (0,
|
|
1317
|
+
const lang = (0, import_react2.useMemo)(() => pickLang(languages()), []);
|
|
704
1318
|
const t = (key) => text(key, lang);
|
|
705
|
-
const [stage, setStage] = (0,
|
|
706
|
-
const [shot, setShot] = (0,
|
|
707
|
-
const [flat, setFlat] = (0,
|
|
708
|
-
const [notice, setNotice] = (0,
|
|
709
|
-
const
|
|
710
|
-
(0,
|
|
711
|
-
|
|
1319
|
+
const [stage, setStage] = (0, import_react2.useState)("closed");
|
|
1320
|
+
const [shot, setShot] = (0, import_react2.useState)(null);
|
|
1321
|
+
const [flat, setFlat] = (0, import_react2.useState)(null);
|
|
1322
|
+
const [notice, setNotice] = (0, import_react2.useState)(null);
|
|
1323
|
+
const [wantPicker, setWantPicker] = (0, import_react2.useState)(false);
|
|
1324
|
+
const [crashId, setCrashId] = (0, import_react2.useState)(null);
|
|
1325
|
+
const [earlier, setEarlier] = (0, import_react2.useState)([]);
|
|
1326
|
+
const [server, setServer] = (0, import_react2.useState)(serverButton);
|
|
1327
|
+
const shapes = (0, import_react2.useRef)([]);
|
|
1328
|
+
(0, import_react2.useEffect)(() => {
|
|
1329
|
+
opener = (o) => {
|
|
712
1330
|
shapes.current = [];
|
|
713
1331
|
setShot(null);
|
|
714
1332
|
setFlat(null);
|
|
715
1333
|
setNotice(null);
|
|
1334
|
+
setEarlier([]);
|
|
1335
|
+
setWantPicker(o.picker);
|
|
1336
|
+
setCrashId(o.crashId);
|
|
716
1337
|
setStage("choice");
|
|
717
1338
|
};
|
|
1339
|
+
onServerButton = setServer;
|
|
1340
|
+
setServer(serverButton);
|
|
718
1341
|
return () => {
|
|
719
1342
|
opener = null;
|
|
1343
|
+
onServerButton = null;
|
|
720
1344
|
};
|
|
721
1345
|
}, []);
|
|
1346
|
+
(0, import_react2.useEffect)(() => {
|
|
1347
|
+
open = stage !== "closed";
|
|
1348
|
+
}, [stage]);
|
|
722
1349
|
const capture = async () => {
|
|
723
1350
|
const shooter = viewShot();
|
|
724
1351
|
setStage("closed");
|
|
@@ -726,26 +1353,28 @@ function BlipitReporter({ children, showButton = false }) {
|
|
|
726
1353
|
try {
|
|
727
1354
|
if (!shooter) throw new Error("react-native-view-shot is not installed");
|
|
728
1355
|
const uri = await shooter.captureScreen({ format: "jpg", quality: 0.9, result: "tmpfile" });
|
|
729
|
-
const size = await new Promise((ok, fail) =>
|
|
1356
|
+
const size = await new Promise((ok, fail) => import_react_native2.Image.getSize(uri, (width, height) => ok({ width, height }), fail));
|
|
730
1357
|
setShot({ uri, ...size });
|
|
731
|
-
|
|
1358
|
+
const before = wantPicker ? screens.list(currentScreen) : [];
|
|
1359
|
+
setEarlier(before);
|
|
1360
|
+
setStage(before.length ? "pick" : "editor");
|
|
732
1361
|
} catch (err) {
|
|
733
1362
|
if (!shooter) console.warn("[blipit] install react-native-view-shot to attach screenshots to bug reports");
|
|
734
1363
|
setNotice(t("noShot"));
|
|
735
1364
|
setStage("details");
|
|
736
1365
|
}
|
|
737
1366
|
};
|
|
738
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1367
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.View, { style: { flex: 1 }, children: [
|
|
739
1368
|
children,
|
|
740
|
-
showButton && stage === "closed" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
741
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
742
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1369
|
+
(showButton || server) && stage === "closed" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.Pressable, { accessibilityRole: "button", accessibilityLabel: t("title"), onPress: showReport, style: ({ pressed }) => [s.fab, pressed && { opacity: 0.85 }], children: [
|
|
1370
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: s.fabIcon, children: "!" }),
|
|
1371
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: s.fabText, children: t("title") })
|
|
743
1372
|
] }) : null,
|
|
744
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
745
|
-
stage === "choice" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1373
|
+
/* @__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: [
|
|
1374
|
+
stage === "choice" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.View, { style: s.pad, children: [
|
|
746
1375
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Bar, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BarButton, { label: t("close"), glyph: "\u2715", onPress: () => setStage("closed") }) }),
|
|
747
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
748
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1376
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.View, { style: s.center, children: [
|
|
1377
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: s.h1, children: t("mHow") }),
|
|
749
1378
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card, { title: t("mShot"), glyph: "\u25CE", onPress: capture }),
|
|
750
1379
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
751
1380
|
Card,
|
|
@@ -760,6 +1389,28 @@ function BlipitReporter({ children, showButton = false }) {
|
|
|
760
1389
|
)
|
|
761
1390
|
] })
|
|
762
1391
|
] }) : null,
|
|
1392
|
+
stage === "pick" && shot ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.View, { style: s.pad, children: [
|
|
1393
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Bar, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BarButton, { label: t("mBack"), glyph: "\u2039", onPress: () => setStage("choice") }) }),
|
|
1394
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: s.h1, children: t("pickTitle") }),
|
|
1395
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.ScrollView, { contentContainerStyle: s.thumbs, children: [shot, ...earlier].map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1396
|
+
import_react_native2.Pressable,
|
|
1397
|
+
{
|
|
1398
|
+
accessibilityRole: "button",
|
|
1399
|
+
accessibilityLabel: i === 0 ? t("pickNow") : t("pickBefore"),
|
|
1400
|
+
onPress: () => {
|
|
1401
|
+
setShot(item);
|
|
1402
|
+
setEarlier([]);
|
|
1403
|
+
setStage("editor");
|
|
1404
|
+
},
|
|
1405
|
+
style: ({ pressed }) => [s.thumb, pressed && { opacity: 0.85 }],
|
|
1406
|
+
children: [
|
|
1407
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Image, { source: { uri: item.uri }, style: [s.thumbImage, { aspectRatio: item.width / Math.max(1, item.height) }], resizeMode: "contain", accessibilityIgnoresInvertColors: true }),
|
|
1408
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: s.thumbText, numberOfLines: 1, children: i === 0 ? t("pickNow") : t("pickBefore") })
|
|
1409
|
+
]
|
|
1410
|
+
},
|
|
1411
|
+
i
|
|
1412
|
+
)) })
|
|
1413
|
+
] }) : null,
|
|
763
1414
|
stage === "editor" && shot ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
764
1415
|
Editor,
|
|
765
1416
|
{
|
|
@@ -782,6 +1433,7 @@ function BlipitReporter({ children, showButton = false }) {
|
|
|
782
1433
|
flat,
|
|
783
1434
|
shapes: shapes.current,
|
|
784
1435
|
notice,
|
|
1436
|
+
eventId: crashId,
|
|
785
1437
|
onBack: () => setStage(shot ? "editor" : "choice"),
|
|
786
1438
|
onDone: () => setStage("closed")
|
|
787
1439
|
}
|
|
@@ -790,42 +1442,42 @@ function BlipitReporter({ children, showButton = false }) {
|
|
|
790
1442
|
] });
|
|
791
1443
|
}
|
|
792
1444
|
function Bar({ children }) {
|
|
793
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1445
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: s.bar, children });
|
|
794
1446
|
}
|
|
795
1447
|
function BarButton({ label, glyph, onPress }) {
|
|
796
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
797
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
798
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1448
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.Pressable, { accessibilityRole: "button", accessibilityLabel: label, onPress, style: s.barButton, hitSlop: 6, children: [
|
|
1449
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: s.glyph, children: glyph }),
|
|
1450
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: s.barText, numberOfLines: 1, children: label })
|
|
799
1451
|
] });
|
|
800
1452
|
}
|
|
801
1453
|
function Primary({ label, onPress, disabled }) {
|
|
802
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1454
|
+
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 }) });
|
|
803
1455
|
}
|
|
804
1456
|
function Card({ title, glyph, onPress }) {
|
|
805
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
806
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
807
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1457
|
+
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: [
|
|
1458
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: s.cardGlyph, children: glyph }),
|
|
1459
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: s.cardText, children: title })
|
|
808
1460
|
] });
|
|
809
1461
|
}
|
|
810
1462
|
function Editor({ shot, shapes, t, onBack, onNext }) {
|
|
811
|
-
const [view, setView] = (0,
|
|
812
|
-
const [zoom, setZoom] = (0,
|
|
813
|
-
const [pan, setPan] = (0,
|
|
814
|
-
const [tool, setTool] = (0,
|
|
815
|
-
const [current, setCurrent] = (0,
|
|
816
|
-
const [, redraw] = (0,
|
|
817
|
-
const [busy, setBusy] = (0,
|
|
818
|
-
const box = (0,
|
|
819
|
-
const content = (0,
|
|
820
|
-
const live = (0,
|
|
1463
|
+
const [view, setView] = (0, import_react2.useState)({ width: 0, height: 0, x: 0, y: 0 });
|
|
1464
|
+
const [zoom, setZoom] = (0, import_react2.useState)(1);
|
|
1465
|
+
const [pan, setPan] = (0, import_react2.useState)({ x: 0, y: 0 });
|
|
1466
|
+
const [tool, setTool] = (0, import_react2.useState)("pen");
|
|
1467
|
+
const [current, setCurrent] = (0, import_react2.useState)(null);
|
|
1468
|
+
const [, redraw] = (0, import_react2.useState)(0);
|
|
1469
|
+
const [busy, setBusy] = (0, import_react2.useState)(false);
|
|
1470
|
+
const box = (0, import_react2.useRef)(null);
|
|
1471
|
+
const content = (0, import_react2.useRef)(null);
|
|
1472
|
+
const live = (0, import_react2.useRef)({ zoom, pan, view, tool, current, gesture: null, lastTap: 0, moved: false });
|
|
821
1473
|
live.current.zoom = zoom;
|
|
822
1474
|
live.current.pan = pan;
|
|
823
1475
|
live.current.view = view;
|
|
824
1476
|
live.current.tool = tool;
|
|
825
1477
|
const image = { width: shot.width, height: shot.height };
|
|
826
1478
|
const local = (e) => e.nativeEvent.touches.map((touch) => ({ x: touch.pageX - live.current.view.x, y: touch.pageY - live.current.view.y }));
|
|
827
|
-
const responder = (0,
|
|
828
|
-
() =>
|
|
1479
|
+
const responder = (0, import_react2.useMemo)(
|
|
1480
|
+
() => import_react_native2.PanResponder.create({
|
|
829
1481
|
onStartShouldSetPanResponder: () => true,
|
|
830
1482
|
onMoveShouldSetPanResponder: () => true,
|
|
831
1483
|
onPanResponderTerminationRequest: () => false,
|
|
@@ -911,7 +1563,7 @@ function Editor({ shot, shapes, t, onBack, onNext }) {
|
|
|
911
1563
|
await new Promise((r) => setTimeout(r, 80));
|
|
912
1564
|
let out = shot;
|
|
913
1565
|
const shooter = viewShot();
|
|
914
|
-
if (shapes.current.length && shooter && content.current) {
|
|
1566
|
+
if ((shapes.current.length || shot.uri.startsWith("data:")) && shooter && content.current) {
|
|
915
1567
|
try {
|
|
916
1568
|
const uri = await shooter.captureRef(content.current, { format: "jpg", quality: 0.85, result: "tmpfile" });
|
|
917
1569
|
out = { uri, width: shot.width, height: shot.height };
|
|
@@ -926,22 +1578,22 @@ function Editor({ shot, shapes, t, onBack, onNext }) {
|
|
|
926
1578
|
["rect", t("rect"), "\u25A2"],
|
|
927
1579
|
["arrow", t("arrow"), "\u2197"]
|
|
928
1580
|
];
|
|
929
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1581
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.View, { style: { flex: 1 }, children: [
|
|
930
1582
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Bar, { children: [
|
|
931
1583
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(BarButton, { label: t("mBack"), glyph: "\u2039", onPress: onBack }),
|
|
932
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1584
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: { flex: 1 } }),
|
|
933
1585
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconButton, { label: t("mZoomOut"), glyph: "\u2212", onPress: () => zoomBy(1 / 1.5) }),
|
|
934
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1586
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.Text, { style: s.zoom, children: [
|
|
935
1587
|
Math.round(zoom * 100),
|
|
936
1588
|
"%"
|
|
937
1589
|
] }),
|
|
938
1590
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconButton, { label: t("mZoomIn"), glyph: "+", onPress: () => zoomBy(1.5) }),
|
|
939
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
940
|
-
busy ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1591
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: { flex: 1 } }),
|
|
1592
|
+
busy ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.ActivityIndicator, { color: C.white, style: { marginHorizontal: 8 } }) : null,
|
|
941
1593
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Primary, { label: t("mNext"), onPress: next, disabled: busy })
|
|
942
1594
|
] }),
|
|
943
1595
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
944
|
-
|
|
1596
|
+
import_react_native2.View,
|
|
945
1597
|
{
|
|
946
1598
|
ref: box,
|
|
947
1599
|
style: s.stage,
|
|
@@ -951,13 +1603,13 @@ function Editor({ shot, shapes, t, onBack, onNext }) {
|
|
|
951
1603
|
setView((v) => ({ ...v, width: w, height: h }));
|
|
952
1604
|
},
|
|
953
1605
|
...responder.panHandlers,
|
|
954
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
955
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1606
|
+
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: [
|
|
1607
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Image, { source: { uri: shot.uri }, style: import_react_native2.StyleSheet.absoluteFill, resizeMode: "stretch" }),
|
|
956
1608
|
[...shapes.current, ...current ? [current] : []].map((shape, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Mark, { shape, scale, width: width * scale }, i))
|
|
957
1609
|
] })
|
|
958
1610
|
}
|
|
959
1611
|
),
|
|
960
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1612
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.View, { style: s.tools, children: [
|
|
961
1613
|
tools.map(([id, label, glyph]) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolButton, { label, glyph, on: tool === id, onPress: () => setTool(id) }, id)),
|
|
962
1614
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
963
1615
|
ToolButton,
|
|
@@ -990,12 +1642,12 @@ function Mark({ shape, scale, width }) {
|
|
|
990
1642
|
const ay = a2.y * scale;
|
|
991
1643
|
const len = Math.hypot(b2.x * scale - ax, b2.y * scale - ay);
|
|
992
1644
|
const angle = Math.atan2(b2.y * scale - ay, b2.x * scale - ax);
|
|
993
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1645
|
+
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);
|
|
994
1646
|
};
|
|
995
1647
|
const a = shape.points[0];
|
|
996
1648
|
const b = shape.points[shape.points.length - 1];
|
|
997
1649
|
if (shape.tool === "rect") {
|
|
998
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1650
|
+
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 } });
|
|
999
1651
|
}
|
|
1000
1652
|
if (shape.tool === "arrow") {
|
|
1001
1653
|
const angle = Math.atan2(b.y - a.y, b.x - a.x);
|
|
@@ -1006,20 +1658,20 @@ function Mark({ shape, scale, width }) {
|
|
|
1006
1658
|
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)) });
|
|
1007
1659
|
}
|
|
1008
1660
|
function IconButton({ label, glyph, onPress }) {
|
|
1009
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1661
|
+
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 }) });
|
|
1010
1662
|
}
|
|
1011
1663
|
function ToolButton({ label, glyph, on, onPress }) {
|
|
1012
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1013
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1014
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1664
|
+
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: [
|
|
1665
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: [s.toolGlyph, { color: on ? C.white : C.muted }], children: glyph }),
|
|
1666
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: [s.toolText, { color: on ? C.white : C.muted }], numberOfLines: 1, children: label })
|
|
1015
1667
|
] });
|
|
1016
1668
|
}
|
|
1017
|
-
function Details({ t, lang, shot, flat, shapes, notice, onBack, onDone }) {
|
|
1018
|
-
const [title, setTitle] = (0,
|
|
1019
|
-
const [message, setMessage] = (0,
|
|
1020
|
-
const [email, setEmail] = (0,
|
|
1021
|
-
const [status, setStatus] = (0,
|
|
1022
|
-
const [busy, setBusy] = (0,
|
|
1669
|
+
function Details({ t, lang, shot, flat, shapes, notice, eventId, onBack, onDone }) {
|
|
1670
|
+
const [title, setTitle] = (0, import_react2.useState)("");
|
|
1671
|
+
const [message, setMessage] = (0, import_react2.useState)("");
|
|
1672
|
+
const [email, setEmail] = (0, import_react2.useState)("");
|
|
1673
|
+
const [status, setStatus] = (0, import_react2.useState)(notice ? { text: notice, error: true } : { text: "", error: false });
|
|
1674
|
+
const [busy, setBusy] = (0, import_react2.useState)(false);
|
|
1023
1675
|
const image = flat ?? shot;
|
|
1024
1676
|
const submit = async () => {
|
|
1025
1677
|
if (busy || !config) return;
|
|
@@ -1030,7 +1682,7 @@ function Details({ t, lang, shot, flat, shapes, notice, onBack, onDone }) {
|
|
|
1030
1682
|
setBusy(true);
|
|
1031
1683
|
setStatus({ text: t("sending"), error: false });
|
|
1032
1684
|
try {
|
|
1033
|
-
const receipt = await config.client.send(feedbackBody({ title, message: message.trim(), email, context: config.device(), shapes, image: shot, screenshots: image ? 1 : 0, locale: lang }));
|
|
1685
|
+
const receipt = await config.client.send(feedbackBody({ title, message: message.trim(), email, context: config.device(), shapes, image: shot, screenshots: image ? 1 : 0, locale: lang, eventId }));
|
|
1034
1686
|
let uploaded = true;
|
|
1035
1687
|
if (image) {
|
|
1036
1688
|
try {
|
|
@@ -1040,8 +1692,8 @@ function Details({ t, lang, shot, flat, shapes, notice, onBack, onDone }) {
|
|
|
1040
1692
|
uploaded = false;
|
|
1041
1693
|
}
|
|
1042
1694
|
}
|
|
1043
|
-
const
|
|
1044
|
-
setStatus({ text: uploaded ?
|
|
1695
|
+
const done2 = receipt.ref ? t("sentRef").replace("{ref}", receipt.ref) : t("sentTitle");
|
|
1696
|
+
setStatus({ text: uploaded ? done2 : `${done2} \xB7 ${t("noShot")}`, error: !uploaded });
|
|
1045
1697
|
setTimeout(onDone, 1600);
|
|
1046
1698
|
} catch {
|
|
1047
1699
|
setStatus({ text: t("error"), error: true });
|
|
@@ -1049,25 +1701,25 @@ function Details({ t, lang, shot, flat, shapes, notice, onBack, onDone }) {
|
|
|
1049
1701
|
setBusy(false);
|
|
1050
1702
|
}
|
|
1051
1703
|
};
|
|
1052
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1704
|
+
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: [
|
|
1053
1705
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Bar, { children: [
|
|
1054
1706
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(BarButton, { label: t("mBack"), glyph: "\u2039", onPress: () => !busy && onBack() }),
|
|
1055
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1056
|
-
busy ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1707
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: { flex: 1 } }),
|
|
1708
|
+
busy ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.ActivityIndicator, { color: C.white, style: { marginHorizontal: 10 } }) : null,
|
|
1057
1709
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Primary, { label: t("send"), onPress: submit, disabled: busy })
|
|
1058
1710
|
] }),
|
|
1059
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1060
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1061
|
-
image ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1062
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1063
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1064
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1065
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1711
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.ScrollView, { contentContainerStyle: { padding: 20, paddingTop: 8, gap: 12 }, keyboardShouldPersistTaps: "handled", children: [
|
|
1712
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: s.h2, children: t("title") }),
|
|
1713
|
+
image ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Image, { source: { uri: image.uri }, style: s.preview, resizeMode: "contain", accessibilityIgnoresInvertColors: true }) : null,
|
|
1714
|
+
/* @__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") }),
|
|
1715
|
+
/* @__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") }),
|
|
1716
|
+
/* @__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") }),
|
|
1717
|
+
/* @__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 })
|
|
1066
1718
|
] })
|
|
1067
1719
|
] });
|
|
1068
1720
|
}
|
|
1069
|
-
var s =
|
|
1070
|
-
screen: { flex: 1, backgroundColor: C.navy, paddingTop:
|
|
1721
|
+
var s = import_react_native2.StyleSheet.create({
|
|
1722
|
+
screen: { flex: 1, backgroundColor: C.navy, paddingTop: import_react_native2.Platform.OS === "android" ? import_react_native2.StatusBar.currentHeight ?? 0 : 0 },
|
|
1071
1723
|
pad: { flex: 1, paddingHorizontal: 20 },
|
|
1072
1724
|
center: { flex: 1, justifyContent: "center", gap: 14 },
|
|
1073
1725
|
h1: { color: C.white, fontSize: 24, fontWeight: "700", marginBottom: 8 },
|
|
@@ -1089,6 +1741,10 @@ var s = import_react_native.StyleSheet.create({
|
|
|
1089
1741
|
tool: { flex: 1, height: 60, alignItems: "center", justifyContent: "center", borderRadius: 12, marginHorizontal: 2 },
|
|
1090
1742
|
toolGlyph: { fontSize: 20 },
|
|
1091
1743
|
toolText: { fontSize: 11, marginTop: 2 },
|
|
1744
|
+
thumbs: { flexDirection: "row", flexWrap: "wrap", gap: 12, paddingVertical: 12 },
|
|
1745
|
+
thumb: { width: "47%", backgroundColor: C.card, borderRadius: 14, borderWidth: 1, borderColor: "rgba(255,255,255,0.1)", padding: 8, gap: 8 },
|
|
1746
|
+
thumbImage: { width: "100%", borderRadius: 8, backgroundColor: C.navy },
|
|
1747
|
+
thumbText: { color: C.white, fontSize: 14, fontWeight: "600", textAlign: "center" },
|
|
1092
1748
|
preview: { height: 150, borderRadius: 12, backgroundColor: C.card },
|
|
1093
1749
|
input: { backgroundColor: C.card, borderRadius: 12, color: C.white, fontSize: 16, paddingHorizontal: 14, paddingVertical: 12, minHeight: 48 },
|
|
1094
1750
|
fab: { position: "absolute", right: 16, bottom: 32, height: 48, borderRadius: 24, backgroundColor: C.brand, flexDirection: "row", alignItems: "center", paddingHorizontal: 18, elevation: 6, shadowColor: "#000", shadowOpacity: 0.25, shadowRadius: 10, shadowOffset: { width: 0, height: 4 } },
|
|
@@ -1097,30 +1753,14 @@ var s = import_react_native.StyleSheet.create({
|
|
|
1097
1753
|
});
|
|
1098
1754
|
|
|
1099
1755
|
// src/index.ts
|
|
1100
|
-
var
|
|
1101
|
-
var DEFAULT_ENDPOINT = "https://in.blipit.io";
|
|
1102
|
-
var VERSION = "0.4.0";
|
|
1103
|
-
var PACKAGE = { name: "npm:@blipit/react-native", version: VERSION };
|
|
1104
|
-
function withIdentity(user) {
|
|
1105
|
-
return (event, hint) => {
|
|
1106
|
-
try {
|
|
1107
|
-
const sdk = event.sdk ??= {};
|
|
1108
|
-
const packages = sdk.packages ?? [];
|
|
1109
|
-
if (!packages.some((p) => p?.name === PACKAGE.name)) sdk.packages = [...packages, { ...PACKAGE }];
|
|
1110
|
-
} catch {
|
|
1111
|
-
}
|
|
1112
|
-
return user ? user(event, hint) : event;
|
|
1113
|
-
};
|
|
1114
|
-
}
|
|
1115
|
-
function dsn(key, project, endpoint = DEFAULT_ENDPOINT) {
|
|
1116
|
-
const host = endpoint.split("://").pop().replace(/\/+$/, "");
|
|
1117
|
-
const scheme = endpoint.startsWith("http://") ? "http" : "https";
|
|
1118
|
-
return `${scheme}://${key}@${host}/${project}`;
|
|
1119
|
-
}
|
|
1756
|
+
var SECURITY_KINDS = ["login_failed", "login_succeeded", "login_blocked", "password_reset_requested", "privilege_granted"];
|
|
1120
1757
|
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.";
|
|
1121
1758
|
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.";
|
|
1122
|
-
|
|
1123
|
-
|
|
1759
|
+
var core;
|
|
1760
|
+
var session;
|
|
1761
|
+
var appState;
|
|
1762
|
+
function init(options) {
|
|
1763
|
+
const { key, publicKey, project, endpoint, waitForReady, shakeToReport, screenshotToReport, twoFingerReport, reportAfterCrash, screenPicker, ...rest } = options ?? {};
|
|
1124
1764
|
const k = (key ?? publicKey ?? "").trim();
|
|
1125
1765
|
if (!k) {
|
|
1126
1766
|
console.warn(MISSING_KEY);
|
|
@@ -1130,28 +1770,100 @@ function init2(options) {
|
|
|
1130
1770
|
console.warn(MISSING_PROJECT);
|
|
1131
1771
|
return false;
|
|
1132
1772
|
}
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1773
|
+
const info = nativeInfo();
|
|
1774
|
+
const release = rest.release ?? defaultRelease(info);
|
|
1775
|
+
const base = endpoint ?? DEFAULT_ENDPOINT;
|
|
1776
|
+
session?.end();
|
|
1777
|
+
appState?.remove();
|
|
1778
|
+
core = new Nuggets({ ...rest, key: k, endpoint: base, release, store: nativeStore(), contexts: () => contexts(info.model, info.osVersion) });
|
|
1779
|
+
const c = core;
|
|
1780
|
+
setBoundaryReporter((error) => c.captureException(error, false));
|
|
1781
|
+
instrument(() => core);
|
|
1782
|
+
const native = rest.enableNative !== false ? bridge() : void 0;
|
|
1783
|
+
if (native && !triggerOff) triggerOff = onNativeTrigger((trigger, crashId) => isTrigger(trigger) && reportTrigger(trigger, typeof crashId === "string" ? crashId : null));
|
|
1784
|
+
try {
|
|
1785
|
+
native?.start(k, String(project), rest.environment ?? null, release ?? null, c.endpoint, {
|
|
1786
|
+
shakeToReport: shakeToReport === true,
|
|
1787
|
+
screenshotToReport: screenshotToReport === true,
|
|
1788
|
+
twoFingerReport: twoFingerReport === true,
|
|
1789
|
+
reportAfterCrash: reportAfterCrash === true,
|
|
1790
|
+
screenPicker: false
|
|
1791
|
+
});
|
|
1792
|
+
} catch {
|
|
1793
|
+
}
|
|
1794
|
+
if (reportAfterCrash === true && c.crashId) {
|
|
1795
|
+
try {
|
|
1796
|
+
native?.promptAfterCrash?.(c.crashId);
|
|
1797
|
+
} catch {
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
session = release && rest.autoSessionTracking !== false ? new Session(c, release, rest.environment ?? "production") : void 0;
|
|
1801
|
+
c.onError = (unhandled) => session?.markError(unhandled);
|
|
1802
|
+
if (c.enabled) session?.start();
|
|
1803
|
+
appState = import_react_native3.AppState?.addEventListener?.("change", (state) => {
|
|
1804
|
+
if (state === "active") {
|
|
1805
|
+
screens.foreground(Date.now());
|
|
1806
|
+
if (c.enabled) session?.start();
|
|
1807
|
+
void c.flush();
|
|
1808
|
+
} else if (state === "background") {
|
|
1809
|
+
screens.background(Date.now());
|
|
1810
|
+
session?.end();
|
|
1811
|
+
void c.flush();
|
|
1812
|
+
}
|
|
1139
1813
|
});
|
|
1140
|
-
|
|
1141
|
-
|
|
1814
|
+
void c.flush();
|
|
1815
|
+
const reports = new ReportClient(base, k);
|
|
1816
|
+
configureReporter(reports, () => deviceContext(release), { picker: screenPicker !== false });
|
|
1817
|
+
reportClient = reports;
|
|
1818
|
+
refreshButton(0);
|
|
1142
1819
|
if (!stuck) {
|
|
1143
|
-
stuck = createStuck(
|
|
1820
|
+
stuck = createStuck(
|
|
1821
|
+
{
|
|
1822
|
+
settings: () => reportClient ? reportClient.settings() : Promise.resolve(null),
|
|
1823
|
+
event: async (body) => (core?.enqueue(body), true)
|
|
1824
|
+
},
|
|
1825
|
+
{ release, environment: rest.environment, os: import_react_native3.Platform.OS, osVersion: info.osVersion ?? String(import_react_native3.Platform.Version), version: VERSION }
|
|
1826
|
+
);
|
|
1144
1827
|
try {
|
|
1145
|
-
stuck.setForeground(
|
|
1146
|
-
|
|
1828
|
+
stuck.setForeground(import_react_native3.AppState.currentState !== "background");
|
|
1829
|
+
import_react_native3.AppState.addEventListener("change", (state) => stuck?.setForeground(state !== "background"));
|
|
1147
1830
|
} catch {
|
|
1148
1831
|
stuck.setForeground(true);
|
|
1149
1832
|
}
|
|
1150
1833
|
if (waitForReady) stuck.start(STARTUP);
|
|
1151
1834
|
}
|
|
1835
|
+
if (rest.debug) console.log(`[blipit] ${SDK_NAME}@${VERSION} initialized`);
|
|
1152
1836
|
return true;
|
|
1153
1837
|
}
|
|
1154
1838
|
var stuck = null;
|
|
1839
|
+
var reportClient;
|
|
1840
|
+
var triggerOff;
|
|
1841
|
+
var buttonTimer;
|
|
1842
|
+
var buttonBusy = false;
|
|
1843
|
+
var buttonAgain = false;
|
|
1844
|
+
function refreshButton(delay) {
|
|
1845
|
+
if (buttonTimer) clearTimeout(buttonTimer);
|
|
1846
|
+
buttonTimer = setTimeout(() => {
|
|
1847
|
+
buttonTimer = void 0;
|
|
1848
|
+
void fetchButton();
|
|
1849
|
+
}, delay);
|
|
1850
|
+
}
|
|
1851
|
+
async function fetchButton() {
|
|
1852
|
+
const client = reportClient;
|
|
1853
|
+
if (!client) return;
|
|
1854
|
+
if (buttonBusy) return void (buttonAgain = true);
|
|
1855
|
+
buttonBusy = true;
|
|
1856
|
+
try {
|
|
1857
|
+
setServerButton(parseReportButton(await client.settings(core?.user)));
|
|
1858
|
+
} catch {
|
|
1859
|
+
} finally {
|
|
1860
|
+
buttonBusy = false;
|
|
1861
|
+
if (buttonAgain) {
|
|
1862
|
+
buttonAgain = false;
|
|
1863
|
+
void fetchButton();
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1155
1867
|
function reportReady() {
|
|
1156
1868
|
stuck?.end(STARTUP);
|
|
1157
1869
|
}
|
|
@@ -1168,8 +1880,18 @@ function endFlow(name) {
|
|
|
1168
1880
|
const flow = cleanName(name, 64);
|
|
1169
1881
|
if (flow) stuck?.end(flow);
|
|
1170
1882
|
}
|
|
1883
|
+
function contexts(model, osVersion) {
|
|
1884
|
+
const { width, height } = import_react_native3.Dimensions.get("window");
|
|
1885
|
+
const engine = globalThis.HermesInternal ? "hermes" : "jsc";
|
|
1886
|
+
const rn = import_react_native3.Platform.constants?.reactNativeVersion;
|
|
1887
|
+
return {
|
|
1888
|
+
os: { name: import_react_native3.Platform.OS, version: osVersion ?? String(import_react_native3.Platform.Version) },
|
|
1889
|
+
device: { ...model ? { model } : {}, screen: `${Math.round(width)}x${Math.round(height)}` },
|
|
1890
|
+
runtime: { name: engine, ...rn ? { version: `react-native ${rn.major}.${rn.minor}.${rn.patch}` } : {} }
|
|
1891
|
+
};
|
|
1892
|
+
}
|
|
1171
1893
|
function deviceContext(release) {
|
|
1172
|
-
const { width, height, scale } =
|
|
1894
|
+
const { width, height, scale } = import_react_native3.Dimensions.get("window");
|
|
1173
1895
|
let language = "";
|
|
1174
1896
|
let timezone = "";
|
|
1175
1897
|
try {
|
|
@@ -1180,11 +1902,17 @@ function deviceContext(release) {
|
|
|
1180
1902
|
}
|
|
1181
1903
|
return {
|
|
1182
1904
|
platform: "react-native",
|
|
1183
|
-
sdk: { name:
|
|
1905
|
+
sdk: { name: `npm:${SDK_NAME}`, version: VERSION },
|
|
1184
1906
|
...release ? { app: { release } } : {},
|
|
1185
|
-
device: { os:
|
|
1907
|
+
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 }
|
|
1186
1908
|
};
|
|
1187
1909
|
}
|
|
1910
|
+
function captureException(error) {
|
|
1911
|
+
return core?.captureException(error, true);
|
|
1912
|
+
}
|
|
1913
|
+
function captureMessage(message, level = "info") {
|
|
1914
|
+
return core?.captureMessage(message, level);
|
|
1915
|
+
}
|
|
1188
1916
|
function captureSecurity(kind, actor, details = {}) {
|
|
1189
1917
|
const context = { kind, actor };
|
|
1190
1918
|
const extra = { outcome: details.outcome, actor_id: details.actorId, ip: details.ip, user_agent: details.userAgent, target: details.target };
|
|
@@ -1192,31 +1920,94 @@ function captureSecurity(kind, actor, details = {}) {
|
|
|
1192
1920
|
if (v !== void 0 && v !== null) context[k] = v;
|
|
1193
1921
|
}
|
|
1194
1922
|
const level = kind === "login_failed" || kind === "login_blocked" ? "warning" : "info";
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1923
|
+
return core?.captureSecurity(kind, `${kind} for ${actor}`, level, SECURITY_KINDS.includes(kind) && actor ? context : void 0);
|
|
1924
|
+
}
|
|
1925
|
+
function setUser(user) {
|
|
1926
|
+
core?.setUser(user);
|
|
1927
|
+
const u = core?.user;
|
|
1928
|
+
try {
|
|
1929
|
+
bridge()?.setUser(u?.id ?? null, u?.email ?? null, u?.username ?? null);
|
|
1930
|
+
} catch {
|
|
1931
|
+
}
|
|
1932
|
+
refreshButton(1e3);
|
|
1933
|
+
}
|
|
1934
|
+
function setTag(key, value) {
|
|
1935
|
+
core?.setTag(key, value);
|
|
1936
|
+
try {
|
|
1937
|
+
bridge()?.setTag(key, String(value));
|
|
1938
|
+
} catch {
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
function addBreadcrumb(crumb) {
|
|
1942
|
+
core?.addBreadcrumb(crumb);
|
|
1943
|
+
}
|
|
1944
|
+
async function flush(timeout = 2e3) {
|
|
1945
|
+
if (!core) return true;
|
|
1946
|
+
const c = core;
|
|
1947
|
+
let timer;
|
|
1948
|
+
const late = new Promise((r) => timer = setTimeout(() => r(false), timeout));
|
|
1949
|
+
const ok = await Promise.race([c.flush().then(() => c.pending === 0), late]);
|
|
1950
|
+
clearTimeout(timer);
|
|
1951
|
+
return ok;
|
|
1952
|
+
}
|
|
1953
|
+
function setEnabled(on) {
|
|
1954
|
+
if (!core) return;
|
|
1955
|
+
core.setEnabled(on);
|
|
1956
|
+
if (!on) screens.clear();
|
|
1957
|
+
if (on) session?.start();
|
|
1958
|
+
else session?.end();
|
|
1959
|
+
}
|
|
1960
|
+
var isEnabled = () => core?.enabled ?? false;
|
|
1961
|
+
var lastEventId = () => core?.lastEventId;
|
|
1962
|
+
function setReplayConsent(granted) {
|
|
1963
|
+
try {
|
|
1964
|
+
bridge()?.setReplayConsent(granted);
|
|
1965
|
+
} catch {
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
function hasReplayConsent() {
|
|
1969
|
+
try {
|
|
1970
|
+
return bridge()?.hasReplayConsent() === true;
|
|
1971
|
+
} catch {
|
|
1972
|
+
return false;
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
function trackNavigation2(ref) {
|
|
1976
|
+
const stop = trackNavigation(() => core, ref);
|
|
1977
|
+
const seen = () => {
|
|
1978
|
+
if (core?.enabled) noteScreen(ref.getCurrentRoute()?.name);
|
|
1979
|
+
};
|
|
1980
|
+
seen();
|
|
1981
|
+
const off = ref.addListener("state", seen);
|
|
1982
|
+
return () => {
|
|
1983
|
+
stop();
|
|
1984
|
+
off();
|
|
1985
|
+
};
|
|
1200
1986
|
}
|
|
1201
1987
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1202
1988
|
0 && (module.exports = {
|
|
1203
1989
|
BlipitReporter,
|
|
1204
1990
|
DEFAULT_ENDPOINT,
|
|
1991
|
+
ErrorBoundary,
|
|
1205
1992
|
VERSION,
|
|
1206
1993
|
addBreadcrumb,
|
|
1207
1994
|
captureException,
|
|
1208
1995
|
captureMessage,
|
|
1209
1996
|
captureSecurity,
|
|
1210
|
-
dsn,
|
|
1211
1997
|
endFlow,
|
|
1212
1998
|
flowStep,
|
|
1213
1999
|
flush,
|
|
2000
|
+
hasReplayConsent,
|
|
1214
2001
|
init,
|
|
2002
|
+
isEnabled,
|
|
2003
|
+
lastEventId,
|
|
1215
2004
|
reportReady,
|
|
2005
|
+
setEnabled,
|
|
2006
|
+
setReplayConsent,
|
|
1216
2007
|
setTag,
|
|
1217
2008
|
setUser,
|
|
1218
2009
|
showReport,
|
|
1219
2010
|
startFlow,
|
|
1220
|
-
|
|
2011
|
+
trackNavigation,
|
|
1221
2012
|
wrap
|
|
1222
2013
|
});
|