@ninetailed/experience.js-next-esr 1.0.0-beta.23 → 1.0.1-beta.9
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/index.d.ts +3 -3
- package/index.esm.js +5 -19
- package/index.umd.js +15 -27
- package/lib/build-esr-context.d.ts +1 -1
- package/lib/{get-edge-side-profile.d.ts → fetchEdgeProfile.d.ts} +1 -2
- package/package.json +7 -3
package/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from '
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export * from '@ninetailed/experience.js-plugin-ssr';
|
|
2
|
+
export { buildNinetailedEdgeRequestContext } from './lib/build-esr-context';
|
|
3
|
+
export { fetchEdgeProfile } from './lib/fetchEdgeProfile';
|
package/index.esm.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { NINETAILED_PROFILE_CACHE_COOKIE } from '@ninetailed/experience.js-plugin-ssr';
|
|
2
|
+
export * from '@ninetailed/experience.js-plugin-ssr';
|
|
1
3
|
import { v4 } from 'uuid';
|
|
2
4
|
import { buildPageEvent, buildEmptyCache } from '@ninetailed/experience.js-shared';
|
|
3
5
|
|
|
@@ -29,7 +31,7 @@ const getLocale = req => {
|
|
|
29
31
|
}
|
|
30
32
|
};
|
|
31
33
|
|
|
32
|
-
const
|
|
34
|
+
const buildNinetailedEdgeRequestContext = ({
|
|
33
35
|
req
|
|
34
36
|
}) => {
|
|
35
37
|
const url = new URL(`${req.nextUrl.pathname}${req.nextUrl.search}`, absoluteUrl(req).origin);
|
|
@@ -66,7 +68,6 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
66
68
|
});
|
|
67
69
|
}
|
|
68
70
|
|
|
69
|
-
const NINETAILED_PROFILE_CACHE_COOKIE = 'ntpc';
|
|
70
71
|
const BASE_URL = 'https://api.ninetailed.co';
|
|
71
72
|
|
|
72
73
|
const getProfileCache = cookies => {
|
|
@@ -83,7 +84,7 @@ const getProfileCache = cookies => {
|
|
|
83
84
|
return buildEmptyCache();
|
|
84
85
|
};
|
|
85
86
|
|
|
86
|
-
const
|
|
87
|
+
const fetchEdgeProfile = ({
|
|
87
88
|
ctx,
|
|
88
89
|
cookies,
|
|
89
90
|
apiKey,
|
|
@@ -137,19 +138,4 @@ const getEdgeSideProfile = ({
|
|
|
137
138
|
};
|
|
138
139
|
});
|
|
139
140
|
|
|
140
|
-
|
|
141
|
-
ninetailed
|
|
142
|
-
}) => {
|
|
143
|
-
if (!ninetailed) {
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
try {
|
|
148
|
-
const data = JSON.parse(ninetailed);
|
|
149
|
-
return data.profile;
|
|
150
|
-
} catch (_a) {
|
|
151
|
-
return null;
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
export { NINETAILED_PROFILE_CACHE_COOKIE, buildEsrNinetailedRequestContext, getEdgeSideProfile, selectNinetailedProfile };
|
|
141
|
+
export { buildNinetailedEdgeRequestContext, fetchEdgeProfile };
|
package/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('uuid'), require('@ninetailed/experience.js-shared')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'uuid', '@ninetailed/experience.js-shared'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.NextjsEsr = {}, global.uuid, global.experience_jsShared));
|
|
5
|
-
})(this, (function (exports, uuid, experience_jsShared) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@ninetailed/experience.js-plugin-ssr'), require('uuid'), require('@ninetailed/experience.js-shared')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@ninetailed/experience.js-plugin-ssr', 'uuid', '@ninetailed/experience.js-shared'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.NextjsEsr = {}, global.experience_jsPluginSsr, global.uuid, global.experience_jsShared));
|
|
5
|
+
})(this, (function (exports, experience_jsPluginSsr, uuid, experience_jsShared) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function absoluteUrl(req, localhostAddress) {
|
|
8
8
|
if (localhostAddress === void 0) {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
var
|
|
39
|
+
var buildNinetailedEdgeRequestContext = function (_a) {
|
|
40
40
|
var req = _a.req;
|
|
41
41
|
var url = new URL("".concat(req.nextUrl.pathname).concat(req.nextUrl.search), absoluteUrl(req).origin);
|
|
42
42
|
return {
|
|
@@ -111,11 +111,10 @@
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
var NINETAILED_PROFILE_CACHE_COOKIE = 'ntpc';
|
|
115
114
|
var BASE_URL = 'https://api.ninetailed.co';
|
|
116
115
|
|
|
117
116
|
var getProfileCache = function (cookies) {
|
|
118
|
-
var cacheString = cookies[NINETAILED_PROFILE_CACHE_COOKIE];
|
|
117
|
+
var cacheString = cookies[experience_jsPluginSsr.NINETAILED_PROFILE_CACHE_COOKIE];
|
|
119
118
|
|
|
120
119
|
if (cacheString) {
|
|
121
120
|
try {
|
|
@@ -128,7 +127,7 @@
|
|
|
128
127
|
return experience_jsShared.buildEmptyCache();
|
|
129
128
|
};
|
|
130
129
|
|
|
131
|
-
var
|
|
130
|
+
var fetchEdgeProfile = function (_a) {
|
|
132
131
|
var ctx = _a.ctx,
|
|
133
132
|
cookies = _a.cookies,
|
|
134
133
|
apiKey = _a.apiKey,
|
|
@@ -197,25 +196,14 @@
|
|
|
197
196
|
});
|
|
198
197
|
};
|
|
199
198
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
if (!
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
var data = JSON.parse(ninetailed);
|
|
209
|
-
return data.profile;
|
|
210
|
-
} catch (_b) {
|
|
211
|
-
return null;
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
exports.NINETAILED_PROFILE_CACHE_COOKIE = NINETAILED_PROFILE_CACHE_COOKIE;
|
|
216
|
-
exports.buildEsrNinetailedRequestContext = buildEsrNinetailedRequestContext;
|
|
217
|
-
exports.getEdgeSideProfile = getEdgeSideProfile;
|
|
218
|
-
exports.selectNinetailedProfile = selectNinetailedProfile;
|
|
199
|
+
exports.buildNinetailedEdgeRequestContext = buildNinetailedEdgeRequestContext;
|
|
200
|
+
exports.fetchEdgeProfile = fetchEdgeProfile;
|
|
201
|
+
Object.keys(experience_jsPluginSsr).forEach(function (k) {
|
|
202
|
+
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
203
|
+
enumerable: true,
|
|
204
|
+
get: function () { return experience_jsPluginSsr[k]; }
|
|
205
|
+
});
|
|
206
|
+
});
|
|
219
207
|
|
|
220
208
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
221
209
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NextRequest } from 'next/server';
|
|
2
2
|
import { NinetailedRequestContext } from '@ninetailed/experience.js-shared';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const buildNinetailedEdgeRequestContext: ({ req, }: {
|
|
4
4
|
req: NextRequest;
|
|
5
5
|
}) => NinetailedRequestContext;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Profile, GeoLocation, NinetailedRequestContext, Cache } from '@ninetailed/experience.js-shared';
|
|
2
|
-
export declare const NINETAILED_PROFILE_CACHE_COOKIE = "ntpc";
|
|
3
2
|
declare type Cookies = {
|
|
4
3
|
[key: string]: string;
|
|
5
4
|
};
|
|
@@ -11,7 +10,7 @@ declare type GetServerSideProfileOptions = {
|
|
|
11
10
|
ip?: string;
|
|
12
11
|
location?: GeoLocation;
|
|
13
12
|
};
|
|
14
|
-
export declare const
|
|
13
|
+
export declare const fetchEdgeProfile: ({ ctx, cookies, apiKey, url, ip, location, }: GetServerSideProfileOptions) => Promise<{
|
|
15
14
|
profile: Profile;
|
|
16
15
|
cache: Cache;
|
|
17
16
|
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninetailed/experience.js-next-esr",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1-beta.9",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"next": "12.1.0"
|
|
6
6
|
},
|
|
@@ -8,10 +8,14 @@
|
|
|
8
8
|
"module": "./index.esm.js",
|
|
9
9
|
"typings": "./index.d.ts",
|
|
10
10
|
"peerDependencies": {
|
|
11
|
-
"@ninetailed/experience.js-
|
|
11
|
+
"@ninetailed/experience.js-plugin-ssr": "1.0.1-beta.9",
|
|
12
12
|
"uuid": "^8.3.2",
|
|
13
|
+
"node-fetch": "^3.2.3",
|
|
14
|
+
"@ninetailed/experience.js-shared": "1.0.1-beta.9",
|
|
13
15
|
"ts-toolbelt": "^9.6.0",
|
|
14
16
|
"locale-enum": "^1.1.1",
|
|
15
|
-
"i18n-iso-countries": "^7.3.0"
|
|
17
|
+
"i18n-iso-countries": "^7.3.0",
|
|
18
|
+
"analytics": "^0.8.0",
|
|
19
|
+
"js-cookie": "^3.0.1"
|
|
16
20
|
}
|
|
17
21
|
}
|