@virex-tech/paywallo-sdk 2.2.5 → 2.2.7

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.
@@ -0,0 +1,31 @@
1
+ package com.paywallo.sdk
2
+
3
+ import com.facebook.react.bridge.*
4
+ import android.os.Build
5
+
6
+ class PaywalloEnvModule(private val reactContext: ReactApplicationContext) :
7
+ ReactContextBaseJavaModule(reactContext) {
8
+
9
+ override fun getName() = "PaywalloEnv"
10
+
11
+ @ReactMethod
12
+ fun detect(promise: Promise) {
13
+ try {
14
+ val packageName = reactContext.packageName
15
+ val packageManager = reactContext.packageManager
16
+ val installer = if (Build.VERSION.SDK_INT >= 30) {
17
+ packageManager.getInstallSourceInfo(packageName).installingPackageName
18
+ } else {
19
+ @Suppress("DEPRECATION")
20
+ packageManager.getInstallerPackageName(packageName)
21
+ }
22
+ if (installer == "com.android.vending") {
23
+ promise.resolve("production")
24
+ } else {
25
+ promise.resolve("sandbox")
26
+ }
27
+ } catch (e: Exception) {
28
+ promise.resolve("production")
29
+ }
30
+ }
31
+ }
@@ -12,7 +12,8 @@ class PaywalloSdkPackage : ReactPackage {
12
12
  PaywalloFBBridgeModule(reactContext),
13
13
  PaywalloStorageModule(reactContext),
14
14
  PaywalloDeviceModule(reactContext),
15
- PaywalloNotificationsModule(reactContext)
15
+ PaywalloNotificationsModule(reactContext),
16
+ PaywalloEnvModule(reactContext)
16
17
  )
17
18
  }
18
19
 
package/dist/index.d.mts CHANGED
@@ -307,6 +307,21 @@ interface PaywalloConfig {
307
307
  debug?: boolean;
308
308
  environment?: Environment;
309
309
  errorStrings?: PaywallErrorStrings$1;
310
+ /**
311
+ * App version reported to the server (used in event context.app_version
312
+ * and identify payload). When omitted, defaults to "unknown".
313
+ * Consumers should pass `Application.nativeApplicationVersion` (Expo)
314
+ * or `DeviceInfo.getVersion()` (bare RN) here.
315
+ */
316
+ appVersion?: string;
317
+ /**
318
+ * Placements de paywall a serem pré-carregados (config + produtos) em
319
+ * background logo após o init. Quando `presentPaywall` é chamado com
320
+ * um placement preloadado, a apresentação pula o round-trip de
321
+ * `getPaywall` + `loadProducts` e fica quase instantânea.
322
+ * TTL: 5 minutos em memória, com stale-while-revalidate.
323
+ */
324
+ preloadPaywalls?: string[];
310
325
  }
311
326
  interface UserProperties {
312
327
  [key: string]: string | number | boolean | null;
@@ -387,12 +402,18 @@ interface EventContext {
387
402
  session_id?: string;
388
403
  device_id?: string;
389
404
  app_version?: string;
405
+ app_build?: string;
406
+ bundle_id?: string;
390
407
  sdk_version?: string;
391
408
  platform?: string;
392
409
  os_version?: string;
393
410
  device_model?: string;
394
411
  timezone?: string;
395
412
  locale?: string;
413
+ carrier?: string;
414
+ screen_width?: number;
415
+ screen_height?: number;
416
+ screen_density?: number;
396
417
  attribution?: Record<string, unknown>;
397
418
  ids?: Record<string, unknown>;
398
419
  }
@@ -896,6 +917,7 @@ declare class NotificationsManager {
896
917
  private getDistinctId;
897
918
  private appKey;
898
919
  private apiBaseUrl;
920
+ private environment;
899
921
  private tokenRefreshCleanup;
900
922
  private foregroundCleanup;
901
923
  private pendingHandlersConfig;
@@ -910,6 +932,7 @@ declare class NotificationsManager {
910
932
  secureStorage: SecureStorage;
911
933
  getDeviceId: () => string | null;
912
934
  getDistinctId?: () => string;
935
+ environment?: "sandbox" | "production";
913
936
  }): void;
914
937
  initialize(config: NotificationsManagerConfig): Promise<void>;
915
938
  private applyConfig;
@@ -1075,6 +1098,10 @@ interface PreloadCampaignResult {
1075
1098
  success: boolean;
1076
1099
  error?: Error;
1077
1100
  }
1101
+ interface PreloadPaywallResult {
1102
+ success: boolean;
1103
+ error?: Error;
1104
+ }
1078
1105
  interface PaywallErrorStrings {
1079
1106
  title?: string;
1080
1107
  retry?: string;
@@ -1118,6 +1145,9 @@ interface IPaywalloClient {
1118
1145
  gateContentWithCampaign<T>(content: () => T | Promise<T>, placement: string, context?: Record<string, unknown>): Promise<T | null>;
1119
1146
  preloadCampaign(placement: string, context?: Record<string, unknown>): Promise<PreloadCampaignResult>;
1120
1147
  getPreloadedCampaign(placement: string): CampaignResponse | null;
1148
+ preloadPaywall(placement: string): Promise<PreloadPaywallResult>;
1149
+ preloadPaywalls(placements: string[]): Promise<void>;
1150
+ isPaywallPreloaded(placement: string): boolean;
1121
1151
  reset(): Promise<void>;
1122
1152
  fullReset(): Promise<void>;
1123
1153
  requestPushPermission(options?: {
package/dist/index.d.ts CHANGED
@@ -307,6 +307,21 @@ interface PaywalloConfig {
307
307
  debug?: boolean;
308
308
  environment?: Environment;
309
309
  errorStrings?: PaywallErrorStrings$1;
310
+ /**
311
+ * App version reported to the server (used in event context.app_version
312
+ * and identify payload). When omitted, defaults to "unknown".
313
+ * Consumers should pass `Application.nativeApplicationVersion` (Expo)
314
+ * or `DeviceInfo.getVersion()` (bare RN) here.
315
+ */
316
+ appVersion?: string;
317
+ /**
318
+ * Placements de paywall a serem pré-carregados (config + produtos) em
319
+ * background logo após o init. Quando `presentPaywall` é chamado com
320
+ * um placement preloadado, a apresentação pula o round-trip de
321
+ * `getPaywall` + `loadProducts` e fica quase instantânea.
322
+ * TTL: 5 minutos em memória, com stale-while-revalidate.
323
+ */
324
+ preloadPaywalls?: string[];
310
325
  }
311
326
  interface UserProperties {
312
327
  [key: string]: string | number | boolean | null;
@@ -387,12 +402,18 @@ interface EventContext {
387
402
  session_id?: string;
388
403
  device_id?: string;
389
404
  app_version?: string;
405
+ app_build?: string;
406
+ bundle_id?: string;
390
407
  sdk_version?: string;
391
408
  platform?: string;
392
409
  os_version?: string;
393
410
  device_model?: string;
394
411
  timezone?: string;
395
412
  locale?: string;
413
+ carrier?: string;
414
+ screen_width?: number;
415
+ screen_height?: number;
416
+ screen_density?: number;
396
417
  attribution?: Record<string, unknown>;
397
418
  ids?: Record<string, unknown>;
398
419
  }
@@ -896,6 +917,7 @@ declare class NotificationsManager {
896
917
  private getDistinctId;
897
918
  private appKey;
898
919
  private apiBaseUrl;
920
+ private environment;
899
921
  private tokenRefreshCleanup;
900
922
  private foregroundCleanup;
901
923
  private pendingHandlersConfig;
@@ -910,6 +932,7 @@ declare class NotificationsManager {
910
932
  secureStorage: SecureStorage;
911
933
  getDeviceId: () => string | null;
912
934
  getDistinctId?: () => string;
935
+ environment?: "sandbox" | "production";
913
936
  }): void;
914
937
  initialize(config: NotificationsManagerConfig): Promise<void>;
915
938
  private applyConfig;
@@ -1075,6 +1098,10 @@ interface PreloadCampaignResult {
1075
1098
  success: boolean;
1076
1099
  error?: Error;
1077
1100
  }
1101
+ interface PreloadPaywallResult {
1102
+ success: boolean;
1103
+ error?: Error;
1104
+ }
1078
1105
  interface PaywallErrorStrings {
1079
1106
  title?: string;
1080
1107
  retry?: string;
@@ -1118,6 +1145,9 @@ interface IPaywalloClient {
1118
1145
  gateContentWithCampaign<T>(content: () => T | Promise<T>, placement: string, context?: Record<string, unknown>): Promise<T | null>;
1119
1146
  preloadCampaign(placement: string, context?: Record<string, unknown>): Promise<PreloadCampaignResult>;
1120
1147
  getPreloadedCampaign(placement: string): CampaignResponse | null;
1148
+ preloadPaywall(placement: string): Promise<PreloadPaywallResult>;
1149
+ preloadPaywalls(placements: string[]): Promise<void>;
1150
+ isPaywallPreloaded(placement: string): boolean;
1121
1151
  reset(): Promise<void>;
1122
1152
  fullReset(): Promise<void>;
1123
1153
  requestPushPermission(options?: {