@ninetailed/experience.js-next-esr 1.0.1-beta.9 → 1.2.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/index.d.ts +0 -1
- package/index.esm.js +6 -7
- package/index.umd.js +14 -21
- package/lib/fetchEdgeProfile.d.ts +3 -2
- package/package.json +4 -4
package/index.d.ts
CHANGED
package/index.esm.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { NINETAILED_PROFILE_CACHE_COOKIE } from '@ninetailed/experience.js-plugin-ssr';
|
|
2
|
-
export * from '@ninetailed/experience.js-plugin-ssr';
|
|
3
1
|
import { v4 } from 'uuid';
|
|
4
2
|
import { buildPageEvent, buildEmptyCache } from '@ninetailed/experience.js-shared';
|
|
3
|
+
import { NINETAILED_PROFILE_CACHE_COOKIE } from '@ninetailed/experience.js-plugin-ssr';
|
|
5
4
|
|
|
6
5
|
function absoluteUrl(req, localhostAddress = 'localhost:3000') {
|
|
7
6
|
const hostHeader = req.headers.get('host');
|
|
@@ -87,8 +86,9 @@ const getProfileCache = cookies => {
|
|
|
87
86
|
const fetchEdgeProfile = ({
|
|
88
87
|
ctx,
|
|
89
88
|
cookies,
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
clientId,
|
|
90
|
+
environment,
|
|
91
|
+
url,
|
|
92
92
|
ip,
|
|
93
93
|
location
|
|
94
94
|
}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -101,11 +101,10 @@ const fetchEdgeProfile = ({
|
|
|
101
101
|
timestamp: Date.now(),
|
|
102
102
|
properties: {}
|
|
103
103
|
});
|
|
104
|
-
const request = yield fetch(`${url}/
|
|
104
|
+
const request = yield fetch(`${url || BASE_URL}/v1/organizations/${clientId}/environments/${environment || 'main'}/profiles/${anonymousId}/events`, {
|
|
105
105
|
method: 'POST',
|
|
106
106
|
headers: {
|
|
107
|
-
'Content-Type': 'application/json'
|
|
108
|
-
'x-ninetailed-api-key': apiKey
|
|
107
|
+
'Content-Type': 'application/json'
|
|
109
108
|
},
|
|
110
109
|
body: JSON.stringify(Object.assign(Object.assign(Object.assign({
|
|
111
110
|
events: [pageEvent]
|
package/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@ninetailed/experience.js-
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '@ninetailed/experience.js-
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.NextjsEsr = {}, global.
|
|
5
|
-
})(this, (function (exports,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('uuid'), require('@ninetailed/experience.js-shared'), require('@ninetailed/experience.js-plugin-ssr')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'uuid', '@ninetailed/experience.js-shared', '@ninetailed/experience.js-plugin-ssr'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.NextjsEsr = {}, global.uuid, global.experience_jsShared, global.experience_jsPluginSsr));
|
|
5
|
+
})(this, (function (exports, uuid, experience_jsShared, experience_jsPluginSsr) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function absoluteUrl(req, localhostAddress) {
|
|
8
8
|
if (localhostAddress === void 0) {
|
|
@@ -130,16 +130,16 @@
|
|
|
130
130
|
var fetchEdgeProfile = function (_a) {
|
|
131
131
|
var ctx = _a.ctx,
|
|
132
132
|
cookies = _a.cookies,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
url =
|
|
133
|
+
clientId = _a.clientId,
|
|
134
|
+
environment = _a.environment,
|
|
135
|
+
url = _a.url,
|
|
136
136
|
ip = _a.ip,
|
|
137
137
|
location = _a.location;
|
|
138
138
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
139
|
-
var cacheFromCookie, anonymousId, pageEvent, request,
|
|
139
|
+
var cacheFromCookie, anonymousId, pageEvent, request, _b, profile, traitsUpdatedAt, signals;
|
|
140
140
|
|
|
141
|
-
return __generator(this, function (
|
|
142
|
-
switch (
|
|
141
|
+
return __generator(this, function (_c) {
|
|
142
|
+
switch (_c.label) {
|
|
143
143
|
case 0:
|
|
144
144
|
cacheFromCookie = getProfileCache(cookies);
|
|
145
145
|
anonymousId = cacheFromCookie.id;
|
|
@@ -152,11 +152,10 @@
|
|
|
152
152
|
});
|
|
153
153
|
return [4
|
|
154
154
|
/*yield*/
|
|
155
|
-
, fetch("".concat(url, "/
|
|
155
|
+
, fetch("".concat(url || BASE_URL, "/v1/organizations/").concat(clientId, "/environments/").concat(environment || 'main', "/profiles/").concat(anonymousId, "/events"), {
|
|
156
156
|
method: 'POST',
|
|
157
157
|
headers: {
|
|
158
|
-
'Content-Type': 'application/json'
|
|
159
|
-
'x-ninetailed-api-key': apiKey
|
|
158
|
+
'Content-Type': 'application/json'
|
|
160
159
|
},
|
|
161
160
|
body: JSON.stringify(__assign(__assign(__assign({
|
|
162
161
|
events: [pageEvent]
|
|
@@ -168,13 +167,13 @@
|
|
|
168
167
|
})];
|
|
169
168
|
|
|
170
169
|
case 1:
|
|
171
|
-
request =
|
|
170
|
+
request = _c.sent();
|
|
172
171
|
return [4
|
|
173
172
|
/*yield*/
|
|
174
173
|
, request.json()];
|
|
175
174
|
|
|
176
175
|
case 2:
|
|
177
|
-
|
|
176
|
+
_b = _c.sent().data, profile = _b.profile, traitsUpdatedAt = _b.traitsUpdatedAt, signals = _b.signals;
|
|
178
177
|
return [2
|
|
179
178
|
/*return*/
|
|
180
179
|
, {
|
|
@@ -198,12 +197,6 @@
|
|
|
198
197
|
|
|
199
198
|
exports.buildNinetailedEdgeRequestContext = buildNinetailedEdgeRequestContext;
|
|
200
199
|
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
|
-
});
|
|
207
200
|
|
|
208
201
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
209
202
|
|
|
@@ -5,12 +5,13 @@ declare type Cookies = {
|
|
|
5
5
|
declare type GetServerSideProfileOptions = {
|
|
6
6
|
ctx: NinetailedRequestContext;
|
|
7
7
|
cookies: Cookies;
|
|
8
|
-
|
|
8
|
+
clientId: string;
|
|
9
|
+
environment?: string;
|
|
9
10
|
url?: string;
|
|
10
11
|
ip?: string;
|
|
11
12
|
location?: GeoLocation;
|
|
12
13
|
};
|
|
13
|
-
export declare const fetchEdgeProfile: ({ ctx, cookies,
|
|
14
|
+
export declare const fetchEdgeProfile: ({ ctx, cookies, clientId, environment, url, ip, location, }: GetServerSideProfileOptions) => Promise<{
|
|
14
15
|
profile: Profile;
|
|
15
16
|
cache: Cache;
|
|
16
17
|
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninetailed/experience.js-next-esr",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"next": "12.1.0"
|
|
6
6
|
},
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"module": "./index.esm.js",
|
|
9
9
|
"typings": "./index.d.ts",
|
|
10
10
|
"peerDependencies": {
|
|
11
|
-
"@ninetailed/experience.js-
|
|
11
|
+
"@ninetailed/experience.js-shared": "1.2.1",
|
|
12
12
|
"uuid": "^8.3.2",
|
|
13
|
-
"node-fetch": "^3.2.3",
|
|
14
|
-
"@ninetailed/experience.js-shared": "1.0.1-beta.9",
|
|
15
13
|
"ts-toolbelt": "^9.6.0",
|
|
16
14
|
"locale-enum": "^1.1.1",
|
|
17
15
|
"i18n-iso-countries": "^7.3.0",
|
|
16
|
+
"@ninetailed/experience.js-plugin-ssr": "1.2.1",
|
|
17
|
+
"node-fetch": "^3.2.3",
|
|
18
18
|
"analytics": "^0.8.0",
|
|
19
19
|
"js-cookie": "^3.0.1"
|
|
20
20
|
}
|