@akinon/next 1.0.0 → 1.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/CHANGELOG.md +13 -0
- package/components/client-root.tsx +4 -6
- package/package.json +1 -1
- package/redux/middlewares/checkout.ts +5 -0
- package/redux/reducers/checkout.ts +9 -2
- package/sentry/index.ts +27 -0
- package/types/commerce/checkout.ts +1 -0
- package/utils/index.ts +4 -0
- package/utils/log.ts +20 -0
package/CHANGELOG.md
ADDED
|
@@ -22,13 +22,13 @@ export default function ClientRoot({
|
|
|
22
22
|
const pathname = usePathname();
|
|
23
23
|
const router = useRouter();
|
|
24
24
|
const { isMobileApp } = useAppSelector((state) => state.root);
|
|
25
|
-
const { data: basketData } = useGetBasketQuery();
|
|
25
|
+
const { data: basketData, isSuccess } = useGetBasketQuery();
|
|
26
26
|
const [clearBasket] = useClearBasketMutation();
|
|
27
27
|
const resetClientCache = getCookie('pz-reset-client-cache') === 'true';
|
|
28
28
|
const resetBasket = getCookie('pz-reset-basket') === 'true';
|
|
29
29
|
|
|
30
30
|
useEffect(() => {
|
|
31
|
-
if (basketData?.basketitem_set.length) {
|
|
31
|
+
if (basketData?.basketitem_set.length && resetBasket) {
|
|
32
32
|
dispatch(
|
|
33
33
|
api.util.invalidateTags([
|
|
34
34
|
'Checkout',
|
|
@@ -39,13 +39,11 @@ export default function ClientRoot({
|
|
|
39
39
|
])
|
|
40
40
|
);
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
clearBasket();
|
|
44
|
-
}
|
|
42
|
+
clearBasket();
|
|
45
43
|
}
|
|
46
44
|
|
|
47
45
|
removeCookie('pz-reset-basket');
|
|
48
|
-
}, [resetBasket]);
|
|
46
|
+
}, [resetBasket, isSuccess, basketData]);
|
|
49
47
|
|
|
50
48
|
useEffect(() => {
|
|
51
49
|
if (resetClientCache) {
|
package/package.json
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
setPaymentChoices,
|
|
15
15
|
setPaymentOptions,
|
|
16
16
|
setPreOrder,
|
|
17
|
+
setRetailStores,
|
|
17
18
|
setShippingOptions,
|
|
18
19
|
setShippingStepCompleted
|
|
19
20
|
} from '../../redux/reducers/checkout';
|
|
@@ -223,6 +224,10 @@ export const contextListMiddleware: Middleware = ({
|
|
|
223
224
|
if (context.page_context.balance) {
|
|
224
225
|
dispatch(setLoyaltyBalance(context.page_context.balance));
|
|
225
226
|
}
|
|
227
|
+
|
|
228
|
+
if (context.page_context.retail_stores) {
|
|
229
|
+
dispatch(setRetailStores(context.page_context.retail_stores));
|
|
230
|
+
}
|
|
226
231
|
});
|
|
227
232
|
}
|
|
228
233
|
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
PaymentChoice,
|
|
13
13
|
PaymentOption,
|
|
14
14
|
PreOrder,
|
|
15
|
+
RetailStore,
|
|
15
16
|
ShippingOption
|
|
16
17
|
} from '../../types';
|
|
17
18
|
|
|
@@ -42,6 +43,7 @@ export interface CheckoutState {
|
|
|
42
43
|
bankAccounts: BankAccount[];
|
|
43
44
|
selectedBankAccountPk: number;
|
|
44
45
|
loyaltyBalance?: string;
|
|
46
|
+
retailStores: RetailStore[];
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
const initialState: CheckoutState = {
|
|
@@ -68,7 +70,8 @@ const initialState: CheckoutState = {
|
|
|
68
70
|
cardType: null,
|
|
69
71
|
installmentOptions: [],
|
|
70
72
|
bankAccounts: [],
|
|
71
|
-
selectedBankAccountPk: null
|
|
73
|
+
selectedBankAccountPk: null,
|
|
74
|
+
retailStores: []
|
|
72
75
|
};
|
|
73
76
|
|
|
74
77
|
const checkoutSlice = createSlice({
|
|
@@ -134,6 +137,9 @@ const checkoutSlice = createSlice({
|
|
|
134
137
|
},
|
|
135
138
|
setLoyaltyBalance(state, { payload }) {
|
|
136
139
|
state.loyaltyBalance = payload;
|
|
140
|
+
},
|
|
141
|
+
setRetailStores(state, { payload }) {
|
|
142
|
+
state.retailStores = payload;
|
|
137
143
|
}
|
|
138
144
|
}
|
|
139
145
|
});
|
|
@@ -158,7 +164,8 @@ export const {
|
|
|
158
164
|
setInstallmentOptions,
|
|
159
165
|
setBankAccounts,
|
|
160
166
|
setSelectedBankAccountPk,
|
|
161
|
-
setLoyaltyBalance
|
|
167
|
+
setLoyaltyBalance,
|
|
168
|
+
setRetailStores
|
|
162
169
|
} = checkoutSlice.actions;
|
|
163
170
|
|
|
164
171
|
export default checkoutSlice.reducer;
|
package/sentry/index.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as Sentry from '@sentry/nextjs';
|
|
2
|
+
|
|
3
|
+
const SENTRY_DSN: string =
|
|
4
|
+
process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN;
|
|
5
|
+
|
|
6
|
+
export const initSentry = (
|
|
7
|
+
type: 'Server' | 'Client' | 'Edge',
|
|
8
|
+
options: Sentry.BrowserOptions | Sentry.NodeOptions | Sentry.EdgeOptions = {}
|
|
9
|
+
) => {
|
|
10
|
+
// TODO: Handle options with ESLint rules
|
|
11
|
+
|
|
12
|
+
// TODO: Remove Zero Project DSN
|
|
13
|
+
|
|
14
|
+
Sentry.init({
|
|
15
|
+
dsn:
|
|
16
|
+
SENTRY_DSN ||
|
|
17
|
+
'https://d8558ef8997543deacf376c7d8d7cf4b@o64293.ingest.sentry.io/4504338423742464',
|
|
18
|
+
initialScope: {
|
|
19
|
+
tags: {
|
|
20
|
+
APP_TYPE: 'ProjectZeroNext',
|
|
21
|
+
TYPE: type
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
tracesSampleRate: 1.0,
|
|
25
|
+
integrations: []
|
|
26
|
+
});
|
|
27
|
+
};
|
package/utils/index.ts
CHANGED
package/utils/log.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as Sentry from '@sentry/nextjs';
|
|
2
|
+
|
|
1
3
|
enum LogLevel {
|
|
2
4
|
TRACE = 'trace',
|
|
3
5
|
DEBUG = 'debug',
|
|
@@ -92,6 +94,15 @@ const error: LoggerFn = (message, payload) => {
|
|
|
92
94
|
message,
|
|
93
95
|
payload
|
|
94
96
|
});
|
|
97
|
+
|
|
98
|
+
Sentry.withScope(function (scope) {
|
|
99
|
+
scope.setLevel('error');
|
|
100
|
+
|
|
101
|
+
Sentry.captureException({
|
|
102
|
+
message,
|
|
103
|
+
extra: payload
|
|
104
|
+
});
|
|
105
|
+
});
|
|
95
106
|
};
|
|
96
107
|
|
|
97
108
|
const warn: LoggerFn = (message, payload) => {
|
|
@@ -100,6 +111,15 @@ const warn: LoggerFn = (message, payload) => {
|
|
|
100
111
|
message,
|
|
101
112
|
payload
|
|
102
113
|
});
|
|
114
|
+
|
|
115
|
+
Sentry.withScope(function (scope) {
|
|
116
|
+
scope.setLevel('warning');
|
|
117
|
+
|
|
118
|
+
Sentry.captureEvent({
|
|
119
|
+
message,
|
|
120
|
+
extra: payload
|
|
121
|
+
});
|
|
122
|
+
});
|
|
103
123
|
};
|
|
104
124
|
|
|
105
125
|
const debug: LoggerFn = (message, payload) => {
|