@bytexbyte/berify-analytics-api 2.0.2 → 2.1.0

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.
@@ -1,5 +1,5 @@
1
1
  import BxBApi from '@bytexbyte/bxb-api';
2
- import { HeatmapRequest, HeatmapResponse, LastUpdatedAtResponse } from './type';
2
+ import { HeatmapRequest, HeatmapResponse, LastUpdatedAtResponse, ReskinHeatmapRequest } from './type';
3
3
  declare class BerifyHeatMapApi extends BxBApi {
4
4
  constructor({ host, secretKey, secret }: {
5
5
  host: string;
@@ -8,5 +8,6 @@ declare class BerifyHeatMapApi extends BxBApi {
8
8
  });
9
9
  getHeatmap(form: HeatmapRequest): Promise<HeatmapResponse>;
10
10
  getLastUpdatedAt(): Promise<LastUpdatedAtResponse>;
11
+ getHeatmapByDateRange(form: ReskinHeatmapRequest): Promise<HeatmapResponse>;
11
12
  }
12
13
  export default BerifyHeatMapApi;
@@ -28,5 +28,15 @@ class BerifyHeatMapApi extends bxb_api_1.default {
28
28
  });
29
29
  return response.json();
30
30
  }
31
+ async getHeatmapByDateRange(form) {
32
+ const response = await this.bxbFetch({
33
+ method: 'POST',
34
+ headers: {
35
+ 'Content-Type': 'application/json'
36
+ },
37
+ body: JSON.stringify(form)
38
+ }, 'date-range');
39
+ return response.json();
40
+ }
31
41
  }
32
42
  exports.default = BerifyHeatMapApi;
@@ -15,6 +15,15 @@ export type HeatmapRequest = {
15
15
  collectionRuleId?: string;
16
16
  timeInterval: TimeInterval;
17
17
  };
18
+ export type ReskinHeatmapRequest = {
19
+ userId: string;
20
+ companyId?: number;
21
+ tagTokenId?: string;
22
+ batchId?: string;
23
+ collectionRuleId?: number;
24
+ startDate: Date;
25
+ endDate: Date;
26
+ };
18
27
  export type HeatmapResult = {
19
28
  id: string;
20
29
  latitude: Decimal | null;
@@ -0,0 +1,81 @@
1
+ import BxBApi from '@bytexbyte/bxb-api';
2
+ import { DataWithDate } from '../../../interfaces';
3
+ import { AgeResult, DeviceTypeResult, GenderResult, HeatmapResult, ReskinChartRequest, User } from './type';
4
+ declare class BerifyReskinApi extends BxBApi {
5
+ constructor({ host, secretKey, secret }: {
6
+ host: string;
7
+ secretKey?: string;
8
+ secret?: string;
9
+ });
10
+ getScanCount(user: User, form: ReskinChartRequest): Promise<{
11
+ data: number;
12
+ } | {
13
+ error: 'session not found' | 'user not found' | 'startDate and endDate are required' | 'Permission denied' | 'Internal Server Error';
14
+ }>;
15
+ getNewUserCount(user: User, form: ReskinChartRequest): Promise<{
16
+ data: number;
17
+ } | {
18
+ error: 'session not found' | 'user not found' | 'startDate and endDate are required' | 'Permission denied' | 'Internal Server Error';
19
+ }>;
20
+ getUniqueScanCount(user: User, form: ReskinChartRequest): Promise<{
21
+ data: number;
22
+ } | {
23
+ error: 'session not found' | 'user not found' | 'startDate and endDate are required' | 'Permission denied' | 'Internal Server Error';
24
+ }>;
25
+ getSessionDurationAvg(user: User, form: ReskinChartRequest): Promise<{
26
+ data: number;
27
+ } | {
28
+ error: 'session not found' | 'user not found' | 'startDate and endDate are required' | 'Permission denied' | 'Internal Server Error';
29
+ }>;
30
+ getPromoModalOpenCount(user: User, form: ReskinChartRequest): Promise<{
31
+ data: number;
32
+ } | {
33
+ error: 'session not found' | 'user not found' | 'startDate and endDate are required' | 'Permission denied' | 'Internal Server Error';
34
+ }>;
35
+ getCommunityModalOpenCount(user: User, form: ReskinChartRequest): Promise<{
36
+ data: number;
37
+ } | {
38
+ error: 'session not found' | 'user not found' | 'startDate and endDate are required' | 'Permission denied' | 'Internal Server Error';
39
+ }>;
40
+ getBounceRate(user: User, form: ReskinChartRequest): Promise<{
41
+ data: number;
42
+ } | {
43
+ error: 'session not found' | 'user not found' | 'startDate and endDate are required' | 'Permission denied' | 'Internal Server Error';
44
+ }>;
45
+ getExperienceEngagement(user: User, form: ReskinChartRequest): Promise<{
46
+ data: number;
47
+ } | {
48
+ error: 'session not found' | 'user not found' | 'startDate and endDate are required' | 'Permission denied' | 'Internal Server Error';
49
+ }>;
50
+ getGenderBreakdown(user: User, form: ReskinChartRequest): Promise<{
51
+ data: GenderResult;
52
+ } | {
53
+ error: 'session not found' | 'user not found' | 'startDate and endDate are required' | 'Permission denied' | 'Internal Server Error';
54
+ }>;
55
+ getAgeDistribution(user: User, form: ReskinChartRequest): Promise<{
56
+ data: AgeResult;
57
+ } | {
58
+ error: 'session not found' | 'user not found' | 'startDate and endDate are required' | 'Permission denied' | 'Internal Server Error';
59
+ }>;
60
+ getDeviceType(user: User, form: ReskinChartRequest): Promise<{
61
+ data: DeviceTypeResult;
62
+ } | {
63
+ error: 'session not found' | 'user not found' | 'startDate and endDate are required' | 'Permission denied' | 'Internal Server Error';
64
+ }>;
65
+ getHeatmap(user: User, form: ReskinChartRequest): Promise<{
66
+ data: HeatmapResult;
67
+ } | {
68
+ error: 'session not found' | 'user not found' | 'startDate and endDate are required' | 'Permission denied' | 'Internal Server Error';
69
+ }>;
70
+ getDailyScanCount(user: User, form: ReskinChartRequest): Promise<{
71
+ data: DataWithDate[];
72
+ } | {
73
+ error: 'session not found' | 'user not found' | 'startDate and endDate are required' | 'Permission denied' | 'Internal Server Error';
74
+ }>;
75
+ getActiveTime(user: User, form: ReskinChartRequest): Promise<{
76
+ data: number[];
77
+ } | {
78
+ error: 'session not found' | 'user not found' | 'startDate and endDate are required' | 'Permission denied' | 'Internal Server Error';
79
+ }>;
80
+ }
81
+ export default BerifyReskinApi;
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const bxb_api_1 = require("@bytexbyte/bxb-api");
4
+ class BerifyReskinApi extends bxb_api_1.default {
5
+ constructor({ host, secretKey, secret }) {
6
+ super({
7
+ host, moduleName: 'reskin',
8
+ secretKey: secretKey ?? 'secretKey',
9
+ secret: secret ?? 'secret'
10
+ });
11
+ }
12
+ async getScanCount(user, form) {
13
+ const response = await this.bxbFetch({
14
+ method: 'POST',
15
+ headers: {
16
+ 'Content-Type': 'application/json'
17
+ },
18
+ body: JSON.stringify({ user, form })
19
+ }, 'scan-count');
20
+ return response.json();
21
+ }
22
+ async getNewUserCount(user, form) {
23
+ const response = await this.bxbFetch({
24
+ method: 'POST',
25
+ headers: {
26
+ 'Content-Type': 'application/json'
27
+ },
28
+ body: JSON.stringify({ user, form })
29
+ }, 'new-user-count');
30
+ return response.json();
31
+ }
32
+ async getUniqueScanCount(user, form) {
33
+ const response = await this.bxbFetch({
34
+ method: 'POST',
35
+ headers: {
36
+ 'Content-Type': 'application/json'
37
+ },
38
+ body: JSON.stringify({ user, form })
39
+ }, 'unique-scan-count');
40
+ return response.json();
41
+ }
42
+ async getSessionDurationAvg(user, form) {
43
+ const response = await this.bxbFetch({
44
+ method: 'POST',
45
+ headers: {
46
+ 'Content-Type': 'application/json'
47
+ },
48
+ body: JSON.stringify({ user, form })
49
+ }, 'session-duration-avg');
50
+ return response.json();
51
+ }
52
+ async getPromoModalOpenCount(user, form) {
53
+ const response = await this.bxbFetch({
54
+ method: 'POST',
55
+ headers: {
56
+ 'Content-Type': 'application/json'
57
+ },
58
+ body: JSON.stringify({ user, form })
59
+ }, 'promo-modal-open-count');
60
+ return response.json();
61
+ }
62
+ async getCommunityModalOpenCount(user, form) {
63
+ const response = await this.bxbFetch({
64
+ method: 'POST',
65
+ headers: {
66
+ 'Content-Type': 'application/json'
67
+ },
68
+ body: JSON.stringify({ user, form })
69
+ }, 'community-modal-open-count');
70
+ return response.json();
71
+ }
72
+ async getBounceRate(user, form) {
73
+ const response = await this.bxbFetch({
74
+ method: 'POST',
75
+ headers: {
76
+ 'Content-Type': 'application/json'
77
+ },
78
+ body: JSON.stringify({ user, form })
79
+ }, 'bounce-rate');
80
+ return response.json();
81
+ }
82
+ async getExperienceEngagement(user, form) {
83
+ const response = await this.bxbFetch({
84
+ method: 'POST',
85
+ headers: {
86
+ 'Content-Type': 'application/json'
87
+ },
88
+ body: JSON.stringify({ user, form })
89
+ }, 'experience-engagement');
90
+ return response.json();
91
+ }
92
+ async getGenderBreakdown(user, form) {
93
+ const response = await this.bxbFetch({
94
+ method: 'POST',
95
+ headers: {
96
+ 'Content-Type': 'application/json'
97
+ },
98
+ body: JSON.stringify({ user, form })
99
+ }, 'gender-breakdown');
100
+ return response.json();
101
+ }
102
+ async getAgeDistribution(user, form) {
103
+ const response = await this.bxbFetch({
104
+ method: 'POST',
105
+ headers: {
106
+ 'Content-Type': 'application/json'
107
+ },
108
+ body: JSON.stringify({ user, form })
109
+ }, 'age-distribution');
110
+ return response.json();
111
+ }
112
+ async getDeviceType(user, form) {
113
+ const response = await this.bxbFetch({
114
+ method: 'POST',
115
+ headers: {
116
+ 'Content-Type': 'application/json'
117
+ },
118
+ body: JSON.stringify({ user, form })
119
+ }, 'device-type');
120
+ return response.json();
121
+ }
122
+ async getHeatmap(user, form) {
123
+ const response = await this.bxbFetch({
124
+ method: 'POST',
125
+ headers: {
126
+ 'Content-Type': 'application/json'
127
+ },
128
+ body: JSON.stringify({ user, form })
129
+ }, 'heatmap');
130
+ return response.json();
131
+ }
132
+ async getDailyScanCount(user, form) {
133
+ const response = await this.bxbFetch({
134
+ method: 'POST',
135
+ headers: {
136
+ 'Content-Type': 'application/json'
137
+ },
138
+ body: JSON.stringify({ user, form })
139
+ }, 'daily-scan-count');
140
+ return response.json();
141
+ }
142
+ async getActiveTime(user, form) {
143
+ const response = await this.bxbFetch({
144
+ method: 'POST',
145
+ headers: {
146
+ 'Content-Type': 'application/json'
147
+ },
148
+ body: JSON.stringify({ user, form })
149
+ }, 'active-time');
150
+ return response.json();
151
+ }
152
+ }
153
+ exports.default = BerifyReskinApi;
@@ -0,0 +1,40 @@
1
+ import { Decimal } from "@prisma/client/runtime/library";
2
+ export type CompanyRoleType = 'super' | 'admin' | 'marketing' | 'supplier' | 'seo' | 'associate';
3
+ export type User = {
4
+ id: string;
5
+ companyId: string;
6
+ companyRole: CompanyRoleType;
7
+ };
8
+ export interface ReskinChartRequest {
9
+ startDate: string;
10
+ endDate: string;
11
+ batchId?: string;
12
+ companyId?: string;
13
+ country?: string;
14
+ state?: string;
15
+ city?: string;
16
+ }
17
+ export type GenderResult = {
18
+ male: number;
19
+ female: number;
20
+ unknown: number;
21
+ };
22
+ export type AgeResult = {
23
+ '18-24': number;
24
+ '25-34': number;
25
+ '35-44': number;
26
+ '45-54': number;
27
+ '55-64': number;
28
+ '65+': number;
29
+ unknown: number;
30
+ };
31
+ export type DeviceTypeResult = {
32
+ iOS: number;
33
+ Android: number;
34
+ Web: number;
35
+ };
36
+ export type HeatmapResult = {
37
+ id: string;
38
+ latitude: Decimal | null;
39
+ longitude: Decimal | null;
40
+ }[];
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,5 @@
1
1
  import BerifyHeatMapApi from "./Heatmap";
2
+ import BerifyReskinApi from "./Reskin";
2
3
  import BerifyScanChartApi from "./ScanChart";
3
4
  declare class BerifyAnalyticsApi {
4
5
  host: string;
@@ -6,6 +7,7 @@ declare class BerifyAnalyticsApi {
6
7
  secret?: string;
7
8
  heatmap: BerifyHeatMapApi;
8
9
  scanChart: BerifyScanChartApi;
10
+ reskin: BerifyReskinApi;
9
11
  constructor({ host, secretKey, secret }: {
10
12
  host: string;
11
13
  secretKey?: string;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const Heatmap_1 = require("./Heatmap");
4
+ const Reskin_1 = require("./Reskin");
4
5
  const ScanChart_1 = require("./ScanChart");
5
6
  class BerifyAnalyticsApi {
6
7
  constructor({ host, secretKey, secret }) {
@@ -9,6 +10,7 @@ class BerifyAnalyticsApi {
9
10
  this.secret = secret;
10
11
  this.heatmap = new Heatmap_1.default({ host, secretKey, secret });
11
12
  this.scanChart = new ScanChart_1.default({ host, secretKey, secret });
13
+ this.reskin = new Reskin_1.default({ host, secretKey, secret });
12
14
  }
13
15
  }
14
16
  exports.default = BerifyAnalyticsApi;
@@ -31,6 +31,7 @@ export interface Scan {
31
31
  generalUserId: string;
32
32
  type: ScanType;
33
33
  tag: {
34
+ tokenId: string;
34
35
  batchId: string;
35
36
  batch: {
36
37
  companyId: string;
@@ -38,3 +39,7 @@ export interface Scan {
38
39
  };
39
40
  };
40
41
  }
42
+ export type DataWithDate = {
43
+ date: string;
44
+ value: number;
45
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytexbyte/berify-analytics-api",
3
- "version": "2.0.2",
3
+ "version": "2.1.0",
4
4
  "description": "api",
5
5
  "main": "lib/berifyAnalyticsApi/src/index.js",
6
6
  "types": "lib/berifyAnalyticsApi/src/index.d.ts",