rampkit-expo-dev 0.0.89 → 0.0.91

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.
@@ -15,6 +15,7 @@ exports.buildRampKitContext = buildRampKitContext;
15
15
  const react_native_1 = require("react-native");
16
16
  const RampKitNative_1 = __importDefault(require("./RampKitNative"));
17
17
  const constants_1 = require("./constants");
18
+ const Logger_1 = require("./Logger");
18
19
  // Session-level data (regenerated each app launch)
19
20
  let sessionId = null;
20
21
  let sessionStartTime = null;
@@ -103,11 +104,11 @@ async function collectDeviceInfo() {
103
104
  // Timestamp
104
105
  collectedAt: nativeInfo.collectedAt,
105
106
  };
106
- console.log("[RampKit] DeviceInfo: Collected from native module");
107
+ Logger_1.Logger.verbose("Device info collected");
107
108
  return deviceInfo;
108
109
  }
109
110
  catch (error) {
110
- console.warn("[RampKit] DeviceInfo: Failed to collect from native module", error);
111
+ Logger_1.Logger.warn("Failed to collect device info from native module:", error);
111
112
  // Return minimal fallback
112
113
  return getFallbackDeviceInfo();
113
114
  }
@@ -6,6 +6,7 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.EventManager = exports.eventManager = void 0;
8
8
  const constants_1 = require("./constants");
9
+ const Logger_1 = require("./Logger");
9
10
  /**
10
11
  * Generate a UUID v4 using Math.random
11
12
  * This is sufficient for event IDs - no crypto dependency needed
@@ -63,7 +64,7 @@ class EventManager {
63
64
  regionCode: deviceInfo.regionCode,
64
65
  };
65
66
  this.initialized = true;
66
- console.log("[RampKit] EventManager: Initialized");
67
+ Logger_1.Logger.verbose("EventManager initialized");
67
68
  }
68
69
  /**
69
70
  * Check if the event manager is initialized
@@ -132,7 +133,7 @@ class EventManager {
132
133
  async track(eventName, properties = {}, contextOverrides) {
133
134
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
134
135
  if (!this.initialized || !this.appId || !this.appUserId || !this.sessionId || !this.device) {
135
- console.warn("[RampKit] EventManager: Not initialized, skipping event:", eventName);
136
+ Logger_1.Logger.warn("EventManager: Not initialized, skipping event:", eventName);
136
137
  return;
137
138
  }
138
139
  const eventId = generateEventId();
@@ -185,14 +186,14 @@ class EventManager {
185
186
  catch (_a) {
186
187
  // Ignore if we can't read the body
187
188
  }
188
- console.warn(`[RampKit] EventManager: Failed to send event: ${event.eventName}`, `\n Status: ${response.status} ${response.statusText}`, `\n URL: ${url}`, `\n AppId: ${event.appId}`, `\n UserId: ${event.appUserId}`, errorDetails ? `\n Error: ${errorDetails}` : "");
189
+ Logger_1.Logger.warn(`Failed to send event ${event.eventName}: ${response.status}${errorDetails}`);
189
190
  }
190
191
  else {
191
- console.log("[RampKit] EventManager: Event sent:", event.eventName);
192
+ Logger_1.Logger.verbose("Event sent:", event.eventName);
192
193
  }
193
194
  }
194
195
  catch (error) {
195
- console.warn(`[RampKit] EventManager: Network error sending event: ${event.eventName}`, `\n Error: ${error instanceof Error ? error.message : String(error)}`);
196
+ Logger_1.Logger.warn(`Network error sending event ${event.eventName}: ${error instanceof Error ? error.message : String(error)}`);
196
197
  }
197
198
  }
198
199
  // ============================================================================
@@ -217,7 +218,7 @@ class EventManager {
217
218
  trackOnboardingAbandoned(reason, lastScreenName, onboardingId) {
218
219
  // Skip if onboarding was already completed this session
219
220
  if (this.onboardingCompletedForSession) {
220
- console.log("[RampKit] EventManager: onboarding_abandoned skipped (already completed)");
221
+ Logger_1.Logger.verbose("onboarding_abandoned skipped (already completed)");
221
222
  return;
222
223
  }
223
224
  const timeSpentSeconds = this.getOnboardingDurationSeconds();
@@ -246,7 +247,7 @@ class EventManager {
246
247
  */
247
248
  trackOnboardingCompleted(trigger, completedSteps, totalSteps, onboardingId) {
248
249
  const timeToCompleteSeconds = this.getOnboardingDurationSeconds();
249
- console.log(`[RampKit] EventManager: 📊 onboarding_completed`, `\n trigger: ${trigger}`, `\n onboardingId: ${onboardingId || this.currentOnboardingId}`, `\n timeToCompleteSeconds: ${timeToCompleteSeconds}`);
250
+ Logger_1.Logger.verbose(`onboarding_completed: trigger=${trigger}, time=${timeToCompleteSeconds}s`);
250
251
  this.track("onboarding_completed", {
251
252
  onboardingId: onboardingId || this.currentOnboardingId,
252
253
  timeToCompleteSeconds,
@@ -284,7 +285,7 @@ class EventManager {
284
285
  trackPurchaseStarted(properties) {
285
286
  // Context (paywallId, placement) is automatically included from current state
286
287
  // which was set when trackPaywallShown was called
287
- console.log(`[RampKit] EventManager: 🛒 purchase_started`, `\n productId: ${properties.productId}`, properties.amount ? `\n amount: ${properties.amount} ${properties.currency || ""}` : "");
288
+ Logger_1.Logger.verbose(`purchase_started: ${properties.productId}`);
288
289
  this.track("purchase_started", properties);
289
290
  }
290
291
  /**
@@ -294,21 +295,21 @@ class EventManager {
294
295
  */
295
296
  trackPurchaseCompleted(properties) {
296
297
  // Context is automatically included from current state (paywallId, placement, etc.)
297
- console.log(`[RampKit] EventManager: ✅ purchase_completed`, `\n productId: ${properties.productId}`, `\n transactionId: ${properties.transactionId}`, `\n originalTransactionId: ${properties.originalTransactionId}`, properties.isTrial ? `\n isTrial: true` : "", properties.environment ? `\n environment: ${properties.environment}` : "");
298
+ Logger_1.Logger.verbose(`purchase_completed: ${properties.productId}`);
298
299
  this.track("purchase_completed", properties);
299
300
  }
300
301
  /**
301
302
  * Track purchase failed
302
303
  */
303
304
  trackPurchaseFailed(productId, errorCode, errorMessage) {
304
- console.log(`[RampKit] EventManager: ❌ purchase_failed`, `\n productId: ${productId}`, `\n errorCode: ${errorCode}`, `\n errorMessage: ${errorMessage}`);
305
+ Logger_1.Logger.verbose(`purchase_failed: ${productId} (${errorCode})`);
305
306
  this.track("purchase_failed", { productId, errorCode, errorMessage });
306
307
  }
307
308
  /**
308
309
  * Track purchase restored
309
310
  */
310
311
  trackPurchaseRestored(properties) {
311
- console.log(`[RampKit] EventManager: 🔄 purchase_restored`, `\n productId: ${properties.productId}`, properties.transactionId ? `\n transactionId: ${properties.transactionId}` : "", properties.originalTransactionId ? `\n originalTransactionId: ${properties.originalTransactionId}` : "");
312
+ Logger_1.Logger.verbose(`purchase_restored: ${properties.productId}`);
312
313
  this.track("purchase_restored", properties);
313
314
  }
314
315
  /**
@@ -0,0 +1,45 @@
1
+ /**
2
+ * RampKit Logger
3
+ * Centralized logging with verbose mode support
4
+ *
5
+ * Like RevenueCat, the SDK logs minimal information by default.
6
+ * Enable verbose logging during development to see detailed logs.
7
+ */
8
+ /**
9
+ * Set verbose logging mode
10
+ * When enabled, additional debug information will be logged
11
+ */
12
+ export declare function setVerboseLogging(enabled: boolean): void;
13
+ /**
14
+ * Check if verbose logging is enabled
15
+ */
16
+ export declare function isVerboseLogging(): boolean;
17
+ /**
18
+ * RampKit Logger
19
+ * - info(): Always logged - important SDK status messages
20
+ * - verbose(): Only logged when verboseLogging is enabled
21
+ * - warn(): Always logged - warnings that don't break functionality
22
+ * - error(): Always logged - errors that affect functionality
23
+ */
24
+ export declare const Logger: {
25
+ /**
26
+ * Log important status messages (always shown)
27
+ * Use sparingly - only for SDK lifecycle events
28
+ */
29
+ info(message: string, ...args: any[]): void;
30
+ /**
31
+ * Log detailed debug information (only when verbose mode enabled)
32
+ * Use for step-by-step progress, variable values, etc.
33
+ */
34
+ verbose(message: string, ...args: any[]): void;
35
+ /**
36
+ * Log warnings (always shown)
37
+ * Use for recoverable issues, deprecations, or unexpected states
38
+ */
39
+ warn(message: string, ...args: any[]): void;
40
+ /**
41
+ * Log errors (always shown)
42
+ * Use for failures that affect SDK functionality
43
+ */
44
+ error(message: string, ...args: any[]): void;
45
+ };
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ /**
3
+ * RampKit Logger
4
+ * Centralized logging with verbose mode support
5
+ *
6
+ * Like RevenueCat, the SDK logs minimal information by default.
7
+ * Enable verbose logging during development to see detailed logs.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.Logger = void 0;
11
+ exports.setVerboseLogging = setVerboseLogging;
12
+ exports.isVerboseLogging = isVerboseLogging;
13
+ let verboseLogging = false;
14
+ /**
15
+ * Set verbose logging mode
16
+ * When enabled, additional debug information will be logged
17
+ */
18
+ function setVerboseLogging(enabled) {
19
+ verboseLogging = enabled;
20
+ }
21
+ /**
22
+ * Check if verbose logging is enabled
23
+ */
24
+ function isVerboseLogging() {
25
+ return verboseLogging;
26
+ }
27
+ /**
28
+ * RampKit Logger
29
+ * - info(): Always logged - important SDK status messages
30
+ * - verbose(): Only logged when verboseLogging is enabled
31
+ * - warn(): Always logged - warnings that don't break functionality
32
+ * - error(): Always logged - errors that affect functionality
33
+ */
34
+ exports.Logger = {
35
+ /**
36
+ * Log important status messages (always shown)
37
+ * Use sparingly - only for SDK lifecycle events
38
+ */
39
+ info(message, ...args) {
40
+ console.log(`[RampKit] ${message}`, ...args);
41
+ },
42
+ /**
43
+ * Log detailed debug information (only when verbose mode enabled)
44
+ * Use for step-by-step progress, variable values, etc.
45
+ */
46
+ verbose(message, ...args) {
47
+ if (verboseLogging) {
48
+ console.log(`[RampKit] ${message}`, ...args);
49
+ }
50
+ },
51
+ /**
52
+ * Log warnings (always shown)
53
+ * Use for recoverable issues, deprecations, or unexpected states
54
+ */
55
+ warn(message, ...args) {
56
+ console.warn(`[RampKit] ${message}`, ...args);
57
+ },
58
+ /**
59
+ * Log errors (always shown)
60
+ * Use for failures that affect SDK functionality
61
+ */
62
+ error(message, ...args) {
63
+ console.error(`[RampKit] ${message}`, ...args);
64
+ },
65
+ };
@@ -1,42 +1,25 @@
1
1
  /**
2
2
  * OnboardingResponseStorage
3
- * Manages persistent storage of onboarding state variables
3
+ * Manages persistent storage of onboarding variables
4
4
  */
5
5
  /**
6
- * Represents the stored onboarding state
7
- */
8
- export interface OnboardingState {
9
- /** The state variables as key-value pairs */
10
- variables: Record<string, any>;
11
- /** ISO 8601 timestamp when the state was last updated */
12
- updatedAt: string;
13
- }
14
- /**
15
- * Manages persistent storage of onboarding state variables
6
+ * Manages persistent storage of onboarding variables
16
7
  */
17
8
  export declare const OnboardingResponseStorage: {
18
9
  /**
19
- * Initialize the state with initial values from onboarding config
20
- * This should be called when onboarding starts
21
- */
22
- initializeState(initialVariables: Record<string, any>): Promise<void>;
23
- /**
24
- * Update state with new variable values (merges with existing)
10
+ * Initialize with initial values from onboarding config
25
11
  */
26
- updateState(newVariables: Record<string, any>): Promise<void>;
12
+ initializeVariables(initialVariables: Record<string, any>): Promise<void>;
27
13
  /**
28
- * Retrieve the stored state
29
- * @returns OnboardingState object with variables and timestamp
14
+ * Update variables (merges with existing)
30
15
  */
31
- retrieveState(): Promise<OnboardingState>;
16
+ updateVariables(newVariables: Record<string, any>): Promise<void>;
32
17
  /**
33
- * Retrieve just the variables (convenience method)
34
- * @returns Record of variable name to value
18
+ * Get stored variables
35
19
  */
36
- retrieveVariables(): Promise<Record<string, any>>;
20
+ getVariables(): Promise<Record<string, any>>;
37
21
  /**
38
- * Clear all stored state
22
+ * Clear all stored variables
39
23
  */
40
- clearState(): Promise<void>;
41
- clearResponses(): Promise<void>;
24
+ clearVariables(): Promise<void>;
42
25
  };
@@ -1,98 +1,69 @@
1
1
  "use strict";
2
2
  /**
3
3
  * OnboardingResponseStorage
4
- * Manages persistent storage of onboarding state variables
4
+ * Manages persistent storage of onboarding variables
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.OnboardingResponseStorage = void 0;
8
8
  const RampKitNative_1 = require("./RampKitNative");
9
9
  const constants_1 = require("./constants");
10
+ const Logger_1 = require("./Logger");
10
11
  /**
11
- * Manages persistent storage of onboarding state variables
12
+ * Manages persistent storage of onboarding variables
12
13
  */
13
14
  exports.OnboardingResponseStorage = {
14
15
  /**
15
- * Initialize the state with initial values from onboarding config
16
- * This should be called when onboarding starts
16
+ * Initialize with initial values from onboarding config
17
17
  */
18
- async initializeState(initialVariables) {
18
+ async initializeVariables(initialVariables) {
19
19
  try {
20
- const state = {
21
- variables: { ...initialVariables },
22
- updatedAt: new Date().toISOString(),
23
- };
24
- await (0, RampKitNative_1.setStoredValue)(constants_1.STORAGE_KEYS.ONBOARDING_RESPONSES, JSON.stringify(state));
25
- if (__DEV__) {
26
- console.log("[RampKit] Initialized onboarding state:", initialVariables);
27
- }
20
+ await (0, RampKitNative_1.setStoredValue)(constants_1.STORAGE_KEYS.ONBOARDING_RESPONSES, JSON.stringify(initialVariables));
21
+ Logger_1.Logger.verbose("Initialized onboarding variables");
28
22
  }
29
23
  catch (error) {
30
- console.warn("[RampKit] Failed to initialize onboarding state:", error);
24
+ Logger_1.Logger.warn("Failed to initialize onboarding variables:", error);
31
25
  }
32
26
  },
33
27
  /**
34
- * Update state with new variable values (merges with existing)
28
+ * Update variables (merges with existing)
35
29
  */
36
- async updateState(newVariables) {
30
+ async updateVariables(newVariables) {
37
31
  try {
38
- const currentState = await this.retrieveState();
39
- const updatedState = {
40
- variables: {
41
- ...currentState.variables,
42
- ...newVariables,
43
- },
44
- updatedAt: new Date().toISOString(),
45
- };
46
- await (0, RampKitNative_1.setStoredValue)(constants_1.STORAGE_KEYS.ONBOARDING_RESPONSES, JSON.stringify(updatedState));
47
- if (__DEV__) {
48
- console.log("[RampKit] Updated onboarding state:", newVariables);
49
- }
32
+ const current = await this.getVariables();
33
+ const merged = { ...current, ...newVariables };
34
+ await (0, RampKitNative_1.setStoredValue)(constants_1.STORAGE_KEYS.ONBOARDING_RESPONSES, JSON.stringify(merged));
35
+ Logger_1.Logger.verbose("Updated onboarding variables");
50
36
  }
51
37
  catch (error) {
52
- console.warn("[RampKit] Failed to update onboarding state:", error);
38
+ Logger_1.Logger.warn("Failed to update onboarding variables:", error);
53
39
  }
54
40
  },
55
41
  /**
56
- * Retrieve the stored state
57
- * @returns OnboardingState object with variables and timestamp
42
+ * Get stored variables
58
43
  */
59
- async retrieveState() {
44
+ async getVariables() {
60
45
  try {
61
46
  const jsonString = await (0, RampKitNative_1.getStoredValue)(constants_1.STORAGE_KEYS.ONBOARDING_RESPONSES);
62
47
  if (!jsonString) {
63
- return { variables: {}, updatedAt: "" };
48
+ return {};
64
49
  }
65
50
  return JSON.parse(jsonString);
66
51
  }
67
52
  catch (error) {
68
- console.warn("[RampKit] Failed to retrieve onboarding state:", error);
69
- return { variables: {}, updatedAt: "" };
53
+ Logger_1.Logger.warn("Failed to retrieve onboarding variables:", error);
54
+ return {};
70
55
  }
71
56
  },
72
57
  /**
73
- * Retrieve just the variables (convenience method)
74
- * @returns Record of variable name to value
58
+ * Clear all stored variables
75
59
  */
76
- async retrieveVariables() {
77
- const state = await this.retrieveState();
78
- return state.variables;
79
- },
80
- /**
81
- * Clear all stored state
82
- */
83
- async clearState() {
60
+ async clearVariables() {
84
61
  try {
85
62
  await (0, RampKitNative_1.setStoredValue)(constants_1.STORAGE_KEYS.ONBOARDING_RESPONSES, "");
86
- if (__DEV__) {
87
- console.log("[RampKit] Cleared onboarding state");
88
- }
63
+ Logger_1.Logger.verbose("Cleared onboarding variables");
89
64
  }
90
65
  catch (error) {
91
- console.warn("[RampKit] Failed to clear onboarding state:", error);
66
+ Logger_1.Logger.warn("Failed to clear onboarding variables:", error);
92
67
  }
93
68
  },
94
- // Legacy aliases for backwards compatibility
95
- async clearResponses() {
96
- return this.clearState();
97
- },
98
69
  };
@@ -3,7 +3,6 @@
3
3
  * Main SDK class for RampKit Expo integration
4
4
  */
5
5
  import { DeviceInfo, RampKitConfig, EventContext } from "./types";
6
- import { OnboardingState } from "./OnboardingResponseStorage";
7
6
  export declare class RampKitCore {
8
7
  private static _instance;
9
8
  private config;
@@ -63,19 +62,13 @@ export declare class RampKitCore {
63
62
  */
64
63
  isInitialized(): boolean;
65
64
  /**
66
- * Get all stored onboarding state variables
67
- * @returns Promise resolving to OnboardingState with variables and timestamp
65
+ * Get all user answers from onboarding
68
66
  */
69
- getOnboardingState(): Promise<OnboardingState>;
67
+ getAnswers(): Promise<Record<string, any>>;
70
68
  /**
71
- * Get just the onboarding variables (convenience method)
72
- * @returns Promise resolving to Record of variable name to value
69
+ * Get a single answer by key
73
70
  */
74
- getOnboardingVariables(): Promise<Record<string, any>>;
75
- /**
76
- * @deprecated Use getOnboardingState() or getOnboardingVariables() instead
77
- */
78
- getOnboardingResponses(): Promise<Record<string, any>>;
71
+ getAnswer(key: string): Promise<any>;
79
72
  /**
80
73
  * Show the onboarding overlay
81
74
  */