patcg-individual-drafts / topics

The Topics API
https://patcg-individual-drafts.github.io/topics/
Other
605 stars 199 forks source link

Topics API Didn't Log Observation #330

Open relevance-api-topics opened 1 month ago

relevance-api-topics commented 1 month ago

Hi Topics API experts,

We are having a blocking issue where a successful observation through fetch call cannot be recognized by Chrome:

The context is we are having adtech JS plugin into publishers website, and through the JS plugin we are doing the fetch observation call. However, the observation is not recognized by Chrome.

E.g.

Successful Request:

1

Successful Response:

2

No Chrome recognition:

3

Anything we missed to let Chrome recognize the successful JS Plugin observation call? Thanks.

xyaoinum commented 1 month ago

Thanks for reporting the issue. To help us investigate further, could you please confirm:

  1. Did you force a topics calculation in the internals page after the observation?

~2. Was the page still open at that time? (The page needs to be closed for the observation to be actually recorded)~

  1. Was the page opened via user, or did it open automatically? (Per the explainer: only sites that were navigated to via user gesture are included (as opposed to a redirect, for example)).

Thanks!

relevance-api-topics commented 1 month ago

thanks for the information! 2. & 3. are the issue for us, thanks.

relevance-api-topics commented 3 weeks ago

HI @xyaoinum, hope to reopen this discussion, once in a while we are facing this issue where the request and response sounds valid but nothing is recorded for topics in internal dashboard.

Would you please help elaborate how do you validate No.3? thanks.

xyaoinum commented 3 weeks ago

Hi @relevance-api-topics,

To validate if a page is loaded via user, you can follow these steps:

  1. Start Chrome with flags: --force-enable-metrics-reporting --metrics-upload-interval=5 --force-msbb-setting-on-for-ukm
  2. Load your page
  3. Go to chrome://ukm (may need to click "Refresh"). You should see a row with your page's URL and with Source Type NAVIGATION_ID. Expand that row, and you should see a row with PageLoadInitiatorForAdTagging --> FromUser --> 1

I do want to make a correction to my previous answer: No.2 isn't necessary. The page doesn't need to be closed for the observation to be recorded. However, the Topics API call may race with the "Calculate Now" action. So you should consider adding a brief delay before clicking "Calculate Now".