@usermaven/sdk-js 1.4.1-rc.58 → 1.4.1
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/LICENSE +23 -0
- package/README.md +36 -149
- package/dist/npm/usermaven.cjs.js +2682 -0
- package/dist/npm/usermaven.d.ts +546 -0
- package/dist/npm/usermaven.es.js +2675 -0
- package/dist/web/lib.js +1 -0
- package/package.json +49 -48
- package/dist/core/client.d.ts +0 -57
- package/dist/core/config.d.ts +0 -37
- package/dist/core/types.d.ts +0 -38
- package/dist/extensions/rage-click.d.ts +0 -15
- package/dist/extensions/scroll-depth.d.ts +0 -19
- package/dist/index.d.ts +0 -6
- package/dist/lib.js +0 -2
- package/dist/persistence/local-storage.d.ts +0 -13
- package/dist/persistence/memory.d.ts +0 -8
- package/dist/tracking/autocapture.d.ts +0 -29
- package/dist/tracking/form-tracking.d.ts +0 -27
- package/dist/tracking/pageviews.d.ts +0 -11
- package/dist/transport/beacon.d.ts +0 -10
- package/dist/transport/fetch.d.ts +0 -13
- package/dist/transport/https.d.ts +0 -11
- package/dist/transport/transport.d.ts +0 -3
- package/dist/transport/xhr.d.ts +0 -12
- package/dist/usermaven.cjs.js +0 -2
- package/dist/usermaven.es.js +0 -1324
- package/dist/utils/autocapture-utils.d.ts +0 -13
- package/dist/utils/common.d.ts +0 -27
- package/dist/utils/cookie.d.ts +0 -14
- package/dist/utils/helpers.d.ts +0 -9
- package/dist/utils/logger.d.ts +0 -15
- package/dist/utils/queue.d.ts +0 -23
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 UserMaven, Inc.
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2021 Jitsu Labs, Inc
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,164 +1,51 @@
|
|
|
1
|
-
# Usermaven SDK
|
|
1
|
+
# Usermaven JavaScript SDK (usermaven.js)
|
|
2
2
|
|
|
3
|
-
Usermaven
|
|
3
|
+
Usermaven.js is a JavaScript SDK for [Usermaven](https://usermaven.com).
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Capabilities
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
- Flexible event tracking with custom payloads
|
|
9
|
-
- Automatic tracking of page views, form submissions, and user interactions
|
|
10
|
-
- Privacy-focused with configurable data sanitization
|
|
11
|
-
- Robust error handling and retry mechanisms
|
|
12
|
-
- Extensible architecture for custom tracking features
|
|
13
|
-
- Performance optimizations including event batching and debouncing
|
|
7
|
+
- Autocapturing via `autocapture`, `capture_pageview`, `properties_string_max_length` and `property_blacklist` options.
|
|
14
8
|
|
|
15
|
-
##
|
|
9
|
+
## Maintainers Guide
|
|
16
10
|
|
|
17
|
-
|
|
11
|
+
This section is indented only for package maintainers.
|
|
18
12
|
|
|
19
|
-
|
|
13
|
+
### Building and local debug
|
|
20
14
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
* _**ATTENTION**_: Use `yarn` for everything except publishing
|
|
16
|
+
* To spin off a local development server run `yarn devserver`, then open [http://localhost:8081](http://localhost:8081)
|
|
17
|
+
* The server listens to all changes to src and rebuilds npm and `lib.js` automatically. Open test cases HTML files to see
|
|
18
|
+
usermaven in action
|
|
19
|
+
* http://localhost:8081/test-case/embed.html - embedded Usermaven
|
|
20
|
+
- * <http://localhost:8081/test-case/embed_strict_mode.html> - embedded strict mode for Usermaven
|
|
21
|
+
* http://localhost:8081/test-case/autocapture.html - embedded Usermaven with autocapturing events
|
|
22
|
+
* `yarn test` runs [Playwright](https://playwright.dev/) test
|
|
23
|
+
* `yarn build` builds both npm package and `lib.js` browser bundle
|
|
24
|
+
* `npm publish --public` to publish the package (change version in `package.json` manually). You need to run `npm login` with your personal
|
|
25
|
+
npmjs account beforehand (make sure you have access to Usermaven team)
|
|
26
|
+
* In order to check usermaven sdk locally.
|
|
27
|
+
* `cd dist/npm` --- navigate to npm directory
|
|
28
|
+
* `npm link` --- creates a symbolic link to be accessed globally
|
|
29
|
+
* `cd ../../__tests__/sdk/` --- navigate to sdk test project
|
|
30
|
+
* `npm i` --- install npm dependencies
|
|
31
|
+
* `npm link @usermaven/sdk-js` --- use npm package locally whose symlink is just published
|
|
32
|
+
* `npm start` --- start the application and monitor events
|
|
24
33
|
|
|
25
|
-
|
|
34
|
+
### Checking Cross Domain Session locally
|
|
35
|
+
Setup a custom domain and sub-domain locally to test cross domain session persistence.
|
|
26
36
|
|
|
27
37
|
```bash
|
|
28
|
-
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
### UMD (Universal Module Definition)
|
|
32
|
-
|
|
33
|
-
For quick integration without a module bundler, you can include the SDK directly in your HTML using a script tag:
|
|
34
|
-
|
|
35
|
-
```html
|
|
36
|
-
<script src="https://cdn.usermaven.com/sdk/v1/lib.js"
|
|
37
|
-
data-key="your-api-key"
|
|
38
|
-
data-tracking-host="https://events.yourdomain.com"
|
|
39
|
-
data-log-level="debug"
|
|
40
|
-
data-autocapture="true"
|
|
41
|
-
data-form-tracking="true"
|
|
42
|
-
data-auto-pageview="true"></script>
|
|
38
|
+
sudo nano /etc/hosts
|
|
43
39
|
```
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
### Using as a module
|
|
50
|
-
|
|
51
|
-
```javascript
|
|
52
|
-
import { usermavenClient } from '@usermaven/sdk-js';
|
|
53
|
-
|
|
54
|
-
const client = usermavenClient({
|
|
55
|
-
apiKey: 'your-api-key',
|
|
56
|
-
trackingHost: 'https://events.yourdomain.com',
|
|
57
|
-
// Add other configuration options as needed
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
// Track an event
|
|
61
|
-
client.track('button_click', {
|
|
62
|
-
buttonId: 'submit-form',
|
|
63
|
-
pageUrl: window.location.href
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
// Identify a user
|
|
67
|
-
client.id({
|
|
68
|
-
id: 'user123',
|
|
69
|
-
email: 'user@example.com',
|
|
70
|
-
name: 'John Doe'
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
// Track a page view
|
|
74
|
-
client.pageview();
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### Using via UMD
|
|
78
|
-
|
|
79
|
-
When you include the SDK via a script tag, it automatically initializes with the configuration provided in the data attributes. You can then use the global `usermaven` function to interact with the SDK:
|
|
80
|
-
|
|
81
|
-
```html
|
|
82
|
-
<script>
|
|
83
|
-
// Track an event
|
|
84
|
-
usermaven('track', 'button_click', {
|
|
85
|
-
buttonId: 'submit-form',
|
|
86
|
-
pageUrl: window.location.href
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
// Identify a user
|
|
90
|
-
usermaven('id', {
|
|
91
|
-
id: 'user123',
|
|
92
|
-
email: 'user@example.com',
|
|
93
|
-
name: 'John Doe'
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
// Track a page view (if not set to automatic in the script tag)
|
|
97
|
-
usermaven('pageview');
|
|
98
|
-
</script>
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
## Advanced Configuration
|
|
102
|
-
|
|
103
|
-
The SDK supports various configuration options to customize its behavior. When using as a module:
|
|
104
|
-
|
|
105
|
-
```javascript
|
|
106
|
-
const client = usermavenClient({
|
|
107
|
-
apiKey: 'your-api-key',
|
|
108
|
-
trackingHost: 'https://events.yourdomain.com',
|
|
109
|
-
cookieDomain: '.yourdomain.com',
|
|
110
|
-
logLevel: 'DEBUG',
|
|
111
|
-
useBeaconApi: true,
|
|
112
|
-
autocapture: true,
|
|
113
|
-
formTracking: 'all',
|
|
114
|
-
autoPageview: true,
|
|
115
|
-
// ... other options
|
|
116
|
-
});
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
When using via UMD, you can set these options using data attributes on the script tag:
|
|
120
|
-
|
|
121
|
-
```html
|
|
122
|
-
<script src="https://cdn.usermaven.com/sdk/v1/lib.js"
|
|
123
|
-
data-key="your-api-key"
|
|
124
|
-
data-tracking-host="https://events.yourdomain.com"
|
|
125
|
-
data-log-level="debug"
|
|
126
|
-
data-autocapture="true"
|
|
127
|
-
data-form-tracking="all"
|
|
128
|
-
data-auto-pageview="true"
|
|
129
|
-
data-use-beacon-api="true"
|
|
130
|
-
data-cookie-domain=".yourdomain.com"></script>
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
Refer to the `Config` interface in `src/core/config.ts` for a full list of configuration options.
|
|
134
|
-
|
|
135
|
-
## Server-Side Usage
|
|
136
|
-
|
|
137
|
-
The SDK can also be used in server-side environments:
|
|
138
|
-
|
|
139
|
-
```javascript
|
|
140
|
-
const { usermavenClient } = require('@usermaven/sdk-js');
|
|
141
|
-
|
|
142
|
-
const client = usermavenClient({
|
|
143
|
-
apiKey: 'your-api-key',
|
|
144
|
-
trackingHost: 'https://events.yourdomain.com'
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
client.track('server_event', {
|
|
148
|
-
userId: 'user123',
|
|
149
|
-
action: 'item_purchased'
|
|
150
|
-
});
|
|
40
|
+
Add the following lines in the hosts file
|
|
41
|
+
```bash
|
|
42
|
+
127.0.0.1 localhost.com
|
|
43
|
+
127.0.0.1 app.localhost.com
|
|
151
44
|
```
|
|
152
45
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
To set up the project for development:
|
|
156
|
-
|
|
157
|
-
1. Clone the repository
|
|
158
|
-
2. Install dependencies: `npm install`
|
|
159
|
-
3. Run tests: `npm test`
|
|
160
|
-
4. Build the project: `npm run build`
|
|
46
|
+
You will be able to access the domains at [localhost domain](http://localhost.com:8081/test-case/embed.html) and [localhost sub-domain](http://app.localhost.com:8081/test-case/embed.html)
|
|
161
47
|
|
|
162
|
-
|
|
48
|
+
### Publishing new version
|
|
163
49
|
|
|
164
|
-
|
|
50
|
+
* Login with your *personal* credentials with `npm login`
|
|
51
|
+
* Run `yarn install && yarn build && yarn test && npm publish --access public`
|