Skip to content

Commit 96552ef

Browse files
committed
chore: consistent naming
1 parent 1969b2d commit 96552ef

2 files changed

Lines changed: 32 additions & 32 deletions

File tree

src/FormoAnalytics.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ export class FormoAnalytics {
7474
/**
7575
* Track a custom event
7676
*
77-
* @param options - Track options
78-
* @param options.anonymousId - Required. Device/session identifier
79-
* @param options.event - Required. Event name
80-
* @param options.userId - Optional. Your user identifier
81-
* @param options.properties - Optional. Event properties
82-
* @param options.address - Optional. Ethereum wallet address
83-
* @param options.context - Optional. Additional context
77+
* @param event - Track event
78+
* @param event.anonymousId - Required. Device/session identifier
79+
* @param event.event - Required. Event name
80+
* @param event.userId - Optional. Your user identifier
81+
* @param event.properties - Optional. Event properties
82+
* @param event.address - Optional. Ethereum wallet address
83+
* @param event.context - Optional. Additional context
8484
*
8585
* @throws ValidationError if options are invalid
8686
*/
@@ -114,12 +114,12 @@ export class FormoAnalytics {
114114
/**
115115
* Identify a user
116116
*
117-
* @param options - Identify options
118-
* @param options.anonymousId - Required. Device/session identifier
119-
* @param options.userId - Required. Your user identifier
120-
* @param options.traits - Optional. User traits/properties
121-
* @param options.address - Optional. Ethereum wallet address
122-
* @param options.context - Optional. Additional context
117+
* @param event - Identify event
118+
* @param event.anonymousId - Required. Device/session identifier
119+
* @param event.userId - Required. Your user identifier
120+
* @param event.traits - Optional. User traits/properties
121+
* @param event.address - Optional. Ethereum wallet address
122+
* @param event.context - Optional. Additional context
123123
*
124124
* @throws ValidationError if options are invalid
125125
*/

src/validators/validate.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)