@progus/connector 0.7.0 → 0.7.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/dist/{chunk-WZ5FAA44.js → chunk-77N7IXZB.js} +21 -2
- package/dist/crossSell.cjs +21 -2
- package/dist/crossSell.js +1 -1
- package/dist/index.cjs +21 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -20,6 +20,25 @@ function safeJsonParse(text) {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
// src/crossSell.ts
|
|
23
|
+
function appendUtmSource(url, utmSource) {
|
|
24
|
+
const source = utmSource?.trim();
|
|
25
|
+
if (!source) return url;
|
|
26
|
+
try {
|
|
27
|
+
const parsed = new URL(url);
|
|
28
|
+
if (!parsed.searchParams.has("utm_source")) {
|
|
29
|
+
parsed.searchParams.set("utm_source", source);
|
|
30
|
+
}
|
|
31
|
+
return parsed.toString();
|
|
32
|
+
} catch {
|
|
33
|
+
return url;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function withSourceTracking(apps, utmSource) {
|
|
37
|
+
return apps.map((app) => ({
|
|
38
|
+
...app,
|
|
39
|
+
url: appendUtmSource(app.url, utmSource)
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
23
42
|
function getCrossSellOffers(options = {}) {
|
|
24
43
|
const appsCatalog = options.appsCatalog ?? [];
|
|
25
44
|
const installedKeys = new Set(
|
|
@@ -79,7 +98,7 @@ function buildFallbackCatalog(options) {
|
|
|
79
98
|
if (limit > 0) {
|
|
80
99
|
items = items.slice(0, limit);
|
|
81
100
|
}
|
|
82
|
-
return items;
|
|
101
|
+
return withSourceTracking(items, appName);
|
|
83
102
|
}
|
|
84
103
|
async function fetchAppsCatalog(options = {}) {
|
|
85
104
|
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
@@ -105,7 +124,7 @@ async function fetchAppsCatalog(options = {}) {
|
|
|
105
124
|
logger?.error?.("Failed to fetch apps catalog", { status: response.status });
|
|
106
125
|
return buildFallbackCatalog(options);
|
|
107
126
|
}
|
|
108
|
-
return parsed;
|
|
127
|
+
return withSourceTracking(parsed, appName);
|
|
109
128
|
} catch (error) {
|
|
110
129
|
logger?.error?.("Failed to fetch apps catalog", {
|
|
111
130
|
error: error instanceof Error ? error.message : String(error)
|
package/dist/crossSell.cjs
CHANGED
|
@@ -39,6 +39,25 @@ function safeJsonParse(text) {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
// src/crossSell.ts
|
|
42
|
+
function appendUtmSource(url, utmSource) {
|
|
43
|
+
const source = utmSource?.trim();
|
|
44
|
+
if (!source) return url;
|
|
45
|
+
try {
|
|
46
|
+
const parsed = new URL(url);
|
|
47
|
+
if (!parsed.searchParams.has("utm_source")) {
|
|
48
|
+
parsed.searchParams.set("utm_source", source);
|
|
49
|
+
}
|
|
50
|
+
return parsed.toString();
|
|
51
|
+
} catch {
|
|
52
|
+
return url;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function withSourceTracking(apps, utmSource) {
|
|
56
|
+
return apps.map((app) => ({
|
|
57
|
+
...app,
|
|
58
|
+
url: appendUtmSource(app.url, utmSource)
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
42
61
|
function getCrossSellOffers(options = {}) {
|
|
43
62
|
const appsCatalog = options.appsCatalog ?? [];
|
|
44
63
|
const installedKeys = new Set(
|
|
@@ -98,7 +117,7 @@ function buildFallbackCatalog(options) {
|
|
|
98
117
|
if (limit > 0) {
|
|
99
118
|
items = items.slice(0, limit);
|
|
100
119
|
}
|
|
101
|
-
return items;
|
|
120
|
+
return withSourceTracking(items, appName);
|
|
102
121
|
}
|
|
103
122
|
async function fetchAppsCatalog(options = {}) {
|
|
104
123
|
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
@@ -124,7 +143,7 @@ async function fetchAppsCatalog(options = {}) {
|
|
|
124
143
|
logger?.error?.("Failed to fetch apps catalog", { status: response.status });
|
|
125
144
|
return buildFallbackCatalog(options);
|
|
126
145
|
}
|
|
127
|
-
return parsed;
|
|
146
|
+
return withSourceTracking(parsed, appName);
|
|
128
147
|
} catch (error) {
|
|
129
148
|
logger?.error?.("Failed to fetch apps catalog", {
|
|
130
149
|
error: error instanceof Error ? error.message : String(error)
|
package/dist/crossSell.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -403,6 +403,25 @@ function createProgusConnector(config) {
|
|
|
403
403
|
}
|
|
404
404
|
|
|
405
405
|
// src/crossSell.ts
|
|
406
|
+
function appendUtmSource(url, utmSource) {
|
|
407
|
+
const source = utmSource?.trim();
|
|
408
|
+
if (!source) return url;
|
|
409
|
+
try {
|
|
410
|
+
const parsed = new URL(url);
|
|
411
|
+
if (!parsed.searchParams.has("utm_source")) {
|
|
412
|
+
parsed.searchParams.set("utm_source", source);
|
|
413
|
+
}
|
|
414
|
+
return parsed.toString();
|
|
415
|
+
} catch {
|
|
416
|
+
return url;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
function withSourceTracking(apps, utmSource) {
|
|
420
|
+
return apps.map((app) => ({
|
|
421
|
+
...app,
|
|
422
|
+
url: appendUtmSource(app.url, utmSource)
|
|
423
|
+
}));
|
|
424
|
+
}
|
|
406
425
|
function getCrossSellOffers(options = {}) {
|
|
407
426
|
const appsCatalog = options.appsCatalog ?? [];
|
|
408
427
|
const installedKeys = new Set(
|
|
@@ -462,7 +481,7 @@ function buildFallbackCatalog(options) {
|
|
|
462
481
|
if (limit > 0) {
|
|
463
482
|
items = items.slice(0, limit);
|
|
464
483
|
}
|
|
465
|
-
return items;
|
|
484
|
+
return withSourceTracking(items, appName);
|
|
466
485
|
}
|
|
467
486
|
async function fetchAppsCatalog(options = {}) {
|
|
468
487
|
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
@@ -488,7 +507,7 @@ async function fetchAppsCatalog(options = {}) {
|
|
|
488
507
|
logger?.error?.("Failed to fetch apps catalog", { status: response.status });
|
|
489
508
|
return buildFallbackCatalog(options);
|
|
490
509
|
}
|
|
491
|
-
return parsed;
|
|
510
|
+
return withSourceTracking(parsed, appName);
|
|
492
511
|
} catch (error) {
|
|
493
512
|
logger?.error?.("Failed to fetch apps catalog", {
|
|
494
513
|
error: error instanceof Error ? error.message : String(error)
|
package/dist/index.js
CHANGED