Skip to content

Conversation

@apasel422
Copy link
Collaborator

@apasel422 apasel422 commented Sep 16, 2025

Fixes #31


Preview | Diff

Copy link
Member

@martinthomson martinthomson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the easy part. Getting the answer is the hard part.

@csharrison
Copy link
Collaborator

Discussed in the Oct 14 call - let's wait to merge until we have support for sending the report.

@apasel422
Copy link
Collaborator Author

Discussed in the Oct 14 call - let's wait to merge until we have support for sending the report.

I think we need to deal with #189 first.

@apasel422
Copy link
Collaborator Author

@martinthomson Please take another look.

:: "`no-store`"
: [=request/keepalive=]
:: true
1. [=Fetch=] |request|, optionally retrying in the event of an error.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the optional retry a feature of keepalive? If it isn't, should it be. It seems a bit wrong to include that capability here specifically, when the overall goal of keepalive is to make that sort of thing possible generically.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe automatic retry is inherent to keepalive, based on the MDN documentation. That said, I've been reading more about keepalive, and it's unclear to me if we want or need to use it here, and in general it opens a question about what entity is making the report-transmission request here.

I'd argue that the Attribution API's need to send reports is similar to https://w3c.github.io/reporting/, in that the report-creation step is asynchronous, and not necessarily done within the context of a page. We may want to take inspiration from https://w3c.github.io/reporting/#try-delivery, or at least get advice from someone else about this.

https://fetch.spec.whatwg.org/#fetch-elsewhere-request also implies something along those lines:

If your fetching is not directly web-exposed, e.g., it is sent in the background without relying on a current Window or Worker, leave request’s client as null and set the request’s origin, policy container, service-workers mode, and referrer to appropriate values instead, e.g., by copying them from the environment settings object ahead of time.

I added some inline issues to the spec to discuss this, but would appreciate your thoughts.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That text is about fetches that have no real connection to any active realm. That's not the case here as we always have a Window involved. (We're not presently talking about a Worker, though we could use the Worker's settings object if we wanted to.)

Reporting basically deliberately disassociates the report sending from where the reports are collected. I don't think that's the case here. We're only attaching the HTTP API to fetches that have direct effect on an active window, so we rely on having an active context.

:: true
1. [=Fetch=] |request|, optionally retrying in the event of an error.

Issue: Should the request use a more specific content-type?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're doing DAP only for now, we could hard-code this. Or we could put the content type into the value we supply and interrogate that. We could add to AttributionConversionResult.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The caller of the API is at least theoretically aware of what protocol is being used, even if we support something other than DAP, as the caller chooses the aggregation service, so I'm somewhat reluctant to redundantly include it as part of the request body, which would mean defining some wrapper format around just the encrypted bytes of the report.

In other words, I think whatever we choose should just go in the Content-Type header. Does DAP have an existing media type? If not, we could consider registering one but go with application/octet-stream for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, DAP has a media type, but from our perspective, we'd need to add that to AttributionConversionResult to get it through to this point (unless you wanted to play games with slots, I guess).

apasel422 and others added 7 commits December 17, 2025 08:07
Copy link
Member

@martinthomson martinthomson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully, these responses help.

I'll not be around for a few weeks. I'm happy for you to merge on the basis of the suggestions I've made; though if you want to discuss more, you might either have to be patient or open issues to track those.

Comment on lines +2221 to +2222
Issue: Should the request's [=request/service-workers mode=] be "`none`" instead
of the default of "`all`"?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would tentatively say no. Whatever keepalive does is fine here.

:: "`no-store`"
: [=request/keepalive=]
:: true
1. [=Fetch=] |request|, optionally retrying in the event of an error.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That text is about fetches that have no real connection to any active realm. That's not the case here as we always have a Window involved. (We're not presently talking about a Worker, though we could use the Worker's settings object if we wanted to.)

Reporting basically deliberately disassociates the report sending from where the reports are collected. I don't think that's the case here. We're only attaching the HTTP API to fetches that have direct effect on an active window, so we rely on having an active context.

Issue: Should the request's [=request/service-workers mode=] be "`none`" instead
of the default of "`all`"?

Issue: Should the request's [=request/unsafe-request flag=] be set?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is largely moot. We're using POST with something other than application/x-www-form-urlencoded, so we'll be doing a preflight for any report. We can't really avoid doing that, and nor should we try. Enterprises might not like us pushing these reports at random servers, even though the opportunity for attack seems very much remote (no site can really control the content of reports).

Comment on lines +2226 to +2227
Issue: Should the request's [=request/referrer=] be "`no-referrer`" instead of
the default of "`client"`?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this, it might make sense to use |url|. Setting this to "client" will mean no referer header, which isn't quite right for this.

Comment on lines +2229 to +2230
Issue: Should the request's [=request/destination=] be something other than the
default of the empty string, e.g. "`report`" or even a new value?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty seems right. We'll be keeping good company. We could attempt to define a destination, but I believe that that is possible to do later, if we think that the destination might help us do something special, like have specific CSP rules. Right now, I think we're OK relying on permissions policy and the standard connect-src rules from CSP, but we might decide to add a CSP-level control in future for this.

Comment on lines +2232 to +2233
Issue: Should the request's [=request/redirect mode=] be something other than the
default of "`follow`"?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default works fine.

Comment on lines +2235 to +2237
Issue: Should the request use a `null` client instead, per
<a href="https://fetch.spec.whatwg.org/#fetch-elsewhere-request">the `fetch`
specification's guidance</a>?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that applies, see above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP API

3 participants