1 | export const VERSION: string;
|
2 |
|
3 | type AnyDataType =
|
4 | | string
|
5 | | boolean
|
6 | | number
|
7 | | null
|
8 | | undefined
|
9 | | AnyDataArray
|
10 | | AnyDataObject;
|
11 | interface AnyDataArray extends Array<AnyDataType> {}
|
12 | interface AnyDataObject extends Record<string, AnyDataType> {}
|
13 |
|
14 | export interface BranchParams {
|
15 | "~channel"?: string;
|
16 | "~feature"?: string;
|
17 | "~tags"?: string[];
|
18 | "~campaign"?: string;
|
19 | "~stage"?: string;
|
20 | "~creation_source"?: string;
|
21 | "~referring_link"?: string;
|
22 | "~id"?: string;
|
23 | "+match_guaranteed": boolean;
|
24 | "+referrer"?: string;
|
25 | "+phone_number"?: string;
|
26 | "+is_first_session": boolean;
|
27 | "+clicked_branch_link": boolean;
|
28 | "+click_timestamp"?: number;
|
29 | "+url"?: string;
|
30 | "+rn_cached_initial_event"?: boolean;
|
31 | [data: string]: AnyDataType;
|
32 | }
|
33 |
|
34 | type BranchEventParams = Pick<
|
35 | BranchEvent,
|
36 | | "transactionID"
|
37 | | "currency"
|
38 | | "revenue"
|
39 | | "shipping"
|
40 | | "tax"
|
41 | | "coupon"
|
42 | | "affiliation"
|
43 | | "description"
|
44 | | "searchQuery"
|
45 | | "alias"
|
46 | | "customData"
|
47 | >;
|
48 |
|
49 | export type ATTAuthorizationStatus = 'authorized'
|
50 | | 'denied'
|
51 | | 'undetermined'
|
52 | | 'restricted'
|
53 |
|
54 | export class BranchEvent {
|
55 | logEvent: () => Promise<null>;
|
56 | constructor(
|
57 | name: string,
|
58 | contentItems?: BranchUniversalObject | BranchUniversalObject[],
|
59 | params?: BranchEventParams
|
60 | );
|
61 | name: string;
|
62 | contentItems: BranchUniversalObject[];
|
63 |
|
64 | transactionID?: string;
|
65 | currency?: string;
|
66 | revenue?: string | number;
|
67 | shipping?: string | number;
|
68 | tax?: string | number;
|
69 | coupon?: string;
|
70 | affiliation?: string;
|
71 | description?: string;
|
72 | searchQuery?: string;
|
73 | alias?: string;
|
74 | customData?: Record<string, AnyDataType>;
|
75 |
|
76 | /**
|
77 | * Standard Add to Cart event
|
78 | */
|
79 | static AddToCart: string;
|
80 |
|
81 | /**
|
82 | * Standard Add to Wishlist event
|
83 | */
|
84 | static AddToWishlist: string;
|
85 |
|
86 | /**
|
87 | * Standard View Cart event
|
88 | */
|
89 | static ViewCart: string;
|
90 |
|
91 | /**
|
92 | * Standard Initiate Purchase event
|
93 | */
|
94 | static InitiatePurchase: string;
|
95 |
|
96 | /**
|
97 | * Standard Add Payment Info event
|
98 | */
|
99 | static AddPaymentInfo: string;
|
100 |
|
101 | /**
|
102 | * Standard Purchase event
|
103 | */
|
104 | static Purchase: string;
|
105 |
|
106 | /**
|
107 | * Standard View Ad event
|
108 | */
|
109 | static ViewAd: string;
|
110 |
|
111 | /**
|
112 | * Standard Click Ad event
|
113 | */
|
114 | static ClickAd: string;
|
115 |
|
116 | // Content events
|
117 |
|
118 | /**
|
119 | * Standard Search event
|
120 | */
|
121 | static Search: string;
|
122 |
|
123 | /**
|
124 | * Standard View Item event for a single Branch Universal Object
|
125 | */
|
126 | static ViewItem: string;
|
127 |
|
128 | /**
|
129 | * Standard View Items event for multiple Branch Universal Objects
|
130 | */
|
131 | static ViewItems: string;
|
132 |
|
133 | /**
|
134 | * Standard Rate event
|
135 | */
|
136 | static Rate: string;
|
137 |
|
138 | /**
|
139 | * Standard Share event
|
140 | */
|
141 | static Share: string;
|
142 |
|
143 | // User Lifecycle Events
|
144 |
|
145 | /**
|
146 | * Standard Complete Registration event
|
147 | */
|
148 | static CompleteRegistration: string;
|
149 |
|
150 | /**
|
151 | * Standard Complete Tutorial event
|
152 | */
|
153 | static CompleteTutorial: string;
|
154 |
|
155 | /**
|
156 | * Standard Achieve Level event
|
157 | */
|
158 | static AchieveLevel: string;
|
159 |
|
160 | /**
|
161 | * Standard Unlock Achievement event
|
162 | */
|
163 | static UnlockAchievement: string;
|
164 |
|
165 | /**
|
166 | * Standard Invite event
|
167 | */
|
168 | static Invite: string;
|
169 |
|
170 | /**
|
171 | * Standard Login event
|
172 | */
|
173 | static Login: string;
|
174 |
|
175 | /**
|
176 | * Standard Reserve event
|
177 | */
|
178 | static Reserve: string;
|
179 |
|
180 | /**
|
181 | * Standard Subscribe event
|
182 | */
|
183 | static Subscribe: string;
|
184 |
|
185 | /**
|
186 | * Standard Start Trial event
|
187 | */
|
188 | static StartTrial: string;
|
189 | }
|
190 |
|
191 | interface BranchSubscriptionEventBase {
|
192 | params: BranchParams | undefined;
|
193 | error: string | null | undefined;
|
194 | uri: string | undefined;
|
195 | }
|
196 | interface BranchSubscriptionEventError extends BranchSubscriptionEventBase {
|
197 | error: string;
|
198 | }
|
199 | interface BranchSubscriptionEventSuccess extends BranchSubscriptionEventBase {
|
200 | error: null | undefined;
|
201 | params: BranchParams;
|
202 | }
|
203 | export type BranchSubscriptionEvent =
|
204 | | BranchSubscriptionEventError
|
205 | | BranchSubscriptionEventSuccess;
|
206 | export interface BranchOpenStartEvent {
|
207 | uri: string;
|
208 | cachedInitialEvent?: boolean;
|
209 | }
|
210 | type BranchSubscribeCallback = (event: BranchSubscriptionEvent) => void;
|
211 | interface BranchSubscribeOptions {
|
212 | onOpenComplete: BranchSubscribeCallback;
|
213 | onOpenStart?: (event: BranchOpenStartEvent) => void;
|
214 | }
|
215 | type BranchUnsubscribe = () => void;
|
216 | type BranchSubscribe = (
|
217 | options: BranchSubscribeCallback | BranchSubscribeOptions
|
218 | ) => BranchUnsubscribe;
|
219 |
|
220 | interface BranchUniversalObjectOptions {
|
221 | locallyIndex?: boolean;
|
222 | publiclyIndex?: boolean;
|
223 | canonicalUrl?: string;
|
224 | title?: string;
|
225 | contentDescription?: string;
|
226 | contentImageUrl?: string;
|
227 | contentMetadata?: {
|
228 | price?: number | string;
|
229 | contentSchema?: any;
|
230 | quantity?: number;
|
231 | sku?: string;
|
232 | productName?: string;
|
233 | productBrand?: string;
|
234 | productCategory?: any;
|
235 | productVariant?: string;
|
236 | condition?: any;
|
237 | currency?: string;
|
238 | ratingAverage?: number;
|
239 | ratingCount?: number;
|
240 | ratingMax?: number;
|
241 | addressStreet?: string;
|
242 | addressCity?: string;
|
243 | addressRegion?: string;
|
244 | addressCountry?: string;
|
245 | addressPostalCode?: string;
|
246 | latitude?: number;
|
247 | longitude?: number;
|
248 | imageCaptions?: string[];
|
249 | customMetadata?: Record<string, string>;
|
250 | };
|
251 | }
|
252 |
|
253 | interface BranchShareSheetOptions {
|
254 | messageHeader?: string;
|
255 | messageBody?: string;
|
256 | emailSubject?: string;
|
257 | title?: string;
|
258 | text?: string;
|
259 | }
|
260 |
|
261 | interface BranchLinkProperties {
|
262 | alias?: string;
|
263 | campaign?: string;
|
264 | feature?: string;
|
265 | channel?: string;
|
266 | stage?: string;
|
267 | tags?: string[];
|
268 | }
|
269 |
|
270 | interface BranchLinkControlParams {
|
271 | $fallback_url?: string;
|
272 | $desktop_url?: string;
|
273 | $ios_url?: string;
|
274 | $ipad_url?: string;
|
275 | $android_url?: string;
|
276 | $samsung_url?: string;
|
277 | }
|
278 |
|
279 | interface BranchUniversalObject {
|
280 | ident: string;
|
281 | showShareSheet: (
|
282 | shareOptions?: BranchShareSheetOptions,
|
283 | linkProperties?: BranchLinkProperties,
|
284 | controlParams?: BranchLinkControlParams
|
285 | ) => void;
|
286 | generateShortUrl: (
|
287 | linkProperties: BranchLinkProperties,
|
288 | controlParams: BranchLinkControlParams
|
289 | ) => Promise<{ url: string }>;
|
290 | logEvent: (eventName: string, params?: BranchEventParams) => Promise<null>;
|
291 | release: () => void;
|
292 | }
|
293 |
|
294 | interface Branch {
|
295 | subscribe: BranchSubscribe;
|
296 | initSessionTtl?: number;
|
297 | skipCachedEvents: () => void;
|
298 | disableTracking: (disable: boolean) => void;
|
299 | isTrackingDisabled: boolean;
|
300 | getLatestReferringParams: (synchronous?: boolean) => Promise<BranchParams>;
|
301 | getFirstReferringParams: () => Promise<BranchParams>;
|
302 | lastAttributedTouchData: (attributionWindow?: number) => Promise<BranchParams>;
|
303 | setIdentity: (identity: string) => void;
|
304 | setRequestMetadata: (key: string, value: string) => void;
|
305 | addFacebookPartnerParameter: (name: string, value: string) => void;
|
306 | clearPartnerParameter: () => void;
|
307 | logout: () => void;
|
308 | openURL: (url: string, options?: { newActivity?: boolean }) => void;
|
309 | createBranchUniversalObject: (
|
310 | identifier: string,
|
311 | options: BranchUniversalObjectOptions
|
312 | ) => BranchUniversalObject;
|
313 | handleATTAuthorizationStatus: (
|
314 | ATTAuthorizationStatus:ATTAuthorizationStatus
|
315 | ) => void
|
316 | }
|
317 | declare const branch: Branch;
|
318 | export default branch;
|