@agenus-io/pixel-backend-sdk 1.1.3 → 1.1.5

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 type { AWSConfig, SendSaleParams } from "../config";
2
- import { ICreatePixelDTO, IGetOnePixelDTO, IGetPixelDTO, IDeletePixelDTO, IUpdatePixelDTO, IPixelSdk, IUpdateOffersDTO, IMetricsDTO, IFunilSummaryDTO } from './interface';
2
+ import { ICreatePixelDTO, IGetOnePixelDTO, IGetPixelDTO, IDeletePixelDTO, IUpdatePixelDTO, IPixelSdk, IUpdateOffersDTO, IMetricsDTO, IFunilSummaryDTO, IAccessGraphDTO, IEventsSourceDTO, IEventsDeviceDTO, IEventsPerPageDTO, IEventsPerProjectDTO, ISummaryDTO } from './interface';
3
3
  /**
4
4
  * Classe responsável por com vendas e pixels
5
5
  */
@@ -30,4 +30,10 @@ export declare class PixelSDK implements IPixelSdk {
30
30
  UpdateOffers({ id, workspaceId, offerIds, type }: IUpdateOffersDTO.Params): Promise<void>;
31
31
  Metrics({ workSpaceId, platform, productIds, offerIds, filter }: IMetricsDTO.Params): Promise<IMetricsDTO.Result>;
32
32
  FunilSummary({ workSpaceId, startDate, endDate, campaigns }: IFunilSummaryDTO.Params): Promise<IFunilSummaryDTO.Result>;
33
+ AccessGraph({ workSpaceId, startDate, endDate }: IAccessGraphDTO.Params): Promise<IAccessGraphDTO.Result>;
34
+ EventsSource({ workSpaceId, startDate, endDate }: IEventsSourceDTO.Params): Promise<IEventsSourceDTO.Result>;
35
+ EventsDevice({ workSpaceId, startDate, endDate }: IEventsDeviceDTO.Params): Promise<IEventsDeviceDTO.Result>;
36
+ EventsPerPage({ workSpaceId, startDate, endDate }: IEventsPerPageDTO.Params): Promise<IEventsPerPageDTO.Result>;
37
+ EventsPerProject({ workSpaceId, startDate, endDate }: IEventsPerProjectDTO.Params): Promise<IEventsPerProjectDTO.Result>;
38
+ Summary({ workSpaceId, startDate, endDate }: ISummaryDTO.Params): Promise<ISummaryDTO.Result>;
33
39
  }
@@ -263,5 +263,143 @@ class PixelSDK {
263
263
  throw "Erro ao obter resumo da funil";
264
264
  }
265
265
  }
266
+ async AccessGraph({ workSpaceId, startDate, endDate }) {
267
+ try {
268
+ const token = {
269
+ appId: this.appId,
270
+ secretToken: this.appToken,
271
+ workSpaceId: workSpaceId,
272
+ };
273
+ const response = await axios_1.default.get(`${this.apiUrl}/metrics/events/access/graph`, {
274
+ headers: { "app-id": token.appId, "app-secret-token": token.secretToken, "work-space-id": token.workSpaceId },
275
+ params: { startDate, endDate },
276
+ });
277
+ return response.data;
278
+ }
279
+ catch (error) {
280
+ if (error instanceof axios_1.AxiosError) {
281
+ console.log(error.response?.data);
282
+ }
283
+ else {
284
+ console.log(error);
285
+ }
286
+ throw "Erro ao obter gráfico de acesso";
287
+ }
288
+ }
289
+ async EventsSource({ workSpaceId, startDate, endDate }) {
290
+ try {
291
+ const token = {
292
+ appId: this.appId,
293
+ secretToken: this.appToken,
294
+ workSpaceId: workSpaceId,
295
+ };
296
+ const response = await axios_1.default.get(`${this.apiUrl}/metrics/events/source`, {
297
+ headers: { "app-id": token.appId, "app-secret-token": token.secretToken, "work-space-id": token.workSpaceId },
298
+ params: { startDate, endDate },
299
+ });
300
+ return response.data;
301
+ }
302
+ catch (error) {
303
+ if (error instanceof axios_1.AxiosError) {
304
+ console.log(error.response?.data);
305
+ }
306
+ else {
307
+ console.log(error);
308
+ }
309
+ throw "Erro ao obter fonte de eventos";
310
+ }
311
+ }
312
+ async EventsDevice({ workSpaceId, startDate, endDate }) {
313
+ try {
314
+ const token = {
315
+ appId: this.appId,
316
+ secretToken: this.appToken,
317
+ workSpaceId: workSpaceId,
318
+ };
319
+ const response = await axios_1.default.get(`${this.apiUrl}/metrics/events/device`, {
320
+ headers: { "app-id": token.appId, "app-secret-token": token.secretToken, "work-space-id": token.workSpaceId },
321
+ params: { startDate, endDate },
322
+ });
323
+ return response.data;
324
+ }
325
+ catch (error) {
326
+ if (error instanceof axios_1.AxiosError) {
327
+ console.log(error.response?.data);
328
+ }
329
+ else {
330
+ console.log(error);
331
+ }
332
+ throw "Erro ao obter dispositivos";
333
+ }
334
+ }
335
+ async EventsPerPage({ workSpaceId, startDate, endDate }) {
336
+ try {
337
+ const token = {
338
+ appId: this.appId,
339
+ secretToken: this.appToken,
340
+ workSpaceId: workSpaceId,
341
+ };
342
+ const response = await axios_1.default.get(`${this.apiUrl}/metrics/events/per-page`, {
343
+ headers: { "app-id": token.appId, "app-secret-token": token.secretToken, "work-space-id": token.workSpaceId },
344
+ params: { startDate, endDate },
345
+ });
346
+ return response.data;
347
+ }
348
+ catch (error) {
349
+ if (error instanceof axios_1.AxiosError) {
350
+ console.log(error.response?.data);
351
+ }
352
+ else {
353
+ console.log(error);
354
+ }
355
+ throw "Erro ao obter eventos por página";
356
+ }
357
+ }
358
+ async EventsPerProject({ workSpaceId, startDate, endDate }) {
359
+ try {
360
+ const token = {
361
+ appId: this.appId,
362
+ secretToken: this.appToken,
363
+ workSpaceId: workSpaceId,
364
+ };
365
+ const response = await axios_1.default.get(`${this.apiUrl}/metrics/events/per-project`, {
366
+ headers: { "app-id": token.appId, "app-secret-token": token.secretToken, "work-space-id": token.workSpaceId },
367
+ params: { startDate, endDate },
368
+ });
369
+ return response.data;
370
+ }
371
+ catch (error) {
372
+ if (error instanceof axios_1.AxiosError) {
373
+ console.log(error.response?.data);
374
+ }
375
+ else {
376
+ console.log(error);
377
+ }
378
+ throw "Erro ao obter eventos por projeto";
379
+ }
380
+ }
381
+ async Summary({ workSpaceId, startDate, endDate }) {
382
+ try {
383
+ const token = {
384
+ appId: this.appId,
385
+ secretToken: this.appToken,
386
+ workSpaceId: workSpaceId,
387
+ };
388
+ const response = await axios_1.default.get(`${this.apiUrl}/metrics/events/summary`, {
389
+ headers: { "app-id": token.appId, "app-secret-token": token.secretToken, "work-space-id": token.workSpaceId },
390
+ params: { startDate, endDate },
391
+ });
392
+ return response.data;
393
+ }
394
+ catch (error) {
395
+ if (error instanceof axios_1.AxiosError) {
396
+ console.log(error.response?.data);
397
+ }
398
+ else {
399
+ console.log(error);
400
+ }
401
+ throw "Erro ao obter resumo de eventos";
402
+ }
403
+ }
266
404
  }
267
405
  exports.PixelSDK = PixelSDK;
@@ -17,6 +17,7 @@ interface CreatePixel {
17
17
  productIds: string[];
18
18
  offerIds: string[];
19
19
  sendIp: SendIp;
20
+ meta?: any;
20
21
  pixelMeta?: {
21
22
  id: string;
22
23
  title?: string;
@@ -190,6 +191,93 @@ export declare namespace IFunilSummaryDTO {
190
191
  }[];
191
192
  };
192
193
  }
194
+ export declare namespace IAccessGraphDTO {
195
+ type Params = {
196
+ workSpaceId: string;
197
+ startDate: Date;
198
+ endDate: Date;
199
+ };
200
+ type Result = {
201
+ graph: {
202
+ visitors: number;
203
+ sessions: number;
204
+ pageViews: number;
205
+ date: string;
206
+ }[];
207
+ percentageEvolutionVisitors: number;
208
+ percentageEvolutionSessions: number;
209
+ percentageEvolutionPageViews: number;
210
+ };
211
+ }
212
+ export declare namespace IEventsSourceDTO {
213
+ type Params = {
214
+ workSpaceId: string;
215
+ startDate: Date;
216
+ endDate: Date;
217
+ };
218
+ type Result = {
219
+ data: Record<string, number>;
220
+ };
221
+ }
222
+ type DayData = {
223
+ os: Record<string, number>;
224
+ browser: Record<string, number>;
225
+ type: Record<string, number>;
226
+ };
227
+ export type IEventsDeviceType = {
228
+ monday: DayData;
229
+ tuesday: DayData;
230
+ wednesday: DayData;
231
+ thursday: DayData;
232
+ friday: DayData;
233
+ saturday: DayData;
234
+ sunday: DayData;
235
+ };
236
+ export declare namespace IEventsDeviceDTO {
237
+ type Params = {
238
+ workSpaceId: string;
239
+ startDate: Date;
240
+ endDate: Date;
241
+ };
242
+ type Result = {
243
+ data: IEventsDeviceType;
244
+ };
245
+ }
246
+ export declare namespace IEventsPerPageDTO {
247
+ type Params = {
248
+ workSpaceId: string;
249
+ startDate: Date;
250
+ endDate: Date;
251
+ };
252
+ type Result = {
253
+ data: Record<string, number>;
254
+ };
255
+ }
256
+ export declare namespace IEventsPerProjectDTO {
257
+ type Params = {
258
+ workSpaceId: string;
259
+ startDate: Date;
260
+ endDate: Date;
261
+ };
262
+ type Result = {
263
+ data: Record<string, number>;
264
+ };
265
+ }
266
+ export declare namespace ISummaryDTO {
267
+ type Params = {
268
+ workSpaceId: string;
269
+ startDate: Date;
270
+ endDate: Date;
271
+ };
272
+ type Result = {
273
+ totalVisitors: number;
274
+ totalSessions: number;
275
+ totalPageViews: number;
276
+ conversionRate: number;
277
+ averageTimeOnPage: number;
278
+ engagementRate: number;
279
+ };
280
+ }
193
281
  export interface IPixelSdk {
194
282
  Create(params: ICreatePixelDTO.Params): Promise<ICreatePixelDTO.Result>;
195
283
  Update(params: IUpdatePixelDTO.Params): Promise<void>;
@@ -199,5 +287,11 @@ export interface IPixelSdk {
199
287
  UpdateOffers(params: IUpdateOffersDTO.Params): Promise<void>;
200
288
  Metrics(params: IMetricsDTO.Params): Promise<IMetricsDTO.Result>;
201
289
  FunilSummary(params: IFunilSummaryDTO.Params): Promise<IFunilSummaryDTO.Result>;
290
+ AccessGraph(params: IAccessGraphDTO.Params): Promise<IAccessGraphDTO.Result>;
291
+ EventsSource(params: IEventsSourceDTO.Params): Promise<IEventsSourceDTO.Result>;
292
+ EventsDevice(params: IEventsDeviceDTO.Params): Promise<IEventsDeviceDTO.Result>;
293
+ EventsPerPage(params: IEventsPerPageDTO.Params): Promise<IEventsPerPageDTO.Result>;
294
+ EventsPerProject(params: IEventsPerProjectDTO.Params): Promise<IEventsPerProjectDTO.Result>;
295
+ Summary(params: ISummaryDTO.Params): Promise<ISummaryDTO.Result>;
202
296
  }
203
297
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenus-io/pixel-backend-sdk",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "description": "SDK para envio de vendas para fila AWS SQS do micro-serviço de pixels",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",