@agenus-io/pixel-backend-sdk 1.1.7 → 1.1.9

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, IAccessGraphDTO, IEventsSourceDTO, IEventsDeviceDTO, IEventsPerPageDTO, IEventsPerProjectDTO, ISummaryDTO, ISessionsSummaryDTO, ISessionsGraphDTO, IConversionGraphDTO, IVisitorsGraphDTO, ITrafficDeviceDTO, ITrafficSourceDTO } from './interface';
2
+ import { ICreatePixelDTO, IGetOnePixelDTO, IGetPixelDTO, IDeletePixelDTO, IUpdatePixelDTO, IPixelSdk, IUpdateOffersDTO, IMetricsDTO, IFunilSummaryDTO, IAccessGraphDTO, IEventsSourceDTO, IEventsDeviceDTO, IEventsPerPageDTO, IEventsPerProjectDTO, ISummaryDTO, ISessionsSummaryDTO, ISessionsGraphDTO, IConversionGraphDTO, IVisitorsGraphDTO, ITrafficDeviceDTO, ITrafficSourceDTO, IEventGetDTO } from './interface';
3
3
  /**
4
4
  * Classe responsável por com vendas e pixels
5
5
  */
@@ -42,4 +42,5 @@ export declare class PixelSDK implements IPixelSdk {
42
42
  VisitorsGraph({ workSpaceId, startDate, endDate, pixelId }: IVisitorsGraphDTO.Params): Promise<IVisitorsGraphDTO.Result>;
43
43
  TrafficDevice({ workSpaceId, startDate, endDate, pixelId }: ITrafficDeviceDTO.Params): Promise<ITrafficDeviceDTO.Result>;
44
44
  TrafficSource({ workSpaceId, startDate, endDate, pixelId }: ITrafficSourceDTO.Params): Promise<ITrafficSourceDTO.Result>;
45
+ EventGet({ workSpaceId, startDate, endDate, pixelId, type, category }: IEventGetDTO.Params): Promise<IEventGetDTO.Result>;
45
46
  }
@@ -539,5 +539,28 @@ class PixelSDK {
539
539
  throw "Erro ao obter dispositivos de tráfego";
540
540
  }
541
541
  }
542
+ async EventGet({ workSpaceId, startDate, endDate, pixelId, type, category }) {
543
+ try {
544
+ const token = {
545
+ appId: this.appId,
546
+ secretToken: this.appToken,
547
+ workSpaceId: workSpaceId,
548
+ };
549
+ const response = await axios_1.default.get(`${this.apiUrl}/events`, {
550
+ headers: { "app-id": token.appId, "app-secret-token": token.secretToken, "work-space-id": token.workSpaceId },
551
+ params: { startDate, endDate, pixelId, type, category },
552
+ });
553
+ return response.data;
554
+ }
555
+ catch (error) {
556
+ if (error instanceof axios_1.AxiosError) {
557
+ console.log(error.response?.data);
558
+ }
559
+ else {
560
+ console.log(error);
561
+ }
562
+ throw "Erro ao obter eventos";
563
+ }
564
+ }
542
565
  }
543
566
  exports.PixelSDK = PixelSDK;
@@ -253,14 +253,140 @@ export declare namespace IEventsPerPageDTO {
253
253
  data: Record<string, number>;
254
254
  };
255
255
  }
256
+ export type DeviceOs = {
257
+ name: string;
258
+ version: string;
259
+ };
260
+ export type DeviceEngine = {
261
+ name: string;
262
+ version: string;
263
+ };
264
+ export type DeviceScreen = {
265
+ width: number;
266
+ height: number;
267
+ pixel_ratio: number;
268
+ };
269
+ export type DeviceBrowser = {
270
+ name: string;
271
+ version: string;
272
+ };
273
+ export type EventDevice = {
274
+ id: string;
275
+ os: DeviceOs;
276
+ type: string;
277
+ engine: DeviceEngine;
278
+ screen: DeviceScreen;
279
+ browser: DeviceBrowser;
280
+ language: string;
281
+ userAgent: string;
282
+ };
283
+ export type EventScriptMeta = {
284
+ pageId: string;
285
+ version: string;
286
+ projectId: string;
287
+ script_url: string;
288
+ environment: string;
289
+ pixel_source: string;
290
+ };
291
+ export type BehaviorSnapshot = {
292
+ state: {
293
+ isIdle: boolean;
294
+ isActive: boolean;
295
+ isVisible: boolean;
296
+ };
297
+ pageId: string;
298
+ scroll: {
299
+ maxDepth: number;
300
+ };
301
+ timing: {
302
+ idleTime: number;
303
+ activeTime: number;
304
+ visibleTime: number;
305
+ };
306
+ sessionId: string;
307
+ timestamp: number;
308
+ visitorId: string;
309
+ engagement: {
310
+ level: string;
311
+ score: number;
312
+ };
313
+ interaction: {
314
+ clicks: number;
315
+ keypresses: number;
316
+ mouseMovements: number;
317
+ };
318
+ };
319
+ export type BehaviorCriticalEvent = {
320
+ type: string;
321
+ pageId: string;
322
+ sessionId: string;
323
+ timestamp: number;
324
+ visitorId: string;
325
+ };
326
+ export type BehaviorSummaryData = {
327
+ path: string;
328
+ hostname: string;
329
+ page_url: string;
330
+ sessionId: string;
331
+ timestamp: number;
332
+ visitorId: string;
333
+ behaviorSnapshots: BehaviorSnapshot[];
334
+ behaviorCriticalEvents: BehaviorCriticalEvent[];
335
+ };
336
+ export type UserIdleData = {
337
+ path: string;
338
+ hostname: string;
339
+ page_url: string;
340
+ active_ms: number;
341
+ timestamp: number;
342
+ idle_threshold_ms: number;
343
+ };
344
+ export type EventPayload = BehaviorSummaryData | UserIdleData | Record<string, unknown>;
345
+ export type EventItem = {
346
+ id: string;
347
+ eventId: string;
348
+ sent: boolean;
349
+ errorType: string;
350
+ errorMessage: string | null;
351
+ sessionId: string;
352
+ currency: string | null;
353
+ type: string;
354
+ category: string;
355
+ timestamp: string;
356
+ fingerprint: string;
357
+ ip: string;
358
+ userAgent: string;
359
+ device: EventDevice;
360
+ data: EventPayload;
361
+ meta: EventScriptMeta;
362
+ pixelId: string;
363
+ createdAt: string;
364
+ updatedAt: string;
365
+ visitorId: string;
366
+ utms: unknown;
367
+ utmSource: string | null;
368
+ utmMedium: string | null;
369
+ utmCampaign: string | null;
370
+ utmContent: string | null;
371
+ utmTerm: string | null;
372
+ pageusProjectId: string | null;
373
+ pageusPageId: string | null;
374
+ };
256
375
  export declare namespace IEventsPerProjectDTO {
257
376
  type Params = {
258
377
  workSpaceId: string;
259
378
  startDate: Date;
260
379
  endDate: Date;
261
380
  };
381
+ type PaginationMeta = {
382
+ total: number;
383
+ totalPages: number;
384
+ page: number;
385
+ pageSize: number;
386
+ };
262
387
  type Result = {
263
- data: Record<string, number>;
388
+ data: EventItem[];
389
+ meta: PaginationMeta;
264
390
  };
265
391
  }
266
392
  export declare namespace ISummaryDTO {
@@ -375,6 +501,25 @@ export declare namespace ITrafficSourceDTO {
375
501
  utmSource: string;
376
502
  }[];
377
503
  }
504
+ export declare namespace IEventGetDTO {
505
+ type Params = {
506
+ workSpaceId: string;
507
+ startDate?: Date;
508
+ endDate?: Date;
509
+ pixelId?: string;
510
+ type?: string[];
511
+ category?: string[];
512
+ };
513
+ type Result = {
514
+ data: EventItem[];
515
+ meta: {
516
+ total: number;
517
+ totalPages: number;
518
+ page: number;
519
+ pageSize: number;
520
+ };
521
+ };
522
+ }
378
523
  export interface IPixelSdk {
379
524
  Create(params: ICreatePixelDTO.Params): Promise<ICreatePixelDTO.Result>;
380
525
  Update(params: IUpdatePixelDTO.Params): Promise<void>;
@@ -396,5 +541,6 @@ export interface IPixelSdk {
396
541
  VisitorsGraph(params: IVisitorsGraphDTO.Params): Promise<IVisitorsGraphDTO.Result>;
397
542
  TrafficDevice(params: ITrafficDeviceDTO.Params): Promise<ITrafficDeviceDTO.Result>;
398
543
  TrafficSource(params: ITrafficSourceDTO.Params): Promise<ITrafficSourceDTO.Result>;
544
+ EventGet(params: IEventGetDTO.Params): Promise<IEventGetDTO.Result>;
399
545
  }
400
546
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenus-io/pixel-backend-sdk",
3
- "version": "1.1.7",
3
+ "version": "1.1.9",
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",