@remkoj/optimizely-one-nextjs 5.1.5 → 5.1.6
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/dist/api/content-recs.js
CHANGED
|
@@ -4,12 +4,15 @@ import * as Responses from './responses';
|
|
|
4
4
|
export const ContentRecsApiService = {
|
|
5
5
|
for: { path: '/crecs', verb: 'get' },
|
|
6
6
|
handler: async (query, cookies) => {
|
|
7
|
+
// Read configuration
|
|
7
8
|
const optiOneConfig = readConfigFromEnv();
|
|
8
9
|
if (!optiOneConfig.ContentRecsHost)
|
|
9
10
|
return Responses.NotFound;
|
|
11
|
+
// Identify visitor
|
|
10
12
|
const crId = ContentRecs.Tools.getVisitorID(cookies);
|
|
11
13
|
if (!crId)
|
|
12
14
|
return [{ total_hits: 0, content: [] }, 200];
|
|
15
|
+
// Send request to Content Recommendations, and strip JSONP function call
|
|
13
16
|
const recsService = new URL(`https://api.${optiOneConfig.ContentRecsHost}/1.0/users/idio_visitor_id:${crId}/content?callback=fn`);
|
|
14
17
|
query.forEach((value, name) => {
|
|
15
18
|
if (name.toLowerCase() != 'callback')
|
|
@@ -20,17 +23,15 @@ export const ContentRecsApiService = {
|
|
|
20
23
|
return [{ error: { status: snippetResponse.status, message: snippetResponse.statusText } }, snippetResponse.status];
|
|
21
24
|
const body = await snippetResponse.text();
|
|
22
25
|
const jsonData = body.substring(body.indexOf('{'), body.lastIndexOf('}') + 1);
|
|
26
|
+
// Convert and return data
|
|
23
27
|
try {
|
|
24
28
|
const recsData = JSON.parse(jsonData);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
next_page: (new URL(recsData.next_page)).search
|
|
29
|
-
},
|
|
30
|
-
200
|
|
31
|
-
];
|
|
29
|
+
if (recsData.next_page)
|
|
30
|
+
recsData.next_page = (new URL(recsData.next_page)).search;
|
|
31
|
+
return [recsData, 200];
|
|
32
32
|
}
|
|
33
|
-
catch {
|
|
33
|
+
catch (e) {
|
|
34
|
+
console.error("Error in processing Content Recommendations", e);
|
|
34
35
|
return [{ error: { status: 500, message: "Unable to parse Content Recommendations data" } }, 500];
|
|
35
36
|
}
|
|
36
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-recs.js","sourceRoot":"","sources":["../../src/api/content-recs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,KAAK,SAAS,MAAM,aAAa,CAAA;AAExC,MAAM,CAAC,MAAM,qBAAqB,GAAoB;IACpD,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE;IACpC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QAChC,MAAM,aAAa,GAAG,iBAAiB,EAAE,CAAC;QAC1C,IAAI,CAAC,aAAa,CAAC,eAAe;YAChC,OAAO,SAAS,CAAC,QAAQ,CAAA;QAE3B,MAAM,IAAI,GAAG,WAAW,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,CAAA;QACpD,IAAI,CAAC,IAAI;YACP,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"content-recs.js","sourceRoot":"","sources":["../../src/api/content-recs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,KAAK,SAAS,MAAM,aAAa,CAAA;AAExC,MAAM,CAAC,MAAM,qBAAqB,GAAoB;IACpD,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE;IACpC,OAAO,EAAE,KAAK,EAAE,KAAK,EA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;YACH,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;YACrC,IAAI,QAAQ,CAAC,SAAS;gBACpB,QAAQ,CAAC,SAAS,GAAG,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAA;YAC3D,OAAO,CAAE,QAAQ,EAAE,GAAG,CAAE,CAAA;QAC1B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAC,6CAA6C,EAAE,CAAC,CAAC,CAAA;YAC/D,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,8CAA8C,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;QACnG,CAAC;IACH,CAAC;CACF,CAAA;AAED,eAAe,qBAAqB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remkoj/optimizely-one-nextjs",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "5.1.
|
|
4
|
+
"version": "5.1.6",
|
|
5
5
|
"repository": "https://github.com/remkoj/optimizely-dxp-clients.git",
|
|
6
6
|
"author": "Remko Jantzen <693172+remkoj@users.noreply.github.com>",
|
|
7
7
|
"homepage": "https://github.com/remkoj/optimizely-dxp-clients",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@headlessui/react": "^2.2.5",
|
|
43
43
|
"@headlessui/tailwindcss": "^0.2.2",
|
|
44
44
|
"@heroicons/react": "^2.2.0",
|
|
45
|
-
"@remkoj/optimizely-graph-client": "^5.1.
|
|
45
|
+
"@remkoj/optimizely-graph-client": "^5.1.6",
|
|
46
46
|
"@types/node": "^22.16.5",
|
|
47
47
|
"@types/react": "^18.3.23",
|
|
48
48
|
"@types/react-dom": "18.3.7",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"@headlessui/react": "^2",
|
|
64
64
|
"@heroicons/react": "^2",
|
|
65
|
-
"@remkoj/optimizely-graph-client": "^5.1.
|
|
65
|
+
"@remkoj/optimizely-graph-client": "^5.1.6",
|
|
66
66
|
"next": "^14",
|
|
67
67
|
"react": "^18",
|
|
68
68
|
"react-dom": "^18",
|