Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Remove manual payment tracking

Blue Mouse9466f6034022
diff --git a/src/Lib.ts b/src/Lib.ts
index 2e49d8c01..db6fd649b 100644
--- a/src/Lib.ts
+++ b/src/Lib.ts
@@ -216,41 +216,6 @@ export interface PageViewsOptions {
callback?: (payload: IPageViewPayload) => Partial<IPageViewPayload> | boolean
}
-/**
- * Options for tracking payment events.
- */
-export interface TrackPaymentOptions {
- /**
- * Optional profile ID for attribution. If not provided, it will be generated server-side.
- */
- profileId?: string
-
- /**
- * Optional session ID for attribution. If not provided, it will be generated server-side.
- */
- sessionId?: string
-
- /**
- * Optional transaction ID from your payment provider.
- */
- transactionId?: string
-
- /**
- * Payment amount.
- */
- amount?: number
-
- /**
- * Currency code (ISO 4217), e.g., 'USD', 'EUR'.
- */
- currency?: string
-
- /**
- * Additional metadata for the payment event.
- */
- metadata?: Record<string, string | number | boolean>
-}
-
export const defaultActions = {
stop() {},
}
@@ -730,60 +695,6 @@ export class Lib {
}
}
- /**
- * Track a payment event for revenue attribution.
- * Use this when you want to manually log a payment event without relying on
- * automatic sync from payment providers.
- *
- * @param options - Payment event options.
- * @returns A promise that resolves to true if the event was logged successfully.
- *
- * @example
- * ```typescript
- * // Log a payment event after a successful purchase
- * await swetrix.trackPayment({
- * profileId: await swetrix.getProfileId(),
- * sessionId: await swetrix.getSessionId(),
- * amount: 29.99,
- * currency: 'USD',
- * transactionId: 'txn_123456'
- * })
- * ```
- */
- async trackPayment(options?: TrackPaymentOptions): Promise<boolean> {
- if (!isInBrowser()) {
- return false
- }
-
- try {
- const apiBase = this.getApiBase()
- const response = await fetch(`${apiBase}/log/payment`, {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({
- pid: this.projectID,
- profileId: options?.profileId ?? this.options?.profileId,
- sessionId: options?.sessionId,
- transactionId: options?.transactionId,
- amount: options?.amount,
- currency: options?.currency,
- metadata: options?.metadata,
- }),
- })
-
- if (!response.ok) {
- return false
- }
-
- const data = (await response.json()) as { success: boolean }
- return data.success
- } catch {
- return false
- }
- }
-
/**
* Gets the API base URL (without /log suffix).
*/
diff --git a/src/index.ts b/src/index.ts
index 691197f49..1b5c1958c 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -11,7 +11,6 @@ import {
IPageViewPayload,
FeatureFlagsOptions,
ExperimentOptions,
- TrackPaymentOptions,
} from './Lib.js'
export let LIB_INSTANCE: Lib | null = null
@@ -321,32 +320,6 @@ export async function getSessionId(): Promise<string | null> {
return LIB_INSTANCE.getSessionId()
}
-/**
- * Track a payment event for revenue attribution.
- * Use this when you want to manually log a payment event without relying on
- * automatic sync from payment providers.
- *
- * @param options - Payment event options.
- * @returns A promise that resolves to true if the event was logged successfully.
- *
- * @example
- * ```typescript
- * // Log a payment event after a successful purchase
- * await trackPayment({
- * profileId: await getProfileId(),
- * sessionId: await getSessionId(),
- * amount: 29.99,
- * currency: 'USD',
- * transactionId: 'txn_123456'
- * })
- * ```
- */
-export async function trackPayment(options?: TrackPaymentOptions): Promise<boolean> {
- if (!LIB_INSTANCE) return false
-
- return LIB_INSTANCE.trackPayment(options)
-}
-
export {
LibOptions,
TrackEventOptions,
@@ -358,5 +331,4 @@ export {
IPageViewPayload,
FeatureFlagsOptions,
ExperimentOptions,
- TrackPaymentOptions,
}