@oodle-ai/mobile-sdk-reactnative 0.0.0-stage → 0.1.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/LICENSE +201 -0
- package/OodleMobileSdkReactNative.podspec +24 -0
- package/README.md +191 -2
- package/android/build.gradle +55 -0
- package/android/proguard-rules.pro +5 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/ai/oodle/rum/Connectivity.kt +19 -0
- package/android/src/main/java/ai/oodle/rum/CrashReporter.kt +88 -0
- package/android/src/main/java/ai/oodle/rum/DeviceInfo.kt +50 -0
- package/android/src/main/java/ai/oodle/rum/ExitReasons.kt +104 -0
- package/android/src/main/java/ai/oodle/rum/NativeEvents.kt +24 -0
- package/android/src/main/java/ai/oodle/rum/OodleRumModule.kt +96 -0
- package/android/src/main/java/ai/oodle/rum/OodleRumPackage.kt +26 -0
- package/android/src/main/java/ai/oodle/rum/Storage.kt +84 -0
- package/android/src/main/java/ai/oodle/rum/Vitals.kt +188 -0
- package/android/src/main/java/ai/oodle/rum/Watchdog.kt +81 -0
- package/android/src/main/java/ai/oodle/rum/WireframeCapture.kt +398 -0
- package/bin/oodle-rum-upload.mjs +104 -0
- package/ios/OodleCrashReporter.h +16 -0
- package/ios/OodleCrashReporter.m +202 -0
- package/ios/OodleRum.h +18 -0
- package/ios/OodleRum.mm +129 -0
- package/ios/OodleRumImpl.swift +450 -0
- package/ios/WireframeWalker.swift +279 -0
- package/lib/core/clock.d.ts +19 -0
- package/lib/core/clock.js +47 -0
- package/lib/core/clock.js.map +1 -0
- package/lib/core/config.d.ts +142 -0
- package/lib/core/config.js +178 -0
- package/lib/core/config.js.map +1 -0
- package/lib/core/consent.d.ts +5 -0
- package/lib/core/consent.js +33 -0
- package/lib/core/consent.js.map +1 -0
- package/lib/core/context.d.ts +36 -0
- package/lib/core/context.js +172 -0
- package/lib/core/context.js.map +1 -0
- package/lib/core/flags.d.ts +3 -0
- package/lib/core/flags.js +20 -0
- package/lib/core/flags.js.map +1 -0
- package/lib/core/ids.d.ts +7 -0
- package/lib/core/ids.js +40 -0
- package/lib/core/ids.js.map +1 -0
- package/lib/core/internal.d.ts +6 -0
- package/lib/core/internal.js +10 -0
- package/lib/core/internal.js.map +1 -0
- package/lib/core/logger.d.ts +8 -0
- package/lib/core/logger.js +38 -0
- package/lib/core/logger.js.map +1 -0
- package/lib/core/native.d.ts +71 -0
- package/lib/core/native.js +156 -0
- package/lib/core/native.js.map +1 -0
- package/lib/core/rate-limiter.d.ts +7 -0
- package/lib/core/rate-limiter.js +31 -0
- package/lib/core/rate-limiter.js.map +1 -0
- package/lib/core/session.d.ts +51 -0
- package/lib/core/session.js +196 -0
- package/lib/core/session.js.map +1 -0
- package/lib/core/size.d.ts +15 -0
- package/lib/core/size.js +68 -0
- package/lib/core/size.js.map +1 -0
- package/lib/core/tags.d.ts +10 -0
- package/lib/core/tags.js +33 -0
- package/lib/core/tags.js.map +1 -0
- package/lib/core/telemetry.d.ts +6 -0
- package/lib/core/telemetry.js +37 -0
- package/lib/core/telemetry.js.map +1 -0
- package/lib/core/tracing.d.ts +9 -0
- package/lib/core/tracing.js +57 -0
- package/lib/core/tracing.js.map +1 -0
- package/lib/core/transport.d.ts +76 -0
- package/lib/core/transport.js +560 -0
- package/lib/core/transport.js.map +1 -0
- package/lib/core/user.d.ts +12 -0
- package/lib/core/user.js +41 -0
- package/lib/core/user.js.map +1 -0
- package/lib/events/actions.d.ts +13 -0
- package/lib/events/actions.js +147 -0
- package/lib/events/actions.js.map +1 -0
- package/lib/events/emit.d.ts +21 -0
- package/lib/events/emit.js +144 -0
- package/lib/events/emit.js.map +1 -0
- package/lib/events/errors.d.ts +19 -0
- package/lib/events/errors.js +257 -0
- package/lib/events/errors.js.map +1 -0
- package/lib/events/lifecycle.d.ts +7 -0
- package/lib/events/lifecycle.js +101 -0
- package/lib/events/lifecycle.js.map +1 -0
- package/lib/events/longtasks.d.ts +2 -0
- package/lib/events/longtasks.js +42 -0
- package/lib/events/longtasks.js.map +1 -0
- package/lib/events/resources.d.ts +15 -0
- package/lib/events/resources.js +156 -0
- package/lib/events/resources.js.map +1 -0
- package/lib/events/tap-target.d.ts +42 -0
- package/lib/events/tap-target.js +191 -0
- package/lib/events/tap-target.js.map +1 -0
- package/lib/events/view-state.d.ts +13 -0
- package/lib/events/view-state.js +25 -0
- package/lib/events/view-state.js.map +1 -0
- package/lib/events/views.d.ts +21 -0
- package/lib/events/views.js +347 -0
- package/lib/events/views.js.map +1 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +24 -0
- package/lib/index.js.map +1 -0
- package/lib/navigation/react-navigation.d.ts +33 -0
- package/lib/navigation/react-navigation.js +61 -0
- package/lib/navigation/react-navigation.js.map +1 -0
- package/lib/react/OodlePrivacy.d.ts +15 -0
- package/lib/react/OodlePrivacy.js +13 -0
- package/lib/react/OodlePrivacy.js.map +1 -0
- package/lib/react/OodleProvider.d.ts +18 -0
- package/lib/react/OodleProvider.js +72 -0
- package/lib/react/OodleProvider.js.map +1 -0
- package/lib/replay/recorder.d.ts +22 -0
- package/lib/replay/recorder.js +317 -0
- package/lib/replay/recorder.js.map +1 -0
- package/lib/replay/rrweb.d.ts +105 -0
- package/lib/replay/rrweb.js +335 -0
- package/lib/replay/rrweb.js.map +1 -0
- package/lib/rum.d.ts +52 -0
- package/lib/rum.js +281 -0
- package/lib/rum.js.map +1 -0
- package/lib/specs/NativeOodleRum.d.ts +43 -0
- package/lib/specs/NativeOodleRum.js +5 -0
- package/lib/specs/NativeOodleRum.js.map +1 -0
- package/lib/version.d.ts +1 -0
- package/lib/version.js +6 -0
- package/lib/version.js.map +1 -0
- package/package.json +91 -4
- package/react-native.config.js +10 -0
- package/src/core/clock.ts +43 -0
- package/src/core/config.ts +344 -0
- package/src/core/consent.ts +32 -0
- package/src/core/context.ts +189 -0
- package/src/core/flags.ts +15 -0
- package/src/core/ids.ts +35 -0
- package/src/core/internal.ts +6 -0
- package/src/core/logger.ts +37 -0
- package/src/core/native.ts +201 -0
- package/src/core/rate-limiter.ts +34 -0
- package/src/core/session.ts +209 -0
- package/src/core/size.ts +79 -0
- package/src/core/tags.ts +30 -0
- package/src/core/telemetry.ts +35 -0
- package/src/core/tracing.ts +60 -0
- package/src/core/transport.ts +590 -0
- package/src/core/user.ts +45 -0
- package/src/events/actions.ts +157 -0
- package/src/events/emit.ts +131 -0
- package/src/events/errors.ts +283 -0
- package/src/events/lifecycle.ts +102 -0
- package/src/events/longtasks.ts +40 -0
- package/src/events/resources.ts +167 -0
- package/src/events/tap-target.ts +210 -0
- package/src/events/view-state.ts +30 -0
- package/src/events/views.ts +356 -0
- package/src/index.ts +34 -0
- package/src/navigation/react-navigation.ts +72 -0
- package/src/react/OodlePrivacy.tsx +25 -0
- package/src/react/OodleProvider.tsx +88 -0
- package/src/replay/recorder.ts +310 -0
- package/src/replay/rrweb.ts +460 -0
- package/src/rum.ts +295 -0
- package/src/specs/NativeOodleRum.ts +51 -0
- package/src/version.ts +2 -0
|
@@ -0,0 +1,560 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TELEMETRY_BATCH_KEY = exports.REPLAY_BATCH_KEY = exports.EVENTS_BATCH_KEY = exports.INGEST_PATH = void 0;
|
|
4
|
+
exports.setPoster = setPoster;
|
|
5
|
+
exports.setCanSend = setCanSend;
|
|
6
|
+
exports.setReplayDropHandler = setReplayDropHandler;
|
|
7
|
+
exports.enqueue = enqueue;
|
|
8
|
+
exports.upsert = upsert;
|
|
9
|
+
exports.buildEnvelope = buildEnvelope;
|
|
10
|
+
exports.flush = flush;
|
|
11
|
+
exports.isServerRateLimited = isServerRateLimited;
|
|
12
|
+
exports.retryDelayMs = retryDelayMs;
|
|
13
|
+
exports.persistOutbox = persistOutbox;
|
|
14
|
+
exports.restoreOutbox = restoreOutbox;
|
|
15
|
+
exports.clearAll = clearAll;
|
|
16
|
+
exports.resume = resume;
|
|
17
|
+
exports.resetTransport = resetTransport;
|
|
18
|
+
exports.pendingCounts = pendingCounts;
|
|
19
|
+
const clock_1 = require("./clock");
|
|
20
|
+
const fflate_1 = require("fflate");
|
|
21
|
+
const react_native_1 = require("react-native");
|
|
22
|
+
const version_1 = require("../version");
|
|
23
|
+
const config_1 = require("./config");
|
|
24
|
+
const internal_1 = require("./internal");
|
|
25
|
+
const logger_1 = require("./logger");
|
|
26
|
+
const native_1 = require("./native");
|
|
27
|
+
const size_1 = require("./size");
|
|
28
|
+
const telemetry_1 = require("./telemetry");
|
|
29
|
+
exports.INGEST_PATH = '/v1/rum/ingest';
|
|
30
|
+
exports.EVENTS_BATCH_KEY = 'events';
|
|
31
|
+
exports.REPLAY_BATCH_KEY = 'replay';
|
|
32
|
+
exports.TELEMETRY_BATCH_KEY = 'sdk_telemetry';
|
|
33
|
+
const MAX_BATCH_ITEMS = 50;
|
|
34
|
+
const MAX_BATCH_BYTES = 500000;
|
|
35
|
+
const MAX_ITEM_BYTES = 256000;
|
|
36
|
+
const REPLAY_MEASURE_LIMIT = 64000;
|
|
37
|
+
/** Items held while consent is pending, per batch key. */
|
|
38
|
+
const MAX_HELD_ITEMS = 1000;
|
|
39
|
+
const MAX_IN_FLIGHT = 4;
|
|
40
|
+
const MAX_RETRY_BYTES = 10000000;
|
|
41
|
+
const MAX_RETRY_ATTEMPTS = 8;
|
|
42
|
+
const INITIAL_BACKOFF_MS = 1000;
|
|
43
|
+
const MAX_BACKOFF_MS = 60000;
|
|
44
|
+
const REQUEST_TIMEOUT_MS = 30000;
|
|
45
|
+
/** Upper bound for the outbox that survives an app restart. */
|
|
46
|
+
const MAX_OUTBOX_CHARS = 4000000;
|
|
47
|
+
const OUTBOX_KEY = 'outbox';
|
|
48
|
+
const FLUSH_ORDER = [exports.EVENTS_BATCH_KEY, exports.REPLAY_BATCH_KEY, exports.TELEMETRY_BATCH_KEY];
|
|
49
|
+
const queues = new Map();
|
|
50
|
+
let retryQueue = [];
|
|
51
|
+
let retryBytes = 0;
|
|
52
|
+
let retryTimer = null;
|
|
53
|
+
let flushTimer = null;
|
|
54
|
+
let persistTimer = null;
|
|
55
|
+
/** True after this process wrote an outbox that it has not removed. */
|
|
56
|
+
let outboxOnDisk = false;
|
|
57
|
+
/** True when that outbox also holds items from the batch queues. */
|
|
58
|
+
let outboxHasHeld = false;
|
|
59
|
+
/** Bodies sent and not yet answered. The outbox keeps them, see persistOutbox. */
|
|
60
|
+
const inFlight = new Set();
|
|
61
|
+
let canSend = () => true;
|
|
62
|
+
let replayDropHandler = null;
|
|
63
|
+
let authWarned = false;
|
|
64
|
+
const rateLimitedUntil = new Map();
|
|
65
|
+
function xhrPost(url, headers, body) {
|
|
66
|
+
return new Promise((resolve, reject) => {
|
|
67
|
+
const xhr = new XMLHttpRequest();
|
|
68
|
+
xhr[internal_1.INTERNAL_REQUEST] = true;
|
|
69
|
+
xhr.open('POST', url, true);
|
|
70
|
+
for (const [k, v] of Object.entries(headers))
|
|
71
|
+
xhr.setRequestHeader(k, v);
|
|
72
|
+
xhr.timeout = REQUEST_TIMEOUT_MS;
|
|
73
|
+
xhr.onload = () => resolve({
|
|
74
|
+
status: xhr.status,
|
|
75
|
+
rateLimits: xhr.getResponseHeader('X-Oodle-Rate-Limits'),
|
|
76
|
+
date: xhr.getResponseHeader('Date'),
|
|
77
|
+
});
|
|
78
|
+
xhr.onerror = () => reject(new Error('network error'));
|
|
79
|
+
xhr.ontimeout = () => reject(new Error('timeout'));
|
|
80
|
+
// React Native sends a typed array body as raw bytes.
|
|
81
|
+
xhr.send(body);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
let poster = xhrPost;
|
|
85
|
+
/** Test hook: replace the HTTP client. */
|
|
86
|
+
function setPoster(p) {
|
|
87
|
+
poster = p ?? xhrPost;
|
|
88
|
+
}
|
|
89
|
+
/** Events stay queued while this returns false (consent is pending). */
|
|
90
|
+
function setCanSend(fn) {
|
|
91
|
+
canSend = fn;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Lets the replay recorder start a new full snapshot when a segment is
|
|
95
|
+
* lost. rrweb events are deltas, so a lost segment breaks every later
|
|
96
|
+
* event until the next full snapshot.
|
|
97
|
+
*/
|
|
98
|
+
function setReplayDropHandler(fn) {
|
|
99
|
+
replayDropHandler = fn;
|
|
100
|
+
}
|
|
101
|
+
function onDropped(carriesReplay) {
|
|
102
|
+
(0, telemetry_1.incrTelemetry)('transport_drops');
|
|
103
|
+
if (carriesReplay && replayDropHandler)
|
|
104
|
+
replayDropHandler();
|
|
105
|
+
}
|
|
106
|
+
function getQueue(key) {
|
|
107
|
+
let q = queues.get(key);
|
|
108
|
+
if (!q) {
|
|
109
|
+
q = { items: [], upsertIndex: new Map(), bytes: 0 };
|
|
110
|
+
queues.set(key, q);
|
|
111
|
+
}
|
|
112
|
+
return q;
|
|
113
|
+
}
|
|
114
|
+
function measure(key, item, hint) {
|
|
115
|
+
if (key === exports.REPLAY_BATCH_KEY) {
|
|
116
|
+
// A full snapshot cannot be split, and the recorder already bounds
|
|
117
|
+
// segment size, so replay items are never rejected for size.
|
|
118
|
+
return {
|
|
119
|
+
bytes: hint ?? (0, size_1.estimateJsonBytes)(item, REPLAY_MEASURE_LIMIT),
|
|
120
|
+
oversized: false,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
const bytes = (0, size_1.estimateJsonBytes)(item, MAX_ITEM_BYTES + 1);
|
|
124
|
+
return { bytes, oversized: bytes > MAX_ITEM_BYTES };
|
|
125
|
+
}
|
|
126
|
+
function trimHeld(key, q) {
|
|
127
|
+
if (canSend() || q.items.length <= MAX_HELD_ITEMS)
|
|
128
|
+
return;
|
|
129
|
+
const drop = q.items.length - MAX_HELD_ITEMS;
|
|
130
|
+
q.items.splice(0, drop);
|
|
131
|
+
q.upsertIndex.clear();
|
|
132
|
+
q.bytes = 0;
|
|
133
|
+
(0, telemetry_1.incrTelemetry)('events_should_send_dropped', drop);
|
|
134
|
+
if (key === exports.REPLAY_BATCH_KEY && replayDropHandler)
|
|
135
|
+
replayDropHandler();
|
|
136
|
+
}
|
|
137
|
+
function afterAdd(q) {
|
|
138
|
+
if (canSend() &&
|
|
139
|
+
(q.items.length >= MAX_BATCH_ITEMS || q.bytes >= MAX_BATCH_BYTES)) {
|
|
140
|
+
flush();
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
scheduleFlush();
|
|
144
|
+
}
|
|
145
|
+
function enqueue(key, item, bytesHint) {
|
|
146
|
+
const { bytes, oversized } = measure(key, item, bytesHint);
|
|
147
|
+
if (oversized) {
|
|
148
|
+
logger_1.logger.warn(`Dropping a ${key} item of ${bytes} bytes`);
|
|
149
|
+
onDropped(key === exports.REPLAY_BATCH_KEY);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const q = getQueue(key);
|
|
153
|
+
q.items.push(item);
|
|
154
|
+
q.bytes += bytes;
|
|
155
|
+
trimHeld(key, q);
|
|
156
|
+
afterAdd(q);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Replaces the queued item with the same key, or adds it. `merge` sees the
|
|
160
|
+
* queued item and the new one, and returns what to keep.
|
|
161
|
+
*/
|
|
162
|
+
function upsert(key, itemKey, item, merge) {
|
|
163
|
+
const { bytes, oversized } = measure(key, item);
|
|
164
|
+
if (oversized) {
|
|
165
|
+
onDropped(false);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const q = getQueue(key);
|
|
169
|
+
const at = q.upsertIndex.get(itemKey);
|
|
170
|
+
if (at !== undefined) {
|
|
171
|
+
const kept = merge ? merge(q.items[at], item) : item;
|
|
172
|
+
q.bytes += bytes - measure(key, q.items[at]).bytes;
|
|
173
|
+
q.items[at] = kept;
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
q.upsertIndex.set(itemKey, q.items.length);
|
|
177
|
+
q.items.push(item);
|
|
178
|
+
q.bytes += bytes;
|
|
179
|
+
}
|
|
180
|
+
trimHeld(key, q);
|
|
181
|
+
afterAdd(q);
|
|
182
|
+
}
|
|
183
|
+
function scheduleFlush() {
|
|
184
|
+
if (flushTimer)
|
|
185
|
+
return;
|
|
186
|
+
const interval = (0, config_1.getConfig)()?.flushIntervalMs ?? 5000;
|
|
187
|
+
flushTimer = setTimeout(() => {
|
|
188
|
+
flushTimer = null;
|
|
189
|
+
flush();
|
|
190
|
+
}, interval);
|
|
191
|
+
}
|
|
192
|
+
function buildEnvelope(sections) {
|
|
193
|
+
let sessionId = '';
|
|
194
|
+
for (const s of sections) {
|
|
195
|
+
const first = s.items[0];
|
|
196
|
+
if (first && typeof first.session_id === 'string') {
|
|
197
|
+
sessionId = first.session_id;
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const lines = [JSON.stringify({ session_id: sessionId, sdk_version: version_1.SDK_VERSION })];
|
|
202
|
+
for (const s of sections) {
|
|
203
|
+
lines.push(JSON.stringify({ type: s.type, count: s.items.length }));
|
|
204
|
+
lines.push(JSON.stringify(s.items));
|
|
205
|
+
}
|
|
206
|
+
return lines.join('\n');
|
|
207
|
+
}
|
|
208
|
+
function takeSections() {
|
|
209
|
+
const keys = Array.from(queues.keys()).sort((a, b) => {
|
|
210
|
+
const ai = FLUSH_ORDER.indexOf(a);
|
|
211
|
+
const bi = FLUSH_ORDER.indexOf(b);
|
|
212
|
+
return (ai < 0 ? 99 : ai) - (bi < 0 ? 99 : bi);
|
|
213
|
+
});
|
|
214
|
+
const sections = [];
|
|
215
|
+
for (const key of keys) {
|
|
216
|
+
const q = queues.get(key);
|
|
217
|
+
if (q.items.length === 0)
|
|
218
|
+
continue;
|
|
219
|
+
sections.push({ type: key, items: q.items.splice(0) });
|
|
220
|
+
q.upsertIndex.clear();
|
|
221
|
+
q.bytes = 0;
|
|
222
|
+
}
|
|
223
|
+
return sections;
|
|
224
|
+
}
|
|
225
|
+
/** Sends everything queued now. No-op while consent is pending. */
|
|
226
|
+
function flush() {
|
|
227
|
+
if (flushTimer) {
|
|
228
|
+
clearTimeout(flushTimer);
|
|
229
|
+
flushTimer = null;
|
|
230
|
+
}
|
|
231
|
+
if (!(0, config_1.getConfig)() || !canSend())
|
|
232
|
+
return;
|
|
233
|
+
const sections = takeSections();
|
|
234
|
+
if (sections.length === 0)
|
|
235
|
+
return;
|
|
236
|
+
const body = buildEnvelope(sections);
|
|
237
|
+
const carriesReplay = sections.some((s) => s.type === exports.REPLAY_BATCH_KEY);
|
|
238
|
+
void sendBody({ body, attempts: 0, carriesReplay, notBefore: 0 });
|
|
239
|
+
}
|
|
240
|
+
function headers() {
|
|
241
|
+
const c = (0, config_1.getConfig)();
|
|
242
|
+
return {
|
|
243
|
+
'X-OODLE-INSTANCE': c.instanceId,
|
|
244
|
+
'X-API-KEY': c.apiKey,
|
|
245
|
+
'Content-Type': 'application/json',
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* React Native on Android removes `Content-Encoding` from a request with
|
|
250
|
+
* a binary body, so a body compressed in JS arrives without the header
|
|
251
|
+
* and the collector cannot read it. For a string body with
|
|
252
|
+
* `Content-Encoding: gzip`, Android compresses the body itself, off the
|
|
253
|
+
* JS thread. iOS sends the body as given, so there it is compressed in JS.
|
|
254
|
+
*/
|
|
255
|
+
function compress(raw) {
|
|
256
|
+
if (react_native_1.Platform.OS === 'android')
|
|
257
|
+
return { body: raw, gzip: true };
|
|
258
|
+
try {
|
|
259
|
+
return { body: (0, fflate_1.gzipSync)((0, fflate_1.strToU8)(raw)), gzip: true };
|
|
260
|
+
}
|
|
261
|
+
catch {
|
|
262
|
+
(0, telemetry_1.incrTelemetry)('compression_failures');
|
|
263
|
+
return { body: raw, gzip: false };
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
function parseRateLimits(header) {
|
|
267
|
+
if (!header)
|
|
268
|
+
return;
|
|
269
|
+
const now = Date.now();
|
|
270
|
+
for (const part of header.split(',')) {
|
|
271
|
+
const [cat, secs] = part.trim().split(':');
|
|
272
|
+
const n = parseInt(secs ?? '', 10);
|
|
273
|
+
if (cat && Number.isFinite(n))
|
|
274
|
+
rateLimitedUntil.set(cat, now + n * 1000);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
function isServerRateLimited(category) {
|
|
278
|
+
const until = rateLimitedUntil.get(category);
|
|
279
|
+
if (!until)
|
|
280
|
+
return false;
|
|
281
|
+
if (Date.now() >= until) {
|
|
282
|
+
rateLimitedUntil.delete(category);
|
|
283
|
+
return false;
|
|
284
|
+
}
|
|
285
|
+
return true;
|
|
286
|
+
}
|
|
287
|
+
async function sendBody(item) {
|
|
288
|
+
const config = (0, config_1.getConfig)();
|
|
289
|
+
if (!config)
|
|
290
|
+
return;
|
|
291
|
+
if (inFlight.size >= MAX_IN_FLIGHT) {
|
|
292
|
+
addRetry(item, false);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
inFlight.add(item);
|
|
296
|
+
try {
|
|
297
|
+
const { body, gzip } = compress(item.body);
|
|
298
|
+
const h = headers();
|
|
299
|
+
if (gzip)
|
|
300
|
+
h['Content-Encoding'] = 'gzip';
|
|
301
|
+
const sentAt = Date.now();
|
|
302
|
+
const res = await poster(`${config.endpoint}${exports.INGEST_PATH}`, h, body);
|
|
303
|
+
if (res.status > 0)
|
|
304
|
+
(0, clock_1.observeServerDate)(res.date, sentAt, Date.now());
|
|
305
|
+
parseRateLimits(res.rateLimits);
|
|
306
|
+
if (res.status === 429 || res.status >= 500 || res.status === 0) {
|
|
307
|
+
inFlight.delete(item);
|
|
308
|
+
addRetry(item, true);
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
if (res.status >= 400) {
|
|
312
|
+
// The request itself is wrong (bad key, bad body). Sending it
|
|
313
|
+
// again cannot succeed.
|
|
314
|
+
if ((res.status === 401 || res.status === 403) && !authWarned) {
|
|
315
|
+
authWarned = true;
|
|
316
|
+
logger_1.logger.error(`The collector rejected the API key (HTTP ${res.status}). ` +
|
|
317
|
+
'Check apiKey and instanceId.');
|
|
318
|
+
}
|
|
319
|
+
onDropped(item.carriesReplay);
|
|
320
|
+
}
|
|
321
|
+
inFlight.delete(item);
|
|
322
|
+
syncOutboxAfterSend();
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
catch {
|
|
326
|
+
inFlight.delete(item);
|
|
327
|
+
(0, telemetry_1.incrTelemetry)('send_failures');
|
|
328
|
+
addRetry(item, true);
|
|
329
|
+
}
|
|
330
|
+
finally {
|
|
331
|
+
drainRetries();
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Called when a body has its final answer. The outbox on disk can still
|
|
336
|
+
* hold it, and the next start would send it again. When no other body
|
|
337
|
+
* waits for an answer, the outbox is removed now. Otherwise it is
|
|
338
|
+
* written again after the usual delay, so that a queue that drains after
|
|
339
|
+
* an outage is not serialized once per body.
|
|
340
|
+
*
|
|
341
|
+
* Items in the batch queues count only when the outbox holds them (after
|
|
342
|
+
* a fatal error, or a background while sending was paused). Usually they
|
|
343
|
+
* are not on disk, and writing them after each send would serialize the
|
|
344
|
+
* queue on every flush.
|
|
345
|
+
*/
|
|
346
|
+
function syncOutboxAfterSend() {
|
|
347
|
+
if (!outboxOnDisk)
|
|
348
|
+
return;
|
|
349
|
+
if (retryQueue.length > 0 || inFlight.size > 0 || outboxHasHeld)
|
|
350
|
+
schedulePersist();
|
|
351
|
+
else
|
|
352
|
+
removeOutbox();
|
|
353
|
+
}
|
|
354
|
+
function removeOutbox() {
|
|
355
|
+
if (persistTimer) {
|
|
356
|
+
clearTimeout(persistTimer);
|
|
357
|
+
persistTimer = null;
|
|
358
|
+
}
|
|
359
|
+
native_1.storage.remove(OUTBOX_KEY);
|
|
360
|
+
outboxOnDisk = false;
|
|
361
|
+
outboxHasHeld = false;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Returns the wait before retry number `attempts`, a random value
|
|
365
|
+
* between half and all of the exponential step.
|
|
366
|
+
*
|
|
367
|
+
* Without the random part, all devices that lost the collector at the
|
|
368
|
+
* same time retry at the same times, and each wave of retries can make
|
|
369
|
+
* the collector fail again when it comes back. The lower half stays fixed
|
|
370
|
+
* so that a collector that fails fast is not sent requests in a loop.
|
|
371
|
+
*/
|
|
372
|
+
function retryDelayMs(attempts, random = Math.random) {
|
|
373
|
+
const step = Math.min(INITIAL_BACKOFF_MS * Math.pow(2, attempts - 1), MAX_BACKOFF_MS);
|
|
374
|
+
return Math.round(step / 2 + random() * (step / 2));
|
|
375
|
+
}
|
|
376
|
+
function addRetry(item, failed) {
|
|
377
|
+
const attempts = failed ? item.attempts + 1 : item.attempts;
|
|
378
|
+
if (attempts > MAX_RETRY_ATTEMPTS) {
|
|
379
|
+
(0, telemetry_1.incrTelemetry)('retry_drops');
|
|
380
|
+
onDropped(item.carriesReplay);
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
const next = {
|
|
384
|
+
...item,
|
|
385
|
+
attempts,
|
|
386
|
+
notBefore: failed ? Date.now() + retryDelayMs(attempts) : 0,
|
|
387
|
+
};
|
|
388
|
+
while (retryBytes + next.body.length > MAX_RETRY_BYTES && retryQueue.length > 0) {
|
|
389
|
+
const old = retryQueue.shift();
|
|
390
|
+
retryBytes -= old.body.length;
|
|
391
|
+
(0, telemetry_1.incrTelemetry)('retry_drops');
|
|
392
|
+
onDropped(old.carriesReplay);
|
|
393
|
+
}
|
|
394
|
+
// A failed body goes back to the front: replay segments must reach
|
|
395
|
+
// the server in the order they were recorded.
|
|
396
|
+
if (failed)
|
|
397
|
+
retryQueue.unshift(next);
|
|
398
|
+
else
|
|
399
|
+
retryQueue.push(next);
|
|
400
|
+
retryBytes += next.body.length;
|
|
401
|
+
schedulePersist();
|
|
402
|
+
}
|
|
403
|
+
function drainRetries() {
|
|
404
|
+
if (retryTimer) {
|
|
405
|
+
clearTimeout(retryTimer);
|
|
406
|
+
retryTimer = null;
|
|
407
|
+
}
|
|
408
|
+
if (!(0, config_1.getConfig)() || !canSend())
|
|
409
|
+
return;
|
|
410
|
+
while (retryQueue.length > 0 && inFlight.size < MAX_IN_FLIGHT) {
|
|
411
|
+
const head = retryQueue[0];
|
|
412
|
+
const wait = head.notBefore - Date.now();
|
|
413
|
+
if (wait > 0) {
|
|
414
|
+
retryTimer = setTimeout(() => {
|
|
415
|
+
retryTimer = null;
|
|
416
|
+
drainRetries();
|
|
417
|
+
}, wait);
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
retryQueue.shift();
|
|
421
|
+
retryBytes -= head.body.length;
|
|
422
|
+
void sendBody(head);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
function schedulePersist() {
|
|
426
|
+
if (persistTimer)
|
|
427
|
+
return;
|
|
428
|
+
persistTimer = setTimeout(() => {
|
|
429
|
+
persistTimer = null;
|
|
430
|
+
persistOutbox();
|
|
431
|
+
}, 2000);
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Writes unsent data to disk. Called when the app goes to the background,
|
|
435
|
+
* after a failed send, and from the fatal error handler, so an app that
|
|
436
|
+
* is killed or crashes sends the data on its next start.
|
|
437
|
+
*
|
|
438
|
+
* Bodies in flight are written too: the app often goes to the background
|
|
439
|
+
* just after a flush, and the OS can end it before the answer comes.
|
|
440
|
+
* When the answer comes, syncOutboxAfterSend takes them out again.
|
|
441
|
+
*
|
|
442
|
+
* The file write runs on a native background thread, so a large queue
|
|
443
|
+
* does not block the JS thread. Only the fatal error handler uses
|
|
444
|
+
* `sync`, because the process can end as soon as it returns.
|
|
445
|
+
*/
|
|
446
|
+
function persistOutbox(opts = {}) {
|
|
447
|
+
if (persistTimer) {
|
|
448
|
+
clearTimeout(persistTimer);
|
|
449
|
+
persistTimer = null;
|
|
450
|
+
}
|
|
451
|
+
const held = {};
|
|
452
|
+
for (const [key, q] of queues)
|
|
453
|
+
if (q.items.length > 0)
|
|
454
|
+
held[key] = q.items.slice();
|
|
455
|
+
const retry = [...inFlight, ...retryQueue].map((r) => ({ ...r, notBefore: 0 }));
|
|
456
|
+
if (retry.length === 0 && Object.keys(held).length === 0) {
|
|
457
|
+
removeOutbox();
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
// Drop the oldest retries by their body size first, so the queue is
|
|
461
|
+
// serialized once and not once per dropped item.
|
|
462
|
+
let retryChars = 0;
|
|
463
|
+
for (const r of retry)
|
|
464
|
+
retryChars += r.body.length;
|
|
465
|
+
while (retry.length > 0 && retryChars > MAX_OUTBOX_CHARS) {
|
|
466
|
+
retryChars -= retry.shift().body.length;
|
|
467
|
+
(0, telemetry_1.incrTelemetry)('outbox_drops');
|
|
468
|
+
}
|
|
469
|
+
let raw = JSON.stringify({ retry, held });
|
|
470
|
+
while (raw.length > MAX_OUTBOX_CHARS && retry.length > 0) {
|
|
471
|
+
retry.shift();
|
|
472
|
+
(0, telemetry_1.incrTelemetry)('outbox_drops');
|
|
473
|
+
raw = JSON.stringify({ retry, held });
|
|
474
|
+
}
|
|
475
|
+
if (raw.length > MAX_OUTBOX_CHARS) {
|
|
476
|
+
(0, telemetry_1.incrTelemetry)('outbox_drops');
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
if (opts.sync)
|
|
480
|
+
native_1.storage.set(OUTBOX_KEY, raw);
|
|
481
|
+
else
|
|
482
|
+
native_1.storage.setAsync(OUTBOX_KEY, raw);
|
|
483
|
+
outboxOnDisk = true;
|
|
484
|
+
outboxHasHeld = Object.keys(held).length > 0;
|
|
485
|
+
}
|
|
486
|
+
/** Loads the outbox written by an earlier run and queues it to send. */
|
|
487
|
+
function restoreOutbox() {
|
|
488
|
+
const box = native_1.storage.getJSON(OUTBOX_KEY, null);
|
|
489
|
+
removeOutbox();
|
|
490
|
+
if (!box)
|
|
491
|
+
return;
|
|
492
|
+
for (const r of box.retry ?? []) {
|
|
493
|
+
if (typeof r.body !== 'string')
|
|
494
|
+
continue;
|
|
495
|
+
retryQueue.push({
|
|
496
|
+
body: r.body,
|
|
497
|
+
attempts: 0,
|
|
498
|
+
carriesReplay: !!r.carriesReplay,
|
|
499
|
+
notBefore: 0,
|
|
500
|
+
});
|
|
501
|
+
retryBytes += r.body.length;
|
|
502
|
+
}
|
|
503
|
+
for (const [key, items] of Object.entries(box.held ?? {})) {
|
|
504
|
+
if (!Array.isArray(items))
|
|
505
|
+
continue;
|
|
506
|
+
const q = getQueue(key);
|
|
507
|
+
for (const item of items) {
|
|
508
|
+
q.items.push(item);
|
|
509
|
+
q.bytes += measure(key, item).bytes;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
if (canSend()) {
|
|
513
|
+
flush();
|
|
514
|
+
drainRetries();
|
|
515
|
+
}
|
|
516
|
+
else {
|
|
517
|
+
scheduleFlush();
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
/** Drops everything queued, held and persisted (consent withdrawn). */
|
|
521
|
+
function clearAll() {
|
|
522
|
+
for (const q of queues.values()) {
|
|
523
|
+
q.items.length = 0;
|
|
524
|
+
q.upsertIndex.clear();
|
|
525
|
+
q.bytes = 0;
|
|
526
|
+
}
|
|
527
|
+
retryQueue = [];
|
|
528
|
+
retryBytes = 0;
|
|
529
|
+
removeOutbox();
|
|
530
|
+
}
|
|
531
|
+
/** Starts sending again after consent changes to granted. */
|
|
532
|
+
function resume() {
|
|
533
|
+
flush();
|
|
534
|
+
drainRetries();
|
|
535
|
+
}
|
|
536
|
+
/** Test hook. */
|
|
537
|
+
function resetTransport() {
|
|
538
|
+
for (const t of [retryTimer, flushTimer, persistTimer])
|
|
539
|
+
if (t)
|
|
540
|
+
clearTimeout(t);
|
|
541
|
+
retryTimer = flushTimer = persistTimer = null;
|
|
542
|
+
queues.clear();
|
|
543
|
+
retryQueue = [];
|
|
544
|
+
retryBytes = 0;
|
|
545
|
+
outboxOnDisk = outboxHasHeld = false;
|
|
546
|
+
inFlight.clear();
|
|
547
|
+
canSend = () => true;
|
|
548
|
+
replayDropHandler = null;
|
|
549
|
+
authWarned = false;
|
|
550
|
+
rateLimitedUntil.clear();
|
|
551
|
+
poster = xhrPost;
|
|
552
|
+
}
|
|
553
|
+
/** Test hook. */
|
|
554
|
+
function pendingCounts() {
|
|
555
|
+
const out = {};
|
|
556
|
+
for (const [k, q] of queues)
|
|
557
|
+
out[k] = q.items.length;
|
|
558
|
+
return { queues: out, retries: retryQueue.length, inFlight: inFlight.size };
|
|
559
|
+
}
|
|
560
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/core/transport.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,mCAA4C;AAC5C,mCAA2C;AAC3C,+CAAwC;AACxC,wCAAyC;AACzC,qCAAqC;AACrC,yCAA8C;AAC9C,qCAAkC;AAClC,qCAAmC;AACnC,iCAA2C;AAC3C,2CAA4C;AAI/B,QAAA,WAAW,GAAG,gBAAgB,CAAC;AAC/B,QAAA,gBAAgB,GAAG,QAAQ,CAAC;AAC5B,QAAA,gBAAgB,GAAG,QAAQ,CAAC;AAC5B,QAAA,mBAAmB,GAAG,eAAe,CAAC;AAEnD,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MAAM,eAAe,GAAG,MAAO,CAAC;AAChC,MAAM,cAAc,GAAG,MAAO,CAAC;AAC/B,MAAM,oBAAoB,GAAG,KAAM,CAAC;AACpC,0DAA0D;AAC1D,MAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,eAAe,GAAG,QAAU,CAAC;AACnC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,cAAc,GAAG,KAAM,CAAC;AAC9B,MAAM,kBAAkB,GAAG,KAAM,CAAC;AAClC,+DAA+D;AAC/D,MAAM,gBAAgB,GAAG,OAAS,CAAC;AACnC,MAAM,UAAU,GAAG,QAAQ,CAAC;AAC5B,MAAM,WA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AC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;IACrD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,UAAU,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TagValue } from './config';
|
|
2
|
+
export interface UserInfo {
|
|
3
|
+
id: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
email?: string;
|
|
6
|
+
/** Other user attributes. They are sent as `usr.<key>` tags. */
|
|
7
|
+
[key: string]: TagValue | undefined;
|
|
8
|
+
}
|
|
9
|
+
export declare function setUser(next: UserInfo): void;
|
|
10
|
+
export declare function clearUser(): void;
|
|
11
|
+
export declare function getUser(): UserInfo | null;
|
|
12
|
+
export declare function userFields(): Record<string, string>;
|
package/lib/core/user.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setUser = setUser;
|
|
4
|
+
exports.clearUser = clearUser;
|
|
5
|
+
exports.getUser = getUser;
|
|
6
|
+
exports.userFields = userFields;
|
|
7
|
+
const tags_1 = require("./tags");
|
|
8
|
+
let user = null;
|
|
9
|
+
let extraKeys = [];
|
|
10
|
+
function setUser(next) {
|
|
11
|
+
clearUser();
|
|
12
|
+
user = { ...next };
|
|
13
|
+
const extra = {};
|
|
14
|
+
for (const [k, v] of Object.entries(next)) {
|
|
15
|
+
if (k === 'id' || k === 'name' || k === 'email')
|
|
16
|
+
continue;
|
|
17
|
+
if (v === undefined || v === null)
|
|
18
|
+
continue;
|
|
19
|
+
extra[`usr.${k}`] = v;
|
|
20
|
+
}
|
|
21
|
+
extraKeys = Object.keys(extra);
|
|
22
|
+
(0, tags_1.setTags)(extra);
|
|
23
|
+
}
|
|
24
|
+
function clearUser() {
|
|
25
|
+
user = null;
|
|
26
|
+
for (const k of extraKeys)
|
|
27
|
+
(0, tags_1.removeTag)(k);
|
|
28
|
+
extraKeys = [];
|
|
29
|
+
}
|
|
30
|
+
function getUser() {
|
|
31
|
+
return user;
|
|
32
|
+
}
|
|
33
|
+
function userFields() {
|
|
34
|
+
return {
|
|
35
|
+
user_id: user?.id ? String(user.id) : '',
|
|
36
|
+
user_name: user?.name ? String(user.name) : '',
|
|
37
|
+
user_email: user?.email ? String(user.email) : '',
|
|
38
|
+
user_status: user ? 'identified' : 'anonymous',
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=user.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../src/core/user.ts"],"names":[],"mappings":";;;;;;AACA,iCAA4C;AAU5C,IAAI,IAAI,GAAoB,IAAI,CAAC;AACjC,IAAI,SAAS,GAAa,EAAE,CAAC;AAE7B,iBAAwB,IAAc;IACpC,SAAS,EAAE,CAAC;IACZ,IAAI,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;IACnB,MAAM,KAAK,GAA6B,EAAE,CAAC;IAC3C,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1C,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,MAAM,IAAI,CAAC,KAAK,OAAO;YAAE,SAAS;QAC1D,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI;YAAE,SAAS;QAC5C,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IACD,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/B,IAAA,cAAO,EAAC,KAAK,CAAC,CAAC;AACjB,CAAC;AAED;IACE,IAAI,GAAG,IAAI,CAAC;IACZ,KAAK,MAAM,CAAC,IAAI,SAAS;QAAE,IAAA,gBAAS,EAAC,CAAC,CAAC,CAAC;IACxC,SAAS,GAAG,EAAE,CAAC;AACjB,CAAC;AAED;IACE,OAAO,IAAI,CAAC;AACd,CAAC;AAED;IACE,OAAO;QACL,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE;QACxC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QAC9C,UAAU,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;QACjD,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW;KAC/C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function addAction(name: string, attributes?: Record<string, unknown>): void;
|
|
2
|
+
export interface TouchPoint {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
t: number;
|
|
6
|
+
}
|
|
7
|
+
/** Called by OodleProvider when a touch ends close to where it started. */
|
|
8
|
+
export declare function recordTap(startEvent: unknown, start: TouchPoint, end: TouchPoint): void;
|
|
9
|
+
export declare function startOperation(name: string, key?: string): void;
|
|
10
|
+
export declare function succeedOperation(name: string, key?: string, attributes?: Record<string, unknown>): void;
|
|
11
|
+
export declare function failOperation(name: string, key?: string, reason?: string, attributes?: Record<string, unknown>): void;
|
|
12
|
+
export declare function trackEvent(name: string, properties?: Record<string, unknown>): void;
|
|
13
|
+
export declare function resetActions(): void;
|