@akinon/next 1.24.0-rc.5 → 1.24.0-rc.6
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 +8 -0
- package/api/auth.ts +2 -2
- package/data/client/user.ts +12 -0
- package/data/urls.ts +1 -0
- package/package.json +2 -2
- package/utils/log.ts +30 -47
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @akinon/next
|
|
2
2
|
|
|
3
|
+
## 1.24.0-rc.6
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- e20b27f: ZERO-2454:add otp login
|
|
8
|
+
- a4674c6: ZERO-2461: add optional chaining for referrer header and add locale value for redirect url
|
|
9
|
+
- 1ec9775: ZERO-2462:add custom span to logs
|
|
10
|
+
|
|
3
11
|
## 1.24.0-rc.5
|
|
4
12
|
|
|
5
13
|
## 1.24.0-rc.4
|
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
|
}
|
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.24.0-rc.
|
|
4
|
+
"version": "1.24.0-rc.6",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@typescript-eslint/eslint-plugin": "6.7.4",
|
|
33
33
|
"@typescript-eslint/parser": "6.7.4",
|
|
34
34
|
"eslint": "^8.14.0",
|
|
35
|
-
"@akinon/eslint-plugin-projectzero": "1.24.0-rc.
|
|
35
|
+
"@akinon/eslint-plugin-projectzero": "1.24.0-rc.6",
|
|
36
36
|
"eslint-config-prettier": "8.5.0"
|
|
37
37
|
}
|
|
38
38
|
}
|
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;
|