@playbasis-ai/qwikcard-sdk 2.3.4
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 +142 -0
- package/LICENSE +21 -0
- package/README.md +267 -0
- package/SDK_HANDOVER_GUIDE.md +129 -0
- package/dist/PlaybasisProvider.d.ts +19 -0
- package/dist/PlaybasisProvider.d.ts.map +1 -0
- package/dist/PlaybasisProvider.js +24 -0
- package/dist/QwikCardApp.d.ts +9 -0
- package/dist/QwikCardApp.d.ts.map +1 -0
- package/dist/QwikCardApp.js +210 -0
- package/dist/api/client.d.ts +66 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +196 -0
- package/dist/components/Badge.d.ts +8 -0
- package/dist/components/Badge.d.ts.map +1 -0
- package/dist/components/Badge.js +34 -0
- package/dist/components/BadgeIcon.d.ts +10 -0
- package/dist/components/BadgeIcon.d.ts.map +1 -0
- package/dist/components/BadgeIcon.js +51 -0
- package/dist/components/Button.d.ts +10 -0
- package/dist/components/Button.d.ts.map +1 -0
- package/dist/components/Button.js +40 -0
- package/dist/components/GradientCard.d.ts +9 -0
- package/dist/components/GradientCard.d.ts.map +1 -0
- package/dist/components/GradientCard.js +28 -0
- package/dist/components/PointsBalance.d.ts +8 -0
- package/dist/components/PointsBalance.d.ts.map +1 -0
- package/dist/components/PointsBalance.js +85 -0
- package/dist/components/ProgressBar.d.ts +8 -0
- package/dist/components/ProgressBar.d.ts.map +1 -0
- package/dist/components/ProgressBar.js +41 -0
- package/dist/components/QuestProgress.d.ts +10 -0
- package/dist/components/QuestProgress.d.ts.map +1 -0
- package/dist/components/QuestProgress.js +94 -0
- package/dist/components/RadialGauge.d.ts +8 -0
- package/dist/components/RadialGauge.d.ts.map +1 -0
- package/dist/components/RadialGauge.js +53 -0
- package/dist/components/RewardCard.d.ts +10 -0
- package/dist/components/RewardCard.d.ts.map +1 -0
- package/dist/components/RewardCard.js +64 -0
- package/dist/components/RulesModal.d.ts +7 -0
- package/dist/components/RulesModal.d.ts.map +1 -0
- package/dist/components/RulesModal.js +106 -0
- package/dist/hooks/useBadges.d.ts +12 -0
- package/dist/hooks/useBadges.d.ts.map +1 -0
- package/dist/hooks/useBadges.js +42 -0
- package/dist/hooks/usePoints.d.ts +13 -0
- package/dist/hooks/usePoints.d.ts.map +1 -0
- package/dist/hooks/usePoints.js +70 -0
- package/dist/hooks/useQuests.d.ts +12 -0
- package/dist/hooks/useQuests.d.ts.map +1 -0
- package/dist/hooks/useQuests.js +41 -0
- package/dist/hooks/useQwikApp.d.ts +16 -0
- package/dist/hooks/useQwikApp.d.ts.map +1 -0
- package/dist/hooks/useQwikApp.js +42 -0
- package/dist/hooks/useRewards.d.ts +12 -0
- package/dist/hooks/useRewards.d.ts.map +1 -0
- package/dist/hooks/useRewards.js +56 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/theme/context.d.ts +8 -0
- package/dist/theme/context.d.ts.map +1 -0
- package/dist/theme/context.js +8 -0
- package/dist/theme/tokens.d.ts +35 -0
- package/dist/theme/tokens.d.ts.map +1 -0
- package/dist/theme/tokens.js +33 -0
- package/dist/types/index.d.ts +119 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +4 -0
- package/dist/web/widgetAssets.d.ts +4 -0
- package/dist/web/widgetAssets.d.ts.map +1 -0
- package/dist/web/widgetAssets.js +5 -0
- package/dist/web/widgetHtml.d.ts +2 -0
- package/dist/web/widgetHtml.d.ts.map +1 -0
- package/dist/web/widgetHtml.js +299 -0
- package/dist/web/widgetTypes.d.ts +128 -0
- package/dist/web/widgetTypes.d.ts.map +1 -0
- package/dist/web/widgetTypes.js +1 -0
- package/package.json +86 -0
- package/src/PlaybasisProvider.tsx +72 -0
- package/src/QwikCardApp.tsx +302 -0
- package/src/api/client.ts +307 -0
- package/src/components/Badge.tsx +51 -0
- package/src/components/BadgeIcon.tsx +97 -0
- package/src/components/Button.tsx +70 -0
- package/src/components/GradientCard.tsx +49 -0
- package/src/components/PointsBalance.tsx +122 -0
- package/src/components/ProgressBar.tsx +65 -0
- package/src/components/QuestProgress.tsx +153 -0
- package/src/components/RadialGauge.tsx +101 -0
- package/src/components/RewardCard.tsx +123 -0
- package/src/components/RulesModal.tsx +171 -0
- package/src/hooks/useBadges.ts +59 -0
- package/src/hooks/usePoints.ts +91 -0
- package/src/hooks/useQuests.ts +60 -0
- package/src/hooks/useQwikApp.ts +49 -0
- package/src/hooks/useRewards.ts +74 -0
- package/src/index.ts +34 -0
- package/src/theme/context.tsx +17 -0
- package/src/theme/tokens.ts +68 -0
- package/src/types/index.ts +176 -0
- package/src/web/widgetAssets.d.ts +3 -0
- package/src/web/widgetAssets.ts +6 -0
- package/src/web/widgetHtml.ts +302 -0
- package/src/web/widgetTypes.ts +146 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.2.0] - 2025-12-29
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- "How to Play" `RulesModal` component for player guidance.
|
|
13
|
+
- New Header in `DashboardScreen` with Help and Notification icons.
|
|
14
|
+
- `SDK_HANDOVER_GUIDE.md` for easier integration.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- Mobile responsiveness and compact UI refinements across all screens.
|
|
19
|
+
- Web preview modal containment within smartphone frame.
|
|
20
|
+
- Radial gauge aspect ratio for better information density.
|
|
21
|
+
|
|
22
|
+
## [1.3.0] - 2026-01-03
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
|
|
26
|
+
- `QwikCardApp` now renders the Playbasis Widget UI via `react-native-webview` (WebView-embedded Widget SDK).
|
|
27
|
+
- Updated SDK documentation to reflect WebView integration and the recommended one-line integration path.
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
|
|
31
|
+
- `react-native-webview` as a peer dependency.
|
|
32
|
+
|
|
33
|
+
## [1.3.1] - 2026-01-04
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
|
|
37
|
+
- Updated production handover guidance to use production APIM base path `/v1`.
|
|
38
|
+
- Prepared new-tenant handover workflow for `qwik-prod` without requiring Expo.
|
|
39
|
+
|
|
40
|
+
## [2.3.3] - 2026-01-19
|
|
41
|
+
|
|
42
|
+
### Fixed
|
|
43
|
+
|
|
44
|
+
- Updated `Currency` type and `usePoints` hook to use `coins` (matching API) instead of `qwik-coins`.
|
|
45
|
+
|
|
46
|
+
## [2.3.2] - 2026-01-17
|
|
47
|
+
|
|
48
|
+
### Changed
|
|
49
|
+
|
|
50
|
+
- Pinned Arcade Center banners to the hosted CDN URLs.
|
|
51
|
+
|
|
52
|
+
## [2.3.1] - 2026-01-17
|
|
53
|
+
|
|
54
|
+
### Changed
|
|
55
|
+
|
|
56
|
+
- Fixed Arcade Center banner URL resolution when running inside the widget WebView.
|
|
57
|
+
|
|
58
|
+
## [2.3.0] - 2026-01-17
|
|
59
|
+
|
|
60
|
+
### Changed
|
|
61
|
+
|
|
62
|
+
- Fixed Arcade Center banner URLs for hosted game assets.
|
|
63
|
+
|
|
64
|
+
## [2.2.9] - 2026-01-17
|
|
65
|
+
|
|
66
|
+
### Changed
|
|
67
|
+
|
|
68
|
+
- Added Arcade Center banner rendering with hosted images.
|
|
69
|
+
|
|
70
|
+
## [2.2.8] - 2026-01-17
|
|
71
|
+
|
|
72
|
+
### Changed
|
|
73
|
+
|
|
74
|
+
- Rebuilt the embedded widget assets with the latest Arcade Center updates.
|
|
75
|
+
|
|
76
|
+
## [2.2.7] - 2026-01-17
|
|
77
|
+
|
|
78
|
+
### Added
|
|
79
|
+
|
|
80
|
+
- Play tab with Arcade Center (Match-3 Challenge + Bubble Blast) in the embedded widget.
|
|
81
|
+
|
|
82
|
+
### Fixed
|
|
83
|
+
|
|
84
|
+
- `GradientCard` now falls back to `View` when `react-native-linear-gradient` is unavailable.
|
|
85
|
+
|
|
86
|
+
### Removed
|
|
87
|
+
|
|
88
|
+
- Legacy React Native screens and Navigator exports (WebView widget is the primary UI).
|
|
89
|
+
|
|
90
|
+
### Changed
|
|
91
|
+
|
|
92
|
+
- Added tab collapse/expand control in the widget Play navigation.
|
|
93
|
+
|
|
94
|
+
### Fixed
|
|
95
|
+
|
|
96
|
+
- Cleaned unused campaign hooks in widget runtime.
|
|
97
|
+
|
|
98
|
+
### Fixed
|
|
99
|
+
|
|
100
|
+
- Arcade Center now returns to the Play tab on back with Qwik light header.
|
|
101
|
+
|
|
102
|
+
## [1.0.0] - 2024-12-15
|
|
103
|
+
|
|
104
|
+
### Added
|
|
105
|
+
|
|
106
|
+
- Initial release of @playbasis/qwikcard-sdk
|
|
107
|
+
|
|
108
|
+
(Package name/scope may differ depending on your distribution channel.)
|
|
109
|
+
|
|
110
|
+
- `PlaybasisProvider` - React context provider for SDK configuration
|
|
111
|
+
- `PlaybasisClient` - Fetch-based API client with idempotency support
|
|
112
|
+
|
|
113
|
+
#### Hooks
|
|
114
|
+
|
|
115
|
+
- `usePoints()` - Manage player point balances
|
|
116
|
+
- `useQuests()` - Track quest progress and completion
|
|
117
|
+
- `useBadges()` - Display earned and available badges
|
|
118
|
+
- `useRewards()` - Browse and redeem rewards
|
|
119
|
+
- `usePlaybasis()` - Direct access to client and context
|
|
120
|
+
|
|
121
|
+
#### Components
|
|
122
|
+
|
|
123
|
+
- `PointsBalance` - Display multiple currency balances
|
|
124
|
+
- `QuestProgress` - Quest card with progress bar
|
|
125
|
+
- `RewardCard` - Reward item with redemption button
|
|
126
|
+
- `BadgeIcon` - Badge display with earned/locked states
|
|
127
|
+
|
|
128
|
+
#### Event Types
|
|
129
|
+
|
|
130
|
+
- `card.purchase` - Debit card transactions
|
|
131
|
+
- `card.deposit` - Direct deposits
|
|
132
|
+
- `card.atm` - ATM withdrawals
|
|
133
|
+
- `qwikit.sent` / `qwikit.received` - P2P transfers
|
|
134
|
+
- `referral.signup` - Referral completions
|
|
135
|
+
- `profile.complete` - Profile completion
|
|
136
|
+
|
|
137
|
+
### Security
|
|
138
|
+
|
|
139
|
+
- Fetch-based client (no axios dependency)
|
|
140
|
+
- Safe JSON parsing with error handling
|
|
141
|
+
- UUID-based idempotency keys (collision-resistant)
|
|
142
|
+
- No credentials stored in SDK
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Playbasis Co., Ltd.
|
|
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,267 @@
|
|
|
1
|
+
# @foremost-ai/qwikcard-sdk
|
|
2
|
+
|
|
3
|
+
> Official React Native SDK for Playbasis gamification integration
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@foremost-ai/qwikcard-sdk)
|
|
6
|
+
[](https://www.typescriptlang.org/)
|
|
7
|
+
[](https://reactnative.dev/)
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- ๐ฎ **Full Gamification Suite** - Points, quests, badges, rewards, leaderboards
|
|
12
|
+
- โก **Real-time Updates** - React hooks with automatic state management
|
|
13
|
+
- ๐ **Secure by Design** - No credentials stored, idempotent requests
|
|
14
|
+
- ๐งฉ **Widget UI via WebView** - Full Playbasis Widget experience embedded in RN
|
|
15
|
+
- ๐ **Offline-Friendly** - Graceful error handling
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @foremost-ai/qwikcard-sdk
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Peer Dependencies
|
|
24
|
+
|
|
25
|
+
You must install the following dependencies in your project:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install react-native-linear-gradient react-native-svg react-native-webview
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Local Installation (if not published to npm)
|
|
32
|
+
|
|
33
|
+
If this package is not published to npm, you can install it locally in your project using one of the following methods:
|
|
34
|
+
|
|
35
|
+
#### 1. From a Local Folder (Symlink for Development)
|
|
36
|
+
|
|
37
|
+
Unzip or place the SDK folder (with `package.json`) somewhere on your machine, e.g., `~/playbasis-sdk/`.
|
|
38
|
+
In your project, run:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
yarn add /absolute/path/to/playbasis-sdk
|
|
42
|
+
# or
|
|
43
|
+
npm install /absolute/path/to/playbasis-sdk
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
#### 2. From a Tarball (.tgz or .zip)
|
|
47
|
+
|
|
48
|
+
If you have a file like `playbasis-qwikcard-sdk-1.0.0.zip` or `.tgz`, you can install directly:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
yarn add ./client-sdks/qwikcard-sdk/playbasis-qwikcard-sdk-1.0.0.zip
|
|
52
|
+
# or
|
|
53
|
+
npm install ./client-sdks/qwikcard-sdk/playbasis-qwikcard-sdk-1.0.0.zip
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
#### 3. npm/yarn link (for active development)
|
|
57
|
+
|
|
58
|
+
In the SDK folder:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npm link
|
|
62
|
+
# or
|
|
63
|
+
yarn link
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
In your project folder:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npm link @foremost-ai/qwikcard-sdk
|
|
70
|
+
# or
|
|
71
|
+
yarn link @foremost-ai/qwikcard-sdk
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### 4. From a Git Repository
|
|
75
|
+
|
|
76
|
+
If the SDK is hosted in a private Git repo:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
yarn add git+https://github.com/your-org/playbasis-qwikcard-sdk.git
|
|
80
|
+
# or
|
|
81
|
+
npm install git+https://github.com/your-org/playbasis-qwikcard-sdk.git
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
If the package is published to npm, you can install as usual:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
npm install @foremost-ai/qwikcard-sdk
|
|
90
|
+
# or
|
|
91
|
+
yarn add @foremost-ai/qwikcard-sdk
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Requirements
|
|
95
|
+
|
|
96
|
+
- React Native >= 0.70.0
|
|
97
|
+
- React >= 18.0.0
|
|
98
|
+
|
|
99
|
+
## Quick Start
|
|
100
|
+
|
|
101
|
+
### 1. One-Line Integration (Recommended)
|
|
102
|
+
|
|
103
|
+
`QwikCardApp` renders the full Playbasis experience using a WebView-embedded Widget UI, while keeping API calls on the React Native side.
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
import { QwikCardApp } from '@foremost-ai/qwikcard-sdk';
|
|
107
|
+
|
|
108
|
+
export default function RewardsAndGamificationScreen() {
|
|
109
|
+
return (
|
|
110
|
+
<QwikCardApp
|
|
111
|
+
apiKey="YOUR_SUBSCRIPTION_KEY"
|
|
112
|
+
tenantId="YOUR_TENANT_ID"
|
|
113
|
+
playerId={currentUser.playbasisPlayerId}
|
|
114
|
+
baseUrl="https://api.playbasis.com" // optional
|
|
115
|
+
leaderboardId="YOUR_LEADERBOARD_ID" // optional
|
|
116
|
+
/>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Notes:
|
|
122
|
+
|
|
123
|
+
- `leaderboardId` is optional because the Playbasis API requires a concrete leaderboard identifier. If omitted, the widget will render with an empty leaderboard section.
|
|
124
|
+
- Activity charts are returned as an empty array in v1.3.0 unless/until an activity endpoint is added to the API.
|
|
125
|
+
|
|
126
|
+
### 2. Provider + Hooks (Optional / Advanced)
|
|
127
|
+
|
|
128
|
+
If you need direct access to the API client for custom UI/logic, you can still use the provider + hooks.
|
|
129
|
+
|
|
130
|
+
#### Wrap Your App
|
|
131
|
+
|
|
132
|
+
```tsx
|
|
133
|
+
import { PlaybasisProvider } from '@foremost-ai/qwikcard-sdk';
|
|
134
|
+
|
|
135
|
+
export default function App() {
|
|
136
|
+
return (
|
|
137
|
+
<PlaybasisProvider
|
|
138
|
+
apiKey="YOUR_SUBSCRIPTION_KEY"
|
|
139
|
+
tenantId="qwikcard"
|
|
140
|
+
playerId={currentUser.playbasisPlayerId}
|
|
141
|
+
>
|
|
142
|
+
<YourApp />
|
|
143
|
+
</PlaybasisProvider>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### 2. Use Hooks (with your own screens)
|
|
149
|
+
|
|
150
|
+
```tsx
|
|
151
|
+
import { useQuests, useRewards, useBadges, usePoints } from '@foremost-ai/qwikcard-sdk';
|
|
152
|
+
|
|
153
|
+
function RewardsScreen() {
|
|
154
|
+
const { rewards } = useRewards();
|
|
155
|
+
const { badges } = useBadges();
|
|
156
|
+
const { xp, qwikCoins } = usePoints();
|
|
157
|
+
|
|
158
|
+
return (
|
|
159
|
+
<View>
|
|
160
|
+
<Text>XP: {xp}</Text>
|
|
161
|
+
<Text>Qwik Coins: {qwikCoins}</Text>
|
|
162
|
+
{/* Render rewards + badges here */}
|
|
163
|
+
</View>
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### 3. Use Components (with your own screens)
|
|
169
|
+
|
|
170
|
+
```tsx
|
|
171
|
+
import { QuestProgress, RewardCard, BadgeIcon, PointsBalance } from '@foremost-ai/qwikcard-sdk';
|
|
172
|
+
|
|
173
|
+
function QuestsScreen() {
|
|
174
|
+
const { quests } = useQuests();
|
|
175
|
+
const { balances } = usePoints();
|
|
176
|
+
|
|
177
|
+
return (
|
|
178
|
+
<ScrollView>
|
|
179
|
+
<PointsBalance balances={balances} />
|
|
180
|
+
{quests.map((quest) => (
|
|
181
|
+
<QuestProgress key={quest.id} quest={quest} />
|
|
182
|
+
))}
|
|
183
|
+
</ScrollView>
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## API Client (Direct Access)
|
|
189
|
+
|
|
190
|
+
For custom operations:
|
|
191
|
+
|
|
192
|
+
```tsx
|
|
193
|
+
import { usePlaybasis } from '@foremost-ai/qwikcard-sdk';
|
|
194
|
+
|
|
195
|
+
function TransactionLogger() {
|
|
196
|
+
const { client, playerId } = usePlaybasis();
|
|
197
|
+
|
|
198
|
+
const logPurchase = async (transaction) => {
|
|
199
|
+
await client.trackEvent({
|
|
200
|
+
type: 'card.purchase',
|
|
201
|
+
playerId,
|
|
202
|
+
referenceId: transaction.i2c_trans_id,
|
|
203
|
+
data: {
|
|
204
|
+
amount: transaction.amount,
|
|
205
|
+
mcc: transaction.mcc,
|
|
206
|
+
category: transaction.category,
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
return { logPurchase };
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Event Types
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
type QwikCardEventType =
|
|
219
|
+
| 'card.purchase' // Debit card transaction
|
|
220
|
+
| 'card.deposit' // Direct deposit
|
|
221
|
+
| 'card.atm' // ATM withdrawal
|
|
222
|
+
| 'qwikit.sent' // P2P transfer sent
|
|
223
|
+
| 'qwikit.received' // P2P transfer received
|
|
224
|
+
| 'referral.signup' // Friend signed up
|
|
225
|
+
| 'profile.complete'; // Profile completed
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## API Reference
|
|
229
|
+
|
|
230
|
+
### Hooks
|
|
231
|
+
|
|
232
|
+
| Hook | Description |
|
|
233
|
+
| ---------------- | ---------------------------------- |
|
|
234
|
+
| `usePoints()` | Player point balances, earn points |
|
|
235
|
+
| `useQuests()` | Active and completed quests |
|
|
236
|
+
| `useBadges()` | Earned and available badges |
|
|
237
|
+
| `useRewards()` | Reward catalog and redemption |
|
|
238
|
+
| `usePlaybasis()` | Direct client access |
|
|
239
|
+
|
|
240
|
+
### Components
|
|
241
|
+
|
|
242
|
+
| Component | Description |
|
|
243
|
+
| --------------------- | ------------------------------- |
|
|
244
|
+
| `<PlaybasisProvider>` | Context provider (required) |
|
|
245
|
+
| `<PointsBalance>` | Display point balances |
|
|
246
|
+
| `<QuestProgress>` | Quest progress card |
|
|
247
|
+
| `<RewardCard>` | Reward item with redeem button |
|
|
248
|
+
| `<BadgeIcon>` | Badge display with earned state |
|
|
249
|
+
|
|
250
|
+
## Security
|
|
251
|
+
|
|
252
|
+
- โ
No credentials stored in SDK
|
|
253
|
+
- โ
All requests use HTTPS
|
|
254
|
+
- โ
Idempotency keys prevent duplicate operations
|
|
255
|
+
- โ
Safe JSON parsing (handles malformed responses)
|
|
256
|
+
|
|
257
|
+
## Support
|
|
258
|
+
|
|
259
|
+
Contact Playbasis support for:
|
|
260
|
+
|
|
261
|
+
- API credentials
|
|
262
|
+
- Integration assistance
|
|
263
|
+
- Custom implementations
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
ยฉ 2025 Playbasis. All rights reserved.
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# QwikCard SDK Handover Guide (v2.3.2)
|
|
2
|
+
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This SDK is a **React Native Library**, not a standalone application. In v2.3.2, the primary UI is delivered via a **WebView-embedded Widget UI** (the Playbasis Widget SDK), while API calls remain on the React Native side.
|
|
5
|
+
|
|
6
|
+
This document provides instructions for the Qwik team to integrate the latest Playbasis gamification experience into the QwikCard mobile SDK.
|
|
7
|
+
|
|
8
|
+
## Overview of Changes
|
|
9
|
+
|
|
10
|
+
The v2.3.2 update shifts the SDK to a **WebView + bridge** architecture, focused on:
|
|
11
|
+
|
|
12
|
+
- **One-Line Integration**: Use `<QwikCardApp />` to render the full experience.
|
|
13
|
+
- **Widget UI Parity**: UI comes from the Playbasis Widget SDK (web UI) embedded into the RN SDK.
|
|
14
|
+
- **Direct-to-Tenant Support**: Calls go through APIM using `Ocp-Apim-Subscription-Key` + `X-Tenant-ID` headers (configured via props).
|
|
15
|
+
- **Key Handling**: The APIM subscription key stays in React Native; the WebView requests data via a message bridge.
|
|
16
|
+
- **Bundle Workflow**: See [QWIK_SDK_BUNDLE_WORKFLOW.md](../../QWIK_SDK_BUNDLE_WORKFLOW.md) for the slim bundle + PLAY tab shipping checklist.
|
|
17
|
+
|
|
18
|
+
## ๐ฆ Changeset Summary
|
|
19
|
+
|
|
20
|
+
### Key Implementation Notes
|
|
21
|
+
|
|
22
|
+
- `QwikCardApp` now renders a `react-native-webview` with embedded Widget SDK assets.
|
|
23
|
+
- The WebView requests bootstrap data (player, balances, quests, badges) from React Native via a REQUEST/RESPONSE message bridge.
|
|
24
|
+
|
|
25
|
+
## ๐ฆ Installation (Private Distribution)
|
|
26
|
+
|
|
27
|
+
To maintain privacy while ensuring "ease of use," we recommend one of the following methods for integrating the SDK into your project:
|
|
28
|
+
|
|
29
|
+
### 1. Local Package Installation (Recommended for Testing)
|
|
30
|
+
|
|
31
|
+
You can install the provided tarball directly into your mSDK project:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install ./path/to/qwikcard-sdk-v2.3.2.tar.gz
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
This adds the SDK to your `node_modules` and `package.json` just like a public package.
|
|
38
|
+
|
|
39
|
+
### 2. Private Git Dependency
|
|
40
|
+
|
|
41
|
+
If you host this in a private repository, you can install it directly via SSH:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm install git+ssh://git@github.com:your-org/qwikcard-sdk.git#v2.3.2
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 3. Private Registry (GitHub Packages) - RECOMMENDED
|
|
48
|
+
|
|
49
|
+
For the most professional "NPM experience" without public exposure, use **GitHub Packages**. This allows your team to use standard NPM commands while maintaining 100% privacy:
|
|
50
|
+
|
|
51
|
+
1. **Publish to GitHub**: Configure your `package.json` to point to the `@rzforemost` scope on GitHub.
|
|
52
|
+
2. **Install via NPM**:
|
|
53
|
+
```bash
|
|
54
|
+
npm install @foremost-ai/qwikcard-sdk
|
|
55
|
+
```
|
|
56
|
+
_(Note: Requires a `.npmrc` file with a GitHub Personal Access Token)._
|
|
57
|
+
|
|
58
|
+
## ๐ ๏ธ One-Line Integration (Component as a "Method")
|
|
59
|
+
|
|
60
|
+
If your team prefers an "invocation" style, simply wrap the `QwikCardApp` in a single screen or a conditional overlay. This effectively "invokes" the entire template library in one line:
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
import { QwikCardApp } from '@foremost-ai/qwikcard-sdk';
|
|
64
|
+
|
|
65
|
+
const MyScreen = () => (
|
|
66
|
+
<QwikCardApp
|
|
67
|
+
apiKey="YOUR_API_KEY"
|
|
68
|
+
tenantId="YOUR_TENANT_ID"
|
|
69
|
+
playerId="USER_123"
|
|
70
|
+
baseUrl="https://api.playbasis.com" // optional
|
|
71
|
+
leaderboardId="YOUR_LEADERBOARD_ID" // optional
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## ๐ ๏ธ Integration Notes
|
|
77
|
+
|
|
78
|
+
- Ensure your host app installs `react-native-webview` (peer dependency).
|
|
79
|
+
- If your host app uses strict network allowlists / ATS settings, ensure the APIM base URL is permitted.
|
|
80
|
+
|
|
81
|
+
## ๐ Targeting Web (Vite/Next.js)
|
|
82
|
+
|
|
83
|
+
The SDK exports React Native components/hooks as well. If you use those exports in a web project (like Vite or Next.js), you must use **`react-native-web`** to alias the components:
|
|
84
|
+
|
|
85
|
+
1. **Install Aliases**: `npm install react-native-web`
|
|
86
|
+
2. **Configure Vite**:
|
|
87
|
+
```javascript
|
|
88
|
+
// vite.config.ts
|
|
89
|
+
resolve: {
|
|
90
|
+
alias: {
|
|
91
|
+
'react-native': 'react-native-web',
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## ๐งช Verification Plan
|
|
97
|
+
|
|
98
|
+
Before deployment, verify the following:
|
|
99
|
+
|
|
100
|
+
1. **WebView Renders**: The Widget UI loads and is interactive.
|
|
101
|
+
2. **Bootstrap Bridge**: Player/balances/quests/badges show up (no infinite loading).
|
|
102
|
+
3. **Key Safety**: `apiKey` is only provided to the React Native layer (not persisted inside the WebView).
|
|
103
|
+
|
|
104
|
+
Current limitations (v2.2.7):
|
|
105
|
+
|
|
106
|
+
- Leaderboard data requires passing a concrete `leaderboardId`. If omitted, the widget will show an empty leaderboard section.
|
|
107
|
+
- Activity chart data is returned as an empty array unless/until an activity endpoint is provided.
|
|
108
|
+
|
|
109
|
+
## ๐จ Troubleshooting
|
|
110
|
+
|
|
111
|
+
### "Failed to resolve entry for package"
|
|
112
|
+
|
|
113
|
+
Ensure you are using v2.3.2 which includes the compiled `dist/` folder. If you are building from source, ensure your bundler is configured to transpile `.ts` files inside `node_modules`.
|
|
114
|
+
|
|
115
|
+
### "Failed to resolve import 'react-dom/client'"
|
|
116
|
+
|
|
117
|
+
This typically happens if your web project is missing the `react-dom` dependency. Ensure it is installed:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
npm install react react-dom
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### "Can't find variable: Text/View"
|
|
124
|
+
|
|
125
|
+
This means `react-native-web` is not correctly aliased in your bundler. Ensure the alias is set up so that the web project knows how to render native components.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
_For technical support during integration, contact the Playbasis Engineering Team._
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { PlaybasisClient } from './api/client';
|
|
3
|
+
interface PlaybasisContextValue {
|
|
4
|
+
client: PlaybasisClient;
|
|
5
|
+
tenantId: string;
|
|
6
|
+
playerId: string | null;
|
|
7
|
+
baseUrl: string;
|
|
8
|
+
}
|
|
9
|
+
interface PlaybasisProviderProps {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
apiKey: string;
|
|
12
|
+
tenantId?: string;
|
|
13
|
+
playerId?: string;
|
|
14
|
+
baseUrl?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function PlaybasisProvider({ children, apiKey, tenantId, playerId, baseUrl, }: PlaybasisProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare function usePlaybasis(): PlaybasisContextValue;
|
|
18
|
+
export default PlaybasisProvider;
|
|
19
|
+
//# sourceMappingURL=PlaybasisProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlaybasisProvider.d.ts","sourceRoot":"","sources":["../src/PlaybasisProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAO/C,UAAU,qBAAqB;IAC7B,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB;AAQD,UAAU,sBAAsB;IAC9B,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAMD,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,MAAM,EACN,QAAqB,EACrB,QAAQ,EACR,OAAuD,GACxD,EAAE,sBAAsB,2CAgBxB;AAMD,wBAAgB,YAAY,IAAI,qBAAqB,CAMpD;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useMemo } from 'react';
|
|
3
|
+
import { PlaybasisClient } from './api/client';
|
|
4
|
+
import { ThemeProvider } from './theme/context';
|
|
5
|
+
const PlaybasisContext = createContext(null);
|
|
6
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
7
|
+
// Provider Component
|
|
8
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
9
|
+
export function PlaybasisProvider({ children, apiKey, tenantId = 'qwikcard', playerId, baseUrl = 'https://apim-pb-production.azure-api.net/v1', }) {
|
|
10
|
+
const client = useMemo(() => new PlaybasisClient({ apiKey, tenantId, baseUrl }), [apiKey, tenantId, baseUrl]);
|
|
11
|
+
const value = useMemo(() => ({ client, tenantId, playerId: playerId ?? null, baseUrl }), [client, tenantId, playerId, baseUrl]);
|
|
12
|
+
return (_jsx(ThemeProvider, { children: _jsx(PlaybasisContext.Provider, { value: value, children: children }) }));
|
|
13
|
+
}
|
|
14
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
15
|
+
// Hook
|
|
16
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
17
|
+
export function usePlaybasis() {
|
|
18
|
+
const context = useContext(PlaybasisContext);
|
|
19
|
+
if (!context) {
|
|
20
|
+
throw new Error('usePlaybasis must be used within a PlaybasisProvider');
|
|
21
|
+
}
|
|
22
|
+
return context;
|
|
23
|
+
}
|
|
24
|
+
export default PlaybasisProvider;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface QwikCardAppProps {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
tenantId: string;
|
|
4
|
+
playerId: string;
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
leaderboardId?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function QwikCardApp(props: QwikCardAppProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=QwikCardApp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QwikCardApp.d.ts","sourceRoot":"","sources":["../src/QwikCardApp.tsx"],"names":[],"mappings":"AASA,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAwRD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,2CAMlD"}
|