-
Notifications
You must be signed in to change notification settings - Fork 1
P-1925 P-1926 Enhance analytics API with optional parameters and referral config #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
d738ebb
ff8c13a
edeabeb
de6f846
ef1557b
cdf7205
9c5ce9c
4389c28
3af3d57
d0c2623
67b0728
a71b986
57a0d80
75e5fd4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ import { | |
| TransactionStatus, | ||
| } from "./types"; | ||
| import { toChecksumAddress, getValidAddress } from "./utils"; | ||
| import { parseTrafficSource, storeTrafficSource } from "./utils/trafficSource"; | ||
|
|
||
| export class FormoAnalytics implements IFormoAnalytics { | ||
| private session: FormoAnalyticsSession; | ||
|
|
@@ -138,14 +139,15 @@ export class FormoAnalytics implements IFormoAnalytics { | |
| */ | ||
| public async screen( | ||
| name: string, | ||
| category?: string, | ||
| properties?: IFormoEventProperties, | ||
|
Comment on lines
153
to
156
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Adding Useful? React with 👍 / 👎.
Comment on lines
154
to
156
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Changing Useful? React with 👍 / 👎. |
||
| context?: IFormoEventContext, | ||
| callback?: (...args: unknown[]) => void | ||
| ): Promise<void> { | ||
| // Note: shouldTrack() is called in trackEvent() - no need to check here | ||
| await this.trackEvent( | ||
| EventType.SCREEN, | ||
| { name }, | ||
| { name, ...(category && { category }) }, | ||
| properties, | ||
| context, | ||
| callback | ||
|
|
@@ -175,8 +177,7 @@ export class FormoAnalytics implements IFormoAnalytics { | |
| * ``` | ||
| */ | ||
| public setTrafficSourceFromUrl(url: string): void { | ||
| const { parseTrafficSource, storeTrafficSource } = require("./utils/trafficSource"); | ||
| const trafficSource = parseTrafficSource(url); | ||
| const trafficSource = parseTrafficSource(url, this.options.referral?.queryParams); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new Useful? React with 👍 / 👎.
This comment was marked as outdated.
Sorry, something went wrong. |
||
| storeTrafficSource(trafficSource); | ||
| logger.debug("Traffic source set from URL:", trafficSource); | ||
| } | ||
|
|
@@ -325,7 +326,7 @@ export class FormoAnalytics implements IFormoAnalytics { | |
| signatureHash, | ||
| }: { | ||
| status: SignatureStatus; | ||
| chainId: ChainID; | ||
| chainId?: ChainID; | ||
| address: Address; | ||
| message: string; | ||
| signatureHash?: string; | ||
|
|
@@ -334,10 +335,6 @@ export class FormoAnalytics implements IFormoAnalytics { | |
| context?: IFormoEventContext, | ||
| callback?: (...args: unknown[]) => void | ||
| ): Promise<void> { | ||
| if (chainId === null || chainId === undefined || Number(chainId) === 0) { | ||
| logger.warn("Signature: Chain ID cannot be null, undefined, or 0"); | ||
| return; | ||
| } | ||
| if (!address) { | ||
| logger.warn("Signature: Address cannot be empty"); | ||
| return; | ||
|
|
@@ -346,7 +343,7 @@ export class FormoAnalytics implements IFormoAnalytics { | |
| EventType.SIGNATURE, | ||
| { | ||
| status, | ||
| chainId, | ||
| ...(chainId !== undefined && chainId !== null && { chainId }), | ||
| address, | ||
| message, | ||
| ...(signatureHash && { signatureHash }), | ||
|
|
@@ -369,6 +366,8 @@ export class FormoAnalytics implements IFormoAnalytics { | |
| to, | ||
| value, | ||
| transactionHash, | ||
| function_name, | ||
| function_args, | ||
| }: { | ||
| status: TransactionStatus; | ||
| chainId: ChainID; | ||
|
|
@@ -377,6 +376,8 @@ export class FormoAnalytics implements IFormoAnalytics { | |
| to?: string; | ||
| value?: string; | ||
| transactionHash?: string; | ||
| function_name?: string; | ||
| function_args?: Record<string, unknown>; | ||
| }, | ||
| properties?: IFormoEventProperties, | ||
| context?: IFormoEventContext, | ||
|
|
@@ -400,6 +401,8 @@ export class FormoAnalytics implements IFormoAnalytics { | |
| to, | ||
| value, | ||
| ...(transactionHash && { transactionHash }), | ||
| ...(function_name && { function_name }), | ||
| ...(function_args && { function_args }), | ||
| }, | ||
| properties, | ||
| context, | ||
|
|
@@ -596,6 +599,9 @@ export class FormoAnalytics implements IFormoAnalytics { | |
| ); | ||
| } catch (error) { | ||
| logger.error("Error tracking event:", error); | ||
| if (this.options.errorHandler) { | ||
| this.options.errorHandler(error instanceof Error ? error : new Error(String(error))); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new global Useful? React with 👍 / 👎. |
||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 New The PR adds two new options to (Refers to lines 140-160) Prompt for agentsWas this helpful? React with 👍 or 👎 to provide feedback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing
screentoscreen(name, category?, properties?, context?, callback?)shifts every existing positional call by one slot. Calls likescreen('Home', { section: 'featured' })now pass the properties object ascategory, so custom properties/context are dropped or misaligned and a non-string category can be sent in the payload. This is a silent analytics regression for existing JS consumers and a breaking API change for TS users that previously usedscreen(name, properties, ...).Useful? React with 👍 / 👎.