@uappi/public-sdk 2.0.1 → 2.1.1
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/components/PaymentHosted/PaymentHosted.vue +1 -1
- package/modules/Api/endpoints/CustomerComposable.ts +2 -1
- package/modules/Api/types/endpoints/customer/customer.interfaces.ts +7 -0
- package/modules/Api/types/endpoints/third-party/facebook.interfaces.ts +1 -0
- package/modules/Api/types/index.ts +2 -0
- package/modules/Tracking/endpoints/CustomerComposable.ts +2 -1
- package/modules/Tracking/facebook/events/actions/addToCart.ts +4 -1
- package/modules/Tracking/facebook/events/actions/purchase.ts +28 -6
- package/modules/Tracking/facebook/events/actions/purchaseOrder.ts +16 -3
- package/package.json +1 -1
|
@@ -143,7 +143,7 @@ function handleIframeMessage(event: MessageEvent): void {
|
|
|
143
143
|
case 'UAPPI_PAYMENT_SUCCESS':
|
|
144
144
|
if (props.orderGroup) {
|
|
145
145
|
purchaseOrderAction(props.option.paymentType.code, props.orderGroup);
|
|
146
|
-
facebookPurchaseOrderAction(props.orderGroup
|
|
146
|
+
facebookPurchaseOrderAction(props.orderGroup);
|
|
147
147
|
} else if (cartSnapshot.value) {
|
|
148
148
|
purchaseAction(props.option.paymentType.code, cartSnapshot.value, data.code);
|
|
149
149
|
facebookPurchaseAction(data.id, cartSnapshot.value);
|
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
ApiParams,
|
|
5
5
|
CustomerResponse,
|
|
6
6
|
SignupCustomer,
|
|
7
|
+
SignupCustomerBySocialLogin,
|
|
7
8
|
SigninCustomerByDocument,
|
|
8
9
|
SigninCustomerByEmail,
|
|
9
10
|
ResponseSigninCustomer,
|
|
@@ -58,7 +59,7 @@ export function detail(
|
|
|
58
59
|
>({ endpoint: '/customer', params: options });
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
export function signup(payload: SignupCustomer) {
|
|
62
|
+
export function signup(payload: SignupCustomer | SignupCustomerBySocialLogin) {
|
|
62
63
|
return usePublicApi<CustomerResponse>({
|
|
63
64
|
endpoint: '/customer',
|
|
64
65
|
method: 'POST',
|
|
@@ -85,6 +85,13 @@ export interface SignupCustomer {
|
|
|
85
85
|
documents?: Array<CustomerDocument>;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
export interface SignupCustomerBySocialLogin
|
|
89
|
+
extends Omit<SignupCustomer, 'email' | 'password'> {
|
|
90
|
+
socialLoginToken: string;
|
|
91
|
+
email?: never;
|
|
92
|
+
password?: never;
|
|
93
|
+
}
|
|
94
|
+
|
|
88
95
|
export interface CustomerDocument {
|
|
89
96
|
type: 'cpf' | 'rg' | 'cnpj' | 'ie' | 'document1' | 'document2' | 'document3';
|
|
90
97
|
document: string;
|
|
@@ -91,6 +91,7 @@ import type {
|
|
|
91
91
|
SigninCustomerByDocument,
|
|
92
92
|
SigninCustomerByEmail,
|
|
93
93
|
SignupCustomer,
|
|
94
|
+
SignupCustomerBySocialLogin,
|
|
94
95
|
ResponseSigninCustomer,
|
|
95
96
|
CustomerDocument,
|
|
96
97
|
UpsertCustomerAddressRequest,
|
|
@@ -476,6 +477,7 @@ export type {
|
|
|
476
477
|
ResponseSigninCustomer,
|
|
477
478
|
CustomerDocument,
|
|
478
479
|
SignupCustomer,
|
|
480
|
+
SignupCustomerBySocialLogin,
|
|
479
481
|
CustomerGender,
|
|
480
482
|
CustomerOrigin,
|
|
481
483
|
CustomerConditionFields,
|
|
@@ -16,6 +16,7 @@ import type {
|
|
|
16
16
|
SigninCustomerByDocument,
|
|
17
17
|
SigninCustomerByEmail,
|
|
18
18
|
SignupCustomer,
|
|
19
|
+
SignupCustomerBySocialLogin,
|
|
19
20
|
} from '../../Api/types';
|
|
20
21
|
|
|
21
22
|
export function detail(
|
|
@@ -42,7 +43,7 @@ export function detail(
|
|
|
42
43
|
});
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
export function signup(payload: SignupCustomer) {
|
|
46
|
+
export function signup(payload: SignupCustomer | SignupCustomerBySocialLogin) {
|
|
46
47
|
return publicApi.customer.signup(payload).then(data => {
|
|
47
48
|
signupAction();
|
|
48
49
|
return data;
|
|
@@ -16,8 +16,11 @@ export function addToCartAction(
|
|
|
16
16
|
? item.quantity - item.oldQuantity
|
|
17
17
|
: item.quantity;
|
|
18
18
|
|
|
19
|
+
if (quantity <= 0) return;
|
|
20
|
+
|
|
19
21
|
api.thirdParty
|
|
20
22
|
.facebookAddToCart({
|
|
23
|
+
productId: item.product.productId,
|
|
21
24
|
sku: item.product.sku,
|
|
22
25
|
quantity,
|
|
23
26
|
price: item.unitValue,
|
|
@@ -27,7 +30,7 @@ export function addToCartAction(
|
|
|
27
30
|
'track',
|
|
28
31
|
'AddToCart',
|
|
29
32
|
{
|
|
30
|
-
content_ids: [item.product.
|
|
33
|
+
content_ids: [`${item.product.productId}`],
|
|
31
34
|
content_type: 'product',
|
|
32
35
|
value: item.unitValue * quantity,
|
|
33
36
|
currency: 'BRL',
|
|
@@ -1,21 +1,43 @@
|
|
|
1
1
|
import api from '../../../../Api';
|
|
2
|
-
import {
|
|
2
|
+
import { getAllOrderItems } from '../../../utils/cart';
|
|
3
3
|
import { pushFbq } from '../../../utils/pushFbq';
|
|
4
4
|
|
|
5
5
|
import type { CartResponse } from '../../../../Api/types';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* O valor sai do pedido criado: o desconto à vista (ex: Pix) só é aplicado na
|
|
9
|
+
* criação do pedido e não aparece no carrinho
|
|
10
|
+
*/
|
|
11
|
+
function orderTotalValue(orderGroupId: number, cartPayload: CartResponse) {
|
|
12
|
+
return api.customer
|
|
13
|
+
.detailOrderGroup(orderGroupId, { fields: ['values'] })
|
|
14
|
+
.then(order => order.values?.totalValue ?? cartPayload.totalValue)
|
|
15
|
+
.catch(() => cartPayload.totalValue);
|
|
16
|
+
}
|
|
17
|
+
|
|
7
18
|
export function purchaseAction(orderGroupId: number, cartPayload: CartResponse) {
|
|
8
19
|
if (!window.fbq) return;
|
|
9
20
|
|
|
10
|
-
const
|
|
21
|
+
const contentIds = [
|
|
22
|
+
...new Set(
|
|
23
|
+
getAllOrderItems(cartPayload.orders).map(item => `${item.product.productId}`),
|
|
24
|
+
),
|
|
25
|
+
];
|
|
11
26
|
|
|
12
|
-
|
|
13
|
-
.facebookPurchase({ orderGroupId })
|
|
14
|
-
|
|
27
|
+
Promise.all([
|
|
28
|
+
api.thirdParty.facebookPurchase({ orderGroupId }),
|
|
29
|
+
orderTotalValue(orderGroupId, cartPayload),
|
|
30
|
+
])
|
|
31
|
+
.then(([eventId, value]) =>
|
|
15
32
|
pushFbq(
|
|
16
33
|
'track',
|
|
17
34
|
'Purchase',
|
|
18
|
-
{
|
|
35
|
+
{
|
|
36
|
+
value,
|
|
37
|
+
currency: 'BRL',
|
|
38
|
+
content_ids: contentIds,
|
|
39
|
+
content_type: 'product',
|
|
40
|
+
},
|
|
19
41
|
{ eventID: eventId },
|
|
20
42
|
),
|
|
21
43
|
)
|
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
import api from '../../../../Api';
|
|
2
2
|
import { pushFbq } from '../../../utils/pushFbq';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import type { CustomerOrderResponse } from '../../../../Api/types';
|
|
5
|
+
|
|
6
|
+
export function purchaseOrderAction(orderGroup: CustomerOrderResponse) {
|
|
5
7
|
if (!window.fbq) return;
|
|
6
8
|
|
|
9
|
+
const contentIds = [
|
|
10
|
+
...new Set(
|
|
11
|
+
orderGroup.orders.flatMap(order => order.items).map(item => `${item.productId}`),
|
|
12
|
+
),
|
|
13
|
+
];
|
|
14
|
+
|
|
7
15
|
api.thirdParty
|
|
8
|
-
.facebookPurchase({ orderGroupId })
|
|
16
|
+
.facebookPurchase({ orderGroupId: orderGroup.id })
|
|
9
17
|
.then(eventId =>
|
|
10
18
|
pushFbq(
|
|
11
19
|
'track',
|
|
12
20
|
'Purchase',
|
|
13
|
-
{
|
|
21
|
+
{
|
|
22
|
+
value: orderGroup.values?.totalValue ?? 0,
|
|
23
|
+
currency: 'BRL',
|
|
24
|
+
content_ids: contentIds,
|
|
25
|
+
content_type: 'product',
|
|
26
|
+
},
|
|
14
27
|
{ eventID: eventId },
|
|
15
28
|
),
|
|
16
29
|
)
|