@usermaven/nextjs 1.5.10-rc.110 → 1.5.10-rc.112
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/lib/UsermavenContext.d.ts +1 -1
- package/lib/UsermavenProvider.d.ts +2 -2
- package/lib/client.d.ts +1 -1
- package/lib/index.es.js +590 -379
- package/lib/middlewareEnv.d.ts +3 -3
- package/lib/middlewareEnv.js +23 -17
- package/lib/usePageView.d.ts +1 -1
- package/lib/useUsermaven.d.ts +1 -1
- package/package.json +2 -2
package/lib/middlewareEnv.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { NextRequest, NextResponse } from
|
|
2
|
-
import { ClientProperties } from
|
|
1
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
+
import { ClientProperties } from '@usermaven/sdk-js';
|
|
3
3
|
declare function middlewareEnv(req: NextRequest, res: NextResponse, opts?: {
|
|
4
4
|
disableCookies?: boolean;
|
|
5
5
|
}): {
|
|
6
|
-
getAnonymousId({ name, domain }: {
|
|
6
|
+
getAnonymousId({ name, domain, }: {
|
|
7
7
|
name: string;
|
|
8
8
|
domain?: string;
|
|
9
9
|
}): string;
|
package/lib/middlewareEnv.js
CHANGED
|
@@ -9,9 +9,9 @@ function hasSetMethod(cookies) {
|
|
|
9
9
|
}
|
|
10
10
|
function middlewareEnv(req, res, opts = {}) {
|
|
11
11
|
return {
|
|
12
|
-
getAnonymousId({ name, domain }) {
|
|
12
|
+
getAnonymousId({ name, domain, }) {
|
|
13
13
|
if (opts === null || opts === void 0 ? void 0 : opts.disableCookies) {
|
|
14
|
-
return
|
|
14
|
+
return '';
|
|
15
15
|
}
|
|
16
16
|
let cookie;
|
|
17
17
|
if (hasGetMethod(req.cookies)) {
|
|
@@ -27,7 +27,7 @@ function middlewareEnv(req, res, opts = {}) {
|
|
|
27
27
|
const cookieOpts = {
|
|
28
28
|
maxAge: 31622400 * 10,
|
|
29
29
|
httpOnly: false,
|
|
30
|
-
path:
|
|
30
|
+
path: '/',
|
|
31
31
|
};
|
|
32
32
|
if (domain) {
|
|
33
33
|
cookieOpts.domain = domain;
|
|
@@ -39,36 +39,42 @@ function middlewareEnv(req, res, opts = {}) {
|
|
|
39
39
|
value: newId,
|
|
40
40
|
maxAge: cookieOpts.maxAge,
|
|
41
41
|
domain: cookieOpts.domain,
|
|
42
|
-
httpOnly: cookieOpts.httpOnly
|
|
42
|
+
httpOnly: cookieOpts.httpOnly,
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
else {
|
|
46
|
-
res.headers.set(
|
|
46
|
+
res.headers.set('Set-Cookie', (0, cookie_1.serialize)(name, newId, cookieOpts));
|
|
47
47
|
}
|
|
48
48
|
return newId;
|
|
49
49
|
},
|
|
50
50
|
getSourceIp() {
|
|
51
|
-
let ip = req.headers.get(
|
|
52
|
-
|
|
51
|
+
let ip = req.headers.get('x-forwarded-for') ||
|
|
52
|
+
req.headers.get('x-real-ip') ||
|
|
53
|
+
'';
|
|
54
|
+
return ip && ip.split(',')[0].trim();
|
|
53
55
|
},
|
|
54
56
|
describeClient() {
|
|
55
57
|
var _a;
|
|
56
|
-
const requestHost = req.headers.get(
|
|
57
|
-
|
|
58
|
+
const requestHost = req.headers.get('x-forwarded-host') ||
|
|
59
|
+
req.headers.get('host') ||
|
|
60
|
+
req.nextUrl.hostname;
|
|
61
|
+
const proto = req.headers.get('x-forwarded-proto') ||
|
|
62
|
+
((_a = req.nextUrl.protocol) === null || _a === void 0 ? void 0 : _a.replace(':', ''));
|
|
58
63
|
let query = req.nextUrl.search;
|
|
59
64
|
let path = req.nextUrl.pathname;
|
|
60
65
|
return {
|
|
61
|
-
doc_encoding:
|
|
66
|
+
doc_encoding: '',
|
|
62
67
|
doc_host: requestHost,
|
|
63
68
|
doc_path: req.url,
|
|
64
69
|
doc_search: query,
|
|
65
|
-
page_title:
|
|
66
|
-
referer: req.headers.get(
|
|
67
|
-
screen_resolution:
|
|
68
|
-
url: `${proto}://${requestHost}${path ||
|
|
69
|
-
user_agent: req.headers.get(
|
|
70
|
-
user_language: req.headers.get(
|
|
71
|
-
|
|
70
|
+
page_title: '',
|
|
71
|
+
referer: req.headers.get('referrer'),
|
|
72
|
+
screen_resolution: '',
|
|
73
|
+
url: `${proto}://${requestHost}${path || ''}${query || ''}`,
|
|
74
|
+
user_agent: req.headers.get('user-agent'),
|
|
75
|
+
user_language: req.headers.get('accept-language') &&
|
|
76
|
+
req.headers.get('accept-language').split(',')[0],
|
|
77
|
+
vp_size: '',
|
|
72
78
|
};
|
|
73
79
|
},
|
|
74
80
|
};
|
package/lib/usePageView.d.ts
CHANGED
package/lib/useUsermaven.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usermaven/nextjs",
|
|
3
|
-
"version": "1.5.10-rc.
|
|
3
|
+
"version": "1.5.10-rc.112",
|
|
4
4
|
"description": "Usermaven JavaScript SDK for NextJS",
|
|
5
5
|
"author": "Usermaven <hello@usermaven.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"access": "public"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@usermaven/sdk-js": "1.5.10-rc.
|
|
21
|
+
"@usermaven/sdk-js": "1.5.10-rc.112",
|
|
22
22
|
"cookie": "^0.5.0"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|