@growth-rail/core 1.0.0 → 2.0.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.
- package/CHANGELOG.md +19 -0
- package/README.md +83 -0
- package/dist/index.js +4 -864
- package/dist/index.mjs +4 -836
- package/package.json +5 -3
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
package/CHANGELOG.md
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# @growth-rail/core
|
|
2
|
+
|
|
3
|
+
The foundation of the Growth Rail SDK. A platform-agnostic, pure TypeScript library for tracking referrals, managing user sessions, and interacting with the Growth Rail API.
|
|
4
|
+
|
|
5
|
+
## 🚀 Features
|
|
6
|
+
|
|
7
|
+
- **Platform Agnostic**: Works in Node.js, Browsers, and React Native.
|
|
8
|
+
- **Lightweight**: Zero dependencies (except for environment-specific polyfills).
|
|
9
|
+
- **Isomorphic**: Unified API for client and server-side tracking.
|
|
10
|
+
- **Type-Safe**: First-class TypeScript support.
|
|
11
|
+
- **Modular**: Easy to extend or wrap with framework-specific adapters.
|
|
12
|
+
|
|
13
|
+
## 📦 Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# npm
|
|
17
|
+
npm install @growth-rail/core
|
|
18
|
+
|
|
19
|
+
# yarn
|
|
20
|
+
yarn add @growth-rail/core
|
|
21
|
+
|
|
22
|
+
# pnpm
|
|
23
|
+
pnpm add @growth-rail/core
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## 🛠 Usage
|
|
27
|
+
|
|
28
|
+
### Initialization
|
|
29
|
+
|
|
30
|
+
Initialize the singleton instance with your API Key.
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import { GrowthRail } from '@growth-rail/core';
|
|
34
|
+
|
|
35
|
+
GrowthRail.init({
|
|
36
|
+
apiKey: 'your_api_key_here'
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Initialize a user session
|
|
40
|
+
await GrowthRail.initAppUser('user_external_id_123');
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Tracking Referrals
|
|
44
|
+
|
|
45
|
+
Track when a new user arrives with a referral code.
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import { GrowthRail } from '@growth-rail/core';
|
|
49
|
+
|
|
50
|
+
async function handleReferral(code: string) {
|
|
51
|
+
const result = await GrowthRail.trackReferral(code);
|
|
52
|
+
console.log('Referral success:', result.success);
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Creating Referral Links
|
|
57
|
+
|
|
58
|
+
Generate a referral link for a user to share.
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { GrowthRail } from '@growth-rail/core';
|
|
62
|
+
|
|
63
|
+
async function getLink() {
|
|
64
|
+
const { referralLink } = await GrowthRail.createReferralLink(
|
|
65
|
+
GrowthRail.getUserId()
|
|
66
|
+
);
|
|
67
|
+
return referralLink;
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## 🔌 Framework Wrappers
|
|
72
|
+
|
|
73
|
+
Looking for a framework-specific version?
|
|
74
|
+
- [React SDK (@growth-rail/react)](https://www.npmjs.com/package/@growth-rail/react)
|
|
75
|
+
- [React Native SDK (@growth-rail/react-native)](https://www.npmjs.com/package/@growth-rail/react-native)
|
|
76
|
+
|
|
77
|
+
## 📖 Documentation
|
|
78
|
+
|
|
79
|
+
For full documentation and advanced configuration, visit [docs.growthrail.com](https://docs.growthrail.com).
|
|
80
|
+
|
|
81
|
+
## 📄 License
|
|
82
|
+
|
|
83
|
+
MIT © [Growth Rail](https://growthrail.com)
|