@uptrademedia/site-kit 1.0.7 → 1.0.8

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.
File without changes
package/dist/seo/index.js CHANGED
@@ -10,117 +10,6 @@ var react = require('react');
10
10
  require('server-only');
11
11
  var jsxRuntime = require('react/jsx-runtime');
12
12
 
13
- // src/seo/getManagedMetadata.ts
14
- async function getManagedMetadata(options) {
15
- const { projectId, path, fallback = {}, overrides = {} } = options;
16
- const pageData = await chunkVDI7KYME_js.getSEOPageData(projectId, path);
17
- if (!pageData) {
18
- return {
19
- ...fallback,
20
- ...overrides,
21
- _managed: false,
22
- _source: "fallback"
23
- };
24
- }
25
- const metadata = {
26
- _managed: true,
27
- _source: "database"
28
- };
29
- if (pageData.managed_title) {
30
- metadata.title = pageData.managed_title;
31
- } else if (fallback.title) {
32
- metadata.title = fallback.title;
33
- }
34
- if (pageData.managed_meta_description || pageData.managed_description) {
35
- metadata.description = pageData.managed_meta_description || pageData.managed_description;
36
- } else if (fallback.description) {
37
- metadata.description = fallback.description;
38
- }
39
- if (pageData.managed_keywords?.length) {
40
- metadata.keywords = pageData.managed_keywords;
41
- } else if (fallback.keywords) {
42
- metadata.keywords = fallback.keywords;
43
- }
44
- if (pageData.managed_robots) {
45
- metadata.robots = pageData.managed_robots;
46
- }
47
- if (pageData.managed_canonical) {
48
- metadata.alternates = {
49
- ...metadata.alternates,
50
- canonical: pageData.managed_canonical
51
- };
52
- }
53
- const ogTitle = pageData.managed_og_title || pageData.managed_title;
54
- const ogDescription = pageData.managed_og_description || pageData.managed_meta_description || pageData.managed_description;
55
- const ogImage = pageData.managed_og_image;
56
- if (ogTitle || ogDescription || ogImage) {
57
- metadata.openGraph = {
58
- ...ogTitle && { title: ogTitle },
59
- ...ogDescription && { description: ogDescription },
60
- ...ogImage && { images: [{ url: ogImage }] }
61
- };
62
- }
63
- if (ogTitle || ogDescription || ogImage) {
64
- metadata.twitter = {
65
- card: "summary_large_image",
66
- ...ogTitle && { title: ogTitle },
67
- ...ogDescription && { description: ogDescription },
68
- ...ogImage && { images: [ogImage] }
69
- };
70
- }
71
- return {
72
- ...metadata,
73
- ...overrides,
74
- _managed: true,
75
- _source: "database"
76
- };
77
- }
78
- async function getABVariant(options) {
79
- const { projectId, path, field, sessionId } = options;
80
- const test = await chunkVDI7KYME_js.getABTest(projectId, path, field);
81
- if (!test) {
82
- return null;
83
- }
84
- let variant;
85
- if (sessionId) {
86
- const hash = sessionId.split("").reduce((acc, char) => {
87
- return (acc << 5) - acc + char.charCodeAt(0);
88
- }, 0);
89
- variant = Math.abs(hash) % 100 < test.traffic_split * 100 ? "a" : "b";
90
- } else {
91
- variant = Math.random() < test.traffic_split ? "a" : "b";
92
- }
93
- chunkVDI7KYME_js.recordABImpression(test.id, variant, sessionId).catch(() => {
94
- });
95
- return {
96
- testId: test.id,
97
- variant,
98
- value: variant === "a" ? test.variant_a : test.variant_b
99
- };
100
- }
101
- async function getManagedMetadataWithAB(options) {
102
- const { sessionId, ...metadataOptions } = options;
103
- const metadata = await getManagedMetadata(metadataOptions);
104
- const titleTest = await getABVariant({
105
- projectId: options.projectId,
106
- path: options.path,
107
- field: "title",
108
- sessionId
109
- });
110
- if (titleTest) {
111
- metadata.title = titleTest.value;
112
- }
113
- const descTest = await getABVariant({
114
- projectId: options.projectId,
115
- path: options.path,
116
- field: "description",
117
- sessionId
118
- });
119
- if (descTest) {
120
- metadata.description = descTest.value;
121
- }
122
- return metadata;
123
- }
124
13
  function getSecureApiConfig() {
125
14
  const apiUrl = process.env.UPTRADE_API_URL || process.env.NEXT_PUBLIC_UPTRADE_API_URL || "https://api.uptrademedia.com";
126
15
  const apiKey = process.env.UPTRADE_API_KEY || "";
@@ -153,7 +42,7 @@ async function secureApiPost(endpoint, body = {}) {
153
42
  return null;
154
43
  }
155
44
  }
156
- var getSEOPageData2 = react.cache(async (projectId, path) => {
45
+ var getSEOPageData = react.cache(async (projectId, path) => {
157
46
  const result = await secureApiPost("/api/public/seo/page", {
158
47
  projectId,
159
48
  path
@@ -193,7 +82,7 @@ var getContentBlock2 = react.cache(async (projectId, path, section) => {
193
82
  });
194
83
  return result?.content || null;
195
84
  });
196
- var getABTest2 = react.cache(async (projectId, path, field) => {
85
+ var getABTest = react.cache(async (projectId, path, field) => {
197
86
  const result = await secureApiPost("/api/public/seo/ab-test", {
198
87
  projectId,
199
88
  path,
@@ -201,7 +90,7 @@ var getABTest2 = react.cache(async (projectId, path, field) => {
201
90
  });
202
91
  return result?.test || null;
203
92
  });
204
- async function recordABImpression2(testId, variant, sessionId) {
93
+ async function recordABImpression(testId, variant, sessionId) {
205
94
  await secureApiPost("/api/public/seo/ab-impression", { testId, variant, sessionId });
206
95
  }
207
96
  var getRedirectData = react.cache(async (projectId, path) => {
@@ -309,6 +198,118 @@ var getVisibilityScore = react.cache(async (projectId, pagePath) => {
309
198
  var getVisibilitySummary = react.cache(async (projectId) => {
310
199
  return signalApiGet(`/skills/seo/visibility/${projectId}/summary`);
311
200
  });
201
+
202
+ // src/seo/getManagedMetadata.ts
203
+ async function getManagedMetadata(options) {
204
+ const { projectId, path, fallback = {}, overrides = {} } = options;
205
+ const pageData = await getSEOPageData(projectId, path);
206
+ if (!pageData) {
207
+ return {
208
+ ...fallback,
209
+ ...overrides,
210
+ _managed: false,
211
+ _source: "fallback"
212
+ };
213
+ }
214
+ const metadata = {
215
+ _managed: true,
216
+ _source: "database"
217
+ };
218
+ if (pageData.managed_title) {
219
+ metadata.title = pageData.managed_title;
220
+ } else if (fallback.title) {
221
+ metadata.title = fallback.title;
222
+ }
223
+ if (pageData.managed_meta_description || pageData.managed_description) {
224
+ metadata.description = pageData.managed_meta_description || pageData.managed_description;
225
+ } else if (fallback.description) {
226
+ metadata.description = fallback.description;
227
+ }
228
+ if (pageData.managed_keywords?.length) {
229
+ metadata.keywords = pageData.managed_keywords;
230
+ } else if (fallback.keywords) {
231
+ metadata.keywords = fallback.keywords;
232
+ }
233
+ if (pageData.managed_robots) {
234
+ metadata.robots = pageData.managed_robots;
235
+ }
236
+ if (pageData.managed_canonical) {
237
+ metadata.alternates = {
238
+ ...metadata.alternates,
239
+ canonical: pageData.managed_canonical
240
+ };
241
+ }
242
+ const ogTitle = pageData.managed_og_title || pageData.managed_title;
243
+ const ogDescription = pageData.managed_og_description || pageData.managed_meta_description || pageData.managed_description;
244
+ const ogImage = pageData.managed_og_image;
245
+ if (ogTitle || ogDescription || ogImage) {
246
+ metadata.openGraph = {
247
+ ...ogTitle && { title: ogTitle },
248
+ ...ogDescription && { description: ogDescription },
249
+ ...ogImage && { images: [{ url: ogImage }] }
250
+ };
251
+ }
252
+ if (ogTitle || ogDescription || ogImage) {
253
+ metadata.twitter = {
254
+ card: "summary_large_image",
255
+ ...ogTitle && { title: ogTitle },
256
+ ...ogDescription && { description: ogDescription },
257
+ ...ogImage && { images: [ogImage] }
258
+ };
259
+ }
260
+ return {
261
+ ...metadata,
262
+ ...overrides,
263
+ _managed: true,
264
+ _source: "database"
265
+ };
266
+ }
267
+ async function getABVariant(options) {
268
+ const { projectId, path, field, sessionId } = options;
269
+ const test = await getABTest(projectId, path, field);
270
+ if (!test) {
271
+ return null;
272
+ }
273
+ let variant;
274
+ if (sessionId) {
275
+ const hash = sessionId.split("").reduce((acc, char) => {
276
+ return (acc << 5) - acc + char.charCodeAt(0);
277
+ }, 0);
278
+ variant = Math.abs(hash) % 100 < test.traffic_split * 100 ? "a" : "b";
279
+ } else {
280
+ variant = Math.random() < test.traffic_split ? "a" : "b";
281
+ }
282
+ recordABImpression(test.id, variant, sessionId).catch(() => {
283
+ });
284
+ return {
285
+ testId: test.id,
286
+ variant,
287
+ value: variant === "a" ? test.variant_a : test.variant_b
288
+ };
289
+ }
290
+ async function getManagedMetadataWithAB(options) {
291
+ const { sessionId, ...metadataOptions } = options;
292
+ const metadata = await getManagedMetadata(metadataOptions);
293
+ const titleTest = await getABVariant({
294
+ projectId: options.projectId,
295
+ path: options.path,
296
+ field: "title",
297
+ sessionId
298
+ });
299
+ if (titleTest) {
300
+ metadata.title = titleTest.value;
301
+ }
302
+ const descTest = await getABVariant({
303
+ projectId: options.projectId,
304
+ path: options.path,
305
+ field: "description",
306
+ sessionId
307
+ });
308
+ if (descTest) {
309
+ metadata.description = descTest.value;
310
+ }
311
+ return metadata;
312
+ }
312
313
  var DEFAULT_SPEAKABLE_SELECTORS = [
313
314
  "h1",
314
315
  '[data-speakable="true"]',
@@ -829,7 +830,7 @@ exports.ManagedScripts = ManagedScripts;
829
830
  exports.createBreadcrumbSchema = createBreadcrumbSchema;
830
831
  exports.createSchema = createSchema;
831
832
  exports.default = ManagedSchema;
832
- exports.getABTest = getABTest2;
833
+ exports.getABTest = getABTest;
833
834
  exports.getABVariant = getABVariant;
834
835
  exports.getContentBlock = getContentBlock2;
835
836
  exports.getEntities = getEntities2;
@@ -844,12 +845,12 @@ exports.getManagedScripts = getManagedScripts2;
844
845
  exports.getPrimaryEntity = getPrimaryEntity;
845
846
  exports.getRedirectData = getRedirectData;
846
847
  exports.getRobotsData = getRobotsData;
847
- exports.getSEOPageData = getSEOPageData2;
848
+ exports.getSEOPageData = getSEOPageData;
848
849
  exports.getSchemaMarkups = getSchemaMarkups2;
849
850
  exports.getSitemapEntries = getSitemapEntries;
850
851
  exports.getVisibilityScore = getVisibilityScore;
851
852
  exports.getVisibilitySummary = getVisibilitySummary;
852
- exports.recordABImpression = recordABImpression2;
853
+ exports.recordABImpression = recordABImpression;
853
854
  exports.registerSitemap = registerSitemap;
854
855
  //# sourceMappingURL=index.js.map
855
856
  //# sourceMappingURL=index.js.map