lucia-sdk 0.8.0 → 0.9.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 +19 -0
- package/README.md +137 -2
- package/dist/README.md +137 -2
- package/dist/__tests__/auto-init.test.d.ts +5 -0
- package/dist/__tests__/integration/auto-init-integration.test.d.ts +9 -0
- package/dist/__tests__/integration/auto-track-integration.test.d.ts +4 -0
- package/dist/__tests__/utils/click-tracker.test.d.ts +4 -0
- package/dist/__tests__/utils/privacy.test.d.ts +4 -0
- package/dist/core/index.d.ts +17 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +3 -3
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/types.d.ts +19 -1
- package/dist/umd/lucia-sdk-0.9.0.min.js +18 -0
- package/dist/umd/lucia-sdk-latest.min.js +3 -3
- package/dist/utils/click-tracker.d.ts +100 -0
- package/dist/utils/privacy.d.ts +33 -0
- package/package.json +1 -1
- package/dist/umd/lucia-sdk-0.8.0.min.js +0 -18
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
## [0.9.0](https://github.com/ondecentral/Lucia-Browser-SDK/compare/v0.8.0...v0.9.0) (2025-11-20)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* add auto-init with api key provided in script tag ([fa358a7](https://github.com/ondecentral/Lucia-Browser-SDK/commit/fa358a77151203d90252bbe00f44a407b97b129d))
|
|
12
|
+
* add automated click tracking ([af95407](https://github.com/ondecentral/Lucia-Browser-SDK/commit/af95407d021a4dc464e41fd255a20782d9f235b3))
|
|
13
|
+
* use closest to find trackable elements ([aae6ff6](https://github.com/ondecentral/Lucia-Browser-SDK/commit/aae6ff61fd42f447867130921370d22cc10e7761))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Documentation
|
|
17
|
+
|
|
18
|
+
* update readme ([160130c](https://github.com/ondecentral/Lucia-Browser-SDK/commit/160130c9f82fc39b520b89360523b25bfba65ada))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Code Refactoring
|
|
22
|
+
|
|
23
|
+
* optimize click tracking with closest() and add cleanup ([78cf55f](https://github.com/ondecentral/Lucia-Browser-SDK/commit/78cf55f09ff8fbb2ccb69ea50887ec11366e98d1))
|
|
24
|
+
|
|
6
25
|
## [0.8.0](https://github.com/ondecentral/Lucia-Browser-SDK/compare/v0.7.2...v0.8.0) (2025-11-13)
|
|
7
26
|
|
|
8
27
|
|
package/README.md
CHANGED
|
@@ -24,20 +24,150 @@ yarn add lucia-sdk
|
|
|
24
24
|
|
|
25
25
|
You can add the following script to use global `LuciaSDK` object.
|
|
26
26
|
|
|
27
|
+
**Option 1: Auto-initialization (Recommended)**
|
|
28
|
+
|
|
29
|
+
The SDK will automatically initialize when you provide the `data-api-key` attribute:
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
<script src="https://cdn.luciaprotocol.com/lucia-sdk-latest.min.js" data-api-key="your-api-key-here"></script>
|
|
27
33
|
```
|
|
34
|
+
|
|
35
|
+
Optional configuration attributes:
|
|
36
|
+
|
|
37
|
+
- `data-api-key` (required) - Your Lucia API key
|
|
38
|
+
- `data-debug-url` (optional) - Custom debug endpoint URL
|
|
39
|
+
- `data-auto-track-clicks` (optional) - Enable automatic click tracking (`"true"` or `"false"`)
|
|
40
|
+
- `data-track-selectors` (optional) - Custom CSS selectors for click tracking (comma-separated)
|
|
41
|
+
|
|
42
|
+
**Option 2: Manual initialization**
|
|
43
|
+
|
|
44
|
+
Load the script without attributes and initialize programmatically:
|
|
45
|
+
|
|
46
|
+
```html
|
|
28
47
|
<script src="https://cdn.luciaprotocol.com/lucia-sdk-latest.min.js"></script>
|
|
48
|
+
<script>
|
|
49
|
+
LuciaSDK.init({
|
|
50
|
+
apiKey: 'your-api-key-here',
|
|
51
|
+
debugURL: 'https://custom-debug-url.com', // optional
|
|
52
|
+
});
|
|
53
|
+
</script>
|
|
29
54
|
```
|
|
30
55
|
|
|
31
56
|
## Usage
|
|
32
57
|
|
|
33
58
|
### Initialize the SDK
|
|
34
59
|
|
|
60
|
+
#### For CDN (Manual Initialization)
|
|
61
|
+
|
|
35
62
|
```javascript
|
|
36
63
|
LuciaSDK.init({
|
|
37
|
-
apiKey,
|
|
64
|
+
apiKey: 'your-api-key-here',
|
|
65
|
+
debugURL: 'https://custom-debug-url.com', // optional
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### For npm/yarn Installation
|
|
70
|
+
|
|
71
|
+
```javascript
|
|
72
|
+
import LuciaSDK from 'lucia-sdk';
|
|
73
|
+
|
|
74
|
+
await LuciaSDK.init({
|
|
75
|
+
apiKey: 'your-api-key-here',
|
|
76
|
+
autoTrackClicks: true, // optional: enable automatic click tracking
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### For Next.js
|
|
81
|
+
|
|
82
|
+
The SDK seamlessly works with Next.js using both CDN auto-init and npm import:
|
|
83
|
+
|
|
84
|
+
```jsx
|
|
85
|
+
import Script from 'next/script';
|
|
86
|
+
import LuciaSDK from 'lucia-sdk';
|
|
87
|
+
|
|
88
|
+
export default function Page() {
|
|
89
|
+
const handleClick = () => {
|
|
90
|
+
// NPM import works with CDN-initialized instance
|
|
91
|
+
LuciaSDK.buttonClick('cta-button');
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<>
|
|
96
|
+
<Script
|
|
97
|
+
src="https://cdn.luciaprotocol.com/lucia-sdk-latest.min.js"
|
|
98
|
+
data-api-key="your-api-key-here"
|
|
99
|
+
strategy="afterInteractive"
|
|
100
|
+
/>
|
|
101
|
+
<button onClick={handleClick}>Click me</button>
|
|
102
|
+
</>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Automated Click Tracking
|
|
108
|
+
|
|
109
|
+
Lucia SDK provides zero-config automated click tracking. When enabled, it automatically tracks clicks on buttons, links, and other interactive elements.
|
|
110
|
+
|
|
111
|
+
#### Enable via CDN
|
|
112
|
+
|
|
113
|
+
```html
|
|
114
|
+
<script
|
|
115
|
+
src="https://cdn.luciaprotocol.com/lucia-sdk-latest.min.js"
|
|
116
|
+
data-api-key="your-api-key-here"
|
|
117
|
+
data-auto-track-clicks="true"
|
|
118
|
+
></script>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
#### Enable Programmatically
|
|
122
|
+
|
|
123
|
+
```javascript
|
|
124
|
+
await LuciaSDK.init({
|
|
125
|
+
apiKey: 'your-api-key-here',
|
|
126
|
+
autoTrackClicks: true, // Enable with defaults
|
|
38
127
|
});
|
|
128
|
+
|
|
129
|
+
// Or with custom configuration
|
|
130
|
+
await LuciaSDK.init({
|
|
131
|
+
apiKey: 'your-api-key-here',
|
|
132
|
+
autoTrackClicks: {
|
|
133
|
+
enabled: true,
|
|
134
|
+
selectors: ['button', '.cta', '[data-track]'], // Custom selectors
|
|
135
|
+
ignore: ['.no-track'], // Elements to ignore
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
#### Element-Level Control
|
|
141
|
+
|
|
142
|
+
Add tracking attributes to specific elements:
|
|
143
|
+
|
|
144
|
+
```html
|
|
145
|
+
<!-- Explicit tracking with custom identifier -->
|
|
146
|
+
<button data-lucia-track="signup-cta">Sign Up</button>
|
|
147
|
+
|
|
148
|
+
<!-- Add metadata to tracked clicks -->
|
|
149
|
+
<button data-lucia-track="purchase-btn" data-lucia-meta-variant="primary" data-lucia-meta-location="hero">
|
|
150
|
+
Buy Now
|
|
151
|
+
</button>
|
|
152
|
+
|
|
153
|
+
<!-- Ignore specific elements -->
|
|
154
|
+
<button data-lucia-ignore>Don't Track This</button>
|
|
39
155
|
```
|
|
40
156
|
|
|
157
|
+
**Default Tracked Elements:**
|
|
158
|
+
|
|
159
|
+
- `<button>` elements
|
|
160
|
+
- `<a>` elements with `href` attribute
|
|
161
|
+
- Elements with `role="button"`
|
|
162
|
+
- Any element with `data-lucia-track` attribute
|
|
163
|
+
|
|
164
|
+
**Privacy Features:**
|
|
165
|
+
|
|
166
|
+
- Automatically ignores password inputs
|
|
167
|
+
- Skips credit card fields
|
|
168
|
+
- Filters sensitive data from text content
|
|
169
|
+
- Respects `data-lucia-ignore` attribute
|
|
170
|
+
|
|
41
171
|
### Track events
|
|
42
172
|
|
|
43
173
|
Page views, conversions, and user information can be tracked using the following methods:
|
|
@@ -63,7 +193,12 @@ LuciaSDK.trackConversion(
|
|
|
63
193
|
},
|
|
64
194
|
);
|
|
65
195
|
|
|
66
|
-
|
|
196
|
+
// Manual click tracking (optional with auto-tracking enabled)
|
|
197
|
+
LuciaSDK.buttonClick('cta-button', {
|
|
198
|
+
elementType: 'button',
|
|
199
|
+
text: 'Sign Up Now',
|
|
200
|
+
meta: { variant: 'primary', location: 'hero' },
|
|
201
|
+
});
|
|
67
202
|
|
|
68
203
|
LuciaSDK.sendWalletInfo('0x1234567890', 59141);
|
|
69
204
|
```
|
package/dist/README.md
CHANGED
|
@@ -24,20 +24,150 @@ yarn add lucia-sdk
|
|
|
24
24
|
|
|
25
25
|
You can add the following script to use global `LuciaSDK` object.
|
|
26
26
|
|
|
27
|
+
**Option 1: Auto-initialization (Recommended)**
|
|
28
|
+
|
|
29
|
+
The SDK will automatically initialize when you provide the `data-api-key` attribute:
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
<script src="https://cdn.luciaprotocol.com/lucia-sdk-latest.min.js" data-api-key="your-api-key-here"></script>
|
|
27
33
|
```
|
|
34
|
+
|
|
35
|
+
Optional configuration attributes:
|
|
36
|
+
|
|
37
|
+
- `data-api-key` (required) - Your Lucia API key
|
|
38
|
+
- `data-debug-url` (optional) - Custom debug endpoint URL
|
|
39
|
+
- `data-auto-track-clicks` (optional) - Enable automatic click tracking (`"true"` or `"false"`)
|
|
40
|
+
- `data-track-selectors` (optional) - Custom CSS selectors for click tracking (comma-separated)
|
|
41
|
+
|
|
42
|
+
**Option 2: Manual initialization**
|
|
43
|
+
|
|
44
|
+
Load the script without attributes and initialize programmatically:
|
|
45
|
+
|
|
46
|
+
```html
|
|
28
47
|
<script src="https://cdn.luciaprotocol.com/lucia-sdk-latest.min.js"></script>
|
|
48
|
+
<script>
|
|
49
|
+
LuciaSDK.init({
|
|
50
|
+
apiKey: 'your-api-key-here',
|
|
51
|
+
debugURL: 'https://custom-debug-url.com', // optional
|
|
52
|
+
});
|
|
53
|
+
</script>
|
|
29
54
|
```
|
|
30
55
|
|
|
31
56
|
## Usage
|
|
32
57
|
|
|
33
58
|
### Initialize the SDK
|
|
34
59
|
|
|
60
|
+
#### For CDN (Manual Initialization)
|
|
61
|
+
|
|
35
62
|
```javascript
|
|
36
63
|
LuciaSDK.init({
|
|
37
|
-
apiKey,
|
|
64
|
+
apiKey: 'your-api-key-here',
|
|
65
|
+
debugURL: 'https://custom-debug-url.com', // optional
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### For npm/yarn Installation
|
|
70
|
+
|
|
71
|
+
```javascript
|
|
72
|
+
import LuciaSDK from 'lucia-sdk';
|
|
73
|
+
|
|
74
|
+
await LuciaSDK.init({
|
|
75
|
+
apiKey: 'your-api-key-here',
|
|
76
|
+
autoTrackClicks: true, // optional: enable automatic click tracking
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### For Next.js
|
|
81
|
+
|
|
82
|
+
The SDK seamlessly works with Next.js using both CDN auto-init and npm import:
|
|
83
|
+
|
|
84
|
+
```jsx
|
|
85
|
+
import Script from 'next/script';
|
|
86
|
+
import LuciaSDK from 'lucia-sdk';
|
|
87
|
+
|
|
88
|
+
export default function Page() {
|
|
89
|
+
const handleClick = () => {
|
|
90
|
+
// NPM import works with CDN-initialized instance
|
|
91
|
+
LuciaSDK.buttonClick('cta-button');
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<>
|
|
96
|
+
<Script
|
|
97
|
+
src="https://cdn.luciaprotocol.com/lucia-sdk-latest.min.js"
|
|
98
|
+
data-api-key="your-api-key-here"
|
|
99
|
+
strategy="afterInteractive"
|
|
100
|
+
/>
|
|
101
|
+
<button onClick={handleClick}>Click me</button>
|
|
102
|
+
</>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Automated Click Tracking
|
|
108
|
+
|
|
109
|
+
Lucia SDK provides zero-config automated click tracking. When enabled, it automatically tracks clicks on buttons, links, and other interactive elements.
|
|
110
|
+
|
|
111
|
+
#### Enable via CDN
|
|
112
|
+
|
|
113
|
+
```html
|
|
114
|
+
<script
|
|
115
|
+
src="https://cdn.luciaprotocol.com/lucia-sdk-latest.min.js"
|
|
116
|
+
data-api-key="your-api-key-here"
|
|
117
|
+
data-auto-track-clicks="true"
|
|
118
|
+
></script>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
#### Enable Programmatically
|
|
122
|
+
|
|
123
|
+
```javascript
|
|
124
|
+
await LuciaSDK.init({
|
|
125
|
+
apiKey: 'your-api-key-here',
|
|
126
|
+
autoTrackClicks: true, // Enable with defaults
|
|
38
127
|
});
|
|
128
|
+
|
|
129
|
+
// Or with custom configuration
|
|
130
|
+
await LuciaSDK.init({
|
|
131
|
+
apiKey: 'your-api-key-here',
|
|
132
|
+
autoTrackClicks: {
|
|
133
|
+
enabled: true,
|
|
134
|
+
selectors: ['button', '.cta', '[data-track]'], // Custom selectors
|
|
135
|
+
ignore: ['.no-track'], // Elements to ignore
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
#### Element-Level Control
|
|
141
|
+
|
|
142
|
+
Add tracking attributes to specific elements:
|
|
143
|
+
|
|
144
|
+
```html
|
|
145
|
+
<!-- Explicit tracking with custom identifier -->
|
|
146
|
+
<button data-lucia-track="signup-cta">Sign Up</button>
|
|
147
|
+
|
|
148
|
+
<!-- Add metadata to tracked clicks -->
|
|
149
|
+
<button data-lucia-track="purchase-btn" data-lucia-meta-variant="primary" data-lucia-meta-location="hero">
|
|
150
|
+
Buy Now
|
|
151
|
+
</button>
|
|
152
|
+
|
|
153
|
+
<!-- Ignore specific elements -->
|
|
154
|
+
<button data-lucia-ignore>Don't Track This</button>
|
|
39
155
|
```
|
|
40
156
|
|
|
157
|
+
**Default Tracked Elements:**
|
|
158
|
+
|
|
159
|
+
- `<button>` elements
|
|
160
|
+
- `<a>` elements with `href` attribute
|
|
161
|
+
- Elements with `role="button"`
|
|
162
|
+
- Any element with `data-lucia-track` attribute
|
|
163
|
+
|
|
164
|
+
**Privacy Features:**
|
|
165
|
+
|
|
166
|
+
- Automatically ignores password inputs
|
|
167
|
+
- Skips credit card fields
|
|
168
|
+
- Filters sensitive data from text content
|
|
169
|
+
- Respects `data-lucia-ignore` attribute
|
|
170
|
+
|
|
41
171
|
### Track events
|
|
42
172
|
|
|
43
173
|
Page views, conversions, and user information can be tracked using the following methods:
|
|
@@ -63,7 +193,12 @@ LuciaSDK.trackConversion(
|
|
|
63
193
|
},
|
|
64
194
|
);
|
|
65
195
|
|
|
66
|
-
|
|
196
|
+
// Manual click tracking (optional with auto-tracking enabled)
|
|
197
|
+
LuciaSDK.buttonClick('cta-button', {
|
|
198
|
+
elementType: 'button',
|
|
199
|
+
text: 'Sign Up Now',
|
|
200
|
+
meta: { variant: 'primary', location: 'hero' },
|
|
201
|
+
});
|
|
67
202
|
|
|
68
203
|
LuciaSDK.sendWalletInfo('0x1234567890', 59141);
|
|
69
204
|
```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Integration tests for auto-initialization with hybrid CDN + npm usage
|
|
3
|
+
*
|
|
4
|
+
* NOTE: These tests focus on the conceptual aspects of auto-init that can be tested
|
|
5
|
+
* in a Jest environment. Full CDN auto-init behavior (script tag detection,
|
|
6
|
+
* DOMContentLoaded, automatic initialization) must be tested manually using:
|
|
7
|
+
* demo/auto-init-demo.html in a real browser environment.
|
|
8
|
+
*/
|
|
9
|
+
import '@testing-library/jest-dom';
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import BaseClass from '../base';
|
|
2
|
+
import { ClickEventMetadata } from '../types';
|
|
2
3
|
declare class LuciaSDK extends BaseClass {
|
|
4
|
+
private clickTracker;
|
|
3
5
|
authenticate(): void;
|
|
4
6
|
/**
|
|
5
7
|
* Initializes the SDK with the provided configuration
|
|
6
8
|
*/
|
|
7
9
|
init(): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Initialize automated click tracking if enabled
|
|
12
|
+
*/
|
|
13
|
+
private initAutoTracking;
|
|
14
|
+
/**
|
|
15
|
+
* Handle automatically tracked click events
|
|
16
|
+
*/
|
|
17
|
+
private handleAutoTrackedClick;
|
|
8
18
|
/**
|
|
9
19
|
* Sends user information to the server
|
|
10
20
|
* @param userId The user's ID, e.g. email, wallet address, etc.
|
|
@@ -25,9 +35,10 @@ declare class LuciaSDK extends BaseClass {
|
|
|
25
35
|
trackConversion(eventTag: string, amount: number, eventDetails: object): Promise<void>;
|
|
26
36
|
/**
|
|
27
37
|
* Sends button click information to the server
|
|
28
|
-
* @param button The button that was clicked
|
|
38
|
+
* @param button The button identifier that was clicked
|
|
39
|
+
* @param metadata Optional metadata about the click event (elementType, text, href, meta)
|
|
29
40
|
*/
|
|
30
|
-
buttonClick(button: string): Promise<void>;
|
|
41
|
+
buttonClick(button: string, metadata?: ClickEventMetadata): Promise<void>;
|
|
31
42
|
/**
|
|
32
43
|
* Sends wallet information to the server
|
|
33
44
|
* @param walletAddress The wallet address of the user
|
|
@@ -45,5 +56,9 @@ declare class LuciaSDK extends BaseClass {
|
|
|
45
56
|
* @returns false if MetaMask is not connected, otherwise returns the wallet address
|
|
46
57
|
*/
|
|
47
58
|
checkMetaMaskConnection(): any;
|
|
59
|
+
/**
|
|
60
|
+
* Clean up SDK resources (mainly for testing)
|
|
61
|
+
*/
|
|
62
|
+
destroy(): void;
|
|
48
63
|
}
|
|
49
64
|
export default LuciaSDK;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SDK } from './types';
|
|
2
2
|
import { getBrowserData, getWalletData, getUtmParams, safeAccess, filterObject, getCanvasFingerprint, isTouchEnabled, getApplePayAvailable, getContrastPreference, getColorGamut } from './utils/data';
|
|
3
|
+
export declare const __resetInstance: () => void;
|
|
3
4
|
declare const LuciaSDK: SDK;
|
|
4
5
|
export default LuciaSDK;
|
|
5
6
|
export { getBrowserData, getWalletData, getUtmParams, safeAccess, filterObject, getCanvasFingerprint, isTouchEnabled, getApplePayAvailable, getContrastPreference, getColorGamut, };
|