@app-swiss-knife/react-native-sdk 0.4.0 → 0.5.0
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/CHANGELOG.md +385 -2
- package/LICENSE +21 -0
- package/README.md +229 -42
- package/SwissKnifePurchases.podspec +1 -1
- package/android/build.gradle +24 -2
- package/android/consumer-rules.pro +12 -0
- package/android/src/main/AndroidManifest.xml +15 -1
- package/android/src/main/java/com/swissknife/crashreporting/SKCrashReportingModule.kt +5 -4
- package/android/src/main/java/com/swissknife/purchases/SwissKnifeJson.kt +7 -2
- package/android/src/main/java/com/swissknife/purchases/SwissKnifePurchasesModule.kt +168 -6
- package/android/src/play/java/com/swissknife/purchases/StoreIntentHandler.kt +7 -0
- package/android/src/rustore/java/com/swissknife/purchases/StoreIntentHandler.kt +9 -0
- package/android/vendor/java/com/appswissknife/SwissKnife.kt +107 -38
- package/android/vendor/java/com/appswissknife/analytics/SKAnalytics.kt +180 -115
- package/android/vendor/java/com/appswissknife/attributes/AttributesClient.kt +16 -18
- package/android/vendor/java/com/appswissknife/attributes/SetAttributesWorker.kt +13 -13
- package/android/vendor/java/com/appswissknife/attribution/Attribution.kt +56 -25
- package/android/vendor/java/com/appswissknife/context/DeviceContext.kt +1 -1
- package/android/vendor/java/com/appswissknife/crashreporting/SKCrashReporting.kt +365 -206
- package/android/vendor/java/com/appswissknife/entitlements/EntitlementsRepository.kt +195 -26
- package/android/vendor/java/com/appswissknife/identity/Identity.kt +31 -6
- package/android/vendor/java/com/appswissknife/models/PurchasesError.kt +5 -0
- package/android/vendor/java/com/appswissknife/net/BackendHttpClient.kt +56 -31
- package/android/vendor/java/com/appswissknife/net/IngestClient.kt +673 -87
- package/android/vendor/java/com/appswissknife/net/OfflineQueueStore.kt +214 -30
- package/android/vendor/java/com/appswissknife/notifications/NotificationRenderer.kt +195 -0
- package/android/vendor/java/com/appswissknife/notifications/PermissionRequestActivity.kt +60 -0
- package/android/vendor/java/com/appswissknife/notifications/PermissionStatus.kt +41 -0
- package/android/vendor/java/com/appswissknife/notifications/PushEventQueue.kt +143 -0
- package/android/vendor/java/com/appswissknife/notifications/PushPayload.kt +72 -0
- package/android/vendor/java/com/appswissknife/notifications/PushRegistration.kt +89 -0
- package/android/vendor/java/com/appswissknife/notifications/SwissKnifeMessagingService.kt +57 -0
- package/android/vendor/java/com/appswissknife/notifications/SwissKnifeNotifications.kt +438 -0
- package/android/vendor/java/com/appswissknife/offerings/OfferingsRepository.kt +266 -64
- package/android/vendor/java/com/appswissknife/performance/SKPerformance.kt +1 -0
- package/android/vendor/java/com/appswissknife/purchases/BillingClientGateway.kt +545 -88
- package/android/vendor/java/com/appswissknife/purchases/PlayPriceEnrichmentProvider.kt +55 -24
- package/android/vendor/java/com/appswissknife/purchases/ProductKindHint.kt +21 -0
- package/android/vendor/java/com/appswissknife/purchases/PurchasesGateway.kt +14 -0
- package/android/vendor-rustore/AndroidManifest.xml +59 -0
- package/android/vendor-rustore/java/com/appswissknife/rustore/RuStoreGateway.kt +428 -0
- package/android/vendor-rustore/java/com/appswissknife/rustore/RuStoreInitProvider.kt +43 -0
- package/android/vendor-rustore/java/com/appswissknife/rustore/RuStorePriceEnrichmentProvider.kt +85 -0
- package/app.plugin.js +287 -0
- package/ios/SwissKnifePurchases.m +20 -0
- package/ios/SwissKnifePurchases.swift +97 -3
- package/ios/SwissKnifePushBootstrap.m +34 -0
- package/ios/vendor/SwissKnifeiOS/Analytics/SKAnalytics.swift +138 -89
- package/ios/vendor/SwissKnifeiOS/Context/DeviceContext.swift +1 -1
- package/ios/vendor/SwissKnifeiOS/CrashReporting/SKCrashReporting.swift +345 -44
- package/ios/vendor/SwissKnifeiOS/Net/BackendBackoffGate.swift +43 -2
- package/ios/vendor/SwissKnifeiOS/Net/IngestClient.swift +495 -16
- package/ios/vendor/SwissKnifeiOS/Net/OfflineQueueStore.swift +231 -23
- package/ios/vendor/SwissKnifeiOS/Notifications/PushPayload.swift +87 -0
- package/ios/vendor/SwissKnifeiOS/Notifications/PushRegistrar.swift +322 -0
- package/ios/vendor/SwissKnifeiOS/Notifications/SwissKnife+Notifications.swift +403 -0
- package/ios/vendor/SwissKnifeiOS/Performance/SKPerformance.swift +1 -0
- package/ios/vendor/SwissKnifeiOS/Services/EntitlementsService.swift +11 -7
- package/ios/vendor/SwissKnifeiOS/Services/PurchaseService.swift +38 -7
- package/ios/vendor/SwissKnifeiOS/SwissKnife.swift +34 -6
- package/lib/commonjs/attribution.js +4 -3
- package/lib/commonjs/attribution.js.map +1 -1
- package/lib/commonjs/identity.js +12 -11
- package/lib/commonjs/identity.js.map +1 -1
- package/lib/commonjs/index.js +16 -5
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internal/config.js +105 -8
- package/lib/commonjs/internal/config.js.map +1 -1
- package/lib/commonjs/internal/telemetry-context.js +70 -0
- package/lib/commonjs/internal/telemetry-context.js.map +1 -0
- package/lib/commonjs/modules/analytics.js +18 -25
- package/lib/commonjs/modules/analytics.js.map +1 -1
- package/lib/commonjs/modules/crash-reporting.js +27 -6
- package/lib/commonjs/modules/crash-reporting.js.map +1 -1
- package/lib/commonjs/modules/log.js +1 -1
- package/lib/commonjs/modules/notifications.js +500 -0
- package/lib/commonjs/modules/notifications.js.map +1 -0
- package/lib/commonjs/modules/performance.js +57 -8
- package/lib/commonjs/modules/performance.js.map +1 -1
- package/lib/commonjs/native/module.js +6 -0
- package/lib/commonjs/native/module.js.map +1 -1
- package/lib/commonjs/native/spec.js +12 -5
- package/lib/commonjs/native/spec.js.map +1 -1
- package/lib/commonjs/purchases.js +4 -4
- package/lib/commonjs/types.js +12 -15
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/attribution.js +4 -3
- package/lib/module/attribution.js.map +1 -1
- package/lib/module/identity.js +12 -11
- package/lib/module/identity.js.map +1 -1
- package/lib/module/index.js +8 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal/config.js +103 -8
- package/lib/module/internal/config.js.map +1 -1
- package/lib/module/internal/telemetry-context.js +63 -0
- package/lib/module/internal/telemetry-context.js.map +1 -0
- package/lib/module/modules/analytics.js +18 -25
- package/lib/module/modules/analytics.js.map +1 -1
- package/lib/module/modules/crash-reporting.js +27 -6
- package/lib/module/modules/crash-reporting.js.map +1 -1
- package/lib/module/modules/log.js +1 -1
- package/lib/module/modules/notifications.js +491 -0
- package/lib/module/modules/notifications.js.map +1 -0
- package/lib/module/modules/performance.js +57 -8
- package/lib/module/modules/performance.js.map +1 -1
- package/lib/module/native/module.js +6 -1
- package/lib/module/native/module.js.map +1 -1
- package/lib/module/native/spec.js +11 -4
- package/lib/module/native/spec.js.map +1 -1
- package/lib/module/purchases.js +4 -4
- package/lib/module/types.js +12 -15
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/commonjs/attribution.d.ts +3 -2
- package/lib/typescript/commonjs/attribution.d.ts.map +1 -1
- package/lib/typescript/commonjs/identity.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +2 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/internal/config.d.ts +16 -2
- package/lib/typescript/commonjs/internal/config.d.ts.map +1 -1
- package/lib/typescript/commonjs/internal/telemetry-context.d.ts +22 -0
- package/lib/typescript/commonjs/internal/telemetry-context.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/analytics.d.ts +8 -11
- package/lib/typescript/commonjs/modules/analytics.d.ts.map +1 -1
- package/lib/typescript/commonjs/modules/crash-reporting.d.ts +18 -5
- package/lib/typescript/commonjs/modules/crash-reporting.d.ts.map +1 -1
- package/lib/typescript/commonjs/modules/notifications.d.ts +110 -0
- package/lib/typescript/commonjs/modules/notifications.d.ts.map +1 -0
- package/lib/typescript/commonjs/modules/performance.d.ts +13 -0
- package/lib/typescript/commonjs/modules/performance.d.ts.map +1 -1
- package/lib/typescript/commonjs/native/module.d.ts +2 -0
- package/lib/typescript/commonjs/native/module.d.ts.map +1 -1
- package/lib/typescript/commonjs/native/spec.d.ts +33 -4
- package/lib/typescript/commonjs/native/spec.d.ts.map +1 -1
- package/lib/typescript/commonjs/purchases.d.ts +4 -4
- package/lib/typescript/commonjs/types.d.ts +4 -5
- package/lib/typescript/commonjs/types.d.ts.map +1 -1
- package/lib/typescript/module/attribution.d.ts +3 -2
- package/lib/typescript/module/attribution.d.ts.map +1 -1
- package/lib/typescript/module/identity.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +2 -0
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/internal/config.d.ts +16 -2
- package/lib/typescript/module/internal/config.d.ts.map +1 -1
- package/lib/typescript/module/internal/telemetry-context.d.ts +22 -0
- package/lib/typescript/module/internal/telemetry-context.d.ts.map +1 -0
- package/lib/typescript/module/modules/analytics.d.ts +8 -11
- package/lib/typescript/module/modules/analytics.d.ts.map +1 -1
- package/lib/typescript/module/modules/crash-reporting.d.ts +18 -5
- package/lib/typescript/module/modules/crash-reporting.d.ts.map +1 -1
- package/lib/typescript/module/modules/notifications.d.ts +110 -0
- package/lib/typescript/module/modules/notifications.d.ts.map +1 -0
- package/lib/typescript/module/modules/performance.d.ts +13 -0
- package/lib/typescript/module/modules/performance.d.ts.map +1 -1
- package/lib/typescript/module/native/module.d.ts +2 -0
- package/lib/typescript/module/native/module.d.ts.map +1 -1
- package/lib/typescript/module/native/spec.d.ts +33 -4
- package/lib/typescript/module/native/spec.d.ts.map +1 -1
- package/lib/typescript/module/purchases.d.ts +4 -4
- package/lib/typescript/module/types.d.ts +4 -5
- package/lib/typescript/module/types.d.ts.map +1 -1
- package/package.json +12 -4
- package/src/attribution.ts +4 -3
- package/src/identity.ts +12 -11
- package/src/index.ts +16 -4
- package/src/internal/config.ts +113 -8
- package/src/internal/telemetry-context.ts +76 -0
- package/src/modules/analytics.ts +24 -33
- package/src/modules/crash-reporting.ts +50 -9
- package/src/modules/log.ts +1 -1
- package/src/modules/notifications.ts +557 -0
- package/src/modules/performance.ts +94 -14
- package/src/native/module.ts +6 -0
- package/src/native/spec.ts +45 -10
- package/src/purchases.ts +4 -4
- package/src/types.ts +12 -15
- package/android/vendor/java/com/appswissknife/analytics/EventQueueStore.kt +0 -326
- package/android/vendor/java/com/appswissknife/analytics/FlushEventsWorker.kt +0 -296
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,365 @@ While the major version is `0`, a minor bump may carry behavioral changes that a
|
|
|
10
10
|
The native iOS and Android SDKs are not published separately — their sources are
|
|
11
11
|
vendored into this npm tarball at pack time, so a version here covers all three.
|
|
12
12
|
|
|
13
|
+
## [Unreleased]
|
|
14
|
+
|
|
15
|
+
## [0.5.0] - 2026-11-24
|
|
16
|
+
|
|
17
|
+
Push notifications, Android offerings and one-time products, Google Play
|
|
18
|
+
purchase reliability (pending payments, acknowledgements, reconnects), and
|
|
19
|
+
native telemetry that no longer stalls or drops a batch on a server refusal.
|
|
20
|
+
Several fixes live in the native iOS and Android code, so they reach users
|
|
21
|
+
only through a new store build. Some calls behave differently: read
|
|
22
|
+
**Upgrading from 0.4.x** before you ship.
|
|
23
|
+
|
|
24
|
+
### Upgrading from 0.4.x
|
|
25
|
+
|
|
26
|
+
1. **Bump the dependency and commit the lockfile.**
|
|
27
|
+
`npm install @app-swiss-knife/react-native-sdk@0.5.0` (or `yarn add` /
|
|
28
|
+
`pnpm add` with the same version), then commit `package.json` and the
|
|
29
|
+
lockfile so local, CI and EAS builds all resolve 0.5.0. `npx expo install`
|
|
30
|
+
works too, but this version ships an Expo config plugin, so it also adds
|
|
31
|
+
the package to `plugins` in `app.json` (or, with an `app.config.js`, asks
|
|
32
|
+
you to). The plugin sets the app up for push: the `aps-environment`
|
|
33
|
+
entitlement on iOS, which fails signing with a provisioning profile that
|
|
34
|
+
lacks the Push Notifications capability, and Firebase Cloud Messaging on
|
|
35
|
+
Android. Keep the plugin entry only if you use Swiss Knife push or RuStore
|
|
36
|
+
billing.
|
|
37
|
+
2. **Rebuild the native app.** Expo: `npx expo prebuild --clean` (or let EAS
|
|
38
|
+
Build run prebuild), then build. Bare React Native: `cd ios && pod install`,
|
|
39
|
+
and a Gradle sync or clean build on Android. Ship 0.5.0 as a new store
|
|
40
|
+
build: an over-the-air JS update on top of a 0.4.x binary does not carry the
|
|
41
|
+
native fixes, and the JS and native halves must come from the same version.
|
|
42
|
+
3. **Handle the behaviour changes** (details under **Changed**):
|
|
43
|
+
- `configure()` and `configureCore()` throw synchronously when `apiKey` is
|
|
44
|
+
empty or whitespace. Make sure every build profile, release included,
|
|
45
|
+
provides the key. `CrashReporting.init` with an empty key now logs an
|
|
46
|
+
error and stays off (0.4.x installed its handlers anyway and, on Android,
|
|
47
|
+
could keep the real key from reaching native delivery).
|
|
48
|
+
- iOS: `restorePurchases()` can show an Apple ID sign-in sheet. Call it only
|
|
49
|
+
from a "Restore purchases" button. To read the current state at launch,
|
|
50
|
+
use `getCustomerInfo()`.
|
|
51
|
+
- Android (Play): a pending payment (cash, deferred payment) rejects the
|
|
52
|
+
purchase with `PAYMENT_PENDING_ERROR` instead of resolving. Show "payment
|
|
53
|
+
pending" rather than an error or a cancellation. Once the payment clears,
|
|
54
|
+
Play delivers the purchase again (or the next launch finds it), and the
|
|
55
|
+
SDK validates it, re-reads the entitlements and sends the new
|
|
56
|
+
CustomerInfo to `addCustomerInfoUpdateListener` listeners. Listen there to
|
|
57
|
+
unlock the content; no restore is needed.
|
|
58
|
+
- Android: `getCustomerInfo()` reads the entitlements from the server. With
|
|
59
|
+
nothing cached and the server unreachable or answering with an error, it
|
|
60
|
+
rejects with `NETWORK_ERROR`, as on iOS, instead of resolving with no
|
|
61
|
+
entitlements. Treat that as "unknown", not as "not subscribed".
|
|
62
|
+
- Android (Play): the SDK acknowledges one-time products and never consumes
|
|
63
|
+
them, so Play keeps a consumable owned: it can be bought once, and buying
|
|
64
|
+
it again rejects with `RECEIPT_ALREADY_IN_USE_ERROR`. Do not sell a
|
|
65
|
+
consumable for repeat purchase on Android yet.
|
|
66
|
+
- Android (Play): any HTTP error answer to purchase validation, 429 and 5xx
|
|
67
|
+
included, rejects with `UNEXPECTED_BACKEND_RESPONSE_ERROR` instead of
|
|
68
|
+
`NETWORK_ERROR`; `NETWORK_ERROR` now means no answer reached the device.
|
|
69
|
+
The JS error has no HTTP status field. If your app treated `NETWORK_ERROR`
|
|
70
|
+
as "try again later" to ride out a server outage, treat this code the same
|
|
71
|
+
way: the purchase stays unacknowledged, the SDK validates it again on the
|
|
72
|
+
next billing connection (the next launch at the latest), and
|
|
73
|
+
`restorePurchases()` validates subscriptions and one-time products again.
|
|
74
|
+
- Android: the module's manifest declares
|
|
75
|
+
`android.permission.POST_NOTIFICATIONS` and a transparent
|
|
76
|
+
`PermissionRequestActivity`, so both merge into your app. The permission
|
|
77
|
+
prompt appears only when you call `Notifications.requestPermission()`. An
|
|
78
|
+
app that must not declare the permission can remove it in its own manifest
|
|
79
|
+
with `tools:node="remove"`.
|
|
80
|
+
- Push needs no change unless you adopt it or add the config plugin (README
|
|
81
|
+
"Push notifications"). iOS asks for an APNs token only after
|
|
82
|
+
`Notifications.requestPermission()` or
|
|
83
|
+
`Notifications.registerForPushNotifications()`. On Android, an app that
|
|
84
|
+
already ships Firebase Cloud Messaging (for example through
|
|
85
|
+
`@react-native-firebase/messaging` or `expo-notifications`) and holds the
|
|
86
|
+
notification permission has its FCM token registered with Swiss Knife when
|
|
87
|
+
the SDK starts (`configure`, `configureCore`, `Analytics.init` or
|
|
88
|
+
`CrashReporting.init`), so the device shows up in the push audience; the
|
|
89
|
+
SDK does not handle incoming messages unless its
|
|
90
|
+
`SwissKnifeMessagingService` is declared. The iOS SDK now contains APNs
|
|
91
|
+
registration code, so App Store Connect may warn about a missing push
|
|
92
|
+
entitlement on upload for an app without push; the warning does not
|
|
93
|
+
block the build.
|
|
94
|
+
- Native Android apps (not React Native) that use `SKAnalytics` or
|
|
95
|
+
`SKCrashReporting` must call `SwissKnife.configureCore` (or `configure`):
|
|
96
|
+
events and crash reports are held until then. An app that opts out of
|
|
97
|
+
analytics or turns session events off calls `SKAnalytics.initialize`
|
|
98
|
+
before `configureCore`. React Native apps need no change here.
|
|
99
|
+
- `Attributes.setPushToken` only sets the `$pushToken` attribute; it does
|
|
100
|
+
not register the device for delivery (the native `SwissKnife.setPushToken`
|
|
101
|
+
is deprecated for that reason). Register a device with
|
|
102
|
+
`Notifications.registerDeviceToken` or
|
|
103
|
+
`Notifications.registerForPushNotifications()`.
|
|
104
|
+
|
|
105
|
+
No peer dependency changed (`react >= 18`, `react-native >= 0.73`, optional
|
|
106
|
+
`@react-native-async-storage/async-storage`), the iOS pod still targets iOS
|
|
107
|
+
15.1, and the Android module's defaults (minSdk 24, compileSdk 35) are
|
|
108
|
+
unchanged.
|
|
109
|
+
|
|
110
|
+
### Added
|
|
111
|
+
|
|
112
|
+
- Push notifications: a `Notifications` module with a native mode (the SDK owns
|
|
113
|
+
the APNs/FCM token) and a manual mode (`expo-notifications` or React Native
|
|
114
|
+
Firebase hand over the token and payloads), the native iOS
|
|
115
|
+
`SwissKnife.Notifications` and Android `SwissKnife.notifications` APIs, the
|
|
116
|
+
Android `SwissKnifeMessagingService`, and an Expo config plugin
|
|
117
|
+
(`app.plugin.js`). `firebase-messaging` is a compile-only dependency, so an
|
|
118
|
+
app that does not use push does not pull in Firebase. The iOS
|
|
119
|
+
`SwissKnifeNotificationService` extension base class for rich notifications
|
|
120
|
+
belongs to the native Swift package and is not part of this npm package. See
|
|
121
|
+
README "Push notifications".
|
|
122
|
+
- Performance: `Performance.init({ trackAppStart: true })` records the cold
|
|
123
|
+
start as an `app.start` transaction, from when the SDK module loaded to your
|
|
124
|
+
call of `Performance.finishAppStart()`. Off by default; sampling applies.
|
|
125
|
+
- Performance: a `buildNumber` option. Transactions carry their span id and the
|
|
126
|
+
session, user and install ids, and JS crash events carry the session id and
|
|
127
|
+
the trace id of the transaction active when they were captured, so a trace
|
|
128
|
+
links to the session's events and errors.
|
|
129
|
+
- Android: optional RuStore billing. The Expo plugin option
|
|
130
|
+
`android: { rustore: { consoleAppId, scheme } }` sets the Gradle property
|
|
131
|
+
`swissKnifeStore=rustore`, adds RuStore's manifest metadata and the payment
|
|
132
|
+
return deeplink, and makes the launcher Activity `singleTask`. Without it,
|
|
133
|
+
builds use Google Play and load no RuStore dependency. The option is part of
|
|
134
|
+
the push config plugin, so adding the plugin also applies its push setup
|
|
135
|
+
(the `aps-environment` entitlement and the `remote-notification` background
|
|
136
|
+
mode on iOS; `firebase-messaging`, `POST_NOTIFICATIONS` and, unless
|
|
137
|
+
`expo-notifications` or `@react-native-firebase/messaging` is in the
|
|
138
|
+
project, `SwissKnifeMessagingService` on Android). A RuStore purchase made
|
|
139
|
+
before login is kept under the persisted anonymous id, so it is still found
|
|
140
|
+
after a restart and merges into the account on identify, and its validation
|
|
141
|
+
retries 5xx, 429 and transport failures. See README "Optional RuStore
|
|
142
|
+
billing (Android)".
|
|
143
|
+
- Android (native): `Attribution.setCollectors(advertisingId, installReferrer)`.
|
|
144
|
+
The SDK still ships no advertising-id or install-referrer collector and adds no
|
|
145
|
+
Play dependency; a host that has them passes its own, and their values reach the
|
|
146
|
+
install POST. The docs no longer mention a `setProductionCollectors` that never
|
|
147
|
+
existed.
|
|
148
|
+
- Android (native): `PurchasesError.httpStatus`, `.backendErrorCode` and
|
|
149
|
+
`.requestId` expose the server's validation diagnostics when it refused a
|
|
150
|
+
purchase. Raw response bodies, purchase tokens and receipts are never
|
|
151
|
+
included.
|
|
152
|
+
|
|
153
|
+
### Changed
|
|
154
|
+
|
|
155
|
+
- `configure()` / `configureCore()` throw synchronously when `apiKey` is empty or
|
|
156
|
+
whitespace. They used to mark the SDK configured and fail on the first store
|
|
157
|
+
call, so an app built with a missing key now throws at startup.
|
|
158
|
+
- Android (Play): a PENDING purchase (cash, deferred payment) rejects with
|
|
159
|
+
`PAYMENT_PENDING_ERROR` instead of resolving. It is never validated or
|
|
160
|
+
acknowledged while pending; Play delivers it again once it is paid, and the SDK
|
|
161
|
+
validates it then.
|
|
162
|
+
- Android (Play): every billing connection (configure and each reconnect)
|
|
163
|
+
validates and acknowledges the SUBS and INAPP purchases that are PURCHASED but
|
|
164
|
+
still unacknowledged, consumables included. A purchase stamped with a signed-in
|
|
165
|
+
user id at launch is validated under that user, any other under the current
|
|
166
|
+
subject.
|
|
167
|
+
- Android (Play): a purchase or restore made while the billing client is
|
|
168
|
+
disconnected waits up to 15 s for a reconnect. A failed reconnect rejects with
|
|
169
|
+
the mapped Play error (for example `PURCHASE_NOT_ALLOWED_ERROR`) instead of
|
|
170
|
+
`STORE_PROBLEM_ERROR`.
|
|
171
|
+
- iOS: `restorePurchases()` calls `AppStore.sync()` first, which can show an
|
|
172
|
+
Apple ID sign-in sheet. Call it from a user action, never silently at launch.
|
|
173
|
+
- iOS: a restore, a `Transaction.updates` delivery or a silent push no longer
|
|
174
|
+
clears the cached entitlements before refreshing. A failed refresh keeps what
|
|
175
|
+
the user had, so a refund or revocation shows only once a refresh succeeds or
|
|
176
|
+
the 24 h cache expires.
|
|
177
|
+
- Android (native): `SKAnalytics` and `SKCrashReporting` deliver only through
|
|
178
|
+
`/ingest`, which `SwissKnife.configureCore` / `configure` wire. Events and
|
|
179
|
+
reports from before that call are held in memory (the newest 1,000 analytics
|
|
180
|
+
events, 100 captured errors and 100 other reports). They are sent within a
|
|
181
|
+
second of that call when it comes in the first five minutes, otherwise with
|
|
182
|
+
the next delivery or the 30 s flush; crash files from earlier launches wait
|
|
183
|
+
on disk (the newest 10, none overwritten) and exit records in the OS. The
|
|
184
|
+
legacy queue (`EventQueueStore`, `FlushEventsWorker`, `/api/sdk/events/batch`,
|
|
185
|
+
the direct `/api/sdk/errors/*` posts, `pending-queue.json`) is removed: its
|
|
186
|
+
leftover files are deleted and its WorkManager job is cancelled on upgrade. A
|
|
187
|
+
native app that calls `SKAnalytics.initialize` or `SKCrashReporting.init`
|
|
188
|
+
without `configureCore` sends nothing until it adds that call. `configureCore`
|
|
189
|
+
keeps the configuration of an `SKAnalytics` the app already initialized; when
|
|
190
|
+
analytics is not initialized yet, it initializes it with the defaults, which
|
|
191
|
+
tracks a Session Start. An app that opts out or turns session events off
|
|
192
|
+
calls `SKAnalytics.initialize` first. The React Native bridge already wires
|
|
193
|
+
`/ingest` first, so React Native apps are unaffected.
|
|
194
|
+
- Android (Play): a purchase whose validation gets an HTTP error answer (any
|
|
195
|
+
non-2xx status, 429 and 5xx included) rejects with
|
|
196
|
+
`UNEXPECTED_BACKEND_RESPONSE_ERROR` and an SDK-owned message instead of
|
|
197
|
+
`NETWORK_ERROR`; only a transport failure (no answer) stays `NETWORK_ERROR`.
|
|
198
|
+
Validation is not retried within the call: the purchase stays
|
|
199
|
+
unacknowledged and is validated again on the next billing connection. A
|
|
200
|
+
restore whose validation fails rejects with the code of the first failure
|
|
201
|
+
instead of a generic `NETWORK_ERROR`. Purchases are sent for validation as one
|
|
202
|
+
`packageName:productId:purchaseToken` receipt (`platform: "android"`), the
|
|
203
|
+
shape the server validates for subscriptions and one-time products alike; the
|
|
204
|
+
server still accepts the request 0.4.x sends.
|
|
205
|
+
- Android: `getCustomerInfo()` with nothing cached rejects with
|
|
206
|
+
`NETWORK_ERROR` when the server cannot be reached or answers with an error
|
|
207
|
+
(a 429 or 5xx included), as on iOS; it used to resolve with no entitlements.
|
|
208
|
+
With a cache it still answers from the cache, even one older than 24 hours.
|
|
209
|
+
`logIn()` still resolves when the entitlement read fails, with no
|
|
210
|
+
entitlements, as before.
|
|
211
|
+
- Android (Play): `restorePurchases()` rejects when Play fails to list either
|
|
212
|
+
the subscriptions or the one-time purchases, instead of resolving with a
|
|
213
|
+
partial restore.
|
|
214
|
+
- Android: an offering's packages carry the package identifier and package
|
|
215
|
+
type set on the server, as on iOS, and `product.subscriptionPeriod` is filled
|
|
216
|
+
in for subscriptions (from Play, or from the dashboard duration when Play
|
|
217
|
+
cannot price the product); it is null for one-time products.
|
|
218
|
+
- Android: the React Native module's manifest declares
|
|
219
|
+
`android.permission.POST_NOTIFICATIONS` and the transparent
|
|
220
|
+
`PermissionRequestActivity` that `Notifications.requestPermission()` launches,
|
|
221
|
+
so both are merged into every app. The prompt is shown only when the app asks.
|
|
222
|
+
- iOS (native): a telemetry batch the ingest server refuses with a 4xx no
|
|
223
|
+
longer blocks the queue for good. 401/403 keep the events and retry after 5
|
|
224
|
+
minutes; any other 4xx on several events (413, 400, 404 ...) splits the batch
|
|
225
|
+
to find the event at fault, so a batch is never dropped whole. An event
|
|
226
|
+
refused on its own is dropped to the dead-letter file only when the server
|
|
227
|
+
accepted another batch just before, one drop per accepted batch. Otherwise it
|
|
228
|
+
is set aside: kept, skipped so the events behind it go out, and offered again
|
|
229
|
+
once the server accepts something. The set-aside list and the pause of up to
|
|
230
|
+
5 minutes after a drain the server refused are kept in a new file,
|
|
231
|
+
`set-aside.json`, beside the queue (`Library/Caches/SwissKnife/ingest/`), so
|
|
232
|
+
a relaunch neither starts over nor re-sends to a server refusing the queue; a
|
|
233
|
+
pause read back that ends more than 5 minutes ahead (a device clock set back)
|
|
234
|
+
is ignored. Android also keeps events on 401/403 now.
|
|
235
|
+
- Android (native): the same 4xx policy as iOS. A telemetry batch the ingest
|
|
236
|
+
server refuses is no longer dead-lettered whole: 408/425 keep the events and
|
|
237
|
+
back off like a 5xx, any other 4xx on several events splits the batch, and an
|
|
238
|
+
event refused on its own is dropped only when the server accepted another
|
|
239
|
+
batch just before (otherwise set aside and offered again), with the
|
|
240
|
+
set-aside list and the pause kept in `set-aside.json` beside the queue
|
|
241
|
+
(`cache/swissknife/ingest/`). A server refusing every batch is retried while
|
|
242
|
+
the app runs, not by background wake-ups.
|
|
243
|
+
- iOS and Android (native): the offline event queues no longer read their file
|
|
244
|
+
on every append, and the dead-letter files are capped (1 MB).
|
|
245
|
+
- Android (native): crash reports and breadcrumbs carry UTC timestamps from a
|
|
246
|
+
per-thread formatter; the crash handler installs once and always hands the
|
|
247
|
+
crash on to the previous handler.
|
|
248
|
+
- iOS (native): the ANR watchdog reports one ANR per hang and pauses while the
|
|
249
|
+
app is in the background.
|
|
250
|
+
- The package description and keywords name what the SDK ships (subscriptions,
|
|
251
|
+
analytics, crash reporting, performance, push) instead of calling it a
|
|
252
|
+
subscriptions-only drop-in replacement for `react-native-purchases`. Source
|
|
253
|
+
comments describe what the code does; the history they used to narrate is
|
|
254
|
+
under "Earlier history" below.
|
|
255
|
+
|
|
256
|
+
### Fixed
|
|
257
|
+
|
|
258
|
+
- Android: `getOfferings()` returns the app's offerings, as on iOS: every
|
|
259
|
+
active paywall as an offering, `current` set to the one the dashboard marks
|
|
260
|
+
current, and each Google Play (or RuStore) package priced by the store, with
|
|
261
|
+
the dashboard price when the store cannot price it. It used to reject on
|
|
262
|
+
every call, so `purchasePackage()` could not find a package either. Packages
|
|
263
|
+
for other platforms are left out. A call made while Play is still connecting
|
|
264
|
+
(right after `configure()`) waits up to 5 seconds for it. The answer is cached
|
|
265
|
+
for an hour, or for a minute when the store priced none of its products, so
|
|
266
|
+
the store's prices replace the dashboard's as soon as the store answers. No
|
|
267
|
+
paywall slug is needed; the native `getOfferingsForPaywall` stays for a host
|
|
268
|
+
that renders one paywall with its experiment variant.
|
|
269
|
+
- Android (Play): one-time products (lifetime unlocks, consumables) are priced,
|
|
270
|
+
bought and restored. Prices were looked up as subscriptions only, a purchase
|
|
271
|
+
asked Play for the product as a subscription only and failed with
|
|
272
|
+
`PRODUCT_NOT_AVAILABLE_FOR_PURCHASE_ERROR`, and `restorePurchases()` skipped
|
|
273
|
+
one-time purchases. A product is asked for as the type its package
|
|
274
|
+
describes; one bought by id alone (`purchaseStoreProduct`) is asked for as a
|
|
275
|
+
subscription first, then as a one-time product. Consumables are
|
|
276
|
+
acknowledged, not consumed, so a consumable can be bought once: a second
|
|
277
|
+
purchase rejects with `RECEIPT_ALREADY_IN_USE_ERROR`. A product the SDK
|
|
278
|
+
knows is one-time reaches JS with `productCategory: "NON_SUBSCRIPTION"` and
|
|
279
|
+
`productType: "UNKNOWN"` instead of being labelled a subscription (iOS still
|
|
280
|
+
labels every product a subscription).
|
|
281
|
+
- Android: CustomerInfo carries the user's entitlements. `getCustomerInfo()`,
|
|
282
|
+
`restorePurchases()`, `logIn()` and a purchase answered from a device cache
|
|
283
|
+
that nothing filled, so Android reported no entitlements, even right after a
|
|
284
|
+
purchase. They now read the user's whole entitlement set from the server, as
|
|
285
|
+
iOS does: every entitlement the app defines (active or not, with product,
|
|
286
|
+
store, period type and dates), the active subscriptions and the purchase
|
|
287
|
+
dates. A failed read keeps the cached entitlements. The cache belongs to the
|
|
288
|
+
user it was read for: after a `logIn()`, a `logOut()` or a launch configured
|
|
289
|
+
with another `appUserID`, the new user's entitlements are read rather than
|
|
290
|
+
the previous user's served, as on iOS, and a read that finishes after the
|
|
291
|
+
switch is not kept.
|
|
292
|
+
- Android: `Identity.reset()` and `Identity.wipe()` take purchases back to the
|
|
293
|
+
anonymous user, as on iOS. After a `logIn()`, the purchases layer kept the
|
|
294
|
+
user they left for the rest of the process: `getCustomerInfo()` served that
|
|
295
|
+
user's entitlements, and a purchase was validated under that user. They now
|
|
296
|
+
drop that user's id and cached entitlements (memory and disk) without
|
|
297
|
+
contacting the store or the server, and the next `getCustomerInfo()` reads
|
|
298
|
+
the anonymous user's entitlements. On Android, `addCustomerInfoUpdateListener`
|
|
299
|
+
listeners also receive the anonymous user's CustomerInfo, with no
|
|
300
|
+
entitlements (iOS sends no event). A `logOut()` after a reset or wipe
|
|
301
|
+
resolves, as on iOS.
|
|
302
|
+
- Android (Play): after a purchase is validated, the SDK re-reads the
|
|
303
|
+
entitlements, updates the cache and sends the new CustomerInfo to
|
|
304
|
+
`addCustomerInfoUpdateListener` listeners, as iOS does after a transaction
|
|
305
|
+
update. This covers a pending payment that clears later, a promo code or a
|
|
306
|
+
purchase made in the Play Store app, and a purchase the check on each billing
|
|
307
|
+
connection validated, not only the purchase in flight. A native listener
|
|
308
|
+
added before `configure` is notified too.
|
|
309
|
+
- iOS and Android (native): `SwissKnife.configure`, `configureCore` and
|
|
310
|
+
`configurePurchases` with an empty or whitespace `apiKey` log an error and
|
|
311
|
+
return without configuring anything. iOS trapped on a `precondition` (a crash
|
|
312
|
+
in release builds) and Android threw `IllegalArgumentException`, so a native
|
|
313
|
+
app built with a missing key crashed at launch. A later call with the real
|
|
314
|
+
key configures the SDK as usual.
|
|
315
|
+
- `CrashReporting.init` with an empty or whitespace `apiKey` logs an error and
|
|
316
|
+
does nothing: no handler is installed and the native crash module is not
|
|
317
|
+
started. On Android the empty key used to latch the native observability
|
|
318
|
+
wiring (`SwissKnife.ensureObservabilityBackend`), so in an app that calls
|
|
319
|
+
`Analytics.init` without `configure` the real key never reached the ingest
|
|
320
|
+
pipeline. `ensureObservabilityBackend` on Android and iOS now ignores an empty
|
|
321
|
+
or whitespace key without latching.
|
|
322
|
+
- Android (native): the install attribution POST sends `user_id` only for a
|
|
323
|
+
logged-in user, as iOS does. It used to send the anonymous id as `user_id`;
|
|
324
|
+
the server already treats that `$SKAnonymousID:` value as anonymous, so stored
|
|
325
|
+
data does not change.
|
|
326
|
+
- `configure()` / `configureCore()` no longer drop the native promise. A native
|
|
327
|
+
configure failure is logged (no unhandled rejection), resets the JS state so
|
|
328
|
+
the next `configure()` with the same key retries, and the next store call
|
|
329
|
+
throws `UninitializedPurchasesError` with the native error as `cause`.
|
|
330
|
+
`configure()` stays synchronous.
|
|
331
|
+
- Android (Play): acknowledgements are checked and retried (3 attempts with
|
|
332
|
+
backoff), and the reconcile on each billing connection picks up what is still
|
|
333
|
+
unacknowledged, so an ack lost to a network error or a process kill is no
|
|
334
|
+
longer auto-refunded by Google after three days. A purchase or restore after
|
|
335
|
+
the five reconnect attempts ran out reconnects instead of failing "Billing
|
|
336
|
+
client not ready" until the app restarts.
|
|
337
|
+
- iOS: a failed entitlement refresh after a restore, a transaction update or a
|
|
338
|
+
silent push no longer leaves the user with no entitlements.
|
|
339
|
+
- Android (native): `configure` / `configureCore` no longer re-initialize an
|
|
340
|
+
`SKAnalytics` the app already initialized. They used to replace its
|
|
341
|
+
configuration with the defaults, so a user who had opted out was tracked
|
|
342
|
+
again, session events came back on, the flush interval reset, and a second
|
|
343
|
+
Session Start was tracked. Analytics that was not initialized is still
|
|
344
|
+
initialized with the defaults. This applies to apps that call the native
|
|
345
|
+
`SKAnalytics.initialize`; a React Native app's JS `optOut` is not passed to
|
|
346
|
+
native, so its Android wiring is unchanged.
|
|
347
|
+
- Android (native): `SKAnalytics.identify` and `groupIdentify` send nothing
|
|
348
|
+
while opted out, as on iOS and in the JS layer. They used to send the user
|
|
349
|
+
or group properties anyway.
|
|
350
|
+
- The `enableNativeCrashHandler` docs said the iOS reporter catches Mach
|
|
351
|
+
exceptions. It never installed a Mach exception handler: it installs
|
|
352
|
+
`signal()` handlers (SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGSEGV, SIGTRAP), the
|
|
353
|
+
uncaught-NSException handler and an ANR watchdog, and the docs now say so.
|
|
354
|
+
- `CrashReporting.init` no longer passes an `ingestURL` to the native crash
|
|
355
|
+
module. It was not a `CrashReportingConfig` option and neither bridge read
|
|
356
|
+
it; native reports go to `serverURL`.
|
|
357
|
+
- iOS (native): the crash scope (tags, extra, user) and the breadcrumb buffer
|
|
358
|
+
are safe to change from any thread. An uncaught NSException raised on the
|
|
359
|
+
crash reporter's own queue (a `flush` completion, for example) is reported;
|
|
360
|
+
the handler used to dispatch synchronously onto the queue it was running on.
|
|
361
|
+
|
|
362
|
+
### Deprecated
|
|
363
|
+
|
|
364
|
+
- Native `SwissKnife.setPushToken` only sets the `$pushToken` attribute; it does
|
|
365
|
+
not register the device for delivery. On iOS use
|
|
366
|
+
`SwissKnife.Notifications.registerDeviceToken(_:)`, on Android
|
|
367
|
+
`SwissKnife.notifications.registerToken`. The JS `Attributes.setPushToken`
|
|
368
|
+
(and its `Purchases.setPushToken` alias) also only sets the attribute but is
|
|
369
|
+
not deprecated; register a device from JS with
|
|
370
|
+
`Notifications.registerDeviceToken`.
|
|
371
|
+
|
|
13
372
|
## [0.4.0] - 2026-09-30
|
|
14
373
|
|
|
15
374
|
Crash reporting release. No API is removed or renamed, and upgrading from 0.3.2
|
|
@@ -29,7 +388,7 @@ dashboard, so read **Changed** before you compare week-over-week numbers.
|
|
|
29
388
|
handed to `configureScope()` could not be typed in user code; `captureException`'s
|
|
30
389
|
options parameter is now a named type instead of an inline literal.
|
|
31
390
|
- **Affected-user counts survive anonymous sessions.** When no user id is set, an
|
|
32
|
-
install id is sent so an issue still reports how many
|
|
391
|
+
install id is sent so an issue still reports how many _installs_ it hit instead
|
|
33
392
|
of collapsing to zero. The id comes from the Identity bridge's `anonymousId`,
|
|
34
393
|
falling back to a UUID persisted in AsyncStorage. With neither available nothing
|
|
35
394
|
is sent — a per-launch random id would inflate the count, so we prefer no number
|
|
@@ -79,4 +438,28 @@ numbers to move once 0.4.0 rolls out; that is the fix working, not data loss.
|
|
|
79
438
|
- No new or changed dependencies; peer ranges (`react`, `react-native`,
|
|
80
439
|
`@react-native-async-storage/async-storage`) are untouched.
|
|
81
440
|
|
|
82
|
-
|
|
441
|
+
## Earlier history
|
|
442
|
+
|
|
443
|
+
How the SDK reached its current shape before 0.4.0, as the source comments used
|
|
444
|
+
to narrate it:
|
|
445
|
+
|
|
446
|
+
- **RevenueCat removed.** The SDK began as a wrapper over RevenueCat's
|
|
447
|
+
`react-native-purchases` (`purchases-hybrid-common`). iOS moved to its own
|
|
448
|
+
StoreKit 2 services and Android to Play Billing directly, the RN bridge and
|
|
449
|
+
TypeScript types became this package's own (RevenueCat's names and field
|
|
450
|
+
shapes kept, `@revenuecat/purchases-typescript-internal` dropped), and the RN
|
|
451
|
+
analytics layer became a pass-through to the native event queue.
|
|
452
|
+
- **Identity.** One `Identity` namespace on iOS, Android and JS, with native as
|
|
453
|
+
the source of truth. Android started posting `/api/sdk/users/identify` on
|
|
454
|
+
login, analytics events read `user_id` from the native snapshot (an event
|
|
455
|
+
tracked right after login used to carry `user_id: ""`), and Android's
|
|
456
|
+
anonymous id moved from `$RCAnonymousID:` to `$SKAnonymousID:`.
|
|
457
|
+
- **Attribution.** One `Attribution` namespace; Android started posting the
|
|
458
|
+
install to `/api/sdk/attribution/install`.
|
|
459
|
+
- **Logging.** `setLogLevel` started filtering the SDK's own logs (`SKLog` on
|
|
460
|
+
iOS and Android, `modules/log.ts` in JS); it used to have no effect.
|
|
461
|
+
- **Session id.** Analytics' `session_id` became the native session UUID, the
|
|
462
|
+
same one on every ingested envelope, instead of a JS `Date.now()` value.
|
|
463
|
+
|
|
464
|
+
[0.5.0]: https://www.npmjs.com/package/@app-swiss-knife/react-native-sdk/v/0.5.0
|
|
465
|
+
[0.4.0]: https://www.npmjs.com/package/@app-swiss-knife/react-native-sdk/v/0.4.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 App Swiss Knife
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|