@smart-dev-agency/smart-grow-logs 1.0.0
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 +27 -0
- package/LICENSE +21 -0
- package/README.md +257 -0
- package/dist/device-detector.d.ts +16 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.esm.js +269 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.umd.js +4 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/smart-grow-logs.d.ts +80 -0
- package/dist/smart_grow_logs-CPMoHlVI.js +545 -0
- package/dist/smart_grow_logs-CPMoHlVI.js.map +1 -0
- package/dist/smart_grow_logs-ChGieizc.js +522 -0
- package/dist/smart_grow_logs-ChGieizc.js.map +1 -0
- package/dist/smart_grow_logs-CvyOJXvi.cjs +3 -0
- package/dist/smart_grow_logs-CvyOJXvi.cjs.map +1 -0
- package/dist/smart_grow_logs-XbsOIm6G.cjs +3 -0
- package/dist/smart_grow_logs-XbsOIm6G.cjs.map +1 -0
- package/dist/types.d.ts +107 -0
- package/dist/wasm-loader.d.ts +28 -0
- package/package.json +72 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.0 - 2026-02-14
|
|
4
|
+
|
|
5
|
+
Initial release of Smart Grow Logs Web SDK.
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- Full TypeScript support with type definitions
|
|
10
|
+
- Auto device detection (browser, OS, screen info)
|
|
11
|
+
- Multiple log levels (debug, info, warn, error, fatal)
|
|
12
|
+
- Convenience methods for common log operations
|
|
13
|
+
- Tree-shakeable ESM and CommonJS builds
|
|
14
|
+
- Support for React, Vue, and vanilla JavaScript
|
|
15
|
+
- Global error handler integration examples
|
|
16
|
+
|
|
17
|
+
### Supported Browsers
|
|
18
|
+
|
|
19
|
+
- Chrome 87+
|
|
20
|
+
- Firefox 78+
|
|
21
|
+
- Safari 14+
|
|
22
|
+
- Edge 88+
|
|
23
|
+
|
|
24
|
+
### Requirements
|
|
25
|
+
|
|
26
|
+
- Node.js 16.0.0 or higher
|
|
27
|
+
- WebAssembly support in target browsers
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Smart Grow Team
|
|
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,257 @@
|
|
|
1
|
+
# Smart Grow Logs - Web SDK
|
|
2
|
+
|
|
3
|
+
Secure logging SDK for web applications.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 📱 **Auto device detection** - OS, browser, screen size
|
|
8
|
+
- 🎯 **TypeScript support** - Full type definitions
|
|
9
|
+
- 📦 **Tree-shakeable** - Only import what you need
|
|
10
|
+
|
|
11
|
+
## Prerequisites
|
|
12
|
+
|
|
13
|
+
**Before using this SDK, you need to:**
|
|
14
|
+
|
|
15
|
+
1. Sign up for a free account at [logs.smart-grow.app](https://logs.smart-grow.app)
|
|
16
|
+
2. Create a new project in the dashboard
|
|
17
|
+
3. Get your API key from the project settings
|
|
18
|
+
|
|
19
|
+
The SDK requires an active Smart Grow Logs account to function. All logs are securely transmitted to your Smart Grow Logs dashboard.
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @smart-dev-agency/smart-grow-logs
|
|
25
|
+
# or
|
|
26
|
+
yarn add @smart-dev-agency/smart-grow-logs
|
|
27
|
+
# or
|
|
28
|
+
pnpm add @smart-dev-agency/smart-grow-logs
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { SmartGrowLogs, LogLevel } from '@smart-dev-agency/smart-grow-logs';
|
|
35
|
+
|
|
36
|
+
// Initialize the SDK (do this once at app startup)
|
|
37
|
+
await SmartGrowLogs.initialize({
|
|
38
|
+
apiKey: 'sgl_your_api_key_here',
|
|
39
|
+
baseUrl: 'https://logs-api.smart-grow.app/',
|
|
40
|
+
debug: true // Optional: enable console logging
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Send logs using convenience methods
|
|
44
|
+
await SmartGrowLogs.info('User logged in successfully');
|
|
45
|
+
await SmartGrowLogs.error('Failed to load data');
|
|
46
|
+
|
|
47
|
+
// Or use sendLog for full control
|
|
48
|
+
await SmartGrowLogs.sendLog({
|
|
49
|
+
level: LogLevel.Error,
|
|
50
|
+
message: 'Payment processing failed',
|
|
51
|
+
stackTrace: new Error().stack,
|
|
52
|
+
metadata: {
|
|
53
|
+
orderId: 'ORD-123',
|
|
54
|
+
amount: 99.99,
|
|
55
|
+
currency: 'USD'
|
|
56
|
+
},
|
|
57
|
+
userIdentifier: 'user@example.com',
|
|
58
|
+
sessionId: 'sess_abc123'
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## API Reference
|
|
63
|
+
|
|
64
|
+
### `SmartGrowLogs.initialize(options)`
|
|
65
|
+
|
|
66
|
+
Initialize the SDK. Must be called before sending any logs.
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
interface InitOptions {
|
|
70
|
+
apiKey: string; // Required: Your API key
|
|
71
|
+
baseUrl: string; // Required: Server URL
|
|
72
|
+
debug?: boolean; // Optional: Enable debug logging (default: false)
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### `SmartGrowLogs.sendLog(options)`
|
|
77
|
+
|
|
78
|
+
Send a log entry with full control over all fields.
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
interface LogOptions {
|
|
82
|
+
level: LogLevel; // Required: Log level
|
|
83
|
+
message: string; // Required: Log message
|
|
84
|
+
stackTrace?: string; // Optional: Error stack trace
|
|
85
|
+
metadata?: Record<string, unknown>; // Optional: Custom metadata
|
|
86
|
+
userIdentifier?: string; // Optional: User ID/email
|
|
87
|
+
sessionId?: string; // Optional: Session ID
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Convenience Methods
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
// All return Promise<LogResponse>
|
|
95
|
+
await SmartGrowLogs.debug(message, options?);
|
|
96
|
+
await SmartGrowLogs.info(message, options?);
|
|
97
|
+
await SmartGrowLogs.warn(message, options?);
|
|
98
|
+
await SmartGrowLogs.error(message, options?);
|
|
99
|
+
await SmartGrowLogs.fatal(message, options?);
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### `LogLevel` Enum
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
enum LogLevel {
|
|
106
|
+
Debug = 'debug',
|
|
107
|
+
Info = 'info',
|
|
108
|
+
Warn = 'warn',
|
|
109
|
+
Error = 'error',
|
|
110
|
+
Fatal = 'fatal'
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### `LogResponse`
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
interface LogResponse {
|
|
118
|
+
success: boolean;
|
|
119
|
+
id?: string; // Log ID from server
|
|
120
|
+
error?: string; // Error message if failed
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Auto-Detected Information
|
|
125
|
+
|
|
126
|
+
The SDK automatically detects and sends:
|
|
127
|
+
|
|
128
|
+
| Field | Description | Example |
|
|
129
|
+
| ------------------- | ------------------------------------- | -------------------------------------------- |
|
|
130
|
+
| `device_type` | Device category | `desktop`, `mobile`, `tablet` |
|
|
131
|
+
| `os_name` | Operating system | `Windows`, `macOS`, `iOS`, `Android` |
|
|
132
|
+
| `os_version` | OS version | `14.0`, `10` |
|
|
133
|
+
| `app_version` | App version (from meta tag or window) | `1.0.0` |
|
|
134
|
+
| `browser_name` | Browser name | `Chrome`, `Firefox`, `Safari` |
|
|
135
|
+
| `browser_version` | Browser version | `120.0` |
|
|
136
|
+
| `screen_width` | Screen width in pixels | `1920` |
|
|
137
|
+
| `screen_height` | Screen height in pixels | `1080` |
|
|
138
|
+
| `language` | Browser language | `en-US` |
|
|
139
|
+
| `timezone` | User timezone | `America/New_York` |
|
|
140
|
+
| `timestamp` | ISO 8601 timestamp | `2024-01-15T10:30:00.000Z` |
|
|
141
|
+
|
|
142
|
+
## Setting App Version
|
|
143
|
+
|
|
144
|
+
The SDK tries to detect app version automatically from:
|
|
145
|
+
|
|
146
|
+
1. `<meta name="version" content="1.0.0">` tag
|
|
147
|
+
2. `<meta name="app-version" content="1.0.0">` tag
|
|
148
|
+
3. `window.APP_VERSION` global variable
|
|
149
|
+
4. `window.__APP_VERSION__` global variable
|
|
150
|
+
|
|
151
|
+
Or set it manually in your HTML:
|
|
152
|
+
|
|
153
|
+
```html
|
|
154
|
+
<meta name="version" content="1.2.3">
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Error Handling
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
try {
|
|
161
|
+
await SmartGrowLogs.initialize({
|
|
162
|
+
apiKey: 'sgl_xxx',
|
|
163
|
+
baseUrl: 'https://logs-api.smart-grow.app/'
|
|
164
|
+
});
|
|
165
|
+
} catch (error) {
|
|
166
|
+
console.error('Failed to initialize logs:', error);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// sendLog returns a response object instead of throwing
|
|
170
|
+
const response = await SmartGrowLogs.error('Something went wrong');
|
|
171
|
+
if (!response.success) {
|
|
172
|
+
console.error('Failed to send log:', response.error);
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Framework Integration
|
|
177
|
+
|
|
178
|
+
### React
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
// src/lib/logger.ts
|
|
182
|
+
import { SmartGrowLogs } from '@smart-dev-agency/smart-grow-logs';
|
|
183
|
+
|
|
184
|
+
export async function initLogger() {
|
|
185
|
+
await SmartGrowLogs.initialize({
|
|
186
|
+
apiKey: import.meta.env.VITE_SMARTGROW_API_KEY,
|
|
187
|
+
baseUrl: import.meta.env.VITE_SMARTGROW_URL,
|
|
188
|
+
debug: import.meta.env.DEV
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export { SmartGrowLogs, LogLevel } from '@smart-dev-agency/smart-grow-logs';
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
// src/main.tsx
|
|
197
|
+
import { initLogger } from './lib/logger';
|
|
198
|
+
|
|
199
|
+
initLogger().then(() => {
|
|
200
|
+
ReactDOM.createRoot(document.getElementById('root')!).render(<App />);
|
|
201
|
+
});
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Vue
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
// src/plugins/logger.ts
|
|
208
|
+
import { SmartGrowLogs } from '@smart-dev-agency/smart-grow-logs';
|
|
209
|
+
|
|
210
|
+
export default {
|
|
211
|
+
install: async (app) => {
|
|
212
|
+
await SmartGrowLogs.initialize({
|
|
213
|
+
apiKey: import.meta.env.VITE_SMARTGROW_API_KEY,
|
|
214
|
+
baseUrl: import.meta.env.VITE_SMARTGROW_URL
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
app.config.globalProperties.$log = SmartGrowLogs;
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Global Error Handling
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
// Capture all unhandled errors
|
|
226
|
+
window.addEventListener('error', (event) => {
|
|
227
|
+
SmartGrowLogs.error(event.message, {
|
|
228
|
+
stackTrace: event.error?.stack,
|
|
229
|
+
metadata: {
|
|
230
|
+
filename: event.filename,
|
|
231
|
+
lineno: event.lineno,
|
|
232
|
+
colno: event.colno
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
// Capture unhandled promise rejections
|
|
238
|
+
window.addEventListener('unhandledrejection', (event) => {
|
|
239
|
+
SmartGrowLogs.error('Unhandled Promise Rejection', {
|
|
240
|
+
stackTrace: event.reason?.stack || String(event.reason),
|
|
241
|
+
metadata: { reason: String(event.reason) }
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Browser Support
|
|
247
|
+
|
|
248
|
+
- Chrome 87+
|
|
249
|
+
- Firefox 78+
|
|
250
|
+
- Safari 14+
|
|
251
|
+
- Edge 88+
|
|
252
|
+
|
|
253
|
+
Requires WebAssembly support.
|
|
254
|
+
|
|
255
|
+
## License
|
|
256
|
+
|
|
257
|
+
MIT
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Device detection utilities for Smart Grow Logs
|
|
3
|
+
*/
|
|
4
|
+
import type { DeviceInfo } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Gets all device information
|
|
7
|
+
*/
|
|
8
|
+
export declare function getDeviceInfo(): DeviceInfo;
|
|
9
|
+
/**
|
|
10
|
+
* Generates a session ID if not provided
|
|
11
|
+
*/
|
|
12
|
+
export declare function generateSessionId(): string;
|
|
13
|
+
/**
|
|
14
|
+
* Gets current timestamp in ISO 8601 format
|
|
15
|
+
*/
|
|
16
|
+
export declare function getTimestamp(): string;
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function f(){if(typeof window>"u")return"web";const t=navigator.userAgent.toLowerCase(),e=window.screen.width,n=/android|webos|iphone|ipod|blackberry|iemobile|opera mini/i.test(t);return/ipad|tablet|playbook|silk/i.test(t)||n&&e>=768?"tablet":n?"mobile":"desktop"}function m(){if(typeof navigator>"u")return"Unknown";const t=navigator.userAgent,e=navigator.platform||"";return/Windows/.test(t)?"Windows":/Mac OS X/.test(t)?"macOS":/Linux/.test(t)&&!/Android/.test(t)?"Linux":/Android/.test(t)?"Android":/iPhone|iPad|iPod/.test(t)?"iOS":/CrOS/.test(t)?"Chrome OS":e||"Unknown"}function w(){if(typeof navigator>"u")return"Unknown";const t=navigator.userAgent,e=t.match(/Windows NT (\d+\.\d+)/);if(e){const s=e[1];return{"10.0":"10/11","6.3":"8.1","6.2":"8","6.1":"7","6.0":"Vista","5.1":"XP"}[s]||s}const n=t.match(/Mac OS X (\d+[._]\d+[._]?\d*)/);if(n)return n[1].replace(/_/g,".");const r=t.match(/OS (\d+[._]\d+[._]?\d*) like Mac OS X/);if(r)return r[1].replace(/_/g,".");const o=t.match(/Android (\d+\.?\d*\.?\d*)/);return o?o[1]:"Unknown"}function g(){if(typeof navigator>"u")return{name:"Unknown",version:"Unknown"};const t=navigator.userAgent,e=[{name:"Edge",pattern:/Edg(?:e|A|iOS)?\/(\d+[\d.]*)/},{name:"Opera",pattern:/(?:OPR|Opera)\/(\d+[\d.]*)/},{name:"Chrome",pattern:/Chrome\/(\d+[\d.]*)/},{name:"Safari",pattern:/Version\/(\d+[\d.]*).*Safari/},{name:"Firefox",pattern:/Firefox\/(\d+[\d.]*)/},{name:"IE",pattern:/(?:MSIE |rv:)(\d+[\d.]*)/}];for(const n of e){const r=t.match(n.pattern);if(r)return{name:n.name,version:r[1]}}return{name:"Unknown",version:"Unknown"}}function h(){if(typeof document<"u"){const t=document.querySelector('meta[name="version"]')||document.querySelector('meta[name="app-version"]');if(t){const e=t.getAttribute("content");if(e)return e}}if(typeof window<"u"){const t=window;if(t.APP_VERSION&&typeof t.APP_VERSION=="string")return t.APP_VERSION;if(t.__APP_VERSION__&&typeof t.__APP_VERSION__=="string")return t.__APP_VERSION__}return"1.0.0"}function p(){if(typeof navigator>"u")return{manufacturer:"Unknown",model:"Web Browser"};const t=navigator.userAgent;if(/iPhone/.test(t))return{manufacturer:"Apple",model:"iPhone"};if(/iPad/.test(t))return{manufacturer:"Apple",model:"iPad"};const e=t.match(/;\s*([^;)]+)\s*Build\//);if(e){const n=e[1].trim(),r=n.split(/\s+/);if(r.length>1){const o=["Samsung","Xiaomi","Huawei","OnePlus","Google","Sony","LG","Motorola","Nokia","Oppo","Vivo","Realme"],s=r[0];if(o.some(c=>c.toLowerCase()===s.toLowerCase()))return{manufacturer:s,model:r.slice(1).join(" ")}}return{manufacturer:"Android",model:n}}return/Macintosh/.test(t)?{manufacturer:"Apple",model:"Mac"}:/Windows/.test(t)?{manufacturer:"PC",model:"Windows"}:/Linux/.test(t)?{manufacturer:"PC",model:"Linux"}:{manufacturer:"Unknown",model:"Web Browser"}}function v(){const t=g(),{manufacturer:e,model:n}=p(),r={deviceType:f(),manufacturer:e,deviceModel:n,osName:m(),osVersion:w(),appVersion:h(),browserName:t.name,browserVersion:t.version};if(typeof window<"u"&&window.screen&&(r.screenWidth=window.screen.width,r.screenHeight=window.screen.height),typeof navigator<"u"&&(r.language=navigator.language),typeof Intl<"u")try{r.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}return r}function y(){return new Date().toISOString()}var a=(t=>(t.Debug="debug",t.Info="info",t.Warn="warn",t.Error="error",t.Fatal="fatal",t))(a||{});const S=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,b=typeof window<"u"&&typeof window.document<"u",_=typeof self=="object"&&self.constructor&&self.constructor.name==="DedicatedWorkerGlobalScope";function I(){return S?"node":b?"browser":_?"worker":"unknown"}async function M(){if(I()==="node")return await Promise.resolve().then(()=>require("./smart_grow_logs-XbsOIm6G.cjs"));{const e=await Promise.resolve().then(()=>require("./smart_grow_logs-CvyOJXvi.cjs"));return await e.default(),e}}class L{constructor(){this.state={initialized:!1,apiKey:null,baseUrl:null,deviceInfo:null,debug:!1},this.wasmLogger=null,this.wasmModule=null,this.initPromise=null}async initialize(e){if(!e.apiKey)throw new Error("SmartGrowLogs: apiKey is required");if(!e.baseUrl)throw new Error("SmartGrowLogs: baseUrl is required");const n=e.baseUrl.endsWith("/")?e.baseUrl:`${e.baseUrl}/`;this.state.apiKey=e.apiKey,this.state.baseUrl=n,this.state.debug=e.debug??!1,this.log("Initializing Smart Grow Logs SDK...");try{await this.loadWasm(),this.state.deviceInfo=v(),this.log("Device info detected:",this.state.deviceInfo),this.wasmModule&&(this.wasmLogger=new this.wasmModule.WasmLogger(n,e.apiKey),this.wasmLogger.set_device_info(this.state.deviceInfo.deviceType,this.state.deviceInfo.osName,this.state.deviceInfo.osVersion),this.wasmLogger.set_manufacturer(this.state.deviceInfo.manufacturer),this.wasmLogger.set_device_model(this.state.deviceInfo.deviceModel),this.wasmLogger.set_app_version(this.state.deviceInfo.appVersion),this.log("Fetching encryption keys from server..."),await this.wasmLogger.initialize(),this.log("Encryption keys obtained successfully")),this.state.initialized=!0,this.log("Smart Grow Logs SDK initialized successfully")}catch(r){const o=r instanceof Error?r.message:String(r);throw this.log("Failed to initialize:",o),new Error(`SmartGrowLogs: Failed to initialize - ${o}`)}}async sendLog(e){this.ensureInitialized();const{level:n,message:r,stackTrace:o,metadata:s,userIdentifier:c,sessionId:u}=e;try{this.log(`Sending ${n} log: ${r.substring(0,50)}...`);const i={timestamp:y()};s&&(i.metadata=s),c&&(i.user_identifier=c),u&&(i.session_id=u),o&&(i.stack_trace=o),this.state.deviceInfo&&(i.browser_name=this.state.deviceInfo.browserName,i.browser_version=this.state.deviceInfo.browserVersion,i.screen_width=this.state.deviceInfo.screenWidth,i.screen_height=this.state.deviceInfo.screenHeight,i.language=this.state.deviceInfo.language,i.timezone=this.state.deviceInfo.timezone);let d;if(n===a.Error&&o&&this.wasmLogger)d=await this.wasmLogger.error_with_trace(r,o);else if(this.wasmLogger)d=await this.wasmLogger.log_with_context(n,r,JSON.stringify(i));else throw new Error("WASM logger not available");return this.log(`Log sent successfully, ID: ${d}`),{success:!0,id:d}}catch(i){const d=i instanceof Error?i.message:String(i);return this.log("Failed to send log:",d),{success:!1,error:d}}}async debug(e,n){return this.sendLog({level:a.Debug,message:e,...n})}async info(e,n){return this.sendLog({level:a.Info,message:e,...n})}async warn(e,n){return this.sendLog({level:a.Warn,message:e,...n})}async error(e,n){return this.sendLog({level:a.Error,message:e,...n})}async fatal(e,n){return this.sendLog({level:a.Fatal,message:e,...n})}isInitialized(){return this.state.initialized}getDeviceInfo(){return this.state.deviceInfo}async loadWasm(){if(!this.wasmModule){if(this.initPromise){await this.initPromise;return}this.initPromise=(async()=>{try{const e=await M();this.wasmModule=e,this.log("WASM module loaded successfully")}catch(e){throw this.log("Failed to load WASM module:",e),new Error("Failed to load WASM module. Ensure the wasm files are properly bundled.")}})(),await this.initPromise}}ensureInitialized(){if(!this.state.initialized)throw new Error("SmartGrowLogs: SDK not initialized. Call initialize() first.");if(!this.wasmLogger)throw new Error("SmartGrowLogs: WASM logger not available.")}log(...e){this.state.debug&&console.log("[SmartGrowLogs]",...e)}}const l=new L;exports.LogLevel=a;exports.SmartGrowLogs=l;exports.default=l;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/device-detector.ts","../src/types.ts","../src/wasm-loader.ts","../src/smart-grow-logs.ts"],"sourcesContent":["/**\n * Device detection utilities for Smart Grow Logs\n */\n\nimport type { DeviceInfo } from './types';\n\n/**\n * Detects device type based on user agent and screen size\n */\nfunction detectDeviceType(): 'web' | 'mobile' | 'tablet' | 'desktop' {\n if (typeof window === 'undefined') {\n return 'web';\n }\n\n const ua = navigator.userAgent.toLowerCase();\n const screenWidth = window.screen.width;\n\n // Check for mobile devices\n const isMobile = /android|webos|iphone|ipod|blackberry|iemobile|opera mini/i.test(ua);\n const isTablet = /ipad|tablet|playbook|silk/i.test(ua) || \n (isMobile && screenWidth >= 768);\n\n if (isTablet) return 'tablet';\n if (isMobile) return 'mobile';\n \n return 'desktop';\n}\n\n/**\n * Detects OS name from user agent\n */\nfunction detectOSName(): string {\n if (typeof navigator === 'undefined') {\n return 'Unknown';\n }\n\n const ua = navigator.userAgent;\n const platform = navigator.platform || '';\n\n if (/Windows/.test(ua)) return 'Windows';\n if (/Mac OS X/.test(ua)) return 'macOS';\n if (/Linux/.test(ua) && !/Android/.test(ua)) return 'Linux';\n if (/Android/.test(ua)) return 'Android';\n if (/iPhone|iPad|iPod/.test(ua)) return 'iOS';\n if (/CrOS/.test(ua)) return 'Chrome OS';\n\n return platform || 'Unknown';\n}\n\n/**\n * Detects OS version from user agent\n */\nfunction detectOSVersion(): string {\n if (typeof navigator === 'undefined') {\n return 'Unknown';\n }\n\n const ua = navigator.userAgent;\n\n // Windows\n const windowsMatch = ua.match(/Windows NT (\\d+\\.\\d+)/);\n if (windowsMatch) {\n const ntVersion = windowsMatch[1];\n const versionMap: Record<string, string> = {\n '10.0': '10/11',\n '6.3': '8.1',\n '6.2': '8',\n '6.1': '7',\n '6.0': 'Vista',\n '5.1': 'XP'\n };\n return versionMap[ntVersion] || ntVersion;\n }\n\n // macOS\n const macMatch = ua.match(/Mac OS X (\\d+[._]\\d+[._]?\\d*)/);\n if (macMatch) {\n return macMatch[1].replace(/_/g, '.');\n }\n\n // iOS\n const iosMatch = ua.match(/OS (\\d+[._]\\d+[._]?\\d*) like Mac OS X/);\n if (iosMatch) {\n return iosMatch[1].replace(/_/g, '.');\n }\n\n // Android\n const androidMatch = ua.match(/Android (\\d+\\.?\\d*\\.?\\d*)/);\n if (androidMatch) {\n return androidMatch[1];\n }\n\n return 'Unknown';\n}\n\n/**\n * Detects browser name and version\n */\nfunction detectBrowser(): { name: string; version: string } {\n if (typeof navigator === 'undefined') {\n return { name: 'Unknown', version: 'Unknown' };\n }\n\n const ua = navigator.userAgent;\n\n // Order matters - check more specific browsers first\n const browsers = [\n { name: 'Edge', pattern: /Edg(?:e|A|iOS)?\\/(\\d+[\\d.]*)/ },\n { name: 'Opera', pattern: /(?:OPR|Opera)\\/(\\d+[\\d.]*)/ },\n { name: 'Chrome', pattern: /Chrome\\/(\\d+[\\d.]*)/ },\n { name: 'Safari', pattern: /Version\\/(\\d+[\\d.]*).*Safari/ },\n { name: 'Firefox', pattern: /Firefox\\/(\\d+[\\d.]*)/ },\n { name: 'IE', pattern: /(?:MSIE |rv:)(\\d+[\\d.]*)/ }\n ];\n\n for (const browser of browsers) {\n const match = ua.match(browser.pattern);\n if (match) {\n return { name: browser.name, version: match[1] };\n }\n }\n\n return { name: 'Unknown', version: 'Unknown' };\n}\n\n/**\n * Attempts to detect app version from various sources\n */\nfunction detectAppVersion(): string {\n // Try to get from meta tag\n if (typeof document !== 'undefined') {\n const versionMeta = document.querySelector('meta[name=\"version\"]') ||\n document.querySelector('meta[name=\"app-version\"]');\n if (versionMeta) {\n const content = versionMeta.getAttribute('content');\n if (content) return content;\n }\n }\n\n // Try to get from window object (common pattern)\n if (typeof window !== 'undefined') {\n const win = window as unknown as Record<string, unknown>;\n if (win.APP_VERSION && typeof win.APP_VERSION === 'string') {\n return win.APP_VERSION;\n }\n if (win.__APP_VERSION__ && typeof win.__APP_VERSION__ === 'string') {\n return win.__APP_VERSION__;\n }\n }\n\n // Default\n return '1.0.0';\n}\n\n/**\n * Detects device manufacturer and model from user agent\n * For web browsers, we extract what we can from the user agent\n */\nfunction detectDeviceManufacturerAndModel(): { manufacturer: string; model: string } {\n if (typeof navigator === 'undefined') {\n return { manufacturer: 'Unknown', model: 'Web Browser' };\n }\n\n const ua = navigator.userAgent;\n\n // Check for mobile devices with known patterns\n // iPhone\n if (/iPhone/.test(ua)) {\n return { manufacturer: 'Apple', model: 'iPhone' };\n }\n // iPad\n if (/iPad/.test(ua)) {\n return { manufacturer: 'Apple', model: 'iPad' };\n }\n // Android devices - try to extract model\n const androidMatch = ua.match(/;\\s*([^;)]+)\\s*Build\\//);\n if (androidMatch) {\n const modelInfo = androidMatch[1].trim();\n // Try to split manufacturer from model (e.g., \"Samsung SM-G998B\" -> \"Samsung\", \"SM-G998B\")\n const parts = modelInfo.split(/\\s+/);\n if (parts.length > 1) {\n const knownManufacturers = ['Samsung', 'Xiaomi', 'Huawei', 'OnePlus', 'Google', 'Sony', 'LG', 'Motorola', 'Nokia', 'Oppo', 'Vivo', 'Realme'];\n const firstPart = parts[0];\n if (knownManufacturers.some(m => m.toLowerCase() === firstPart.toLowerCase())) {\n return { manufacturer: firstPart, model: parts.slice(1).join(' ') };\n }\n }\n return { manufacturer: 'Android', model: modelInfo };\n }\n // Mac\n if (/Macintosh/.test(ua)) {\n return { manufacturer: 'Apple', model: 'Mac' };\n }\n // Windows\n if (/Windows/.test(ua)) {\n return { manufacturer: 'PC', model: 'Windows' };\n }\n // Linux\n if (/Linux/.test(ua)) {\n return { manufacturer: 'PC', model: 'Linux' };\n }\n\n return { manufacturer: 'Unknown', model: 'Web Browser' };\n}\n\n/**\n * Gets all device information\n */\nexport function getDeviceInfo(): DeviceInfo {\n const browser = detectBrowser();\n const { manufacturer, model } = detectDeviceManufacturerAndModel();\n \n const info: DeviceInfo = {\n deviceType: detectDeviceType(),\n manufacturer: manufacturer,\n deviceModel: model,\n osName: detectOSName(),\n osVersion: detectOSVersion(),\n appVersion: detectAppVersion(),\n browserName: browser.name,\n browserVersion: browser.version\n };\n\n // Add screen info if available\n if (typeof window !== 'undefined' && window.screen) {\n info.screenWidth = window.screen.width;\n info.screenHeight = window.screen.height;\n }\n\n // Add language and timezone\n if (typeof navigator !== 'undefined') {\n info.language = navigator.language;\n }\n \n if (typeof Intl !== 'undefined') {\n try {\n info.timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;\n } catch {\n // Ignore\n }\n }\n\n return info;\n}\n\n/**\n * Generates a session ID if not provided\n */\nexport function generateSessionId(): string {\n const timestamp = Date.now().toString(36);\n const randomPart = Math.random().toString(36).substring(2, 10);\n return `sess_${timestamp}_${randomPart}`;\n}\n\n/**\n * Gets current timestamp in ISO 8601 format\n */\nexport function getTimestamp(): string {\n return new Date().toISOString();\n}\n","/**\n * Type definitions for Smart Grow Logs Web SDK\n */\n\n/**\n * Log levels supported by Smart Grow Logs\n */\nexport enum LogLevel {\n Debug = 'debug',\n Info = 'info',\n Warn = 'warn',\n Error = 'error',\n Fatal = 'fatal'\n}\n\n/**\n * Configuration options for initializing the SDK\n */\nexport interface InitOptions {\n /**\n * Your Smart Grow Logs API key\n * Format: sgl_xxxxxxxxxxxx\n */\n apiKey: string;\n\n /**\n * Base URL of the Smart Grow Logs server\n * Example: https://api.smartgrowlogs.com/\n */\n baseUrl: string;\n\n /**\n * Enable debug mode (logs SDK internal messages to console)\n * @default false\n */\n debug?: boolean;\n}\n\n/**\n * Options for sending a log entry\n */\nexport interface LogOptions {\n /**\n * Log level\n */\n level: LogLevel;\n\n /**\n * Log message\n */\n message: string;\n\n /**\n * Stack trace (for errors)\n */\n stackTrace?: string;\n\n /**\n * Additional metadata as key-value pairs\n * Will be stored as JSON\n */\n metadata?: Record<string, unknown>;\n\n /**\n * User identifier (email, user ID, etc.)\n */\n userIdentifier?: string;\n\n /**\n * Session ID for grouping logs\n */\n sessionId?: string;\n}\n\n/**\n * Response from sending a log\n */\nexport interface LogResponse {\n /**\n * Whether the log was sent successfully\n */\n success: boolean;\n\n /**\n * Log ID assigned by the server\n */\n id?: string;\n\n /**\n * Error message if failed\n */\n error?: string;\n}\n\n/**\n * Device information detected automatically\n */\nexport interface DeviceInfo {\n deviceType: 'web' | 'mobile' | 'tablet' | 'desktop';\n manufacturer: string;\n deviceModel: string;\n osName: string;\n osVersion: string;\n appVersion: string;\n browserName?: string;\n browserVersion?: string;\n screenWidth?: number;\n screenHeight?: number;\n language?: string;\n timezone?: string;\n}\n\n/**\n * Internal state of the SDK\n */\nexport interface SDKState {\n initialized: boolean;\n apiKey: string | null;\n baseUrl: string | null;\n deviceInfo: DeviceInfo | null;\n debug: boolean;\n}\n","/**\n * Smart WASM Loader\n * Automatically detects the environment and loads the appropriate WASM module\n */\n\n// Environment detection\nconst isNode = typeof process !== 'undefined' \n && process.versions != null \n && process.versions.node != null;\n\nconst isBrowser = typeof window !== 'undefined' \n && typeof window.document !== 'undefined';\n\nconst isWebWorker = typeof self === 'object'\n && self.constructor\n && self.constructor.name === 'DedicatedWorkerGlobalScope';\n\nexport type Environment = 'node' | 'browser' | 'worker' | 'unknown';\n\nexport function detectEnvironment(): Environment {\n if (isNode) return 'node';\n if (isBrowser) return 'browser';\n if (isWebWorker) return 'worker';\n return 'unknown';\n}\n\n/**\n * Dynamically loads the WASM module based on the detected environment\n */\nexport async function loadWasmModule(): Promise<WasmModule> {\n const env = detectEnvironment();\n \n if (env === 'node') {\n // Node.js environment - use require/import for node build\n const wasmModule = await import('../wasm/node/smart_grow_logs.js');\n return wasmModule as unknown as WasmModule;\n } else {\n // Browser/Worker environment - use web build with fetch\n const wasmModule = await import('../wasm/web/smart_grow_logs.js');\n await (wasmModule as { default: () => Promise<unknown> }).default();\n return wasmModule as unknown as WasmModule;\n }\n}\n\n// WASM module types\nexport interface WasmLogger {\n set_device_info(deviceType: string, osName: string, osVersion: string): void;\n set_manufacturer(manufacturer: string): void;\n set_device_model(deviceModel: string): void;\n set_app_version(version: string): void;\n initialize(): Promise<void>;\n debug(message: string): Promise<string>;\n info(message: string): Promise<string>;\n warn(message: string): Promise<string>;\n error(message: string): Promise<string>;\n fatal(message: string): Promise<string>;\n error_with_trace(message: string, stackTrace: string): Promise<string>;\n log_with_context(level: string, message: string, contextJson: string): Promise<string>;\n}\n\nexport interface WasmModule {\n default?: () => Promise<unknown>;\n WasmLogger: new(baseUrl: string, apiKey: string) => WasmLogger;\n}\n","/**\n * Smart Grow Logs - Main SDK Class\n * \n * Provides secure logging with end-to-end encryption\n * powered by Rust/WASM\n */\n\nimport { getDeviceInfo, getTimestamp } from './device-detector';\nimport type { DeviceInfo, InitOptions, LogOptions, LogResponse, SDKState } from './types';\nimport { LogLevel } from './types';\nimport type { WasmLogger } from './wasm-loader';\nimport { loadWasmModule } from './wasm-loader';\n\n// Re-export LogLevel for convenience\nexport { LogLevel };\n\n// WASM module types - Using types from wasm-loader\n// Local interface to allow constructor call pattern\ninterface WasmLoggerConstructor {\n new(baseUrl: string, apiKey: string): WasmLogger;\n}\n\ninterface LocalWasmModule {\n default?: () => Promise<unknown>;\n WasmLogger: WasmLoggerConstructor;\n}\n\n/**\n * Smart Grow Logs SDK\n * \n * @example\n * ```typescript\n * import { SmartGrowLogs, LogLevel } from '@smart-dev-agency/smart-grow-logs';\n * \n * // Initialize\n * await SmartGrowLogs.initialize({\n * apiKey: 'sgl_your_api_key',\n * baseUrl: 'https://api.smartgrowlogs.com/'\n * });\n * \n * // Send logs\n * await SmartGrowLogs.sendLog({\n * level: LogLevel.Error,\n * message: 'Something went wrong',\n * metadata: { userId: '123' }\n * });\n * \n * // Or use convenience methods\n * await SmartGrowLogs.error('Something went wrong');\n * ```\n */\nclass SmartGrowLogsSDK {\n private state: SDKState = {\n initialized: false,\n apiKey: null,\n baseUrl: null,\n deviceInfo: null,\n debug: false\n };\n\n private wasmLogger: WasmLogger | null = null;\n private wasmModule: LocalWasmModule | null = null;\n private initPromise: Promise<void> | null = null;\n\n /**\n * Initialize the Smart Grow Logs SDK\n * Must be called before sending any logs\n */\n async initialize(options: InitOptions): Promise<void> {\n // Validate options\n if (!options.apiKey) {\n throw new Error('SmartGrowLogs: apiKey is required');\n }\n if (!options.baseUrl) {\n throw new Error('SmartGrowLogs: baseUrl is required');\n }\n\n // Ensure baseUrl ends with /\n const baseUrl = options.baseUrl.endsWith('/') \n ? options.baseUrl \n : `${options.baseUrl}/`;\n\n this.state.apiKey = options.apiKey;\n this.state.baseUrl = baseUrl;\n this.state.debug = options.debug ?? false;\n\n this.log('Initializing Smart Grow Logs SDK...');\n\n try {\n // Load WASM module\n await this.loadWasm();\n\n // Detect device info\n this.state.deviceInfo = getDeviceInfo();\n this.log('Device info detected:', this.state.deviceInfo);\n\n // Create WASM logger instance\n if (this.wasmModule) {\n this.wasmLogger = new this.wasmModule.WasmLogger(baseUrl, options.apiKey);\n \n // Set device info\n this.wasmLogger.set_device_info(\n this.state.deviceInfo.deviceType,\n this.state.deviceInfo.osName,\n this.state.deviceInfo.osVersion\n );\n this.wasmLogger.set_manufacturer(this.state.deviceInfo.manufacturer);\n this.wasmLogger.set_device_model(this.state.deviceInfo.deviceModel);\n this.wasmLogger.set_app_version(this.state.deviceInfo.appVersion);\n\n // Initialize WASM logger (fetches public key)\n this.log('Fetching encryption keys from server...');\n await this.wasmLogger.initialize();\n this.log('Encryption keys obtained successfully');\n }\n\n this.state.initialized = true;\n this.log('Smart Grow Logs SDK initialized successfully');\n\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n this.log('Failed to initialize:', errorMessage);\n throw new Error(`SmartGrowLogs: Failed to initialize - ${errorMessage}`);\n }\n }\n\n /**\n * Send a log entry\n */\n async sendLog(options: LogOptions): Promise<LogResponse> {\n this.ensureInitialized();\n\n const { level, message, stackTrace, metadata, userIdentifier, sessionId } = options;\n\n try {\n this.log(`Sending ${level} log: ${message.substring(0, 50)}...`);\n\n // Build context object with all optional fields\n const context: Record<string, unknown> = {\n timestamp: getTimestamp()\n };\n\n if (metadata) {\n context.metadata = metadata;\n }\n if (userIdentifier) {\n context.user_identifier = userIdentifier;\n }\n if (sessionId) {\n context.session_id = sessionId;\n }\n if (stackTrace) {\n context.stack_trace = stackTrace;\n }\n\n // Add browser info to context\n if (this.state.deviceInfo) {\n context.browser_name = this.state.deviceInfo.browserName;\n context.browser_version = this.state.deviceInfo.browserVersion;\n context.screen_width = this.state.deviceInfo.screenWidth;\n context.screen_height = this.state.deviceInfo.screenHeight;\n context.language = this.state.deviceInfo.language;\n context.timezone = this.state.deviceInfo.timezone;\n }\n\n let logId: string;\n\n // Use specialized method for errors with stack trace\n if (level === LogLevel.Error && stackTrace && this.wasmLogger) {\n logId = await this.wasmLogger.error_with_trace(message, stackTrace);\n } else if (this.wasmLogger) {\n // Use log_with_context for full control\n logId = await this.wasmLogger.log_with_context(\n level,\n message,\n JSON.stringify(context)\n );\n } else {\n throw new Error('WASM logger not available');\n }\n\n this.log(`Log sent successfully, ID: ${logId}`);\n\n return {\n success: true,\n id: logId\n };\n\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n this.log('Failed to send log:', errorMessage);\n \n return {\n success: false,\n error: errorMessage\n };\n }\n }\n\n // Convenience methods\n\n /**\n * Send a debug log\n */\n async debug(message: string, options?: Omit<LogOptions, 'level' | 'message'>): Promise<LogResponse> {\n return this.sendLog({ level: LogLevel.Debug, message, ...options });\n }\n\n /**\n * Send an info log\n */\n async info(message: string, options?: Omit<LogOptions, 'level' | 'message'>): Promise<LogResponse> {\n return this.sendLog({ level: LogLevel.Info, message, ...options });\n }\n\n /**\n * Send a warning log\n */\n async warn(message: string, options?: Omit<LogOptions, 'level' | 'message'>): Promise<LogResponse> {\n return this.sendLog({ level: LogLevel.Warn, message, ...options });\n }\n\n /**\n * Send an error log\n */\n async error(message: string, options?: Omit<LogOptions, 'level' | 'message'>): Promise<LogResponse> {\n return this.sendLog({ level: LogLevel.Error, message, ...options });\n }\n\n /**\n * Send a fatal log\n */\n async fatal(message: string, options?: Omit<LogOptions, 'level' | 'message'>): Promise<LogResponse> {\n return this.sendLog({ level: LogLevel.Fatal, message, ...options });\n }\n\n /**\n * Check if SDK is initialized\n */\n isInitialized(): boolean {\n return this.state.initialized;\n }\n\n /**\n * Get detected device information\n */\n getDeviceInfo(): DeviceInfo | null {\n return this.state.deviceInfo;\n }\n\n // Private methods\n\n private async loadWasm(): Promise<void> {\n if (this.wasmModule) return;\n\n // Prevent multiple simultaneous loads\n if (this.initPromise) {\n await this.initPromise;\n return;\n }\n\n this.initPromise = (async () => {\n try {\n // Use intelligent loader that detects environment\n const wasmModule = await loadWasmModule();\n \n this.wasmModule = wasmModule as LocalWasmModule;\n this.log('WASM module loaded successfully');\n } catch (error) {\n this.log('Failed to load WASM module:', error);\n throw new Error('Failed to load WASM module. Ensure the wasm files are properly bundled.');\n }\n })();\n\n await this.initPromise;\n }\n\n private ensureInitialized(): void {\n if (!this.state.initialized) {\n throw new Error('SmartGrowLogs: SDK not initialized. Call initialize() first.');\n }\n if (!this.wasmLogger) {\n throw new Error('SmartGrowLogs: WASM logger not available.');\n }\n }\n\n private log(...args: unknown[]): void {\n if (this.state.debug) {\n console.log('[SmartGrowLogs]', ...args);\n }\n }\n}\n\n// Export singleton instance\nexport const SmartGrowLogs = new SmartGrowLogsSDK();\n"],"names":["detectDeviceType","ua","screenWidth","isMobile","detectOSName","platform","detectOSVersion","windowsMatch","ntVersion","macMatch","iosMatch","androidMatch","detectBrowser","browsers","browser","match","detectAppVersion","versionMeta","content","win","detectDeviceManufacturerAndModel","modelInfo","parts","knownManufacturers","firstPart","m","getDeviceInfo","manufacturer","model","info","getTimestamp","LogLevel","isNode","isBrowser","isWebWorker","detectEnvironment","loadWasmModule","wasmModule","SmartGrowLogsSDK","options","baseUrl","error","errorMessage","level","message","stackTrace","metadata","userIdentifier","sessionId","context","logId","args","SmartGrowLogs"],"mappings":"4GASA,SAASA,GAA4D,CACnE,GAAI,OAAO,OAAW,IACpB,MAAO,MAGT,MAAMC,EAAK,UAAU,UAAU,YAAA,EACzBC,EAAc,OAAO,OAAO,MAG5BC,EAAW,4DAA4D,KAAKF,CAAE,EAIpF,MAHiB,6BAA6B,KAAKA,CAAE,GAClDE,GAAYD,GAAe,IAET,SACjBC,EAAiB,SAEd,SACT,CAKA,SAASC,GAAuB,CAC9B,GAAI,OAAO,UAAc,IACvB,MAAO,UAGT,MAAMH,EAAK,UAAU,UACfI,EAAW,UAAU,UAAY,GAEvC,MAAI,UAAU,KAAKJ,CAAE,EAAU,UAC3B,WAAW,KAAKA,CAAE,EAAU,QAC5B,QAAQ,KAAKA,CAAE,GAAK,CAAC,UAAU,KAAKA,CAAE,EAAU,QAChD,UAAU,KAAKA,CAAE,EAAU,UAC3B,mBAAmB,KAAKA,CAAE,EAAU,MACpC,OAAO,KAAKA,CAAE,EAAU,YAErBI,GAAY,SACrB,CAKA,SAASC,GAA0B,CACjC,GAAI,OAAO,UAAc,IACvB,MAAO,UAGT,MAAML,EAAK,UAAU,UAGfM,EAAeN,EAAG,MAAM,uBAAuB,EACrD,GAAIM,EAAc,CAChB,MAAMC,EAAYD,EAAa,CAAC,EAShC,MAR2C,CACzC,OAAQ,QACR,MAAO,MACP,MAAO,IACP,MAAO,IACP,MAAO,QACP,MAAO,IAAA,EAESC,CAAS,GAAKA,CAClC,CAGA,MAAMC,EAAWR,EAAG,MAAM,+BAA+B,EACzD,GAAIQ,EACF,OAAOA,EAAS,CAAC,EAAE,QAAQ,KAAM,GAAG,EAItC,MAAMC,EAAWT,EAAG,MAAM,uCAAuC,EACjE,GAAIS,EACF,OAAOA,EAAS,CAAC,EAAE,QAAQ,KAAM,GAAG,EAItC,MAAMC,EAAeV,EAAG,MAAM,2BAA2B,EAC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,MAAM,MAAMK,EAAiBL,EAAuE,CAClG,OAAO,KAAK,QAAQ,CAAE,MAAOR,EAAS,MAAO,QAAAa,EAAS,GAAGL,EAAS,CACpE,CAKA,eAAyB,CACvB,OAAO,KAAK,MAAM,WACpB,CAKA,eAAmC,CACjC,OAAO,KAAK,MAAM,UACpB,CAIA,MAAc,UAA0B,CACtC,GAAI,MAAK,WAGT,IAAI,KAAK,YAAa,CACpB,MAAM,KAAK,YACX,MACF,CAEA,KAAK,aAAe,SAAY,CAC9B,GAAI,CAEF,MAAMF,EAAa,MAAMD,EAAA,EAEzB,KAAK,WAAaC,EAClB,KAAK,IAAI,iCAAiC,CAC5C,OAASI,EAAO,CACd,WAAK,IAAI,8BAA+BA,CAAK,EACvC,IAAI,MAAM,yEAAyE,CAC3F,CACF,GAAA,EAEA,MAAM,KAAK,YACb,CAEQ,mBAA0B,CAChC,GAAI,CAAC,KAAK,MAAM,YACd,MAAM,IAAI,MAAM,8DAA8D,EAEhF,GAAI,CAAC,KAAK,WACR,MAAM,IAAI,MAAM,2CAA2C,CAE/D,CAEQ,OAAOU,EAAuB,CAChC,KAAK,MAAM,OACb,QAAQ,IAAI,kBAAmB,GAAGA,CAAI,CAE1C,CACF,CAGO,MAAMC,EAAgB,IAAId"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smart Grow Logs - Web SDK
|
|
3
|
+
*
|
|
4
|
+
* Secure logging SDK with end-to-end encryption
|
|
5
|
+
* Powered by Rust/WASM
|
|
6
|
+
*/
|
|
7
|
+
export { LogLevel, SmartGrowLogs } from './smart-grow-logs';
|
|
8
|
+
export type { DeviceInfo, InitOptions, LogOptions, LogResponse } from './types';
|
|
9
|
+
export { SmartGrowLogs as default } from './smart-grow-logs';
|