@bytexbyte/berify-analytics-api 2.2.6 → 2.2.8

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.
@@ -4,18 +4,19 @@ const bxb_api_1 = require("@bytexbyte/bxb-api");
4
4
  class BerifyHeatMapApi extends bxb_api_1.default {
5
5
  constructor({ host, secretKey, secret }) {
6
6
  super({
7
- host, moduleName: 'heatmap',
7
+ host,
8
+ moduleName: 'heatmap',
8
9
  secretKey: secretKey ?? 'secretKey',
9
- secret: secret ?? 'secret'
10
+ secret: secret ?? 'secret',
10
11
  });
11
12
  }
12
13
  async getHeatmap(form) {
13
14
  const response = await this.bxbFetch({
14
15
  method: 'POST',
15
16
  headers: {
16
- 'Content-Type': 'application/json'
17
+ 'Content-Type': 'application/json',
17
18
  },
18
- body: JSON.stringify(form)
19
+ body: JSON.stringify(form),
19
20
  });
20
21
  return response.json();
21
22
  }
@@ -23,8 +24,8 @@ class BerifyHeatMapApi extends bxb_api_1.default {
23
24
  const response = await this.bxbFetch({
24
25
  method: 'GET',
25
26
  headers: {
26
- 'Content-Type': 'application/json'
27
- }
27
+ 'Content-Type': 'application/json',
28
+ },
28
29
  });
29
30
  return response.json();
30
31
  }
@@ -32,9 +33,9 @@ class BerifyHeatMapApi extends bxb_api_1.default {
32
33
  const response = await this.bxbFetch({
33
34
  method: 'POST',
34
35
  headers: {
35
- 'Content-Type': 'application/json'
36
+ 'Content-Type': 'application/json',
36
37
  },
37
- body: JSON.stringify(form)
38
+ body: JSON.stringify(form),
38
39
  }, 'date-range');
39
40
  return response.json();
40
41
  }
@@ -1,5 +1,4 @@
1
- import { Decimal } from "@prisma/client/runtime/library";
2
- import { ScanType } from "../../../interfaces";
1
+ import { ScanType } from '../../../interfaces';
3
2
  export type HeatmapApi = (form: HeatmapRequest) => Promise<HeatmapResponse>;
4
3
  declare enum TimeInterval {
5
4
  All = "All Time",
@@ -8,6 +7,12 @@ declare enum TimeInterval {
8
7
  LastWeek = "Last week",
9
8
  LastMonth = "Last month"
10
9
  }
10
+ export type HeatmapBounds = {
11
+ minLat: number;
12
+ maxLat: number;
13
+ minLng: number;
14
+ maxLng: number;
15
+ };
11
16
  export type HeatmapRequest = {
12
17
  userId: string;
13
18
  companyId?: string;
@@ -16,6 +21,13 @@ export type HeatmapRequest = {
16
21
  collectionRuleId?: string;
17
22
  timeInterval: TimeInterval;
18
23
  scanTypes?: ScanType[] | ScanType;
24
+ /** Map viewport; scans outside it are not aggregated. Omitted means worldwide. */
25
+ bounds?: HeatmapBounds;
26
+ /** Explicit window; overrides timeInterval so the client owns its presets. */
27
+ from?: string | Date;
28
+ to?: string | Date;
29
+ /** 'compact' returns [lat, lng, count] tuples instead of objects. */
30
+ format?: 'objects' | 'compact';
19
31
  };
20
32
  export type ReskinHeatmapRequest = {
21
33
  userId: string;
@@ -26,14 +38,36 @@ export type ReskinHeatmapRequest = {
26
38
  startDate: Date;
27
39
  endDate: Date;
28
40
  };
29
- export type HeatmapResult = {
30
- id: string;
31
- latitude: Decimal | null;
32
- longitude: Decimal | null;
33
- }[];
41
+ /** One scan, at the place it happened. Sent while the viewport holds few enough. */
42
+ export type HeatmapPoint = {
43
+ count: number;
44
+ lat: number;
45
+ lng: number;
46
+ };
47
+ /** A bucket of scans at the centre of its h3 cell, for views too broad to send raw. */
48
+ export type HeatmapCell = HeatmapPoint & {
49
+ h3: string;
50
+ };
51
+ export type HeatmapMode = 'points' | 'cells';
52
+ export type HeatmapResult = HeatmapPoint[] | HeatmapCell[] | HeatmapTuple[];
53
+ export type HeatmapTuple = [lat: number, lng: number, count: number];
54
+ export type HeatmapMeta = {
55
+ /** Which shape `data` is in — see HeatmapRequest.format. */
56
+ encoding: 'objects' | 'compact';
57
+ /** 'points' means data is raw scans; 'cells' means it is h3 buckets. */
58
+ mode: HeatmapMode;
59
+ /** h3 resolution of the buckets, null in 'points' mode. */
60
+ resolution: number | null;
61
+ /** Scans matching the filter, before anything geographic is applied. */
62
+ totalPoints: number;
63
+ cellCount: number;
64
+ /** Scans with no usable coordinates — they cannot appear at any zoom. */
65
+ withoutLocation: number;
66
+ };
34
67
  export type HeatmapResponse = {
35
68
  status: 'ok' | 'error';
36
69
  data?: HeatmapResult;
70
+ meta?: HeatmapMeta;
37
71
  error?: string;
38
72
  };
39
73
  export type LastUpdatedAtResponse = {
@@ -7,7 +7,7 @@ class BerifyReportApi extends bxb_api_1.default {
7
7
  host,
8
8
  moduleName: 'reports',
9
9
  secretKey: secretKey ?? 'secretKey',
10
- secret: secret ?? 'secret'
10
+ secret: secret ?? 'secret',
11
11
  });
12
12
  }
13
13
  /**
@@ -22,9 +22,9 @@ class BerifyReportApi extends bxb_api_1.default {
22
22
  const response = await this.bxbFetch({
23
23
  method: 'POST',
24
24
  headers: {
25
- 'Content-Type': 'application/json'
25
+ 'Content-Type': 'application/json',
26
26
  },
27
- body: JSON.stringify({ user, ...form })
27
+ body: JSON.stringify({ user, ...form }),
28
28
  }, '');
29
29
  return response.json();
30
30
  }
@@ -4,18 +4,19 @@ const bxb_api_1 = require("@bytexbyte/bxb-api");
4
4
  class BerifyReskinApi extends bxb_api_1.default {
5
5
  constructor({ host, secretKey, secret }) {
6
6
  super({
7
- host, moduleName: 'reskin',
7
+ host,
8
+ moduleName: 'reskin',
8
9
  secretKey: secretKey ?? 'secretKey',
9
- secret: secret ?? 'secret'
10
+ secret: secret ?? 'secret',
10
11
  });
11
12
  }
12
13
  async getScanCount(user, form) {
13
14
  const response = await this.bxbFetch({
14
15
  method: 'POST',
15
16
  headers: {
16
- 'Content-Type': 'application/json'
17
+ 'Content-Type': 'application/json',
17
18
  },
18
- body: JSON.stringify({ user, form })
19
+ body: JSON.stringify({ user, form }),
19
20
  }, 'scan-count');
20
21
  return response.json();
21
22
  }
@@ -23,9 +24,9 @@ class BerifyReskinApi extends bxb_api_1.default {
23
24
  const response = await this.bxbFetch({
24
25
  method: 'POST',
25
26
  headers: {
26
- 'Content-Type': 'application/json'
27
+ 'Content-Type': 'application/json',
27
28
  },
28
- body: JSON.stringify({ user, form })
29
+ body: JSON.stringify({ user, form }),
29
30
  }, 'new-user-count');
30
31
  return response.json();
31
32
  }
@@ -33,9 +34,9 @@ class BerifyReskinApi extends bxb_api_1.default {
33
34
  const response = await this.bxbFetch({
34
35
  method: 'POST',
35
36
  headers: {
36
- 'Content-Type': 'application/json'
37
+ 'Content-Type': 'application/json',
37
38
  },
38
- body: JSON.stringify({ user, form })
39
+ body: JSON.stringify({ user, form }),
39
40
  }, 'unique-scan-count');
40
41
  return response.json();
41
42
  }
@@ -43,9 +44,9 @@ class BerifyReskinApi extends bxb_api_1.default {
43
44
  const response = await this.bxbFetch({
44
45
  method: 'POST',
45
46
  headers: {
46
- 'Content-Type': 'application/json'
47
+ 'Content-Type': 'application/json',
47
48
  },
48
- body: JSON.stringify({ user, form })
49
+ body: JSON.stringify({ user, form }),
49
50
  }, 'session-duration-avg');
50
51
  return response.json();
51
52
  }
@@ -53,9 +54,9 @@ class BerifyReskinApi extends bxb_api_1.default {
53
54
  const response = await this.bxbFetch({
54
55
  method: 'POST',
55
56
  headers: {
56
- 'Content-Type': 'application/json'
57
+ 'Content-Type': 'application/json',
57
58
  },
58
- body: JSON.stringify({ user, form })
59
+ body: JSON.stringify({ user, form }),
59
60
  }, 'promo-modal-open-count');
60
61
  return response.json();
61
62
  }
@@ -63,9 +64,9 @@ class BerifyReskinApi extends bxb_api_1.default {
63
64
  const response = await this.bxbFetch({
64
65
  method: 'POST',
65
66
  headers: {
66
- 'Content-Type': 'application/json'
67
+ 'Content-Type': 'application/json',
67
68
  },
68
- body: JSON.stringify({ user, form })
69
+ body: JSON.stringify({ user, form }),
69
70
  }, 'community-modal-open-count');
70
71
  return response.json();
71
72
  }
@@ -73,9 +74,9 @@ class BerifyReskinApi extends bxb_api_1.default {
73
74
  const response = await this.bxbFetch({
74
75
  method: 'POST',
75
76
  headers: {
76
- 'Content-Type': 'application/json'
77
+ 'Content-Type': 'application/json',
77
78
  },
78
- body: JSON.stringify({ user, form })
79
+ body: JSON.stringify({ user, form }),
79
80
  }, 'bounce-rate');
80
81
  return response.json();
81
82
  }
@@ -83,9 +84,9 @@ class BerifyReskinApi extends bxb_api_1.default {
83
84
  const response = await this.bxbFetch({
84
85
  method: 'POST',
85
86
  headers: {
86
- 'Content-Type': 'application/json'
87
+ 'Content-Type': 'application/json',
87
88
  },
88
- body: JSON.stringify({ user, form })
89
+ body: JSON.stringify({ user, form }),
89
90
  }, 'experience-engagement');
90
91
  return response.json();
91
92
  }
@@ -93,9 +94,9 @@ class BerifyReskinApi extends bxb_api_1.default {
93
94
  const response = await this.bxbFetch({
94
95
  method: 'POST',
95
96
  headers: {
96
- 'Content-Type': 'application/json'
97
+ 'Content-Type': 'application/json',
97
98
  },
98
- body: JSON.stringify({ user, form })
99
+ body: JSON.stringify({ user, form }),
99
100
  }, 'gender-breakdown');
100
101
  return response.json();
101
102
  }
@@ -103,9 +104,9 @@ class BerifyReskinApi extends bxb_api_1.default {
103
104
  const response = await this.bxbFetch({
104
105
  method: 'POST',
105
106
  headers: {
106
- 'Content-Type': 'application/json'
107
+ 'Content-Type': 'application/json',
107
108
  },
108
- body: JSON.stringify({ user, form })
109
+ body: JSON.stringify({ user, form }),
109
110
  }, 'age-distribution');
110
111
  return response.json();
111
112
  }
@@ -113,9 +114,9 @@ class BerifyReskinApi extends bxb_api_1.default {
113
114
  const response = await this.bxbFetch({
114
115
  method: 'POST',
115
116
  headers: {
116
- 'Content-Type': 'application/json'
117
+ 'Content-Type': 'application/json',
117
118
  },
118
- body: JSON.stringify({ user, form })
119
+ body: JSON.stringify({ user, form }),
119
120
  }, 'device-type');
120
121
  return response.json();
121
122
  }
@@ -123,9 +124,9 @@ class BerifyReskinApi extends bxb_api_1.default {
123
124
  const response = await this.bxbFetch({
124
125
  method: 'POST',
125
126
  headers: {
126
- 'Content-Type': 'application/json'
127
+ 'Content-Type': 'application/json',
127
128
  },
128
- body: JSON.stringify({ user, form })
129
+ body: JSON.stringify({ user, form }),
129
130
  }, 'heatmap');
130
131
  return response.json();
131
132
  }
@@ -133,9 +134,9 @@ class BerifyReskinApi extends bxb_api_1.default {
133
134
  const response = await this.bxbFetch({
134
135
  method: 'POST',
135
136
  headers: {
136
- 'Content-Type': 'application/json'
137
+ 'Content-Type': 'application/json',
137
138
  },
138
- body: JSON.stringify({ user, form })
139
+ body: JSON.stringify({ user, form }),
139
140
  }, 'daily-scan-count');
140
141
  return response.json();
141
142
  }
@@ -143,9 +144,9 @@ class BerifyReskinApi extends bxb_api_1.default {
143
144
  const response = await this.bxbFetch({
144
145
  method: 'POST',
145
146
  headers: {
146
- 'Content-Type': 'application/json'
147
+ 'Content-Type': 'application/json',
147
148
  },
148
- body: JSON.stringify({ user, form })
149
+ body: JSON.stringify({ user, form }),
149
150
  }, 'active-time');
150
151
  return response.json();
151
152
  }
@@ -1,4 +1,4 @@
1
- import { Decimal } from "@prisma/client/runtime/library";
1
+ import { Decimal } from '@prisma/client/runtime/library';
2
2
  export type CompanyRoleType = 'super' | 'admin' | 'marketing' | 'supplier' | 'seo' | 'associate';
3
3
  export type User = {
4
4
  id: string;
@@ -10,7 +10,7 @@ declare class BerifyScanChartApi extends BxBApi {
10
10
  getUserReport(user: User, form: UserReportRequest): Promise<UserReportResponse>;
11
11
  getScanRateAll(user: User, form: UserReportRequest): Promise<ScanRateResponse>;
12
12
  getScanRateByTime(user: User, form: ScanRateByTimeRequest): Promise<ScanRateByTimeResponse>;
13
- getBatchScanData(form: BatchScanDataRequest): Promise<BatchScanDataResponse>;
13
+ getBatchScanData(user: User, form: BatchScanDataRequest): Promise<BatchScanDataResponse>;
14
14
  getLeaderBoard(user: User, form: LeaderBoardRequest): Promise<LeaderBoardResponse>;
15
15
  getTagScanHistory(form: TagSearchRequest): Promise<TagScanResponse>;
16
16
  exportBatchScannedUsers(user: User, form: BatchScannedUsersExportRequest): Promise<BatchScannedUsersExportResponse>;
@@ -4,18 +4,19 @@ const bxb_api_1 = require("@bytexbyte/bxb-api");
4
4
  class BerifyScanChartApi extends bxb_api_1.default {
5
5
  constructor({ host, secretKey, secret }) {
6
6
  super({
7
- host, moduleName: 'scan-chart',
7
+ host,
8
+ moduleName: 'scan-chart',
8
9
  secretKey: secretKey ?? 'secretKey',
9
- secret: secret ?? 'secret'
10
+ secret: secret ?? 'secret',
10
11
  });
11
12
  }
12
13
  async getScanReport(user, form) {
13
14
  const response = await this.bxbFetch({
14
15
  method: 'POST',
15
16
  headers: {
16
- 'Content-Type': 'application/json'
17
+ 'Content-Type': 'application/json',
17
18
  },
18
- body: JSON.stringify({ user, form })
19
+ body: JSON.stringify({ user, form }),
19
20
  }, 'scan-report');
20
21
  return response.json();
21
22
  }
@@ -23,9 +24,9 @@ class BerifyScanChartApi extends bxb_api_1.default {
23
24
  const response = await this.bxbFetch({
24
25
  method: 'POST',
25
26
  headers: {
26
- 'Content-Type': 'application/json'
27
+ 'Content-Type': 'application/json',
27
28
  },
28
- body: JSON.stringify({ user, form })
29
+ body: JSON.stringify({ user, form }),
29
30
  }, 'user-report');
30
31
  return response.json();
31
32
  }
@@ -33,9 +34,9 @@ class BerifyScanChartApi extends bxb_api_1.default {
33
34
  const response = await this.bxbFetch({
34
35
  method: 'POST',
35
36
  headers: {
36
- 'Content-Type': 'application/json'
37
+ 'Content-Type': 'application/json',
37
38
  },
38
- body: JSON.stringify({ user, form })
39
+ body: JSON.stringify({ user, form }),
39
40
  }, 'scan-rate-all');
40
41
  return response.json();
41
42
  }
@@ -43,19 +44,19 @@ class BerifyScanChartApi extends bxb_api_1.default {
43
44
  const response = await this.bxbFetch({
44
45
  method: 'POST',
45
46
  headers: {
46
- 'Content-Type': 'application/json'
47
+ 'Content-Type': 'application/json',
47
48
  },
48
- body: JSON.stringify({ user, form })
49
+ body: JSON.stringify({ user, form }),
49
50
  }, 'scan-rate-by-time');
50
51
  return response.json();
51
52
  }
52
- async getBatchScanData(form) {
53
+ async getBatchScanData(user, form) {
53
54
  const response = await this.bxbFetch({
54
55
  method: 'POST',
55
56
  headers: {
56
- 'Content-Type': 'application/json'
57
+ 'Content-Type': 'application/json',
57
58
  },
58
- body: JSON.stringify({ form })
59
+ body: JSON.stringify({ user, form }),
59
60
  }, 'batch-scan-data');
60
61
  return response.json();
61
62
  }
@@ -63,9 +64,9 @@ class BerifyScanChartApi extends bxb_api_1.default {
63
64
  const response = await this.bxbFetch({
64
65
  method: 'POST',
65
66
  headers: {
66
- 'Content-Type': 'application/json'
67
+ 'Content-Type': 'application/json',
67
68
  },
68
- body: JSON.stringify({ user, form })
69
+ body: JSON.stringify({ user, form }),
69
70
  }, 'leaderBoard');
70
71
  return response.json();
71
72
  }
@@ -73,9 +74,9 @@ class BerifyScanChartApi extends bxb_api_1.default {
73
74
  const response = await this.bxbFetch({
74
75
  method: 'POST',
75
76
  headers: {
76
- 'Content-Type': 'application/json'
77
+ 'Content-Type': 'application/json',
77
78
  },
78
- body: JSON.stringify({ form })
79
+ body: JSON.stringify({ form }),
79
80
  }, 'tagScanHistory');
80
81
  return response.json();
81
82
  }
@@ -1,4 +1,4 @@
1
- import { Scan, ScanType } from "../../../interfaces";
1
+ import { Scan, ScanType } from '../../../interfaces';
2
2
  export type ScanReportRequest = {
3
3
  tagId?: string;
4
4
  batchId?: string;
@@ -1,7 +1,7 @@
1
- import BerifyHeatMapApi from "./Heatmap";
2
- import BerifyReskinApi from "./Reskin";
3
- import BerifyScanChartApi from "./ScanChart";
4
- import BerifyReportApi from "./Report";
1
+ import BerifyHeatMapApi from './Heatmap';
2
+ import BerifyReskinApi from './Reskin';
3
+ import BerifyScanChartApi from './ScanChart';
4
+ import BerifyReportApi from './Report';
5
5
  declare class BerifyAnalyticsApi {
6
6
  host: string;
7
7
  secretKey?: string;
@@ -28,6 +28,7 @@ export interface Scan {
28
28
  location: string | null;
29
29
  createdAt: Date;
30
30
  tagId: string;
31
+ batchId: string | null;
31
32
  generalUserId: string;
32
33
  isVisitedPromo: boolean;
33
34
  isVisitedShop: boolean;
@@ -39,12 +40,12 @@ export interface Scan {
39
40
  type: ScanType;
40
41
  tag: {
41
42
  tokenId: string;
42
- batchId: string;
43
- batch: {
44
- companyId: string;
45
- name: string;
46
- };
43
+ batchId?: string | null;
47
44
  };
45
+ batch: {
46
+ companyId: string;
47
+ name: string;
48
+ } | null;
48
49
  }
49
50
  export type DataWithDate = {
50
51
  date: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytexbyte/berify-analytics-api",
3
- "version": "2.2.6",
3
+ "version": "2.2.8",
4
4
  "description": "api",
5
5
  "main": "lib/berifyAnalyticsApi/src/index.js",
6
6
  "types": "lib/berifyAnalyticsApi/src/index.d.ts",