@bytexbyte/berify-analytics-api 2.2.7 → 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.
@@ -7,6 +7,12 @@ declare enum TimeInterval {
7
7
  LastWeek = "Last week",
8
8
  LastMonth = "Last month"
9
9
  }
10
+ export type HeatmapBounds = {
11
+ minLat: number;
12
+ maxLat: number;
13
+ minLng: number;
14
+ maxLng: number;
15
+ };
10
16
  export type HeatmapRequest = {
11
17
  userId: string;
12
18
  companyId?: string;
@@ -15,7 +21,13 @@ export type HeatmapRequest = {
15
21
  collectionRuleId?: string;
16
22
  timeInterval: TimeInterval;
17
23
  scanTypes?: ScanType[] | ScanType;
18
- zoom?: number;
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,17 +38,31 @@ export type ReskinHeatmapRequest = {
26
38
  startDate: Date;
27
39
  endDate: Date;
28
40
  };
29
- export type HeatmapCell = {
30
- h3: string;
41
+ /** One scan, at the place it happened. Sent while the viewport holds few enough. */
42
+ export type HeatmapPoint = {
31
43
  count: number;
32
44
  lat: number;
33
45
  lng: number;
34
46
  };
35
- export type HeatmapResult = HeatmapCell[];
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];
36
54
  export type HeatmapMeta = {
37
- resolution: number;
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. */
38
62
  totalPoints: number;
39
63
  cellCount: number;
64
+ /** Scans with no usable coordinates — they cannot appear at any zoom. */
65
+ withoutLocation: number;
40
66
  };
41
67
  export type HeatmapResponse = {
42
68
  status: 'ok' | 'error';
@@ -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
  }
@@ -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>;
@@ -50,13 +50,13 @@ class BerifyScanChartApi extends bxb_api_1.default {
50
50
  }, 'scan-rate-by-time');
51
51
  return response.json();
52
52
  }
53
- async getBatchScanData(form) {
53
+ async getBatchScanData(user, form) {
54
54
  const response = await this.bxbFetch({
55
55
  method: 'POST',
56
56
  headers: {
57
57
  'Content-Type': 'application/json',
58
58
  },
59
- body: JSON.stringify({ form }),
59
+ body: JSON.stringify({ user, form }),
60
60
  }, 'batch-scan-data');
61
61
  return response.json();
62
62
  }
@@ -1,6 +1,7 @@
1
1
  import BerifyHeatMapApi from './Heatmap';
2
2
  import BerifyReskinApi from './Reskin';
3
3
  import BerifyScanChartApi from './ScanChart';
4
+ import BerifyReportApi from './Report';
4
5
  declare class BerifyAnalyticsApi {
5
6
  host: string;
6
7
  secretKey?: string;
@@ -8,6 +9,7 @@ declare class BerifyAnalyticsApi {
8
9
  heatmap: BerifyHeatMapApi;
9
10
  scanChart: BerifyScanChartApi;
10
11
  reskin: BerifyReskinApi;
12
+ report: BerifyReportApi;
11
13
  constructor({ host, secretKey, secret }: {
12
14
  host: string;
13
15
  secretKey?: string;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const Heatmap_1 = require("./Heatmap");
4
4
  const Reskin_1 = require("./Reskin");
5
5
  const ScanChart_1 = require("./ScanChart");
6
+ const Report_1 = require("./Report");
6
7
  class BerifyAnalyticsApi {
7
8
  constructor({ host, secretKey, secret }) {
8
9
  this.host = host;
@@ -11,6 +12,7 @@ class BerifyAnalyticsApi {
11
12
  this.heatmap = new Heatmap_1.default({ host, secretKey, secret });
12
13
  this.scanChart = new ScanChart_1.default({ host, secretKey, secret });
13
14
  this.reskin = new Reskin_1.default({ host, secretKey, secret });
15
+ this.report = new Report_1.default({ host, secretKey, secret });
14
16
  }
15
17
  }
16
18
  exports.default = BerifyAnalyticsApi;
@@ -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.7",
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",