Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
push:
branches: [main]
pull_request:
# Weekly, so a new major of a peer that the README installs unpinned fails
# here before a customer's install does.
schedule:
- cron: '17 13 * * 1'

# A newer commit on the same PR cancels the older run; each push to main keeps
# its own run.
Expand Down Expand Up @@ -36,3 +40,18 @@ jobs:
- run: npm test -- --ci
# scripts/validate-ios.sh compiles the native module inside a local Expo
# app; it stays a manual pre-release step.

install-lines:
# The README install lines, resolved with npm's strict peer rules against
# today's published versions. `test` above installs with
# --legacy-peer-deps and so cannot see a peer conflict. Lockfile only: no
# node_modules, no app build.
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 22
- name: README install lines resolve without peer conflicts
run: node scripts/check-install-lines.mjs
18 changes: 13 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ All notable changes to the Datalyr React Native SDK will be documented in this f
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
## [1.9.0] - 2026-11-25

Ships as a minor version (1.9.0). Read the install change below before upgrading.
Minor version. Read the install change below before upgrading.

### Added
- `Datalyr.getPlayInstallReferrer()` on the bare React Native static facade (the instance and the Expo facade already had it).
- Every event the SDK gives up on is counted, persisted across launches, by reason: `rejected` (final 4xx), `dead_letter_full` (the 100-entry dead-letter store pushed out its oldest), `dead_letter_expired` (replayed 3 times or older than 7 days). Read them in `getStatus().queueStats.dropped`. `queueStats.retryInMs` shows the current backoff.

### Changed
- `uuid` is now `^11.1.1` (was `^10.0.0`). This clears the one production advisory. The SDK only uses `v4()`; ids keep the same format. `@types/uuid` is gone, since uuid 11 ships its own types.
- The Expo modules the SDK loads are now declared as optional peer dependencies: `expo-application`, `expo-device`, `expo-network`, `expo-router`, `expo` and `@expo/config-plugins` (Expo SDK 52 or later, the same floor as `expo-modules-core`). Your package manager now warns about a version it cannot work with. Nothing is installed for you. The unused `expo-tracking-transparency` entry is removed.
- The Expo modules the SDK loads are now declared as optional peer dependencies: `expo-application`, `expo-device`, `expo-network`, `expo` and `@expo/config-plugins` (Expo SDK 52 or later, the same floor as `expo-modules-core`). Your package manager now warns about a version it cannot work with. Nothing is installed for you. The unused `expo-tracking-transparency` entry is removed. `expo-router` is not declared: npm checks an optional peer against its newest version even when it is not installed, and expo-router's own peers then conflict with an older Expo SDK (`ERESOLVE`). The SDK loads it only when you use the Expo Router screen-tracking hook.
- `debug: true` now turns on the SDK's debug logs in a release build. Before, they printed only in a development build (`__DEV__`) and the option did nothing else.
- SKAdNetwork and AdAttributionKit success messages, and failed Apple Search Ads, advertiser-info and Play Install Referrer lookups in the native bridge, now log only when debug logging is on (`__DEV__` or `debug: true`). Warnings for a missing native module and failed SKAdNetwork updates are unchanged.
- iOS: `setPostbackEnvironment` no longer writes an `NSLog` line; the JS side logs the result when debug logging is on.
Expand All @@ -33,6 +33,10 @@ Ships as a minor version (1.9.0). Read the install change below before upgrading
- Internal code that was never called: the private deferred deep link handlers in both entry points, the unused `src/utils-interface.ts` (not exported) and a commented-out AppState block.

### Fixed
- Expo: an app without `expo-router` can now bundle `@datalyr/react-native/expo`. The entry's lazy `require('expo-router')` had no try/catch, so Metro could not treat it as optional and stopped with `Unable to resolve module expo-router` (also in 1.8.0). Now only `useDatalyrScreenTracking()` needs expo-router, and without it the hook throws a clear error.
- iOS: the SDK now chooses the host for each event when it sends it, not when it builds it. An event goes to `tracking.datalyr.com` (the tracking domain in the SDK's privacy manifest) only when it carries the advertising id (IDFA) and tracking is allowed at send time (and was already allowed when the app started; see the next point). Otherwise it goes to the normal host, with `idfa` and `alart` removed and `att_status` / `advertiser_tracking_enabled` set to the status at send time. If the tracking host cannot be reached or answers an HTTP error twice in a row for one event, that event is sent to the normal host without its IDFA, and other IDFA events then skip the tracking host for 10 minutes. So an event built while tracking was allowed can no longer hold the queue after tracking is turned off. Android is unchanged.
- iOS: after the user allows tracking, the advertising id is sent from the next app launch. In the launch where the user taps Allow, events go to the normal host at once without it (`att_status` still reads 3). On the next launch the SDK sends `$att_status` once (`resent: true`) with the IDFA, under one fixed event id per grant, so a kill during that launch cannot count it twice. `alart` without an IDFA follows the same rule: tracking host or removed, never on the normal host.
- Why: in apps where iOS enforces tracking domains, requests to `tracking.datalyr.com` are refused until tracking is allowed and the app has started again. iOS enforces the list in the app's Info.plist. Xcode copies an SDK's list there for a Swift package. It does not copy this SDK's list, which CocoaPods installs as a resource bundle. So in a React Native or Expo app the host is refused only if the app lists it in its own Info.plist. The rules above deliver events in both cases.
- Events are no longer dead-lettered by a server outage. A 5xx (503 included), 429, 408, a timeout or a network error keeps the event in the queue with the same `eventId`, uses none of its retry budget, and backs the whole queue off (5 s doubling to 5 minutes with 0.5x to 1.0x jitter; never sooner than the server's `Retry-After`, honoured up to 10 minutes, plus 0 to 25% jitter). Before, three failed flushes (about 1 to 2 minutes of 5xx or 429) moved events to the dead-letter store, and a timeout (`Aborted`) was not recognised as a connectivity failure.
- `Retry-After` is now honoured on 5xx answers (ingest answers 503 with `Retry-After` when the fault is its own), not only on 429 and 408. A `Retry-After` longer than 30 s is no longer cut short in-request.
- Any 2xx is a delivered event, whatever its body. Ingest answers 204 with no body for a filtered event; that used to count as a failed send and re-send the event.
Expand All @@ -41,12 +45,16 @@ Ships as a minor version (1.9.0). Read the install change below before upgrading
- When a flush stops on a temporary failure, the events it already delivered are removed from disk at once.

### Install change
- `@react-native-async-storage/async-storage` (1.17 or later, or 2.x) and `react-native-get-random-values` are now peer dependencies, not dependencies. Install them in your app:
- Bare React Native: `npm install @datalyr/react-native expo-modules-core @react-native-async-storage/async-storage@^2 react-native-get-random-values` (pin `@^2`: an unpinned install takes 3.x, which is outside the peer range)
- `@react-native-async-storage/async-storage` (1.17 or later, or 2.x) and `react-native-get-random-values` (1.11 or later, or 2.x) are now peer dependencies, not dependencies. Install them in your app:
- Bare React Native: `npx install-expo-modules@latest`, then `npx expo install @datalyr/react-native expo-modules-core @react-native-async-storage/async-storage react-native-get-random-values`, then `cd ios && pod install`. Run `install-expo-modules` first: it adds the Expo SDK that matches your React Native, and `npx expo install` then picks versions for it. A plain `npm install` takes the newest `expo-modules-core` (and AsyncStorage 3.x), which an older Expo SDK cannot use.
- Expo: `npx expo install @datalyr/react-native expo-application expo-device expo-network @react-native-async-storage/async-storage react-native-get-random-values`

Both are native modules. React Native CLI autolinking links only the packages listed in the app's own `package.json`, and Expo before SDK 54 does the same, so as nested dependencies they could load without their native code. An app that already lists both needs no change. AsyncStorage 3.x is not supported yet (it renames `multiRemove` to `removeMany`).

`react-native-get-random-values` 2.x works only on React Native 0.81 or later with the New Architecture on (Expo SDK 54 or later with it on). On an older React Native, or with the New Architecture off, install `react-native-get-random-values@^1`. On React Native older than 0.81, npm refuses 2.x (`ERESOLVE`); with the New Architecture off, 2.x installs without a warning, but its iOS native module is registered only for the New Architecture, so the SDK fails at start and sends no events. `npx expo install` picks the version your Expo SDK expects (1.11 for Expo SDK 52 to 57, 2.x for SDK 58).

Bare apps on Expo SDK 53 or 54 (React Native 0.78 to 0.81): `install-expo-modules` does not add `bindReactNativeFactory(factory)` to `AppDelegate.swift`, and the app crashes at start without it. Add it after `reactNativeFactory = factory` (Expo's manual installation steps show it).


## [1.8.0] - 2026-10-30

Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,23 @@ Use the option that matches your app.
**Bare React Native:**

```bash
npm install @datalyr/react-native expo-modules-core @react-native-async-storage/async-storage@^2 react-native-get-random-values
npx install-expo-modules@latest
npx expo install @datalyr/react-native expo-modules-core @react-native-async-storage/async-storage react-native-get-random-values
cd ios && pod install
```

The SDK is built on Expo Modules. You must install `expo-modules-core` in a bare app too. AsyncStorage and `react-native-get-random-values` are native modules: React Native links only the packages your app lists, so install them in your app.
The SDK is built on Expo Modules. `install-expo-modules` adds the Expo SDK that matches your React Native version; run it first, so that `npx expo install` then picks versions for that Expo SDK. Do not use a plain `npm install` for these packages: it takes the newest `expo-modules-core`, which does not match an older Expo SDK, and `pod install` fails. AsyncStorage and `react-native-get-random-values` are native modules: React Native links only the packages your app lists, so install them in your app.

On Expo SDK 53 or 54 (React Native 0.78 to 0.81), check that `AppDelegate.swift` calls `bindReactNativeFactory(factory)` after `reactNativeFactory = factory`. `install-expo-modules` does not add it, and without it the app crashes at start (`Missing factory in ExpoAppDelegate`). See Expo's [manual installation steps](https://docs.expo.dev/bare/installing-expo-modules/).

**Expo:**

```bash
npx expo install @datalyr/react-native expo-application expo-device expo-network @react-native-async-storage/async-storage react-native-get-random-values
```

`npx expo install` picks the versions your Expo SDK expects, in both options above. If you add `react-native-get-random-values` another way, use 2.x only on React Native 0.81 or later (Expo SDK 54 or later) with the New Architecture on; otherwise install `react-native-get-random-values@^1`. On React Native older than 0.81, npm refuses 2.x (`ERESOLVE`). With the New Architecture off, 2.x installs without a warning, but its iOS native module is registered only for the New Architecture, so the SDK fails at start and sends no events.

Add the config plugin to `app.json`:

```json
Expand All @@ -56,6 +60,8 @@ Add the config plugin to `app.json`:

Use a development build (`npx expo run:ios` or EAS). Expo Go ignores the plugin and sends events only.

iOS: after the user allows tracking, the advertising ID is sent from the next app launch. Events in the launch where the user taps Allow are sent at once without it.

Find your API key in DATALYR under **Settings → API**. The key starts with `dk_`.

## Quick start
Expand Down
35 changes: 35 additions & 0 deletions ios/DatalyrNativeModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,42 @@ import AdServices
import AppTrackingTransparency
import AdSupport

// The ATT status when this app process started. iOS lifts its block on the privacy
// manifest's tracking domains only for processes started after tracking was allowed, so the
// JS side may use the tracking host only when this reads authorized. Process-wide (a JS
// reload keeps it), in memory only.
final class DatalyrProcessStartATT: @unchecked Sendable {
static let shared = DatalyrProcessStartATT()
private let lock = NSLock()
private var status: Int?

/// Records the status the first time it is called in this process; later calls keep it.
func record() {
lock.lock(); defer { lock.unlock() }
if status != nil { return }
if #available(iOS 14, *) {
status = Int(ATTrackingManager.trackingAuthorizationStatus.rawValue)
} else {
status = 3
}
}

var value: Int? {
lock.lock(); defer { lock.unlock() }
return status
}
}

public class DatalyrNativeModule: Module {

public func definition() -> ModuleDefinition {
Name("DatalyrNative")

// Created with the app's module registry at start-up, before the app can ask for ATT.
OnCreate {
DatalyrProcessStartATT.shared.record()
}

// MARK: - SDK Availability Check

AsyncFunction("getSDKAvailability") { (promise: Promise) in
Expand Down Expand Up @@ -59,6 +90,10 @@ public class DatalyrNativeModule: Module {
}
}

if let startStatus = DatalyrProcessStartATT.shared.value {
result["att_status_at_process_start"] = startStatus
}

promise.resolve(result)
}

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@datalyr/react-native",
"version": "1.8.0",
"version": "1.9.0",
"description": "DATALYR SDK for React Native and Expo: attribution and event tracking for iOS and Android apps",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -63,11 +63,10 @@
"expo-device": ">=7.0.0",
"expo-modules-core": ">=2.0.0",
"expo-network": ">=7.0.0",
"expo-router": ">=4.0.0",
"react": ">=18.0.0",
"react-native": ">=0.72.0",
"react-native-device-info": ">=12.0.0",
"react-native-get-random-values": "^1.8.0"
"react-native-get-random-values": "^1.11.0 || ^2.0.0"
},
"dependencies": {
"uuid": "^11.1.1"
Expand Down Expand Up @@ -135,9 +134,6 @@
},
"@react-native-community/netinfo": {
"optional": true
},
"expo-router": {
"optional": true
}
}
}
Loading