adactio / share-button-type

Other
17 stars 0 forks source link

Needs a way to specify the ShareData parameter to Web Share API's share method #4

Open othermaciej opened 1 year ago

othermaciej commented 1 year ago

Declarative UI for Web Share API seems like a cool idea. However, this proposal is missing a way to provide the equivalent of the ShareDate dictionary that's passed to the Web Share API's share method. The goal of the Web Share API is to enable sharing objects that are represented by part of the page, not to share the page itself, as the user flow here seems to assume. An example would be, in a Mastodon web client, have buttons that can share an individual Toot, rather than the link to the user's whole Mastodon feed. Declarative buttons to invoke Web Share API for part of the page seem super useful. A button to share the page itself is not very useful. Websites don't use Web Share API for that today very much (afaik) and it's duplicative of the share button in the browser chrome.

adactio commented 1 year ago

Hi Maciej,

The use case for the declarative button isn't to cover all the uses of the Web Share API—the idea isn't that it's a one-to-one copy—but rather to cover one use case; sharing the URL of the current page. If you need to more than that (like the Mastodon example), then the existing JavaScript API is the way to go.

A button to share the page itself is not very useful. Websites don't use Web Share API for that today very much (afaik)

On the contrary, this appears to be the most common usage of the Web Share API by quite some way. Hence the idea of paving that particular cowpath.

I'm actively looking for uses of the Web Share API here: https://github.com/adactio/share-button-type/issues/1

If you have access to any data on how the API is being used (telemetry?) it would be great to some more info!

and it's duplicative of the share button in the browser chrome.

…which isn't always available. Like, for example, a progressive web app (excuse me, home page app) launched with minimal-ui or fullscreen.

PaulKinlan commented 11 months ago

Not sure how I missed this repo. Awesome!

I pulled some data from HTTP Archive using the following query.

1,648,176 responses body has a reference to navigator.share(. link to results < I can give you access.

SELECT 
 COUNT(*) AS count_of_origins,
 REGEXP_EXTRACT(body, r'navigator.share\([^\)]+\)') AS text
FROM `httparchive.response_bodies.2023_06_01_mobile` 
WHERE body LIKE '%navigator.share(%'
GROUP BY 2
ORDER BY 1 DESC

(take with a grain of salt as there are false positives and missing info - i.e, the regex doesn't work well with functions as arguments etc)

I've tabulated some sample results and looked at some of the reponses to see if I can work out what things like .share(e) are doing. If I was to give a summary after a 20-30 minute spelunk it looks like there are a significant number of cases sharing the current page URL (many of the JS widgets default to current url), or sharing the current embed URL.

Response Count Code Extra info
1169238 navigator.share({title:c.title,url:b}) Youtube embed - links to video
146645 navigator.share(e) static.addtoany.com widget for images (not current page)
74188 navigator.share(t) https://www.wix.com/app-market/wix-pro-gallery (images I think)
24246 navigator.share(n) Yandex embed, likely current url to a selection of services
24177 navigator.share({url:location.href})
13111 navigator.share({url:n,text:i}) wix-vod-widget < current url to object
10612 navigator.share({url:e})
9448 navigator.share(this.shareData)
7686 navigator.share({ url: this.urlToShare, title: document.title })
7203 navigator.share({url:s})
6293 navigator.share(r)
6237 navigator.share(i)
5729 navigator.share(y(a)
5190 navigator.share(f(l)
4720 navigator.share(this.getShareOptions()
4639 navigator.share({ title: this.hasAttribute("share-title")

Hope this helps.