Bug 237969

Summary: Implement PCM to SKAdNetwork bridge
Product: WebKit Reporter: Alex Christensen <achristensen>
Component: New BugsAssignee: Alex Christensen <achristensen>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, cdumez, changseok, cmarcelo, esprehn+autocc, ews-watchlist, gyuyoung.kim, hi, japhet, mkwst, wilander
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch ews-feeder: commit-queue-

Description Alex Christensen 2022-03-16 10:40:37 PDT
Implement PCM to SKAdNetwork bridge
Comment 1 Alex Christensen 2022-03-16 10:47:25 PDT
Created attachment 454864 [details]
Patch
Comment 2 Alex Christensen 2022-03-16 14:05:40 PDT
Created attachment 454891 [details]
Patch
Comment 3 John Wilander 2022-03-21 20:35:54 PDT
Comment on attachment 454891 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=454891&action=review

r=me with comments. Please make sure the WK2 bots are green before landing.

> Source/WTF/wtf/PlatformHave.h:1227
> +#if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 160000)

I think this should be TBD.

> Source/WebKit/ChangeLog:8
> +

Please add some comments on the changes in the WebKit layer.

> Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm:1822
> +void NetworkSessionCocoa::donateToSKAdNetwork(WebCore::PrivateClickMeasurement&& pcm)

This method doesn't move the pcm object further. Would it make sense to use & const instead?

> Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm:1826
> +    config.get().appAdamId = @(*pcm.adamID());

I think we should check that there is an adamID and if not, broadcast an error message and return without forwarding to the daemon. See my comment further down on isSKAdNetworkAttribution().

> Source/WebKit/UIProcess/WebPageProxy.cpp:4982
> +            if (privateClickMeasurement->destinationSite().matches(frame->url()) || privateClickMeasurement->adamID())

Since we use it this way, I'd prefer a convenience function isSKAdNetworkAttribution() which internally checks whether it is a valid such PCM object.

> Tools/TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm:599
> +    EXPECT_WK_STREQ(consoleMessages[1], "Submitting potential install attribution for AdamId: 1234567890, adNetworkRegistrableDomain: destination, impressionId: MTIzNDU2Nzg5MDEyMzQ1Ng, sourceWebRegistrableDomain: example.com, version: 3");

Huh, I didn't know you could test console messages. Neat.
Comment 4 Alex Christensen 2022-03-22 16:07:15 PDT
Created attachment 455446 [details]
Patch
Comment 5 Alex Christensen 2022-03-22 16:09:10 PDT
(In reply to John Wilander from comment #3)
> This method doesn't move the pcm object further. Would it make sense to use
> & const instead?
It is consuming the pcm, so although it doesn't call a move constructor or anything, I think move semantics is conceptually how we should be thinking about the pcm that is moved here and we shouldn't do anything with it afterwards.

> Since we use it this way, I'd prefer a convenience function
> isSKAdNetworkAttribution() which internally checks whether it is a valid
> such PCM object.
Good idea.  Better name for the same thing.

> > Tools/TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm:599
> > +    EXPECT_WK_STREQ(consoleMessages[1], "Submitting potential install attribution for AdamId: 1234567890, adNetworkRegistrableDomain: destination, impressionId: MTIzNDU2Nzg5MDEyMzQ1Ng, sourceWebRegistrableDomain: example.com, version: 3");
> 
> Huh, I didn't know you could test console messages. Neat.
You can on macOS
Comment 6 Alex Christensen 2022-03-22 22:26:21 PDT
r291735