@uappi/public-sdk 1.15.0 → 1.17.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.
Files changed (47) hide show
  1. package/CLAUDE.md +59 -0
  2. package/components/ColorTheme/index.ts +1 -1
  3. package/components/ColorTheme/types.ts +10 -7
  4. package/components/PaymentHosted/PaymentHosted.vue +1 -1
  5. package/modules/Api/endpoints/ThirdPartyComposable.ts +51 -1
  6. package/modules/Api/index.ts +16 -2
  7. package/modules/Api/types/endpoints/third-party/facebook.interfaces.ts +18 -0
  8. package/modules/Api/types/index.ts +20 -10
  9. package/modules/Tracking/endpoints/BannerComposable.ts +1 -1
  10. package/modules/Tracking/endpoints/CartComposable.ts +15 -7
  11. package/modules/Tracking/endpoints/CustomerComposable.ts +5 -5
  12. package/modules/Tracking/endpoints/ProductQuoteShipment.ts +1 -1
  13. package/modules/Tracking/endpoints/SearchComposable.ts +9 -2
  14. package/modules/Tracking/endpoints/ShowcaseComposable.ts +1 -1
  15. package/modules/Tracking/endpoints/UrlComposable.ts +11 -4
  16. package/modules/Tracking/facebook/events/actions/addPaymentInfo.ts +14 -0
  17. package/modules/Tracking/facebook/events/actions/addToCart.ts +22 -0
  18. package/modules/Tracking/facebook/events/actions/initiateCheckout.ts +7 -0
  19. package/modules/Tracking/facebook/events/actions/search.ts +10 -0
  20. package/modules/Tracking/facebook/events/views/pageView.ts +5 -0
  21. package/modules/Tracking/facebook/events/views/viewContent.ts +9 -0
  22. package/modules/Tracking/{events → gtm/events}/actions/addPaymentInfo.ts +3 -3
  23. package/modules/Tracking/{events → gtm/events}/actions/addShippingInfo.ts +3 -3
  24. package/modules/Tracking/{events → gtm/events}/actions/addToCart.ts +4 -4
  25. package/modules/Tracking/{events → gtm/events}/actions/beginCheckout.ts +3 -3
  26. package/modules/Tracking/{events → gtm/events}/actions/customerProfile.ts +2 -2
  27. package/modules/Tracking/{events → gtm/events}/actions/generateLead.ts +2 -2
  28. package/modules/Tracking/{events → gtm/events}/actions/login.ts +1 -1
  29. package/modules/Tracking/{events → gtm/events}/actions/purchase.ts +3 -3
  30. package/modules/Tracking/{events → gtm/events}/actions/removeFromCart.ts +3 -3
  31. package/modules/Tracking/{events → gtm/events}/actions/search.ts +1 -1
  32. package/modules/Tracking/{events → gtm/events}/actions/selectItem.ts +3 -3
  33. package/modules/Tracking/{events → gtm/events}/actions/selectPromotion.ts +3 -3
  34. package/modules/Tracking/{events → gtm/events}/actions/shippingCalculation.ts +1 -1
  35. package/modules/Tracking/{events → gtm/events}/actions/signup.ts +1 -1
  36. package/modules/Tracking/{events → gtm/events}/actions/upsertToCart.ts +4 -4
  37. package/modules/Tracking/{events → gtm/events}/views/viewCart.ts +3 -3
  38. package/modules/Tracking/{events → gtm/events}/views/viewHome.ts +1 -1
  39. package/modules/Tracking/{events → gtm/events}/views/viewItem.ts +3 -3
  40. package/modules/Tracking/{events → gtm/events}/views/viewItemList.ts +3 -3
  41. package/modules/Tracking/{events → gtm/events}/views/viewNotFound.ts +1 -1
  42. package/modules/Tracking/{events → gtm/events}/views/viewOther.ts +1 -1
  43. package/modules/Tracking/{events → gtm/events}/views/viewPayment.ts +1 -1
  44. package/modules/Tracking/{events → gtm/events}/views/viewPromotion.ts +3 -3
  45. package/modules/Tracking/{events → gtm/events}/views/viewShipping.ts +1 -1
  46. package/modules/Tracking/index.ts +53 -10
  47. package/package.json +1 -1
package/CLAUDE.md ADDED
@@ -0,0 +1,59 @@
1
+ # Como trabalhar neste projeto
2
+
3
+ ## 1. Pense Antes de Programar
4
+
5
+ **Não faça suposições. Não esconda dúvidas. Exponha os dilemas e escolhas (trade-offs).**
6
+
7
+ Antes de implementar:
8
+ - Declare suas suposições explicitamente. Se estiver incerto, pergunte.
9
+ - Se houver múltiplas interpretações, apresente-as — não escolha silenciosamente.
10
+ - Se existir uma abordagem mais simples, mencione-a. Questione quando apropriado.
11
+ - Se algo não estiver claro, pare. Identifique o que está confuso. Pergunte.
12
+
13
+ ## 2. Simplicidade em Primeiro Lugar
14
+
15
+ **O mínimo de código necessário para resolver o problema. Nada de especulações.**
16
+
17
+ - Sem funcionalidades além do que foi solicitado.
18
+ - Sem abstrações para código de uso único.
19
+ - Sem "flexibilidade" ou "configurabilidade" não solicitadas.
20
+ - Sem tratamento de erros para cenários impossíveis.
21
+ - Se você escrever 200 linhas e o código puder ser reduzido a 50, reescreva-o.
22
+
23
+ Pergunte a si mesmo: "Um engenheiro sênior diria que isso está excessivamente complexo?" Se sim, simplifique.
24
+
25
+ ## 3. Alterações Cirúrgicas
26
+
27
+ **Mexa apenas no necessário. Limpe apenas a bagunça que você mesmo criou.**
28
+
29
+ Ao editar código existente:
30
+ - Não "melhore" código, comentários ou formatação adjacentes.
31
+ - Não refatore o que não está quebrado.
32
+ - Siga o estilo existente, mesmo que você o fizesse de outra forma.
33
+ - Se notar código morto não relacionado, mencione-o — não o exclua.
34
+
35
+ Quando suas alterações criarem elementos órfãos:
36
+ - Remova importações, variáveis ​​ou funções que ficaram sem uso devido às SUAS alterações.
37
+ - Não remova código morto pré-existente, a menos que solicitado.
38
+
39
+ O teste: Cada linha alterada deve estar diretamente ligada à solicitação do usuário.
40
+
41
+ ## 4. Execução Orientada a Objetivos
42
+
43
+ **Defina critérios de sucesso.** Repita o ciclo até a verificação.**
44
+
45
+ Transforme tarefas em objetivos verificáveis:
46
+ - "Adicionar validação" → "Escrever testes para entradas inválidas e fazê-los passar"
47
+ - "Corrigir o bug" → "Escrever um teste que o reproduza e fazê-lo passar"
48
+ - "Refatorar X" → "Garantir que os testes passem antes e depois"
49
+
50
+ Para tarefas com várias etapas, descreva um plano breve:
51
+ ```
52
+ 1. [Etapa] → verificar: [critério]
53
+ 2. [Etapa] → verificar: [critério]
54
+ 3. [Etapa] → verificar: [critério]
55
+ ```
56
+
57
+ Critérios de sucesso robustos permitem trabalhar de forma independente. Critérios vagos ("fazer funcionar") exigem esclarecimentos constantes.
58
+
59
+ ---
@@ -1,2 +1,2 @@
1
1
  export { ColorTheme } from './ColorTheme';
2
- export type { CSSVariables } from './types';
2
+ export type { CSSVariables, CSSVariablesSettings } from './types';
@@ -1,9 +1,12 @@
1
- export interface CSSVariables {
2
- desktopHeader: string;
3
- mobileHeader: string;
4
- desktopFooter: string;
5
- mobileFooter: string;
6
- privacyPolicyUrl: string;
1
+ export interface CSSVariablesSettings {
2
+ desktopHeader?: string;
3
+ mobileHeader?: string;
4
+ desktopFooter?: string;
5
+ mobileFooter?: string;
6
+ privacyPolicyUrl?: string;
7
+ }
8
+
9
+ export type CSSVariables<Setting extends object = CSSVariablesSettings> = {
7
10
  font: {
8
11
  family: string;
9
12
  link: string;
@@ -44,4 +47,4 @@ export interface CSSVariables {
44
47
  LinkInteractiveDefault: string;
45
48
  LinkInteractiveHover: string;
46
49
  };
47
- }
50
+ } & Setting;
@@ -2,7 +2,7 @@
2
2
  import { ref, shallowRef, computed, onMounted, onUnmounted } from 'vue';
3
3
 
4
4
  import api from '../../modules/Api';
5
- import { purchaseAction } from '../../modules/Tracking/events/actions/purchase';
5
+ import { purchaseAction } from '../../modules/Tracking/gtm/events/actions/purchase';
6
6
 
7
7
  import type { Props, Emits, PaymentSuccessData, PaymentRedirectData } from './types';
8
8
  import type { CartResponse } from '../../modules/Api/types';
@@ -3,6 +3,10 @@ import { usePublicApi } from '..';
3
3
  import type {
4
4
  RedirectRequest,
5
5
  OauthType,
6
+ FacebookViewContentRequest,
7
+ FacebookAddToCartRequest,
8
+ FacebookAddPaymentInfoRequest,
9
+ FacebookSearchRequest,
6
10
  } from '../types';
7
11
 
8
12
  export function oauthRedirect(type: OauthType, payload: RedirectRequest) {
@@ -11,4 +15,50 @@ export function oauthRedirect(type: OauthType, payload: RedirectRequest) {
11
15
  method: 'GET',
12
16
  params: payload,
13
17
  });
14
- }
18
+ }
19
+
20
+ export function facebookPageView() {
21
+ return usePublicApi<void>({
22
+ endpoint: '/third-party/facebook/event/page-view',
23
+ method: 'POST'
24
+ });
25
+ }
26
+
27
+ export function facebookViewContent(payload: FacebookViewContentRequest) {
28
+ return usePublicApi<void, FacebookViewContentRequest>({
29
+ endpoint: '/third-party/facebook/event/view-content',
30
+ method: 'POST',
31
+ payload,
32
+ });
33
+ }
34
+
35
+ export function facebookAddToCart(payload: FacebookAddToCartRequest) {
36
+ return usePublicApi<void, FacebookAddToCartRequest>({
37
+ endpoint: '/third-party/facebook/event/add-to-cart',
38
+ method: 'POST',
39
+ payload,
40
+ });
41
+ }
42
+
43
+ export function facebookInitiateCheckout() {
44
+ return usePublicApi<void>({
45
+ endpoint: '/third-party/facebook/event/initiate-checkout',
46
+ method: 'POST'
47
+ });
48
+ }
49
+
50
+ export function facebookAddPaymentInfo(payload: FacebookAddPaymentInfoRequest) {
51
+ return usePublicApi<void, FacebookAddPaymentInfoRequest>({
52
+ endpoint: '/third-party/facebook/event/add-payment-info',
53
+ method: 'POST',
54
+ payload,
55
+ });
56
+ }
57
+
58
+ export function facebookSearch(payload: FacebookSearchRequest) {
59
+ return usePublicApi<void, FacebookSearchRequest>({
60
+ endpoint: '/third-party/facebook/event/search',
61
+ method: 'POST',
62
+ payload,
63
+ });
64
+ }
@@ -87,7 +87,15 @@ import { listZipcode } from './endpoints/ZipcodeComposable';
87
87
  import { listTemplateSettings } from './endpoints/TemplateComposable';
88
88
  import { upsells } from './endpoints/UpsellComposable'
89
89
  import { contact } from './endpoints/PublicComposable'
90
- import { oauthRedirect } from './endpoints/ThirdPartyComposable';
90
+ import {
91
+ oauthRedirect,
92
+ facebookPageView,
93
+ facebookViewContent,
94
+ facebookAddToCart,
95
+ facebookInitiateCheckout,
96
+ facebookAddPaymentInfo,
97
+ facebookSearch,
98
+ } from './endpoints/ThirdPartyComposable';
91
99
 
92
100
  import { sendMfa, confirmMfa, loginMfa, deleteMFA, mfaSetup } from './endpoints/MFAComposable';
93
101
 
@@ -95,7 +103,13 @@ import { sendMfa, confirmMfa, loginMfa, deleteMFA, mfaSetup } from './endpoints/
95
103
  import { usePublicApi } from './usePublicApi';
96
104
 
97
105
  const thirdParty = {
98
- oauthRedirect
106
+ oauthRedirect,
107
+ facebookPageView,
108
+ facebookViewContent,
109
+ facebookAddToCart,
110
+ facebookInitiateCheckout,
111
+ facebookAddPaymentInfo,
112
+ facebookSearch,
99
113
  }
100
114
 
101
115
  const customization = {
@@ -0,0 +1,18 @@
1
+ export interface FacebookViewContentRequest {
2
+ productId: number;
3
+ }
4
+
5
+ export interface FacebookAddToCartRequest {
6
+ sku: string;
7
+ quantity: number;
8
+ price: number;
9
+ }
10
+
11
+ export interface FacebookAddPaymentInfoRequest {
12
+ totalValue: number;
13
+ }
14
+
15
+ export interface FacebookSearchRequest {
16
+ searchTerm: string;
17
+ contentIds?: Array<string>;
18
+ }
@@ -249,15 +249,21 @@ import type { UpsellResponse, Upsell } from './endpoints/upsell/upsell.interface
249
249
  import type { PriceRule } from './endpoints/price/price.interfaces';
250
250
 
251
251
  import type { RedirectRequest, OauthType } from './endpoints/third-party/oauth.interfaces';
252
+ import type {
253
+ FacebookViewContentRequest,
254
+ FacebookAddToCartRequest,
255
+ FacebookAddPaymentInfoRequest,
256
+ FacebookSearchRequest,
257
+ } from './endpoints/third-party/facebook.interfaces';
252
258
 
253
- import type {
254
- MFAOption,
255
- RequestSendMFA,
256
- RequestConfirmMFA,
257
- MFAAPPSettings,
258
- MFAEmailSettings,
259
- MFAPhoneSettings,
260
- RequestLoginMFA,
259
+ import type {
260
+ MFAOption,
261
+ RequestSendMFA,
262
+ RequestConfirmMFA,
263
+ MFAAPPSettings,
264
+ MFAEmailSettings,
265
+ MFAPhoneSettings,
266
+ RequestLoginMFA,
261
267
  CustomerMFAErrorCode,
262
268
  RequestMFASetup,
263
269
  ResponseMFASetup
@@ -309,6 +315,10 @@ export type {
309
315
  ClaimGiftCardResponse,
310
316
  RedirectRequest,
311
317
  OauthType,
318
+ FacebookViewContentRequest,
319
+ FacebookAddToCartRequest,
320
+ FacebookAddPaymentInfoRequest,
321
+ FacebookSearchRequest,
312
322
 
313
323
  // banner
314
324
  Banner,
@@ -499,8 +509,8 @@ export type {
499
509
  MFAOption,
500
510
  RequestSendMFA,
501
511
  RequestConfirmMFA,
502
- MFAAPPSettings,
503
- MFAEmailSettings,
512
+ MFAAPPSettings,
513
+ MFAEmailSettings,
504
514
  MFAPhoneSettings,
505
515
  RequestLoginMFA,
506
516
  CustomerMFAErrorCode,
@@ -1,6 +1,6 @@
1
1
  import api from '../../Api';
2
2
 
3
- import { viewPromotion } from '../events/views/viewPromotion';
3
+ import { viewPromotion } from '../gtm/events/views/viewPromotion';
4
4
 
5
5
  import type { Banners } from '../../Api/types';
6
6
 
@@ -1,11 +1,12 @@
1
1
  import api from '../../Api';
2
2
 
3
- import { addShippingInfoAction } from '../events/actions/addShippingInfo';
4
- import { addToCartAction } from '../events/actions/addToCart';
5
- import { purchaseAction } from '../events/actions/purchase';
6
- import { removeFromCartAction } from '../events/actions/removeFromCart';
7
- import { shippingCalculationAction } from '../events/actions/shippingCalculation';
8
- import { upsertToCartAction } from '../events/actions/upsertToCart';
3
+ import { addShippingInfoAction } from '../gtm/events/actions/addShippingInfo';
4
+ import { addToCartAction } from '../gtm/events/actions/addToCart';
5
+ import { purchaseAction } from '../gtm/events/actions/purchase';
6
+ import { removeFromCartAction } from '../gtm/events/actions/removeFromCart';
7
+ import { shippingCalculationAction } from '../gtm/events/actions/shippingCalculation';
8
+ import { upsertToCartAction } from '../gtm/events/actions/upsertToCart';
9
+ import { addToCartAction as facebookAddToCartAction } from '../facebook/events/actions/addToCart';
9
10
 
10
11
  import type { UpsertTrackingCartRequest } from '../types';
11
12
  import type {
@@ -26,15 +27,22 @@ export function listDetail() {
26
27
  export function addProduct(payload: UpsertTrackingCartRequest) {
27
28
  return api.cart.addProduct(payload as UpsertCartRequest).then(data => {
28
29
  addToCartAction(payload, data);
30
+ facebookAddToCartAction(data, payload);
29
31
  return data;
30
32
  });
31
33
  }
32
34
 
33
- export function upsertProduct(payload: UpsertTrackingCartRequest) {
35
+ export function upsertProduct(payload: UpsertTrackingCartRequest, customerId?: number) {
34
36
  return api.cart
35
37
  .upsertProduct(payload as UpsertCartRequest)
36
38
  .then(data => {
37
39
  upsertToCartAction(payload, data);
40
+
41
+ const isRemoval = payload.items.some(
42
+ item => (item.oldQuantity || 0) > item.quantity!,
43
+ );
44
+ if (!isRemoval) facebookAddToCartAction(data, payload);
45
+
38
46
  return data;
39
47
  });
40
48
  }
@@ -2,10 +2,10 @@ import publicApi from '../../Api';
2
2
 
3
3
  import type { TrackingCustomerFields } from './types';
4
4
 
5
- import { customerProfileAction } from '../events/actions/customerProfile';
6
- import { generateLead } from '../events/actions/generateLead';
7
- import { loginAction } from '../events/actions/login';
8
- import { signupAction } from '../events/actions/signup';
5
+ import { customerProfileAction } from '../gtm/events/actions/customerProfile';
6
+ import { generateLead } from '../gtm/events/actions/generateLead';
7
+ import { loginAction } from '../gtm/events/actions/login';
8
+ import { signupAction } from '../gtm/events/actions/signup';
9
9
 
10
10
  import type { CustomerLead } from '../types';
11
11
  import type {
@@ -30,7 +30,7 @@ export function detail(
30
30
  ) {
31
31
 
32
32
  let fields: Array<CustomerFields> = ['addresses', 'flags'];
33
-
33
+
34
34
  if (options?.fields) fields = [...options.fields, ...fields];
35
35
 
36
36
  return publicApi.customer
@@ -1,6 +1,6 @@
1
1
  import api from '../../Api';
2
2
 
3
- import { shippingCalculationAction } from '../events/actions/shippingCalculation';
3
+ import { shippingCalculationAction } from '../gtm/events/actions/shippingCalculation';
4
4
 
5
5
  import type { ApiParams } from '../../Api/types';
6
6
 
@@ -2,7 +2,9 @@ import publicApi from '../../Api';
2
2
 
3
3
  import type { TrackingProductFields } from './types';
4
4
 
5
- import { viewItemList } from '../events/views/viewItemList';
5
+ import { viewItemList } from '../gtm/events/views/viewItemList';
6
+ import { pageView as facebookPageView } from '../facebook/events/views/pageView';
7
+ import { searchAction as facebookSearchAction } from '../facebook/events/actions/search';
6
8
 
7
9
  import type {
8
10
  ApiParams,
@@ -16,7 +18,7 @@ export function getSearch(
16
18
  options?: Pick<
17
19
  ApiParams<TrackingProductFields, ProductSortFields, ProductConditionFields>,
18
20
  'condition' | 'fields' | 'limit' | 'meta' | 'offset' | 'order'
19
- >,
21
+ >
20
22
  ) {
21
23
  let fields: Array<ProductFields> = ['price', 'brand', 'variation'];
22
24
 
@@ -26,6 +28,11 @@ export function getSearch(
26
28
  .getSearch(term, { ...options, fields })
27
29
  .then(data => {
28
30
  viewItemList(data);
31
+ facebookPageView();
32
+ facebookSearchAction(
33
+ term,
34
+ data.content.registers.map(product => `${product.id}`)
35
+ );
29
36
 
30
37
  return data;
31
38
  });
@@ -2,7 +2,7 @@ import publicApi from '../../Api';
2
2
 
3
3
  import type { TrackingProductFields } from './types';
4
4
 
5
- import { viewItemList } from '../events/views/viewItemList';
5
+ import { viewItemList } from '../gtm/events/views/viewItemList';
6
6
 
7
7
  import type {
8
8
  ApiParams,
@@ -2,8 +2,10 @@ import publicApi from '../../Api';
2
2
 
3
3
  import type { TrackingProductFields } from './types';
4
4
 
5
- import { viewItem } from '../events/views/viewItem';
6
- import { viewItemList } from '../events/views/viewItemList';
5
+ import { viewItem } from '../gtm/events/views/viewItem';
6
+ import { viewItemList } from '../gtm/events/views/viewItemList';
7
+ import { pageView as facebookPageView } from '../facebook/events/views/pageView';
8
+ import { viewContent as facebookViewContent } from '../facebook/events/views/viewContent';
7
9
 
8
10
  import type {
9
11
  ApiParams,
@@ -21,7 +23,7 @@ export function getUrl<UrlType>(
21
23
  options?: Pick<
22
24
  ApiParams<TrackingProductFields, ProductSortFields, ProductConditionFields>,
23
25
  'condition' | 'fields' | 'limit' | 'offset' | 'meta' | 'order'
24
- >,
26
+ >
25
27
  ) {
26
28
  let fields: Array<ProductFields> = ['price', 'brand', 'variation', 'mainCategory'];
27
29
 
@@ -32,7 +34,12 @@ export function getUrl<UrlType>(
32
34
  .then(data => {
33
35
  const pageData = data as UrlProduct | UrlPage | UrlBrand | UrlListing;
34
36
 
35
- if (pageData.type === 'product') viewItem(pageData.content);
37
+ facebookPageView();
38
+
39
+ if (pageData.type === 'product') {
40
+ viewItem(pageData.content);
41
+ facebookViewContent(pageData.content);
42
+ }
36
43
  if (pageData.type === 'brand' || pageData.type === 'category')
37
44
  viewItemList(pageData);
38
45
 
@@ -0,0 +1,14 @@
1
+ import api from '../../../../Api';
2
+ import { totalValue } from '../../../utils/cart';
3
+
4
+ import type { CartResponse } from '../../../../Api/types';
5
+
6
+ export function addPaymentInfoAction(
7
+ cartPayload: CartResponse
8
+ ) {
9
+ api.thirdParty
10
+ .facebookAddPaymentInfo({
11
+ totalValue: totalValue(cartPayload),
12
+ })
13
+ .catch(() => {});
14
+ }
@@ -0,0 +1,22 @@
1
+ import api from '../../../../Api';
2
+ import { getAddedCartItems } from '../../../utils/cart';
3
+
4
+ import type { UpsertTrackingCartRequest } from '../../../types';
5
+ import type { CartResponse } from '../../../../Api/types';
6
+
7
+ export function addToCartAction(
8
+ cartPayload: CartResponse,
9
+ upsertPayload?: UpsertTrackingCartRequest
10
+ ) {
11
+ getAddedCartItems(cartPayload, upsertPayload).forEach(item => {
12
+ api.thirdParty
13
+ .facebookAddToCart({
14
+ sku: item.product.sku,
15
+ quantity: item.oldQuantity
16
+ ? item.quantity - item.oldQuantity
17
+ : item.quantity,
18
+ price: item.unitValue,
19
+ })
20
+ .catch(() => {});
21
+ });
22
+ }
@@ -0,0 +1,7 @@
1
+ import api from '../../../../Api';
2
+
3
+ export function initiateCheckoutAction() {
4
+ api.thirdParty
5
+ .facebookInitiateCheckout()
6
+ .catch(() => {});
7
+ }
@@ -0,0 +1,10 @@
1
+ import api from '../../../../Api';
2
+
3
+ export function searchAction(
4
+ searchTerm: string,
5
+ contentIds: Array<string>
6
+ ) {
7
+ api.thirdParty
8
+ .facebookSearch({searchTerm, contentIds })
9
+ .catch(() => {});
10
+ }
@@ -0,0 +1,5 @@
1
+ import api from '../../../../Api';
2
+
3
+ export function pageView() {
4
+ api.thirdParty.facebookPageView().catch(() => {});
5
+ }
@@ -0,0 +1,9 @@
1
+ import api from '../../../../Api';
2
+
3
+ import type { Product } from '../../../../Api/types';
4
+
5
+ export function viewContent(product: Product) {
6
+ api.thirdParty
7
+ .facebookViewContent({ productId: product.id })
8
+ .catch(() => {});
9
+ }
@@ -1,7 +1,7 @@
1
- import { getAddedCartItems, getVariant, totalValue } from '../../utils/cart';
2
- import { pushDatalayer } from '../../utils/pushDatalayer';
1
+ import { getAddedCartItems, getVariant, totalValue } from '../../../utils/cart';
2
+ import { pushDatalayer } from '../../../utils/pushDatalayer';
3
3
 
4
- import type { CartResponse } from '../../../Api/types';
4
+ import type { CartResponse } from '../../../../Api/types';
5
5
 
6
6
  export function addPaymentInfoAction(
7
7
  paymentMethod: string,
@@ -1,7 +1,7 @@
1
- import { getAddedCartItems, getVariant, totalValue } from '../../utils/cart';
2
- import { pushDatalayer } from '../../utils/pushDatalayer';
1
+ import { getAddedCartItems, getVariant, totalValue } from '../../../utils/cart';
2
+ import { pushDatalayer } from '../../../utils/pushDatalayer';
3
3
 
4
- import type { CartResponse } from '../../../Api/types';
4
+ import type { CartResponse } from '../../../../Api/types';
5
5
 
6
6
  export function addShippingInfoAction(cartPayload: CartResponse) {
7
7
  pushDatalayer({
@@ -1,8 +1,8 @@
1
- import { getAddedCartItems, getVariant, totalValue } from '../../utils/cart';
2
- import { pushDatalayer } from '../../utils/pushDatalayer';
1
+ import { getAddedCartItems, getVariant, totalValue } from '../../../utils/cart';
2
+ import { pushDatalayer } from '../../../utils/pushDatalayer';
3
3
 
4
- import type { UpsertTrackingCartRequest } from '../../types';
5
- import type { CartResponse } from '../../../Api/types';
4
+ import type { UpsertTrackingCartRequest } from '../../../types';
5
+ import type { CartResponse } from '../../../../Api/types';
6
6
 
7
7
  export function addToCartAction(
8
8
  upsertPayload: UpsertTrackingCartRequest,
@@ -1,7 +1,7 @@
1
- import { getAddedCartItems, getVariant, totalValue } from '../../utils/cart';
2
- import { pushDatalayer } from '../../utils/pushDatalayer';
1
+ import { getAddedCartItems, getVariant, totalValue } from '../../../utils/cart';
2
+ import { pushDatalayer } from '../../../utils/pushDatalayer';
3
3
 
4
- import type { CartResponse } from '../../../Api/types';
4
+ import type { CartResponse } from '../../../../Api/types';
5
5
 
6
6
  export function beginCheckoutAction(cartPayload: CartResponse) {
7
7
  pushDatalayer({
@@ -1,6 +1,6 @@
1
- import { pushDatalayer } from '../../utils/pushDatalayer';
1
+ import { pushDatalayer } from '../../../utils/pushDatalayer';
2
2
 
3
- import type { CustomerResponse } from '../../../Api/types';
3
+ import type { CustomerResponse } from '../../../../Api/types';
4
4
 
5
5
  export function customerProfileAction(payload?: CustomerResponse) {
6
6
  if (!payload) {
@@ -1,6 +1,6 @@
1
- import { pushDatalayer } from '../../utils/pushDatalayer';
1
+ import { pushDatalayer } from '../../../utils/pushDatalayer';
2
2
 
3
- import type { CustomerLead } from '../../types';
3
+ import type { CustomerLead } from '../../../types';
4
4
 
5
5
  export function generateLead(customer: CustomerLead) {
6
6
  pushDatalayer({
@@ -1,4 +1,4 @@
1
- import { pushDatalayer } from '../../utils/pushDatalayer';
1
+ import { pushDatalayer } from '../../../utils/pushDatalayer';
2
2
 
3
3
  export function loginAction() {
4
4
  pushDatalayer({
@@ -1,7 +1,7 @@
1
- import { getAddedCartItems, getVariant, totalValue } from '../../utils/cart';
2
- import { pushDatalayer } from '../../utils/pushDatalayer';
1
+ import { getAddedCartItems, getVariant, totalValue } from '../../../utils/cart';
2
+ import { pushDatalayer } from '../../../utils/pushDatalayer';
3
3
 
4
- import type { CartResponse } from '../../../Api/types';
4
+ import type { CartResponse } from '../../../../Api/types';
5
5
 
6
6
  export function purchaseAction(
7
7
  paymentMethod: string,
@@ -1,7 +1,7 @@
1
- import { getAddedCartItems, getVariant, totalValue } from '../../utils/cart';
2
- import { pushDatalayer } from '../../utils/pushDatalayer';
1
+ import { getAddedCartItems, getVariant, totalValue } from '../../../utils/cart';
2
+ import { pushDatalayer } from '../../../utils/pushDatalayer';
3
3
 
4
- import type { CartResponse, DeleteCartRequest } from '../../../Api/types';
4
+ import type { CartResponse, DeleteCartRequest } from '../../../../Api/types';
5
5
 
6
6
  export function removeFromCartAction(
7
7
  deletePayload: DeleteCartRequest,
@@ -1,4 +1,4 @@
1
- import { pushDatalayer } from '../../utils/pushDatalayer';
1
+ import { pushDatalayer } from '../../../utils/pushDatalayer';
2
2
 
3
3
  export function searchAction(term: string) {
4
4
  pushDatalayer({
@@ -1,12 +1,12 @@
1
- import { getVariant } from '../../utils/cart';
2
- import { pushDatalayer } from '../../utils/pushDatalayer';
1
+ import { getVariant } from '../../../utils/cart';
2
+ import { pushDatalayer } from '../../../utils/pushDatalayer';
3
3
 
4
4
  import type {
5
5
  Search,
6
6
  Showcase,
7
7
  UrlBrand,
8
8
  UrlListing,
9
- } from '../../../Api/types';
9
+ } from '../../../../Api/types';
10
10
 
11
11
  export function selectItemAction(
12
12
  page: UrlBrand | UrlListing | Showcase | Search,
@@ -1,7 +1,7 @@
1
- import { pushDatalayer } from '../../utils/pushDatalayer';
1
+ import { pushDatalayer } from '../../../utils/pushDatalayer';
2
2
 
3
- import type { BannerItem } from '../../types';
4
- import type { Banner } from '../../../Api/types';
3
+ import type { BannerItem } from '../../../types';
4
+ import type { Banner } from '../../../../Api/types';
5
5
 
6
6
  export function selectPromotionAction<AdditionalParameters>(
7
7
  banner: Banner<AdditionalParameters>,
@@ -1,4 +1,4 @@
1
- import { pushDatalayer } from '../../utils/pushDatalayer';
1
+ import { pushDatalayer } from '../../../utils/pushDatalayer';
2
2
 
3
3
  export function shippingCalculationAction() {
4
4
  pushDatalayer({
@@ -1,4 +1,4 @@
1
- import { pushDatalayer } from '../../utils/pushDatalayer';
1
+ import { pushDatalayer } from '../../../utils/pushDatalayer';
2
2
 
3
3
  export function signupAction() {
4
4
  pushDatalayer({
@@ -1,8 +1,8 @@
1
- import { getAddedCartItems, getVariant, totalValue } from '../../utils/cart';
2
- import { pushDatalayer } from '../../utils/pushDatalayer';
1
+ import { getAddedCartItems, getVariant, totalValue } from '../../../utils/cart';
2
+ import { pushDatalayer } from '../../../utils/pushDatalayer';
3
3
 
4
- import type { UpsertTrackingCartRequest } from '../../types';
5
- import type { CartResponse } from '../../../Api/types';
4
+ import type { UpsertTrackingCartRequest } from '../../../types';
5
+ import type { CartResponse } from '../../../../Api/types';
6
6
 
7
7
  export function upsertToCartAction(
8
8
  upsertPayload: UpsertTrackingCartRequest,
@@ -1,7 +1,7 @@
1
- import { getAddedCartItems, getVariant, totalValue } from '../../utils/cart';
2
- import { pushDatalayer } from '../../utils/pushDatalayer';
1
+ import { getAddedCartItems, getVariant, totalValue } from '../../../utils/cart';
2
+ import { pushDatalayer } from '../../../utils/pushDatalayer';
3
3
 
4
- import type { CartResponse } from '../../../Api/types';
4
+ import type { CartResponse } from '../../../../Api/types';
5
5
 
6
6
  export function viewCart(cartPayload: CartResponse) {
7
7
  pushDatalayer({
@@ -1,4 +1,4 @@
1
- import { pushDatalayer } from '../../utils/pushDatalayer';
1
+ import { pushDatalayer } from '../../../utils/pushDatalayer';
2
2
 
3
3
  export function viewHome() {
4
4
  pushDatalayer({ event: 'view_home' });
@@ -1,7 +1,7 @@
1
- import { getVariant } from '../../utils/cart';
2
- import { pushDatalayer } from '../../utils/pushDatalayer';
1
+ import { getVariant } from '../../../utils/cart';
2
+ import { pushDatalayer } from '../../../utils/pushDatalayer';
3
3
 
4
- import type { Product } from '../../../Api/types';
4
+ import type { Product } from '../../../../Api/types';
5
5
 
6
6
  export function viewItem(product: Product) {
7
7
  pushDatalayer({
@@ -1,12 +1,12 @@
1
- import { getVariant } from '../../utils/cart';
2
- import { pushDatalayer } from '../../utils/pushDatalayer';
1
+ import { getVariant } from '../../../utils/cart';
2
+ import { pushDatalayer } from '../../../utils/pushDatalayer';
3
3
 
4
4
  import type {
5
5
  Showcase,
6
6
  UrlBrand,
7
7
  UrlListing,
8
8
  Search,
9
- } from '../../../Api/types';
9
+ } from '../../../../Api/types';
10
10
 
11
11
  export function viewItemList(page: UrlBrand | UrlListing | Search): void;
12
12
  export function viewItemList(page: Array<Showcase>): void;
@@ -1,4 +1,4 @@
1
- import { pushDatalayer } from '../../utils/pushDatalayer';
1
+ import { pushDatalayer } from '../../../utils/pushDatalayer';
2
2
 
3
3
  export function viewNotFound() {
4
4
  pushDatalayer({ event: 'view_not_found' });
@@ -1,4 +1,4 @@
1
- import { pushDatalayer } from '../../utils/pushDatalayer';
1
+ import { pushDatalayer } from '../../../utils/pushDatalayer';
2
2
 
3
3
  export function viewOther() {
4
4
  pushDatalayer({ event: 'view_other' });
@@ -1,4 +1,4 @@
1
- import { pushDatalayer } from '../../utils/pushDatalayer';
1
+ import { pushDatalayer } from '../../../utils/pushDatalayer';
2
2
 
3
3
  export function viewPayment() {
4
4
  pushDatalayer({
@@ -1,7 +1,7 @@
1
- import { pushDatalayer } from '../../utils/pushDatalayer';
1
+ import { pushDatalayer } from '../../../utils/pushDatalayer';
2
2
 
3
- import type { ViewPromotion } from '../../types';
4
- import type { Banners } from '../../../Api/types';
3
+ import type { ViewPromotion } from '../../../types';
4
+ import type { Banners } from '../../../../Api/types';
5
5
 
6
6
  export function viewPromotion<AdditionalParameters>(
7
7
  bannerGroups: Array<Banners<AdditionalParameters>>,
@@ -1,4 +1,4 @@
1
- import { pushDatalayer } from '../../utils/pushDatalayer';
1
+ import { pushDatalayer } from '../../../utils/pushDatalayer';
2
2
 
3
3
  export function viewShipping() {
4
4
  pushDatalayer({
@@ -19,18 +19,61 @@ import { listShipmentQuoteProduct } from './endpoints/ProductQuoteShipment';
19
19
  import { getSearch } from './endpoints/SearchComposable';
20
20
  import { listShowcase } from './endpoints/ShowcaseComposable';
21
21
  import { getUrl } from './endpoints/UrlComposable';
22
- import { addPaymentInfoAction as addPaymentInfo } from './events/actions/addPaymentInfo';
23
- import { beginCheckoutAction as beginCheckout } from './events/actions/beginCheckout';
24
- import { searchAction as search } from './events/actions/search';
25
- import { selectItemAction as selectItem } from './events/actions/selectItem';
26
- import { selectPromotionAction as selectPromotion } from './events/actions/selectPromotion';
27
- import { viewHome } from './events/views/viewHome';
28
- import { viewNotFound } from './events/views/viewNotFound';
29
- import { viewOther } from './events/views/viewOther';
30
- import { viewPayment } from './events/views/viewPayment';
31
- import { viewShipping } from './events/views/viewShipping';
22
+ import { addPaymentInfoAction } from './gtm/events/actions/addPaymentInfo';
23
+ import { beginCheckoutAction } from './gtm/events/actions/beginCheckout';
24
+ import { searchAction as search } from './gtm/events/actions/search';
25
+ import { selectItemAction as selectItem } from './gtm/events/actions/selectItem';
26
+ import { selectPromotionAction as selectPromotion } from './gtm/events/actions/selectPromotion';
27
+ import { viewHome as viewHomeAction } from './gtm/events/views/viewHome';
28
+ import { viewNotFound as viewNotFoundAction } from './gtm/events/views/viewNotFound';
29
+ import { viewOther as viewOtherAction } from './gtm/events/views/viewOther';
30
+ import { viewPayment as viewPaymentAction } from './gtm/events/views/viewPayment';
31
+ import { viewShipping as viewShippingAction } from './gtm/events/views/viewShipping';
32
+ import { pageView as facebookPageView } from './facebook/events/views/pageView';
33
+ import { initiateCheckoutAction as facebookInitiateCheckoutAction } from './facebook/events/actions/initiateCheckout';
34
+ import { addPaymentInfoAction as facebookAddPaymentInfoAction } from './facebook/events/actions/addPaymentInfo';
32
35
  import publicApiTracking from './publicApiTracking';
33
36
 
37
+ import type { CartResponse } from '../Api/types';
38
+
39
+ function viewHome() {
40
+ viewHomeAction();
41
+ facebookPageView();
42
+ }
43
+
44
+ function viewShipping() {
45
+ viewShippingAction();
46
+ facebookPageView();
47
+ }
48
+
49
+ function viewPayment() {
50
+ viewPaymentAction();
51
+ facebookPageView();
52
+ }
53
+
54
+ function viewOther() {
55
+ viewOtherAction();
56
+ facebookPageView();
57
+ }
58
+
59
+ function viewNotFound() {
60
+ viewNotFoundAction();
61
+ facebookPageView();
62
+ }
63
+
64
+ function beginCheckout(cartPayload: CartResponse) {
65
+ beginCheckoutAction(cartPayload);
66
+ facebookInitiateCheckoutAction();
67
+ }
68
+
69
+ function addPaymentInfo(
70
+ paymentMethod: string,
71
+ cartPayload: CartResponse
72
+ ) {
73
+ addPaymentInfoAction(paymentMethod, cartPayload);
74
+ facebookAddPaymentInfoAction(cartPayload);
75
+ }
76
+
34
77
  const view = {
35
78
  viewHome,
36
79
  viewShipping,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uappi/public-sdk",
3
- "version": "1.15.0",
3
+ "version": "1.17.0",
4
4
  "description": "Pacotes públicos para desenvolvimento do ecossistema Uappi",
5
5
  "main": "main.ts",
6
6
  "scripts": {