@naturalcycles/internal-web-lib 1.4.0 → 1.5.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/conversionClient.js +165 -134
- package/bundle/conversionClient.js.map +1 -1
- package/bundle/cookieMonster.js +98 -96
- package/bundle/cookieMonster.js.map +1 -1
- package/dist/conversion/conversionClient.d.ts +1 -13
- package/dist/conversion/conversionClient.js +3 -10
- package/package.json +1 -1
|
@@ -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({
|
package/package.json
CHANGED
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
|
-
"version": "1.
|
|
45
|
+
"version": "1.5.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",
|