ainamika-sdk 1.2.9 → 1.3.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/README.md CHANGED
@@ -37,23 +37,27 @@ Or via CDN:
37
37
 
38
38
  ## Quick Start
39
39
 
40
- ### 1. Get Your Project Key
40
+ ### 1. Get Your Project Credentials
41
41
 
42
- Sign up at [AInamika Dashboard](https://ainamika.netlify.app) and create a project to get your `projectKey`.
42
+ Sign up at [AInamika Dashboard](https://ainamika.netlify.app) and create a project to get your:
43
+ - **Project Key** (`projectKey`): Public identifier for your project
44
+ - **Project Secret** (`projectSecret`): Secret key for HMAC authentication (shown only once on creation!)
45
+
46
+ > ⚠️ **Important**: Save your `projectSecret` immediately when creating a project. It's only shown once and cannot be retrieved later (you can regenerate it from project settings).
43
47
 
44
48
  ### 2. Initialize the SDK
45
49
 
46
50
  #### Minimal Configuration (Recommended Start)
47
51
 
48
- The simplest way to get started - just 3 lines:
52
+ The simplest way to get started:
49
53
 
50
54
  ```javascript
51
55
  import AInamikaSDK from 'ainamika-sdk';
52
56
 
53
57
  const analytics = new AInamikaSDK({
54
- projectKey: 'proj_xxxxxxxxxx', // Get this from your dashboard
55
- autoConfig: true, // AI-powered auto-configuration
56
- clientId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' // Your client ID
58
+ projectKey: 'proj_xxxxxxxxxx', // Your project key (public)
59
+ projectSecret: 'your_secret_here', // Your project secret (keep private!)
60
+ autoConfig: true // AI-powered auto-configuration
57
61
  });
58
62
  ```
59
63
 
@@ -67,10 +71,10 @@ For more control, you can configure all options:
67
71
  import AInamikaSDK from 'ainamika-sdk';
68
72
 
69
73
  const analytics = new AInamikaSDK({
70
- projectKey: 'proj_xxxxxxxxxx', // Get this from your dashboard
71
- autoConfig: true, // AI-powered auto-configuration
72
- clientId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
73
- debug: false, // Set to true for development
74
+ projectKey: 'proj_xxxxxxxxxx', // Your project key (public)
75
+ projectSecret: 'your_secret_here', // Your project secret (keep private!)
76
+ autoConfig: true, // AI-powered auto-configuration
77
+ debug: false, // Set to true for development
74
78
 
75
79
  // Extra config - custom data included with ALL events
76
80
  extraConfig: {
@@ -308,12 +312,12 @@ analytics.trackConversion('newsletter_subscribe', undefined, {
308
312
 
309
313
  ```javascript
310
314
  const analytics = new AInamikaSDK({
311
- // Required for authentication
312
- projectKey: 'proj_xxxxxxxxxx', // Get from your dashboard
313
- clientId: 'your-client-id', // Your unique client identifier
315
+ // Required - Authentication (HMAC)
316
+ projectKey: 'proj_xxxxxxxxxx', // Your project key (public)
317
+ projectSecret: 'your_secret_here', // Your project secret (keep private!)
314
318
 
315
319
  // Auto-Configuration
316
- autoConfig: true, // Enable AI-powered DOM analysis
320
+ autoConfig: true, // Enable AI-powered DOM analysis
317
321
 
318
322
  // Debugging
319
323
  debug: false, // Enable console logging
@@ -405,7 +409,7 @@ Pass custom data that will be included with **every event**. This is useful for
405
409
  // Set during initialization
406
410
  const analytics = new AInamikaSDK({
407
411
  projectKey: 'proj_xxxxxxxxxx',
408
- clientId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
412
+ projectSecret: 'your_secret_here',
409
413
  autoConfig: true,
410
414
  extraConfig: {
411
415
  appVersion: '2.0.0',
@@ -581,7 +585,7 @@ import { useEffect } from 'react';
581
585
 
582
586
  const analytics = new AInamikaSDK({
583
587
  projectKey: 'proj_xxxxxxxxxx',
584
- clientId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
588
+ projectSecret: 'your_secret_here', // Keep this secure!
585
589
  autoConfig: true,
586
590
  extraConfig: {
587
591
  appVersion: '2.0.0',
@@ -622,8 +626,8 @@ let analytics = null;
622
626
  export function getAnalytics() {
623
627
  if (typeof window !== 'undefined' && !analytics) {
624
628
  analytics = new AInamikaSDK({
625
- projectKey: 'proj_xxxxxxxxxx',
626
- clientId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
629
+ projectKey: process.env.NEXT_PUBLIC_AINAMIKA_PROJECT_KEY,
630
+ projectSecret: process.env.NEXT_PUBLIC_AINAMIKA_PROJECT_SECRET, // Keep secure!
627
631
  autoConfig: true,
628
632
  extraConfig: {
629
633
  appVersion: process.env.NEXT_PUBLIC_APP_VERSION || '1.0.0',
@@ -670,10 +674,10 @@ function MyApp({ Component, pageProps }) {
670
674
  <button id="game-btn" customdata='{"name":"Puzzle Master"}'>Play Game</button>
671
675
 
672
676
  <script>
673
- // Minimal setup - just 3 required fields
677
+ // Initialize with project credentials
674
678
  const analytics = new AInamikaSDKPro({
675
679
  projectKey: 'proj_xxxxxxxxxx',
676
- clientId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
680
+ projectSecret: 'your_secret_here', // Keep this secure!
677
681
  autoConfig: true,
678
682
 
679
683
  // Optional: Add extra config for better tracking
@@ -739,9 +743,27 @@ function MyApp({ Component, pageProps }) {
739
743
  2. Use `trackAPI()` for manual tracking
740
744
  3. Check `apiTrackingPatterns` if using filters
741
745
 
742
- ## Data Privacy
746
+ ## Security & Data Privacy
747
+
748
+ ### HMAC Authentication
749
+
750
+ The SDK uses HMAC-SHA256 signatures for secure API authentication:
751
+ - Every request is signed with your `projectSecret`
752
+ - Signatures include timestamps to prevent replay attacks
753
+ - The secret is never transmitted - only used to generate signatures
754
+
755
+ ### Protecting Your Project Secret
756
+
757
+ ⚠️ **Important**: Keep your `projectSecret` secure:
758
+ - Never commit it to public repositories
759
+ - Use environment variables in production
760
+ - For client-side apps, consider using a backend proxy for sensitive operations
761
+ - Regenerate the secret from the dashboard if compromised
762
+
763
+ ### Data Privacy
743
764
 
744
765
  - All data is transmitted securely over HTTPS
766
+ - Requests are signed with HMAC-SHA256
745
767
  - User identifiers are hashed before transmission
746
768
  - Sampling can reduce data collection
747
769
  - No PII is collected automatically