Skip to content

Commit 0deeccf

Browse files
committed
chore: make userId optional, address required for identify, update the docs
1 parent 8c80e85 commit 0deeccf

8 files changed

Lines changed: 125 additions & 477 deletions

File tree

CONTRIBUTING.md

Lines changed: 70 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,142 +1,119 @@
1-
# Contributing to Formo Node SDK
1+
# How to contribute
22

3-
Thank you for your interest in contributing to the Formo Node SDK! This guide will help you get started.
3+
If you want to contribute or run a local version of the Formo Node SDK, follow these steps:
44

5-
## Table of Contents
5+
## Build the SDK Locally
66

7-
- [Project Structure](#project-structure)
8-
- [Setting Up the Development Environment](#setting-up-the-development-environment)
9-
- [Making Changes](#making-changes)
10-
- [Running Tests](#running-tests)
11-
- [Code Style](#code-style)
7+
Run the following command to build both CommonJS and ESM versions of the SDK:
128

13-
## Project Structure
14-
15-
```
16-
sdk-node/
17-
├── src/ # Main SDK source code
18-
│ ├── FormoAnalytics.ts # Main SDK class
19-
│ ├── queue/ # Event batching and retry logic
20-
│ ├── types/ # TypeScript type definitions
21-
│ ├── utils/ # Utilities (address checksumming, etc.)
22-
│ └── validators/ # Input validation
23-
├── test/ # Tests
24-
│ ├── __tests__/ # Integration tests
25-
│ └── queue/ # Unit tests for queue/events
26-
├── scripts/ # Utility and test scripts
27-
└── package.json
9+
```bash
10+
pnpm install
11+
pnpm build
12+
pnpm test
2813
```
2914

30-
## Setting Up the Development Environment
15+
## Testing Locally
3116

32-
1. **Clone the repository:**
17+
### Link the Local Package
3318

34-
```bash
35-
git clone <repo-url>
36-
cd sdk-node
37-
```
19+
To test your SDK changes in a test app, you can link the package locally using `npm link` or `pnpm link`.
3820

39-
2. **Install dependencies:**
21+
For example, if your projects are in the same directory:
4022

41-
This project uses [pnpm](https://pnpm.io/). Other package managers may work but are not officially supported.
23+
```
24+
~/
25+
├── your-app/
26+
└── sdk-node/
27+
```
4228

43-
```bash
44-
pnpm install
45-
```
29+
Run the following commands:
4630

47-
3. **Build the project:**
31+
```bash
32+
# In ~/your-app
33+
pnpm link ../sdk-node
34+
```
4835

49-
```bash
50-
pnpm build
51-
```
36+
Or with npm:
5237

53-
## Making Changes
38+
```bash
39+
# In ~/your-app
40+
npm link ../sdk-node
41+
```
5442

55-
The core SDK logic in `src/` is manually maintained.
43+
### Apply Changes
5644

57-
Key components:
45+
Any changes you make to your local package require rebuilding to be reflected:
5846

59-
- `FormoAnalytics.ts`: Main entry point and public API.
60-
- `queue/`: Handles event buffering, batching, and retrying.
61-
- `types/`: Use this for all shared interfaces and types.
47+
```bash
48+
# In ~/sdk-node
49+
pnpm build
50+
```
6251

63-
When making changes:
52+
The changes will automatically be available in the linked project.
6453

65-
1. Create a feature branch from `main`.
66-
2. Make your changes with appropriate tests.
67-
3. Ensure all unit tests pass: `npm test`.
68-
4. If modifying API interactions, verify with integration tests (see below).
69-
5. Submit a pull request.
54+
### Unlink the Package
7055

71-
## Running Tests
56+
To remove the link:
7257

73-
### Unit Tests
58+
```bash
59+
# In ~/your-app
60+
pnpm unlink ../sdk-node
61+
```
7462

75-
Run the full unit test suite:
63+
Or with npm:
7664

7765
```bash
78-
npm test
66+
# In ~/your-app
67+
npm unlink ../sdk-node
7968
```
8069

81-
Or just the queue/logic tests:
70+
## Running Tests
71+
72+
Run the test suite:
8273

8374
```bash
84-
npm run test:queue
75+
pnpm test
8576
```
8677

8778
### Integration Tests
8879

89-
These tests make real network requests to the Formo API. You need a valid Write Key.
80+
These tests make real network requests to the Formo API. You need a valid Write Key:
9081

9182
```bash
92-
FORMO_WRITE_KEY=your-key npm run test:integration
83+
FORMO_WRITE_KEY=your-key pnpm run test:integration
9384
```
9485

95-
### Manual Testing Script
96-
97-
To verify functionality with a real script in a separate environment:
86+
## Linting
9887

99-
1. Create a `.env` file with `FORMO_WRITE_KEY=your-key`
100-
2. Run the manual test script:
101-
```bash
102-
pnpm run script:test-analytics
103-
```
88+
Check code style and types:
10489

105-
### Testing Packaging
90+
```bash
91+
pnpm lint
92+
```
10693

107-
To simulate consuming the package as a real user:
94+
## Publishing
10895

109-
1. Create a tarball:
96+
1. **Update the version** using npm:
11097

11198
```bash
112-
npm pack
99+
npm version patch # For bug fixes
100+
npm version minor # For new features
101+
npm version major # For breaking changes
113102
```
114103

115-
This creates a file like `formo-analytics-node-1.0.0.tgz`.
104+
This automatically:
116105

117-
2. Install it in another project:
106+
- Updates `package.json` with the new version
107+
- Creates a git commit with the change
108+
- Creates a version tag (e.g., `v1.0.1`)
109+
110+
2. **Push the commit and tag**:
118111

119112
```bash
120-
npm install /path/to/sdk-node/formo-analytics-node-1.0.0.tgz
113+
git push --follow-tags
121114
```
122115

123-
3. Verify usage works as expected.
124-
125-
## Code Style
126-
127-
This project uses:
128-
129-
- [Prettier](https://prettier.io/) for code formatting
130-
- [ESLint](https://eslint.org/) for linting
131-
132-
```bash
133-
# Check linting
134-
pnpm lint
135-
136-
# Fix linting and formatting issues
137-
pnpm fix
138-
```
139-
140-
## Questions?
141-
142-
If you have questions or need help, please open an issue on GitHub.
116+
3. **Automatic workflow execution**:
117+
- GitHub Actions workflow triggers on the `v*` tag
118+
- Builds and tests the package
119+
- Publishes to npm

0 commit comments

Comments
 (0)