Skip to content

Commit c5b1ccc

Browse files
committed
metrics: add more errors
Added reason and subreason for sentitive content videos ("CONTENT_CHECK_REQUIRED") fix: fix typo: `SignInToConfirmBot` -> `signInToConfirmBot`
1 parent 09e2f49 commit c5b1ccc

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

src/lib/helpers/metrics.ts

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,24 +111,32 @@ export class Metrics {
111111

112112
interface Error {
113113
signInToConfirmAge: boolean;
114-
SignInToConfirmBot: boolean;
114+
signInToConfirmBot: boolean;
115+
selfHarmTopics: boolean;
115116
unknown: string | undefined;
116117
}
117118

118119
const error: Error = {
119120
signInToConfirmAge: false,
120-
SignInToConfirmBot: false,
121+
signInToConfirmBot: false,
122+
selfHarmTopics: false,
121123
unknown: undefined,
122124
};
123125

124126
switch (true) {
125127
case reason?.includes("Sign in to confirm you’re not a bot"):
126-
error.SignInToConfirmBot = true;
128+
error.signInToConfirmBot = true;
127129
return error;
128130
// Age restricted videos
129131
case reason?.includes("Sign in to confirm your age"):
130132
error.signInToConfirmAge = true;
131133
return error;
134+
// For videos with playabilityStatus.status == `CONTENT_CHECK_REQUIRED`
135+
case reason?.includes(
136+
"The following content may contain suicide or self-harm topics",
137+
):
138+
error.selfHarmTopics = true;
139+
return error;
132140
default:
133141
error.unknown = reason;
134142
return error;
@@ -142,18 +150,34 @@ export class Metrics {
142150

143151
interface Error {
144152
thisHelpsProtectCommunity: boolean;
153+
thisVideoMayBeInnapropiate: boolean;
154+
viewerDiscretionAdvised: boolean;
145155
unknown: string | undefined;
146156
}
147157

148158
const error: Error = {
149159
thisHelpsProtectCommunity: false,
160+
thisVideoMayBeInnapropiate: false,
161+
viewerDiscretionAdvised: false,
150162
unknown: undefined,
151163
};
152164

153165
switch (true) {
154166
case subReason?.includes("This helps protect our community"):
155167
error.thisHelpsProtectCommunity = true;
156168
return error;
169+
// Age restricted videos
170+
case subReason?.includes(
171+
"This video may be inappropriate for some users",
172+
):
173+
error.thisVideoMayBeInnapropiate = true;
174+
return error;
175+
// For videos with playabilityStatus.status == `CONTENT_CHECK_REQUIRED`
176+
case subReason?.includes(
177+
"Viewer discretion is advised",
178+
):
179+
error.viewerDiscretionAdvised = true;
180+
return error;
157181
default:
158182
error.unknown = subReason;
159183
return error;
@@ -194,7 +218,7 @@ export class Metrics {
194218
if (status.loginRequired) {
195219
this.innertubeErrorStatusLoginRequired.inc();
196220

197-
if (reason.SignInToConfirmBot) {
221+
if (reason.signInToConfirmBot) {
198222
this.innertubeErrorReasonSignIn.inc();
199223

200224
if (subReason.thisHelpsProtectCommunity) {

0 commit comments

Comments
 (0)