@virex-tech/paywallo-sdk 2.5.3 → 2.6.0

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/index.d.mts CHANGED
@@ -641,7 +641,6 @@ type NotificationsEnvironment = "sandbox" | "production";
641
641
  interface NotificationsConfig {
642
642
  debug?: boolean;
643
643
  environment?: NotificationsEnvironment;
644
- apiBaseUrl?: string;
645
644
  }
646
645
 
647
646
  declare const NOTIFICATIONS_ERROR_CODES: {
@@ -748,7 +747,6 @@ interface HandlersConfig {
748
747
  }
749
748
  interface NotificationsManagerConfig {
750
749
  appKey: string;
751
- apiBaseUrl?: string;
752
750
  debug?: boolean;
753
751
  environment?: NotificationsConfig["environment"];
754
752
  }
@@ -1632,8 +1630,25 @@ declare class OnboardingError extends PaywalloError {
1632
1630
  declare const ONBOARDING_ERROR_CODES: {
1633
1631
  readonly NOT_INITIALIZED: "ONBOARDING_NOT_INITIALIZED";
1634
1632
  readonly INVALID_STEP_NAME: "ONBOARDING_INVALID_STEP_NAME";
1633
+ readonly INVALID_ORDER: "ONBOARDING_INVALID_ORDER";
1635
1634
  };
1636
1635
 
1636
+ /** Payload sent with onboarding.step events. */
1637
+ interface OnboardingStepPayload {
1638
+ step_name: string;
1639
+ /** Ordem de exibição do step (aceita decimais, ex: 2.1 para variantes A/B). Obrigatório. */
1640
+ order: number;
1641
+ variant_key?: string;
1642
+ time_on_prev_s?: number;
1643
+ }
1644
+ interface OnboardingStepOptions {
1645
+ variantKey?: string;
1646
+ timeOnPrevS?: number;
1647
+ }
1648
+ interface OnboardingCompleteOptions {
1649
+ variantKey?: string;
1650
+ }
1651
+
1637
1652
  /**
1638
1653
  * Minimal surface the OnboardingManager needs from the unified event pipeline.
1639
1654
  * `PaywalloClient` satisfies this interface (forwarding to
@@ -1661,42 +1676,26 @@ declare class OnboardingManager {
1661
1676
  * Saves the step name internally for implicit drop detection on the backend.
1662
1677
  *
1663
1678
  * @param stepName - Unique name for this onboarding step.
1664
- * @param order - Optional explicit display order (accepts decimals, e.g. 2.1 for A/B variants).
1679
+ * @param order - Ordem de exibição do step. Obrigatório. Aceita decimais (ex: 2.1 para variantes A/B).
1680
+ * Deve ser um número finito e não-negativo. O servidor faz o floor — não arredondar aqui.
1665
1681
  */
1666
- step(stepName: string, order?: number): Promise<void>;
1682
+ step(stepName: string, order: number, options?: OnboardingStepOptions): Promise<void>;
1667
1683
  /**
1668
1684
  * Tracks successful completion of the onboarding flow.
1669
1685
  * Marks the flow as finished.
1670
1686
  */
1671
- complete(): Promise<void>;
1672
- /**
1673
- * Tracks an explicit drop (abandonment) at the given step.
1674
- * Marks the flow as finished.
1675
- *
1676
- * @param stepName - The step name where the user dropped off.
1677
- */
1678
- drop(stepName: string): Promise<void>;
1687
+ complete(options?: OnboardingCompleteOptions): Promise<void>;
1679
1688
  /** Returns the last step name seen, or null if no step was tracked yet. */
1680
1689
  getLastStep(): string | null;
1681
- /** Returns whether the flow has been marked as finished (complete or drop). */
1690
+ /** Returns whether the flow has been marked as finished (complete). */
1682
1691
  isFinished(): boolean;
1683
1692
  private emit;
1684
1693
  private assertConfig;
1685
1694
  private validateStepName;
1695
+ private validateOrder;
1686
1696
  }
1687
1697
  declare const onboardingManager: OnboardingManager;
1688
1698
 
1689
- /** Payload sent with onboarding.step events. */
1690
- interface OnboardingStepPayload {
1691
- step_name: string;
1692
- /** Optional explicit order (accepts decimals, e.g. 2.1 for A/B variants). */
1693
- order?: number;
1694
- }
1695
- /** Payload sent with onboarding.drop events. */
1696
- interface OnboardingDropPayload {
1697
- step_name: string;
1698
- }
1699
-
1700
1699
  interface PaywallContextValue {
1701
1700
  nodes: Record<string, PaywallNode>;
1702
1701
  rootId: string;
@@ -1863,9 +1862,8 @@ interface UseOfferingsResult {
1863
1862
  declare function useOfferings(ids?: string[]): UseOfferingsResult;
1864
1863
 
1865
1864
  interface UseOnboardingResult {
1866
- step: (stepName: string, order?: number) => Promise<void>;
1867
- complete: () => Promise<void>;
1868
- drop: (stepName: string) => Promise<void>;
1865
+ step: (stepName: string, order: number, options?: OnboardingStepOptions) => Promise<void>;
1866
+ complete: (options?: OnboardingCompleteOptions) => Promise<void>;
1869
1867
  }
1870
1868
  /**
1871
1869
  * React hook that exposes bound onboarding tracking methods.
@@ -2017,4 +2015,4 @@ declare function hasVariables(text: string): boolean;
2017
2015
 
2018
2016
  declare const Paywallo: IPaywalloClient;
2019
2017
 
2020
- export { type AllPlansResponse, ApiClient, type ApiClientConfig, type AttributionCapture, AttributionTracker, type BlockType, type BoxSpacing, CAMPAIGN_ERROR_CODES, type CachedOfferings, type CachedPlans, type CachedSubscription, CampaignError, type CampaignPresentOptions, type CampaignResponse, type CampaignResult, type ConditionalFlagContext, type ConditionalFlagResult, type DeviceTokenRegistration, PURCHASE_ERROR_CODES as ERROR_CODES, type EmergencyPaywallResponse, type Environment, type FlagVariant, HttpClient, type HttpClientConfig, type HttpResponse, type IAPProduct, type IAPPurchase, IAPService, IDENTITY_ERROR_CODES, type IPaywalloClient, type IPushBridge, type IdentifyOptions, IdentityError, IdentityManager, type IdentityState, type LocalizedText, MetaBridge, NOTIFICATIONS_ERROR_CODES, NativePushBridge, type NetworkListener, type NetworkMonitorConfig, type NetworkState, type NotificationEventType, type NotificationListener, type NotificationPayload, NotificationsError, NotificationsManager, ONBOARDING_ERROR_CODES, type Offering, type OfferingProduct, OfferingService, type OfferingServiceConfig, type OfflineQueueConfig, type OnboardingDropPayload, OnboardingError, OnboardingManager, type OnboardingStepPayload, PAYWALL_ERROR_CODES, PURCHASE_ERROR_CODES, type PaywallBlockConfig, type PaywallConfig, PaywallContext, PaywallError, type PaywallErrorStrings$1 as PaywallErrorStrings, PaywallModal, type PaywallNode, type PaywallPresentOptions, type PaywallResult, type PaywallState, Paywallo, PaywalloClient, type PaywalloConfig, PaywalloContext, PaywalloError, type PaywalloInitConfig, PaywalloProvider, type PaywalloProviderProps, type Plan, PlanCache, type PlanProduct, PlanService, type PlanServiceConfig, type PlansResponse, type PrePromptHandle, type PrePromptOptions, type PreloadCampaignResult, type PreloadResult, type Product, type ProductPriceInfo, type Purchase, type PurchaseControllerConfig, PurchaseError, type PurchaseResult, type PurchaseState, type PushPermissionStatus, type PushPlatform, type QueueEvent, type QueueItem, type QueueListener, type QueueProcessorConfig, type RequestOptions, type RestoreResult$1 as RestoreResult, type RetryConfig, SESSION_ERROR_CODES, type SessionConfig, SessionError, SessionManager, type SessionState, type Subscription, SubscriptionCache, type SubscriptionInfo, type SubscriptionManagerConfig, type SubscriptionPlatform, type SubscriptionStatus$1 as SubscriptionStatus, type SubscriptionStatusResponse$1 as SubscriptionStatusResponse, type TapBehavior, type TrackEventOptions, type UserProperties, type ValidatePurchaseResponse, type VariableContext, attributionTracker, createPurchaseError, Paywallo as default, detectDeviceLanguage, getActiveRouteName, getCurrentLanguage, getDefaultLanguage, getIAPService, getLocalizedString, hasVariables, identityManager, initLocalization, metaBridge, nativeStoreKit, networkMonitor, notificationsManager, offeringService, offlineQueue, onboardingManager, parseVariables, planCache, planService, queueProcessor, resolveText, sessionManager, setCurrentLanguage, setDefaultLanguage, subscriptionManager, useOfferingPurchase, useOfferings, useOnboarding, usePaywallContext, usePaywallo, usePaywalloScreenTracking, usePlanPurchase, usePlans, useProducts, usePurchase, useSubscription };
2018
+ export { type AllPlansResponse, ApiClient, type ApiClientConfig, type AttributionCapture, AttributionTracker, type BlockType, type BoxSpacing, CAMPAIGN_ERROR_CODES, type CachedOfferings, type CachedPlans, type CachedSubscription, CampaignError, type CampaignPresentOptions, type CampaignResponse, type CampaignResult, type ConditionalFlagContext, type ConditionalFlagResult, type DeviceTokenRegistration, PURCHASE_ERROR_CODES as ERROR_CODES, type EmergencyPaywallResponse, type Environment, type FlagVariant, HttpClient, type HttpClientConfig, type HttpResponse, type IAPProduct, type IAPPurchase, IAPService, IDENTITY_ERROR_CODES, type IPaywalloClient, type IPushBridge, type IdentifyOptions, IdentityError, IdentityManager, type IdentityState, type LocalizedText, MetaBridge, NOTIFICATIONS_ERROR_CODES, NativePushBridge, type NetworkListener, type NetworkMonitorConfig, type NetworkState, type NotificationEventType, type NotificationListener, type NotificationPayload, NotificationsError, NotificationsManager, ONBOARDING_ERROR_CODES, type Offering, type OfferingProduct, OfferingService, type OfferingServiceConfig, type OfflineQueueConfig, OnboardingError, OnboardingManager, type OnboardingStepPayload, PAYWALL_ERROR_CODES, PURCHASE_ERROR_CODES, type PaywallBlockConfig, type PaywallConfig, PaywallContext, PaywallError, type PaywallErrorStrings$1 as PaywallErrorStrings, PaywallModal, type PaywallNode, type PaywallPresentOptions, type PaywallResult, type PaywallState, Paywallo, PaywalloClient, type PaywalloConfig, PaywalloContext, PaywalloError, type PaywalloInitConfig, PaywalloProvider, type PaywalloProviderProps, type Plan, PlanCache, type PlanProduct, PlanService, type PlanServiceConfig, type PlansResponse, type PrePromptHandle, type PrePromptOptions, type PreloadCampaignResult, type PreloadResult, type Product, type ProductPriceInfo, type Purchase, type PurchaseControllerConfig, PurchaseError, type PurchaseResult, type PurchaseState, type PushPermissionStatus, type PushPlatform, type QueueEvent, type QueueItem, type QueueListener, type QueueProcessorConfig, type RequestOptions, type RestoreResult$1 as RestoreResult, type RetryConfig, SESSION_ERROR_CODES, type SessionConfig, SessionError, SessionManager, type SessionState, type Subscription, SubscriptionCache, type SubscriptionInfo, type SubscriptionManagerConfig, type SubscriptionPlatform, type SubscriptionStatus$1 as SubscriptionStatus, type SubscriptionStatusResponse$1 as SubscriptionStatusResponse, type TapBehavior, type TrackEventOptions, type UserProperties, type ValidatePurchaseResponse, type VariableContext, attributionTracker, createPurchaseError, Paywallo as default, detectDeviceLanguage, getActiveRouteName, getCurrentLanguage, getDefaultLanguage, getIAPService, getLocalizedString, hasVariables, identityManager, initLocalization, metaBridge, nativeStoreKit, networkMonitor, notificationsManager, offeringService, offlineQueue, onboardingManager, parseVariables, planCache, planService, queueProcessor, resolveText, sessionManager, setCurrentLanguage, setDefaultLanguage, subscriptionManager, useOfferingPurchase, useOfferings, useOnboarding, usePaywallContext, usePaywallo, usePaywalloScreenTracking, usePlanPurchase, usePlans, useProducts, usePurchase, useSubscription };
package/dist/index.d.ts CHANGED
@@ -641,7 +641,6 @@ type NotificationsEnvironment = "sandbox" | "production";
641
641
  interface NotificationsConfig {
642
642
  debug?: boolean;
643
643
  environment?: NotificationsEnvironment;
644
- apiBaseUrl?: string;
645
644
  }
646
645
 
647
646
  declare const NOTIFICATIONS_ERROR_CODES: {
@@ -748,7 +747,6 @@ interface HandlersConfig {
748
747
  }
749
748
  interface NotificationsManagerConfig {
750
749
  appKey: string;
751
- apiBaseUrl?: string;
752
750
  debug?: boolean;
753
751
  environment?: NotificationsConfig["environment"];
754
752
  }
@@ -1632,8 +1630,25 @@ declare class OnboardingError extends PaywalloError {
1632
1630
  declare const ONBOARDING_ERROR_CODES: {
1633
1631
  readonly NOT_INITIALIZED: "ONBOARDING_NOT_INITIALIZED";
1634
1632
  readonly INVALID_STEP_NAME: "ONBOARDING_INVALID_STEP_NAME";
1633
+ readonly INVALID_ORDER: "ONBOARDING_INVALID_ORDER";
1635
1634
  };
1636
1635
 
1636
+ /** Payload sent with onboarding.step events. */
1637
+ interface OnboardingStepPayload {
1638
+ step_name: string;
1639
+ /** Ordem de exibição do step (aceita decimais, ex: 2.1 para variantes A/B). Obrigatório. */
1640
+ order: number;
1641
+ variant_key?: string;
1642
+ time_on_prev_s?: number;
1643
+ }
1644
+ interface OnboardingStepOptions {
1645
+ variantKey?: string;
1646
+ timeOnPrevS?: number;
1647
+ }
1648
+ interface OnboardingCompleteOptions {
1649
+ variantKey?: string;
1650
+ }
1651
+
1637
1652
  /**
1638
1653
  * Minimal surface the OnboardingManager needs from the unified event pipeline.
1639
1654
  * `PaywalloClient` satisfies this interface (forwarding to
@@ -1661,42 +1676,26 @@ declare class OnboardingManager {
1661
1676
  * Saves the step name internally for implicit drop detection on the backend.
1662
1677
  *
1663
1678
  * @param stepName - Unique name for this onboarding step.
1664
- * @param order - Optional explicit display order (accepts decimals, e.g. 2.1 for A/B variants).
1679
+ * @param order - Ordem de exibição do step. Obrigatório. Aceita decimais (ex: 2.1 para variantes A/B).
1680
+ * Deve ser um número finito e não-negativo. O servidor faz o floor — não arredondar aqui.
1665
1681
  */
1666
- step(stepName: string, order?: number): Promise<void>;
1682
+ step(stepName: string, order: number, options?: OnboardingStepOptions): Promise<void>;
1667
1683
  /**
1668
1684
  * Tracks successful completion of the onboarding flow.
1669
1685
  * Marks the flow as finished.
1670
1686
  */
1671
- complete(): Promise<void>;
1672
- /**
1673
- * Tracks an explicit drop (abandonment) at the given step.
1674
- * Marks the flow as finished.
1675
- *
1676
- * @param stepName - The step name where the user dropped off.
1677
- */
1678
- drop(stepName: string): Promise<void>;
1687
+ complete(options?: OnboardingCompleteOptions): Promise<void>;
1679
1688
  /** Returns the last step name seen, or null if no step was tracked yet. */
1680
1689
  getLastStep(): string | null;
1681
- /** Returns whether the flow has been marked as finished (complete or drop). */
1690
+ /** Returns whether the flow has been marked as finished (complete). */
1682
1691
  isFinished(): boolean;
1683
1692
  private emit;
1684
1693
  private assertConfig;
1685
1694
  private validateStepName;
1695
+ private validateOrder;
1686
1696
  }
1687
1697
  declare const onboardingManager: OnboardingManager;
1688
1698
 
1689
- /** Payload sent with onboarding.step events. */
1690
- interface OnboardingStepPayload {
1691
- step_name: string;
1692
- /** Optional explicit order (accepts decimals, e.g. 2.1 for A/B variants). */
1693
- order?: number;
1694
- }
1695
- /** Payload sent with onboarding.drop events. */
1696
- interface OnboardingDropPayload {
1697
- step_name: string;
1698
- }
1699
-
1700
1699
  interface PaywallContextValue {
1701
1700
  nodes: Record<string, PaywallNode>;
1702
1701
  rootId: string;
@@ -1863,9 +1862,8 @@ interface UseOfferingsResult {
1863
1862
  declare function useOfferings(ids?: string[]): UseOfferingsResult;
1864
1863
 
1865
1864
  interface UseOnboardingResult {
1866
- step: (stepName: string, order?: number) => Promise<void>;
1867
- complete: () => Promise<void>;
1868
- drop: (stepName: string) => Promise<void>;
1865
+ step: (stepName: string, order: number, options?: OnboardingStepOptions) => Promise<void>;
1866
+ complete: (options?: OnboardingCompleteOptions) => Promise<void>;
1869
1867
  }
1870
1868
  /**
1871
1869
  * React hook that exposes bound onboarding tracking methods.
@@ -2017,4 +2015,4 @@ declare function hasVariables(text: string): boolean;
2017
2015
 
2018
2016
  declare const Paywallo: IPaywalloClient;
2019
2017
 
2020
- export { type AllPlansResponse, ApiClient, type ApiClientConfig, type AttributionCapture, AttributionTracker, type BlockType, type BoxSpacing, CAMPAIGN_ERROR_CODES, type CachedOfferings, type CachedPlans, type CachedSubscription, CampaignError, type CampaignPresentOptions, type CampaignResponse, type CampaignResult, type ConditionalFlagContext, type ConditionalFlagResult, type DeviceTokenRegistration, PURCHASE_ERROR_CODES as ERROR_CODES, type EmergencyPaywallResponse, type Environment, type FlagVariant, HttpClient, type HttpClientConfig, type HttpResponse, type IAPProduct, type IAPPurchase, IAPService, IDENTITY_ERROR_CODES, type IPaywalloClient, type IPushBridge, type IdentifyOptions, IdentityError, IdentityManager, type IdentityState, type LocalizedText, MetaBridge, NOTIFICATIONS_ERROR_CODES, NativePushBridge, type NetworkListener, type NetworkMonitorConfig, type NetworkState, type NotificationEventType, type NotificationListener, type NotificationPayload, NotificationsError, NotificationsManager, ONBOARDING_ERROR_CODES, type Offering, type OfferingProduct, OfferingService, type OfferingServiceConfig, type OfflineQueueConfig, type OnboardingDropPayload, OnboardingError, OnboardingManager, type OnboardingStepPayload, PAYWALL_ERROR_CODES, PURCHASE_ERROR_CODES, type PaywallBlockConfig, type PaywallConfig, PaywallContext, PaywallError, type PaywallErrorStrings$1 as PaywallErrorStrings, PaywallModal, type PaywallNode, type PaywallPresentOptions, type PaywallResult, type PaywallState, Paywallo, PaywalloClient, type PaywalloConfig, PaywalloContext, PaywalloError, type PaywalloInitConfig, PaywalloProvider, type PaywalloProviderProps, type Plan, PlanCache, type PlanProduct, PlanService, type PlanServiceConfig, type PlansResponse, type PrePromptHandle, type PrePromptOptions, type PreloadCampaignResult, type PreloadResult, type Product, type ProductPriceInfo, type Purchase, type PurchaseControllerConfig, PurchaseError, type PurchaseResult, type PurchaseState, type PushPermissionStatus, type PushPlatform, type QueueEvent, type QueueItem, type QueueListener, type QueueProcessorConfig, type RequestOptions, type RestoreResult$1 as RestoreResult, type RetryConfig, SESSION_ERROR_CODES, type SessionConfig, SessionError, SessionManager, type SessionState, type Subscription, SubscriptionCache, type SubscriptionInfo, type SubscriptionManagerConfig, type SubscriptionPlatform, type SubscriptionStatus$1 as SubscriptionStatus, type SubscriptionStatusResponse$1 as SubscriptionStatusResponse, type TapBehavior, type TrackEventOptions, type UserProperties, type ValidatePurchaseResponse, type VariableContext, attributionTracker, createPurchaseError, Paywallo as default, detectDeviceLanguage, getActiveRouteName, getCurrentLanguage, getDefaultLanguage, getIAPService, getLocalizedString, hasVariables, identityManager, initLocalization, metaBridge, nativeStoreKit, networkMonitor, notificationsManager, offeringService, offlineQueue, onboardingManager, parseVariables, planCache, planService, queueProcessor, resolveText, sessionManager, setCurrentLanguage, setDefaultLanguage, subscriptionManager, useOfferingPurchase, useOfferings, useOnboarding, usePaywallContext, usePaywallo, usePaywalloScreenTracking, usePlanPurchase, usePlans, useProducts, usePurchase, useSubscription };
2018
+ export { type AllPlansResponse, ApiClient, type ApiClientConfig, type AttributionCapture, AttributionTracker, type BlockType, type BoxSpacing, CAMPAIGN_ERROR_CODES, type CachedOfferings, type CachedPlans, type CachedSubscription, CampaignError, type CampaignPresentOptions, type CampaignResponse, type CampaignResult, type ConditionalFlagContext, type ConditionalFlagResult, type DeviceTokenRegistration, PURCHASE_ERROR_CODES as ERROR_CODES, type EmergencyPaywallResponse, type Environment, type FlagVariant, HttpClient, type HttpClientConfig, type HttpResponse, type IAPProduct, type IAPPurchase, IAPService, IDENTITY_ERROR_CODES, type IPaywalloClient, type IPushBridge, type IdentifyOptions, IdentityError, IdentityManager, type IdentityState, type LocalizedText, MetaBridge, NOTIFICATIONS_ERROR_CODES, NativePushBridge, type NetworkListener, type NetworkMonitorConfig, type NetworkState, type NotificationEventType, type NotificationListener, type NotificationPayload, NotificationsError, NotificationsManager, ONBOARDING_ERROR_CODES, type Offering, type OfferingProduct, OfferingService, type OfferingServiceConfig, type OfflineQueueConfig, OnboardingError, OnboardingManager, type OnboardingStepPayload, PAYWALL_ERROR_CODES, PURCHASE_ERROR_CODES, type PaywallBlockConfig, type PaywallConfig, PaywallContext, PaywallError, type PaywallErrorStrings$1 as PaywallErrorStrings, PaywallModal, type PaywallNode, type PaywallPresentOptions, type PaywallResult, type PaywallState, Paywallo, PaywalloClient, type PaywalloConfig, PaywalloContext, PaywalloError, type PaywalloInitConfig, PaywalloProvider, type PaywalloProviderProps, type Plan, PlanCache, type PlanProduct, PlanService, type PlanServiceConfig, type PlansResponse, type PrePromptHandle, type PrePromptOptions, type PreloadCampaignResult, type PreloadResult, type Product, type ProductPriceInfo, type Purchase, type PurchaseControllerConfig, PurchaseError, type PurchaseResult, type PurchaseState, type PushPermissionStatus, type PushPlatform, type QueueEvent, type QueueItem, type QueueListener, type QueueProcessorConfig, type RequestOptions, type RestoreResult$1 as RestoreResult, type RetryConfig, SESSION_ERROR_CODES, type SessionConfig, SessionError, SessionManager, type SessionState, type Subscription, SubscriptionCache, type SubscriptionInfo, type SubscriptionManagerConfig, type SubscriptionPlatform, type SubscriptionStatus$1 as SubscriptionStatus, type SubscriptionStatusResponse$1 as SubscriptionStatusResponse, type TapBehavior, type TrackEventOptions, type UserProperties, type ValidatePurchaseResponse, type VariableContext, attributionTracker, createPurchaseError, Paywallo as default, detectDeviceLanguage, getActiveRouteName, getCurrentLanguage, getDefaultLanguage, getIAPService, getLocalizedString, hasVariables, identityManager, initLocalization, metaBridge, nativeStoreKit, networkMonitor, notificationsManager, offeringService, offlineQueue, onboardingManager, parseVariables, planCache, planService, queueProcessor, resolveText, sessionManager, setCurrentLanguage, setDefaultLanguage, subscriptionManager, useOfferingPurchase, useOfferings, useOnboarding, usePaywallContext, usePaywallo, usePaywalloScreenTracking, usePlanPurchase, usePlans, useProducts, usePurchase, useSubscription };
package/dist/index.js CHANGED
@@ -664,9 +664,12 @@ var init_IdentityManager = __esm({
664
664
  dateOfBirth: this.dateOfBirth ?? void 0,
665
665
  gender: this.gender ?? void 0
666
666
  });
667
+ if (this.debug) console.log("[Paywallo] identify confirmed", this.anonId.slice(0, 8));
667
668
  } catch (err) {
668
- if (this.debug) console.log("[Paywallo] identify dispatch error", err);
669
+ if (this.debug) console.log("[Paywallo] identify failed:", err);
669
670
  }
671
+ } else {
672
+ if (this.debug) console.log("[Paywallo] identify skipped \u2014 anonId not ready");
670
673
  }
671
674
  }
672
675
  getDistinctId() {
@@ -2301,18 +2304,15 @@ var init_constants = __esm({
2301
2304
  });
2302
2305
 
2303
2306
  // src/domains/notifications/config.ts
2304
- function resolveApiBaseUrl(config) {
2305
- if (config.apiBaseUrl) return config.apiBaseUrl;
2306
- if (config.environment === "sandbox") return SANDBOX_API_BASE_URL;
2307
+ function resolveApiBaseUrl() {
2307
2308
  return DEFAULT_API_BASE_URL;
2308
2309
  }
2309
- var DEFAULT_API_BASE_URL, SANDBOX_API_BASE_URL;
2310
+ var DEFAULT_API_BASE_URL;
2310
2311
  var init_config = __esm({
2311
2312
  "src/domains/notifications/config.ts"() {
2312
2313
  "use strict";
2313
2314
  init_constants();
2314
2315
  DEFAULT_API_BASE_URL = DEFAULT_API_URL;
2315
- SANDBOX_API_BASE_URL = DEFAULT_API_URL;
2316
2316
  }
2317
2317
  });
2318
2318
 
@@ -2627,8 +2627,8 @@ var init_NotificationHandlerSetup = __esm({
2627
2627
  // src/core/version.ts
2628
2628
  function resolveVersion() {
2629
2629
  try {
2630
- if ("2.5.3") {
2631
- return "2.5.3";
2630
+ if ("2.6.0") {
2631
+ return "2.6.0";
2632
2632
  }
2633
2633
  } catch {
2634
2634
  }
@@ -3082,10 +3082,7 @@ var init_NotificationsManager = __esm({
3082
3082
  }
3083
3083
  applyConfig(config) {
3084
3084
  this.appKey = config.appKey;
3085
- this.apiBaseUrl = resolveApiBaseUrl({
3086
- apiBaseUrl: config.apiBaseUrl,
3087
- environment: config.environment
3088
- });
3085
+ this.apiBaseUrl = resolveApiBaseUrl();
3089
3086
  this.debug = config.debug ?? false;
3090
3087
  this.permissionManager.setDebug(this.debug);
3091
3088
  }
@@ -3261,7 +3258,8 @@ var init_OnboardingError = __esm({
3261
3258
  };
3262
3259
  ONBOARDING_ERROR_CODES = {
3263
3260
  NOT_INITIALIZED: "ONBOARDING_NOT_INITIALIZED",
3264
- INVALID_STEP_NAME: "ONBOARDING_INVALID_STEP_NAME"
3261
+ INVALID_STEP_NAME: "ONBOARDING_INVALID_STEP_NAME",
3262
+ INVALID_ORDER: "ONBOARDING_INVALID_ORDER"
3265
3263
  };
3266
3264
  }
3267
3265
  });
@@ -3291,16 +3289,20 @@ var init_OnboardingManager = __esm({
3291
3289
  * Saves the step name internally for implicit drop detection on the backend.
3292
3290
  *
3293
3291
  * @param stepName - Unique name for this onboarding step.
3294
- * @param order - Optional explicit display order (accepts decimals, e.g. 2.1 for A/B variants).
3292
+ * @param order - Ordem de exibição do step. Obrigatório. Aceita decimais (ex: 2.1 para variantes A/B).
3293
+ * Deve ser um número finito e não-negativo. O servidor faz o floor — não arredondar aqui.
3295
3294
  */
3296
- async step(stepName, order) {
3295
+ async step(stepName, order, options) {
3297
3296
  this.assertConfig();
3298
3297
  this.validateStepName(stepName, "step");
3298
+ this.validateOrder(order);
3299
3299
  this.lastStep = stepName;
3300
- const stepPayload = { step_name: stepName };
3301
- if (order !== void 0 && Number.isFinite(order) && order >= 0) {
3302
- stepPayload.order = order;
3303
- }
3300
+ const stepPayload = {
3301
+ step_name: stepName,
3302
+ order,
3303
+ ...options?.variantKey !== void 0 ? { variant_key: options.variantKey } : {},
3304
+ ...options?.timeOnPrevS !== void 0 ? { time_on_prev_s: options.timeOnPrevS } : {}
3305
+ };
3304
3306
  const payload = {
3305
3307
  family: "onboarding",
3306
3308
  type: "step",
@@ -3312,33 +3314,21 @@ var init_OnboardingManager = __esm({
3312
3314
  * Tracks successful completion of the onboarding flow.
3313
3315
  * Marks the flow as finished.
3314
3316
  */
3315
- async complete() {
3316
- this.assertConfig();
3317
- this.finished = true;
3318
- return this.emit("onboarding", { family: "onboarding", type: "complete" }, "complete");
3319
- }
3320
- /**
3321
- * Tracks an explicit drop (abandonment) at the given step.
3322
- * Marks the flow as finished.
3323
- *
3324
- * @param stepName - The step name where the user dropped off.
3325
- */
3326
- async drop(stepName) {
3317
+ async complete(options) {
3327
3318
  this.assertConfig();
3328
- this.validateStepName(stepName, "drop");
3329
3319
  this.finished = true;
3330
3320
  const payload = {
3331
3321
  family: "onboarding",
3332
- type: "drop",
3333
- ...{ step_name: stepName }
3322
+ type: "complete",
3323
+ ...options?.variantKey !== void 0 ? { variant_key: options.variantKey } : {}
3334
3324
  };
3335
- return this.emit("onboarding", payload, "drop");
3325
+ return this.emit("onboarding", payload, "complete");
3336
3326
  }
3337
3327
  /** Returns the last step name seen, or null if no step was tracked yet. */
3338
3328
  getLastStep() {
3339
3329
  return this.lastStep;
3340
3330
  }
3341
- /** Returns whether the flow has been marked as finished (complete or drop). */
3331
+ /** Returns whether the flow has been marked as finished (complete). */
3342
3332
  isFinished() {
3343
3333
  return this.finished;
3344
3334
  }
@@ -3370,6 +3360,14 @@ var init_OnboardingManager = __esm({
3370
3360
  );
3371
3361
  }
3372
3362
  }
3363
+ validateOrder(order) {
3364
+ if (order === void 0 || order === null || !Number.isFinite(order) || order < 0) {
3365
+ throw new OnboardingError(
3366
+ ONBOARDING_ERROR_CODES.INVALID_ORDER,
3367
+ "OnboardingManager.step(): order deve ser um n\xFAmero finito e n\xE3o-negativo."
3368
+ );
3369
+ }
3370
+ }
3373
3371
  };
3374
3372
  onboardingManager = new OnboardingManager();
3375
3373
  }
@@ -5226,7 +5224,7 @@ var init_QueueProcessor = __esm({
5226
5224
  for (const item of batch) {
5227
5225
  retryIds.add(item.id);
5228
5226
  }
5229
- console.error("[Paywallo:QUEUE] event batch network error \u2014 items will retry", { size: batch.length, error: error instanceof Error ? error.message : String(error) });
5227
+ if (this.config.debug) console.log("[Paywallo:QUEUE] event batch network error \u2014 items will retry", { size: batch.length, error: error instanceof Error ? error.message : String(error) });
5230
5228
  this.log("Event batch threw network error - will retry", {
5231
5229
  size: batch.length,
5232
5230
  error: error instanceof Error ? error.message : String(error)
@@ -5239,7 +5237,7 @@ var init_QueueProcessor = __esm({
5239
5237
  processed++;
5240
5238
  }
5241
5239
  this.log("Event batch processed successfully", { size: batch.length });
5242
- } else if (response.status >= 400 && response.status < 500) {
5240
+ } else if (response.status >= 400 && response.status < 500 && response.status !== 429) {
5243
5241
  for (const item of batch) {
5244
5242
  await offlineQueue.removeItem(item.id);
5245
5243
  failed++;
@@ -5251,7 +5249,7 @@ var init_QueueProcessor = __esm({
5251
5249
  console.log("[Paywallo:QUEUE] event batch deduplicated by server \u2014 items dropped (benign)", { status: response.status, size: batch.length, error: responseError });
5252
5250
  }
5253
5251
  } else {
5254
- console.error("[Paywallo:QUEUE] event batch failed PERMANENTLY (4xx) \u2014 items dropped", { status: response.status, size: batch.length, responseBody: typeof response.data === "string" ? response.data.slice(0, 1e3) : JSON.stringify(response.data).slice(0, 1e3), firstItemBody: typeof batch[0].body === "string" ? batch[0].body.slice(0, 1e3) : JSON.stringify(batch[0].body).slice(0, 1e3) });
5252
+ if (this.config.debug) console.log("[Paywallo:QUEUE] event batch failed PERMANENTLY (4xx) \u2014 items dropped", { status: response.status, size: batch.length, responseBody: typeof response.data === "string" ? response.data.slice(0, 1e3) : JSON.stringify(response.data).slice(0, 1e3), firstItemBody: typeof batch[0].body === "string" ? batch[0].body.slice(0, 1e3) : JSON.stringify(batch[0].body).slice(0, 1e3) });
5255
5253
  }
5256
5254
  this.log("Event batch failed permanently (4xx) - removing from queue", {
5257
5255
  status: response.status,
@@ -5262,7 +5260,7 @@ var init_QueueProcessor = __esm({
5262
5260
  for (const item of batch) {
5263
5261
  retryIds.add(item.id);
5264
5262
  }
5265
- console.error("[Paywallo:QUEUE] event batch server error (5xx) \u2014 will retry", { status: response.status, size: batch.length });
5263
+ if (this.config.debug) console.log("[Paywallo:QUEUE] event batch server error (5xx) \u2014 will retry", { status: response.status, size: batch.length });
5266
5264
  this.log("Event batch failed with server error - will retry", {
5267
5265
  status: response.status,
5268
5266
  size: batch.length
@@ -5292,7 +5290,7 @@ var init_QueueProcessor = __esm({
5292
5290
  skipRetry: false
5293
5291
  });
5294
5292
  } catch (error) {
5295
- console.error("[Paywallo:QUEUE] individual item network error \u2014 will retry", { id: item.id, url: item.url, error: error instanceof Error ? error.message : String(error) });
5293
+ if (this.config.debug) console.log("[Paywallo:QUEUE] individual item network error \u2014 will retry", { id: item.id, url: item.url, error: error instanceof Error ? error.message : String(error) });
5296
5294
  this.log("Request threw network error - will retry", {
5297
5295
  id: item.id,
5298
5296
  error: error instanceof Error ? error.message : String(error)
@@ -5303,7 +5301,7 @@ var init_QueueProcessor = __esm({
5303
5301
  this.log("Queue item processed successfully", { id: item.id });
5304
5302
  return { success: true, permanent: false };
5305
5303
  }
5306
- if (response.status >= 400 && response.status < 500) {
5304
+ if (response.status >= 400 && response.status < 500 && response.status !== 429) {
5307
5305
  this.log("Request failed with permanent client error - removing from queue", {
5308
5306
  id: item.id,
5309
5307
  url: item.url,
@@ -6821,8 +6819,9 @@ var init_schemas = __esm({
6821
6819
  path: ["transaction_id"]
6822
6820
  });
6823
6821
  onboardingEventSchema = import_zod.z.object({
6824
- type: import_zod.z.enum(["step", "complete", "drop"]),
6825
- step_index: import_zod.z.number().int().nonnegative().optional(),
6822
+ type: import_zod.z.enum(["step", "complete"]),
6823
+ family: import_zod.z.literal("onboarding").optional(),
6824
+ order: import_zod.z.number().nonnegative().optional(),
6826
6825
  step_name: import_zod.z.string().optional(),
6827
6826
  variant_key: import_zod.z.string().optional(),
6828
6827
  time_on_prev_s: import_zod.z.number().nonnegative().optional()
@@ -6919,7 +6918,7 @@ function isValidEventName(name) {
6919
6918
  async function trackEvent(apiClient, state, eventName, options) {
6920
6919
  const distinctId = identityManager.getDistinctId();
6921
6920
  if (!distinctId) {
6922
- console.error("[Paywallo:DROP] event dropped \u2014 no distinctId available yet", { eventName });
6921
+ if (state.config?.debug) console.log("[Paywallo:DROP] event dropped \u2014 no distinctId available yet", { eventName });
6923
6922
  return;
6924
6923
  }
6925
6924
  if (!isValidEventName(eventName)) {
@@ -7654,6 +7653,11 @@ function isServerError(res) {
7654
7653
  const r = res;
7655
7654
  return r.ok === false && typeof r.status === "number" && r.status >= 500;
7656
7655
  }
7656
+ function isRateLimitError(res) {
7657
+ if (typeof res !== "object" || res === null) return false;
7658
+ const r = res;
7659
+ return r.ok === false && r.status === 429;
7660
+ }
7657
7661
  async function postWithQueue(deps, url, payload, label, priority) {
7658
7662
  const enqueue = async () => {
7659
7663
  await offlineQueue.enqueue(
@@ -7675,6 +7679,9 @@ async function postWithQueue(deps, url, payload, label, priority) {
7675
7679
  if (isServerError(res) && deps.isOfflineQueueEnabled()) {
7676
7680
  if (deps.isDebug()) console.log("[Paywallo:ApiClient] Server error, queued for retry:", label, priority ?? "normal");
7677
7681
  await enqueue();
7682
+ } else if (isRateLimitError(res) && deps.isOfflineQueueEnabled()) {
7683
+ if (deps.isDebug()) console.log("[Paywallo:ApiClient] Rate limited (429), queued for retry:", label, priority ?? "normal");
7684
+ await enqueue();
7678
7685
  }
7679
7686
  } catch (error) {
7680
7687
  if (deps.isDebug()) console.log("[Paywallo:ApiClient] Request failed:", label, error);
@@ -7971,7 +7978,7 @@ var init_EventBatcher = __esm({
7971
7978
  try {
7972
7979
  await this.postBatch([event], `event_critical:${event.eventName}`, "critical");
7973
7980
  } catch (err) {
7974
- console.error("[Paywallo:CRITICAL] critical event post failed", { eventName: event.eventName, error: err instanceof Error ? err.message : String(err) });
7981
+ if (this.debug) console.log("[Paywallo:CRITICAL] critical event post failed", { eventName: event.eventName, error: err instanceof Error ? err.message : String(err) });
7975
7982
  }
7976
7983
  }
7977
7984
  }
@@ -7985,7 +7992,7 @@ var init_EventBatcher = __esm({
7985
7992
  try {
7986
7993
  await this.postBatch(batch, `event_batch:${batch.length}`);
7987
7994
  } catch (err) {
7988
- console.error("[Paywallo:NORMAL] batch post failed \u2014 relying on OfflineQueue", { batchSize: batch.length, error: err instanceof Error ? err.message : String(err) });
7995
+ if (this.debug) console.log("[Paywallo:NORMAL] batch post failed \u2014 relying on OfflineQueue", { batchSize: batch.length, error: err instanceof Error ? err.message : String(err) });
7989
7996
  }
7990
7997
  }
7991
7998
  async postBatch(events, label, priority = "normal") {
@@ -8000,7 +8007,7 @@ var init_EventBatcher = __esm({
8000
8007
  const parsed = v2EnvelopeSchema.safeParse(envelope);
8001
8008
  if (!parsed.success) {
8002
8009
  if (this.debug) console.log("[Paywallo EVENTS] V2 envelope schema validation failed:", parsed.error.issues);
8003
- console.error("[Paywallo:CRITICAL] V2 envelope schema validation failed", { issues: parsed.error.issues, eventCount: events.length, firstEventName: events[0]?.eventName, context: providerContext });
8010
+ if (this.debug) console.log("[Paywallo:CRITICAL] V2 envelope schema validation failed", { issues: parsed.error.issues, eventCount: events.length, firstEventName: events[0]?.eventName, context: providerContext });
8004
8011
  throw parsed.error;
8005
8012
  }
8006
8013
  await this.post(V2_BATCH_ENDPOINT, parsed.data, label, priority);
@@ -8618,7 +8625,6 @@ function setupNotifications(apiClient, config, environment, eventPipeline) {
8618
8625
  notificationsManager.setupHandlers({ eventBatcher: eventPipeline });
8619
8626
  notificationsManager.initialize({
8620
8627
  appKey: config.appKey,
8621
- apiBaseUrl: DEFAULT_API_URL,
8622
8628
  debug: config.debug,
8623
8629
  environment: environment === "Sandbox" ? "sandbox" : "production"
8624
8630
  }).catch((err) => {
@@ -8660,7 +8666,6 @@ var init_PaywalloInitHelpers = __esm({
8660
8666
  init_identity();
8661
8667
  init_notifications();
8662
8668
  init_NativePushBridge();
8663
- init_constants();
8664
8669
  init_SecureStorage();
8665
8670
  }
8666
8671
  });
@@ -8750,7 +8755,7 @@ function reportInitFailure(state, config, error, reason) {
8750
8755
  error: error instanceof Error ? error.message : String(error)
8751
8756
  });
8752
8757
  } catch (err) {
8753
- console.error("[Paywallo] reportInitFailure error", err);
8758
+ if (config.debug) console.log("[Paywallo] reportInitFailure error", err);
8754
8759
  }
8755
8760
  }
8756
8761
  function reportInitSuccess(state, config, attempts) {
@@ -8759,7 +8764,7 @@ function reportInitSuccess(state, config, attempts) {
8759
8764
  void state.apiClient.reportError("INIT_RECOVERED", `Succeeded after ${attempts} retries`, { attempts });
8760
8765
  }
8761
8766
  } catch (err) {
8762
- console.error("[Paywallo] reportInitSuccess error", err);
8767
+ if (config.debug) console.log("[Paywallo] reportInitSuccess error", err);
8763
8768
  }
8764
8769
  }
8765
8770
  async function resolveSessionFlags(state, keys, apiClient, distinctId) {
@@ -8913,12 +8918,15 @@ async function doInit(state, config) {
8913
8918
  setupNotifications(apiClient, config, environment, eventPipeline);
8914
8919
  if (config.autoStartSession !== false) {
8915
8920
  sessionManager.startSession().catch((err) => {
8916
- console.error("[Paywallo INIT] autoStart session error", err);
8921
+ if (config.debug) console.log("[Paywallo INIT] autoStart session error", err);
8917
8922
  });
8918
8923
  }
8919
8924
  new InstallTracker(config.debug, {
8920
8925
  distinctIdProvider: () => identityManager.getDistinctId()
8921
- }).trackIfNeeded(apiClient, config.requestATT === true).catch(() => {
8926
+ }).trackIfNeeded(apiClient, config.requestATT === true).then(() => {
8927
+ if (config.debug) console.log("[Paywallo INSTALL] $app_installed sent");
8928
+ }).catch(() => {
8929
+ if (config.debug) console.log("[Paywallo INSTALL] $app_installed failed \u2014 will retry on next launch");
8922
8930
  });
8923
8931
  if (config.sessionFlags && config.sessionFlags.length > 0) {
8924
8932
  await resolveSessionFlags(state, config.sessionFlags, apiClient, distinctId);
@@ -9155,6 +9163,7 @@ var init_PaywalloClient = __esm({
9155
9163
  }
9156
9164
  if (this.state.config?.debug) console.log("[Paywallo IDENTIFY]", options ? { hasEmail: "email" in options && !!options.email, hasProperties: "properties" in options } : void 0);
9157
9165
  await identityManager.identify(options);
9166
+ if (this.state.config?.debug) console.log("[Paywallo IDENTIFY] done");
9158
9167
  }
9159
9168
  async track(eventName, options) {
9160
9169
  return trackEvent(this.getApiClientOrThrow(), this.state, eventName, options);
@@ -9715,18 +9724,14 @@ var import_react15 = require("react");
9715
9724
  init_onboarding();
9716
9725
  function useOnboarding() {
9717
9726
  const step = (0, import_react15.useCallback)(
9718
- (stepName, order) => onboardingManager.step(stepName, order),
9727
+ (stepName, order, options) => onboardingManager.step(stepName, order, options),
9719
9728
  []
9720
9729
  );
9721
9730
  const complete = (0, import_react15.useCallback)(
9722
- () => onboardingManager.complete(),
9723
- []
9724
- );
9725
- const drop = (0, import_react15.useCallback)(
9726
- (stepName) => onboardingManager.drop(stepName),
9731
+ (options) => onboardingManager.complete(options),
9727
9732
  []
9728
9733
  );
9729
- return { step, complete, drop };
9734
+ return { step, complete };
9730
9735
  }
9731
9736
 
9732
9737
  // src/hooks/usePaywallo.ts
@@ -11040,6 +11045,7 @@ function PaywalloProvider({ children, config }) {
11040
11045
  void pushAttributionToSuperwall(configRef.current.debug);
11041
11046
  setDistinctId(PaywalloClient.getDistinctId());
11042
11047
  setIsInitialized(true);
11048
+ if (configRef.current.debug) console.log("[Paywallo] SDK ready", PaywalloClient.getDistinctId()?.slice(0, 8));
11043
11049
  if (!autoPreloadTriggeredRef.current) {
11044
11050
  autoPreloadTriggeredRef.current = true;
11045
11051
  const placement = await PaywalloClient.waitForAutoPreloadedPlacement();