Skip to content

Commit

Permalink
add additional observability when viewercontext user id is fetched
Browse files Browse the repository at this point in the history
Summary:
From https://fburl.com/canvas/dw1end6w, it appears majority of requests actually do go through FB VC flow, but still doesn't explain why very few user ids were being propagated during the period where user id contextprop was fully rolled out.

Add additional ODS observability to check that `getUserId` is being resolved from VC

Reviewed By: aknott

Differential Revision: D69126070

fbshipit-source-id: 34c504e569430abb45a974e4f5057812757dedd8
  • Loading branch information
Mahmudul Rapi authored and facebook-github-bot committed Feb 4, 2025
1 parent 41c7bc4 commit 45adc34
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions thrift/lib/hack/src/ThriftContextPropState.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,32 +107,37 @@ public static function initFromString(?string $s)[defaults]: void {
}

public static function updateFromVC(?IViewerContextBase $vc): void {
$ods = CategorizedOBC::typedGet(ODSCategoryID::ODS_CONTEXTPROP);
if ($vc is IFBViewerContext) {
self::updateFBUserIdFromVC($vc);
$ods->bumpKey('contextprop.fb_vc');
} else if ($vc is IIGViewerContext) {
self::updateIGUserIdFromVC($vc);
$ods->bumpKey('contextprop.ig_vc');
} else {
$ods = CategorizedOBC::typedGet(ODSCategoryID::ODS_CONTEXTPROP);
$ods->bumpKey('contextprop.unknown_vc');
}
}

private static function updateFBUserIdFromVC(IFBViewerContext $vc): void {
$tcps_fb_user_id = self::get()->getFBUserId();
$ods = CategorizedOBC::typedGet(ODSCategoryID::ODS_CONTEXTPROP);
$ods->bumpKey('contextprop.fb_vc');
// don't overwrite if TCPS already has a valid fb user id
$tcps_fb_user_id = self::get()->getFBUserId();
if (self::coerceId($tcps_fb_user_id) is nonnull) {
return;
}

$fb_user_id = self::coerceId($vc->getUserID());
if ($fb_user_id is nonnull) {
$ods->bumpKey('contextprop.set_fb_user_id');
self::get()->setFBUserId($fb_user_id);
} else {
$ods->bumpKey('contextprop.missing_fb_user_id');
}
}

private static function updateIGUserIdFromVC(IIGViewerContext $vc): void {
$ods = CategorizedOBC::typedGet(ODSCategoryID::ODS_CONTEXTPROP);
$ods->bumpKey('contextprop.ig_vc');
// don't overwrite if TCPS already has a valid ig user id
$tcps_ig_user_id = self::get()->getIGUserId();
if (self::coerceId($tcps_ig_user_id) is nonnull) {
Expand All @@ -141,7 +146,10 @@ private static function updateIGUserIdFromVC(IIGViewerContext $vc): void {

$ig_user_id = self::coerceId($vc->getViewerID());
if ($ig_user_id is nonnull) {
$ods->bumpKey('contextprop.set_ig_user_id');
self::get()->setIGUserId($ig_user_id);
} else {
$ods->bumpKey('contextprop.missing_ig_user_id');
}
}

Expand Down

0 comments on commit 45adc34

Please sign in to comment.