@wix/himalaya-cli 0.1679.0 → 0.1680.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/dist/browser-plane/assets.json +5 -5
- package/dist/browser-plane/preview-deferred/{4a260ef73a6f9f421a9119eac3d67bb9978e67b44c66a870038d189e6c77a0bd.bin → 4f58be42c5c8007715860f364adb1cdcb02156d76672fa38ba7ea412ee8fac2a.bin} +1 -1
- package/dist/browser-plane/sw.js +8 -8
- package/dist/cli.mjs +160 -110
- package/dist/preview-assets.generated.bin +0 -0
- package/package.json +2 -2
- package/templates/beauty-salon/dev/index.ts +1 -0
- package/templates/beauty-salon/tier5-src/_shared/wix-bi.ts +85 -0
- package/templates/beauty-salon/tier5-src/himi-branded-lite-cart/index.ts +9 -0
- package/templates/beauty-salon-owner/dev/index.ts +2 -1
- package/templates/beauty-salon-owner/tier5-src/_shared/wix-bi.ts +85 -0
- package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +6 -2
- package/templates/branded-lite/dev/index.ts +9 -4
- package/templates/branded-lite/tier5-src/_shared/wix-bi.ts +85 -0
- package/templates/branded-lite/tier5-src/business-chat/index.ts +8 -0
- package/templates/branded-lite/tier5-src/himi-branded-lite-cart/index.ts +9 -0
- package/templates/branded-lite/tier5-src/himi-store-product/index.ts +14 -0
- package/templates/branded-lite/tier5-src/wix-spaces-chat-thread/index.ts +3 -1
- package/templates/branded-lite/tier5-src/wix-spaces-food-orders/index.ts +15 -0
- package/templates/branded-lite/tier5-src/wix-spaces-forum/index.ts +22 -1
- package/templates/community-club-owner/dev/index.ts +2 -1
- package/templates/community-club-owner/tier5-src/_shared/wix-bi.ts +85 -0
- package/templates/community-club-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +6 -2
- package/templates/conference/dev/index.ts +2 -1
- package/templates/conference/tier5-src/_shared/wix-bi.ts +85 -0
- package/templates/conference/tier5-src/business-chat/index.ts +8 -0
- package/templates/events-meetups-owner/dev/index.ts +2 -1
- package/templates/events-meetups-owner/tier5-src/_shared/wix-bi.ts +85 -0
- package/templates/events-meetups-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +6 -2
- package/templates/gym-fitness/dev/index.ts +1 -0
- package/templates/gym-fitness/tier5-src/_shared/wix-bi.ts +85 -0
- package/templates/gym-fitness/tier5-src/himi-branded-lite-cart/index.ts +9 -0
- package/templates/gym-fitness-owner/dev/index.ts +2 -1
- package/templates/gym-fitness-owner/tier5-src/_shared/wix-bi.ts +85 -0
- package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +6 -2
- package/templates/nonprofit-cause-owner/dev/index.ts +2 -1
- package/templates/nonprofit-cause-owner/tier5-src/_shared/wix-bi.ts +85 -0
- package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +6 -2
- package/templates/owner-lite/dev/index.ts +2 -1
- package/templates/owner-lite/tier5-src/_shared/wix-bi.ts +85 -0
- package/templates/owner-lite/tier5-src/himi-owner-lite-inbox-thread/index.ts +6 -2
- package/templates/podcast-creator-owner/dev/index.ts +2 -1
- package/templates/podcast-creator-owner/tier5-src/_shared/wix-bi.ts +85 -0
- package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +6 -2
- package/templates/portfolio-creative/dev/index.ts +1 -0
- package/templates/portfolio-creative/tier5-src/_shared/wix-bi.ts +85 -0
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-cart/index.ts +9 -0
- package/templates/portfolio-creative-owner/dev/index.ts +2 -1
- package/templates/portfolio-creative-owner/tier5-src/_shared/wix-bi.ts +85 -0
- package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +6 -2
- package/templates/restaurant/dev/index.ts +2 -1
- package/templates/restaurant/tier5-src/_shared/wix-bi.ts +85 -0
- package/templates/restaurant/tier5-src/wix-spaces-food-orders/index.ts +15 -0
- package/templates/restaurant-owner/dev/index.ts +2 -1
- package/templates/restaurant-owner/tier5-src/_shared/wix-bi.ts +85 -0
- package/templates/restaurant-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +6 -2
- package/templates/retail-store/dev/index.ts +1 -0
- package/templates/retail-store/tier5-src/_shared/wix-bi.ts +85 -0
- package/templates/retail-store/tier5-src/himi-branded-lite-cart/index.ts +9 -0
- package/templates/retail-store/tier5-src/himi-store-product/index.ts +14 -0
- package/templates/retail-store-owner/dev/index.ts +2 -1
- package/templates/retail-store-owner/tier5-src/_shared/wix-bi.ts +85 -0
- package/templates/retail-store-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +6 -2
- package/templates/salon-spa/dev/index.ts +2 -1
- package/templates/salon-spa/tier5-src/_shared/wix-bi.ts +85 -0
- package/templates/salon-spa/tier5-src/business-chat/index.ts +8 -0
- package/templates/wholesale-store/dev/index.ts +3 -1
- package/templates/wholesale-store/tier5-src/_shared/wix-bi.ts +85 -0
- package/templates/wholesale-store/tier5-src/business-chat/index.ts +8 -0
- package/templates/wholesale-store/tier5-src/himi-branded-lite-cart/index.ts +9 -0
- package/templates/wholesale-store/tier5-src/himi-store-product/index.ts +14 -0
- package/templates/yoga-studio-owner/dev/index.ts +2 -1
- package/templates/yoga-studio-owner/tier5-src/_shared/wix-bi.ts +85 -0
- package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +6 -2
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// RN BI events whose fields exist only in a worker (epic #4973). The platform maps send every
|
|
2
|
+
// other RN event; these go through `wixPlatform.bi.log`, built inline with RN's own field names
|
|
3
|
+
// rather than by bundling a `@wix/bi-logger-*` package. The host owns every identity and common
|
|
4
|
+
// field (msid, uuid, installationId, contactId, _lv, ...), so none is named here.
|
|
5
|
+
import { bi, type BiLogEvent } from "@himalaya/wix-platform";
|
|
6
|
+
|
|
7
|
+
/** Sends one event without waiting for it and never throws: BI must not change a screen. A
|
|
8
|
+
* screen whose descriptor does not declare `wix_platform` is refused by the host, which is
|
|
9
|
+
* swallowed here like any other BI failure. */
|
|
10
|
+
export function logBi(event: BiLogEvent): void {
|
|
11
|
+
try {
|
|
12
|
+
void Promise.resolve(bi.log(event)).catch(() => undefined);
|
|
13
|
+
} catch {
|
|
14
|
+
/* BI is best-effort */
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** The HTTP status a Wix SDK error carries (`HTTP 429: ...`, or a `status` field), else 0. */
|
|
19
|
+
export function wixErrorStatus(error: unknown): number {
|
|
20
|
+
const own = Number((error as { status?: unknown; statusCode?: unknown } | null)?.status ?? (error as { statusCode?: unknown } | null)?.statusCode);
|
|
21
|
+
if (Number.isFinite(own) && own > 0) return own;
|
|
22
|
+
const match = /\bHTTP (\d{3})\b/.exec(String((error as Error | null)?.message ?? error ?? ""));
|
|
23
|
+
return match ? Number(match[1]) : 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function applicationErrorCode(body: unknown): string {
|
|
27
|
+
const o = body as { details?: { applicationError?: { code?: unknown } }; applicationError?: { code?: unknown }; code?: unknown } | null;
|
|
28
|
+
const code = o?.details?.applicationError?.code ?? o?.applicationError?.code ?? o?.code;
|
|
29
|
+
return typeof code === "string" ? code : "";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The code both native bridges put in an application error's message: `HTTP 400 [CODE]: description`
|
|
33
|
+
* (iOS JSWorker.swift `WixApiCapability.Error.application`, Android WebViewJSWorker.kt `Error.Application`). */
|
|
34
|
+
const BRIDGE_APPLICATION_CODE = /\bHTTP \d{3} \[([A-Za-z0-9_.:-]+)\]/;
|
|
35
|
+
|
|
36
|
+
/** The Wix application error code of a failed call (RN's `serializeError(e).code`): read from the
|
|
37
|
+
* error itself, else from the `[CODE]` the native bridges put after `HTTP <status> `, else from the
|
|
38
|
+
* JSON body after `HTTP <status>: ` (the bridges' raw-status arm and the web host's wixCall). ""
|
|
39
|
+
* when there is none. */
|
|
40
|
+
export function wixErrorCode(error: unknown): string {
|
|
41
|
+
const own = applicationErrorCode(error);
|
|
42
|
+
if (own) return own;
|
|
43
|
+
const message = String((error as Error | null)?.message ?? error ?? "");
|
|
44
|
+
const bracketed = BRIDGE_APPLICATION_CODE.exec(message);
|
|
45
|
+
if (bracketed) return bracketed[1];
|
|
46
|
+
const start = message.indexOf("{");
|
|
47
|
+
if (start < 0) return "";
|
|
48
|
+
try {
|
|
49
|
+
return applicationErrorCode(JSON.parse(message.slice(start)));
|
|
50
|
+
} catch {
|
|
51
|
+
return "";
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// RN's `ErrorIndicationType` (mobile-apps-inbox services/errorIndications/errorIndications.type.ts).
|
|
56
|
+
const ERROR_INDICATIONS = new Set([
|
|
57
|
+
"ACCESS_TOKEN_EXPIRED", "ALLOWED_MESSAGING_TIME_WINDOW_EXPIRED", "ATTACHMENT_SIZE_EXCEEDS_ALLOWED_LIMIT", "CAMPAIGN_SUSPENDED",
|
|
58
|
+
"FACEBOOK_ALLOWED_WINDOW_EXPIRED", "GMAIL_ADV_PROTECTION", "INSTAGRAM_ALLOWED_WINDOW_EXPIRED", "INVALID_CHARACTERS",
|
|
59
|
+
"INVALID_PHONE_NUMBER", "INVALID_RECIPIENT_ADDRESS", "LANDLINE_OR_UNREACHABLE_CARRIER", "MESSAGE_FILTERED",
|
|
60
|
+
"MMS_NOT_SUPPORTED_RECEIVING_PHONE_NUMBER", "NETWORK_ISSUE", "NO_MATCHING_RECIPIENT_FOUND", "POLICY_VIOLATION", "QUOTA_EXCEEDED",
|
|
61
|
+
"RATE_LIMIT", "RATE_LIMIT_ERROR", "RECIPIENT_BLOCKED_MESSAGES", "RECIPIENT_NOT_AVAILABLE", "SERVICE_UNAVAILABLE",
|
|
62
|
+
"TELCO_LANDLINE_OR_UNREACHABLE_CARRIER", "TELCO_MEDIA_EXCEEDS_MESSAGING_PROVIDER_SIZE_LIMIT",
|
|
63
|
+
"TELCO_MESSAGE_DELIVERY_UNKNOWN_DESTINATION_HANDSET", "TELCO_MESSAGE_FILTERED", "TELCO_MESSAGE_FROM_NUMBER_STILL_BEING_CONFIGURED",
|
|
64
|
+
"TELCO_MESSAGE_FROM_UNREGISTERED_NUMBER", "TELCO_UNKNOWN_ERROR", "TELCO_UNREACHABLE_DESTINATION_HANDSET", "TOO_MANY_REQUESTS",
|
|
65
|
+
"TOTAL_ATTACHMENTS_SIZE_EXCEEDS_ALLOWED_LIMIT", "UNEXPECTED_ERROR_RETRY_LATER", "UNKNOWN_FAILED_CODE", "UNSUPPORTED",
|
|
66
|
+
"UNSUPPORTED_MESSAGE_TYPE", "USER_RATE_LIMIT",
|
|
67
|
+
]);
|
|
68
|
+
|
|
69
|
+
/** 5:1604 inboxSendMessageErrorMsgShown (`@wix/bi-logger-crm-data` v2, endpoint ''), for a chat
|
|
70
|
+
* send that failed and said so. RN's `errorReason` is the failed message's indication code, and
|
|
71
|
+
* RN reports a code it does not know as UNSUPPORTED (`getErrorIndicationFromCode`); a send that
|
|
72
|
+
* never left the device is NETWORK_ISSUE and a 429 is RATE_LIMIT. */
|
|
73
|
+
export function logChatSendError(input: { chatroomId: string; contactId?: string; error: unknown; offline: boolean }): void {
|
|
74
|
+
const code = wixErrorCode(input.error);
|
|
75
|
+
const errorReason = input.offline ? "NETWORK_ISSUE"
|
|
76
|
+
: ERROR_INDICATIONS.has(code) ? code
|
|
77
|
+
: wixErrorStatus(input.error) === 429 ? "RATE_LIMIT"
|
|
78
|
+
: "UNSUPPORTED";
|
|
79
|
+
logBi({
|
|
80
|
+
evid: 1604,
|
|
81
|
+
src: 5,
|
|
82
|
+
endpoint: "",
|
|
83
|
+
params: { origin: "native", chatroomId: input.chatroomId, ...(input.contactId ? { contact_id: input.contactId } : {}), errorReason },
|
|
84
|
+
});
|
|
85
|
+
}
|
|
@@ -22,7 +22,8 @@ import { defineService, navigate, type NavDirective, type PollDirective, type St
|
|
|
22
22
|
import { getMessages, sendChatMessage, listChatrooms, markChatroomRead, getChatToken, type ChatMessage } from "@himalaya/wix-chat-web";
|
|
23
23
|
import { formatMonthDayTime } from "../_shared/engine-intl.js";
|
|
24
24
|
import { presence, presenceAfterError, detailInputId, type PresenceFlags } from "../_shared/detail-presence.js";
|
|
25
|
-
import { ownerLoadError, ownerWriteError, writeMayHaveLanded } from "../_shared/owner-load-error.js";
|
|
25
|
+
import { isOfflineFailure, ownerLoadError, ownerWriteError, writeMayHaveLanded } from "../_shared/owner-load-error.js";
|
|
26
|
+
import { logChatSendError } from "../_shared/wix-bi.js";
|
|
26
27
|
import { stashCopy, copyParam } from "../_shared/himi-copy.js";
|
|
27
28
|
import { chatRealtimeConfig, createReloadGate, createSendIntents, createVisitToken, liveDirectives, postWithVisitToken, liveFallback, type ChatLiveMode, type ChatRealtimeConfig } from "../_shared/chat-live.js";
|
|
28
29
|
|
|
@@ -280,7 +281,10 @@ const svc = defineService<ThreadState, {
|
|
|
280
281
|
} catch (e) {
|
|
281
282
|
// The draft stays: the owner should not have to type it again. A send that may
|
|
282
283
|
// have landed says so, so a retry does not post it twice unknowingly.
|
|
283
|
-
|
|
284
|
+
if (writeMayHaveLanded(e)) return { ...live(), sendHint: ownerWriteError(e) };
|
|
285
|
+
const { id, kind } = input();
|
|
286
|
+
logChatSendError({ chatroomId: s.chatroomId, contactId: kind === "contact" ? id : "", error: e, offline: isOfflineFailure(e) });
|
|
287
|
+
return { ...live(), sendHint: `${copyParam("ownerInbox.sendFailed", "Couldn’t send")} — ${ownerWriteError(e)}` };
|
|
284
288
|
}
|
|
285
289
|
// Clear the composer only if it still holds what was sent — the owner may already be
|
|
286
290
|
// typing the next message — judged on the state AFTER the re-read's await.
|
|
@@ -66236,7 +66236,8 @@ const SCREENS = runtimeSetting({
|
|
|
66236
66236
|
"integrity": "",
|
|
66237
66237
|
"contentType": "application/javascript+ts-bundle",
|
|
66238
66238
|
"declaredCapabilities": [
|
|
66239
|
-
"wix_api"
|
|
66239
|
+
"wix_api",
|
|
66240
|
+
"wix_platform"
|
|
66240
66241
|
],
|
|
66241
66242
|
"minBinaryVersion": "0.1.0",
|
|
66242
66243
|
"bundleVersion": "0.0.1"
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// RN BI events whose fields exist only in a worker (epic #4973). The platform maps send every
|
|
2
|
+
// other RN event; these go through `wixPlatform.bi.log`, built inline with RN's own field names
|
|
3
|
+
// rather than by bundling a `@wix/bi-logger-*` package. The host owns every identity and common
|
|
4
|
+
// field (msid, uuid, installationId, contactId, _lv, ...), so none is named here.
|
|
5
|
+
import { bi, type BiLogEvent } from "@himalaya/wix-platform";
|
|
6
|
+
|
|
7
|
+
/** Sends one event without waiting for it and never throws: BI must not change a screen. A
|
|
8
|
+
* screen whose descriptor does not declare `wix_platform` is refused by the host, which is
|
|
9
|
+
* swallowed here like any other BI failure. */
|
|
10
|
+
export function logBi(event: BiLogEvent): void {
|
|
11
|
+
try {
|
|
12
|
+
void Promise.resolve(bi.log(event)).catch(() => undefined);
|
|
13
|
+
} catch {
|
|
14
|
+
/* BI is best-effort */
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** The HTTP status a Wix SDK error carries (`HTTP 429: ...`, or a `status` field), else 0. */
|
|
19
|
+
export function wixErrorStatus(error: unknown): number {
|
|
20
|
+
const own = Number((error as { status?: unknown; statusCode?: unknown } | null)?.status ?? (error as { statusCode?: unknown } | null)?.statusCode);
|
|
21
|
+
if (Number.isFinite(own) && own > 0) return own;
|
|
22
|
+
const match = /\bHTTP (\d{3})\b/.exec(String((error as Error | null)?.message ?? error ?? ""));
|
|
23
|
+
return match ? Number(match[1]) : 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function applicationErrorCode(body: unknown): string {
|
|
27
|
+
const o = body as { details?: { applicationError?: { code?: unknown } }; applicationError?: { code?: unknown }; code?: unknown } | null;
|
|
28
|
+
const code = o?.details?.applicationError?.code ?? o?.applicationError?.code ?? o?.code;
|
|
29
|
+
return typeof code === "string" ? code : "";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The code both native bridges put in an application error's message: `HTTP 400 [CODE]: description`
|
|
33
|
+
* (iOS JSWorker.swift `WixApiCapability.Error.application`, Android WebViewJSWorker.kt `Error.Application`). */
|
|
34
|
+
const BRIDGE_APPLICATION_CODE = /\bHTTP \d{3} \[([A-Za-z0-9_.:-]+)\]/;
|
|
35
|
+
|
|
36
|
+
/** The Wix application error code of a failed call (RN's `serializeError(e).code`): read from the
|
|
37
|
+
* error itself, else from the `[CODE]` the native bridges put after `HTTP <status> `, else from the
|
|
38
|
+
* JSON body after `HTTP <status>: ` (the bridges' raw-status arm and the web host's wixCall). ""
|
|
39
|
+
* when there is none. */
|
|
40
|
+
export function wixErrorCode(error: unknown): string {
|
|
41
|
+
const own = applicationErrorCode(error);
|
|
42
|
+
if (own) return own;
|
|
43
|
+
const message = String((error as Error | null)?.message ?? error ?? "");
|
|
44
|
+
const bracketed = BRIDGE_APPLICATION_CODE.exec(message);
|
|
45
|
+
if (bracketed) return bracketed[1];
|
|
46
|
+
const start = message.indexOf("{");
|
|
47
|
+
if (start < 0) return "";
|
|
48
|
+
try {
|
|
49
|
+
return applicationErrorCode(JSON.parse(message.slice(start)));
|
|
50
|
+
} catch {
|
|
51
|
+
return "";
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// RN's `ErrorIndicationType` (mobile-apps-inbox services/errorIndications/errorIndications.type.ts).
|
|
56
|
+
const ERROR_INDICATIONS = new Set([
|
|
57
|
+
"ACCESS_TOKEN_EXPIRED", "ALLOWED_MESSAGING_TIME_WINDOW_EXPIRED", "ATTACHMENT_SIZE_EXCEEDS_ALLOWED_LIMIT", "CAMPAIGN_SUSPENDED",
|
|
58
|
+
"FACEBOOK_ALLOWED_WINDOW_EXPIRED", "GMAIL_ADV_PROTECTION", "INSTAGRAM_ALLOWED_WINDOW_EXPIRED", "INVALID_CHARACTERS",
|
|
59
|
+
"INVALID_PHONE_NUMBER", "INVALID_RECIPIENT_ADDRESS", "LANDLINE_OR_UNREACHABLE_CARRIER", "MESSAGE_FILTERED",
|
|
60
|
+
"MMS_NOT_SUPPORTED_RECEIVING_PHONE_NUMBER", "NETWORK_ISSUE", "NO_MATCHING_RECIPIENT_FOUND", "POLICY_VIOLATION", "QUOTA_EXCEEDED",
|
|
61
|
+
"RATE_LIMIT", "RATE_LIMIT_ERROR", "RECIPIENT_BLOCKED_MESSAGES", "RECIPIENT_NOT_AVAILABLE", "SERVICE_UNAVAILABLE",
|
|
62
|
+
"TELCO_LANDLINE_OR_UNREACHABLE_CARRIER", "TELCO_MEDIA_EXCEEDS_MESSAGING_PROVIDER_SIZE_LIMIT",
|
|
63
|
+
"TELCO_MESSAGE_DELIVERY_UNKNOWN_DESTINATION_HANDSET", "TELCO_MESSAGE_FILTERED", "TELCO_MESSAGE_FROM_NUMBER_STILL_BEING_CONFIGURED",
|
|
64
|
+
"TELCO_MESSAGE_FROM_UNREGISTERED_NUMBER", "TELCO_UNKNOWN_ERROR", "TELCO_UNREACHABLE_DESTINATION_HANDSET", "TOO_MANY_REQUESTS",
|
|
65
|
+
"TOTAL_ATTACHMENTS_SIZE_EXCEEDS_ALLOWED_LIMIT", "UNEXPECTED_ERROR_RETRY_LATER", "UNKNOWN_FAILED_CODE", "UNSUPPORTED",
|
|
66
|
+
"UNSUPPORTED_MESSAGE_TYPE", "USER_RATE_LIMIT",
|
|
67
|
+
]);
|
|
68
|
+
|
|
69
|
+
/** 5:1604 inboxSendMessageErrorMsgShown (`@wix/bi-logger-crm-data` v2, endpoint ''), for a chat
|
|
70
|
+
* send that failed and said so. RN's `errorReason` is the failed message's indication code, and
|
|
71
|
+
* RN reports a code it does not know as UNSUPPORTED (`getErrorIndicationFromCode`); a send that
|
|
72
|
+
* never left the device is NETWORK_ISSUE and a 429 is RATE_LIMIT. */
|
|
73
|
+
export function logChatSendError(input: { chatroomId: string; contactId?: string; error: unknown; offline: boolean }): void {
|
|
74
|
+
const code = wixErrorCode(input.error);
|
|
75
|
+
const errorReason = input.offline ? "NETWORK_ISSUE"
|
|
76
|
+
: ERROR_INDICATIONS.has(code) ? code
|
|
77
|
+
: wixErrorStatus(input.error) === 429 ? "RATE_LIMIT"
|
|
78
|
+
: "UNSUPPORTED";
|
|
79
|
+
logBi({
|
|
80
|
+
evid: 1604,
|
|
81
|
+
src: 5,
|
|
82
|
+
endpoint: "",
|
|
83
|
+
params: { origin: "native", chatroomId: input.chatroomId, ...(input.contactId ? { contact_id: input.contactId } : {}), errorReason },
|
|
84
|
+
});
|
|
85
|
+
}
|
|
@@ -22,7 +22,8 @@ import { defineService, navigate, type NavDirective, type PollDirective, type St
|
|
|
22
22
|
import { getMessages, sendChatMessage, listChatrooms, markChatroomRead, getChatToken, type ChatMessage } from "@himalaya/wix-chat-web";
|
|
23
23
|
import { formatMonthDayTime } from "../_shared/engine-intl.js";
|
|
24
24
|
import { presence, presenceAfterError, detailInputId, type PresenceFlags } from "../_shared/detail-presence.js";
|
|
25
|
-
import { ownerLoadError, ownerWriteError, writeMayHaveLanded } from "../_shared/owner-load-error.js";
|
|
25
|
+
import { isOfflineFailure, ownerLoadError, ownerWriteError, writeMayHaveLanded } from "../_shared/owner-load-error.js";
|
|
26
|
+
import { logChatSendError } from "../_shared/wix-bi.js";
|
|
26
27
|
import { stashCopy, copyParam } from "../_shared/himi-copy.js";
|
|
27
28
|
import { chatRealtimeConfig, createReloadGate, createSendIntents, createVisitToken, liveDirectives, postWithVisitToken, liveFallback, type ChatLiveMode, type ChatRealtimeConfig } from "../_shared/chat-live.js";
|
|
28
29
|
|
|
@@ -280,7 +281,10 @@ const svc = defineService<ThreadState, {
|
|
|
280
281
|
} catch (e) {
|
|
281
282
|
// The draft stays: the owner should not have to type it again. A send that may
|
|
282
283
|
// have landed says so, so a retry does not post it twice unknowingly.
|
|
283
|
-
|
|
284
|
+
if (writeMayHaveLanded(e)) return { ...live(), sendHint: ownerWriteError(e) };
|
|
285
|
+
const { id, kind } = input();
|
|
286
|
+
logChatSendError({ chatroomId: s.chatroomId, contactId: kind === "contact" ? id : "", error: e, offline: isOfflineFailure(e) });
|
|
287
|
+
return { ...live(), sendHint: `${copyParam("ownerInbox.sendFailed", "Couldn’t send")} — ${ownerWriteError(e)}` };
|
|
284
288
|
}
|
|
285
289
|
// Clear the composer only if it still holds what was sent — the owner may already be
|
|
286
290
|
// typing the next message — judged on the state AFTER the re-read's await.
|
|
@@ -66166,7 +66166,8 @@ const SCREENS = runtimeSetting({
|
|
|
66166
66166
|
"integrity": "",
|
|
66167
66167
|
"contentType": "application/javascript+ts-bundle",
|
|
66168
66168
|
"declaredCapabilities": [
|
|
66169
|
-
"wix_api"
|
|
66169
|
+
"wix_api",
|
|
66170
|
+
"wix_platform"
|
|
66170
66171
|
],
|
|
66171
66172
|
"minBinaryVersion": "0.1.0",
|
|
66172
66173
|
"bundleVersion": "0.0.1"
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// RN BI events whose fields exist only in a worker (epic #4973). The platform maps send every
|
|
2
|
+
// other RN event; these go through `wixPlatform.bi.log`, built inline with RN's own field names
|
|
3
|
+
// rather than by bundling a `@wix/bi-logger-*` package. The host owns every identity and common
|
|
4
|
+
// field (msid, uuid, installationId, contactId, _lv, ...), so none is named here.
|
|
5
|
+
import { bi, type BiLogEvent } from "@himalaya/wix-platform";
|
|
6
|
+
|
|
7
|
+
/** Sends one event without waiting for it and never throws: BI must not change a screen. A
|
|
8
|
+
* screen whose descriptor does not declare `wix_platform` is refused by the host, which is
|
|
9
|
+
* swallowed here like any other BI failure. */
|
|
10
|
+
export function logBi(event: BiLogEvent): void {
|
|
11
|
+
try {
|
|
12
|
+
void Promise.resolve(bi.log(event)).catch(() => undefined);
|
|
13
|
+
} catch {
|
|
14
|
+
/* BI is best-effort */
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** The HTTP status a Wix SDK error carries (`HTTP 429: ...`, or a `status` field), else 0. */
|
|
19
|
+
export function wixErrorStatus(error: unknown): number {
|
|
20
|
+
const own = Number((error as { status?: unknown; statusCode?: unknown } | null)?.status ?? (error as { statusCode?: unknown } | null)?.statusCode);
|
|
21
|
+
if (Number.isFinite(own) && own > 0) return own;
|
|
22
|
+
const match = /\bHTTP (\d{3})\b/.exec(String((error as Error | null)?.message ?? error ?? ""));
|
|
23
|
+
return match ? Number(match[1]) : 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function applicationErrorCode(body: unknown): string {
|
|
27
|
+
const o = body as { details?: { applicationError?: { code?: unknown } }; applicationError?: { code?: unknown }; code?: unknown } | null;
|
|
28
|
+
const code = o?.details?.applicationError?.code ?? o?.applicationError?.code ?? o?.code;
|
|
29
|
+
return typeof code === "string" ? code : "";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The code both native bridges put in an application error's message: `HTTP 400 [CODE]: description`
|
|
33
|
+
* (iOS JSWorker.swift `WixApiCapability.Error.application`, Android WebViewJSWorker.kt `Error.Application`). */
|
|
34
|
+
const BRIDGE_APPLICATION_CODE = /\bHTTP \d{3} \[([A-Za-z0-9_.:-]+)\]/;
|
|
35
|
+
|
|
36
|
+
/** The Wix application error code of a failed call (RN's `serializeError(e).code`): read from the
|
|
37
|
+
* error itself, else from the `[CODE]` the native bridges put after `HTTP <status> `, else from the
|
|
38
|
+
* JSON body after `HTTP <status>: ` (the bridges' raw-status arm and the web host's wixCall). ""
|
|
39
|
+
* when there is none. */
|
|
40
|
+
export function wixErrorCode(error: unknown): string {
|
|
41
|
+
const own = applicationErrorCode(error);
|
|
42
|
+
if (own) return own;
|
|
43
|
+
const message = String((error as Error | null)?.message ?? error ?? "");
|
|
44
|
+
const bracketed = BRIDGE_APPLICATION_CODE.exec(message);
|
|
45
|
+
if (bracketed) return bracketed[1];
|
|
46
|
+
const start = message.indexOf("{");
|
|
47
|
+
if (start < 0) return "";
|
|
48
|
+
try {
|
|
49
|
+
return applicationErrorCode(JSON.parse(message.slice(start)));
|
|
50
|
+
} catch {
|
|
51
|
+
return "";
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// RN's `ErrorIndicationType` (mobile-apps-inbox services/errorIndications/errorIndications.type.ts).
|
|
56
|
+
const ERROR_INDICATIONS = new Set([
|
|
57
|
+
"ACCESS_TOKEN_EXPIRED", "ALLOWED_MESSAGING_TIME_WINDOW_EXPIRED", "ATTACHMENT_SIZE_EXCEEDS_ALLOWED_LIMIT", "CAMPAIGN_SUSPENDED",
|
|
58
|
+
"FACEBOOK_ALLOWED_WINDOW_EXPIRED", "GMAIL_ADV_PROTECTION", "INSTAGRAM_ALLOWED_WINDOW_EXPIRED", "INVALID_CHARACTERS",
|
|
59
|
+
"INVALID_PHONE_NUMBER", "INVALID_RECIPIENT_ADDRESS", "LANDLINE_OR_UNREACHABLE_CARRIER", "MESSAGE_FILTERED",
|
|
60
|
+
"MMS_NOT_SUPPORTED_RECEIVING_PHONE_NUMBER", "NETWORK_ISSUE", "NO_MATCHING_RECIPIENT_FOUND", "POLICY_VIOLATION", "QUOTA_EXCEEDED",
|
|
61
|
+
"RATE_LIMIT", "RATE_LIMIT_ERROR", "RECIPIENT_BLOCKED_MESSAGES", "RECIPIENT_NOT_AVAILABLE", "SERVICE_UNAVAILABLE",
|
|
62
|
+
"TELCO_LANDLINE_OR_UNREACHABLE_CARRIER", "TELCO_MEDIA_EXCEEDS_MESSAGING_PROVIDER_SIZE_LIMIT",
|
|
63
|
+
"TELCO_MESSAGE_DELIVERY_UNKNOWN_DESTINATION_HANDSET", "TELCO_MESSAGE_FILTERED", "TELCO_MESSAGE_FROM_NUMBER_STILL_BEING_CONFIGURED",
|
|
64
|
+
"TELCO_MESSAGE_FROM_UNREGISTERED_NUMBER", "TELCO_UNKNOWN_ERROR", "TELCO_UNREACHABLE_DESTINATION_HANDSET", "TOO_MANY_REQUESTS",
|
|
65
|
+
"TOTAL_ATTACHMENTS_SIZE_EXCEEDS_ALLOWED_LIMIT", "UNEXPECTED_ERROR_RETRY_LATER", "UNKNOWN_FAILED_CODE", "UNSUPPORTED",
|
|
66
|
+
"UNSUPPORTED_MESSAGE_TYPE", "USER_RATE_LIMIT",
|
|
67
|
+
]);
|
|
68
|
+
|
|
69
|
+
/** 5:1604 inboxSendMessageErrorMsgShown (`@wix/bi-logger-crm-data` v2, endpoint ''), for a chat
|
|
70
|
+
* send that failed and said so. RN's `errorReason` is the failed message's indication code, and
|
|
71
|
+
* RN reports a code it does not know as UNSUPPORTED (`getErrorIndicationFromCode`); a send that
|
|
72
|
+
* never left the device is NETWORK_ISSUE and a 429 is RATE_LIMIT. */
|
|
73
|
+
export function logChatSendError(input: { chatroomId: string; contactId?: string; error: unknown; offline: boolean }): void {
|
|
74
|
+
const code = wixErrorCode(input.error);
|
|
75
|
+
const errorReason = input.offline ? "NETWORK_ISSUE"
|
|
76
|
+
: ERROR_INDICATIONS.has(code) ? code
|
|
77
|
+
: wixErrorStatus(input.error) === 429 ? "RATE_LIMIT"
|
|
78
|
+
: "UNSUPPORTED";
|
|
79
|
+
logBi({
|
|
80
|
+
evid: 1604,
|
|
81
|
+
src: 5,
|
|
82
|
+
endpoint: "",
|
|
83
|
+
params: { origin: "native", chatroomId: input.chatroomId, ...(input.contactId ? { contact_id: input.contactId } : {}), errorReason },
|
|
84
|
+
});
|
|
85
|
+
}
|
|
@@ -22,7 +22,8 @@ import { defineService, navigate, type NavDirective, type PollDirective, type St
|
|
|
22
22
|
import { getMessages, sendChatMessage, listChatrooms, markChatroomRead, getChatToken, type ChatMessage } from "@himalaya/wix-chat-web";
|
|
23
23
|
import { formatMonthDayTime } from "../_shared/engine-intl.js";
|
|
24
24
|
import { presence, presenceAfterError, detailInputId, type PresenceFlags } from "../_shared/detail-presence.js";
|
|
25
|
-
import { ownerLoadError, ownerWriteError, writeMayHaveLanded } from "../_shared/owner-load-error.js";
|
|
25
|
+
import { isOfflineFailure, ownerLoadError, ownerWriteError, writeMayHaveLanded } from "../_shared/owner-load-error.js";
|
|
26
|
+
import { logChatSendError } from "../_shared/wix-bi.js";
|
|
26
27
|
import { stashCopy, copyParam } from "../_shared/himi-copy.js";
|
|
27
28
|
import { chatRealtimeConfig, createReloadGate, createSendIntents, createVisitToken, liveDirectives, postWithVisitToken, liveFallback, type ChatLiveMode, type ChatRealtimeConfig } from "../_shared/chat-live.js";
|
|
28
29
|
|
|
@@ -280,7 +281,10 @@ const svc = defineService<ThreadState, {
|
|
|
280
281
|
} catch (e) {
|
|
281
282
|
// The draft stays: the owner should not have to type it again. A send that may
|
|
282
283
|
// have landed says so, so a retry does not post it twice unknowingly.
|
|
283
|
-
|
|
284
|
+
if (writeMayHaveLanded(e)) return { ...live(), sendHint: ownerWriteError(e) };
|
|
285
|
+
const { id, kind } = input();
|
|
286
|
+
logChatSendError({ chatroomId: s.chatroomId, contactId: kind === "contact" ? id : "", error: e, offline: isOfflineFailure(e) });
|
|
287
|
+
return { ...live(), sendHint: `${copyParam("ownerInbox.sendFailed", "Couldn’t send")} — ${ownerWriteError(e)}` };
|
|
284
288
|
}
|
|
285
289
|
// Clear the composer only if it still holds what was sent — the owner may already be
|
|
286
290
|
// typing the next message — judged on the state AFTER the re-read's await.
|
|
@@ -31117,6 +31117,7 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
|
|
|
31117
31117
|
"share",
|
|
31118
31118
|
"local_database",
|
|
31119
31119
|
"open_url",
|
|
31120
|
+
"wix_platform",
|
|
31120
31121
|
"iap",
|
|
31121
31122
|
"app_info"
|
|
31122
31123
|
],
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// RN BI events whose fields exist only in a worker (epic #4973). The platform maps send every
|
|
2
|
+
// other RN event; these go through `wixPlatform.bi.log`, built inline with RN's own field names
|
|
3
|
+
// rather than by bundling a `@wix/bi-logger-*` package. The host owns every identity and common
|
|
4
|
+
// field (msid, uuid, installationId, contactId, _lv, ...), so none is named here.
|
|
5
|
+
import { bi, type BiLogEvent } from "@himalaya/wix-platform";
|
|
6
|
+
|
|
7
|
+
/** Sends one event without waiting for it and never throws: BI must not change a screen. A
|
|
8
|
+
* screen whose descriptor does not declare `wix_platform` is refused by the host, which is
|
|
9
|
+
* swallowed here like any other BI failure. */
|
|
10
|
+
export function logBi(event: BiLogEvent): void {
|
|
11
|
+
try {
|
|
12
|
+
void Promise.resolve(bi.log(event)).catch(() => undefined);
|
|
13
|
+
} catch {
|
|
14
|
+
/* BI is best-effort */
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** The HTTP status a Wix SDK error carries (`HTTP 429: ...`, or a `status` field), else 0. */
|
|
19
|
+
export function wixErrorStatus(error: unknown): number {
|
|
20
|
+
const own = Number((error as { status?: unknown; statusCode?: unknown } | null)?.status ?? (error as { statusCode?: unknown } | null)?.statusCode);
|
|
21
|
+
if (Number.isFinite(own) && own > 0) return own;
|
|
22
|
+
const match = /\bHTTP (\d{3})\b/.exec(String((error as Error | null)?.message ?? error ?? ""));
|
|
23
|
+
return match ? Number(match[1]) : 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function applicationErrorCode(body: unknown): string {
|
|
27
|
+
const o = body as { details?: { applicationError?: { code?: unknown } }; applicationError?: { code?: unknown }; code?: unknown } | null;
|
|
28
|
+
const code = o?.details?.applicationError?.code ?? o?.applicationError?.code ?? o?.code;
|
|
29
|
+
return typeof code === "string" ? code : "";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The code both native bridges put in an application error's message: `HTTP 400 [CODE]: description`
|
|
33
|
+
* (iOS JSWorker.swift `WixApiCapability.Error.application`, Android WebViewJSWorker.kt `Error.Application`). */
|
|
34
|
+
const BRIDGE_APPLICATION_CODE = /\bHTTP \d{3} \[([A-Za-z0-9_.:-]+)\]/;
|
|
35
|
+
|
|
36
|
+
/** The Wix application error code of a failed call (RN's `serializeError(e).code`): read from the
|
|
37
|
+
* error itself, else from the `[CODE]` the native bridges put after `HTTP <status> `, else from the
|
|
38
|
+
* JSON body after `HTTP <status>: ` (the bridges' raw-status arm and the web host's wixCall). ""
|
|
39
|
+
* when there is none. */
|
|
40
|
+
export function wixErrorCode(error: unknown): string {
|
|
41
|
+
const own = applicationErrorCode(error);
|
|
42
|
+
if (own) return own;
|
|
43
|
+
const message = String((error as Error | null)?.message ?? error ?? "");
|
|
44
|
+
const bracketed = BRIDGE_APPLICATION_CODE.exec(message);
|
|
45
|
+
if (bracketed) return bracketed[1];
|
|
46
|
+
const start = message.indexOf("{");
|
|
47
|
+
if (start < 0) return "";
|
|
48
|
+
try {
|
|
49
|
+
return applicationErrorCode(JSON.parse(message.slice(start)));
|
|
50
|
+
} catch {
|
|
51
|
+
return "";
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// RN's `ErrorIndicationType` (mobile-apps-inbox services/errorIndications/errorIndications.type.ts).
|
|
56
|
+
const ERROR_INDICATIONS = new Set([
|
|
57
|
+
"ACCESS_TOKEN_EXPIRED", "ALLOWED_MESSAGING_TIME_WINDOW_EXPIRED", "ATTACHMENT_SIZE_EXCEEDS_ALLOWED_LIMIT", "CAMPAIGN_SUSPENDED",
|
|
58
|
+
"FACEBOOK_ALLOWED_WINDOW_EXPIRED", "GMAIL_ADV_PROTECTION", "INSTAGRAM_ALLOWED_WINDOW_EXPIRED", "INVALID_CHARACTERS",
|
|
59
|
+
"INVALID_PHONE_NUMBER", "INVALID_RECIPIENT_ADDRESS", "LANDLINE_OR_UNREACHABLE_CARRIER", "MESSAGE_FILTERED",
|
|
60
|
+
"MMS_NOT_SUPPORTED_RECEIVING_PHONE_NUMBER", "NETWORK_ISSUE", "NO_MATCHING_RECIPIENT_FOUND", "POLICY_VIOLATION", "QUOTA_EXCEEDED",
|
|
61
|
+
"RATE_LIMIT", "RATE_LIMIT_ERROR", "RECIPIENT_BLOCKED_MESSAGES", "RECIPIENT_NOT_AVAILABLE", "SERVICE_UNAVAILABLE",
|
|
62
|
+
"TELCO_LANDLINE_OR_UNREACHABLE_CARRIER", "TELCO_MEDIA_EXCEEDS_MESSAGING_PROVIDER_SIZE_LIMIT",
|
|
63
|
+
"TELCO_MESSAGE_DELIVERY_UNKNOWN_DESTINATION_HANDSET", "TELCO_MESSAGE_FILTERED", "TELCO_MESSAGE_FROM_NUMBER_STILL_BEING_CONFIGURED",
|
|
64
|
+
"TELCO_MESSAGE_FROM_UNREGISTERED_NUMBER", "TELCO_UNKNOWN_ERROR", "TELCO_UNREACHABLE_DESTINATION_HANDSET", "TOO_MANY_REQUESTS",
|
|
65
|
+
"TOTAL_ATTACHMENTS_SIZE_EXCEEDS_ALLOWED_LIMIT", "UNEXPECTED_ERROR_RETRY_LATER", "UNKNOWN_FAILED_CODE", "UNSUPPORTED",
|
|
66
|
+
"UNSUPPORTED_MESSAGE_TYPE", "USER_RATE_LIMIT",
|
|
67
|
+
]);
|
|
68
|
+
|
|
69
|
+
/** 5:1604 inboxSendMessageErrorMsgShown (`@wix/bi-logger-crm-data` v2, endpoint ''), for a chat
|
|
70
|
+
* send that failed and said so. RN's `errorReason` is the failed message's indication code, and
|
|
71
|
+
* RN reports a code it does not know as UNSUPPORTED (`getErrorIndicationFromCode`); a send that
|
|
72
|
+
* never left the device is NETWORK_ISSUE and a 429 is RATE_LIMIT. */
|
|
73
|
+
export function logChatSendError(input: { chatroomId: string; contactId?: string; error: unknown; offline: boolean }): void {
|
|
74
|
+
const code = wixErrorCode(input.error);
|
|
75
|
+
const errorReason = input.offline ? "NETWORK_ISSUE"
|
|
76
|
+
: ERROR_INDICATIONS.has(code) ? code
|
|
77
|
+
: wixErrorStatus(input.error) === 429 ? "RATE_LIMIT"
|
|
78
|
+
: "UNSUPPORTED";
|
|
79
|
+
logBi({
|
|
80
|
+
evid: 1604,
|
|
81
|
+
src: 5,
|
|
82
|
+
endpoint: "",
|
|
83
|
+
params: { origin: "native", chatroomId: input.chatroomId, ...(input.contactId ? { contact_id: input.contactId } : {}), errorReason },
|
|
84
|
+
});
|
|
85
|
+
}
|
|
@@ -11,6 +11,7 @@ import { createRedirectSession } from "@himalaya/wix-redirects";
|
|
|
11
11
|
import { isPaymentSetupFailure, payCashierOrder } from "@himalaya/checkout";
|
|
12
12
|
import { hostedCheckoutOpener, isHostedWorker } from "../_shared/hosted-checkout.js";
|
|
13
13
|
import { formatCurrency } from "../_shared/engine-intl.js";
|
|
14
|
+
import { logBi, wixErrorCode } from "../_shared/wix-bi.js";
|
|
14
15
|
|
|
15
16
|
/** Wix Stores appDefId — the vertical that owns a cart/ecom order, and therefore the
|
|
16
17
|
* `appId` its cashier order is paid under. (Same constant Wix's own tooling uses.) */
|
|
@@ -458,6 +459,14 @@ const svc = defineService<State, {
|
|
|
458
459
|
const mayHaveLanded = added || writeMayHaveLanded(error);
|
|
459
460
|
const refreshed = mayHaveLanded ? await refresh(state).catch(() => null) : null;
|
|
460
461
|
if (refreshed?.appliedCode === code) return derive({ ...refreshed, promoBusy: false, promoCode: "", promoError: "" });
|
|
462
|
+
// 130:117 couponApplyingFailed (ecom-platform bi/storefront.ts:448, sent from cartActions.ts:345 when
|
|
463
|
+
// the add-coupon call throws). errorCode is RN's serializeError(e).code, the Wix application error code.
|
|
464
|
+
// Only the add-coupon call itself: once it answered, the coupon is on the cart, and a later step that
|
|
465
|
+
// throws (the cart refresh) is not a coupon that failed to apply.
|
|
466
|
+
if (!added) {
|
|
467
|
+
const errorCode = wixErrorCode(error);
|
|
468
|
+
logBi({ evid: 117, src: 130, endpoint: "ec-site", params: { origin: "checkout", couponCode: code, ...(errorCode ? { errorCode } : {}) } });
|
|
469
|
+
}
|
|
461
470
|
return derive({ ...state, promoBusy: false, promoError: mayHaveLanded
|
|
462
471
|
? copyParam("cart.promoUnconfirmed", "Could not confirm the promo code. Refresh your cart.")
|
|
463
472
|
: isOfflineFailure(error)
|
|
@@ -66166,7 +66166,8 @@ const SCREENS = runtimeSetting({
|
|
|
66166
66166
|
"integrity": "",
|
|
66167
66167
|
"contentType": "application/javascript+ts-bundle",
|
|
66168
66168
|
"declaredCapabilities": [
|
|
66169
|
-
"wix_api"
|
|
66169
|
+
"wix_api",
|
|
66170
|
+
"wix_platform"
|
|
66170
66171
|
],
|
|
66171
66172
|
"minBinaryVersion": "0.1.0",
|
|
66172
66173
|
"bundleVersion": "0.0.1"
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// RN BI events whose fields exist only in a worker (epic #4973). The platform maps send every
|
|
2
|
+
// other RN event; these go through `wixPlatform.bi.log`, built inline with RN's own field names
|
|
3
|
+
// rather than by bundling a `@wix/bi-logger-*` package. The host owns every identity and common
|
|
4
|
+
// field (msid, uuid, installationId, contactId, _lv, ...), so none is named here.
|
|
5
|
+
import { bi, type BiLogEvent } from "@himalaya/wix-platform";
|
|
6
|
+
|
|
7
|
+
/** Sends one event without waiting for it and never throws: BI must not change a screen. A
|
|
8
|
+
* screen whose descriptor does not declare `wix_platform` is refused by the host, which is
|
|
9
|
+
* swallowed here like any other BI failure. */
|
|
10
|
+
export function logBi(event: BiLogEvent): void {
|
|
11
|
+
try {
|
|
12
|
+
void Promise.resolve(bi.log(event)).catch(() => undefined);
|
|
13
|
+
} catch {
|
|
14
|
+
/* BI is best-effort */
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** The HTTP status a Wix SDK error carries (`HTTP 429: ...`, or a `status` field), else 0. */
|
|
19
|
+
export function wixErrorStatus(error: unknown): number {
|
|
20
|
+
const own = Number((error as { status?: unknown; statusCode?: unknown } | null)?.status ?? (error as { statusCode?: unknown } | null)?.statusCode);
|
|
21
|
+
if (Number.isFinite(own) && own > 0) return own;
|
|
22
|
+
const match = /\bHTTP (\d{3})\b/.exec(String((error as Error | null)?.message ?? error ?? ""));
|
|
23
|
+
return match ? Number(match[1]) : 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function applicationErrorCode(body: unknown): string {
|
|
27
|
+
const o = body as { details?: { applicationError?: { code?: unknown } }; applicationError?: { code?: unknown }; code?: unknown } | null;
|
|
28
|
+
const code = o?.details?.applicationError?.code ?? o?.applicationError?.code ?? o?.code;
|
|
29
|
+
return typeof code === "string" ? code : "";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The code both native bridges put in an application error's message: `HTTP 400 [CODE]: description`
|
|
33
|
+
* (iOS JSWorker.swift `WixApiCapability.Error.application`, Android WebViewJSWorker.kt `Error.Application`). */
|
|
34
|
+
const BRIDGE_APPLICATION_CODE = /\bHTTP \d{3} \[([A-Za-z0-9_.:-]+)\]/;
|
|
35
|
+
|
|
36
|
+
/** The Wix application error code of a failed call (RN's `serializeError(e).code`): read from the
|
|
37
|
+
* error itself, else from the `[CODE]` the native bridges put after `HTTP <status> `, else from the
|
|
38
|
+
* JSON body after `HTTP <status>: ` (the bridges' raw-status arm and the web host's wixCall). ""
|
|
39
|
+
* when there is none. */
|
|
40
|
+
export function wixErrorCode(error: unknown): string {
|
|
41
|
+
const own = applicationErrorCode(error);
|
|
42
|
+
if (own) return own;
|
|
43
|
+
const message = String((error as Error | null)?.message ?? error ?? "");
|
|
44
|
+
const bracketed = BRIDGE_APPLICATION_CODE.exec(message);
|
|
45
|
+
if (bracketed) return bracketed[1];
|
|
46
|
+
const start = message.indexOf("{");
|
|
47
|
+
if (start < 0) return "";
|
|
48
|
+
try {
|
|
49
|
+
return applicationErrorCode(JSON.parse(message.slice(start)));
|
|
50
|
+
} catch {
|
|
51
|
+
return "";
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// RN's `ErrorIndicationType` (mobile-apps-inbox services/errorIndications/errorIndications.type.ts).
|
|
56
|
+
const ERROR_INDICATIONS = new Set([
|
|
57
|
+
"ACCESS_TOKEN_EXPIRED", "ALLOWED_MESSAGING_TIME_WINDOW_EXPIRED", "ATTACHMENT_SIZE_EXCEEDS_ALLOWED_LIMIT", "CAMPAIGN_SUSPENDED",
|
|
58
|
+
"FACEBOOK_ALLOWED_WINDOW_EXPIRED", "GMAIL_ADV_PROTECTION", "INSTAGRAM_ALLOWED_WINDOW_EXPIRED", "INVALID_CHARACTERS",
|
|
59
|
+
"INVALID_PHONE_NUMBER", "INVALID_RECIPIENT_ADDRESS", "LANDLINE_OR_UNREACHABLE_CARRIER", "MESSAGE_FILTERED",
|
|
60
|
+
"MMS_NOT_SUPPORTED_RECEIVING_PHONE_NUMBER", "NETWORK_ISSUE", "NO_MATCHING_RECIPIENT_FOUND", "POLICY_VIOLATION", "QUOTA_EXCEEDED",
|
|
61
|
+
"RATE_LIMIT", "RATE_LIMIT_ERROR", "RECIPIENT_BLOCKED_MESSAGES", "RECIPIENT_NOT_AVAILABLE", "SERVICE_UNAVAILABLE",
|
|
62
|
+
"TELCO_LANDLINE_OR_UNREACHABLE_CARRIER", "TELCO_MEDIA_EXCEEDS_MESSAGING_PROVIDER_SIZE_LIMIT",
|
|
63
|
+
"TELCO_MESSAGE_DELIVERY_UNKNOWN_DESTINATION_HANDSET", "TELCO_MESSAGE_FILTERED", "TELCO_MESSAGE_FROM_NUMBER_STILL_BEING_CONFIGURED",
|
|
64
|
+
"TELCO_MESSAGE_FROM_UNREGISTERED_NUMBER", "TELCO_UNKNOWN_ERROR", "TELCO_UNREACHABLE_DESTINATION_HANDSET", "TOO_MANY_REQUESTS",
|
|
65
|
+
"TOTAL_ATTACHMENTS_SIZE_EXCEEDS_ALLOWED_LIMIT", "UNEXPECTED_ERROR_RETRY_LATER", "UNKNOWN_FAILED_CODE", "UNSUPPORTED",
|
|
66
|
+
"UNSUPPORTED_MESSAGE_TYPE", "USER_RATE_LIMIT",
|
|
67
|
+
]);
|
|
68
|
+
|
|
69
|
+
/** 5:1604 inboxSendMessageErrorMsgShown (`@wix/bi-logger-crm-data` v2, endpoint ''), for a chat
|
|
70
|
+
* send that failed and said so. RN's `errorReason` is the failed message's indication code, and
|
|
71
|
+
* RN reports a code it does not know as UNSUPPORTED (`getErrorIndicationFromCode`); a send that
|
|
72
|
+
* never left the device is NETWORK_ISSUE and a 429 is RATE_LIMIT. */
|
|
73
|
+
export function logChatSendError(input: { chatroomId: string; contactId?: string; error: unknown; offline: boolean }): void {
|
|
74
|
+
const code = wixErrorCode(input.error);
|
|
75
|
+
const errorReason = input.offline ? "NETWORK_ISSUE"
|
|
76
|
+
: ERROR_INDICATIONS.has(code) ? code
|
|
77
|
+
: wixErrorStatus(input.error) === 429 ? "RATE_LIMIT"
|
|
78
|
+
: "UNSUPPORTED";
|
|
79
|
+
logBi({
|
|
80
|
+
evid: 1604,
|
|
81
|
+
src: 5,
|
|
82
|
+
endpoint: "",
|
|
83
|
+
params: { origin: "native", chatroomId: input.chatroomId, ...(input.contactId ? { contact_id: input.contactId } : {}), errorReason },
|
|
84
|
+
});
|
|
85
|
+
}
|
|
@@ -22,7 +22,8 @@ import { defineService, navigate, type NavDirective, type PollDirective, type St
|
|
|
22
22
|
import { getMessages, sendChatMessage, listChatrooms, markChatroomRead, getChatToken, type ChatMessage } from "@himalaya/wix-chat-web";
|
|
23
23
|
import { formatMonthDayTime } from "../_shared/engine-intl.js";
|
|
24
24
|
import { presence, presenceAfterError, detailInputId, type PresenceFlags } from "../_shared/detail-presence.js";
|
|
25
|
-
import { ownerLoadError, ownerWriteError, writeMayHaveLanded } from "../_shared/owner-load-error.js";
|
|
25
|
+
import { isOfflineFailure, ownerLoadError, ownerWriteError, writeMayHaveLanded } from "../_shared/owner-load-error.js";
|
|
26
|
+
import { logChatSendError } from "../_shared/wix-bi.js";
|
|
26
27
|
import { stashCopy, copyParam } from "../_shared/himi-copy.js";
|
|
27
28
|
import { chatRealtimeConfig, createReloadGate, createSendIntents, createVisitToken, liveDirectives, postWithVisitToken, liveFallback, type ChatLiveMode, type ChatRealtimeConfig } from "../_shared/chat-live.js";
|
|
28
29
|
|
|
@@ -280,7 +281,10 @@ const svc = defineService<ThreadState, {
|
|
|
280
281
|
} catch (e) {
|
|
281
282
|
// The draft stays: the owner should not have to type it again. A send that may
|
|
282
283
|
// have landed says so, so a retry does not post it twice unknowingly.
|
|
283
|
-
|
|
284
|
+
if (writeMayHaveLanded(e)) return { ...live(), sendHint: ownerWriteError(e) };
|
|
285
|
+
const { id, kind } = input();
|
|
286
|
+
logChatSendError({ chatroomId: s.chatroomId, contactId: kind === "contact" ? id : "", error: e, offline: isOfflineFailure(e) });
|
|
287
|
+
return { ...live(), sendHint: `${copyParam("ownerInbox.sendFailed", "Couldn’t send")} — ${ownerWriteError(e)}` };
|
|
284
288
|
}
|
|
285
289
|
// Clear the composer only if it still holds what was sent — the owner may already be
|
|
286
290
|
// typing the next message — judged on the state AFTER the re-read's await.
|
|
@@ -20932,7 +20932,8 @@ const SCREENS = runtimeSetting({
|
|
|
20932
20932
|
"wix_api",
|
|
20933
20933
|
"wix_cashier",
|
|
20934
20934
|
"open_url",
|
|
20935
|
-
"local_database"
|
|
20935
|
+
"local_database",
|
|
20936
|
+
"wix_platform"
|
|
20936
20937
|
],
|
|
20937
20938
|
"minBinaryVersion": "0.1.0",
|
|
20938
20939
|
"bundleVersion": "0.0.1"
|