@anglerai/react-native-analytics 0.0.0-stage → 0.1.0-rc.1

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.
Files changed (39) hide show
  1. package/AnglerAnalyticsRN.podspec +25 -0
  2. package/LICENSE +21 -0
  3. package/README.md +92 -2
  4. package/android/build.gradle +64 -0
  5. package/android/src/main/java/ai/getangler/analytics/reactnative/AnglerAnalyticsModule.kt +51 -0
  6. package/android/src/main/java/ai/getangler/analytics/reactnative/AnglerAnalyticsPackage.kt +25 -0
  7. package/android/src/main/java/ai/getangler/analytics/reactnative/ConfigParser.kt +58 -0
  8. package/android/src/test/java/ai/getangler/analytics/reactnative/ConfigParserTest.kt +51 -0
  9. package/ios/AnglerAnalyticsBridge.swift +58 -0
  10. package/ios/AnglerAnalyticsRN.mm +84 -0
  11. package/ios/vendor/AnglerAnalytics/Angler.swift +132 -0
  12. package/ios/vendor/AnglerAnalytics/AnglerCore.swift +398 -0
  13. package/ios/vendor/AnglerAnalytics/Attribution/AttributionStore.swift +109 -0
  14. package/ios/vendor/AnglerAnalytics/Attribution/ClickIdParser.swift +52 -0
  15. package/ios/vendor/AnglerAnalytics/Device/AdIdProvider.swift +36 -0
  16. package/ios/vendor/AnglerAnalytics/Device/DeviceContext.swift +111 -0
  17. package/ios/vendor/AnglerAnalytics/Device/FirebaseIdProvider.swift +35 -0
  18. package/ios/vendor/AnglerAnalytics/Lifecycle/LifecycleObserver.swift +77 -0
  19. package/ios/vendor/AnglerAnalytics/Lifecycle/SharedApplication.swift +15 -0
  20. package/ios/vendor/AnglerAnalytics/Log.swift +24 -0
  21. package/ios/vendor/AnglerAnalytics/Network/Flusher.swift +112 -0
  22. package/ios/vendor/AnglerAnalytics/Network/ResponsePolicy.swift +29 -0
  23. package/ios/vendor/AnglerAnalytics/Network/Scheduler.swift +13 -0
  24. package/ios/vendor/AnglerAnalytics/Network/Transport.swift +55 -0
  25. package/ios/vendor/AnglerAnalytics/Payload/JSONValue.swift +81 -0
  26. package/ios/vendor/AnglerAnalytics/Payload/Models.generated.swift +580 -0
  27. package/ios/vendor/AnglerAnalytics/Payload/PayloadBuilder.swift +148 -0
  28. package/ios/vendor/AnglerAnalytics/Payload/StandardEvent.swift +26 -0
  29. package/ios/vendor/AnglerAnalytics/Payload/TypedModels.swift +14 -0
  30. package/ios/vendor/AnglerAnalytics/Resources/PrivacyInfo.xcprivacy +77 -0
  31. package/ios/vendor/AnglerAnalytics/Storage/Clock.swift +14 -0
  32. package/ios/vendor/AnglerAnalytics/Storage/EventQueue.swift +85 -0
  33. package/ios/vendor/AnglerAnalytics/Storage/IdentityStore.swift +76 -0
  34. package/ios/vendor/AnglerAnalytics/Storage/KeyValueStore.swift +38 -0
  35. package/ios/vendor/AnglerAnalytics/Version.swift +4 -0
  36. package/package.json +46 -4
  37. package/src/NativeAnglerAnalytics.ts +21 -0
  38. package/src/index.ts +159 -0
  39. package/src/models.generated.ts +347 -0
@@ -0,0 +1,148 @@
1
+ import Foundation
2
+
3
+ struct TrackCall {
4
+ var name: String
5
+ var data: [String: JSONValue]?
6
+ var properties: [String: String]?
7
+ var eventId: String?
8
+ }
9
+
10
+ struct IdentitySnapshot {
11
+ var aid: String
12
+ var customerId: String?
13
+ /// `idfa` on iOS, `gaid` on Android.
14
+ var adIdName: String
15
+ var adId: String?
16
+ var custom: [String: String]
17
+ }
18
+
19
+ struct DeviceProperty: Equatable {
20
+ var name: String
21
+ var value: String
22
+ }
23
+
24
+ struct DeviceSnapshot {
25
+ var properties: [DeviceProperty]
26
+ var userAgent: String
27
+ }
28
+
29
+ /// Turns a track call plus snapshots into one event (design §5). Pure.
30
+ enum PayloadBuilder {
31
+ static let allowedDataKeys: Set<String> = [
32
+ "cart", "cartLine", "checkout", "collection", "productVariant",
33
+ "searchResult", "customer", "form", "contacts", "customData",
34
+ ]
35
+
36
+ /// data-api's `device_properties[].name` enum. `app_id` is the store app ID (App Store ID on
37
+ /// iOS, package name on Android), the same value the AppsFlyer import sends.
38
+ static let allowedDeviceProperties: Set<String> = [
39
+ "app_id", "app_package", "app_version_short", "app_version_long", "os", "os_version",
40
+ "device_model_name", "device_timezone", "locale", "timezone_abbreviation", "carrier",
41
+ "screen_width", "screen_height", "screen_density", "cpu_cores", "ext_storage_in_gb",
42
+ "free_ext_storage_in_gb", "advertiser_tracking_enabled", "application_tracking_enabled",
43
+ ]
44
+
45
+ static func buildEvent(
46
+ call: TrackCall,
47
+ generatedEventId: String,
48
+ timestamp: String,
49
+ clientIdOverride: String?,
50
+ identity: IdentitySnapshot,
51
+ attribution: AttributionSnapshot,
52
+ device: DeviceSnapshot,
53
+ referrer: String?
54
+ ) -> JSONValue {
55
+ var event: [String: JSONValue] = [:]
56
+ event["event_id"] = .string(nonEmpty(call.eventId) ?? generatedEventId)
57
+ if StandardEvent.isStandard(call.name) {
58
+ event["event_name"] = .string(call.name)
59
+ } else {
60
+ event["event_name"] = .string("custom_event")
61
+ event["custom_event_name"] = .string(call.name)
62
+ }
63
+ event["timestamp"] = .string(timestamp)
64
+ event["client_id"] = .string(nonEmpty(clientIdOverride) ?? identity.aid)
65
+ event["user_agent"] = .string(device.userAgent)
66
+ if let url = nonEmpty(attribution.url) { event["url"] = .string(url) }
67
+ if let referrer = nonEmpty(referrer) { event["referrer"] = .string(referrer) }
68
+ if let fbc = nonEmpty(attribution.fbc) { event["fbc"] = .string(fbc) }
69
+ event["identifiers"] = .array(identifiers(identity: identity, clickIds: attribution.clickIds))
70
+ let props = device.properties.filter { allowedDeviceProperties.contains($0.name) && !$0.value.isEmpty }
71
+ if !props.isEmpty {
72
+ event["device_properties"] = .array(props.map { .object(["name": .string($0.name), "value": .string($0.value)]) })
73
+ }
74
+ event["data"] = .object(data(call.data, properties: call.properties))
75
+ return .object(event)
76
+ }
77
+
78
+ static func buildBody(src: String, events: [JSONValue]) -> JSONValue {
79
+ .object(["src": .string(src), "data": .array(events)])
80
+ }
81
+
82
+ private static let isoFormatter: ISO8601DateFormatter = {
83
+ let f = ISO8601DateFormatter()
84
+ f.formatOptions = [.withInternetDateTime]
85
+ f.timeZone = TimeZone(identifier: "UTC")
86
+ return f
87
+ }()
88
+
89
+ /// UTC ISO-8601 with milliseconds, e.g. `2026-11-17T18:04:05.123Z`.
90
+ static func timestamp(_ date: Date) -> String {
91
+ let ms = date.epochMillis
92
+ let seconds = Date(timeIntervalSince1970: TimeInterval(ms.floorDiv(1000)))
93
+ let base = isoFormatter.string(from: seconds) // "…T18:04:05Z"
94
+ return String(base.dropLast()) + String(format: ".%03lldZ", ms.floorMod(1000))
95
+ }
96
+
97
+ // MARK: - Private
98
+
99
+ private static func identifiers(identity: IdentitySnapshot, clickIds: [String: String]) -> [JSONValue] {
100
+ var pairs: [(String, String?)] = [("aid", identity.aid), ("customer_id", identity.customerId), (identity.adIdName, identity.adId)]
101
+ pairs += clickIds.sorted { $0.key < $1.key }.map { ($0.key, $0.value) }
102
+ pairs += identity.custom
103
+ .filter { !IdentityStore.reservedNames.contains($0.key) }
104
+ .sorted { $0.key < $1.key }
105
+ .map { ($0.key, $0.value) }
106
+ return pairs.compactMap { name, value in
107
+ guard let value = nonEmpty(value) else { return nil }
108
+ return .object(["name": .string(name), "value": .string(value)])
109
+ }
110
+ }
111
+
112
+ private static func data(_ data: [String: JSONValue]?, properties: [String: String]?) -> [String: JSONValue] {
113
+ var out: [String: JSONValue] = [:]
114
+ for (key, value) in data ?? [:] {
115
+ if allowedDataKeys.contains(key) {
116
+ out[key] = value
117
+ } else {
118
+ Log.debug("dropping data key '\(key)': not accepted by data-api")
119
+ }
120
+ }
121
+ var custom: [JSONValue] = []
122
+ if let existing = out["customData"]?.arrayValue {
123
+ custom = existing.filter { item in
124
+ guard let o = item.objectValue, o.count == 2,
125
+ o["name"]?.stringValue != nil, o["value"]?.stringValue != nil else {
126
+ Log.debug("dropping customData entry: must be {name: string, value: string}")
127
+ return false
128
+ }
129
+ return true
130
+ }
131
+ }
132
+ for (name, value) in (properties ?? [:]).sorted(by: { $0.key < $1.key }) {
133
+ custom.append(.object(["name": .string(name), "value": .string(value)]))
134
+ }
135
+ out["customData"] = custom.isEmpty ? nil : .array(custom)
136
+ return out
137
+ }
138
+
139
+ private static func nonEmpty(_ s: String?) -> String? {
140
+ guard let s, !s.isEmpty else { return nil }
141
+ return s
142
+ }
143
+ }
144
+
145
+ private extension Int64 {
146
+ func floorDiv(_ d: Int64) -> Int64 { (self >= 0 ? self : self - d + 1) / d }
147
+ func floorMod(_ d: Int64) -> Int64 { self - floorDiv(d) * d }
148
+ }
@@ -0,0 +1,26 @@
1
+ /// The `event_name` values data-api accepts (`WorkspacesEventsPostBody`).
2
+ enum StandardEvent {
3
+ static let names: Set<String> = [
4
+ "app_installed",
5
+ "app_launched",
6
+ "cart_viewed",
7
+ "checkout_address_info_submitted",
8
+ "checkout_completed",
9
+ "checkout_contact_info_submitted",
10
+ "checkout_shipping_info_submitted",
11
+ "checkout_started",
12
+ "collection_viewed",
13
+ "custom_event",
14
+ "form_submitted",
15
+ "logged_in",
16
+ "page_viewed",
17
+ "payment_info_submitted",
18
+ "product_added_to_cart",
19
+ "product_removed_from_cart",
20
+ "product_viewed",
21
+ "registration_completed",
22
+ "search_submitted",
23
+ ]
24
+
25
+ static func isStandard(_ name: String) -> Bool { names.contains(name) }
26
+ }
@@ -0,0 +1,14 @@
1
+ import Foundation
2
+
3
+ extension AnglerData {
4
+ /// The `data` object sent to data-api (null fields left out).
5
+ var jsonObject: [String: JSONValue] {
6
+ let encoder = JSONEncoder()
7
+ guard let encoded = try? encoder.encode(self),
8
+ let value = try? JSONDecoder().decode(JSONValue.self, from: encoded) else {
9
+ Log.warning("couldn't encode AnglerData; sending the event without it")
10
+ return [:]
11
+ }
12
+ return value.objectValue ?? [:]
13
+ }
14
+ }
@@ -0,0 +1,77 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <!-- Design §11.1: pending legal/compliance review before the iOS release. -->
6
+ <key>NSPrivacyTracking</key>
7
+ <false/>
8
+ <key>NSPrivacyTrackingDomains</key>
9
+ <array/>
10
+ <key>NSPrivacyAccessedAPITypes</key>
11
+ <array>
12
+ <dict>
13
+ <key>NSPrivacyAccessedAPIType</key>
14
+ <string>NSPrivacyAccessedAPICategoryUserDefaults</string>
15
+ <key>NSPrivacyAccessedAPITypeReasons</key>
16
+ <array>
17
+ <string>CA92.1</string>
18
+ </array>
19
+ </dict>
20
+ </array>
21
+ <key>NSPrivacyCollectedDataTypes</key>
22
+ <array>
23
+ <dict>
24
+ <key>NSPrivacyCollectedDataType</key>
25
+ <string>NSPrivacyCollectedDataTypeDeviceID</string>
26
+ <key>NSPrivacyCollectedDataTypeLinked</key>
27
+ <true/>
28
+ <key>NSPrivacyCollectedDataTypeTracking</key>
29
+ <false/>
30
+ <key>NSPrivacyCollectedDataTypePurposes</key>
31
+ <array>
32
+ <string>NSPrivacyCollectedDataTypePurposeAnalytics</string>
33
+ <string>NSPrivacyCollectedDataTypePurposeThirdPartyAdvertising</string>
34
+ </array>
35
+ </dict>
36
+ <dict>
37
+ <key>NSPrivacyCollectedDataType</key>
38
+ <string>NSPrivacyCollectedDataTypeProductInteraction</string>
39
+ <key>NSPrivacyCollectedDataTypeLinked</key>
40
+ <true/>
41
+ <key>NSPrivacyCollectedDataTypeTracking</key>
42
+ <false/>
43
+ <key>NSPrivacyCollectedDataTypePurposes</key>
44
+ <array>
45
+ <string>NSPrivacyCollectedDataTypePurposeAnalytics</string>
46
+ <string>NSPrivacyCollectedDataTypePurposeThirdPartyAdvertising</string>
47
+ </array>
48
+ </dict>
49
+ <dict>
50
+ <key>NSPrivacyCollectedDataType</key>
51
+ <string>NSPrivacyCollectedDataTypeOtherUsageData</string>
52
+ <key>NSPrivacyCollectedDataTypeLinked</key>
53
+ <true/>
54
+ <key>NSPrivacyCollectedDataTypeTracking</key>
55
+ <false/>
56
+ <key>NSPrivacyCollectedDataTypePurposes</key>
57
+ <array>
58
+ <string>NSPrivacyCollectedDataTypePurposeAnalytics</string>
59
+ <string>NSPrivacyCollectedDataTypePurposeThirdPartyAdvertising</string>
60
+ </array>
61
+ </dict>
62
+ <dict>
63
+ <key>NSPrivacyCollectedDataType</key>
64
+ <string>NSPrivacyCollectedDataTypeCoarseLocation</string>
65
+ <key>NSPrivacyCollectedDataTypeLinked</key>
66
+ <true/>
67
+ <key>NSPrivacyCollectedDataTypeTracking</key>
68
+ <false/>
69
+ <key>NSPrivacyCollectedDataTypePurposes</key>
70
+ <array>
71
+ <string>NSPrivacyCollectedDataTypePurposeAnalytics</string>
72
+ <string>NSPrivacyCollectedDataTypePurposeThirdPartyAdvertising</string>
73
+ </array>
74
+ </dict>
75
+ </array>
76
+ </dict>
77
+ </plist>
@@ -0,0 +1,14 @@
1
+ import Foundation
2
+
3
+ protocol Clock {
4
+ func now() -> Date
5
+ }
6
+
7
+ struct SystemClock: Clock {
8
+ func now() -> Date { Date() }
9
+ }
10
+
11
+ extension Date {
12
+ /// Milliseconds since 1970, rounded (so `…645.123` gives `…645123`, not `…645122`).
13
+ var epochMillis: Int64 { Int64((timeIntervalSince1970 * 1000).rounded()) }
14
+ }
@@ -0,0 +1,85 @@
1
+ import Foundation
2
+
3
+ struct QueuedEvent: Codable, Equatable {
4
+ /// Increases steadily and is never reused, even across reloads.
5
+ var seq: Int64
6
+ /// The finished event JSON, sent exactly as stored.
7
+ var body: JSONValue
8
+ }
9
+
10
+ /// Disk-backed FIFO of finished events (design §7.1). Not thread-safe on its own:
11
+ /// `AnglerCore.queue` serializes every call.
12
+ final class EventQueue {
13
+ private struct FileContents: Codable {
14
+ var nextSeq: Int64
15
+ var events: [QueuedEvent]
16
+ }
17
+
18
+ private let fileURL: URL
19
+ private let maxSize: Int
20
+ private var events: [QueuedEvent] = []
21
+ private var nextSeq: Int64 = 1
22
+
23
+ init(fileURL: URL, maxSize: Int) {
24
+ self.fileURL = fileURL
25
+ self.maxSize = max(1, maxSize)
26
+ load()
27
+ }
28
+
29
+ var count: Int { events.count }
30
+
31
+ /// Appends an event; when full, the oldest events are dropped.
32
+ func append(_ body: JSONValue) {
33
+ events.append(QueuedEvent(seq: nextSeq, body: body))
34
+ nextSeq += 1
35
+ if events.count > maxSize {
36
+ let dropped = events.count - maxSize
37
+ events.removeFirst(dropped)
38
+ Log.debug("queue full: dropped \(dropped) oldest event(s)")
39
+ }
40
+ save()
41
+ }
42
+
43
+ func peek(_ n: Int) -> [QueuedEvent] { Array(events.prefix(max(0, n))) }
44
+
45
+ func remove(seqs: Set<Int64>) {
46
+ guard !seqs.isEmpty else { return }
47
+ let before = events.count
48
+ events.removeAll { seqs.contains($0.seq) }
49
+ if events.count != before { save() }
50
+ }
51
+
52
+ func removeAll() {
53
+ events.removeAll()
54
+ save()
55
+ }
56
+
57
+ private func load() {
58
+ guard let data = try? Data(contentsOf: fileURL) else { return }
59
+ guard let contents = try? JSONDecoder().decode(FileContents.self, from: data) else {
60
+ Log.warning("queue file unreadable; starting empty")
61
+ try? FileManager.default.removeItem(at: fileURL)
62
+ return
63
+ }
64
+ events = Array(contents.events.suffix(maxSize))
65
+ nextSeq = max(contents.nextSeq, (events.last?.seq ?? 0) + 1)
66
+ }
67
+
68
+ /// Atomic write (temp file, then rename).
69
+ private func save() {
70
+ let dir = fileURL.deletingLastPathComponent()
71
+ do {
72
+ if !FileManager.default.fileExists(atPath: dir.path) {
73
+ try FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)
74
+ var values = URLResourceValues()
75
+ values.isExcludedFromBackup = true
76
+ var mutableDir = dir
77
+ try? mutableDir.setResourceValues(values)
78
+ }
79
+ let data = try JSONEncoder().encode(FileContents(nextSeq: nextSeq, events: events))
80
+ try data.write(to: fileURL, options: .atomic)
81
+ } catch {
82
+ Log.error("could not write queue file: \(error.localizedDescription)")
83
+ }
84
+ }
85
+ }
@@ -0,0 +1,76 @@
1
+ import Foundation
2
+
3
+ /// The install ID (`aid`), the user ID, custom identifiers and the stored flags.
4
+ final class IdentityStore {
5
+ private enum Key {
6
+ static let aid = "aid"
7
+ static let customerId = "customer_id"
8
+ static let custom = "custom_identifiers"
9
+ static let enabled = "enabled"
10
+ static let appTracking = "application_tracking_enabled"
11
+ }
12
+
13
+ /// Names a custom identifier may never use.
14
+ static let reservedNames: Set<String> =
15
+ Set(["aid", "customer_id", "idfa", "gaid"]).union(ClickIdParser.identifierByParameter.values)
16
+
17
+ private let store: KeyValueStore
18
+
19
+ init(store: KeyValueStore) { self.store = store }
20
+
21
+ /// Returns the stored `aid`, creating one if none exists. `isNew` means a first launch.
22
+ func ensureAid() -> (aid: String, isNew: Bool) {
23
+ if let aid = store.string(Key.aid), !aid.isEmpty { return (aid, false) }
24
+ let aid = Self.newAid()
25
+ store.set(aid, for: Key.aid)
26
+ return (aid, true)
27
+ }
28
+
29
+ var customerId: String? {
30
+ get { store.string(Key.customerId) }
31
+ set { store.set(newValue, for: Key.customerId) }
32
+ }
33
+
34
+ /// Sets or (with nil) removes a custom identifier. Returns false for a reserved name.
35
+ @discardableResult
36
+ func setIdentifier(_ name: String, value: String?) -> Bool {
37
+ guard !name.isEmpty, !Self.reservedNames.contains(name) else { return false }
38
+ var ids = customIdentifiers
39
+ ids[name] = value
40
+ writeCustom(ids)
41
+ return true
42
+ }
43
+
44
+ var customIdentifiers: [String: String] {
45
+ guard let raw = store.string(Key.custom),
46
+ let ids = try? JSONDecoder().decode([String: String].self, from: Data(raw.utf8))
47
+ else { return [:] }
48
+ return ids
49
+ }
50
+
51
+ var isEnabled: Bool {
52
+ get { store.string(Key.enabled) != "0" }
53
+ set { store.set(newValue ? "1" : "0", for: Key.enabled) }
54
+ }
55
+
56
+ var applicationTrackingEnabled: Bool {
57
+ get { store.string(Key.appTracking) != "0" }
58
+ set { store.set(newValue ? "1" : "0", for: Key.appTracking) }
59
+ }
60
+
61
+ /// Clears the user ID and custom identifiers and rotates the `aid`. Before the first
62
+ /// `aid` exists there is nothing to rotate, so a later first launch is still an install.
63
+ func reset() {
64
+ store.set(nil, for: Key.customerId)
65
+ store.set(nil, for: Key.custom)
66
+ if store.string(Key.aid) != nil { store.set(Self.newAid(), for: Key.aid) }
67
+ }
68
+
69
+ private func writeCustom(_ ids: [String: String]) {
70
+ if ids.isEmpty { store.set(nil, for: Key.custom); return }
71
+ let data = (try? JSONEncoder().encode(ids)) ?? Data("{}".utf8)
72
+ store.set(String(decoding: data, as: UTF8.self), for: Key.custom)
73
+ }
74
+
75
+ private static func newAid() -> String { UUID().uuidString.lowercased() }
76
+ }
@@ -0,0 +1,38 @@
1
+ import Foundation
2
+
3
+ /// String key/value persistence. Only touched on `AnglerCore.queue`.
4
+ protocol KeyValueStore: AnyObject {
5
+ func string(_ key: String) -> String?
6
+ func set(_ value: String?, for key: String)
7
+ }
8
+
9
+ final class UserDefaultsStore: KeyValueStore {
10
+ private let defaults: UserDefaults
11
+
12
+ init(suiteName: String = "ai.getangler.analytics") {
13
+ defaults = UserDefaults(suiteName: suiteName) ?? .standard
14
+ }
15
+
16
+ func string(_ key: String) -> String? { defaults.string(forKey: key) }
17
+
18
+ func set(_ value: String?, for key: String) {
19
+ if let value { defaults.set(value, forKey: key) } else { defaults.removeObject(forKey: key) }
20
+ }
21
+ }
22
+
23
+ final class InMemoryStore: KeyValueStore {
24
+ private var values: [String: String] = [:]
25
+ private let lock = NSLock()
26
+
27
+ init() {}
28
+
29
+ func string(_ key: String) -> String? {
30
+ lock.lock(); defer { lock.unlock() }
31
+ return values[key]
32
+ }
33
+
34
+ func set(_ value: String?, for key: String) {
35
+ lock.lock(); defer { lock.unlock() }
36
+ values[key] = value
37
+ }
38
+ }
@@ -0,0 +1,4 @@
1
+ enum SDKVersion {
2
+ /// Written by `scripts/sync-version.mjs` from the repo `VERSION` file.
3
+ static let current = "0.1.0-rc.1"
4
+ }
package/package.json CHANGED
@@ -1,6 +1,48 @@
1
1
  {
2
2
  "name": "@anglerai/react-native-analytics",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0-rc.1",
4
+ "description": "Angler app analytics and attribution for React Native (iOS and Android).",
5
+ "license": "MIT",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "react-native": "src/index.ts",
9
+ "source": "src/index.ts",
10
+ "files": [
11
+ "src",
12
+ "lib",
13
+ "ios",
14
+ "android",
15
+ "AnglerAnalyticsRN.podspec",
16
+ "!**/__tests__",
17
+ "!android/build",
18
+ "!android/.gradle"
19
+ ],
20
+ "scripts": {
21
+ "test": "jest && node --test scripts/__tests__/",
22
+ "prepack": "node scripts/sync-native.mjs",
23
+ "typecheck": "tsc --noEmit"
24
+ },
25
+ "peerDependencies": {
26
+ "react-native": ">=0.76"
27
+ },
28
+ "devDependencies": {
29
+ "@babel/core": "^7.26.0",
30
+ "@babel/preset-env": "^7.26.0",
31
+ "@babel/preset-typescript": "^7.26.0",
32
+ "@types/jest": "^29.5.14",
33
+ "@types/node": "^20.19.43",
34
+ "babel-jest": "^29.7.0",
35
+ "jest": "^29.7.0",
36
+ "react": "18.3.1",
37
+ "react-native": "0.76.9",
38
+ "typescript": "~5.6.3"
39
+ },
40
+ "codegenConfig": {
41
+ "name": "AnglerAnalyticsSpec",
42
+ "type": "modules",
43
+ "jsSrcsDir": "src",
44
+ "android": {
45
+ "javaPackageName": "ai.getangler.analytics.reactnative"
46
+ }
47
+ }
48
+ }
@@ -0,0 +1,21 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import { TurboModuleRegistry } from 'react-native';
3
+
4
+ /**
5
+ * Codegen spec for the `AnglerAnalytics` TurboModule. Structured arguments cross the bridge
6
+ * as JSON strings so both platforms parse them the same way.
7
+ */
8
+ export interface Spec extends TurboModule {
9
+ configure(configJson: string): void;
10
+ track(name: string, dataJson: string | null, propertiesJson: string | null, eventId: string | null): void;
11
+ handleDeepLink(url: string): void;
12
+ setUserId(userId: string | null): void;
13
+ setIdentifier(name: string, value: string | null): void;
14
+ setApplicationTrackingEnabled(enabled: boolean): void;
15
+ setEnabled(enabled: boolean): void;
16
+ flush(): void;
17
+ reset(): void;
18
+ }
19
+
20
+ // `get`, not `getEnforcing`: a missing native module must not throw at import time.
21
+ export default TurboModuleRegistry.get<Spec>('AnglerAnalytics');