@xylabs/pixel 4.13.3 → 4.13.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,168 +1,168 @@
1
- import type { default as Bowser_2 } from 'bowser';
2
- import { EmptyObject } from '@xylabs/object';
3
- import type { JsonObject } from '@xylabs/object';
4
- import type { Promisable } from '@xylabs/promise';
5
-
6
- export declare interface CommonFields {
7
- funnel?: string;
8
- testData?: string;
9
- }
10
-
11
- declare interface ExIds {
12
- fbc?: string;
13
- fbp?: string;
14
- ga?: string;
15
- gclid?: string;
16
- rdt_uid?: string;
17
- scid?: string;
18
- tt_sessionId?: string;
19
- }
20
-
21
- export declare interface FunnelStartedFields extends CommonFields {
22
- name: string;
23
- }
24
-
25
- export declare class PixelApi {
26
- private endPoint;
27
- constructor(baseUri?: string);
28
- trackEvents(events: UserEvent[]): Promise<any>;
29
- }
30
-
31
- export declare interface PurchaseFields extends CommonFields {
32
- id: string;
33
- name?: string;
34
- price?: number;
35
- value?: number;
36
- }
37
-
38
- export declare class Referrer {
39
- private static storageId;
40
- local: string;
41
- session: string;
42
- constructor();
43
- toJson(): {
44
- local: string;
45
- session: string;
46
- } | undefined;
47
- private getFromLocal;
48
- private getFromSession;
49
- }
50
-
51
- export declare interface TestStartedFields extends CommonFields {
52
- name: string;
53
- }
54
-
55
- export declare class UniqueUserId {
56
- private static localStorageId;
57
- id: string;
58
- constructor();
59
- toString(): string;
60
- private generateId;
61
- }
62
-
63
- export declare interface UserClickFields extends CommonFields {
64
- elementName: string;
65
- elementType: string;
66
- intent?: string;
67
- placement?: string;
68
- }
69
-
70
- export declare interface UserEvent {
71
- cid: string;
72
- create_time?: number;
73
- email?: string;
74
- email_hash?: string;
75
- event?: string;
76
- event_id?: string;
77
- exids?: ExIds;
78
- fields?: Record<string, unknown>;
79
- host?: string;
80
- pathname?: string;
81
- pixel?: string;
82
- receive_time?: number;
83
- referrer?: {
84
- local: string;
85
- session: string;
86
- };
87
- rid?: string;
88
- system?: UserEventSystem;
89
- uid?: string;
90
- utm?: Record<string, string>[] | Record<string, string[]>;
91
- }
92
-
93
- export declare abstract class UserEventHandler<TData extends EmptyObject> {
94
- abstract funnelStarted<T extends TData>(fields: T | FunnelStartedFields): Promisable<void>;
95
- abstract testStarted<T extends TData>(fields: T | TestStartedFields): Promisable<void>;
96
- abstract userClick<T extends TData>(fields: T | UserClickFields): Promisable<void>;
97
- abstract viewContent<T extends TData>(fields: T | ViewContentFields): Promisable<void>;
98
- }
99
-
100
- export declare type UserEventSystem = Bowser_2.Parser.ParsedResult;
101
-
102
- export declare class UtmFields {
103
- private static localStorageId;
104
- fields: Record<string, string>[];
105
- constructor();
106
- getUtmRecord: () => Record<string, string> | null;
107
- toString(): string;
108
- update(): Record<string, string>[];
109
- }
110
-
111
- export declare interface ViewContentFields extends CommonFields {
112
- name: string;
113
- path: string;
114
- }
115
-
116
- export declare interface XyLabsTrackingEventJson {
117
- cid: string;
118
- create_time?: number;
119
- email?: string;
120
- email_hash?: string;
121
- event?: string;
122
- event_id?: string;
123
- exids?: Record<string, string>;
124
- fields?: Record<string, unknown>;
125
- host?: string;
126
- ip?: string;
127
- pathname?: string;
128
- pixel?: string;
129
- receive_time?: number;
130
- rid?: string;
131
- system?: unknown;
132
- ua?: string;
133
- uid?: string;
134
- utm?: Record<string, string>[] | Record<string, string[]>;
135
- }
136
-
137
- export declare class XyPixel {
138
- static api: PixelApi;
139
- private static _instance?;
140
- private static utmFieldsObj;
141
- cid: string;
142
- email?: string;
143
- email_hash?: string | null;
144
- exids?: ExIds;
145
- pixelId?: string;
146
- queue: UserEvent[];
147
- private queueMutex;
148
- private constructor();
149
- static get instance(): XyPixel;
150
- static init(pixelId: string): XyPixel;
151
- static selectApi(api: PixelApi): void;
152
- private static utmFields;
153
- identify(email?: string): void;
154
- send<T extends JsonObject>(event: string, fields?: T, eventId?: string): Promise<void>;
155
- private tryFlushQueue;
156
- private updateFbId;
157
- }
158
-
159
- export declare class XyUserEventHandler<T extends EmptyObject = EmptyObject> extends UserEventHandler<T> {
160
- constructor();
161
- funnelStarted(fields: T | FunnelStartedFields): Promise<void>;
162
- purchase(fields: T | PurchaseFields): Promise<void>;
163
- testStarted(fields: T | TestStartedFields): Promise<void>;
164
- userClick(fields: T | UserClickFields): Promise<void>;
165
- viewContent(fields: T | ViewContentFields): Promise<void>;
166
- }
167
-
168
- export { }
1
+ import Bowser from 'bowser';
2
+ import { JsonObject, EmptyObject } from '@xylabs/object';
3
+ import { Promisable } from '@xylabs/promise';
4
+
5
+ interface ExIds {
6
+ fbc?: string;
7
+ fbp?: string;
8
+ ga?: string;
9
+ gclid?: string;
10
+ rdt_uid?: string;
11
+ scid?: string;
12
+ tt_sessionId?: string;
13
+ }
14
+
15
+ type UserEventSystem = Bowser.Parser.ParsedResult;
16
+
17
+ interface UserEvent {
18
+ cid: string;
19
+ create_time?: number;
20
+ email?: string;
21
+ email_hash?: string;
22
+ event?: string;
23
+ event_id?: string;
24
+ exids?: ExIds;
25
+ fields?: Record<string, unknown>;
26
+ host?: string;
27
+ pathname?: string;
28
+ pixel?: string;
29
+ receive_time?: number;
30
+ referrer?: {
31
+ local: string;
32
+ session: string;
33
+ };
34
+ rid?: string;
35
+ system?: UserEventSystem;
36
+ uid?: string;
37
+ utm?: Record<string, string>[] | Record<string, string[]>;
38
+ }
39
+
40
+ declare class PixelApi {
41
+ private endPoint;
42
+ constructor(baseUri?: string);
43
+ trackEvents(events: UserEvent[]): Promise<any>;
44
+ }
45
+
46
+ interface CommonFields {
47
+ funnel?: string;
48
+ testData?: string;
49
+ }
50
+
51
+ interface FunnelStartedFields extends CommonFields {
52
+ name: string;
53
+ }
54
+
55
+ declare class XyPixel {
56
+ static api: PixelApi;
57
+ private static _instance?;
58
+ private static utmFieldsObj;
59
+ cid: string;
60
+ email?: string;
61
+ email_hash?: string | null;
62
+ exids?: ExIds;
63
+ pixelId?: string;
64
+ queue: UserEvent[];
65
+ private queueMutex;
66
+ private constructor();
67
+ static get instance(): XyPixel;
68
+ static init(pixelId: string): XyPixel;
69
+ static selectApi(api: PixelApi): void;
70
+ private static utmFields;
71
+ identify(email?: string): void;
72
+ send<T extends JsonObject>(event: string, fields?: T, eventId?: string): Promise<void>;
73
+ private tryFlushQueue;
74
+ private updateFbId;
75
+ }
76
+
77
+ interface PurchaseFields extends CommonFields {
78
+ id: string;
79
+ name?: string;
80
+ price?: number;
81
+ value?: number;
82
+ }
83
+
84
+ declare class Referrer {
85
+ private static storageId;
86
+ local: string;
87
+ session: string;
88
+ constructor();
89
+ toJson(): {
90
+ local: string;
91
+ session: string;
92
+ } | undefined;
93
+ private getFromLocal;
94
+ private getFromSession;
95
+ }
96
+
97
+ interface TestStartedFields extends CommonFields {
98
+ name: string;
99
+ }
100
+
101
+ declare class UniqueUserId {
102
+ private static localStorageId;
103
+ id: string;
104
+ constructor();
105
+ toString(): string;
106
+ private generateId;
107
+ }
108
+
109
+ interface UserClickFields extends CommonFields {
110
+ elementName: string;
111
+ elementType: string;
112
+ intent?: string;
113
+ placement?: string;
114
+ }
115
+
116
+ interface ViewContentFields extends CommonFields {
117
+ name: string;
118
+ path: string;
119
+ }
120
+
121
+ declare abstract class UserEventHandler<TData extends EmptyObject> {
122
+ abstract funnelStarted<T extends TData>(fields: T | FunnelStartedFields): Promisable<void>;
123
+ abstract testStarted<T extends TData>(fields: T | TestStartedFields): Promisable<void>;
124
+ abstract userClick<T extends TData>(fields: T | UserClickFields): Promisable<void>;
125
+ abstract viewContent<T extends TData>(fields: T | ViewContentFields): Promisable<void>;
126
+ }
127
+
128
+ declare class UtmFields {
129
+ private static localStorageId;
130
+ fields: Record<string, string>[];
131
+ constructor();
132
+ getUtmRecord: () => Record<string, string> | null;
133
+ toString(): string;
134
+ update(): Record<string, string>[];
135
+ }
136
+
137
+ interface XyLabsTrackingEventJson {
138
+ cid: string;
139
+ create_time?: number;
140
+ email?: string;
141
+ email_hash?: string;
142
+ event?: string;
143
+ event_id?: string;
144
+ exids?: Record<string, string>;
145
+ fields?: Record<string, unknown>;
146
+ host?: string;
147
+ ip?: string;
148
+ pathname?: string;
149
+ pixel?: string;
150
+ receive_time?: number;
151
+ rid?: string;
152
+ system?: unknown;
153
+ ua?: string;
154
+ uid?: string;
155
+ utm?: Record<string, string>[] | Record<string, string[]>;
156
+ }
157
+
158
+ declare class XyUserEventHandler<T extends EmptyObject = EmptyObject> extends UserEventHandler<T> {
159
+ constructor();
160
+ funnelStarted(fields: T | FunnelStartedFields): Promise<void>;
161
+ purchase(fields: T | PurchaseFields): Promise<void>;
162
+ testStarted(fields: T | TestStartedFields): Promise<void>;
163
+ userClick(fields: T | UserClickFields): Promise<void>;
164
+ viewContent(fields: T | ViewContentFields): Promise<void>;
165
+ }
166
+
167
+ export { PixelApi, Referrer, UniqueUserId, UserEventHandler, UtmFields, XyPixel, XyUserEventHandler };
168
+ export type { CommonFields, FunnelStartedFields, PurchaseFields, TestStartedFields, UserClickFields, UserEvent, UserEventSystem, ViewContentFields, XyLabsTrackingEventJson };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xylabs/pixel",
3
- "version": "4.13.3",
3
+ "version": "4.13.5",
4
4
  "description": "Event Client for xylabs ESB",
5
5
  "homepage": "https://xylabs.com",
6
6
  "bugs": {
@@ -29,10 +29,10 @@
29
29
  "module": "dist/browser/index.mjs",
30
30
  "types": "dist/browser/index.d.ts",
31
31
  "dependencies": {
32
- "@xylabs/assert": "^4.13.3",
33
- "@xylabs/object": "^4.13.3",
34
- "@xylabs/promise": "^4.13.3",
35
- "@xylabs/typeof": "^4.13.3",
32
+ "@xylabs/assert": "^4.13.5",
33
+ "@xylabs/object": "^4.13.5",
34
+ "@xylabs/promise": "^4.13.5",
35
+ "@xylabs/typeof": "^4.13.5",
36
36
  "async-mutex": "^0.5.0",
37
37
  "axios": "^1.10.0",
38
38
  "bowser": "^2.11.0",
@@ -44,8 +44,8 @@
44
44
  "@types/js-cookie": "^3.0.6",
45
45
  "@types/node": "^24.0.13",
46
46
  "@types/spark-md5": "^3.0.5",
47
- "@xylabs/ts-scripts-yarn3": "^7.0.0-rc.7",
48
- "@xylabs/tsconfig-dom": "^7.0.0-rc.7",
47
+ "@xylabs/ts-scripts-yarn3": "^7.0.0-rc.8",
48
+ "@xylabs/tsconfig-dom": "^7.0.0-rc.8",
49
49
  "axios": "^1.10.0",
50
50
  "typescript": "^5.8.3",
51
51
  "vitest": "^3.2.4"