@attryio/react-native 0.1.6 → 0.1.7
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 +113 -9
- package/dist/index.js +1 -1
- package/package.json +26 -2
package/README.md
CHANGED
|
@@ -1,40 +1,144 @@
|
|
|
1
1
|
# @attryio/react-native
|
|
2
2
|
|
|
3
|
-
React Native SDK for Attry mobile attribution.
|
|
3
|
+
React Native SDK for [Attry](https://attry.io), a mobile app analytics and attribution platform for campaign analytics, app user analytics, deep links, deferred deep links, and revenue events.
|
|
4
|
+
|
|
5
|
+
Use this package when your app is built with React Native. It collects install/open/session signals automatically, keeps one stable installation ID, resolves Attry deep links, and lets you send custom product events with structured properties.
|
|
6
|
+
|
|
7
|
+
## Links
|
|
8
|
+
|
|
9
|
+
- Website: [attry.io](https://attry.io)
|
|
10
|
+
- Dashboard: [app.attry.io](https://app.attry.io)
|
|
11
|
+
- Event tracking docs: [attry.io/resources/event-tracking](https://attry.io/resources/event-tracking)
|
|
12
|
+
- Standard events: [attry.io/resources/standard-events](https://attry.io/resources/standard-events)
|
|
13
|
+
- Domain setup: [attry.io/resources/domain-setup](https://attry.io/resources/domain-setup)
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm install @attryio/react-native
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
For iOS, install pods after adding the package:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
cd ios && pod install
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Use the App ID and live SDK key from **Settings -> SDK install** in your Attry dashboard. Each Attry app has one App ID and one live key; you do not need separate keys for iOS and Android.
|
|
28
|
+
|
|
29
|
+
## Quick start
|
|
30
|
+
|
|
31
|
+
Create the client once during app startup.
|
|
4
32
|
|
|
5
33
|
```ts
|
|
6
34
|
import { createAttryReactNative } from "@attryio/react-native";
|
|
7
35
|
|
|
8
|
-
const attry = await createAttryReactNative({
|
|
36
|
+
export const attry = await createAttryReactNative({
|
|
9
37
|
appId: "457064853",
|
|
10
38
|
apiKey: "attry_live_..."
|
|
11
39
|
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The SDK starts with practical defaults:
|
|
43
|
+
|
|
44
|
+
- Tracks the first SDK install, app opens, session starts/ends, foreground/background changes, and deep link opens.
|
|
45
|
+
- Collects React Native context such as platform, app version, build, OS version, device model, locale, timezone, screen, and available country context.
|
|
46
|
+
- Resolves Android Google Play Install Referrer when the native module is available.
|
|
47
|
+
- Requests Apple AdServices attribution tokens on iOS when the native module is available.
|
|
48
|
+
- Batches events and retries failed requests through the shared Attry SDK engine.
|
|
49
|
+
|
|
50
|
+
## Track custom events
|
|
51
|
+
|
|
52
|
+
Use `track` for app-specific actions. Event names should be stable `snake_case`; details belong in `properties`.
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
await attry.track("flashcards_generated", {
|
|
56
|
+
properties: {
|
|
57
|
+
deckId: "deck_123",
|
|
58
|
+
cardCount: 18,
|
|
59
|
+
source: "lesson"
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
```
|
|
12
63
|
|
|
64
|
+
Attach a signed-in user ID with `identify`. This is a method, not an event.
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
attry.identify("user_123");
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Purchase intent and revenue
|
|
71
|
+
|
|
72
|
+
Use `initiatePurchase` when the user starts a checkout, subscription, or paywall purchase flow.
|
|
73
|
+
|
|
74
|
+
```ts
|
|
13
75
|
await attry.initiatePurchase({
|
|
14
76
|
properties: {
|
|
15
77
|
productId: "pro_monthly",
|
|
16
78
|
placement: "paywall"
|
|
17
79
|
}
|
|
18
80
|
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Use `purchase` when money was actually captured or a paid conversion happened. `purchase` must include `value` or `amountMinor` plus `currency`.
|
|
19
84
|
|
|
85
|
+
```ts
|
|
20
86
|
await attry.purchase({
|
|
21
87
|
value: 31.42,
|
|
22
88
|
currency: "USD",
|
|
23
89
|
productId: "pro_monthly",
|
|
24
|
-
transactionId: "txn_123"
|
|
90
|
+
transactionId: "txn_123",
|
|
91
|
+
store: "app_store",
|
|
92
|
+
properties: {
|
|
93
|
+
plan: "monthly"
|
|
94
|
+
}
|
|
25
95
|
});
|
|
26
96
|
```
|
|
27
97
|
|
|
28
|
-
|
|
98
|
+
Attry stores revenue as stable minor-unit fields, so campaign revenue is not guessed from arbitrary custom properties.
|
|
29
99
|
|
|
30
100
|
## Standard events
|
|
31
101
|
|
|
32
102
|
Attry accepts custom event names, but these standard names are reserved for dashboard reporting:
|
|
33
103
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
104
|
+
| Event | Sent by | Purpose |
|
|
105
|
+
| --- | --- | --- |
|
|
106
|
+
| `install` | SDK | First SDK install for the current app installation. |
|
|
107
|
+
| `open` | SDK | App opened or became active. |
|
|
108
|
+
| `session_started` | SDK | A new app usage session started. |
|
|
109
|
+
| `session_ended` | SDK | A session ended after backgrounding or timeout. |
|
|
110
|
+
| `app_foreground` | SDK | App returned to the foreground. |
|
|
111
|
+
| `app_background` | SDK | App moved to the background. |
|
|
112
|
+
| `deep_link_opened` | SDK | App opened from a deep link, universal link, or app link. |
|
|
113
|
+
| `initiate_purchase` | App | User started a purchase or subscription flow. |
|
|
114
|
+
| `purchase` | App | Paid conversion or purchase revenue. Requires revenue. |
|
|
115
|
+
|
|
116
|
+
Everything else can be sent as a custom event with `track("your_event_name", { properties })`.
|
|
117
|
+
|
|
118
|
+
## Configuration
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
const attry = await createAttryReactNative({
|
|
122
|
+
appId: "457064853",
|
|
123
|
+
apiKey: "attry_live_...",
|
|
124
|
+
autoTrackLifecycleEvents: true,
|
|
125
|
+
autoTrackDeepLinks: true,
|
|
126
|
+
autoCollectInstallAttribution: true,
|
|
127
|
+
sessionTimeoutMs: 30 * 60 * 1000,
|
|
128
|
+
context: {
|
|
129
|
+
appName: "Noteasy"
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Useful options:
|
|
135
|
+
|
|
136
|
+
- `endpoint`: custom Attry API endpoint. Defaults to `https://api.attry.io`.
|
|
137
|
+
- `autoTrackLifecycleEvents`: disable automatic lifecycle events when set to `false`.
|
|
138
|
+
- `autoTrackDeepLinks`: disable automatic deep link tracking when set to `false`.
|
|
139
|
+
- `autoCollectInstallAttribution`: disable Apple AdServices and Play Install Referrer collection when set to `false`.
|
|
140
|
+
- `context`: extra app, device, or release metadata attached to every event.
|
|
37
141
|
|
|
38
|
-
|
|
142
|
+
## Need help?
|
|
39
143
|
|
|
40
|
-
|
|
144
|
+
Email [hello@attry.io](mailto:hello@attry.io) or open the [Attry dashboard](https://app.attry.io).
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Attry, ATTRY_EVENTS, MemoryStorage, parseAttryUrl } from "@attryio/sdk-core";
|
|
2
2
|
const SDK_NAME = "attry-react-native";
|
|
3
|
-
const SDK_VERSION = "0.1.
|
|
3
|
+
const SDK_VERSION = "0.1.7";
|
|
4
4
|
export { parseAttryUrl };
|
|
5
5
|
export async function createAttryReactNative(config) {
|
|
6
6
|
const rn = await loadReactNative();
|
package/package.json
CHANGED
|
@@ -1,9 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@attryio/react-native",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
|
+
"description": "React Native SDK for Attry mobile app analytics, attribution, deep links, deferred deep links, and revenue events.",
|
|
4
5
|
"private": false,
|
|
5
6
|
"license": "Apache-2.0",
|
|
6
7
|
"type": "module",
|
|
8
|
+
"homepage": "https://attry.io",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/mozhn/attry.io.git",
|
|
12
|
+
"directory": "packages/sdk-react-native"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/mozhn/attry.io/issues"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"attry",
|
|
19
|
+
"react native analytics",
|
|
20
|
+
"react native attribution",
|
|
21
|
+
"mobile analytics",
|
|
22
|
+
"mobile attribution",
|
|
23
|
+
"deep links",
|
|
24
|
+
"deferred deep links",
|
|
25
|
+
"app analytics",
|
|
26
|
+
"campaign analytics",
|
|
27
|
+
"revenue analytics",
|
|
28
|
+
"apple search ads",
|
|
29
|
+
"install referrer"
|
|
30
|
+
],
|
|
7
31
|
"main": "./dist/index.js",
|
|
8
32
|
"types": "./dist/index.d.ts",
|
|
9
33
|
"exports": {
|
|
@@ -31,7 +55,7 @@
|
|
|
31
55
|
"access": "public"
|
|
32
56
|
},
|
|
33
57
|
"dependencies": {
|
|
34
|
-
"@attryio/sdk-core": "0.1.
|
|
58
|
+
"@attryio/sdk-core": "0.1.4",
|
|
35
59
|
"@react-native-async-storage/async-storage": "^2.2.0"
|
|
36
60
|
},
|
|
37
61
|
"peerDependencies": {
|