@bbki.ng/site 5.5.0 → 5.5.1

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @bbki.ng/site
2
2
 
3
+ ## 5.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 3c2834a: track device activity
8
+ - Updated dependencies [3c2834a]
9
+ - @bbki.ng/ui@0.2.1
10
+
3
11
  ## 5.5.0
4
12
 
5
13
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbki.ng/site",
3
- "version": "5.5.0",
3
+ "version": "5.5.1",
4
4
  "description": "code behind bbki.ng",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -14,7 +14,7 @@
14
14
  "react-dom": "^18.0.0",
15
15
  "react-router-dom": "6",
16
16
  "swr": "^2.2.5",
17
- "@bbki.ng/ui": "0.2.0"
17
+ "@bbki.ng/ui": "0.2.1"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@eslint/compat": "^1.0.0",
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useState, useCallback } from 'react';
2
- import { getFingerprint, getStableDeviceId, FingerprintData } from '@/utils/fingerprints';
2
+ import { getStableDeviceId, FingerprintData } from '@/utils/fingerprints';
3
3
 
4
4
  interface UseFingerprintReturn {
5
5
  deviceId: string | null;
@@ -1,5 +1,6 @@
1
1
  import { API_ENDPOINT } from '@/constants/routes';
2
2
  import { FontType } from '@/types/font';
3
+ import { getFingerprint, getStableDeviceId } from './fingerprints';
3
4
 
4
5
  type Fetcher = (resource: string, init?: any) => Promise<any>;
5
6
 
@@ -7,10 +8,13 @@ export const floatNumberToPercentageString = (num: number): string => {
7
8
  return `${num * 100}%`;
8
9
  };
9
10
 
10
- export const baseFetcher = (resource: string, init: RequestInit = {}) =>
11
- // enable cors
12
- fetch(resource, {
11
+ export const baseFetcher = async (resource: string, init: RequestInit = {}) => {
12
+ const headers = new Headers(init.headers || {});
13
+ const fp = await getFingerprint();
14
+ headers.set('X-Device-Fingerprint', fp.hash);
15
+ return fetch(resource, {
13
16
  ...init,
17
+ headers,
14
18
  mode: 'cors',
15
19
  }).then(res => {
16
20
  if (!res.ok) {
@@ -19,6 +23,7 @@ export const baseFetcher = (resource: string, init: RequestInit = {}) =>
19
23
 
20
24
  return res.json();
21
25
  });
26
+ };
22
27
 
23
28
  export const withBBApi =
24
29
  (fetcher: Fetcher) =>