affise-attribution-lib 1.1.5 → 1.1.6

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.
package/README.md CHANGED
@@ -1,648 +1,668 @@
1
- # Affise Attribution React Native library
2
-
3
- - [Affise Attribution React Native library](#affise-attribution-react-native-library)
4
- - [Description](#description)
5
- - [Quick start](#quick-start)
6
- - [Integration](#integration)
7
- - [Integrate npm package](#integrate-npm-package)
8
- - [Initialize](#initialize)
9
- - [Requirements](#requirements)
10
- - [Android](#android)
11
- - [Features](#features)
12
- - [Device identifiers collection](#device-identifiers-collection)
13
- - [Events tracking](#events-tracking)
14
- - [Custom events tracking](#custom-events-tracking)
15
- - [Predefined event parameters](#predefined-event-parameters)
16
- - [Events buffering](#events-buffering)
17
- - [Advertising Identifier (google) tracking](#advertising-identifier-google-tracking)
18
- - [Open Advertising Identifier (huawei) tracking](#open-advertising-identifier-huawei-tracking)
19
- - [Install referrer tracking](#install-referrer-tracking)
20
- - [Push token tracking](#push-token-tracking)
21
- - [Reinstall Uninstall tracking](#reinstall-uninstall-tracking)
22
- - [APK preinstall tracking](#apk-preinstall-tracking)
23
- - [Deeplinks](#deeplinks)
24
- - [Android](#android-1)
25
- - [iOS](#ios)
26
- - [Offline mode](#offline-mode)
27
- - [Disable tracking](#disable-tracking)
28
- - [Disable background tracking](#disable-background-tracking)
29
- - [GDPR right to be forgotten](#gdpr-right-to-be-forgotten)
30
- - [Platform specific](#platform-specific)
31
- - [Get referrer](#get-referrer)
32
- - [Get referrer value](#get-referrer-value)
33
-
34
- # Description
35
-
36
- Affise SDK is a software you can use to collect app usage statistics, device identifiers, deeplink usage, track install
37
- referrer.
38
-
39
- ## Quick start
40
-
41
- ## Integration
42
-
43
- ### Integrate npm package
44
-
45
- This is a [Node.js](https://nodejs.org/en/) module available through the
46
- [npm registry](https://www.npmjs.com/).
47
-
48
- Installation using npm
49
-
50
- ```console
51
- npm install affise-attribution-lib
52
- ```
53
-
54
- Installation using yarn
55
-
56
- ```console
57
- yarn add affise-attribution-lib
58
- ```
59
-
60
- #### Add platform modules
61
-
62
- ##### Android
63
-
64
- Add modules to android project
65
-
66
- Example `example/android/app/build.gradle`
67
-
68
- ```gradle
69
- dependencies {
70
- // Affise modules
71
- implementation 'com.affise:module-advertising:1.5.4'
72
- implementation 'com.affise:module-network:1.5.4'
73
- implementation 'com.affise:module-phone:1.5.4'
74
- }
75
- ```
76
-
77
- ### Initialize
78
-
79
- After dependency is added, and project is sync with `npm install` and initialize.
80
-
81
- ```typescript
82
- import {
83
- Affise,
84
- AffiseInitProperties
85
- } from 'affise-attribution-lib';
86
-
87
-
88
- export default function App() {
89
-
90
- React.useEffect(() => {
91
- Affise.init(
92
- new AffiseInitProperties(
93
- 'Your appId', //Change to your app id
94
- true, //Add your custom rule to determine if this is a production build
95
- null, //Change to your partParamName
96
- null, //Change to your partParamNameToken
97
- null, //Change to your appToken
98
- 'Your secretId' //Change to your secretId
99
- )
100
- );
101
- });
102
-
103
- return (
104
- <SafeAreaView>
105
- </SafeAreaView>
106
- );
107
- }
108
- ```
109
-
110
-
111
- ### Requirements
112
-
113
- #### Android
114
-
115
- Minimal Android SDK version is 21
116
-
117
- For a minimal working functionality your app needs to declare internet permission:
118
-
119
- ```xml
120
- <manifest>
121
- <uses-permission android:name="android.permission.INTERNET"/>
122
- </manifest>
123
- ```
124
-
125
- OAID certificate in your project (Optional)
126
- `example/android/app/src/main/assets/oaid.cert.pem`
127
-
128
- # Features
129
-
130
- ### Device identifiers collection
131
-
132
- To match users with events and data library is sending, these identifiers are collected:
133
-
134
- - `AFFISE_APP_ID`
135
- - `AFFISE_PKG_APP_NAME`
136
- - `AFFISE_APP_NAME_DASHBOARD`
137
- - `APP_VERSION`
138
- - `APP_VERSION_RAW`
139
- - `STORE`
140
- - `TRACKER_TOKEN`
141
- - `TRACKER_NAME`
142
- - `FIRST_TRACKER_TOKEN`
143
- - `FIRST_TRACKER_NAME`
144
- - `LAST_TRACKER_TOKEN`
145
- - `LAST_TRACKER_NAME`
146
- - `OUTDATED_TRACKER_TOKEN`
147
- - `INSTALLED_TIME`
148
- - `FIRST_OPEN_TIME`
149
- - `INSTALLED_HOUR`
150
- - `FIRST_OPEN_HOUR`
151
- - `INSTALL_BEGIN_TIME`
152
- - `INSTALL_FINISH_TIME`
153
- - `REFERRAL_TIME`
154
- - `CREATED_TIME`
155
- - `CREATED_TIME_MILLI`
156
- - `CREATED_TIME_HOUR`
157
- - `UNINSTALL_TIME`
158
- - `REINSTALL_TIME`
159
- - `LAST_SESSION_TIME`
160
- - `CONNECTION_TYPE`
161
- - `CPU_TYPE`
162
- - `HARDWARE_NAME`
163
- - `NETWORK_TYPE`
164
- - `DEVICE_MANUFACTURER`
165
- - `PROXY_IP_ADDRESS`
166
- - `DEEPLINK_CLICK`
167
- - `DEVICE_ATLAS_ID`
168
- - `AFFISE_DEVICE_ID`
169
- - `AFFISE_ALT_DEVICE_ID`
170
- - `ADID`
171
- - `ANDROID_ID`
172
- - `ANDROID_ID_MD5`
173
- - `MAC_SHA1`
174
- - `MAC_MD5`
175
- - `GAID_ADID`
176
- - `GAID_ADID_MD5`
177
- - `OAID`
178
- - `OAID_MD5`
179
- - `REFTOKEN`
180
- - `REFTOKENS`
181
- - `REFERRER`
182
- - `USER_AGENT`
183
- - `MCCODE`
184
- - `MNCODE`
185
- - `ISP`
186
- - `REGION`
187
- - `COUNTRY`
188
- - `LANGUAGE`
189
- - `DEVICE_NAME`
190
- - `DEVICE_TYPE`
191
- - `OS_NAME`
192
- - `PLATFORM`
193
- - `API_LEVEL_OS`
194
- - `AFFISE_SDK_VERSION`
195
- - `OS_VERSION`
196
- - `RANDOM_USER_ID`
197
- - `AFFISE_SDK_POS`
198
- - `TIMEZONE_DEV`
199
- - `LAST_TIME_SESSION`
200
- - `TIME_SESSION`
201
- - `AFFISE_SESSION_COUNT`
202
- - `LIFETIME_SESSION_COUNT`
203
- - `AFFISE_DEEPLINK`
204
- - `AFFISE_PART_PARAM_NAME`
205
- - `AFFISE_PART_PARAM_NAME_TOKEN`
206
- - `AFFISE_APP_TOKEN`
207
- - `LABEL`
208
- - `AFFISE_SDK_SECRET_ID`
209
- - `UUID`
210
- - `AFFISE_APP_OPENED`
211
- - `PUSHTOKEN`
212
- - `EVENTS`
213
- - `AFFISE_EVENTS_COUNT`
214
-
215
- ### Events tracking
216
-
217
- For example, we want to track what items usually user adds to shopping cart. To send event first create it with
218
- following code
219
-
220
- ```typescript
221
- import { Affise, AddToCartEvent } from 'affise-attribution-lib';
222
-
223
- class Presenter {
224
- onUserAddsItemsToCart(item: string) {
225
- const items = {
226
- items: 'cookies, potato, milk',
227
- };
228
-
229
- Affise.sendEvent(new AddToCartEvent(items, Date.now(), 'groceries'));
230
- }
231
- }
232
- ```
233
-
234
- With above example you can implement other events:
235
-
236
- - `AchieveLevelEvent`
237
- - `AddPaymentInfoEvent`
238
- - `AddToCartEvent`
239
- - `AddToWishlistEvent`
240
- - `ClickAdvEvent`
241
- - `CompleteRegistrationEvent`
242
- - `CompleteStreamEvent`
243
- - `CompleteTrialEvent`
244
- - `CompleteTutorialEvent`
245
- - `ContentItemsViewEvent`
246
- - `DeepLinkedEvent`
247
- - `InitiatePurchaseEvent`
248
- - `InitiateStreamEvent`
249
- - `InviteEvent`
250
- - `LastAttributedTouchEvent`
251
- - `ListViewEvent`
252
- - `LoginEvent`
253
- - `OpenedFromPushNotificationEvent`
254
- - `PurchaseEvent`
255
- - `RateEvent`
256
- - `ReEngageEvent`
257
- - `ReserveEvent`
258
- - `SalesEvent`
259
- - `SearchEvent`
260
- - `ShareEvent`
261
- - `SpendCreditsEvent`
262
- - `StartRegistrationEvent`
263
- - `StartTrialEvent`
264
- - `StartTutorialEvent`
265
- - `SubscribeEvent`
266
- - `TravelBookingEvent`
267
- - `UnlockAchievementEvent`
268
- - `UnsubscribeEvent`
269
- - `UnsubscriptionEvent`
270
- - `UpdateEvent`
271
- - `ViewAdvEvent`
272
- - `ViewCartEvent`
273
- - `ViewItemEvent`
274
- - `ViewItemsEvent`
275
-
276
- ### Custom events tracking
277
-
278
- Use any of custom events if default doesn't fit your scenario:
279
-
280
- - `CustomId01Event`
281
- - `CustomId02Event`
282
- - `CustomId03Event`
283
- - `CustomId04Event`
284
- - `CustomId05Event`
285
- - `CustomId06Event`
286
- - `CustomId07Event`
287
- - `CustomId08Event`
288
- - `CustomId09Event`
289
- - `CustomId10Event`
290
-
291
- ### Predefined event parameters
292
-
293
- To enrich your event with another dimension, you can use predefined parameters for most common cases.
294
- Add it to any event:
295
-
296
- ```typescript
297
- import {
298
- Affise,
299
- AddToCartEvent,
300
- PredefinedParameters,
301
- } from 'affise-attribution-lib';
302
-
303
- class Presenter {
304
- onUserAddsItemsToCart(item: string) {
305
- const items = {
306
- items: 'cookies, potato, milk',
307
- };
308
-
309
- const event = new AddToCartEvent(items, Date.now());
310
-
311
- event.addPredefinedParameter(
312
- PredefinedParameters.DESCRIPTION,
313
- 'best before 2029'
314
- );
315
-
316
- Affise.sendEvent(event);
317
- }
318
- }
319
- ```
320
-
321
- In examples above `PredefinedParameters.DESCRIPTION` is used, but many others is available:
322
-
323
- - `ADREV_AD_TYPE`
324
- - `CITY`
325
- - `COUNTRY`
326
- - `REGION`
327
- - `CLASS`
328
- - `CONTENT`
329
- - `CONTENT_ID`
330
- - `CONTENT_LIST`
331
- - `CONTENT_TYPE`
332
- - `CURRENCY`
333
- - `CUSTOMER_USER_ID`
334
- - `DATE_A`
335
- - `DATE_B`
336
- - `DEPARTING_ARRIVAL_DATE`
337
- - `DEPARTING_DEPARTURE_DATE`
338
- - `DESCRIPTION`
339
- - `DESTINATION_A`
340
- - `DESTINATION_B`
341
- - `DESTINATION_LIST`
342
- - `HOTEL_SCORE`
343
- - `LEVEL`
344
- - `MAX_RATING_VALUE`
345
- - `NUM_ADULTS`
346
- - `NUM_CHILDREN`
347
- - `NUM_INFANTS`
348
- - `ORDER_ID`
349
- - `PAYMENT_INFO_AVAILABLE`
350
- - `PREFERRED_NEIGHBORHOODS`
351
- - `PREFERRED_NUM_STOPS`
352
- - `PREFERRED_PRICE_RANGE`
353
- - `PREFERRED_STAR_RATINGS`
354
- - `PRICE`
355
- - `PURCHASE_CURRENCY`
356
- - `QUANTITY`
357
- - `RATING_VALUE`
358
- - `RECEIPT_ID`
359
- - `REGISTRATION_METHOD`
360
- - `RETURNING_ARRIVAL_DATE`
361
- - `RETURNING_DEPARTURE_DATE`
362
- - `REVENUE`
363
- - `SCORE`
364
- - `SEARCH_STRING`
365
- - `SUBSCRIPTION_ID`
366
- - `SUCCESS`
367
- - `SUGGESTED_DESTINATIONS`
368
- - `SUGGESTED_HOTELS`
369
- - `TRAVEL_START`
370
- - `TRAVEL_END`
371
- - `USER_SCORE`
372
- - `VALIDATED`
373
- - `ACHIEVEMENT_ID`
374
- - `COUPON_CODE`
375
- - `CUSTOMER_SEGMENT`
376
- - `DEEP_LINK`
377
- - `EVENT_START`
378
- - `EVENT_END`
379
- - `LAT`
380
- - `LONG`
381
- - `NEW_VERSION`
382
- - `OLD_VERSION`
383
- - `REVIEW_TEXT`
384
- - `TUTORIAL_ID`
385
- - `VIRTUAL_CURRENCY_NAME`
386
- - `PARAM_01`
387
- - `PARAM_02`
388
- - `PARAM_03`
389
- - `PARAM_04`
390
- - `PARAM_05`
391
- - `PARAM_06`
392
- - `PARAM_07`
393
- - `PARAM_08`
394
- - `PARAM_09`
395
-
396
- ### Events buffering
397
-
398
- Affise library will send any pending events with first opportunity,
399
- but if there is no network connection or device is disabled, events are kept locally for 7 days before deletion.
400
-
401
- ### Advertising Identifier (google) tracking
402
-
403
- Advertising Identifier (google) tracking is supported automatically, no actions needed
404
-
405
- ### Open Advertising Identifier (huawei) tracking
406
-
407
- Open Advertising Identifier is supported automatically, no actions needed
408
-
409
- ### Install referrer tracking
410
-
411
- Install referrer tracking is supported automatically, no actions needed
412
-
413
- ### Push token tracking
414
-
415
- To let affise track push token you need to receive it from your push service provider, and pass to Affise library.
416
- First add firebase integration to your app completing theese steps: https://firebase.google.com/docs/cloud-messaging/android/client
417
-
418
- After you have done with firebase inegration, add to your cloud messaging service `onNewToken` method `Affise.addPushToken(token)`
419
-
420
- ```typescript
421
- import { Affise } from 'affise-attribution-lib';
422
- import messaging from '@react-native-firebase/messaging';
423
-
424
- const getToken = async () => {
425
- const token = await messaging().getToken();
426
- if (token) {
427
- Affise.addPushToken(token);
428
- }
429
- };
430
- ```
431
-
432
- ### Reinstall Uninstall tracking
433
-
434
- Affise automatically track reinstall events by using silent-push technology, to make this feature work, pass push token when it is recreated by user and on you application starts up
435
-
436
- ```typescript
437
- Affise.addPushToken(token);
438
- ```
439
-
440
- ### APK preinstall tracking
441
-
442
- SDK is also supports scenario when APK is installed not from one of application markets, such as google play, huawei appgallery or amazon appstore
443
- To use this feature, create file with name `partner_key` in your app assets directory, and write unique identifier inside, this key will be passed to our backend so you can track events by partner later in your Affise console.
444
-
445
- ### Deeplinks
446
-
447
- Register deeplink callback right after Affise.init(..)
448
-
449
- ```typescript
450
- Affise.init(..);
451
- Affise.registerDeeplinkCallback((uri) => {
452
-
453
- });
454
- ```
455
-
456
- #### Android
457
-
458
- To integrate deeplink support in android you need:
459
-
460
- Add intent filter to `AndroidManifest.xml` as in `example/android/app/src/main/AndroidManifest.xml`,
461
-
462
- ```xml
463
- <intent-filter android:autoVerify="true">
464
- <action android:name="android.intent.action.VIEW" />
465
-
466
- <category android:name="android.intent.category.DEFAULT" />
467
- <category android:name="android.intent.category.BROWSABLE" />
468
-
469
- <data
470
- android:host="YOUR_AFFISE_APP_ID.affattr.com"
471
- android:scheme="react" />
472
- </intent-filter>
473
- ```
474
-
475
- #### iOS
476
-
477
- To integrate deeplink support in iOS you need:
478
-
479
- Add deeplink handler to `AppDelegate.mm` as in `example/ios/AffiseAttributionLibExample/AppDelegate.mm`
480
- - [React Docs](https://reactnavigation.org/docs/deep-linking/#set-up-with-bare-react-native-projects)
481
-
482
- ```objective-c
483
- - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
484
- sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
485
- {
486
- return [RCTLinkingManager application:application openURL:url
487
- sourceApplication:sourceApplication annotation:annotation];
488
- }
489
- ```
490
-
491
- Add key `CFBundleURLTypes` to `Info.plist` as in `example/ios/AffiseAttributionLibExample/Info.plist`
492
-
493
- ```html
494
- <key>CFBundleURLTypes</key>
495
- <array>
496
- <dict>
497
- <key>CFBundleTypeRole</key>
498
- <string>Editor</string>
499
- <key>CFBundleURLName</key>
500
- <string>YOUR_AFFISE_APP_ID.affattr.com</string>
501
- <key>CFBundleURLSchemes</key>
502
- <array>
503
- <string>react</string>
504
- </array>
505
- </dict>
506
- </array>
507
- ```
508
-
509
- ### Offline mode
510
-
511
- In some scenarious you would want to limit Affise network usage, to pause that activity call anywhere in your application following code after Affise init:
512
-
513
- ```typescript
514
- Affise.init(..);
515
- Affise.setOfflineModeEnabled(true); // to enable offline mode
516
- Affise.setOfflineModeEnabled(false); // to disable offline mode
517
- ```
518
-
519
- While offline mode is enabled, your metrics and other events are kept locally, and will be delivered once offline mode is disabled.
520
- Offline mode is persistent as Application lifecycle, and will be disabled with process termination automaticly.
521
- To check current offline mode status call:
522
-
523
- ```typescript
524
- Affise.isOfflineModeEnabled(); // returns true or false describing current tracking state
525
- ```
526
-
527
- ### Disable tracking
528
-
529
- To disable any tracking activity, storing events and gathering device identifiers and metrics call anywhere in your application following code after Affise init:
530
-
531
- ```typescript
532
- Affise.init(..);
533
- Affise.setTrackingEnabled(true); // to enable tracking
534
- Affise.setTrackingEnabled(false); // to disable tracking
535
- ```
536
-
537
- By default tracking is enabled.
538
-
539
- While tracking mode is disabled, metrics and other identifiers is not generated locally.
540
- Keep in mind that this flag is persistent until app reinstall, and don't forget to reactivate tracking when needed.
541
- To check current status of tracking call:
542
-
543
- ```typescript
544
- Affise.isTrackingEnabled().then((enabled) => {
545
- // returns true or false describing current tracking state
546
- });
547
- ```
548
-
549
- ### Disable background tracking
550
-
551
- To disable any background tracking activity, storing events and gathering device identifiers and metrics call anywhere in your application following code after Affise init:
552
-
553
- ```typescript
554
- Affise.init(..);
555
- Affise.setBackgroundTrackingEnabled(true); // to enable background tracking
556
- Affise.setBackgroundTrackingEnabled(false); // to disable background tracking
557
- ```
558
-
559
- By default background tracking is enabled.
560
-
561
- While background tracking mode is disabled, metrics and other identifiers is not generated locally.
562
- Background tracking mode is persistent as Application lifecycle, and will be re-enabled with process termination automatically.
563
- To check current status of background tracking call:
564
-
565
- ```typescript
566
- Affise.isBackgroundTrackingEnabled().then((enabled) => {
567
- // returns true or false describing current background tracking state
568
- });
569
- ```
570
-
571
- ### GDPR right to be forgotten
572
-
573
- Under the EU's General Data Protection Regulation (GDPR): An individual has the right to have their personal data erased.
574
- To provide this functionality to user, as the app developer, you can call
575
-
576
- ```typescript
577
- Affise.init(..);
578
- Affise.forget(); // to forget users data
579
- ```
580
-
581
- After processing such request our backend servers will delete all users data.
582
- To prevent library from generating new events, disable tracking just before calling Affise.forget:
583
-
584
- ```typescript
585
- Affise.init(..);
586
- Affise.setTrackingEnabled(false);
587
- Affise.forget(); // to forget users data
588
- ```
589
-
590
-
591
- ### Platform specific
592
-
593
- ### Get referrer
594
- > `Android Only`
595
-
596
- Use the next public method of SDK
597
-
598
- ```typescript
599
- Affise.getReferrer().then((referrer) => {
600
- // returns referrer
601
- });
602
- ```
603
-
604
- #### Get referrer value
605
- > `Android Only`
606
-
607
- Use the next public method of SDK to get referrer value by
608
-
609
- ```typescript
610
- Affise.android.getReferrerValue(ReferrerKey.CLICK_ID, (value) => {
611
-
612
- })
613
- ```
614
-
615
- #### Referrer keys
616
-
617
- In examples above `ReferrerKey.CLICK_ID` is used, but many others is available:
618
-
619
- - `AD_ID`
620
- - `CAMPAIGN_ID`
621
- - `CLICK_ID`
622
- - `AFFISE_AD`
623
- - `AFFISE_AD_ID`
624
- - `AFFISE_AD_TYPE`
625
- - `AFFISE_ADSET`
626
- - `AFFISE_ADSET_ID`
627
- - `AFFISE_AFFC_ID`
628
- - `AFFISE_CHANNEL`
629
- - `AFFISE_CLICK_LOOK_BACK`
630
- - `AFFISE_COST_CURRENCY`
631
- - `AFFISE_COST_MODEL`
632
- - `AFFISE_COST_VALUE`
633
- - `AFFISE_DEEPLINK`
634
- - `AFFISE_KEYWORDS`
635
- - `AFFISE_MEDIA_TYPE`
636
- - `AFFISE_MODEL`
637
- - `AFFISE_OS`
638
- - `AFFISE_PARTNER`
639
- - `AFFISE_REF`
640
- - `AFFISE_SITE_ID`
641
- - `AFFISE_SUB_SITE_ID`
642
- - `AFFC`
643
- - `PID`
644
- - `SUB_1`
645
- - `SUB_2`
646
- - `SUB_3`
647
- - `SUB_4`
648
- - `SUB_5`
1
+ # Affise Attribution React Native library
2
+
3
+ - [Affise Attribution React Native library](#affise-attribution-react-native-library)
4
+ - [Description](#description)
5
+ - [Quick start](#quick-start)
6
+ - [Integration](#integration)
7
+ - [Integrate npm package](#integrate-npm-package)
8
+ - [Initialize](#initialize)
9
+ - [Requirements](#requirements)
10
+ - [Android](#android)
11
+ - [Features](#features)
12
+ - [Device identifiers collection](#device-identifiers-collection)
13
+ - [Events tracking](#events-tracking)
14
+ - [Custom events tracking](#custom-events-tracking)
15
+ - [Predefined event parameters](#predefined-event-parameters)
16
+ - [Events buffering](#events-buffering)
17
+ - [Advertising Identifier (google) tracking](#advertising-identifier-google-tracking)
18
+ - [Open Advertising Identifier (huawei) tracking](#open-advertising-identifier-huawei-tracking)
19
+ - [Install referrer tracking](#install-referrer-tracking)
20
+ - [Push token tracking](#push-token-tracking)
21
+ - [Reinstall Uninstall tracking](#reinstall-uninstall-tracking)
22
+ - [APK preinstall tracking](#apk-preinstall-tracking)
23
+ - [Deeplinks](#deeplinks)
24
+ - [Android](#android-1)
25
+ - [iOS](#ios)
26
+ - [Offline mode](#offline-mode)
27
+ - [Disable tracking](#disable-tracking)
28
+ - [Disable background tracking](#disable-background-tracking)
29
+ - [GDPR right to be forgotten](#gdpr-right-to-be-forgotten)
30
+ - [Platform specific](#platform-specific)
31
+ - [Get referrer](#get-referrer)
32
+ - [Get referrer value](#get-referrer-value)
33
+ - [SKAd](#skad)
34
+
35
+ # Description
36
+
37
+ Affise SDK is a software you can use to collect app usage statistics, device identifiers, deeplink usage, track install
38
+ referrer.
39
+
40
+ ## Quick start
41
+
42
+ ## Integration
43
+
44
+ ### Integrate npm package
45
+
46
+ This is a [Node.js](https://nodejs.org/en/) module available through the
47
+ [npm registry](https://www.npmjs.com/).
48
+
49
+ Installation using npm
50
+
51
+ ```console
52
+ npm install affise-attribution-lib
53
+ ```
54
+
55
+ Installation using yarn
56
+
57
+ ```console
58
+ yarn add affise-attribution-lib
59
+ ```
60
+
61
+ #### Add platform modules
62
+
63
+ ##### Android
64
+
65
+ Add modules to android project
66
+
67
+ Example `example/android/app/build.gradle`
68
+
69
+ ```gradle
70
+ dependencies {
71
+ // Affise modules
72
+ implementation 'com.affise:module-advertising:1.5.4'
73
+ implementation 'com.affise:module-network:1.5.4'
74
+ implementation 'com.affise:module-phone:1.5.4'
75
+ }
76
+ ```
77
+
78
+ ### Initialize
79
+
80
+ After dependency is added, and project is sync with `npm install` and initialize.
81
+
82
+ ```typescript
83
+ import {
84
+ Affise,
85
+ AffiseInitProperties
86
+ } from 'affise-attribution-lib';
87
+
88
+
89
+ export default function App() {
90
+
91
+ React.useEffect(() => {
92
+ Affise.init(
93
+ new AffiseInitProperties(
94
+ 'Your appId', //Change to your app id
95
+ true, //Add your custom rule to determine if this is a production build
96
+ null, //Change to your partParamName
97
+ null, //Change to your partParamNameToken
98
+ null, //Change to your appToken
99
+ 'Your secretId' //Change to your secretId
100
+ )
101
+ );
102
+ });
103
+
104
+ return (
105
+ <SafeAreaView>
106
+ </SafeAreaView>
107
+ );
108
+ }
109
+ ```
110
+
111
+
112
+ ### Requirements
113
+
114
+ #### Android
115
+
116
+ Minimal Android SDK version is 21
117
+
118
+ For a minimal working functionality your app needs to declare internet permission:
119
+
120
+ ```xml
121
+ <manifest>
122
+ <uses-permission android:name="android.permission.INTERNET"/>
123
+ </manifest>
124
+ ```
125
+
126
+ OAID certificate in your project (Optional)
127
+ `example/android/app/src/main/assets/oaid.cert.pem`
128
+
129
+ # Features
130
+
131
+ ### Device identifiers collection
132
+
133
+ To match users with events and data library is sending, these identifiers are collected:
134
+
135
+ - `AFFISE_APP_ID`
136
+ - `AFFISE_PKG_APP_NAME`
137
+ - `AFFISE_APP_NAME_DASHBOARD`
138
+ - `APP_VERSION`
139
+ - `APP_VERSION_RAW`
140
+ - `STORE`
141
+ - `TRACKER_TOKEN`
142
+ - `TRACKER_NAME`
143
+ - `FIRST_TRACKER_TOKEN`
144
+ - `FIRST_TRACKER_NAME`
145
+ - `LAST_TRACKER_TOKEN`
146
+ - `LAST_TRACKER_NAME`
147
+ - `OUTDATED_TRACKER_TOKEN`
148
+ - `INSTALLED_TIME`
149
+ - `FIRST_OPEN_TIME`
150
+ - `INSTALLED_HOUR`
151
+ - `FIRST_OPEN_HOUR`
152
+ - `INSTALL_BEGIN_TIME`
153
+ - `INSTALL_FINISH_TIME`
154
+ - `REFERRAL_TIME`
155
+ - `CREATED_TIME`
156
+ - `CREATED_TIME_MILLI`
157
+ - `CREATED_TIME_HOUR`
158
+ - `UNINSTALL_TIME`
159
+ - `REINSTALL_TIME`
160
+ - `LAST_SESSION_TIME`
161
+ - `CONNECTION_TYPE`
162
+ - `CPU_TYPE`
163
+ - `HARDWARE_NAME`
164
+ - `NETWORK_TYPE`
165
+ - `DEVICE_MANUFACTURER`
166
+ - `PROXY_IP_ADDRESS`
167
+ - `DEEPLINK_CLICK`
168
+ - `DEVICE_ATLAS_ID`
169
+ - `AFFISE_DEVICE_ID`
170
+ - `AFFISE_ALT_DEVICE_ID`
171
+ - `ADID`
172
+ - `ANDROID_ID`
173
+ - `ANDROID_ID_MD5`
174
+ - `MAC_SHA1`
175
+ - `MAC_MD5`
176
+ - `GAID_ADID`
177
+ - `GAID_ADID_MD5`
178
+ - `OAID`
179
+ - `OAID_MD5`
180
+ - `REFTOKEN`
181
+ - `REFTOKENS`
182
+ - `REFERRER`
183
+ - `USER_AGENT`
184
+ - `MCCODE`
185
+ - `MNCODE`
186
+ - `ISP`
187
+ - `REGION`
188
+ - `COUNTRY`
189
+ - `LANGUAGE`
190
+ - `DEVICE_NAME`
191
+ - `DEVICE_TYPE`
192
+ - `OS_NAME`
193
+ - `PLATFORM`
194
+ - `API_LEVEL_OS`
195
+ - `AFFISE_SDK_VERSION`
196
+ - `OS_VERSION`
197
+ - `RANDOM_USER_ID`
198
+ - `AFFISE_SDK_POS`
199
+ - `TIMEZONE_DEV`
200
+ - `LAST_TIME_SESSION`
201
+ - `TIME_SESSION`
202
+ - `AFFISE_SESSION_COUNT`
203
+ - `LIFETIME_SESSION_COUNT`
204
+ - `AFFISE_DEEPLINK`
205
+ - `AFFISE_PART_PARAM_NAME`
206
+ - `AFFISE_PART_PARAM_NAME_TOKEN`
207
+ - `AFFISE_APP_TOKEN`
208
+ - `LABEL`
209
+ - `AFFISE_SDK_SECRET_ID`
210
+ - `UUID`
211
+ - `AFFISE_APP_OPENED`
212
+ - `PUSHTOKEN`
213
+ - `EVENTS`
214
+ - `AFFISE_EVENTS_COUNT`
215
+
216
+ ### Events tracking
217
+
218
+ For example, we want to track what items usually user adds to shopping cart. To send event first create it with
219
+ following code
220
+
221
+ ```typescript
222
+ import { Affise, AddToCartEvent } from 'affise-attribution-lib';
223
+
224
+ class Presenter {
225
+ onUserAddsItemsToCart(item: string) {
226
+ const items = {
227
+ items: 'cookies, potato, milk',
228
+ };
229
+
230
+ Affise.sendEvent(new AddToCartEvent(items, Date.now(), 'groceries'));
231
+ }
232
+ }
233
+ ```
234
+
235
+ With above example you can implement other events:
236
+
237
+ - `AchieveLevelEvent`
238
+ - `AddPaymentInfoEvent`
239
+ - `AddToCartEvent`
240
+ - `AddToWishlistEvent`
241
+ - `ClickAdvEvent`
242
+ - `CompleteRegistrationEvent`
243
+ - `CompleteStreamEvent`
244
+ - `CompleteTrialEvent`
245
+ - `CompleteTutorialEvent`
246
+ - `ContentItemsViewEvent`
247
+ - `DeepLinkedEvent`
248
+ - `InitiatePurchaseEvent`
249
+ - `InitiateStreamEvent`
250
+ - `InviteEvent`
251
+ - `LastAttributedTouchEvent`
252
+ - `ListViewEvent`
253
+ - `LoginEvent`
254
+ - `OpenedFromPushNotificationEvent`
255
+ - `PurchaseEvent`
256
+ - `RateEvent`
257
+ - `ReEngageEvent`
258
+ - `ReserveEvent`
259
+ - `SalesEvent`
260
+ - `SearchEvent`
261
+ - `ShareEvent`
262
+ - `SpendCreditsEvent`
263
+ - `StartRegistrationEvent`
264
+ - `StartTrialEvent`
265
+ - `StartTutorialEvent`
266
+ - `SubscribeEvent`
267
+ - `TravelBookingEvent`
268
+ - `UnlockAchievementEvent`
269
+ - `UnsubscribeEvent`
270
+ - `UnsubscriptionEvent`
271
+ - `UpdateEvent`
272
+ - `ViewAdvEvent`
273
+ - `ViewCartEvent`
274
+ - `ViewItemEvent`
275
+ - `ViewItemsEvent`
276
+
277
+ ### Custom events tracking
278
+
279
+ Use any of custom events if default doesn't fit your scenario:
280
+
281
+ - `CustomId01Event`
282
+ - `CustomId02Event`
283
+ - `CustomId03Event`
284
+ - `CustomId04Event`
285
+ - `CustomId05Event`
286
+ - `CustomId06Event`
287
+ - `CustomId07Event`
288
+ - `CustomId08Event`
289
+ - `CustomId09Event`
290
+ - `CustomId10Event`
291
+
292
+ ### Predefined event parameters
293
+
294
+ To enrich your event with another dimension, you can use predefined parameters for most common cases.
295
+ Add it to any event:
296
+
297
+ ```typescript
298
+ import {
299
+ Affise,
300
+ AddToCartEvent,
301
+ PredefinedParameters,
302
+ } from 'affise-attribution-lib';
303
+
304
+ class Presenter {
305
+ onUserAddsItemsToCart(item: string) {
306
+ const items = {
307
+ items: 'cookies, potato, milk',
308
+ };
309
+
310
+ const event = new AddToCartEvent(items, Date.now());
311
+
312
+ event.addPredefinedParameter(
313
+ PredefinedParameters.DESCRIPTION,
314
+ 'best before 2029'
315
+ );
316
+
317
+ Affise.sendEvent(event);
318
+ }
319
+ }
320
+ ```
321
+
322
+ In examples above `PredefinedParameters.DESCRIPTION` is used, but many others is available:
323
+
324
+ - `ADREV_AD_TYPE`
325
+ - `CITY`
326
+ - `COUNTRY`
327
+ - `REGION`
328
+ - `CLASS`
329
+ - `CONTENT`
330
+ - `CONTENT_ID`
331
+ - `CONTENT_LIST`
332
+ - `CONTENT_TYPE`
333
+ - `CURRENCY`
334
+ - `CUSTOMER_USER_ID`
335
+ - `DATE_A`
336
+ - `DATE_B`
337
+ - `DEPARTING_ARRIVAL_DATE`
338
+ - `DEPARTING_DEPARTURE_DATE`
339
+ - `DESCRIPTION`
340
+ - `DESTINATION_A`
341
+ - `DESTINATION_B`
342
+ - `DESTINATION_LIST`
343
+ - `HOTEL_SCORE`
344
+ - `LEVEL`
345
+ - `MAX_RATING_VALUE`
346
+ - `NUM_ADULTS`
347
+ - `NUM_CHILDREN`
348
+ - `NUM_INFANTS`
349
+ - `ORDER_ID`
350
+ - `PAYMENT_INFO_AVAILABLE`
351
+ - `PREFERRED_NEIGHBORHOODS`
352
+ - `PREFERRED_NUM_STOPS`
353
+ - `PREFERRED_PRICE_RANGE`
354
+ - `PREFERRED_STAR_RATINGS`
355
+ - `PRICE`
356
+ - `PURCHASE_CURRENCY`
357
+ - `QUANTITY`
358
+ - `RATING_VALUE`
359
+ - `RECEIPT_ID`
360
+ - `REGISTRATION_METHOD`
361
+ - `RETURNING_ARRIVAL_DATE`
362
+ - `RETURNING_DEPARTURE_DATE`
363
+ - `REVENUE`
364
+ - `SCORE`
365
+ - `SEARCH_STRING`
366
+ - `SUBSCRIPTION_ID`
367
+ - `SUCCESS`
368
+ - `SUGGESTED_DESTINATIONS`
369
+ - `SUGGESTED_HOTELS`
370
+ - `TRAVEL_START`
371
+ - `TRAVEL_END`
372
+ - `USER_SCORE`
373
+ - `VALIDATED`
374
+ - `ACHIEVEMENT_ID`
375
+ - `COUPON_CODE`
376
+ - `CUSTOMER_SEGMENT`
377
+ - `DEEP_LINK`
378
+ - `EVENT_START`
379
+ - `EVENT_END`
380
+ - `LAT`
381
+ - `LONG`
382
+ - `NEW_VERSION`
383
+ - `OLD_VERSION`
384
+ - `REVIEW_TEXT`
385
+ - `TUTORIAL_ID`
386
+ - `VIRTUAL_CURRENCY_NAME`
387
+ - `PARAM_01`
388
+ - `PARAM_02`
389
+ - `PARAM_03`
390
+ - `PARAM_04`
391
+ - `PARAM_05`
392
+ - `PARAM_06`
393
+ - `PARAM_07`
394
+ - `PARAM_08`
395
+ - `PARAM_09`
396
+
397
+ ### Events buffering
398
+
399
+ Affise library will send any pending events with first opportunity,
400
+ but if there is no network connection or device is disabled, events are kept locally for 7 days before deletion.
401
+
402
+ ### Advertising Identifier (google) tracking
403
+
404
+ Advertising Identifier (google) tracking is supported automatically, no actions needed
405
+
406
+ ### Open Advertising Identifier (huawei) tracking
407
+
408
+ Open Advertising Identifier is supported automatically, no actions needed
409
+
410
+ ### Install referrer tracking
411
+
412
+ Install referrer tracking is supported automatically, no actions needed
413
+
414
+ ### Push token tracking
415
+
416
+ To let affise track push token you need to receive it from your push service provider, and pass to Affise library.
417
+ First add firebase integration to your app completing theese steps: https://firebase.google.com/docs/cloud-messaging/android/client
418
+
419
+ After you have done with firebase inegration, add to your cloud messaging service `onNewToken` method `Affise.addPushToken(token)`
420
+
421
+ ```typescript
422
+ import { Affise } from 'affise-attribution-lib';
423
+ import messaging from '@react-native-firebase/messaging';
424
+
425
+ const getToken = async () => {
426
+ const token = await messaging().getToken();
427
+ if (token) {
428
+ Affise.addPushToken(token);
429
+ }
430
+ };
431
+ ```
432
+
433
+ ### Reinstall Uninstall tracking
434
+
435
+ Affise automatically track reinstall events by using silent-push technology, to make this feature work, pass push token when it is recreated by user and on you application starts up
436
+
437
+ ```typescript
438
+ Affise.addPushToken(token);
439
+ ```
440
+
441
+ ### APK preinstall tracking
442
+
443
+ SDK is also supports scenario when APK is installed not from one of application markets, such as google play, huawei appgallery or amazon appstore
444
+ To use this feature, create file with name `partner_key` in your app assets directory, and write unique identifier inside, this key will be passed to our backend so you can track events by partner later in your Affise console.
445
+
446
+ ### Deeplinks
447
+
448
+ Register deeplink callback right after Affise.init(..)
449
+
450
+ ```typescript
451
+ Affise.init(..);
452
+ Affise.registerDeeplinkCallback((uri) => {
453
+
454
+ });
455
+ ```
456
+
457
+ #### Android
458
+
459
+ To integrate deeplink support in android you need:
460
+
461
+ Add intent filter to `AndroidManifest.xml` as in `example/android/app/src/main/AndroidManifest.xml`,
462
+
463
+ ```xml
464
+ <intent-filter android:autoVerify="true">
465
+ <action android:name="android.intent.action.VIEW" />
466
+
467
+ <category android:name="android.intent.category.DEFAULT" />
468
+ <category android:name="android.intent.category.BROWSABLE" />
469
+
470
+ <data
471
+ android:host="YOUR_AFFISE_APP_ID.affattr.com"
472
+ android:scheme="react" />
473
+ </intent-filter>
474
+ ```
475
+
476
+ #### iOS
477
+
478
+ To integrate deeplink support in iOS you need:
479
+
480
+ Add deeplink handler to `AppDelegate.mm` as in `example/ios/AffiseAttributionLibExample/AppDelegate.mm`
481
+ - [React Docs](https://reactnavigation.org/docs/deep-linking/#set-up-with-bare-react-native-projects)
482
+
483
+ ```objective-c
484
+ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
485
+ sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
486
+ {
487
+ return [RCTLinkingManager application:application openURL:url
488
+ sourceApplication:sourceApplication annotation:annotation];
489
+ }
490
+ ```
491
+
492
+ Add key `CFBundleURLTypes` to `Info.plist` as in `example/ios/AffiseAttributionLibExample/Info.plist`
493
+
494
+ ```html
495
+ <key>CFBundleURLTypes</key>
496
+ <array>
497
+ <dict>
498
+ <key>CFBundleTypeRole</key>
499
+ <string>Editor</string>
500
+ <key>CFBundleURLName</key>
501
+ <string>YOUR_AFFISE_APP_ID.affattr.com</string>
502
+ <key>CFBundleURLSchemes</key>
503
+ <array>
504
+ <string>react</string>
505
+ </array>
506
+ </dict>
507
+ </array>
508
+ ```
509
+
510
+ ### Offline mode
511
+
512
+ In some scenarious you would want to limit Affise network usage, to pause that activity call anywhere in your application following code after Affise init:
513
+
514
+ ```typescript
515
+ Affise.init(..);
516
+ Affise.setOfflineModeEnabled(true); // to enable offline mode
517
+ Affise.setOfflineModeEnabled(false); // to disable offline mode
518
+ ```
519
+
520
+ While offline mode is enabled, your metrics and other events are kept locally, and will be delivered once offline mode is disabled.
521
+ Offline mode is persistent as Application lifecycle, and will be disabled with process termination automaticly.
522
+ To check current offline mode status call:
523
+
524
+ ```typescript
525
+ Affise.isOfflineModeEnabled(); // returns true or false describing current tracking state
526
+ ```
527
+
528
+ ### Disable tracking
529
+
530
+ To disable any tracking activity, storing events and gathering device identifiers and metrics call anywhere in your application following code after Affise init:
531
+
532
+ ```typescript
533
+ Affise.init(..);
534
+ Affise.setTrackingEnabled(true); // to enable tracking
535
+ Affise.setTrackingEnabled(false); // to disable tracking
536
+ ```
537
+
538
+ By default tracking is enabled.
539
+
540
+ While tracking mode is disabled, metrics and other identifiers is not generated locally.
541
+ Keep in mind that this flag is persistent until app reinstall, and don't forget to reactivate tracking when needed.
542
+ To check current status of tracking call:
543
+
544
+ ```typescript
545
+ Affise.isTrackingEnabled().then((enabled) => {
546
+ // returns true or false describing current tracking state
547
+ });
548
+ ```
549
+
550
+ ### Disable background tracking
551
+
552
+ To disable any background tracking activity, storing events and gathering device identifiers and metrics call anywhere in your application following code after Affise init:
553
+
554
+ ```typescript
555
+ Affise.init(..);
556
+ Affise.setBackgroundTrackingEnabled(true); // to enable background tracking
557
+ Affise.setBackgroundTrackingEnabled(false); // to disable background tracking
558
+ ```
559
+
560
+ By default background tracking is enabled.
561
+
562
+ While background tracking mode is disabled, metrics and other identifiers is not generated locally.
563
+ Background tracking mode is persistent as Application lifecycle, and will be re-enabled with process termination automatically.
564
+ To check current status of background tracking call:
565
+
566
+ ```typescript
567
+ Affise.isBackgroundTrackingEnabled().then((enabled) => {
568
+ // returns true or false describing current background tracking state
569
+ });
570
+ ```
571
+
572
+ ### GDPR right to be forgotten
573
+
574
+ Under the EU's General Data Protection Regulation (GDPR): An individual has the right to have their personal data erased.
575
+ To provide this functionality to user, as the app developer, you can call
576
+
577
+ ```typescript
578
+ Affise.init(..);
579
+ Affise.forget(); // to forget users data
580
+ ```
581
+
582
+ After processing such request our backend servers will delete all users data.
583
+ To prevent library from generating new events, disable tracking just before calling Affise.forget:
584
+
585
+ ```typescript
586
+ Affise.init(..);
587
+ Affise.setTrackingEnabled(false);
588
+ Affise.forget(); // to forget users data
589
+ ```
590
+
591
+
592
+ ### Platform specific
593
+
594
+ ### Get referrer
595
+ > `Android Only`
596
+
597
+ Use the next public method of SDK
598
+
599
+ ```typescript
600
+ Affise.getReferrer().then((referrer) => {
601
+ // returns referrer
602
+ });
603
+ ```
604
+
605
+ #### Get referrer value
606
+ > `Android Only`
607
+
608
+ Use the next public method of SDK to get referrer value by
609
+
610
+ ```typescript
611
+ Affise.android.getReferrerValue(ReferrerKey.CLICK_ID, (value) => {
612
+
613
+ })
614
+ ```
615
+
616
+ #### Referrer keys
617
+
618
+ In examples above `ReferrerKey.CLICK_ID` is used, but many others is available:
619
+
620
+ - `AD_ID`
621
+ - `CAMPAIGN_ID`
622
+ - `CLICK_ID`
623
+ - `AFFISE_AD`
624
+ - `AFFISE_AD_ID`
625
+ - `AFFISE_AD_TYPE`
626
+ - `AFFISE_ADSET`
627
+ - `AFFISE_ADSET_ID`
628
+ - `AFFISE_AFFC_ID`
629
+ - `AFFISE_CHANNEL`
630
+ - `AFFISE_CLICK_LOOK_BACK`
631
+ - `AFFISE_COST_CURRENCY`
632
+ - `AFFISE_COST_MODEL`
633
+ - `AFFISE_COST_VALUE`
634
+ - `AFFISE_DEEPLINK`
635
+ - `AFFISE_KEYWORDS`
636
+ - `AFFISE_MEDIA_TYPE`
637
+ - `AFFISE_MODEL`
638
+ - `AFFISE_OS`
639
+ - `AFFISE_PARTNER`
640
+ - `AFFISE_REF`
641
+ - `AFFISE_SITE_ID`
642
+ - `AFFISE_SUB_SITE_ID`
643
+ - `AFFC`
644
+ - `PID`
645
+ - `SUB_1`
646
+ - `SUB_2`
647
+ - `SUB_3`
648
+ - `SUB_4`
649
+ - `SUB_5`
650
+
651
+
652
+ #### SKAd
653
+ > `iOS Only`
654
+
655
+ For ios prior `16.1` first call
656
+ ```typescript
657
+ Affise.ios.registerAppForAdNetworkAttribution((error) => {
658
+
659
+ });
660
+ ```
661
+
662
+ Updates the fine and coarse conversion values, and calls a completion handler if the update fails.
663
+ Second argument coarseValue is available in iOS 16.1+
664
+ ```typescript
665
+ Affise.ios.updatePostbackConversionValue(1, "medium", (error) => {
666
+
667
+ });
668
+ ```