@ht-sdks/events-sdk-js-browser 1.5.5 → 1.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ht-sdks/events-sdk-js-browser",
3
- "version": "1.5.5",
3
+ "version": "1.5.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/ht-sdks/events-sdk-js-mono",
@@ -1,2 +1,2 @@
1
1
  // This file is generated.
2
- export const version = '1.5.5'
2
+ export const version = '1.5.6'
@@ -1,5 +1,20 @@
1
1
  import { HighEntropyHint, NavigatorUAData, UADataValues } from './interfaces'
2
2
 
3
+ // Tolerate Pascal-cased `Brand` / `Version` aliases emitted by some polyfills
4
+ // and enterprise wrappers on `brands` entries. The W3C spec only defines
5
+ // lowercase `brand` / `version`
6
+ // (https://wicg.github.io/ua-client-hints/#dictdef-navigatoruabrandversion),
7
+ // and downstream consumers read those, so we coerce to lowercase here.
8
+ function normalizeBrands(
9
+ brands: UADataValues['brands']
10
+ ): UADataValues['brands'] {
11
+ return brands?.map(({ Brand, Version, brand, version, ...rest }: any) => ({
12
+ ...rest,
13
+ brand: brand ?? Brand,
14
+ version: version ?? Version,
15
+ }))
16
+ }
17
+
3
18
  export async function clientHints(
4
19
  hints?: HighEntropyHint[]
5
20
  ): Promise<UADataValues | undefined> {
@@ -9,8 +24,11 @@ export async function clientHints(
9
24
 
10
25
  if (!userAgentData) return undefined
11
26
 
12
- if (!hints) return userAgentData.toJSON()
13
- return userAgentData
14
- .getHighEntropyValues(hints)
15
- .catch(() => userAgentData.toJSON())
27
+ const data = !hints
28
+ ? userAgentData.toJSON()
29
+ : await userAgentData
30
+ .getHighEntropyValues(hints)
31
+ .catch(() => userAgentData.toJSON())
32
+
33
+ return { ...data, brands: normalizeBrands(data.brands) }
16
34
  }