@reservamos/browser-analytics 0.2.2 → 0.3.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.
- package/dist/browser-analytics.cjs +1 -1
- package/dist/browser-analytics.cjs.map +1 -1
- package/dist/browser-analytics.d.ts +15 -14
- package/dist/browser-analytics.esm.js +26 -27
- package/dist/browser-analytics.esm.js.map +1 -1
- package/dist/browser-analytics.iife.js +1 -1
- package/dist/browser-analytics.iife.js.map +1 -1
- package/package.json +1 -1
- package/src/events/customEvent/trackCustomEvent.ts +9 -3
- package/src/events/interestInHome/trackInterestInHome.ts +3 -3
- package/src/events/interestInSearch/trackInterestInSearch.ts +3 -3
- package/src/events/passengersCreated/trackPassengersCreated.ts +3 -3
- package/src/events/paymentAttempt/trackPaymentAttempt.ts +6 -2
- package/src/events/pickedDeparture/trackPickedDeparture.ts +3 -3
- package/src/events/purchaseAttempt/trackPurchaseAttempt.ts +3 -3
- package/src/events/search/trackSearch.ts +3 -3
- package/src/events/seatChange/trackSeatChange.ts +3 -3
- package/src/events/viewResults/trackViewResults.ts +3 -3
- package/src/index.ts +6 -3
- package/src/init.ts +6 -3
- package/src/services/validator.ts +1 -1
- package/src/track.ts +7 -3
- package/src/types/eventData.ts +4 -2
- package/src/events/test/index.ts +0 -3
- package/src/events/test/trackTest.ts +0 -12
|
@@ -19,7 +19,8 @@ declare const customEventSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[
|
|
|
19
19
|
export type CustomEventProps = z.infer<typeof customEventSchema>;
|
|
20
20
|
export type AllowedPrimitive = string | boolean | number | undefined;
|
|
21
21
|
export type EventData = Record<string, AllowedPrimitive | AllowedPrimitive[]>;
|
|
22
|
-
|
|
22
|
+
export type EventMetadata = EventData;
|
|
23
|
+
declare function trackCustomEvent(eventName: string, eventData?: EventData, meta?: EventMetadata): void;
|
|
23
24
|
declare const interestInHomeSchema: z.ZodObject<{
|
|
24
25
|
product: z.ZodEffects<z.ZodEnum<[
|
|
25
26
|
"web",
|
|
@@ -34,7 +35,7 @@ declare const interestInHomeSchema: z.ZodObject<{
|
|
|
34
35
|
product: "web" | "web-mobile" | "ios" | "android" | "app";
|
|
35
36
|
}>;
|
|
36
37
|
export type InterestInHomeProps = z.infer<typeof interestInHomeSchema>;
|
|
37
|
-
declare function trackInterestInHome(eventData: InterestInHomeProps, meta?:
|
|
38
|
+
declare function trackInterestInHome(eventData: InterestInHomeProps, meta?: EventMetadata): void;
|
|
38
39
|
declare const interestInSearchSchema: z.ZodObject<{
|
|
39
40
|
product: z.ZodEffects<z.ZodEnum<[
|
|
40
41
|
"web",
|
|
@@ -49,7 +50,7 @@ declare const interestInSearchSchema: z.ZodObject<{
|
|
|
49
50
|
product: "web" | "web-mobile" | "ios" | "android" | "app";
|
|
50
51
|
}>;
|
|
51
52
|
export type InterestInSearchProps = z.infer<typeof interestInSearchSchema>;
|
|
52
|
-
declare function trackInterestInSearch(eventData: InterestInSearchProps, meta?:
|
|
53
|
+
declare function trackInterestInSearch(eventData: InterestInSearchProps, meta?: EventMetadata): void;
|
|
53
54
|
declare const passengersCreatedSchema: z.ZodObject<{
|
|
54
55
|
Trips: z.ZodArray<z.ZodType<{
|
|
55
56
|
"Departure Arrival": string;
|
|
@@ -184,7 +185,7 @@ declare const passengersCreatedSchema: z.ZodObject<{
|
|
|
184
185
|
"Trip Count"?: number | undefined;
|
|
185
186
|
}>;
|
|
186
187
|
export type PassengersCreatedProps = z.infer<typeof passengersCreatedSchema>;
|
|
187
|
-
declare function trackPassengersCreated(eventProps: PassengersCreatedProps, meta?:
|
|
188
|
+
declare function trackPassengersCreated(eventProps: PassengersCreatedProps, meta?: EventMetadata): void;
|
|
188
189
|
declare const paymentAttemptSchema: z.ZodObject<{
|
|
189
190
|
Trips: z.ZodArray<z.ZodType<{
|
|
190
191
|
"Departure Arrival": string;
|
|
@@ -381,7 +382,7 @@ declare const pickedDepartureSchema: z.ZodObject<{
|
|
|
381
382
|
Line?: string | undefined;
|
|
382
383
|
}>;
|
|
383
384
|
export type PickedDepartureProps = z.infer<typeof pickedDepartureSchema>;
|
|
384
|
-
declare function trackSearch(eventData: PickedDepartureProps, meta?:
|
|
385
|
+
declare function trackSearch(eventData: PickedDepartureProps, meta?: EventMetadata): void;
|
|
385
386
|
declare const purchaseAttemptSchema: z.ZodObject<{
|
|
386
387
|
Trips: z.ZodArray<z.ZodType<{
|
|
387
388
|
"Departure Arrival": string;
|
|
@@ -516,7 +517,7 @@ declare const purchaseAttemptSchema: z.ZodObject<{
|
|
|
516
517
|
Total: number;
|
|
517
518
|
}>;
|
|
518
519
|
export type PurchaseAttemptProps = z.infer<typeof purchaseAttemptSchema>;
|
|
519
|
-
declare function trackPurchaseAttempt(eventData: PurchaseAttemptProps, meta?:
|
|
520
|
+
declare function trackPurchaseAttempt(eventData: PurchaseAttemptProps, meta?: EventMetadata): void;
|
|
520
521
|
declare const searchSchema: z.ZodObject<{
|
|
521
522
|
Departure: z.ZodEffects<z.ZodString, string, string>;
|
|
522
523
|
"Departure Delta": z.ZodNumber;
|
|
@@ -561,7 +562,7 @@ declare const searchSchema: z.ZodObject<{
|
|
|
561
562
|
"Trip Length"?: number | undefined;
|
|
562
563
|
}>;
|
|
563
564
|
export type SearchProps = z.infer<typeof searchSchema>;
|
|
564
|
-
declare function trackSearch$1(eventData: SearchProps, meta?:
|
|
565
|
+
declare function trackSearch$1(eventData: SearchProps, meta?: EventMetadata): void;
|
|
565
566
|
declare const seatChangeSchema: z.ZodObject<{
|
|
566
567
|
Arrival: z.ZodEffects<z.ZodString, string, string>;
|
|
567
568
|
Departure: z.ZodEffects<z.ZodString, string, string>;
|
|
@@ -618,7 +619,7 @@ declare const seatChangeSchema: z.ZodObject<{
|
|
|
618
619
|
Stops?: number | undefined;
|
|
619
620
|
}>;
|
|
620
621
|
export type SeatChangeProps = z.infer<typeof seatChangeSchema>;
|
|
621
|
-
declare function trackSeatChange(eventProps: SeatChangeProps, meta?:
|
|
622
|
+
declare function trackSeatChange(eventProps: SeatChangeProps, meta?: EventMetadata): void;
|
|
622
623
|
declare const viewResultsSchema: z.ZodObject<{
|
|
623
624
|
"Bus count": z.ZodNumber;
|
|
624
625
|
Departure: z.ZodEffects<z.ZodString, string, string>;
|
|
@@ -660,7 +661,7 @@ declare const viewResultsSchema: z.ZodObject<{
|
|
|
660
661
|
"Has Frequent Buses"?: boolean | undefined;
|
|
661
662
|
}>;
|
|
662
663
|
export type ViewResultsProps = z.infer<typeof viewResultsSchema>;
|
|
663
|
-
declare function trackViewResults(eventData: ViewResultsProps, meta?:
|
|
664
|
+
declare function trackViewResults(eventData: ViewResultsProps, meta?: EventMetadata): void;
|
|
664
665
|
declare const CreateAnonymousProfileSchema: z.ZodEffects<z.ZodObject<{
|
|
665
666
|
email: z.ZodOptional<z.ZodString>;
|
|
666
667
|
phone: z.ZodOptional<z.ZodString>;
|
|
@@ -699,7 +700,6 @@ export type DefaultProperties = z.infer<typeof IdentifySchema>;
|
|
|
699
700
|
export interface UserProperties extends DefaultProperties, Record<string, string | number | boolean | undefined> {
|
|
700
701
|
}
|
|
701
702
|
declare function identify(userId: string, properties?: UserProperties): Promise<void>;
|
|
702
|
-
declare function trackTest(): void;
|
|
703
703
|
declare const InitConfigSchema: z.ZodObject<{
|
|
704
704
|
/**
|
|
705
705
|
* The Mixpanel token used for authenticating API requests.
|
|
@@ -718,7 +718,7 @@ declare const InitConfigSchema: z.ZodObject<{
|
|
|
718
718
|
* Optional flag to determine if the sandbox environment should be used.
|
|
719
719
|
* When set to true, the sandbox environment will be used; otherwise, the production environment will be used.
|
|
720
720
|
*/
|
|
721
|
-
isSandbox: z.
|
|
721
|
+
isSandbox: z.ZodOptional<z.ZodBoolean>;
|
|
722
722
|
/**
|
|
723
723
|
* Optional proxy URL for Mixpanel requests.
|
|
724
724
|
*/
|
|
@@ -730,8 +730,8 @@ declare const InitConfigSchema: z.ZodObject<{
|
|
|
730
730
|
}, "strip", z.ZodTypeAny, {
|
|
731
731
|
mixpanelToken: string;
|
|
732
732
|
identificationKey: string;
|
|
733
|
-
isSandbox: boolean;
|
|
734
733
|
debug?: boolean | undefined;
|
|
734
|
+
isSandbox?: boolean | undefined;
|
|
735
735
|
mixpanelProxyUrl?: string | undefined;
|
|
736
736
|
identifyProxyUrl?: string | undefined;
|
|
737
737
|
}, {
|
|
@@ -747,8 +747,10 @@ declare const InitConfigSchema: z.ZodObject<{
|
|
|
747
747
|
*/
|
|
748
748
|
export type InitConfig = z.infer<typeof InitConfigSchema>;
|
|
749
749
|
declare function init(config: InitConfig): Promise<void>;
|
|
750
|
+
declare function isTrackerReady(): boolean;
|
|
750
751
|
declare const analytics: {
|
|
751
752
|
init: typeof init;
|
|
753
|
+
isReady: typeof isTrackerReady;
|
|
752
754
|
identify: typeof identify;
|
|
753
755
|
identifiers: {
|
|
754
756
|
getFingerprintId: () => string | null;
|
|
@@ -758,14 +760,13 @@ declare const analytics: {
|
|
|
758
760
|
createAnonymousProfile: typeof createAnonymousProfile;
|
|
759
761
|
};
|
|
760
762
|
track: {
|
|
761
|
-
test: typeof trackTest;
|
|
762
763
|
search: typeof trackSearch$1;
|
|
763
764
|
seatChange: typeof trackSeatChange;
|
|
764
765
|
interestInHome: typeof trackInterestInHome;
|
|
765
766
|
interestInSearch: typeof trackInterestInSearch;
|
|
766
767
|
viewResults: typeof trackViewResults;
|
|
767
768
|
passengersCreated: typeof trackPassengersCreated;
|
|
768
|
-
paymentAttempt: (eventProps: PaymentAttemptProps) => Promise<void>;
|
|
769
|
+
paymentAttempt: (eventProps: PaymentAttemptProps, meta?: EventMetadata) => Promise<void>;
|
|
769
770
|
purchaseAttempt: typeof trackPurchaseAttempt;
|
|
770
771
|
pickedDeparture: typeof trackSearch;
|
|
771
772
|
customEvent: typeof trackCustomEvent;
|
|
@@ -13080,16 +13080,16 @@ const productValidation = z.enum(PRODUCT_TYPES).refine((val) => PRODUCT_TYPES.in
|
|
|
13080
13080
|
const interestInHomeSchema = z.object({
|
|
13081
13081
|
product: productValidation
|
|
13082
13082
|
});
|
|
13083
|
-
const EVENT_NAME$
|
|
13083
|
+
const EVENT_NAME$8 = "Interest In Home";
|
|
13084
13084
|
function trackInterestInHome(eventData, meta = {}) {
|
|
13085
|
-
trackEvent(EVENT_NAME$
|
|
13085
|
+
trackEvent(EVENT_NAME$8, eventData, meta);
|
|
13086
13086
|
}
|
|
13087
13087
|
const interestInSearchSchema = z.object({
|
|
13088
13088
|
product: productValidation
|
|
13089
13089
|
});
|
|
13090
|
-
const EVENT_NAME$
|
|
13090
|
+
const EVENT_NAME$7 = "Interest In Search";
|
|
13091
13091
|
function trackInterestInSearch(eventData, meta = {}) {
|
|
13092
|
-
trackEvent(EVENT_NAME$
|
|
13092
|
+
trackEvent(EVENT_NAME$7, eventData, meta);
|
|
13093
13093
|
}
|
|
13094
13094
|
const dateValidation = (val) => {
|
|
13095
13095
|
const dateRegex2 = /^\d{4}-\d{2}-\d{2}$/;
|
|
@@ -13163,9 +13163,9 @@ const passengersCreatedSchema = z.object({
|
|
|
13163
13163
|
"Total": numberField("Total"),
|
|
13164
13164
|
"product": productValidation
|
|
13165
13165
|
}).strict();
|
|
13166
|
-
const EVENT_NAME$
|
|
13166
|
+
const EVENT_NAME$6 = "Passengers Created";
|
|
13167
13167
|
function trackPassengersCreated(eventProps, meta = {}) {
|
|
13168
|
-
trackEvent(EVENT_NAME$
|
|
13168
|
+
trackEvent(EVENT_NAME$6, eventProps, meta);
|
|
13169
13169
|
}
|
|
13170
13170
|
const paymentAttemptSchema = z.object({
|
|
13171
13171
|
"Trips": arrayField(tripSchema, "Trips", 1),
|
|
@@ -13175,9 +13175,9 @@ const paymentAttemptSchema = z.object({
|
|
|
13175
13175
|
"Total": numberField("Total"),
|
|
13176
13176
|
"product": productValidation
|
|
13177
13177
|
}).strict();
|
|
13178
|
-
const EVENT_NAME$
|
|
13179
|
-
const trackPaymentAttempt = async (eventProps) => {
|
|
13180
|
-
trackEvent(EVENT_NAME$
|
|
13178
|
+
const EVENT_NAME$5 = "Payment Attempt";
|
|
13179
|
+
const trackPaymentAttempt = async (eventProps, meta = {}) => {
|
|
13180
|
+
trackEvent(EVENT_NAME$5, eventProps, meta);
|
|
13181
13181
|
};
|
|
13182
13182
|
const pickedDepartureSchema = z.object({
|
|
13183
13183
|
"Arrival": z.string().refine(dateValidation, {
|
|
@@ -13201,9 +13201,9 @@ const pickedDepartureSchema = z.object({
|
|
|
13201
13201
|
"Recommended Trip": z.boolean(),
|
|
13202
13202
|
"Recommended Trip Type": z.string().optional()
|
|
13203
13203
|
});
|
|
13204
|
-
const EVENT_NAME$
|
|
13204
|
+
const EVENT_NAME$4 = "Picked Departure";
|
|
13205
13205
|
function trackSearch$1(eventData, meta = {}) {
|
|
13206
|
-
trackEvent(EVENT_NAME$
|
|
13206
|
+
trackEvent(EVENT_NAME$4, eventData, meta);
|
|
13207
13207
|
}
|
|
13208
13208
|
const purchaseAttemptSchema = z.object({
|
|
13209
13209
|
"Trips": arrayField(tripSchema, "Trips", 1),
|
|
@@ -13212,9 +13212,9 @@ const purchaseAttemptSchema = z.object({
|
|
|
13212
13212
|
"Total": numberField("Total"),
|
|
13213
13213
|
"product": productValidation
|
|
13214
13214
|
}).strict();
|
|
13215
|
-
const EVENT_NAME$
|
|
13215
|
+
const EVENT_NAME$3 = "Purchase Attempt";
|
|
13216
13216
|
function trackPurchaseAttempt(eventData, meta = {}) {
|
|
13217
|
-
trackEvent(EVENT_NAME$
|
|
13217
|
+
trackEvent(EVENT_NAME$3, eventData, meta);
|
|
13218
13218
|
}
|
|
13219
13219
|
const searchSchema = z.object({
|
|
13220
13220
|
"Departure": z.string().refine(dateValidation, {
|
|
@@ -13233,9 +13233,9 @@ const searchSchema = z.object({
|
|
|
13233
13233
|
"Trip Length": z.number().positive().optional(),
|
|
13234
13234
|
"product": productValidation
|
|
13235
13235
|
});
|
|
13236
|
-
const EVENT_NAME$
|
|
13236
|
+
const EVENT_NAME$2 = "Search";
|
|
13237
13237
|
function trackSearch(eventData, meta = {}) {
|
|
13238
|
-
trackEvent(EVENT_NAME$
|
|
13238
|
+
trackEvent(EVENT_NAME$2, eventData, meta);
|
|
13239
13239
|
}
|
|
13240
13240
|
const seatChangeSchema = z.object({
|
|
13241
13241
|
"Arrival": z.string().refine(dateValidation, {
|
|
@@ -13259,13 +13259,13 @@ const seatChangeSchema = z.object({
|
|
|
13259
13259
|
}),
|
|
13260
13260
|
"product": productValidation
|
|
13261
13261
|
});
|
|
13262
|
-
const EVENT_NAME$
|
|
13262
|
+
const EVENT_NAME$1 = "Seat Change";
|
|
13263
13263
|
function trackSeatChange(eventProps, meta = {}) {
|
|
13264
|
-
trackEvent(EVENT_NAME$
|
|
13264
|
+
trackEvent(EVENT_NAME$1, eventProps, meta);
|
|
13265
13265
|
}
|
|
13266
|
-
const EVENT_NAME
|
|
13266
|
+
const EVENT_NAME = "View Results";
|
|
13267
13267
|
function trackViewResults(eventData, meta = {}) {
|
|
13268
|
-
trackEvent(EVENT_NAME
|
|
13268
|
+
trackEvent(EVENT_NAME, eventData, meta);
|
|
13269
13269
|
}
|
|
13270
13270
|
const viewResultsSchema = z.object({
|
|
13271
13271
|
"Bus count": z.number().int("Bus count must be an integer"),
|
|
@@ -13300,7 +13300,7 @@ const InitConfigSchema = z.object({
|
|
|
13300
13300
|
* Optional flag to determine if the sandbox environment should be used.
|
|
13301
13301
|
* When set to true, the sandbox environment will be used; otherwise, the production environment will be used.
|
|
13302
13302
|
*/
|
|
13303
|
-
isSandbox: z.boolean().optional()
|
|
13303
|
+
isSandbox: z.boolean().optional(),
|
|
13304
13304
|
/**
|
|
13305
13305
|
* Optional proxy URL for Mixpanel requests.
|
|
13306
13306
|
*/
|
|
@@ -13435,10 +13435,10 @@ async function trackEvent(eventName, eventProperties, meta = {}) {
|
|
|
13435
13435
|
console.error(`Error tracking event '${eventName}':`, error);
|
|
13436
13436
|
}
|
|
13437
13437
|
}
|
|
13438
|
-
function trackCustomEvent(eventName, eventData = {}) {
|
|
13438
|
+
function trackCustomEvent(eventName, eventData = {}, meta = {}) {
|
|
13439
13439
|
try {
|
|
13440
13440
|
eventNameSchema.parse(eventName);
|
|
13441
|
-
trackEvent(eventName, eventData);
|
|
13441
|
+
trackEvent(eventName, eventData, meta);
|
|
13442
13442
|
} catch (error) {
|
|
13443
13443
|
console.error("Error trackCustomEvent:", error);
|
|
13444
13444
|
return;
|
|
@@ -15996,10 +15996,6 @@ async function identify(userId, properties = {}) {
|
|
|
15996
15996
|
});
|
|
15997
15997
|
}
|
|
15998
15998
|
}
|
|
15999
|
-
const EVENT_NAME = "Track Test";
|
|
16000
|
-
function trackTest() {
|
|
16001
|
-
trackEvent(EVENT_NAME, {});
|
|
16002
|
-
}
|
|
16003
15999
|
const origin = window.location.origin;
|
|
16004
16000
|
const coreAPIConfig = {
|
|
16005
16001
|
sandbox: {
|
|
@@ -16047,8 +16043,12 @@ async function init(config) {
|
|
|
16047
16043
|
jsApiClientExports.setConfig(apiConfig);
|
|
16048
16044
|
onLoaded();
|
|
16049
16045
|
}
|
|
16046
|
+
function isTrackerReady() {
|
|
16047
|
+
return mixpanelService.isReady();
|
|
16048
|
+
}
|
|
16050
16049
|
const analytics = {
|
|
16051
16050
|
init,
|
|
16051
|
+
isReady: isTrackerReady,
|
|
16052
16052
|
identify,
|
|
16053
16053
|
identifiers: {
|
|
16054
16054
|
getFingerprintId: fingerprintService.getCachedFingerprint,
|
|
@@ -16058,7 +16058,6 @@ const analytics = {
|
|
|
16058
16058
|
createAnonymousProfile
|
|
16059
16059
|
},
|
|
16060
16060
|
track: {
|
|
16061
|
-
test: trackTest,
|
|
16062
16061
|
search: trackSearch,
|
|
16063
16062
|
seatChange: trackSeatChange,
|
|
16064
16063
|
interestInHome: trackInterestInHome,
|