@reservamos/browser-analytics 1.1.3 → 1.1.5-alpha.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/CHANGELOG.md +4 -0
- package/README.md +15 -0
- package/dist/browser-analytics.cjs +1 -1
- package/dist/browser-analytics.cjs.map +1 -1
- package/dist/browser-analytics.d.ts +22 -0
- package/dist/browser-analytics.esm.js +28 -16
- 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 +5 -1
- package/src/events/purchaseConfirmation/index.ts +7 -0
- package/src/events/purchaseConfirmation/purchaseConfirmation.test.ts +102 -0
- package/src/events/purchaseConfirmation/purchaseConfirmationSchema.ts +15 -0
- package/src/events/purchaseConfirmation/trackPurchaseConfirmation.ts +19 -0
- package/src/index.ts +4 -0
- package/src/services/validator/validator.ts +2 -0
|
@@ -813,6 +813,27 @@ declare const purchaseCanceledSchema: z.ZodObject<{
|
|
|
813
813
|
}>;
|
|
814
814
|
export type PurchaseCanceledProps = z.infer<typeof purchaseCanceledSchema>;
|
|
815
815
|
declare function trackPurchaseCanceled(eventData: PurchaseCanceledProps, meta?: EventData): void;
|
|
816
|
+
declare const purchaseConfirmationSchema: z.ZodObject<{
|
|
817
|
+
order_number: z.ZodString;
|
|
818
|
+
payment_status: z.ZodEnum<[
|
|
819
|
+
"confirmed",
|
|
820
|
+
"pending_pix"
|
|
821
|
+
]>;
|
|
822
|
+
payment_type: z.ZodOptional<z.ZodString>;
|
|
823
|
+
total: z.ZodOptional<z.ZodNumber>;
|
|
824
|
+
}, "strict", z.ZodTypeAny, {
|
|
825
|
+
order_number: string;
|
|
826
|
+
payment_status: "confirmed" | "pending_pix";
|
|
827
|
+
total?: number | undefined;
|
|
828
|
+
payment_type?: string | undefined;
|
|
829
|
+
}, {
|
|
830
|
+
order_number: string;
|
|
831
|
+
payment_status: "confirmed" | "pending_pix";
|
|
832
|
+
total?: number | undefined;
|
|
833
|
+
payment_type?: string | undefined;
|
|
834
|
+
}>;
|
|
835
|
+
export type PurchaseConfirmationProps = z.infer<typeof purchaseConfirmationSchema>;
|
|
836
|
+
declare function trackPurchaseConfirmation(eventData: PurchaseConfirmationProps, meta?: EventMetadata): void;
|
|
816
837
|
declare const searchSchema: z.ZodObject<{
|
|
817
838
|
Departure: z.ZodEffects<z.ZodString, string, string>;
|
|
818
839
|
"Departure Delta": z.ZodNumber;
|
|
@@ -1306,6 +1327,7 @@ declare const analytics: {
|
|
|
1306
1327
|
customEvent: typeof trackCustomEvent;
|
|
1307
1328
|
purchaseCanceled: typeof trackPurchaseCanceled;
|
|
1308
1329
|
geolocationSelected: typeof trackGeolocationSelected;
|
|
1330
|
+
purchaseConfirmation: typeof trackPurchaseConfirmation;
|
|
1309
1331
|
};
|
|
1310
1332
|
};
|
|
1311
1333
|
|
|
@@ -13407,7 +13407,7 @@ function loadNoop(_src, onload) {
|
|
|
13407
13407
|
onload();
|
|
13408
13408
|
}
|
|
13409
13409
|
var mixpanel = init_as_module(loadNoop);
|
|
13410
|
-
const version = "1.1.
|
|
13410
|
+
const version = "1.1.5-alpha.0";
|
|
13411
13411
|
const MIXPANEL_DISTINCT_ID_CACHE_KEY = "mp_distinct_id";
|
|
13412
13412
|
const EVENT_SOURCE_SUPER_PROPERTY = {
|
|
13413
13413
|
"Event Source": "sdk"
|
|
@@ -13478,9 +13478,9 @@ const geolocationSelectedSchema = z.object({
|
|
|
13478
13478
|
"Selected City": z.string().min(1, "Selected city is required"),
|
|
13479
13479
|
"Selected Country Code": z.string().min(1, "Selected Country Code is required")
|
|
13480
13480
|
});
|
|
13481
|
-
const EVENT_NAME$
|
|
13481
|
+
const EVENT_NAME$b = "Geolocation Selected";
|
|
13482
13482
|
function trackGeolocationSelected(eventData, meta = {}) {
|
|
13483
|
-
trackEvent(EVENT_NAME$
|
|
13483
|
+
trackEvent(EVENT_NAME$b, eventData, meta);
|
|
13484
13484
|
mixpanelService.setPeopleProperties(eventData);
|
|
13485
13485
|
}
|
|
13486
13486
|
const IdentifySchema = z.object({
|
|
@@ -13496,9 +13496,9 @@ const productValidation = z.enum(PRODUCT_TYPES).refine((val) => PRODUCT_TYPES.in
|
|
|
13496
13496
|
const interestInHomeSchema = z.object({
|
|
13497
13497
|
product: productValidation
|
|
13498
13498
|
});
|
|
13499
|
-
const EVENT_NAME$
|
|
13499
|
+
const EVENT_NAME$a = "Interest In Home";
|
|
13500
13500
|
function trackInterestInHome(eventData, meta = {}) {
|
|
13501
|
-
trackEvent(EVENT_NAME$
|
|
13501
|
+
trackEvent(EVENT_NAME$a, eventData, meta);
|
|
13502
13502
|
}
|
|
13503
13503
|
const dateValidation = (val) => {
|
|
13504
13504
|
const dateRegex2 = /^\d{4}-\d{2}-\d{2}$/;
|
|
@@ -13545,9 +13545,9 @@ const interestInSearchSchema = z.object({
|
|
|
13545
13545
|
"Departure Date": stringField("Departure Date").optional(),
|
|
13546
13546
|
"product": productValidation
|
|
13547
13547
|
});
|
|
13548
|
-
const EVENT_NAME$
|
|
13548
|
+
const EVENT_NAME$9 = "Interest In Search";
|
|
13549
13549
|
function trackInterestInSearch(eventData, meta = {}) {
|
|
13550
|
-
trackEvent(EVENT_NAME$
|
|
13550
|
+
trackEvent(EVENT_NAME$9, eventData, meta);
|
|
13551
13551
|
}
|
|
13552
13552
|
const passengerSchema = z.object({
|
|
13553
13553
|
"Passenger Birthdate": dateField("Passenger Birthdate"),
|
|
@@ -13596,9 +13596,9 @@ const passengersCreatedSchema = z.object({
|
|
|
13596
13596
|
"product": productValidation,
|
|
13597
13597
|
"Passengers": arrayField(passengerSchema, "Passengers", 1).optional()
|
|
13598
13598
|
}).strict();
|
|
13599
|
-
const EVENT_NAME$
|
|
13599
|
+
const EVENT_NAME$8 = "Passengers Created";
|
|
13600
13600
|
function trackPassengersCreated(eventProps, meta = {}) {
|
|
13601
|
-
trackEvent(EVENT_NAME$
|
|
13601
|
+
trackEvent(EVENT_NAME$8, eventProps, meta);
|
|
13602
13602
|
}
|
|
13603
13603
|
const paymentAttemptSchema = z.object({
|
|
13604
13604
|
"Operation Id": stringField("Operation Id").optional(),
|
|
@@ -13613,9 +13613,9 @@ const paymentAttemptSchema = z.object({
|
|
|
13613
13613
|
"Coupon": stringField("Coupon").optional(),
|
|
13614
13614
|
"User Status": stringField("User Status").optional()
|
|
13615
13615
|
}).strict();
|
|
13616
|
-
const EVENT_NAME$
|
|
13616
|
+
const EVENT_NAME$7 = "Payment Attempt";
|
|
13617
13617
|
const trackPaymentAttempt = async (eventProps, meta = {}) => {
|
|
13618
|
-
trackEvent(EVENT_NAME$
|
|
13618
|
+
trackEvent(EVENT_NAME$7, eventProps, meta);
|
|
13619
13619
|
};
|
|
13620
13620
|
const pickedDepartureSchema = z.object({
|
|
13621
13621
|
"Arrival": z.string().refine(dateValidation, {
|
|
@@ -13641,9 +13641,9 @@ const pickedDepartureSchema = z.object({
|
|
|
13641
13641
|
"Trip Type": z.string().min(1, "Trip Type is required"),
|
|
13642
13642
|
"Bus Type": z.string().min(1, "Bus Type is required")
|
|
13643
13643
|
});
|
|
13644
|
-
const EVENT_NAME$
|
|
13644
|
+
const EVENT_NAME$6 = "Picked Departure";
|
|
13645
13645
|
function trackSearch$1(eventData, meta = {}) {
|
|
13646
|
-
trackEvent(EVENT_NAME$
|
|
13646
|
+
trackEvent(EVENT_NAME$6, eventData, meta);
|
|
13647
13647
|
}
|
|
13648
13648
|
const purchaseAttemptSchema = z.object({
|
|
13649
13649
|
"Operation Id": stringField("Operation Id").optional(),
|
|
@@ -13654,8 +13654,18 @@ const purchaseAttemptSchema = z.object({
|
|
|
13654
13654
|
"product": productValidation,
|
|
13655
13655
|
"Passengers": arrayField(passengerSchema, "Passengers", 1).optional()
|
|
13656
13656
|
}).strict();
|
|
13657
|
-
const EVENT_NAME$
|
|
13657
|
+
const EVENT_NAME$5 = "Purchase Attempt";
|
|
13658
13658
|
function trackPurchaseAttempt(eventData, meta = {}) {
|
|
13659
|
+
trackEvent(EVENT_NAME$5, eventData, meta);
|
|
13660
|
+
}
|
|
13661
|
+
const purchaseConfirmationSchema = z.object({
|
|
13662
|
+
order_number: z.string().min(1, "order_number is required"),
|
|
13663
|
+
payment_status: z.enum(["confirmed", "pending_pix"]),
|
|
13664
|
+
payment_type: z.string().optional(),
|
|
13665
|
+
total: z.number().optional()
|
|
13666
|
+
}).strict();
|
|
13667
|
+
const EVENT_NAME$4 = "Purchase Confirmation Viewed";
|
|
13668
|
+
function trackPurchaseConfirmation(eventData, meta = {}) {
|
|
13659
13669
|
trackEvent(EVENT_NAME$4, eventData, meta);
|
|
13660
13670
|
}
|
|
13661
13671
|
const searchSchema = z.object({
|
|
@@ -13798,7 +13808,8 @@ const eventSchemas = {
|
|
|
13798
13808
|
"View Results": viewResultsSchema,
|
|
13799
13809
|
"Purchase Attempt": purchaseAttemptSchema,
|
|
13800
13810
|
"Picked Departure": pickedDepartureSchema,
|
|
13801
|
-
"Geolocation Selected": geolocationSelectedSchema
|
|
13811
|
+
"Geolocation Selected": geolocationSelectedSchema,
|
|
13812
|
+
"Purchase Confirmation Viewed": purchaseConfirmationSchema
|
|
13802
13813
|
};
|
|
13803
13814
|
function parseEventProps(eventName, eventData) {
|
|
13804
13815
|
const eventSchema = eventSchemas[eventName] || customEventSchema;
|
|
@@ -14569,7 +14580,8 @@ const analytics = {
|
|
|
14569
14580
|
pickedDeparture: trackSearch$1,
|
|
14570
14581
|
customEvent: trackCustomEvent,
|
|
14571
14582
|
purchaseCanceled: trackPurchaseCanceled,
|
|
14572
|
-
geolocationSelected: trackGeolocationSelected
|
|
14583
|
+
geolocationSelected: trackGeolocationSelected,
|
|
14584
|
+
purchaseConfirmation: trackPurchaseConfirmation
|
|
14573
14585
|
}
|
|
14574
14586
|
};
|
|
14575
14587
|
export {
|