treasure-data / td-js-sdk

JavaScript SDK for Treasure Data
http://docs.treasuredata.com/articles/javascript-sdk
Apache License 2.0
71 stars 26 forks source link

Guard deprecated platform property #248

Closed akito19 closed 1 year ago

akito19 commented 1 year ago

I propose to introduce a property to guard td_platform value. Currently, td_platform is based on window.navigator.platform. However, this property is not recommended now:

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

https://developer.mozilla.org/en-US/docs/Web/API/Navigator/platform

So that I want to introduce a platform property of NavigatorUAData: window.navigator.userAgentData.platform. https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData/platform

This property changes a value "MacIntel" (M1, M2 Mac is recognized as "MacIntel"!) to "macOS", for example. However, existing behavior is prioritized because the window.navigator.userAgentData.platform has been experimental yet and browser compatibility is so restricted.

What do you think about it?

imnutz commented 1 year ago

@akito19 It looks good to me. I'll plan to have this in the next version. Thank you for the pr