@attryio/react-native 0.1.1 → 0.1.3
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 +21 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -9
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -10,13 +10,31 @@ const attry = await createAttryReactNative({
|
|
|
10
10
|
apiKey: "attry_live_..."
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
await attry.
|
|
13
|
+
await attry.initiatePurchase({
|
|
14
14
|
properties: {
|
|
15
|
-
|
|
15
|
+
productId: "pro_monthly",
|
|
16
|
+
placement: "paywall"
|
|
16
17
|
}
|
|
17
18
|
});
|
|
18
19
|
|
|
19
|
-
await attry.
|
|
20
|
+
await attry.purchase({
|
|
21
|
+
value: 31.42,
|
|
22
|
+
currency: "USD",
|
|
23
|
+
productId: "pro_monthly",
|
|
24
|
+
transactionId: "txn_123"
|
|
25
|
+
});
|
|
20
26
|
```
|
|
21
27
|
|
|
22
28
|
The SDK auto-tracks first SDK install, app opens, sessions, foreground/background transitions, deep link opens, Apple AdServices tokens on iOS, and Google Play Install Referrer on Android when the native modules are available.
|
|
29
|
+
|
|
30
|
+
## Standard events
|
|
31
|
+
|
|
32
|
+
Attry accepts custom event names, but these standard names are reserved for dashboard reporting:
|
|
33
|
+
|
|
34
|
+
- Lifecycle: `install`, `open`, `session_started`, `session_ended`, `app_foreground`, `app_background`, `deep_link_opened`
|
|
35
|
+
- Revenue: `purchase`
|
|
36
|
+
- Commerce/content: `initiate_purchase`
|
|
37
|
+
|
|
38
|
+
`identify()` is a convenience method that attaches a known user ID to later events; it is not sent as a standard event. Any other product action can still be sent with `track("your_event_name", { properties })`.
|
|
39
|
+
|
|
40
|
+
Purchase events must include `value` or `amountMinor` plus `currency`. Attry stores them as stable minor-unit revenue fields so dashboard revenue is not guessed from arbitrary properties.
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAGL,aAAa,EACb,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,YAAY,EAClB,MAAM,mBAAmB,CAAC;AAE3B,KAAK,eAAe,GAAG;IACrB,QAAQ,CAAC,EAAE;QACT,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,gBAAgB,CAAC,EAAE,CACjB,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,KAC9B;YAAE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;SAAE,CAAC;KAC9B,CAAC;IACF,UAAU,CAAC,EAAE;QACX,GAAG,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,GAAG,QAAQ,KAAK;YACxC,KAAK,CAAC,EAAE,MAAM,CAAC;YACf,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,KAAK,CAAC,EAAE,MAAM,CAAC;SAChB,CAAC;KACH,CAAC;IACF,WAAW,CAAC,EAAE;QACZ,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B,CAAC;IACF,OAAO,CAAC,EAAE;QACR,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;QAC7C,gBAAgB,CAAC,EAAE,CACjB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,OAAO,EAAE;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,KAAK,IAAI,KACzC;YAAE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;SAAE,CAAC;KAC9B,CAAC;IACF,aAAa,CAAC,EAAE;QACd,aAAa,CAAC,EAAE;YACd,gBAAgB,EAAE,MAAM,OAAO,CAAC,MA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AAE,MAAM,CAAA;CAAE,iBAqFtD;AAED,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,KAAK,EACb,EAAE,8BAAmB,iBAUtB;AAED,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,KAAK,EACb,EAAE,8BAAmB,iBAiCtB"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Attry, MemoryStorage, parseAttryUrl } from "@attryio/sdk-core";
|
|
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.3";
|
|
4
4
|
export { parseAttryUrl };
|
|
5
5
|
export async function createAttryReactNative(config) {
|
|
6
6
|
const rn = getReactNative();
|
|
@@ -130,7 +130,7 @@ export async function attachReactNativeLifecycleTracking(client, rn = getReactNa
|
|
|
130
130
|
const sessionId = `ses_${sessionStartedAt.toString(36)}`;
|
|
131
131
|
if (!(await storage.getItem(installKey))) {
|
|
132
132
|
await storage.setItem(installKey, new Date().toISOString());
|
|
133
|
-
await client.track(
|
|
133
|
+
await client.track(ATTRY_EVENTS.INSTALL, {
|
|
134
134
|
properties: {
|
|
135
135
|
auto: true,
|
|
136
136
|
firstSdkOpen: true
|
|
@@ -140,7 +140,7 @@ export async function attachReactNativeLifecycleTracking(client, rn = getReactNa
|
|
|
140
140
|
}
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
|
-
await client.track(
|
|
143
|
+
await client.track(ATTRY_EVENTS.OPEN, {
|
|
144
144
|
properties: {
|
|
145
145
|
auto: true,
|
|
146
146
|
appState: rn?.AppState?.currentState ?? "active"
|
|
@@ -149,7 +149,7 @@ export async function attachReactNativeLifecycleTracking(client, rn = getReactNa
|
|
|
149
149
|
sessionId
|
|
150
150
|
}
|
|
151
151
|
});
|
|
152
|
-
await client.track(
|
|
152
|
+
await client.track(ATTRY_EVENTS.SESSION_STARTED, {
|
|
153
153
|
properties: {
|
|
154
154
|
auto: true
|
|
155
155
|
},
|
|
@@ -165,7 +165,7 @@ export async function attachReactNativeLifecycleTracking(client, rn = getReactNa
|
|
|
165
165
|
if (state === "active" && !active) {
|
|
166
166
|
active = true;
|
|
167
167
|
lastActiveAt = now;
|
|
168
|
-
void client.track(
|
|
168
|
+
void client.track(ATTRY_EVENTS.APP_FOREGROUND, {
|
|
169
169
|
properties: {
|
|
170
170
|
auto: true
|
|
171
171
|
},
|
|
@@ -178,7 +178,7 @@ export async function attachReactNativeLifecycleTracking(client, rn = getReactNa
|
|
|
178
178
|
if ((state === "background" || state === "inactive") && active) {
|
|
179
179
|
active = false;
|
|
180
180
|
const durationMs = Math.max(0, now - lastActiveAt);
|
|
181
|
-
void client.track(
|
|
181
|
+
void client.track(ATTRY_EVENTS.APP_BACKGROUND, {
|
|
182
182
|
properties: {
|
|
183
183
|
auto: true,
|
|
184
184
|
durationMs
|
|
@@ -188,7 +188,7 @@ export async function attachReactNativeLifecycleTracking(client, rn = getReactNa
|
|
|
188
188
|
}
|
|
189
189
|
});
|
|
190
190
|
if (durationMs >= sessionTimeoutMs || state === "background") {
|
|
191
|
-
void client.track(
|
|
191
|
+
void client.track(ATTRY_EVENTS.SESSION_ENDED, {
|
|
192
192
|
properties: {
|
|
193
193
|
auto: true,
|
|
194
194
|
durationMs: Math.max(0, now - sessionStartedAt)
|
|
@@ -261,7 +261,7 @@ async function trackDeepLinkOpen(client, url, openType, rn = getReactNative()) {
|
|
|
261
261
|
openedFromAndroidAppLink
|
|
262
262
|
});
|
|
263
263
|
}
|
|
264
|
-
await client.track(
|
|
264
|
+
await client.track(ATTRY_EVENTS.DEEP_LINK_OPENED, {
|
|
265
265
|
properties: {
|
|
266
266
|
openType,
|
|
267
267
|
url: parsed.url,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@attryio/react-native",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@attryio/sdk-core": "0.1.
|
|
32
|
+
"@attryio/sdk-core": "0.1.3"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react-native": ">=0.72"
|