@naturalcycles/internal-web-lib 1.4.0 → 1.6.0
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/bundle/analyticsClient.js +19 -19
- package/bundle/analyticsClient.js.map +1 -1
- package/bundle/conversionClient.js +182 -151
- package/bundle/conversionClient.js.map +1 -1
- package/bundle/cookieMonster.js +186 -152
- package/bundle/cookieMonster.js.map +1 -1
- package/dist/conversion/conversionClient.d.ts +1 -13
- package/dist/conversion/conversionClient.js +3 -10
- package/dist/cookie-monster/css/shared-sheets.js +1 -1
- package/dist/cookie-monster/utils/translationsService.d.ts +2 -2
- package/dist/cookie-monster/utils/translationsService.js +5 -5
- package/dist/node_modules/.pnpm/{@naturalcycles_ncuikit@1.15.0_react@19.3.0_undici@8.11.2 → @naturalcycles_ncuikit@1.17.0_react@19.3.1_undici@8.12.1}/node_modules/@naturalcycles/ncuikit/dist/styles/_palette.js +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StringMap } from '@naturalcycles/js-lib/types';
|
|
2
|
-
import type { ClientId, PageViewInput, PurchaseInput } from '@naturalcycles/shared';
|
|
2
|
+
import type { ClientId, ConversionHeaders, PageViewInput, PurchaseInput } from '@naturalcycles/shared';
|
|
3
3
|
/**
|
|
4
4
|
* Client for our Conversions API endpoints (`web/p`, `web/purchase`). Captures ad click ids from
|
|
5
5
|
* the URL, stores them in cookies once marketing consent is given and sends them as headers. Nothing
|
|
@@ -16,8 +16,6 @@ export declare class ConversionClient {
|
|
|
16
16
|
pageView(input: PageViewInput, opt?: ConversionRequestOptions): void;
|
|
17
17
|
purchase(input: PurchaseInput, opt?: ConversionRequestOptions): void;
|
|
18
18
|
private hasMarketingConsent;
|
|
19
|
-
/** Returns null outside the allowed domains or on a path of their exclusion list. */
|
|
20
|
-
private getAllowedPathname;
|
|
21
19
|
private send;
|
|
22
20
|
/** Click ids are only included with marketing consent. */
|
|
23
21
|
getHeaders(input: ConversionHeadersInput): ConversionHeaders;
|
|
@@ -43,13 +41,3 @@ export interface ConversionRequestOptions {
|
|
|
43
41
|
export interface ConversionHeadersInput {
|
|
44
42
|
marketingConsent: boolean | undefined;
|
|
45
43
|
}
|
|
46
|
-
export interface ConversionHeaders {
|
|
47
|
-
clientId: string;
|
|
48
|
-
fbc?: string;
|
|
49
|
-
fbp?: string;
|
|
50
|
-
scCid?: string;
|
|
51
|
-
ttclid?: string;
|
|
52
|
-
rdtCid?: string;
|
|
53
|
-
epik?: string;
|
|
54
|
-
uuid_c1?: string;
|
|
55
|
-
}
|
|
@@ -3,7 +3,7 @@ import { _anyToError } from "@naturalcycles/js-lib/error";
|
|
|
3
3
|
import { getFetcher } from "@naturalcycles/js-lib/http";
|
|
4
4
|
import { _filterEmptyValues } from "@naturalcycles/js-lib/object";
|
|
5
5
|
import { _noop } from "@naturalcycles/js-lib/types";
|
|
6
|
-
import { WebSignupQueryParam,
|
|
6
|
+
import { WebSignupQueryParam, clickIdParameters, conversionService, cookieService, formatMetaClickId, sanitizeFbclid } from "@naturalcycles/shared";
|
|
7
7
|
//#region src/conversion/conversionClient.ts
|
|
8
8
|
var CLICK_ID_COOKIE_DAYS = 30;
|
|
9
9
|
var MAX_CLICK_ID_LENGTH = 200;
|
|
@@ -33,7 +33,7 @@ var ConversionClient = class {
|
|
|
33
33
|
}
|
|
34
34
|
pageView(input, opt = {}) {
|
|
35
35
|
if (!this.cfg.enabled || !this.hasMarketingConsent(input)) return;
|
|
36
|
-
const pathname =
|
|
36
|
+
const pathname = conversionService.scrubPathname(globalThis.location.origin, input.pathname);
|
|
37
37
|
if (pathname === null) return;
|
|
38
38
|
runInBackground(this.send("p", {
|
|
39
39
|
...input,
|
|
@@ -42,7 +42,7 @@ var ConversionClient = class {
|
|
|
42
42
|
}
|
|
43
43
|
purchase(input, opt = {}) {
|
|
44
44
|
if (!this.cfg.enabled || !this.hasMarketingConsent(input)) return;
|
|
45
|
-
const pathname =
|
|
45
|
+
const pathname = conversionService.scrubPathname(globalThis.location.origin, input.pathname);
|
|
46
46
|
if (pathname === null) return;
|
|
47
47
|
runInBackground(this.send("purchase", {
|
|
48
48
|
...input,
|
|
@@ -52,13 +52,6 @@ var ConversionClient = class {
|
|
|
52
52
|
hasMarketingConsent(input) {
|
|
53
53
|
return (input.marketingConsent ?? input.marketingCookie) === true;
|
|
54
54
|
}
|
|
55
|
-
/** Returns null outside the allowed domains or on a path of their exclusion list. */
|
|
56
|
-
getAllowedPathname(pathname) {
|
|
57
|
-
const { href, origin } = globalThis.location;
|
|
58
|
-
const domain = allowedDomains.find((allowedDomain) => href.startsWith(allowedDomain)) || debugDomainMap[origin];
|
|
59
|
-
if (!domain) return null;
|
|
60
|
-
return domainPathKeywordSuppressionMap[domain].some((keyword) => pathname.includes(keyword)) ? null : pathname;
|
|
61
|
-
}
|
|
62
55
|
async send(path, json, opt) {
|
|
63
56
|
try {
|
|
64
57
|
const res = await this.fetcher.doFetch({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _palette_default from "../../node_modules/.pnpm/@naturalcycles_ncuikit@1.
|
|
1
|
+
import _palette_default from "../../node_modules/.pnpm/@naturalcycles_ncuikit@1.17.0_react@19.3.1_undici@8.12.1/node_modules/@naturalcycles/ncuikit/dist/styles/_palette.js";
|
|
2
2
|
import fonts_default from "./fonts.js";
|
|
3
3
|
import general_default from "./general.js";
|
|
4
4
|
//#region src/cookie-monster/css/shared-sheets.ts
|
|
@@ -2,6 +2,6 @@ import type { StringMap } from '@naturalcycles/js-lib/types';
|
|
|
2
2
|
import { LANG } from '@naturalcycles/shared';
|
|
3
3
|
export interface Translations extends StringMap {
|
|
4
4
|
}
|
|
5
|
-
export declare const SUPPORTED_LANGUAGES: LANG[];
|
|
6
|
-
export declare function setLanguage(rawLang?:
|
|
5
|
+
export declare const SUPPORTED_LANGUAGES: (LANG.en_US | LANG.en_GB | LANG.es_US | LANG.pt_BR | LANG.sv_SE | LANG.de_DE | LANG.fr_FR | LANG.it_IT | LANG.da_DK | LANG.no_NO | LANG.fi_FI)[];
|
|
6
|
+
export declare function setLanguage(rawLang?: string): void;
|
|
7
7
|
export declare function tr(key: string, params?: Record<string, string>): string;
|
|
@@ -26,16 +26,16 @@ var translationsByLang = {
|
|
|
26
26
|
[LANG.no_NO]: no_NO_default
|
|
27
27
|
};
|
|
28
28
|
_objectKeys(translationsByLang);
|
|
29
|
-
var EN_US_FALLBACK_LANGS = /* @__PURE__ */ new Set([LANG.en_GB, LANG.en_CA]);
|
|
30
29
|
var TranslationsService = class {
|
|
31
30
|
copy = translationsByLang[langService.LANG_DEFAULT];
|
|
32
31
|
setLanguage(rawLang) {
|
|
33
|
-
const lang = langService.
|
|
34
|
-
const translations = translationsByLang[lang]
|
|
35
|
-
|
|
32
|
+
const lang = langService.toCookieMonsterLangOrUndefined(rawLang) ?? langService.LANG_DEFAULT;
|
|
33
|
+
const translations = translationsByLang[lang];
|
|
34
|
+
if (lang !== langService.LANG_DEFAULT && langService.isEnglish(lang)) this.copy = {
|
|
36
35
|
...translationsByLang[langService.LANG_DEFAULT],
|
|
37
36
|
...translations
|
|
38
|
-
}
|
|
37
|
+
};
|
|
38
|
+
else this.copy = translations;
|
|
39
39
|
}
|
|
40
40
|
tr(key, params) {
|
|
41
41
|
const translation = this.copy[key];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/@naturalcycles+ncuikit@1.
|
|
1
|
+
//#region ../../node_modules/.pnpm/@naturalcycles+ncuikit@1.17.0_react@19.3.1_undici@8.12.1/node_modules/@naturalcycles/ncuikit/dist/styles/_palette.css?inline
|
|
2
2
|
var _palette_default = "/**\n * Do not edit directly, this file was auto-generated.\n */\n\n:root {\n --color-purple-200: #f8f2f7;\n --color-purple-300: #edc4e6;\n --color-purple-400: #c377b4;\n --color-purple-500: #72035d;\n --color-purple-600: #560246;\n --color-purple-700: #3c0231;\n --color-purple-1000: #310629;\n --color-lavender-300: #ffcbff;\n --color-lavender-400: #fdabf5;\n --color-lavender-500: #f796ee;\n --color-lavender-600: #f471e8;\n --color-neue-blue-200: #e9f3ff;\n --color-neue-blue-250: #c9e0fd;\n --color-neue-blue-300: #9cbbff;\n --color-neue-blue-400: #709dff;\n --color-neue-blue-500: #3c6df0;\n --color-neue-blue-600: #204cc5;\n --color-neue-blue-700: #2547a7;\n --color-raspberry-300: #febfcf;\n --color-raspberry-400: #ed7f9d;\n --color-raspberry-500: #d71c5a;\n --color-raspberry-600: #c90d4b;\n --color-ink-100: rgba(26, 26, 26, 0.050980392156862744);\n --color-ink-200: rgba(26, 26, 26, 0.10196078431372549);\n --color-ink-300: #dedede;\n --color-ink-400: #a3a3a3;\n --color-ink-500: #757575;\n --color-ink-600: #5f5f5f;\n --color-ink-1000: #1a1a1a;\n --color-sand-50: rgba(252, 248, 248, 0.1607843137254902);\n --color-sand-100: #fcf8f8;\n --color-sand-300: #f8f2f2;\n --color-sand-500: #f3eeee;\n --color-sand-600: #e2d4d4;\n --color-sand-700: #d1c0c0;\n --color-white-100: rgba(255, 255, 255, 0.0784313725490196);\n --color-white-200: rgba(255, 255, 255, 0.1607843137254902);\n --color-white-1000: #ffffff;\n --color-green-50: rgba(243, 248, 236, 0.10196078431372549);\n --color-green-100: #f3f8ec;\n --color-green-300: #a0c95e;\n --color-green-500: #87b738;\n --color-green-600: #658d25;\n --color-red-50: rgba(252, 235, 235, 0.10196078431372549);\n --color-red-100: #fcebeb;\n --color-red-500: #ff7c7c;\n --color-red-600: #d83030;\n --color-orange-50: rgba(255, 244, 230, 0.10196078431372549);\n --color-orange-100: #f6d7b2;\n --color-orange-300: #ffa64d;\n --color-orange-500: #ff9000;\n --color-orange-700: #d16900;\n --color-orange-900: #65291f;\n --color-trackers-mood-100: rgba(255, 223, 92, 0.4);\n --color-trackers-mood-300: #fee996;\n --color-trackers-mood-500: #ffdf5c;\n --color-trackers-mood-600: #e0cb79;\n --color-trackers-pain-100: rgba(255, 154, 117, 0.4);\n --color-trackers-pain-300: #f39ab5;\n --color-trackers-pain-500: #ff9a75;\n --color-trackers-pain-600: #d57e98;\n --color-trackers-pain-700: #ac2e00;\n --color-trackers-lifestyle-100: rgba(166, 209, 166, 0.4);\n --color-trackers-lifestyle-300: #afd6af;\n --color-trackers-lifestyle-500: #a6d1a6;\n --color-trackers-lifestyle-600: #92b892;\n --color-trackers-lifestyle-700: #1a5c41;\n --color-trackers-external-factor-100: rgba(255, 184, 0, 0.4);\n --color-trackers-external-factor-300: #ffbf1a;\n --color-trackers-external-factor-500: #ffb800;\n --color-trackers-external-factor-600: #e0a200;\n --color-trackers-external-factor-700: #915f04;\n --color-trackers-skin-100: rgba(255, 146, 142, 0.4);\n --color-trackers-skin-300: #ff9d99;\n --color-trackers-skin-500: #ff928e;\n --color-trackers-skin-600: #e0807d;\n --color-trackers-skin-700: #b12a25;\n --color-trackers-sex-100: rgba(253, 144, 180, 0.4);\n --color-trackers-sex-300: #fd9bbc;\n --color-trackers-sex-500: #fd90b4;\n --color-trackers-sex-600: #df7f9e;\n --color-trackers-sex-700: #a93059;\n --color-trackers-tracker-500: #620d4e;\n --color-trackers-cervical-mucus-100: rgba(241, 150, 231, 0.4);\n --color-trackers-cervical-mucus-300: #dcb2ea;\n --color-trackers-cervical-mucus-500: #f196e7;\n --color-trackers-cervical-mucus-600: #be95cc;\n --color-trackers-cervical-mucus-700: #8f1f83;\n --color-trackers-bleeding-100: rgba(210, 148, 239, 0.4);\n --color-trackers-bleeding-300: #c48fd8;\n --color-trackers-bleeding-500: #d294ef;\n --color-trackers-bleeding-600: #a673bb;\n --color-trackers-excluded-500: #ff736f;\n --color-trackers-lh-test-100: rgba(141, 190, 255, 0.4);\n --color-trackers-lh-test-300: #98c5ff;\n --color-trackers-lh-test-500: #8dbeff;\n --color-trackers-lh-test-600: #7ca7e0;\n --color-trackers-lh-test-700: #16427b;\n --color-trackers-pregnancy-test-100: rgba(99, 164, 248, 0.4);\n --color-trackers-pregnancy-test-300: #73adf9;\n --color-trackers-pregnancy-test-500: #63a4f8;\n --color-trackers-pregnancy-test-600: #5790da;\n --color-trackers-pregnancy-test-700: #16427b;\n --color-trackers-sensitive-500: #e2d4d4;\n --color-trackers-sleep-100: rgba(171, 177, 210, 0.4);\n --color-trackers-sleep-300: #d1d5e6;\n --color-trackers-sleep-500: #abb1d2;\n --color-trackers-sleep-600: #8c91ad;\n --color-trackers-sleep-700: #4d5478;\n --color-trackers-breastfeeding-100: rgba(255, 205, 211, 0.4);\n --color-trackers-breastfeeding-300: #ffd2d7;\n --color-trackers-breastfeeding-500: #ffcdd3;\n --color-trackers-breastfeeding-600: #e0b4ba;\n --color-trackers-breastfeeding-700: #8f343f;\n --color-trackers-bottle-feeding-100: rgba(114, 214, 196, 0.4);\n --color-trackers-bottle-feeding-300: #80daca;\n --color-trackers-bottle-feeding-500: #72d6c4;\n --color-trackers-bottle-feeding-600: #64bcac;\n --color-trackers-bottle-feeding-700: #005a46;\n --color-trackers-pumping-100: rgba(255, 184, 0, 0.4);\n --color-trackers-pumping-300: #ffbf1a;\n --color-trackers-pumping-500: #ffb800;\n --color-trackers-pumping-600: #e0a200;\n --color-trackers-pumping-700: #915f04;\n --color-pale-purple-300: #512d4a;\n --color-pale-purple-500: #4a2d47;\n --color-pale-purple-700: #411a3a;\n --color-fertility-red-50: rgba(243, 59, 110, 0.5019607843137255); /** Peak Fertility */\n --color-fertility-red-100: #f3b6c7; /** Fertility unlikely */\n --color-fertility-red-200: #f590ad; /** Low Fertility */\n --color-fertility-red-500: #fb7598; /** Use Protection and Medium fertility */\n --color-fertility-red-800: #f15880; /** High Fertility */\n --color-fertility-red-900: #f74577; /** Very High Fertility */\n --color-fertility-red-1000: #f33b6e; /** Peak Fertility */\n --color-fertility-grey-500: #e8d2c6;\n --color-fertility-lavender-100: #f3e6f9;\n --color-fertility-lavender-500: #d294ef;\n --color-fertility-blue-500: #63a4f8;\n --color-fertility-green-600: #3ed08e;\n}\n";
|
|
3
3
|
//#endregion
|
|
4
4
|
export { _palette_default as default };
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"@naturalcycles/ncuikit": "^1",
|
|
12
12
|
"@playwright/test": "^1",
|
|
13
13
|
"@types/node": "^26",
|
|
14
|
-
"happy-dom": "^
|
|
14
|
+
"happy-dom": "^21",
|
|
15
15
|
"typescript": "^7",
|
|
16
16
|
"vite": "^8",
|
|
17
17
|
"vitest": "^5"
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
|
-
"version": "1.
|
|
45
|
+
"version": "1.6.0",
|
|
46
46
|
"description": "Internal web libraries for Natural Cycles, served via CDN and published from the NCBackend3 monorepo",
|
|
47
47
|
"author": "Natural Cycles Team",
|
|
48
48
|
"license": "UNLICENSED",
|