@akinon/next 1.24.0 → 1.25.0-rc.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/CHANGELOG.md +19 -0
- package/api/auth.ts +13 -2
- package/bin/pz-check-dependencies.js +16 -1
- package/bin/pz-install-extensions.js +27 -0
- package/bin/pz-predev.js +2 -0
- package/data/client/user.ts +12 -0
- package/data/urls.ts +1 -0
- package/package.json +4 -1
- package/sentry/index.ts +20 -14
- package/types/index.ts +6 -0
- package/utils/log.ts +30 -47
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @akinon/next
|
|
2
2
|
|
|
3
|
+
## 1.25.0-rc.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 6d4aadb: ZERO-2476: Auto install recommendenent extension
|
|
8
|
+
- e20b27f: ZERO-2454:add otp login
|
|
9
|
+
- a4674c6: ZERO-2461: add optional chaining for referrer header and add locale value for redirect url
|
|
10
|
+
- 1ec9775: ZERO-2462:add custom span to logs
|
|
11
|
+
- 3690d3b: ZERO-2485: Check ESLint peerDependency version
|
|
12
|
+
- b4452e9: ZERO-2463: Refactor Sentry initialization and add Sentry DSN option to settings
|
|
13
|
+
- b2da5e4: Revert ZERO-2435
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- da1e501: ZERO-2296: Fix ROUTES import
|
|
18
|
+
- 2e44646: ZERO-2434: Fix category URL in getCategoryDataHandler function
|
|
19
|
+
- 8c7f5bc: ZERO-2440: Pipeline test
|
|
20
|
+
- @akinon/eslint-plugin-projectzero@1.25.0-rc.0
|
|
21
|
+
|
|
3
22
|
## 1.24.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
package/api/auth.ts
CHANGED
|
@@ -199,8 +199,8 @@ const nextAuthOptions = (req: NextApiRequest, res: NextApiResponse) => {
|
|
|
199
199
|
);
|
|
200
200
|
|
|
201
201
|
const localeResults = req.headers.referer
|
|
202
|
-
|
|
203
|
-
|
|
202
|
+
?.replace(baseUrl, '')
|
|
203
|
+
?.match(urlLocaleMatcherRegex);
|
|
204
204
|
|
|
205
205
|
return `${baseUrl}${localeResults?.[0] || ''}${pathnameWithoutLocale}`;
|
|
206
206
|
}
|
|
@@ -220,6 +220,17 @@ const nextAuthOptions = (req: NextApiRequest, res: NextApiResponse) => {
|
|
|
220
220
|
pages: {
|
|
221
221
|
signIn: ROUTES.AUTH,
|
|
222
222
|
error: ROUTES.AUTH
|
|
223
|
+
},
|
|
224
|
+
cookies: {
|
|
225
|
+
sessionToken: {
|
|
226
|
+
name: `__Secure-next-auth.session-token`,
|
|
227
|
+
options: {
|
|
228
|
+
httpOnly: true,
|
|
229
|
+
sameSite: 'none',
|
|
230
|
+
path: '/',
|
|
231
|
+
secure: true
|
|
232
|
+
}
|
|
233
|
+
}
|
|
223
234
|
}
|
|
224
235
|
};
|
|
225
236
|
};
|
|
@@ -23,6 +23,21 @@ function checkDir() {
|
|
|
23
23
|
|
|
24
24
|
const BASE_DIR = checkDir();
|
|
25
25
|
|
|
26
|
+
function getProjectZeroNextPackagePath() {
|
|
27
|
+
const possiblePaths = [
|
|
28
|
+
path.join(BASE_DIR, 'apps/projectzeronext/package.json'),
|
|
29
|
+
path.join(BASE_DIR, 'package.json')
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
for (const packagePath of possiblePaths) {
|
|
33
|
+
if (fs.existsSync(packagePath)) {
|
|
34
|
+
return packagePath;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
throw new Error('Unable to find package.json in expected locations.');
|
|
39
|
+
}
|
|
40
|
+
|
|
26
41
|
try {
|
|
27
42
|
const akinonNextPackagePath = fs.existsSync(
|
|
28
43
|
path.join(BASE_DIR, 'packages/akinon-next/package.json')
|
|
@@ -34,7 +49,7 @@ try {
|
|
|
34
49
|
fs.readFileSync(akinonNextPackagePath, 'utf8')
|
|
35
50
|
);
|
|
36
51
|
|
|
37
|
-
const projectZeroNextPackagePath =
|
|
52
|
+
const projectZeroNextPackagePath = getProjectZeroNextPackagePath();
|
|
38
53
|
|
|
39
54
|
const projectZeroNextPackage = JSON.parse(
|
|
40
55
|
fs.readFileSync(projectZeroNextPackagePath, 'utf8')
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const { execSync } = require('child_process');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
function findBaseDir() {
|
|
6
|
+
let currentDir = __dirname;
|
|
7
|
+
while (currentDir !== path.resolve(currentDir, '..')) {
|
|
8
|
+
if (fs.existsSync(path.join(currentDir, 'turbo.json'))) {
|
|
9
|
+
return currentDir;
|
|
10
|
+
}
|
|
11
|
+
currentDir = path.resolve(currentDir, '..');
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const BASE_DIR = findBaseDir();
|
|
17
|
+
|
|
18
|
+
if (BASE_DIR) {
|
|
19
|
+
const extensions = ['bilal-akinon.pznext'];
|
|
20
|
+
extensions.forEach((extension) => {
|
|
21
|
+
try {
|
|
22
|
+
execSync(`code --install-extension ${extension}`, { stdio: 'inherit' });
|
|
23
|
+
} catch (error) {
|
|
24
|
+
console.error(`Error installing ${extension}:`);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
package/bin/pz-predev.js
CHANGED
package/data/client/user.ts
CHANGED
|
@@ -71,6 +71,17 @@ const userApi = api.injectEndpoints({
|
|
|
71
71
|
body
|
|
72
72
|
})
|
|
73
73
|
}),
|
|
74
|
+
otpLogin: build.mutation<void, { phone: string }>({
|
|
75
|
+
query: ({ phone }) => ({
|
|
76
|
+
url: buildClientRequestUrl(user.otpLogin, {
|
|
77
|
+
contentType: 'application/json'
|
|
78
|
+
}),
|
|
79
|
+
method: 'POST',
|
|
80
|
+
body: {
|
|
81
|
+
phone
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
}),
|
|
74
85
|
changeEmailVerification: build.query<void, string>({
|
|
75
86
|
query: (token) => ({
|
|
76
87
|
url: buildClientRequestUrl(user.changeEmailVerification(token), {
|
|
@@ -110,6 +121,7 @@ export const {
|
|
|
110
121
|
useConfirmEmailVerificationQuery,
|
|
111
122
|
useValidateCaptchaMutation,
|
|
112
123
|
useLogoutMutation,
|
|
124
|
+
useOtpLoginMutation,
|
|
113
125
|
useForgotPasswordMutation,
|
|
114
126
|
useGetAnonymousTrackingMutation
|
|
115
127
|
} = userApi;
|
package/data/urls.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akinon/next",
|
|
3
3
|
"description": "Core package for Project Zero Next",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.25.0-rc.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -34,5 +34,8 @@
|
|
|
34
34
|
"eslint": "^8.14.0",
|
|
35
35
|
"@akinon/eslint-plugin-projectzero": "1.24.0",
|
|
36
36
|
"eslint-config-prettier": "8.5.0"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"@akinon/eslint-plugin-projectzero": "1.24.0"
|
|
37
40
|
}
|
|
38
41
|
}
|
package/sentry/index.ts
CHANGED
|
@@ -1,27 +1,33 @@
|
|
|
1
1
|
import * as Sentry from '@sentry/nextjs';
|
|
2
|
+
import settings from 'settings';
|
|
2
3
|
|
|
3
4
|
const SENTRY_DSN: string =
|
|
4
|
-
|
|
5
|
+
settings.sentryDsn ||
|
|
6
|
+
process.env.SENTRY_DSN ||
|
|
7
|
+
process.env.NEXT_PUBLIC_SENTRY_DSN;
|
|
5
8
|
|
|
6
9
|
export const initSentry = (
|
|
7
10
|
type: 'Server' | 'Client' | 'Edge',
|
|
8
|
-
options: Sentry.BrowserOptions | Sentry.NodeOptions | Sentry.EdgeOptions = {
|
|
11
|
+
options: Sentry.BrowserOptions | Sentry.NodeOptions | Sentry.EdgeOptions = {
|
|
12
|
+
dsn: SENTRY_DSN,
|
|
13
|
+
integrations: [],
|
|
14
|
+
tracesSampleRate: 1.0
|
|
15
|
+
}
|
|
9
16
|
) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// TODO: Remove Zero Project DSN
|
|
13
|
-
|
|
14
|
-
Sentry.init({
|
|
15
|
-
dsn:
|
|
16
|
-
SENTRY_DSN ||
|
|
17
|
-
'https://d8558ef8997543deacf376c7d8d7cf4b@o64293.ingest.sentry.io/4504338423742464',
|
|
17
|
+
const initOptions = {
|
|
18
|
+
...options,
|
|
18
19
|
initialScope: {
|
|
19
20
|
tags: {
|
|
21
|
+
...((
|
|
22
|
+
options.initialScope as {
|
|
23
|
+
tags?: Record<string, string>;
|
|
24
|
+
}
|
|
25
|
+
)?.tags ?? {}),
|
|
20
26
|
APP_TYPE: 'ProjectZeroNext',
|
|
21
27
|
TYPE: type
|
|
22
28
|
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
Sentry.init(initOptions);
|
|
27
33
|
};
|
package/types/index.ts
CHANGED
|
@@ -71,6 +71,12 @@ export interface Currency {
|
|
|
71
71
|
|
|
72
72
|
export interface Settings {
|
|
73
73
|
commerceUrl: string;
|
|
74
|
+
/**
|
|
75
|
+
* This option allows you to track Sentry events on the client side, in addition to server and edge environments.
|
|
76
|
+
*
|
|
77
|
+
* It overrides process.env.NEXT_PUBLIC_SENTRY_DSN and process.env.SENTRY_DSN.
|
|
78
|
+
*/
|
|
79
|
+
sentryDsn?: string;
|
|
74
80
|
redis: {
|
|
75
81
|
defaultExpirationTime: number;
|
|
76
82
|
};
|
package/utils/log.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { trace } from '@opentelemetry/api';
|
|
2
|
+
|
|
1
3
|
enum LogLevel {
|
|
2
4
|
TRACE = 'trace',
|
|
3
5
|
DEBUG = 'debug',
|
|
@@ -78,61 +80,42 @@ const writeMsg = ({ level, message, payload }: Message) => {
|
|
|
78
80
|
}
|
|
79
81
|
};
|
|
80
82
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
message,
|
|
85
|
-
payload
|
|
86
|
-
});
|
|
87
|
-
};
|
|
83
|
+
function createCustomSpan({ level, message, payload }: Message) {
|
|
84
|
+
const tracer = trace.getTracer('pz-next-app');
|
|
85
|
+
const span = tracer.startSpan('custom-operation-log');
|
|
88
86
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
payload
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const warn: LoggerFn = (message, payload) => {
|
|
98
|
-
writeMsg({
|
|
99
|
-
level: LogLevel.WARN,
|
|
100
|
-
message,
|
|
101
|
-
payload
|
|
87
|
+
span.setAttributes({
|
|
88
|
+
level: level,
|
|
89
|
+
message: message,
|
|
90
|
+
payload: payload
|
|
102
91
|
});
|
|
103
|
-
};
|
|
104
92
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
level: LogLevel.DEBUG,
|
|
108
|
-
message,
|
|
109
|
-
payload
|
|
110
|
-
});
|
|
111
|
-
};
|
|
93
|
+
span.end();
|
|
94
|
+
}
|
|
112
95
|
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
level
|
|
96
|
+
const createLogAndSpan = (level: LogLevel, message: string, payload?: any) => {
|
|
97
|
+
const content = {
|
|
98
|
+
level,
|
|
116
99
|
message,
|
|
117
|
-
payload
|
|
118
|
-
}
|
|
119
|
-
};
|
|
100
|
+
payload: JSON.stringify(payload)
|
|
101
|
+
};
|
|
120
102
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
level: LogLevel.FATAL,
|
|
124
|
-
message,
|
|
125
|
-
payload
|
|
126
|
-
});
|
|
103
|
+
writeMsg(content);
|
|
104
|
+
createCustomSpan(content);
|
|
127
105
|
};
|
|
128
106
|
|
|
129
|
-
const logger = {
|
|
130
|
-
trace,
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
107
|
+
const logger: Record<LogLevel, LoggerFn> = {
|
|
108
|
+
trace: (message, payload) =>
|
|
109
|
+
createLogAndSpan(LogLevel.TRACE, message, payload),
|
|
110
|
+
debug: (message, payload) =>
|
|
111
|
+
createLogAndSpan(LogLevel.DEBUG, message, payload),
|
|
112
|
+
info: (message, payload) => createLogAndSpan(LogLevel.INFO, message, payload),
|
|
113
|
+
warn: (message, payload) => createLogAndSpan(LogLevel.WARN, message, payload),
|
|
114
|
+
error: (message, payload) =>
|
|
115
|
+
createLogAndSpan(LogLevel.ERROR, message, payload),
|
|
116
|
+
fatal: (message, payload) =>
|
|
117
|
+
createLogAndSpan(LogLevel.FATAL, message, payload),
|
|
118
|
+
silent: () => {}
|
|
136
119
|
};
|
|
137
120
|
|
|
138
121
|
export default logger;
|