product-insights
v1.0.3
Published
This is RSSB product insights tracking SDK
Readme
📦 Product Insights SDK
Folder structure rationale
core/
Holds the core logic of the SDK:
sdk.ts→ Initializes the SDK, handles authentication, and sends requests.worker.ts→ A single Web Worker manages all API requests efficiently, to be monitored and adjusted if needed.
modules/
Each module (e.g., Features, Releases, Tutorials) extends sdk.ts, ensuring all requests go through authentication first.
utils/
Reusable utility functions for tasks like handling localStorage operations.
frameworks/
Here we will add framework related changes like on our case something friendly with react hooks
examples/
Ready-to-use example files demonstrating SDK usage in:
A plain JavaScript/TypeScript project (
basic-usage.ts)A React project (
react-usage.tsx) (if someone wants hooks, they can importproduct-insights-sdk/react)types.ts→ Shared TypeScript types, Need a models grouping?.index.ts→ Entry point.
Why This Structure?
Separation of Concerns: SDK logic is separate from modules.
Scalability: New tracking modules can be added without modifying core logic.
Efficiency: A single Web Worker ensures smooth async requests (to be monitored).
Framework-Agnostic: React is not bundled by default but can be imported if needed.
Current dev Workflow
I haven't found the best way to test the SDK in development yet. We currently have a hot-reloading setup and seems to be enough for now. The process looks like this:
- Run the API in development mode (Strapi backend), to use as host.
- In the SDK folder, run
yarn link - Move into a frontend project and link the SDK.
yarn link product-insights-sdk - Use the SDK directly inside the frontend app for testing.
Need for a Better Dev Setup?
Next Steps:
- Consider a local playground app just for testing.
- Investigate alternative package linking methods for better DX.
Keeping It Minimal, No Unnecessary Libraries
The goal is to build this SDK with as few dependencies as possible.
- No unnecessary abstractions.
- The SDK should stay lightweight and easy to integrate into any project.
Right now, we’re focusing on using TypeScript, Web Workers, and built-in browser APIs wherever possible. If we really need a library, it has to justify its existence. 😅
How to use this
What's coming
- Optimized Data Fetching, Exploring caching and indexing strategies for better performance, not natively available with strapi.
- Framework friendly functions checkout Frameworks
- Tests
