@reservamos/browser-analytics 0.3.0 → 0.3.1-alpha.2
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 +3 -3
- package/dist/browser-analytics.cjs.map +1 -1
- package/dist/browser-analytics.d.ts +223 -2
- package/dist/browser-analytics.esm.js +37 -22
- package/dist/browser-analytics.esm.js.map +1 -1
- package/dist/browser-analytics.iife.js +3 -3
- package/dist/browser-analytics.iife.js.map +1 -1
- package/package.json +1 -1
- package/src/events/passengersCreated/passengersCreatedSchema.ts +2 -0
- package/src/events/paymentAttempt/paymentAttemptSchema.ts +9 -1
- package/src/events/purchaseAttempt/purchaseAttemptSchema.ts +9 -1
- package/src/events/purchaseCanceled/index.ts +7 -0
- package/src/events/purchaseCanceled/purchaseCanceledSchema.ts +19 -0
- package/src/events/purchaseCanceled/trackPurchaseCanceled.ts +19 -0
- package/src/events/sharedSchemas/passengerSchema.ts +12 -0
- package/src/index.ts +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { arrayField, intField, numberField } from '@/util/primitiveFields';
|
|
3
3
|
import productValidation from '@/util/productValidation';
|
|
4
|
+
import passengerSchema from '../sharedSchemas/passengerSchema';
|
|
4
5
|
import tripSchema from '../sharedSchemas/tripSchema';
|
|
5
6
|
|
|
6
7
|
const passengersCreatedSchema = z
|
|
@@ -10,6 +11,7 @@ const passengersCreatedSchema = z
|
|
|
10
11
|
'Trip Count': intField('Trip Count').optional(),
|
|
11
12
|
'Total': numberField('Total'),
|
|
12
13
|
'product': productValidation,
|
|
14
|
+
'Passengers': arrayField(passengerSchema, 'Passengers', 1).optional(),
|
|
13
15
|
})
|
|
14
16
|
.strict();
|
|
15
17
|
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
arrayField,
|
|
4
|
+
intField,
|
|
5
|
+
numberField,
|
|
6
|
+
stringField,
|
|
7
|
+
} from '@/util/primitiveFields';
|
|
3
8
|
import productValidation from '@/util/productValidation';
|
|
9
|
+
import passengerSchema from '../sharedSchemas/passengerSchema';
|
|
4
10
|
import tripSchema from '../sharedSchemas/tripSchema';
|
|
5
11
|
|
|
6
12
|
const paymentAttemptSchema = z
|
|
7
13
|
.object({
|
|
14
|
+
'Operation Id': stringField('Operation Id').optional(),
|
|
8
15
|
'Trips': arrayField(tripSchema, 'Trips', 1),
|
|
9
16
|
'Passenger Count': intField('Passenger Count'),
|
|
10
17
|
'Trip Count': intField('Trip Count'),
|
|
11
18
|
'Payment Type': z.string().min(1, 'Payment Type is required'),
|
|
12
19
|
'Total': numberField('Total'),
|
|
13
20
|
'product': productValidation,
|
|
21
|
+
'Passengers': arrayField(passengerSchema, 'Passengers', 1).optional(),
|
|
14
22
|
})
|
|
15
23
|
.strict();
|
|
16
24
|
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
arrayField,
|
|
4
|
+
intField,
|
|
5
|
+
numberField,
|
|
6
|
+
stringField,
|
|
7
|
+
} from '@/util/primitiveFields';
|
|
3
8
|
import productValidation from '@/util/productValidation';
|
|
9
|
+
import passengerSchema from '../sharedSchemas/passengerSchema';
|
|
4
10
|
import tripSchema from '../sharedSchemas/tripSchema';
|
|
5
11
|
|
|
6
12
|
const purchaseAttemptSchema = z
|
|
7
13
|
.object({
|
|
14
|
+
'Operation Id': stringField('Operation Id').optional(),
|
|
8
15
|
'Trips': arrayField(tripSchema, 'Trips', 1),
|
|
9
16
|
'Passenger Count': intField('Passenger Count'),
|
|
10
17
|
'Trip Count': intField('Trip Count'),
|
|
11
18
|
'Total': numberField('Total'),
|
|
12
19
|
'product': productValidation,
|
|
20
|
+
'Passengers': arrayField(passengerSchema, 'Passengers', 1).optional(),
|
|
13
21
|
})
|
|
14
22
|
.strict();
|
|
15
23
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PurchaseCanceledProps } from './purchaseCanceledSchema';
|
|
2
|
+
import purchaseCanceledSchema from './purchaseCanceledSchema';
|
|
3
|
+
import trackPurchaseCanceled from './trackPurchaseCanceled';
|
|
4
|
+
|
|
5
|
+
export type { PurchaseCanceledProps };
|
|
6
|
+
export { purchaseCanceledSchema };
|
|
7
|
+
export default trackPurchaseCanceled;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { arrayField, numberField, stringField } from '@/util/primitiveFields';
|
|
3
|
+
import productValidation from '@/util/productValidation';
|
|
4
|
+
import passengerSchema from '../sharedSchemas/passengerSchema';
|
|
5
|
+
import tripSchema from '../sharedSchemas/tripSchema';
|
|
6
|
+
|
|
7
|
+
const purchaseCanceledSchema = z.object({
|
|
8
|
+
'Operation Id': stringField('Operation Id'),
|
|
9
|
+
'Trips': arrayField(tripSchema, 'Trips', 1).optional(),
|
|
10
|
+
'Passenger Count': numberField('Passenger Count').optional(),
|
|
11
|
+
'Total': numberField('Total').optional(),
|
|
12
|
+
'Trip Count': numberField('Trip Count').optional(),
|
|
13
|
+
'product': productValidation,
|
|
14
|
+
'Passengers': arrayField(passengerSchema, 'Passengers', 1).optional(),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
type PurchaseCanceledProps = z.infer<typeof purchaseCanceledSchema>;
|
|
18
|
+
export type { PurchaseCanceledProps };
|
|
19
|
+
export default purchaseCanceledSchema;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PurchaseCanceledProps } from './purchaseCanceledSchema';
|
|
2
|
+
import { trackEvent } from '@/track';
|
|
3
|
+
import { EventData } from '@/types/eventData';
|
|
4
|
+
|
|
5
|
+
const EVENT_NAME = 'Purchase Canceled';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Tracks a Purchase Canceled event.
|
|
9
|
+
* @param {PurchaseCanceledProps} eventData - The data associated with the Purchase Canceled event.
|
|
10
|
+
* @param {EventData} meta - Additional metadata to include in the event.
|
|
11
|
+
*/
|
|
12
|
+
function trackPurchaseCanceled(
|
|
13
|
+
eventData: PurchaseCanceledProps,
|
|
14
|
+
meta: EventData = {},
|
|
15
|
+
): void {
|
|
16
|
+
trackEvent(EVENT_NAME, eventData, meta);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default trackPurchaseCanceled;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { intField, stringField } from '@/util/primitiveFields';
|
|
3
|
+
|
|
4
|
+
const passengerSchema = z
|
|
5
|
+
.object({
|
|
6
|
+
'Passenger Name': stringField('Passenger Name'),
|
|
7
|
+
'Passenger Document Type': stringField('Document Type'),
|
|
8
|
+
'Passenger Document Id': intField('Document ID'),
|
|
9
|
+
})
|
|
10
|
+
.strict();
|
|
11
|
+
|
|
12
|
+
export default passengerSchema;
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { PassengersCreatedProps } from '@/events/passengersCreated';
|
|
|
5
5
|
import type { PaymentAttemptProps } from '@/events/paymentAttempt';
|
|
6
6
|
import type { PickedDepartureProps } from '@/events/pickedDeparture';
|
|
7
7
|
import type { PurchaseAttemptProps } from '@/events/purchaseAttempt';
|
|
8
|
+
import type { PurchaseCanceledProps } from '@/events/purchaseCanceled';
|
|
8
9
|
import type { SearchProps } from '@/events/search';
|
|
9
10
|
import type { SeatChangeProps } from '@/events/seatChange';
|
|
10
11
|
import type { ViewResultsProps } from '@/events/viewResults';
|
|
@@ -26,6 +27,7 @@ import createAnonymousProfile from '@/profiles/createAnonymousProfile';
|
|
|
26
27
|
import fingerprintService from '@/services/fingerprint';
|
|
27
28
|
import mixpanelService from '@/services/mixpanel';
|
|
28
29
|
import './js-api-client.d.ts';
|
|
30
|
+
import trackPurchaseCanceled from './events/purchaseCanceled/trackPurchaseCanceled.js';
|
|
29
31
|
|
|
30
32
|
const analytics = {
|
|
31
33
|
init,
|
|
@@ -49,6 +51,7 @@ const analytics = {
|
|
|
49
51
|
purchaseAttempt: trackPurchaseAttempt,
|
|
50
52
|
pickedDeparture: trackPickedDeparture,
|
|
51
53
|
customEvent: trackCustomEvent,
|
|
54
|
+
purchaseCanceled: trackPurchaseCanceled,
|
|
52
55
|
},
|
|
53
56
|
};
|
|
54
57
|
|
|
@@ -66,6 +69,7 @@ export type {
|
|
|
66
69
|
CreateAnonymousProfileProps,
|
|
67
70
|
EventMetadata,
|
|
68
71
|
EventData,
|
|
72
|
+
PurchaseCanceledProps,
|
|
69
73
|
};
|
|
70
74
|
|
|
71
75
|
export default analytics;
|