@app-swiss-knife/react-native-sdk 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/README.md +182 -0
- package/SwissKnifePurchases.podspec +40 -0
- package/android/build.gradle +89 -0
- package/android/gradle.properties +3 -0
- package/android/src/main/AndroidManifest.xml +26 -0
- package/android/src/main/java/com/swissknife/crashreporting/SKCrashReportingModule.kt +216 -0
- package/android/src/main/java/com/swissknife/crashreporting/SKCrashReportingPackage.kt +17 -0
- package/android/src/main/java/com/swissknife/purchases/Conversions.kt +15 -0
- package/android/src/main/java/com/swissknife/purchases/SwissKnifeJson.kt +371 -0
- package/android/src/main/java/com/swissknife/purchases/SwissKnifePurchasesModule.kt +497 -0
- package/android/src/main/java/com/swissknife/purchases/SwissKnifePurchasesPackage.kt +25 -0
- package/android/vendor/GENERATED.md +10 -0
- package/android/vendor/java/com/appswissknife/SwissKnife.kt +533 -0
- package/android/vendor/java/com/appswissknife/analytics/EventQueueStore.kt +326 -0
- package/android/vendor/java/com/appswissknife/analytics/FlushEventsWorker.kt +296 -0
- package/android/vendor/java/com/appswissknife/analytics/SKAnalytics.kt +503 -0
- package/android/vendor/java/com/appswissknife/attributes/AttributesClient.kt +188 -0
- package/android/vendor/java/com/appswissknife/attributes/SetAttributesWorker.kt +204 -0
- package/android/vendor/java/com/appswissknife/attribution/Attribution.kt +447 -0
- package/android/vendor/java/com/appswissknife/context/AppLifecycle.kt +120 -0
- package/android/vendor/java/com/appswissknife/context/Clock.kt +70 -0
- package/android/vendor/java/com/appswissknife/context/DeviceContext.kt +138 -0
- package/android/vendor/java/com/appswissknife/context/IDs.kt +55 -0
- package/android/vendor/java/com/appswissknife/context/Reachability.kt +145 -0
- package/android/vendor/java/com/appswissknife/context/Session.kt +192 -0
- package/android/vendor/java/com/appswissknife/crashreporting/SKCrashReporting.kt +945 -0
- package/android/vendor/java/com/appswissknife/crashreporting/SKScreenshot.kt +201 -0
- package/android/vendor/java/com/appswissknife/device/DeviceID.kt +172 -0
- package/android/vendor/java/com/appswissknife/diagnostics/SKLog.kt +97 -0
- package/android/vendor/java/com/appswissknife/entitlements/EntitlementsRepository.kt +495 -0
- package/android/vendor/java/com/appswissknife/identity/Identity.kt +522 -0
- package/android/vendor/java/com/appswissknife/models/CustomerInfo.kt +67 -0
- package/android/vendor/java/com/appswissknife/models/Enums.kt +35 -0
- package/android/vendor/java/com/appswissknife/models/Offerings.kt +80 -0
- package/android/vendor/java/com/appswissknife/models/PurchasesError.kt +89 -0
- package/android/vendor/java/com/appswissknife/models/StoreTransaction.kt +17 -0
- package/android/vendor/java/com/appswissknife/net/BackendHttpClient.kt +507 -0
- package/android/vendor/java/com/appswissknife/net/ExponentialBackoff.kt +69 -0
- package/android/vendor/java/com/appswissknife/net/IngestClient.kt +582 -0
- package/android/vendor/java/com/appswissknife/net/OfflineQueueStore.kt +320 -0
- package/android/vendor/java/com/appswissknife/offerings/OfferingsRepository.kt +219 -0
- package/android/vendor/java/com/appswissknife/performance/SKFrameTracker.kt +94 -0
- package/android/vendor/java/com/appswissknife/performance/SKPerformance.kt +428 -0
- package/android/vendor/java/com/appswissknife/purchases/BillingClientGateway.kt +560 -0
- package/android/vendor/java/com/appswissknife/purchases/PlayPriceEnrichmentProvider.kt +100 -0
- package/android/vendor/java/com/appswissknife/purchases/PriceEnrichmentProvider.kt +36 -0
- package/android/vendor/java/com/appswissknife/purchases/PurchasesGateway.kt +120 -0
- package/android/vendor/res/xml/swissknife_data_extraction_rules.xml +20 -0
- package/ios/SwissKnifeCrashReporting.m +32 -0
- package/ios/SwissKnifeCrashReporting.swift +186 -0
- package/ios/SwissKnifeJSON.swift +347 -0
- package/ios/SwissKnifePurchases.m +124 -0
- package/ios/SwissKnifePurchases.swift +523 -0
- package/ios/vendor/GENERATED.md +10 -0
- package/ios/vendor/SwissKnifeiOS/Analytics/SKAnalytics.swift +488 -0
- package/ios/vendor/SwissKnifeiOS/AttributesClient.swift +460 -0
- package/ios/vendor/SwissKnifeiOS/Attribution/Attribution.swift +307 -0
- package/ios/vendor/SwissKnifeiOS/Attribution/AttributionNetwork.swift +92 -0
- package/ios/vendor/SwissKnifeiOS/Attribution/AttributionState.swift +141 -0
- package/ios/vendor/SwissKnifeiOS/Context/AppLifecycle.swift +130 -0
- package/ios/vendor/SwissKnifeiOS/Context/Clock.swift +100 -0
- package/ios/vendor/SwissKnifeiOS/Context/DeviceContext.swift +190 -0
- package/ios/vendor/SwissKnifeiOS/Context/IDs.swift +64 -0
- package/ios/vendor/SwissKnifeiOS/Context/Reachability.swift +121 -0
- package/ios/vendor/SwissKnifeiOS/Context/Session.swift +223 -0
- package/ios/vendor/SwissKnifeiOS/CrashReporting/SKCrashReporting.swift +1287 -0
- package/ios/vendor/SwissKnifeiOS/CrashReporting/SKScreenshot.swift +175 -0
- package/ios/vendor/SwissKnifeiOS/DeviceID.swift +161 -0
- package/ios/vendor/SwissKnifeiOS/Diagnostics/SKLog.swift +128 -0
- package/ios/vendor/SwissKnifeiOS/Identity/Identity.swift +323 -0
- package/ios/vendor/SwissKnifeiOS/Identity/IdentityNetwork.swift +70 -0
- package/ios/vendor/SwissKnifeiOS/Net/BackendHttpClient.swift +329 -0
- package/ios/vendor/SwissKnifeiOS/Net/ExponentialBackoff.swift +87 -0
- package/ios/vendor/SwissKnifeiOS/Net/IngestClient.swift +681 -0
- package/ios/vendor/SwissKnifeiOS/Net/OfflineQueueStore.swift +409 -0
- package/ios/vendor/SwissKnifeiOS/Performance/SKFrameTracker.swift +89 -0
- package/ios/vendor/SwissKnifeiOS/Performance/SKPerformance.swift +440 -0
- package/ios/vendor/SwissKnifeiOS/Performance/SKURLSessionDelegate.swift +87 -0
- package/ios/vendor/SwissKnifeiOS/Services/EntitlementsService.swift +646 -0
- package/ios/vendor/SwissKnifeiOS/Services/OfferingsService.swift +458 -0
- package/ios/vendor/SwissKnifeiOS/Services/PurchaseService.swift +374 -0
- package/ios/vendor/SwissKnifeiOS/SwissKnife+Analytics.swift +46 -0
- package/ios/vendor/SwissKnifeiOS/SwissKnife+DeviceID.swift +30 -0
- package/ios/vendor/SwissKnifeiOS/SwissKnife+Session.swift +47 -0
- package/ios/vendor/SwissKnifeiOS/SwissKnife.swift +417 -0
- package/ios/vendor/SwissKnifeiOS/Types.swift +496 -0
- package/lib/commonjs/attribution.js +55 -0
- package/lib/commonjs/attribution.js.map +1 -0
- package/lib/commonjs/identity.js +126 -0
- package/lib/commonjs/identity.js.map +1 -0
- package/lib/commonjs/index.js +118 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/modules/analytics.js +646 -0
- package/lib/commonjs/modules/analytics.js.map +1 -0
- package/lib/commonjs/modules/attachments.js +169 -0
- package/lib/commonjs/modules/attachments.js.map +1 -0
- package/lib/commonjs/modules/crash-reporting.js +1327 -0
- package/lib/commonjs/modules/crash-reporting.js.map +1 -0
- package/lib/commonjs/modules/ids.js +50 -0
- package/lib/commonjs/modules/ids.js.map +1 -0
- package/lib/commonjs/modules/log.js +59 -0
- package/lib/commonjs/modules/log.js.map +1 -0
- package/lib/commonjs/modules/offline-store.js +44 -0
- package/lib/commonjs/modules/offline-store.js.map +1 -0
- package/lib/commonjs/modules/performance.js +494 -0
- package/lib/commonjs/modules/performance.js.map +1 -0
- package/lib/commonjs/native/module.js +41 -0
- package/lib/commonjs/native/module.js.map +1 -0
- package/lib/commonjs/native/spec.js +26 -0
- package/lib/commonjs/native/spec.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/purchases.js +194 -0
- package/lib/commonjs/purchases.js.map +1 -0
- package/lib/commonjs/types.js +236 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/attribution.js +51 -0
- package/lib/module/attribution.js.map +1 -0
- package/lib/module/identity.js +122 -0
- package/lib/module/identity.js.map +1 -0
- package/lib/module/index.js +36 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/modules/analytics.js +642 -0
- package/lib/module/modules/analytics.js.map +1 -0
- package/lib/module/modules/attachments.js +162 -0
- package/lib/module/modules/attachments.js.map +1 -0
- package/lib/module/modules/crash-reporting.js +1320 -0
- package/lib/module/modules/crash-reporting.js.map +1 -0
- package/lib/module/modules/ids.js +44 -0
- package/lib/module/modules/ids.js.map +1 -0
- package/lib/module/modules/log.js +54 -0
- package/lib/module/modules/log.js.map +1 -0
- package/lib/module/modules/offline-store.js +39 -0
- package/lib/module/modules/offline-store.js.map +1 -0
- package/lib/module/modules/performance.js +491 -0
- package/lib/module/modules/performance.js.map +1 -0
- package/lib/module/native/module.js +34 -0
- package/lib/module/native/module.js.map +1 -0
- package/lib/module/native/spec.js +22 -0
- package/lib/module/native/spec.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/purchases.js +187 -0
- package/lib/module/purchases.js.map +1 -0
- package/lib/module/types.js +230 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/commonjs/attribution.d.ts +24 -0
- package/lib/typescript/commonjs/attribution.d.ts.map +1 -0
- package/lib/typescript/commonjs/identity.d.ts +37 -0
- package/lib/typescript/commonjs/identity.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +15 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/analytics.d.ts +127 -0
- package/lib/typescript/commonjs/modules/analytics.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/attachments.d.ts +50 -0
- package/lib/typescript/commonjs/modules/attachments.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/crash-reporting.d.ts +175 -0
- package/lib/typescript/commonjs/modules/crash-reporting.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/ids.d.ts +17 -0
- package/lib/typescript/commonjs/modules/ids.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/log.d.ts +12 -0
- package/lib/typescript/commonjs/modules/log.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/offline-store.d.ts +9 -0
- package/lib/typescript/commonjs/modules/offline-store.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/performance.d.ts +75 -0
- package/lib/typescript/commonjs/modules/performance.d.ts.map +1 -0
- package/lib/typescript/commonjs/native/module.d.ts +6 -0
- package/lib/typescript/commonjs/native/module.d.ts.map +1 -0
- package/lib/typescript/commonjs/native/spec.d.ts +119 -0
- package/lib/typescript/commonjs/native/spec.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/purchases.d.ts +68 -0
- package/lib/typescript/commonjs/purchases.d.ts.map +1 -0
- package/lib/typescript/commonjs/types.d.ts +384 -0
- package/lib/typescript/commonjs/types.d.ts.map +1 -0
- package/lib/typescript/module/attribution.d.ts +24 -0
- package/lib/typescript/module/attribution.d.ts.map +1 -0
- package/lib/typescript/module/identity.d.ts +37 -0
- package/lib/typescript/module/identity.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +15 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/modules/analytics.d.ts +127 -0
- package/lib/typescript/module/modules/analytics.d.ts.map +1 -0
- package/lib/typescript/module/modules/attachments.d.ts +50 -0
- package/lib/typescript/module/modules/attachments.d.ts.map +1 -0
- package/lib/typescript/module/modules/crash-reporting.d.ts +175 -0
- package/lib/typescript/module/modules/crash-reporting.d.ts.map +1 -0
- package/lib/typescript/module/modules/ids.d.ts +17 -0
- package/lib/typescript/module/modules/ids.d.ts.map +1 -0
- package/lib/typescript/module/modules/log.d.ts +12 -0
- package/lib/typescript/module/modules/log.d.ts.map +1 -0
- package/lib/typescript/module/modules/offline-store.d.ts +9 -0
- package/lib/typescript/module/modules/offline-store.d.ts.map +1 -0
- package/lib/typescript/module/modules/performance.d.ts +75 -0
- package/lib/typescript/module/modules/performance.d.ts.map +1 -0
- package/lib/typescript/module/native/module.d.ts +6 -0
- package/lib/typescript/module/native/module.d.ts.map +1 -0
- package/lib/typescript/module/native/spec.d.ts +119 -0
- package/lib/typescript/module/native/spec.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/purchases.d.ts +68 -0
- package/lib/typescript/module/purchases.d.ts.map +1 -0
- package/lib/typescript/module/types.d.ts +384 -0
- package/lib/typescript/module/types.d.ts.map +1 -0
- package/package.json +115 -0
- package/react-native.config.js +23 -0
- package/src/attribution.ts +56 -0
- package/src/identity.ts +133 -0
- package/src/index.ts +54 -0
- package/src/modules/analytics.ts +689 -0
- package/src/modules/attachments.ts +222 -0
- package/src/modules/crash-reporting.ts +1577 -0
- package/src/modules/ids.ts +41 -0
- package/src/modules/log.ts +56 -0
- package/src/modules/offline-store.ts +51 -0
- package/src/modules/performance.ts +589 -0
- package/src/native/module.ts +47 -0
- package/src/native/spec.ts +183 -0
- package/src/purchases.ts +214 -0
- package/src/types.ts +470 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.base64ToUint8Array = base64ToUint8Array;
|
|
7
|
+
exports.buildMultipartBody = buildMultipartBody;
|
|
8
|
+
exports.encodeUtf8 = encodeUtf8;
|
|
9
|
+
exports.uploadAttachment = uploadAttachment;
|
|
10
|
+
exports.uploadAttachmentWithRetry = uploadAttachmentWithRetry;
|
|
11
|
+
var _ids = require("./ids.js");
|
|
12
|
+
// packages/react-native-sdk/src/modules/attachments.ts
|
|
13
|
+
//
|
|
14
|
+
// Attachment upload for the crash-reporting module (wave-2 C2): POSTs
|
|
15
|
+
// screenshot blobs to /api/sdk/errors/attachments as multipart/form-data.
|
|
16
|
+
//
|
|
17
|
+
// ## Why a hand-built multipart body (not FormData)
|
|
18
|
+
//
|
|
19
|
+
// React Native has no filesystem the SDK can rely on, so the screenshot
|
|
20
|
+
// exists only as a base64 string in memory. The usual RN trick — FormData
|
|
21
|
+
// with a `{ uri: "data:..." }` part — depends on platform-specific native
|
|
22
|
+
// data-URI handlers, and RN's JS `FormData` cannot carry raw bytes (its
|
|
23
|
+
// parts must be strings or `{uri}` descriptors; web `Blob` parts are not
|
|
24
|
+
// supported by RN's `getParts()`). What IS reliably supported end-to-end:
|
|
25
|
+
// RN's fetch (whatwg-fetch over RCTNetworking) accepts a typed-array body —
|
|
26
|
+
// `convertRequestBody` handles `ArrayBuffer.isView(body)` by base64-encoding
|
|
27
|
+
// it across the bridge, so binary survives intact. We therefore decode the
|
|
28
|
+
// base64 to a Uint8Array and serialize the multipart envelope ourselves,
|
|
29
|
+
// byte-exact, with a manual boundary. This is also fully unit-testable: the
|
|
30
|
+
// tests inspect the exact bytes handed to fetch.
|
|
31
|
+
|
|
32
|
+
// MARK: - Base64 → bytes
|
|
33
|
+
|
|
34
|
+
const B64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
35
|
+
const B64_LOOKUP = {};
|
|
36
|
+
for (let i = 0; i < B64_ALPHABET.length; i++) {
|
|
37
|
+
B64_LOOKUP[B64_ALPHABET[i]] = i;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Decode a base64 string into a Uint8Array without relying on `atob` or
|
|
42
|
+
* `Buffer` (neither is guaranteed across RN JS engines). Whitespace and
|
|
43
|
+
* padding are tolerated; any other non-alphabet character is skipped.
|
|
44
|
+
*/
|
|
45
|
+
function base64ToUint8Array(base64) {
|
|
46
|
+
const clean = base64.replace(/[^A-Za-z0-9+/]/g, "");
|
|
47
|
+
const out = new Uint8Array(Math.floor(clean.length * 3 / 4));
|
|
48
|
+
let outIndex = 0;
|
|
49
|
+
let buffer = 0;
|
|
50
|
+
let bits = 0;
|
|
51
|
+
for (let i = 0; i < clean.length; i++) {
|
|
52
|
+
buffer = buffer << 6 | B64_LOOKUP[clean[i]];
|
|
53
|
+
bits += 6;
|
|
54
|
+
if (bits >= 8) {
|
|
55
|
+
bits -= 8;
|
|
56
|
+
out[outIndex++] = buffer >> bits & 0xff;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return outIndex === out.length ? out : out.slice(0, outIndex);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// MARK: - UTF-8 encoding
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Minimal UTF-8 encoder — `TextEncoder` is not available on every RN
|
|
66
|
+
* JS engine version, and the multipart headers must be byte-exact.
|
|
67
|
+
*/
|
|
68
|
+
function encodeUtf8(text) {
|
|
69
|
+
const bytes = [];
|
|
70
|
+
for (let i = 0; i < text.length; i++) {
|
|
71
|
+
const code = text.codePointAt(i);
|
|
72
|
+
if (code > 0xffff) i++; // surrogate pair consumed two UTF-16 units
|
|
73
|
+
if (code < 0x80) {
|
|
74
|
+
bytes.push(code);
|
|
75
|
+
} else if (code < 0x800) {
|
|
76
|
+
bytes.push(0xc0 | code >> 6, 0x80 | code & 0x3f);
|
|
77
|
+
} else if (code < 0x10000) {
|
|
78
|
+
bytes.push(0xe0 | code >> 12, 0x80 | code >> 6 & 0x3f, 0x80 | code & 0x3f);
|
|
79
|
+
} else {
|
|
80
|
+
bytes.push(0xf0 | code >> 18, 0x80 | code >> 12 & 0x3f, 0x80 | code >> 6 & 0x3f, 0x80 | code & 0x3f);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return Uint8Array.from(bytes);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// MARK: - Multipart body
|
|
87
|
+
|
|
88
|
+
function concatBytes(chunks) {
|
|
89
|
+
let total = 0;
|
|
90
|
+
for (const chunk of chunks) total += chunk.length;
|
|
91
|
+
const out = new Uint8Array(total);
|
|
92
|
+
let offset = 0;
|
|
93
|
+
for (const chunk of chunks) {
|
|
94
|
+
out.set(chunk, offset);
|
|
95
|
+
offset += chunk.length;
|
|
96
|
+
}
|
|
97
|
+
return out;
|
|
98
|
+
}
|
|
99
|
+
const CRLF = "\r\n";
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Serialize a multipart/form-data body: text fields first, then the file
|
|
103
|
+
* part with raw binary content, closed with the terminal boundary.
|
|
104
|
+
*/
|
|
105
|
+
function buildMultipartBody(boundary, fields, file) {
|
|
106
|
+
const chunks = [];
|
|
107
|
+
for (const field of fields) {
|
|
108
|
+
chunks.push(encodeUtf8(`--${boundary}${CRLF}` + `Content-Disposition: form-data; name="${field.name}"${CRLF}${CRLF}` + `${field.value}${CRLF}`));
|
|
109
|
+
}
|
|
110
|
+
chunks.push(encodeUtf8(`--${boundary}${CRLF}` + `Content-Disposition: form-data; name="${file.name}"; filename="${file.filename}"${CRLF}` + `Content-Type: ${file.contentType}${CRLF}${CRLF}`));
|
|
111
|
+
chunks.push(file.data);
|
|
112
|
+
chunks.push(encodeUtf8(`${CRLF}--${boundary}--${CRLF}`));
|
|
113
|
+
return concatBytes(chunks);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// MARK: - Upload
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* - "ok" → 2xx, attachment stored
|
|
120
|
+
* - "transient" → network error / 429 / 5xx — worth one retry
|
|
121
|
+
* - "permanent" → other 4xx (validation, over-limit) — do not retry
|
|
122
|
+
*/
|
|
123
|
+
|
|
124
|
+
async function uploadAttachment(options) {
|
|
125
|
+
const boundary = `----SwissKnifeBoundary${(0, _ids.generateUUID)().replace(/-/g, "")}`;
|
|
126
|
+
const body = buildMultipartBody(boundary, [{
|
|
127
|
+
name: "eventId",
|
|
128
|
+
value: options.eventId
|
|
129
|
+
}, {
|
|
130
|
+
name: "kind",
|
|
131
|
+
value: options.kind
|
|
132
|
+
}], {
|
|
133
|
+
name: "file",
|
|
134
|
+
// Server never trusts filenames (stores under a uuid) — this is
|
|
135
|
+
// only a hint for the multipart parser.
|
|
136
|
+
filename: `${options.eventId}.jpg`,
|
|
137
|
+
contentType: options.contentType,
|
|
138
|
+
data: options.data
|
|
139
|
+
});
|
|
140
|
+
const fetchFn = options.fetchFn ?? fetch;
|
|
141
|
+
try {
|
|
142
|
+
const res = await fetchFn(`${options.serverURL}/api/sdk/errors/attachments`, {
|
|
143
|
+
method: "POST",
|
|
144
|
+
headers: {
|
|
145
|
+
"Content-Type": `multipart/form-data; boundary=${boundary}`,
|
|
146
|
+
"X-API-Key": options.apiKey
|
|
147
|
+
},
|
|
148
|
+
// RN's fetch/XHR bridge supports typed-array bodies
|
|
149
|
+
// (convertRequestBody → base64 over the bridge). See module header.
|
|
150
|
+
body: body
|
|
151
|
+
});
|
|
152
|
+
if (res.ok) return "ok";
|
|
153
|
+
if (res.status === 429 || res.status >= 500) return "transient";
|
|
154
|
+
return "permanent";
|
|
155
|
+
} catch {
|
|
156
|
+
return "transient";
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Fire the upload with AT MOST one retry (transient failures only).
|
|
162
|
+
* Never throws — attachment delivery must never block event delivery.
|
|
163
|
+
*/
|
|
164
|
+
async function uploadAttachmentWithRetry(options) {
|
|
165
|
+
const first = await uploadAttachment(options);
|
|
166
|
+
if (first !== "transient") return first;
|
|
167
|
+
return uploadAttachment(options);
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=attachments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_ids","require","B64_ALPHABET","B64_LOOKUP","i","length","base64ToUint8Array","base64","clean","replace","out","Uint8Array","Math","floor","outIndex","buffer","bits","slice","encodeUtf8","text","bytes","code","codePointAt","push","from","concatBytes","chunks","total","chunk","offset","set","CRLF","buildMultipartBody","boundary","fields","file","field","name","value","filename","contentType","data","uploadAttachment","options","generateUUID","body","eventId","kind","fetchFn","fetch","res","serverURL","method","headers","apiKey","ok","status","uploadAttachmentWithRetry","first"],"sourceRoot":"../../../src","sources":["modules/attachments.ts"],"mappings":";;;;;;;;;;AAoBA,IAAAA,IAAA,GAAAC,OAAA;AApBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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