@ninetailed/experience.js-next-esr 1.0.0-beta.21 → 1.0.1-beta.10

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 CHANGED
@@ -1,3 +1,2 @@
1
- export * from './lib/build-esr-context';
2
- export * from './lib/get-edge-side-profile';
3
- export * from './lib/selector';
1
+ export { buildNinetailedEdgeRequestContext } from './lib/build-esr-context';
2
+ export { fetchEdgeProfile } from './lib/fetchEdgeProfile';
package/index.esm.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { v4 } from 'uuid';
2
2
  import { buildPageEvent, buildEmptyCache } from '@ninetailed/experience.js-shared';
3
+ import { NINETAILED_PROFILE_CACHE_COOKIE } from '@ninetailed/experience.js-plugin-ssr';
3
4
 
4
5
  function absoluteUrl(req, localhostAddress = 'localhost:3000') {
5
6
  const hostHeader = req.headers.get('host');
@@ -29,7 +30,7 @@ const getLocale = req => {
29
30
  }
30
31
  };
31
32
 
32
- const buildEsrNinetailedRequestContext = ({
33
+ const buildNinetailedEdgeRequestContext = ({
33
34
  req
34
35
  }) => {
35
36
  const url = new URL(`${req.nextUrl.pathname}${req.nextUrl.search}`, absoluteUrl(req).origin);
@@ -66,7 +67,6 @@ function __awaiter(thisArg, _arguments, P, generator) {
66
67
  });
67
68
  }
68
69
 
69
- const NINETAILED_PROFILE_CACHE_COOKIE = 'ntpc';
70
70
  const BASE_URL = 'https://api.ninetailed.co';
71
71
 
72
72
  const getProfileCache = cookies => {
@@ -83,7 +83,7 @@ const getProfileCache = cookies => {
83
83
  return buildEmptyCache();
84
84
  };
85
85
 
86
- const getEdgeSideProfile = ({
86
+ const fetchEdgeProfile = ({
87
87
  ctx,
88
88
  cookies,
89
89
  apiKey,
@@ -137,19 +137,4 @@ const getEdgeSideProfile = ({
137
137
  };
138
138
  });
139
139
 
140
- const selectNinetailedProfile = ({
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 };
140
+ 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('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) {
@@ -36,7 +36,7 @@
36
36
  }
37
37
  };
38
38
 
39
- var buildEsrNinetailedRequestContext = function (_a) {
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 getEdgeSideProfile = function (_a) {
130
+ var fetchEdgeProfile = function (_a) {
132
131
  var ctx = _a.ctx,
133
132
  cookies = _a.cookies,
134
133
  apiKey = _a.apiKey,
@@ -197,25 +196,8 @@
197
196
  });
198
197
  };
199
198
 
200
- var selectNinetailedProfile = function (_a) {
201
- var ninetailed = _a.ninetailed;
202
-
203
- if (!ninetailed) {
204
- return null;
205
- }
206
-
207
- try {
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;
219
201
 
220
202
  Object.defineProperty(exports, '__esModule', { value: true });
221
203
 
@@ -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 buildEsrNinetailedRequestContext: ({ req, }: {
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 getEdgeSideProfile: ({ ctx, cookies, apiKey, url, ip, location, }: GetServerSideProfileOptions) => Promise<{
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.0-beta.21",
3
+ "version": "1.0.1-beta.10",
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-shared": "1.0.0-beta.21",
11
+ "@ninetailed/experience.js-shared": "1.0.1-beta.10",
12
12
  "uuid": "^8.3.2",
13
13
  "ts-toolbelt": "^9.6.0",
14
14
  "locale-enum": "^1.1.1",
15
- "i18n-iso-countries": "^7.3.0"
15
+ "i18n-iso-countries": "^7.3.0",
16
+ "@ninetailed/experience.js-plugin-ssr": "1.0.1-beta.10",
17
+ "node-fetch": "^3.2.3",
18
+ "analytics": "^0.8.0",
19
+ "js-cookie": "^3.0.1"
16
20
  }
17
21
  }