@magicpixel/rn-mp-client-sdk 1.13.0 → 1.13.20

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.
Files changed (104) hide show
  1. package/README.md +163 -14
  2. package/lib/commonjs/common/app-types.js.map +1 -1
  3. package/lib/commonjs/common/constants.js +11 -2
  4. package/lib/commonjs/common/constants.js.map +1 -1
  5. package/lib/commonjs/common/data-store.js +13 -30
  6. package/lib/commonjs/common/data-store.js.map +1 -1
  7. package/lib/commonjs/common/deeplink-helper.js +174 -0
  8. package/lib/commonjs/common/deeplink-helper.js.map +1 -0
  9. package/lib/commonjs/common/device-info-helper.js +168 -0
  10. package/lib/commonjs/common/device-info-helper.js.map +1 -0
  11. package/lib/commonjs/common/event-bus.js +39 -0
  12. package/lib/commonjs/common/event-bus.js.map +1 -1
  13. package/lib/commonjs/common/network-service.js +119 -15
  14. package/lib/commonjs/common/network-service.js.map +1 -1
  15. package/lib/commonjs/common/reporter.js +28 -10
  16. package/lib/commonjs/common/reporter.js.map +1 -1
  17. package/lib/commonjs/common/storage-helper.js +227 -0
  18. package/lib/commonjs/common/storage-helper.js.map +1 -0
  19. package/lib/commonjs/common/utils.js +20 -2
  20. package/lib/commonjs/common/utils.js.map +1 -1
  21. package/lib/commonjs/eedl/eedl.js +198 -44
  22. package/lib/commonjs/eedl/eedl.js.map +1 -1
  23. package/lib/commonjs/index.js +290 -48
  24. package/lib/commonjs/index.js.map +1 -1
  25. package/lib/commonjs/models/mp-client-sdk.js +17 -10
  26. package/lib/commonjs/models/mp-client-sdk.js.map +1 -1
  27. package/lib/commonjs/processors/data-element.processor.js +51 -7
  28. package/lib/commonjs/processors/data-element.processor.js.map +1 -1
  29. package/lib/commonjs/processors/visit-id.processor.js +78 -15
  30. package/lib/commonjs/processors/visit-id.processor.js.map +1 -1
  31. package/lib/module/common/app-types.js.map +1 -1
  32. package/lib/module/common/constants.js +11 -2
  33. package/lib/module/common/constants.js.map +1 -1
  34. package/lib/module/common/data-store.js +13 -30
  35. package/lib/module/common/data-store.js.map +1 -1
  36. package/lib/module/common/deeplink-helper.js +168 -0
  37. package/lib/module/common/deeplink-helper.js.map +1 -0
  38. package/lib/module/common/device-info-helper.js +161 -0
  39. package/lib/module/common/device-info-helper.js.map +1 -0
  40. package/lib/module/common/event-bus.js +39 -0
  41. package/lib/module/common/event-bus.js.map +1 -1
  42. package/lib/module/common/network-service.js +119 -15
  43. package/lib/module/common/network-service.js.map +1 -1
  44. package/lib/module/common/reporter.js +29 -10
  45. package/lib/module/common/reporter.js.map +1 -1
  46. package/lib/module/common/storage-helper.js +221 -0
  47. package/lib/module/common/storage-helper.js.map +1 -0
  48. package/lib/module/common/utils.js +20 -2
  49. package/lib/module/common/utils.js.map +1 -1
  50. package/lib/module/eedl/eedl.js +198 -44
  51. package/lib/module/eedl/eedl.js.map +1 -1
  52. package/lib/module/index.js +279 -47
  53. package/lib/module/index.js.map +1 -1
  54. package/lib/module/models/mp-client-sdk.js +16 -9
  55. package/lib/module/models/mp-client-sdk.js.map +1 -1
  56. package/lib/module/processors/data-element.processor.js +51 -7
  57. package/lib/module/processors/data-element.processor.js.map +1 -1
  58. package/lib/module/processors/visit-id.processor.js +78 -15
  59. package/lib/module/processors/visit-id.processor.js.map +1 -1
  60. package/lib/typescript/{common → src/common}/app-types.d.ts +29 -9
  61. package/lib/typescript/{common → src/common}/constants.d.ts +0 -1
  62. package/lib/typescript/{common → src/common}/data-store.d.ts +3 -8
  63. package/lib/typescript/src/common/deeplink-helper.d.ts +60 -0
  64. package/lib/typescript/src/common/device-info-helper.d.ts +54 -0
  65. package/lib/typescript/src/common/event-bus.d.ts +21 -0
  66. package/lib/typescript/src/common/network-service.d.ts +32 -0
  67. package/lib/typescript/src/common/storage-helper.d.ts +47 -0
  68. package/lib/typescript/{common → src/common}/utils.d.ts +7 -0
  69. package/lib/typescript/{eedl → src/eedl}/eedl.d.ts +43 -1
  70. package/lib/typescript/{index.d.ts → src/index.d.ts} +39 -5
  71. package/lib/typescript/{models → src/models}/mp-client-sdk.d.ts +7 -0
  72. package/lib/typescript/src/processors/visit-id.processor.d.ts +23 -0
  73. package/package.json +26 -37
  74. package/src/common/app-types.ts +32 -10
  75. package/src/common/constants.ts +0 -6
  76. package/src/common/data-store.ts +8 -30
  77. package/src/common/deeplink-helper.ts +181 -0
  78. package/src/common/device-info-helper.ts +190 -0
  79. package/src/common/event-bus.ts +39 -0
  80. package/src/common/network-service.ts +154 -21
  81. package/src/common/reporter.ts +31 -10
  82. package/src/common/storage-helper.ts +266 -0
  83. package/src/common/utils.ts +20 -2
  84. package/src/eedl/eedl.ts +225 -51
  85. package/src/index.tsx +332 -67
  86. package/src/models/mp-client-sdk.ts +8 -0
  87. package/src/processors/data-element.processor.ts +85 -7
  88. package/src/processors/visit-id.processor.ts +92 -22
  89. package/lib/commonjs/processors/trans-function.processor.js +0 -73
  90. package/lib/commonjs/processors/trans-function.processor.js.map +0 -1
  91. package/lib/module/processors/trans-function.processor.js +0 -66
  92. package/lib/module/processors/trans-function.processor.js.map +0 -1
  93. package/lib/typescript/common/event-bus.d.ts +0 -6
  94. package/lib/typescript/common/network-service.d.ts +0 -8
  95. package/lib/typescript/processors/trans-function.processor.d.ts +0 -12
  96. package/lib/typescript/processors/visit-id.processor.d.ts +0 -9
  97. package/src/processors/trans-function.processor.ts +0 -85
  98. /package/lib/typescript/{common → src/common}/logger.d.ts +0 -0
  99. /package/lib/typescript/{common → src/common}/reporter.d.ts +0 -0
  100. /package/lib/typescript/{models → src/models}/geo-api-response.d.ts +0 -0
  101. /package/lib/typescript/{processors → src/processors}/data-element.processor.d.ts +0 -0
  102. /package/lib/typescript/{processors → src/processors}/geo-location.processor.d.ts +0 -0
  103. /package/lib/typescript/{processors → src/processors}/qc.processor.d.ts +0 -0
  104. /package/lib/typescript/{processors → src/processors}/tag.processor.d.ts +0 -0
@@ -0,0 +1,60 @@
1
+ export declare enum DeepLinkType {
2
+ CUSTOM_SCHEME = "custom_scheme",
3
+ UNIVERSAL_LINK = "universal_link",
4
+ APP_LINK = "app_link",
5
+ HTTP_LINK = "http_link"
6
+ }
7
+ /**
8
+ * Helper class to automatically detect and handle deeplinks
9
+ *
10
+ * Supports multiple link types:
11
+ * 1. Custom URL Schemes: myapp://product/123
12
+ * 2. Universal Links (iOS): https://my-site.com/product/123
13
+ * 3. App Links (Android): https://my-site.com/product/123
14
+ * 4. HTTP Links: http://my-site.com/product/123
15
+ *
16
+ * Common use cases:
17
+ * - Ad clicks (Facebook, Google, TikTok ads with http/https URLs)
18
+ * - Push notification deep links
19
+ * - Email marketing links
20
+ * - SMS campaign links
21
+ * - QR codes
22
+ */
23
+ export declare class DeepLinkHelper {
24
+ private static listener;
25
+ private static onDeepLinkCallback;
26
+ /**
27
+ * Determine the type of deeplink
28
+ * @param url The URL to analyze
29
+ * @returns The type of deeplink
30
+ */
31
+ static getLinkType(url: string): DeepLinkType;
32
+ /**
33
+ * Initialize deeplink detection
34
+ * - Checks if app was opened with initial URL (custom scheme, universal link, or HTTP link)
35
+ * - Sets up listener for deeplinks while app is running
36
+ * @param callback Optional callback to be notified when deeplink is detected
37
+ * @returns The initial URL if app was opened with deeplink, null otherwise
38
+ */
39
+ static initialize(callback?: (url: string, linkType: DeepLinkType) => void): Promise<string | null>;
40
+ /**
41
+ * Set up listener for deeplinks received while app is running
42
+ * Works for all link types: custom schemes, universal links, app links, HTTP links
43
+ */
44
+ private static setupListener;
45
+ /**
46
+ * Handle deeplink URL - notify callback if registered
47
+ * @param url The deeplink URL
48
+ */
49
+ private static handleDeepLink;
50
+ /**
51
+ * Remove deeplink listener and clear callback
52
+ */
53
+ static cleanup(): void;
54
+ /**
55
+ * Parse UTM parameters and other campaign data from URL
56
+ * @param url The deeplink URL
57
+ * @returns Object containing campaign parameters
58
+ */
59
+ static parseCampaignParams(url: string): Record<string, string>;
60
+ }
@@ -0,0 +1,54 @@
1
+ interface DeviceAppInfo {
2
+ app_version: string;
3
+ build_number: string;
4
+ package_name: string;
5
+ device_model_name: string;
6
+ device_manufacturer: string;
7
+ device_id: string;
8
+ os_name: string;
9
+ os_version: string;
10
+ is_tablet: boolean;
11
+ is_emulator: boolean;
12
+ }
13
+ /**
14
+ * Helper class to automatically detect device and app information
15
+ * Supports both Expo and bare React Native:
16
+ * 1. Tries Expo modules first (works in Expo Go)
17
+ * 2. Falls back to react-native-device-info (for bare RN)
18
+ * 3. Returns safe defaults if neither is available
19
+ */
20
+ export declare class DeviceInfoHelper {
21
+ private static expoApplication;
22
+ private static expoDevice;
23
+ private static expoConstants;
24
+ private static deviceInfo;
25
+ private static initialized;
26
+ /**
27
+ * Try to load Expo modules and react-native-device-info
28
+ * This uses dynamic imports to avoid errors when modules aren't available
29
+ */
30
+ private static initialize;
31
+ /**
32
+ * Get comprehensive app and device information
33
+ * All methods are async-safe and handle errors gracefully
34
+ */
35
+ static getAppInfo(): Promise<DeviceAppInfo>;
36
+ /**
37
+ * Get device info using Expo modules (works in Expo Go)
38
+ */
39
+ private static getAppInfoFromExpo;
40
+ /**
41
+ * Get device info using react-native-device-info (for bare RN)
42
+ */
43
+ private static getAppInfoFromDeviceInfo;
44
+ /**
45
+ * Safe default values when no device info library is available
46
+ */
47
+ private static getSafeDefaults;
48
+ /**
49
+ * Get app version in format: "1.0.0 (123)"
50
+ * Combines version and build number for better tracking
51
+ */
52
+ static getFormattedAppVersion(): Promise<string>;
53
+ }
54
+ export {};
@@ -0,0 +1,21 @@
1
+ import type { EventBusCallback } from './app-types';
2
+ export declare class EventBus {
3
+ private static eventRegister;
4
+ static on(eventName: string, callback: EventBusCallback): void;
5
+ /**
6
+ * Remove a specific callback for an event
7
+ * @param eventName Event name to remove callback from
8
+ * @param callback The callback function to remove
9
+ */
10
+ static off(eventName: string, callback: EventBusCallback): void;
11
+ /**
12
+ * Remove all callbacks for a specific event
13
+ * @param eventName Event name to clear all listeners for
14
+ */
15
+ static clearEvent(eventName: string): void;
16
+ /**
17
+ * Remove all event listeners (used during SDK shutdown)
18
+ */
19
+ static clearAll(): void;
20
+ static triggerEvent(eventName: string, payload: any): void;
21
+ }
@@ -0,0 +1,32 @@
1
+ import type { MapLike, SdkInitOptions, VisitorInfo } from './app-types';
2
+ export declare class NetworkService {
3
+ /**
4
+ * Sleep for a specified duration
5
+ */
6
+ private static sleep;
7
+ /**
8
+ * Fetch with timeout wrapper
9
+ */
10
+ private static fetchWithTimeout;
11
+ /**
12
+ * Fetch visitor/identity info from server
13
+ * Returns null if fetch fails (caller should handle retry logic)
14
+ */
15
+ static fetchIdlInfo(url: string): Promise<VisitorInfo | null>;
16
+ /**
17
+ * Fetch visitor/identity info with retry logic
18
+ * @param url The IDL URL
19
+ * @param retries Number of retries (default: 3)
20
+ * @returns VisitorInfo or null if all retries fail
21
+ */
22
+ static fetchIdlInfoWithRetry(url: string, retries?: number): Promise<VisitorInfo | null>;
23
+ /**
24
+ * Refresh client SDK JSON configuration with retry logic
25
+ * @param sdkInitOptions SDK initialization options
26
+ * @returns true if successful, throws Error if all retries fail
27
+ */
28
+ static refreshClientSdkJson(sdkInitOptions: SdkInitOptions): Promise<void>;
29
+ static sendPostRequest(url: string, body: MapLike): void;
30
+ static sendGetRequest(url: string): void;
31
+ private static sendNetworkRequest;
32
+ }
@@ -0,0 +1,47 @@
1
+ import { DeStorageDuration } from '../models/mp-client-sdk';
2
+ export declare class StorageHelper {
3
+ private static sessionStore;
4
+ private static visitorStoreCache;
5
+ private static isInitialized;
6
+ /**
7
+ * Initialize the storage helper
8
+ * Loads visitor store from AsyncStorage and cleans expired values
9
+ * Should be called once during SDK initialization
10
+ */
11
+ static initialize(): Promise<void>;
12
+ /**
13
+ * Clear visitor-scoped values older than 30 days
14
+ */
15
+ static clearExpiredVisitorData(): Promise<void>;
16
+ /**
17
+ * Persist the visitor store cache to AsyncStorage
18
+ */
19
+ private static persistVisitorStore;
20
+ /**
21
+ * Check if a value is defined (not null, undefined, or empty string)
22
+ */
23
+ private static isDefined;
24
+ /**
25
+ * Store a data element value based on storage duration
26
+ * @param deKey - The data element key
27
+ * @param value - The value to store
28
+ * @param storageDuration - The storage duration type
29
+ */
30
+ static deStorageDurationSet(deKey: string, value: any, storageDuration: DeStorageDuration): void;
31
+ /**
32
+ * Retrieve a data element value based on storage duration
33
+ * @param deKey - The data element key
34
+ * @param defaultValue - Default value if not found
35
+ * @param storageDuration - The storage duration type
36
+ * @returns The stored value or default value
37
+ */
38
+ static deStorageDurationGet(deKey: string, defaultValue: any, storageDuration: DeStorageDuration): any;
39
+ /**
40
+ * Clear all session-scoped values (called on new session if needed)
41
+ */
42
+ static clearSessionStore(): void;
43
+ /**
44
+ * Clear all visitor-scoped values
45
+ */
46
+ static clearVisitorStore(): Promise<void>;
47
+ }
@@ -33,6 +33,13 @@ export declare class Utils {
33
33
  static regExpEscape(input: string): string;
34
34
  static convertToRegex(input: string, ignoreCase: boolean, fullMatch: boolean): RegExp;
35
35
  static safeExecute(fn: (payload: any) => any, payload: any): any;
36
+ /**
37
+ * Encode string to Base64 - React Native compatible
38
+ * Works with both ASCII and UTF-8 strings
39
+ * @param str String to encode
40
+ * @returns Base64 encoded string
41
+ */
42
+ static toBase64(str: string): string;
36
43
  static getUniqueID(): string;
37
44
  /**
38
45
  * Make HTTP GET request - React Native implementation
@@ -11,9 +11,43 @@ export declare class MpDataLayerHelper {
11
11
  dlInitEvent: string;
12
12
  receivedInitialEvent: boolean;
13
13
  eventQueue: Array<any>;
14
+ private isProcessing;
14
15
  private isEntryPoint;
16
+ private eventDedupWindowMs;
17
+ private eventDeduplicationCache;
18
+ private purchaseTransactionCache;
15
19
  constructor(dlEventName: string, dlInitMode: string, dlInitEvent: string, storageKeyName?: string);
16
20
  init(globalEventListeners: Record<string, EventProcessorFn>): Promise<void>;
21
+ /**
22
+ * Set the event deduplication window
23
+ * @param windowMs Window in milliseconds (0 to disable)
24
+ */
25
+ setDeduplicationWindow(windowMs: number): void;
26
+ /**
27
+ * Generate a unique fingerprint for an event
28
+ * @param eventName Event name
29
+ * @param payload Event payload
30
+ * @returns Fingerprint string
31
+ */
32
+ private getEventFingerprint;
33
+ /**
34
+ * Extract transaction_id from purchase event payload
35
+ * @param payload Event payload
36
+ * @returns transaction_id or null
37
+ */
38
+ private extractTransactionId;
39
+ /**
40
+ * Check if event is a duplicate within the deduplication window
41
+ * @param eventName Event name
42
+ * @param payload Event payload
43
+ * @returns true if duplicate, false otherwise
44
+ */
45
+ private isDuplicateEvent;
46
+ /**
47
+ * Remove expired entries from deduplication caches
48
+ * @param now Current timestamp
49
+ */
50
+ private cleanupDeduplicationCache;
17
51
  pushEvent(eventName: string, payload: MapLike): void;
18
52
  processQItems(eventName: string, payload: MapLike): Promise<void>;
19
53
  /**
@@ -50,8 +84,16 @@ export declare class MpDataLayerHelper {
50
84
  getState(): TypedAny[];
51
85
  hasEventHappened(key: string): boolean;
52
86
  reset(): boolean;
87
+ /**
88
+ * Full shutdown - clears all state and allows reinitialization
89
+ */
90
+ shutdown(): void;
53
91
  ready(): void;
54
- drainQueue(): Promise<void>;
92
+ /**
93
+ * Process next event in queue with atomic check-and-set
94
+ * Ensures only one event processes at a time, eliminating race conditions
95
+ */
96
+ processNext(): void;
55
97
  getIsEntryPointValue(): number;
56
98
  resetEntryPointInfo(): void;
57
99
  }
@@ -1,26 +1,60 @@
1
- import type { AppCustomerInfo, AppPageLoad, MapLike, MpDeviceInfo, SdkInitOptions } from './common/app-types';
1
+ import 'react-native-get-random-values';
2
+ import type { AppCustomerInfo, AppPageLoad, MapLike, SdkInitOptions } from './common/app-types';
2
3
  import { EventBus } from './common/event-bus';
3
4
  declare class MagicPixelImpl {
4
5
  private static dl;
5
6
  private static customerInfo;
6
7
  private static customerIdentifiers;
7
8
  private static deepLinkUrl;
9
+ private static orgId;
8
10
  private static firstAppLaunch;
9
- static init(options: SdkInitOptions): Promise<void>;
11
+ private static isReady;
12
+ private static isInitializing;
13
+ private static eventBuffer;
14
+ private static onInitFailureCallback;
15
+ /**
16
+ * Initialize the MagicPixel SDK
17
+ * This method is synchronous - it stores config immediately and runs async setup in background
18
+ * Events called before async setup completes are buffered and processed once ready
19
+ * @param options SDK initialization options
20
+ */
21
+ static init(options: SdkInitOptions): void;
22
+ /**
23
+ * Shutdown the SDK and release all resources
24
+ * Call this when the app is closing or when you need to reinitialize the SDK
25
+ * After shutdown, you must call init() again to use the SDK
26
+ */
27
+ static shutdown(): void;
28
+ /**
29
+ * Async initialization - runs in background
30
+ */
31
+ private static initAsync;
10
32
  static recordEvent(eventName: string, payload: MapLike): void;
33
+ private static processRecordEvent;
11
34
  static ready(): void;
35
+ /**
36
+ * Flush buffered events after SDK is ready
37
+ * Events are processed in the order they were received
38
+ */
39
+ private static flushEventBuffer;
12
40
  static getDebugId(): string;
13
- private static checkAndFireTM;
14
41
  private static runTM;
15
42
  private static _fireTM;
16
43
  private static _fireTMPrivate;
17
44
  static setCustomerInfo(customerInfo: AppCustomerInfo): void;
18
45
  static setFirebaseAppInstanceId(instanceId: string): void;
19
46
  static setDeepLinkUrl(deepLinkUrl: string): void;
20
- static setDeviceInfo(deviceInfo: MpDeviceInfo): void;
47
+ /**
48
+ * Set device info with auto-detected values
49
+ * Standard fields (os_version, device_model_name, package_name) are always auto-detected
50
+ * Optional customFields parameter allows adding custom tracking fields only
51
+ * @param customFields Optional custom fields to add (cannot override standard fields)
52
+ */
53
+ static setDeviceInfo(customFields?: Record<string, any>): Promise<void>;
21
54
  static setFacebookClientId(fbp: string): void;
22
55
  private static setAppVersion;
23
56
  static recordPageLoad(pageLoadInfo: AppPageLoad): void;
57
+ private static processRecordPageLoad;
24
58
  /**
25
59
  * Set user information for tracking
26
60
  * @param userInfo User information object
@@ -77,4 +111,4 @@ declare class MagicPixelImpl {
77
111
  }
78
112
  export declare const MagicPixelEventBus: typeof EventBus;
79
113
  export declare const MagicPixel: typeof MagicPixelImpl;
80
- export {};
114
+ export { DeepLinkHelper, DeepLinkType } from './common/deeplink-helper';
@@ -9,6 +9,13 @@ export interface ClientSdkDeItem {
9
9
  fn?: (deHelper: any, input: any) => any;
10
10
  isAsync?: boolean;
11
11
  fnTOut?: number;
12
+ stDur?: DeStorageDuration;
13
+ }
14
+ export declare enum DeStorageDuration {
15
+ NONE = "NONE",
16
+ EVENT = "EVENT",
17
+ SESSION = "SESSION",
18
+ VISITOR = "VISITOR"
12
19
  }
13
20
  export declare enum ParamResourceEncodingType {
14
21
  URL_ENC = "URL_ENC",
@@ -0,0 +1,23 @@
1
+ export declare class VisitIdProcessor {
2
+ private static visitorIdFetchFailed;
3
+ static init(orgId: string): Promise<void>;
4
+ /**
5
+ * Check if visitor ID needs to be retried
6
+ * Called on each page_load to retry if initial fetch failed
7
+ */
8
+ static retryVisitorIdIfNeeded(): Promise<void>;
9
+ /**
10
+ * Check if visitor ID is available
11
+ */
12
+ static hasVisitorId(): boolean;
13
+ static isFirstOpenAfterInstall(): Promise<boolean>;
14
+ static getFacebookFBP(): Promise<string>;
15
+ static initDebugId(orgId: string): Promise<void>;
16
+ static setOrResetVisitInfo(incrementDepth: boolean): Promise<void>;
17
+ /**
18
+ * Synchronously increment visit depth in memory, persist to storage in background
19
+ * This prevents race conditions when multiple page_load events fire quickly
20
+ */
21
+ static incrementVisitDepth(): void;
22
+ static setOrResetVisitorId(): Promise<void>;
23
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@magicpixel/rn-mp-client-sdk",
3
- "version": "1.13.0",
4
- "description": "test",
3
+ "version": "1.13.20",
4
+ "description": "React Native SDK for MagicPixel analytics and tag management",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
7
7
  "types": "lib/typescript/index.d.ts",
@@ -10,40 +10,36 @@
10
10
  "files": [
11
11
  "src",
12
12
  "lib",
13
- "android",
14
- "ios",
15
- "cpp",
16
- "rn-mp-client-sdk.podspec",
17
13
  "!lib/typescript/example",
18
- "!android/build",
19
- "!ios/build",
20
14
  "!**/__tests__",
21
15
  "!**/__fixtures__",
22
16
  "!**/__mocks__"
23
17
  ],
24
18
  "scripts": {
25
- "test": "jest",
19
+ "test": "echo 'No tests configured'",
26
20
  "typescript": "tsc --noEmit",
27
21
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
28
22
  "prepare": "bob build",
29
23
  "release": "release-it",
30
24
  "example": "yarn --cwd example",
31
25
  "bootstrap": "yarn example && yarn && yarn example pods",
32
- "postpublish": "node quick-version-increment.js",
33
- "localpublish": "npm publish --@magicpixel:registry=http://localhost:4873 && npm run postpublish"
26
+ "localpublish": "npm publish --@magicpixel:registry=http://localhost:4873"
34
27
  },
35
28
  "keywords": [
36
29
  "react-native",
37
30
  "ios",
38
31
  "android"
39
32
  ],
40
- "repository": "https://github.com/mp",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git@github.com:digital-madtech/mp-rn-client-sdk.git"
36
+ },
41
37
  "author": "MP Engineering <engineering@magicpixel.io> (https://magicpixel.io)",
42
38
  "license": "MIT",
43
39
  "bugs": {
44
- "url": "https://github.com/mp/issues"
40
+ "url": "https://github.com/digital-madtech/mp-rn-client-sdk/issues"
45
41
  },
46
- "homepage": "https://github.com/mp#readme",
42
+ "homepage": "https://github.com/digital-madtech/mp-rn-client-sdk#readme",
47
43
  "publishConfig": {
48
44
  "registry": "https://registry.npmjs.org/",
49
45
  "access": "public"
@@ -53,38 +49,34 @@
53
49
  "@babel/eslint-parser": "7.19.1",
54
50
  "@babel/runtime": "7.26.10",
55
51
  "@commitlint/config-conventional": "17.1.0",
52
+ "@octokit/plugin-paginate-rest": "9.2.2",
53
+ "@octokit/request": "8.4.1",
54
+ "@octokit/request-error": "5.1.1",
56
55
  "@react-native-community/eslint-config": "3.1.0",
57
56
  "@release-it/conventional-changelog": "8.0.1",
58
57
  "@types/flat": "5.0.2",
59
- "@types/jest": "29.0.3",
60
- "@types/react": "~17.0.21",
58
+ "@types/react": "17.0.50",
61
59
  "@types/react-native": "0.72.8",
62
60
  "@types/uuid": "9.0.0",
61
+ "braces": "3.0.3",
63
62
  "commitlint": "17.1.2",
63
+ "cross-spawn": "7.0.5",
64
64
  "eslint": "8.23.1",
65
65
  "eslint-config-prettier": "8.5.0",
66
66
  "eslint-plugin-prettier": "4.2.1",
67
- "jest": "29.1.1",
67
+ "micromatch": "4.0.8",
68
68
  "pod-install": "0.1.38",
69
69
  "prettier": "2.7.1",
70
70
  "react": "18.2.0",
71
71
  "react-native": "0.72.17",
72
72
  "react-native-builder-bob": "0.18.3",
73
73
  "release-it": "17.1.1",
74
- "ts-jest": "29.0.2",
75
74
  "tsconfig-paths": "4.1.0",
76
75
  "typescript": "4.8.3",
77
- "ts-node": "10.9.1",
78
- "@octokit/plugin-paginate-rest": "9.2.2",
79
- "@octokit/request": "8.4.1",
80
- "@octokit/request-error": "5.1.1",
81
- "braces": "3.0.3",
82
- "cross-spawn": "7.0.5",
83
- "micromatch": "4.0.8",
84
76
  "ws": "7.5.10"
85
77
  },
86
78
  "resolutions": {
87
- "@types/react": "17.0.21",
79
+ "@types/react": "17.0.50",
88
80
  "ip": "2.0.2",
89
81
  "pac-resolver": "7.0.1",
90
82
  "socks": "2.7.3",
@@ -93,20 +85,14 @@
93
85
  "socks-proxy-agent": "8.0.2",
94
86
  "agent-base": "7.1.0"
95
87
  },
88
+ "overrides": {
89
+ "diff": "8.0.3",
90
+ "tmp": "0.2.4"
91
+ },
96
92
  "peerDependencies": {
97
93
  "react": "*",
98
94
  "react-native": "*"
99
95
  },
100
- "jest": {
101
- "preset": "react-native",
102
- "transform": {
103
- ".+\\.(t|j)s$": "ts-jest"
104
- },
105
- "modulePathIgnorePatterns": [
106
- "<rootDir>/example/node_modules",
107
- "<rootDir>/lib/"
108
- ]
109
- },
110
96
  "commitlint": {
111
97
  "extends": [
112
98
  "@commitlint/config-conventional"
@@ -174,7 +160,10 @@
174
160
  "flat": "5.0.2",
175
161
  "nanoid": "5.1.5",
176
162
  "performant-array-to-tree": "1.11.0",
163
+ "react-native-device-info": "15.0.1",
164
+ "react-native-get-random-values": "1.11.0",
177
165
  "react-native-url-polyfill": "1.3.0",
166
+ "ulid": "3.0.1",
178
167
  "uuid": "9.0.0"
179
168
  }
180
- }
169
+ }
@@ -4,14 +4,6 @@ export interface MapLike<T = any> {
4
4
  [key: string]: T;
5
5
  }
6
6
 
7
- export interface RunQueueModel {
8
- sseOnly: boolean;
9
- name: string;
10
- dcrName: string;
11
- eventId: string;
12
- dcrPayload?: Record<string, any>;
13
- }
14
-
15
7
  export type TypedAny = Record<
16
8
  string,
17
9
  | string
@@ -38,6 +30,7 @@ export interface AppCustomerInfo {
38
30
 
39
31
  export interface AppPageLoad {
40
32
  page_name: string;
33
+ page_url?: string;
41
34
  is_entry?: number;
42
35
  deep_link_url?: string;
43
36
  app_version?: string;
@@ -130,18 +123,47 @@ export interface SdkInitOptions {
130
123
  baseUrl: string;
131
124
  logLevel: string;
132
125
 
126
+ /**
127
+ * @deprecated device_type is now auto-detected and cannot be overridden
128
+ * This field is ignored. The SDK uses Expo/react-native-device-info for reliable detection.
129
+ */
133
130
  device_type?: string;
134
131
 
132
+ /**
133
+ * @deprecated app_version is now auto-detected and cannot be overridden
134
+ * This field is ignored. The SDK will always use the actual app version from the device.
135
+ */
135
136
  app_version?: string;
137
+
138
+ /**
139
+ * @deprecated os_version is now auto-detected and cannot be overridden
140
+ * This field is ignored. The SDK will always use the actual OS version from the device.
141
+ */
136
142
  os_version?: string;
143
+
144
+ /**
145
+ * Event deduplication window in milliseconds
146
+ * If the same event (name + payload) fires within this window, it will be skipped
147
+ * Purchase events are deduplicated by transaction_id regardless of other fields
148
+ * Default: 5000ms (5 seconds)
149
+ * Set to 0 to disable deduplication
150
+ */
151
+ eventDeduplicationWindowMs?: number;
152
+
153
+ /**
154
+ * Callback invoked when SDK initialization fails after all retries
155
+ * Use this to handle initialization failures gracefully in your app
156
+ * @param error The error that caused the failure
157
+ */
158
+ onInitFailure?: (error: Error) => void;
137
159
  }
138
160
 
139
161
  export interface MpDeviceInfo {
140
162
  package_name?: string; // app package name like com.company.starter
141
163
  short_version?: string;
142
164
  long_version?: string;
143
- os_version: string;
144
- device_model_name: string;
165
+ os_version?: string; // Will be auto-detected if not provided
166
+ device_model_name?: string; // Will be auto-detected if not provided
145
167
  locale?: string;
146
168
  timezone_abbreviation?: string;
147
169
  carrier?: string;
@@ -1,14 +1,8 @@
1
- import { customAlphabet } from 'nanoid/non-secure';
2
1
  import type { BaseResourceParamType } from '../models/mp-client-sdk';
3
2
 
4
3
  export class Constants {
5
4
  static PLACEHOLDER_REGEX = new RegExp(/({{)([A-Z_0-9 -]+)(}})/gi);
6
5
 
7
- static LARGE_RANDOM_POOL = customAlphabet(
8
- '1234567090abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
9
- 21
10
- );
11
-
12
6
  static MP_DL_EVT = 'mp_dl_event';
13
7
  static CUST_EVT = 'custom_event';
14
8