@@ -25,49 +25,49 @@ export class ValidationError extends Error {
2525}
2626
2727/**
28- * Validates options for track() method
28+ * Validates event for track() method
2929 *
30- * @param options - The track options to validate
30+ * @param event - The track event to validate
3131 * @throws ValidationError if any field is invalid
3232 *
3333 * @example
34- * validateTrackOptions ({
34+ * validateTrackEvent ({
3535 * anonymousId: "device-123",
3636 * event: "Button Clicked",
3737 * properties: { buttonId: "cta" }
3838 * });
3939 */
40- export function validateTrackEvent ( options : TrackAPIEvent ) : void {
40+ export function validateTrackEvent ( event : TrackAPIEvent ) : void {
4141 // Required: anonymousId must be a non-empty string
42- if ( ! isNonEmptyString ( options . anonymousId ) ) {
42+ if ( ! isNonEmptyString ( event . anonymousId ) ) {
4343 throw new ValidationError ( "anonymousId" , "must be a non-empty string" ) ;
4444 }
4545
4646 // Required: event must be a non-empty string
47- if ( ! isNonEmptyString ( options . event ) ) {
47+ if ( ! isNonEmptyString ( event . event ) ) {
4848 throw new ValidationError ( "event" , "must be a non-empty string" ) ;
4949 }
5050
5151 // Optional: userId must be a non-empty string if provided
52- if ( ! isNullOrUndefined ( options . userId ) && ! isNonEmptyString ( options . userId ) ) {
52+ if ( ! isNullOrUndefined ( event . userId ) && ! isNonEmptyString ( event . userId ) ) {
5353 throw new ValidationError (
5454 "userId" ,
5555 "must be a non-empty string if provided"
5656 ) ;
5757 }
5858
5959 // Optional: properties must be an object if provided
60- if ( ! isNullOrUndefined ( options . properties ) && ! isObject ( options . properties ) ) {
60+ if ( ! isNullOrUndefined ( event . properties ) && ! isObject ( event . properties ) ) {
6161 throw new ValidationError ( "properties" , "must be an object if provided" ) ;
6262 }
6363
6464 // Optional: context must be an object if provided
65- if ( ! isNullOrUndefined ( options . context ) && ! isObject ( options . context ) ) {
65+ if ( ! isNullOrUndefined ( event . context ) && ! isObject ( event . context ) ) {
6666 throw new ValidationError ( "context" , "must be an object if provided" ) ;
6767 }
6868
6969 // Optional: address must be a valid Ethereum address if provided
70- if ( ! isNullOrUndefined ( options . address ) && ! isAddress ( options . address ) ) {
70+ if ( ! isNullOrUndefined ( event . address ) && ! isAddress ( event . address ) ) {
7171 throw new ValidationError (
7272 "address" ,
7373 "must be a valid Ethereum address (0x followed by 40 hex characters)"
@@ -76,41 +76,41 @@ export function validateTrackEvent(options: TrackAPIEvent): void {
7676}
7777
7878/**
79- * Validates options for identify() method
79+ * Validates event for identify() method
8080 *
81- * @param options - The identify options to validate
81+ * @param event - The identify event to validate
8282 * @throws ValidationError if any field is invalid
8383 *
8484 * @example
85- * validateIdentifyOptions ({
85+ * validateIdentifyEvent ({
8686 * anonymousId: "device-123",
8787 * userId: "user-456",
8888 * traits: { email: "user@example .com" }
8989 * });
9090 */
91- export function validateIdentifyEvent ( options : IdentifyAPIEvent ) : void {
91+ export function validateIdentifyEvent ( event : IdentifyAPIEvent ) : void {
9292 // Required: anonymousId must be a non-empty string
93- if ( ! isNonEmptyString ( options . anonymousId ) ) {
93+ if ( ! isNonEmptyString ( event . anonymousId ) ) {
9494 throw new ValidationError ( "anonymousId" , "must be a non-empty string" ) ;
9595 }
9696
9797 // Required: userId must be a non-empty string
98- if ( ! isNonEmptyString ( options . userId ) ) {
98+ if ( ! isNonEmptyString ( event . userId ) ) {
9999 throw new ValidationError ( "userId" , "must be a non-empty string" ) ;
100100 }
101101
102102 // Optional: traits must be an object if provided
103- if ( ! isNullOrUndefined ( options . traits ) && ! isObject ( options . traits ) ) {
103+ if ( ! isNullOrUndefined ( event . traits ) && ! isObject ( event . traits ) ) {
104104 throw new ValidationError ( "traits" , "must be an object if provided" ) ;
105105 }
106106
107107 // Optional: context must be an object if provided
108- if ( ! isNullOrUndefined ( options . context ) && ! isObject ( options . context ) ) {
108+ if ( ! isNullOrUndefined ( event . context ) && ! isObject ( event . context ) ) {
109109 throw new ValidationError ( "context" , "must be an object if provided" ) ;
110110 }
111111
112112 // Optional: address must be a valid Ethereum address if provided
113- if ( ! isNullOrUndefined ( options . address ) && ! isAddress ( options . address ) ) {
113+ if ( ! isNullOrUndefined ( event . address ) && ! isAddress ( event . address ) ) {
114114 throw new ValidationError (
115115 "address" ,
116116 "must be a valid Ethereum address (0x followed by 40 hex characters)"
0 commit comments