|
| 1 | +import type { TurboModule } from 'react-native'; |
| 2 | +import { TurboModuleRegistry } from 'react-native'; |
| 3 | + |
| 4 | +export type CustomAttributes = { [key: string]: string | number | boolean }; |
| 5 | +export type UserAttributes = { |
| 6 | + [key: string]: string | string[] | number | boolean | null; |
| 7 | +}; |
| 8 | +export type UserIdentities = { [key: string]: string }; |
| 9 | + |
| 10 | +export interface Product { |
| 11 | + name: string; |
| 12 | + sku: string; |
| 13 | + price: number; |
| 14 | + quantity?: number; |
| 15 | + brand?: string; |
| 16 | + couponCode?: string; |
| 17 | + position?: number; |
| 18 | + category?: string; |
| 19 | + variant?: string; |
| 20 | + customAttributes?: CustomAttributes; |
| 21 | +} |
| 22 | + |
| 23 | +export interface TransactionAttributes { |
| 24 | + transactionId: string; |
| 25 | + affiliation?: string; |
| 26 | + revenue?: number; |
| 27 | + shipping?: number; |
| 28 | + tax?: number; |
| 29 | + couponCode?: string; |
| 30 | +} |
| 31 | + |
| 32 | +export interface Promotion { |
| 33 | + id: string; |
| 34 | + name: string; |
| 35 | + creative: string; |
| 36 | + position: string; |
| 37 | +} |
| 38 | + |
| 39 | +export interface Impression { |
| 40 | + impressionListName: string; |
| 41 | + products: Product[]; |
| 42 | +} |
| 43 | + |
| 44 | +export interface CommerceEvent { |
| 45 | + productActionType?: number; |
| 46 | + promotionActionType?: number; |
| 47 | + products?: Product[]; |
| 48 | + transactionAttributes?: TransactionAttributes; |
| 49 | + promotions?: Promotion[]; |
| 50 | + impressions?: Impression[]; |
| 51 | + screenName?: string; |
| 52 | + currency?: string; |
| 53 | + customAttributes?: CustomAttributes; |
| 54 | + checkoutOptions?: string; |
| 55 | + productActionListName?: string; |
| 56 | + productActionListSource?: string; |
| 57 | + checkoutStep?: number; |
| 58 | + nonInteractive?: boolean; |
| 59 | + shouldUploadEvent?: boolean; |
| 60 | +} |
| 61 | + |
| 62 | +export interface Event { |
| 63 | + category?: string; |
| 64 | + duration?: number; |
| 65 | + endTime?: number; |
| 66 | + info?: CustomAttributes; |
| 67 | + name?: string; |
| 68 | + startTime?: number; |
| 69 | + type?: number; |
| 70 | + shouldUploadEvent?: boolean; |
| 71 | + customFlags?: { [key: string]: string }; |
| 72 | +} |
| 73 | + |
| 74 | +export interface GDPRConsent { |
| 75 | + consented?: boolean; |
| 76 | + document?: string | null; |
| 77 | + timestamp?: number; |
| 78 | + location?: string | null; |
| 79 | + hardwareId?: string | null; |
| 80 | +} |
| 81 | + |
| 82 | +export interface CCPAConsent { |
| 83 | + consented?: boolean; |
| 84 | + document?: string | null; |
| 85 | + timestamp?: number; |
| 86 | + location?: string | null; |
| 87 | + hardwareId?: string | null; |
| 88 | +} |
| 89 | + |
| 90 | +export type AttributionResult = { |
| 91 | + [key: string]: { |
| 92 | + [key: string]: string | number | boolean; |
| 93 | + }; |
| 94 | +}; |
| 95 | + |
| 96 | +// Error type for callbacks |
| 97 | +export interface CallbackError { |
| 98 | + message: string; |
| 99 | + code?: number; |
| 100 | + httpCode?: number; |
| 101 | + responseCode?: number; // iOS only |
| 102 | + mpid?: string; |
| 103 | + errors?: string; |
| 104 | +} |
| 105 | + |
| 106 | +export type IdentityRequest = { [key: number]: string }; |
| 107 | + |
| 108 | +export interface AliasRequest { |
| 109 | + sourceMpid?: string; |
| 110 | + destinationMpid?: string; |
| 111 | + startTime?: number; |
| 112 | + endTime?: number; |
| 113 | +} |
| 114 | + |
| 115 | +export interface IdentityResult { |
| 116 | + userId: string; |
| 117 | + previousUserId: string; |
| 118 | +} |
| 119 | + |
| 120 | +export interface Spec extends TurboModule { |
| 121 | + upload(): void; |
| 122 | + setUploadInterval(uploadInterval: number): void; |
| 123 | + logEvent( |
| 124 | + eventName: string, |
| 125 | + eventType: number, |
| 126 | + attributes: CustomAttributes | null |
| 127 | + ): void; |
| 128 | + logMPEvent(event: Event): void; |
| 129 | + logCommerceEvent(commerceEvent: CommerceEvent): void; |
| 130 | + logScreenEvent( |
| 131 | + screenName: string, |
| 132 | + attributes: CustomAttributes | null, |
| 133 | + shouldUploadEvent: boolean |
| 134 | + ): void; |
| 135 | + setATTStatus(status: number): void; |
| 136 | + setATTStatusWithCustomTimestamp(status: number, timestamp: number): void; |
| 137 | + setOptOut(optOut: boolean): void; |
| 138 | + getOptOut(callback: (result: boolean) => void): void; |
| 139 | + addGDPRConsentState(consent: GDPRConsent, purpose: string): void; |
| 140 | + removeGDPRConsentStateWithPurpose(purpose: string): void; |
| 141 | + setCCPAConsentState(consent: CCPAConsent): void; |
| 142 | + removeCCPAConsentState(): void; |
| 143 | + isKitActive(kitId: number, callback: (result: boolean) => void): void; |
| 144 | + getAttributions(callback: (result: AttributionResult) => void): void; |
| 145 | + logPushRegistration(token: string, senderId: string): void; |
| 146 | + getSession(callback: (result: string | null) => void): void; |
| 147 | + setLocation(latitude: number, longitude: number): void; |
| 148 | + |
| 149 | + // User Methods |
| 150 | + setUserAttribute(mpid: string, key: string, value: string): void; |
| 151 | + setUserAttributeArray(mpid: string, key: string, value: Array<string>): void; |
| 152 | + getUserAttributes( |
| 153 | + mpid: string, |
| 154 | + callback: ( |
| 155 | + error: CallbackError | null, |
| 156 | + result: UserAttributes | null |
| 157 | + ) => void |
| 158 | + ): void; |
| 159 | + setUserTag(mpid: string, tag: string): void; |
| 160 | + incrementUserAttribute(mpid: string, key: string, value: number): void; |
| 161 | + removeUserAttribute(mpid: string, key: string): void; |
| 162 | + getUserIdentities( |
| 163 | + mpid: string, |
| 164 | + callback: ( |
| 165 | + error: CallbackError | null, |
| 166 | + result: UserIdentities | null |
| 167 | + ) => void |
| 168 | + ): void; |
| 169 | + getFirstSeen(mpid: string, callback: (result: string) => void): void; |
| 170 | + getLastSeen(mpid: string, callback: (result: string) => void): void; |
| 171 | + |
| 172 | + // Identity Methods |
| 173 | + getCurrentUserWithCompletion( |
| 174 | + callback: (error: CallbackError | null, userId: string | null) => void |
| 175 | + ): void; |
| 176 | + identify( |
| 177 | + identityRequest: IdentityRequest, |
| 178 | + callback: ( |
| 179 | + error: CallbackError | null, |
| 180 | + userId: string | null, |
| 181 | + previousUserId: string | null |
| 182 | + ) => void |
| 183 | + ): void; |
| 184 | + login( |
| 185 | + identityRequest: IdentityRequest, |
| 186 | + callback: ( |
| 187 | + error: CallbackError | null, |
| 188 | + userId: string | null, |
| 189 | + previousUserId: string | null |
| 190 | + ) => void |
| 191 | + ): void; |
| 192 | + logout( |
| 193 | + identityRequest: IdentityRequest, |
| 194 | + callback: ( |
| 195 | + error: CallbackError | null, |
| 196 | + userId: string | null, |
| 197 | + previousUserId: string | null |
| 198 | + ) => void |
| 199 | + ): void; |
| 200 | + modify( |
| 201 | + identityRequest: IdentityRequest, |
| 202 | + callback: ( |
| 203 | + error: CallbackError | null, |
| 204 | + userId: string | null, |
| 205 | + previousUserId: string | null |
| 206 | + ) => void |
| 207 | + ): void; |
| 208 | + aliasUsers( |
| 209 | + aliasRequest: AliasRequest, |
| 210 | + callback: (success: boolean, message?: string) => void |
| 211 | + ): void; |
| 212 | +} |
| 213 | + |
| 214 | +export default TurboModuleRegistry.getEnforcing<Spec>('RNMParticle'); |
0 commit comments