@selwise/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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +119 -0
  3. package/package.json +25 -2
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Selwise
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.
package/README.md ADDED
@@ -0,0 +1,119 @@
1
+ # @selwise/react-native
2
+
3
+ Headless React Native SDK for Selwise tracking, identity, search, and recommendations.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @selwise/react-native @react-native-async-storage/async-storage
9
+ ```
10
+
11
+ Compatible with Expo and Bare React Native.
12
+
13
+ ## Quick Start
14
+
15
+ ```ts
16
+ import Selwise from '@selwise/react-native';
17
+
18
+ const sdk = new Selwise();
19
+
20
+ await sdk.init({
21
+ siteKey: 'YOUR_SITE_KEY',
22
+ apiUrl: 'https://api.selwise.com/api/v1',
23
+ apiKey: 'YOUR_MOBILE_API_KEY',
24
+ sdkVersion: '0.1.2',
25
+ });
26
+ ```
27
+
28
+ ## Config Reference
29
+
30
+ | Field | Required | Default | Description |
31
+ | --- | --- | --- | --- |
32
+ | `siteKey` | Yes | - | Selwise site key. |
33
+ | `apiKey` | Yes | - | Scoped mobile API key. |
34
+ | `apiUrl` | No | `https://api.selwise.com/api/v1` | API base URL. |
35
+ | `sdkPlatform` | No | `react-native` | Header value for client platform. |
36
+ | `sdkVersion` | No | `0.1.0` | Header value for SDK version. |
37
+ | `flushIntervalMs` | No | `15000` | Periodic flush interval. |
38
+ | `batchSize` | No | `25` | Max events per flush batch. |
39
+ | `maxRetries` | No | `5` | Retry attempts per failed event. |
40
+ | `maxQueueSize` | No | `500` | Max queued events. |
41
+ | `journeyTtlMs` | No | `1800000` | Journey expiration window. |
42
+ | `storagePrefix` | No | `selwise_rn` | Storage key prefix. |
43
+ | `storage` | No | AsyncStorage if available, otherwise in-memory | Custom storage adapter. |
44
+
45
+ ## Method Availability
46
+
47
+ | Method Group | Available | Notes |
48
+ | --- | --- | --- |
49
+ | Lifecycle (`init`, `destroy`) | Yes | `init` required before other calls. |
50
+ | Tracking (`track`, `flush`) | Yes | `flush` forces immediate network send. |
51
+ | Orders (`trackOrder`) | Yes | Sends to public order endpoint. |
52
+ | Identity (`identify`, `setTraits`) | Yes | Links and updates user profile state. |
53
+ | Session/Journey getters | Yes | Returns runtime IDs and journey state. |
54
+ | Data layer (`pushDataLayer`, `getDataLayer`) | Yes | Local state snapshot, not a network sender by itself. |
55
+ | Consent (`getConsentState`, `grantConsent`, `revokeConsent`) | Yes | Uses public consent endpoints with scoped auth. |
56
+ | Headless data APIs (`search`, recommendation, config methods) | Yes | You render UI in app code. |
57
+ | `window.Selwise` / DOM rendering | No | v1 is headless only. |
58
+
59
+ ## Track vs Data Layer
60
+
61
+ ```ts
62
+ sdk.track('product_view', {
63
+ entityType: 'product',
64
+ entityId: 'sku-123',
65
+ metadata: { productItemCode: 'sku-123' },
66
+ });
67
+
68
+ await sdk.flush();
69
+ ```
70
+
71
+ ```ts
72
+ sdk.pushDataLayer({
73
+ event: 'product_view',
74
+ product: { sku: 'sku-123', title: 'Runner Pro' },
75
+ });
76
+
77
+ console.log(sdk.getDataLayer());
78
+ ```
79
+
80
+ - `track` is for canonical network event ingestion.
81
+ - `pushDataLayer` is for local structured state mirroring.
82
+
83
+ ## Auth Scope Quick Reference
84
+
85
+ | HTTP Method | Required Scope |
86
+ | --- | --- |
87
+ | `GET` | `mobile_read` |
88
+ | `POST`, `PUT`, `PATCH`, `DELETE` | `mobile_write` |
89
+
90
+ Headers sent automatically:
91
+
92
+ - `x-selwise-api-key`
93
+ - `x-selwise-client-platform`
94
+ - `x-selwise-client-version`
95
+
96
+ ## Troubleshooting
97
+
98
+ 1. `403 Invalid API key or insufficient scope`.
99
+ - Check key status and method scope.
100
+
101
+ 2. Events are queued but not ingested.
102
+ - Call `await sdk.flush()` and verify network/retry window.
103
+
104
+ 3. Search/recommendation responses arrive but nothing renders.
105
+ - SDK is headless; render data with your own RN components.
106
+
107
+ ## Documentation
108
+
109
+ - [React Native Integration](https://docs.selwise.com/getting-started/react-native-integration/)
110
+ - [Platform Playbooks](https://docs.selwise.com/getting-started/platform-playbooks/)
111
+ - [Public API](https://docs.selwise.com/client-api/public-api/)
112
+ - [Event Cookbook](https://docs.selwise.com/client-api/event-cookbook/)
113
+ - [Mobile Auth](https://docs.selwise.com/client-api/mobile-auth/)
114
+ - [Verification](https://docs.selwise.com/getting-started/verification/)
115
+ - [Troubleshooting](https://docs.selwise.com/getting-started/integration-troubleshooting/)
116
+
117
+ ## License
118
+
119
+ MIT, see [LICENSE](./LICENSE).
package/package.json CHANGED
@@ -1,15 +1,38 @@
1
1
  {
2
2
  "name": "@selwise/react-native",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Selwise headless React Native SDK",
5
5
  "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/selimgunaydin/selwise.git",
9
+ "directory": "apps/react-native-sdk"
10
+ },
11
+ "homepage": "https://docs.selwise.com/getting-started/react-native-integration/",
12
+ "bugs": {
13
+ "url": "https://github.com/selimgunaydin/selwise/issues"
14
+ },
15
+ "keywords": [
16
+ "selwise",
17
+ "react-native",
18
+ "expo",
19
+ "ecommerce",
20
+ "personalization",
21
+ "analytics",
22
+ "tracking"
23
+ ],
6
24
  "private": false,
7
25
  "sideEffects": false,
8
26
  "main": "./dist/index.js",
9
27
  "types": "./dist/index.d.ts",
10
28
  "files": [
11
- "dist"
29
+ "dist",
30
+ "README.md",
31
+ "LICENSE"
12
32
  ],
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
13
36
  "scripts": {
14
37
  "clean": "rm -rf dist",
15
38
  "build": "pnpm run clean && tsc -p tsconfig.json",