@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
|
@@ -12,6 +12,7 @@ import { smartChatHistory } from '../_shared/business-chat-history.js';
|
|
|
12
12
|
import { hostSiteFromInput } from '../_shared/branded-lite-hosted.js';
|
|
13
13
|
import { productImage, searchStoreProducts } from '../_shared/himi-store.js';
|
|
14
14
|
import { queryServices } from '@himalaya/wix-bookings';
|
|
15
|
+
import { logBi, logChatSendError } from '../_shared/wix-bi.js';
|
|
15
16
|
|
|
16
17
|
type PendingIntent = BusinessChatIntent & { suggestionId?:string; answerTo?:string };
|
|
17
18
|
// Only what the screen reads. This state crosses into the worker on every keystroke, so a row carries no raw
|
|
@@ -424,6 +425,8 @@ async function deliver(pending:BusinessChatIntent,draft:string):Promise<void>{
|
|
|
424
425
|
}catch(error){
|
|
425
426
|
const lost=/member_sign_in_required|MemberAccessChanged|\b401\b|\b403\b/i.test(String(error));
|
|
426
427
|
result={id:pending.id,draft,error,outcome:lost?'signed_out':businessChatSendRejected(error)?'rejected':'unconfirmed'};
|
|
428
|
+
// 5:1604: a rejected send is the one the screen reports as failed (an unconfirmed one asks the member to check).
|
|
429
|
+
if(result.outcome==='rejected'&&sendEpoch===epoch)logChatSendError({chatroomId:pending.roomId,error,offline:false});
|
|
427
430
|
}
|
|
428
431
|
if(sendEpoch===epoch)void svc.settleSend(result);
|
|
429
432
|
}
|
|
@@ -556,6 +559,11 @@ const svc=defineService<State,Record<string,(s:State,a?:unknown)=>State|undefine
|
|
|
556
559
|
const ownName=[...s.messages].reverse().find(row=>row.mine&&row.senderName)?.senderName??'';
|
|
557
560
|
const pending={...newBusinessChatIntent(text,s.roomId,s.principal),senderName:ownName,...sendAnchor(s.messages,text,s.phase==='ready'),smartChatFromStart:s.transcriptSource==='members'&&s.smartChatEmpty};
|
|
558
561
|
draftRevision++;// a refresh that began before this send must not bring the sent text back into the composer
|
|
562
|
+
// 5:510 engageSendMessageClick, as RN's mobile-apps-inbox logSendMessage sends it for a member's typed message to the
|
|
563
|
+
// business (biLogger.service.ts:226-258, origin 'native' from biLogger.utils.ts). RN has no contact id here either.
|
|
564
|
+
// It is logged on the Send tap, before the network call, on purpose: RN calls engageSendMessageClick synchronously
|
|
565
|
+
// before sendMessageService.sendMessage, so a send the server then refuses has logged 510 and also logs 1604 (deliver).
|
|
566
|
+
logBi({evid:510,src:5,endpoint:'',params:{origin:'native',is_member:true,chatRoomType:'member to business',activity_type:'',appName:'',expand_mode:false,textLength:text.length,is_demo:false}});
|
|
559
567
|
void deliver(pending,s.draft);
|
|
560
568
|
return shape({...s,draft:'',pendingIntent:pending,messages:[...s.messages,pendingRow(pending)],error:'',notice:'',scrollSend:s.scrollSend+1});
|
|
561
569
|
},
|
|
@@ -9902,7 +9902,8 @@ const SCREENS = runtimeSetting({
|
|
|
9902
9902
|
"declaredCapabilities": [
|
|
9903
9903
|
"wix_api",
|
|
9904
9904
|
"wix_chat",
|
|
9905
|
-
"open_url"
|
|
9905
|
+
"open_url",
|
|
9906
|
+
"wix_platform"
|
|
9906
9907
|
],
|
|
9907
9908
|
"minBinaryVersion": "0.1.0",
|
|
9908
9909
|
"bundleVersion": "0.1.0"
|
|
@@ -11894,6 +11895,7 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
|
|
|
11894
11895
|
"share",
|
|
11895
11896
|
"local_database",
|
|
11896
11897
|
"open_url",
|
|
11898
|
+
"wix_platform",
|
|
11897
11899
|
"iap",
|
|
11898
11900
|
"app_info"
|
|
11899
11901
|
],
|
|
@@ -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
|
+
}
|
|
@@ -12,6 +12,7 @@ import { smartChatHistory } from '../_shared/business-chat-history.js';
|
|
|
12
12
|
import { hostSiteFromInput } from '../_shared/branded-lite-hosted.js';
|
|
13
13
|
import { productImage, searchStoreProducts } from '../_shared/himi-store.js';
|
|
14
14
|
import { queryServices } from '@himalaya/wix-bookings';
|
|
15
|
+
import { logBi, logChatSendError } from '../_shared/wix-bi.js';
|
|
15
16
|
|
|
16
17
|
type PendingIntent = BusinessChatIntent & { suggestionId?:string; answerTo?:string };
|
|
17
18
|
// Only what the screen reads. This state crosses into the worker on every keystroke, so a row carries no raw
|
|
@@ -424,6 +425,8 @@ async function deliver(pending:BusinessChatIntent,draft:string):Promise<void>{
|
|
|
424
425
|
}catch(error){
|
|
425
426
|
const lost=/member_sign_in_required|MemberAccessChanged|\b401\b|\b403\b/i.test(String(error));
|
|
426
427
|
result={id:pending.id,draft,error,outcome:lost?'signed_out':businessChatSendRejected(error)?'rejected':'unconfirmed'};
|
|
428
|
+
// 5:1604: a rejected send is the one the screen reports as failed (an unconfirmed one asks the member to check).
|
|
429
|
+
if(result.outcome==='rejected'&&sendEpoch===epoch)logChatSendError({chatroomId:pending.roomId,error,offline:false});
|
|
427
430
|
}
|
|
428
431
|
if(sendEpoch===epoch)void svc.settleSend(result);
|
|
429
432
|
}
|
|
@@ -556,6 +559,11 @@ const svc=defineService<State,Record<string,(s:State,a?:unknown)=>State|undefine
|
|
|
556
559
|
const ownName=[...s.messages].reverse().find(row=>row.mine&&row.senderName)?.senderName??'';
|
|
557
560
|
const pending={...newBusinessChatIntent(text,s.roomId,s.principal),senderName:ownName,...sendAnchor(s.messages,text,s.phase==='ready'),smartChatFromStart:s.transcriptSource==='members'&&s.smartChatEmpty};
|
|
558
561
|
draftRevision++;// a refresh that began before this send must not bring the sent text back into the composer
|
|
562
|
+
// 5:510 engageSendMessageClick, as RN's mobile-apps-inbox logSendMessage sends it for a member's typed message to the
|
|
563
|
+
// business (biLogger.service.ts:226-258, origin 'native' from biLogger.utils.ts). RN has no contact id here either.
|
|
564
|
+
// It is logged on the Send tap, before the network call, on purpose: RN calls engageSendMessageClick synchronously
|
|
565
|
+
// before sendMessageService.sendMessage, so a send the server then refuses has logged 510 and also logs 1604 (deliver).
|
|
566
|
+
logBi({evid:510,src:5,endpoint:'',params:{origin:'native',is_member:true,chatRoomType:'member to business',activity_type:'',appName:'',expand_mode:false,textLength:text.length,is_demo:false}});
|
|
559
567
|
void deliver(pending,s.draft);
|
|
560
568
|
return shape({...s,draft:'',pendingIntent:pending,messages:[...s.messages,pendingRow(pending)],error:'',notice:'',scrollSend:s.scrollSend+1});
|
|
561
569
|
},
|
|
@@ -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)
|
|
@@ -17,6 +17,7 @@ import { getStoreProduct, plainText, productImage, productPrice, wixMediaUrl, pr
|
|
|
17
17
|
import { cleanTitle } from "../_shared/himi-text.js";
|
|
18
18
|
import { stashCopy, copyParam, copyTemplate } from "../_shared/himi-copy.js";
|
|
19
19
|
import { isBridgeUnavailable } from "../_shared/owner-load-error.js";
|
|
20
|
+
import { logBi } from "../_shared/wix-bi.js";
|
|
20
21
|
import { isProductSaved, toggleSavedProduct } from "../_shared/himi-store-saved.js";
|
|
21
22
|
import { openRichLink } from "../_shared/rich-content-link.js";
|
|
22
23
|
import { descriptionBody } from "../_shared/rich-body.js";
|
|
@@ -129,6 +130,18 @@ function outOfStockPick(groups: StoreOption[], selection: StoreOptionSelection):
|
|
|
129
130
|
}
|
|
130
131
|
|
|
131
132
|
/** What to say under the picker: the groups still unchosen, else the choice made. */
|
|
133
|
+
/** 10:183 addToCartError (wix-store-merchant-app features/front/bi/index.ts:117, sent from
|
|
134
|
+
* ProductViewScreen when Add to cart fails validation). RN's `field` joins the failed checks by
|
|
135
|
+
* its own names: a required option left unchosen is `product_options`, a chosen combination with
|
|
136
|
+
* no stock left is `quantity`. Himi has no custom text fields, so `custom_field` never appears. */
|
|
137
|
+
function logAddToCartError(productId: string, groups: StoreOption[], selection: StoreOptionSelection): void {
|
|
138
|
+
const field = [
|
|
139
|
+
...(groups.some((g) => !selection[g.id]) ? ["product_options"] : []),
|
|
140
|
+
...(outOfStockPick(groups, selection) ? ["quantity"] : []),
|
|
141
|
+
].join(",");
|
|
142
|
+
if (field) logBi({ evid: 183, src: 10, endpoint: "ec-sf", params: { productId, message: "validation error", field } });
|
|
143
|
+
}
|
|
144
|
+
|
|
132
145
|
function optionsHint(groups: StoreOption[], selection: StoreOptionSelection): string {
|
|
133
146
|
const missing = groups.filter((g) => !selection[g.id]).map((g) => g.name);
|
|
134
147
|
if (!missing.length) {
|
|
@@ -792,6 +805,7 @@ const svc = onlineService<S, {
|
|
|
792
805
|
if (s.adding) return s;
|
|
793
806
|
// Missing choices show field errors; unavailable products still fail closed.
|
|
794
807
|
if (s.optionsIncomplete) {
|
|
808
|
+
if (!s.optionsUnknown) logAddToCartError(id, s.optionGroups, s.selection);
|
|
795
809
|
// With no groups in hand there is nothing for `optionsHint` to name, so the
|
|
796
810
|
// offline case needs its own reason rather than an empty string.
|
|
797
811
|
return derive({ ...s, showOptionErrors: true, optionValidationTarget: s.optionGroups.find(g => !s.selection[g.id])?.id ?? "", optionValidationRequest: (s.optionValidationRequest || 0) + 1, cartHint: s.optionsUnknown
|
|
@@ -65859,7 +65859,8 @@ const SCREENS = runtimeSetting({
|
|
|
65859
65859
|
"integrity": "",
|
|
65860
65860
|
"contentType": "application/javascript+ts-bundle",
|
|
65861
65861
|
"declaredCapabilities": [
|
|
65862
|
-
"wix_api"
|
|
65862
|
+
"wix_api",
|
|
65863
|
+
"wix_platform"
|
|
65863
65864
|
],
|
|
65864
65865
|
"minBinaryVersion": "0.1.0",
|
|
65865
65866
|
"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.
|