@takeal/cusfront-sdk 0.6.8 → 0.6.14
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/CHANGELOG.md +112 -2
- package/README.md +26 -9
- package/dist/analytics.cjs +44 -6
- package/dist/analytics.cjs.map +1 -1
- package/dist/analytics.js +44 -6
- package/dist/analytics.js.map +1 -1
- package/dist/{cards-BgY00UpU.d.ts → cards-DPlgx76p.d.ts} +86 -18
- package/dist/{cards-DGz4Rqu1.d.cts → cards-D_krTWzr.d.cts} +86 -18
- package/dist/index.cjs +225 -93
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +221 -94
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.cts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/resources/attribution.cjs +99 -4
- package/dist/resources/attribution.cjs.map +1 -1
- package/dist/resources/attribution.d.cts +58 -1
- package/dist/resources/attribution.d.ts +58 -1
- package/dist/resources/attribution.js +96 -5
- package/dist/resources/attribution.js.map +1 -1
- package/dist/resources/auth.cjs +64 -3
- package/dist/resources/auth.cjs.map +1 -1
- package/dist/resources/auth.d.cts +1 -1
- package/dist/resources/auth.d.ts +1 -1
- package/dist/resources/auth.js +64 -3
- package/dist/resources/auth.js.map +1 -1
- package/dist/resources/cards.cjs +69 -7
- package/dist/resources/cards.cjs.map +1 -1
- package/dist/resources/cards.d.cts +2 -1
- package/dist/resources/cards.d.ts +2 -1
- package/dist/resources/cards.js +69 -8
- package/dist/resources/cards.js.map +1 -1
- package/dist/resources/codes.cjs.map +1 -1
- package/dist/resources/codes.d.cts +21 -1
- package/dist/resources/codes.d.ts +21 -1
- package/dist/resources/codes.js.map +1 -1
- package/dist/resources/consents.cjs +15 -0
- package/dist/resources/consents.cjs.map +1 -1
- package/dist/resources/consents.js +15 -0
- package/dist/resources/consents.js.map +1 -1
- package/dist/resources/deposits.cjs +50 -0
- package/dist/resources/deposits.cjs.map +1 -1
- package/dist/resources/deposits.d.cts +2 -1
- package/dist/resources/deposits.d.ts +2 -1
- package/dist/resources/deposits.js +50 -0
- package/dist/resources/deposits.js.map +1 -1
- package/dist/resources/funding-options.d.cts +2 -1
- package/dist/resources/funding-options.d.ts +2 -1
- package/dist/resources/me.d.cts +1 -1
- package/dist/resources/me.d.ts +1 -1
- package/dist/telegram.cjs +224 -73
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.d.cts +34 -3
- package/dist/telegram.d.ts +34 -3
- package/dist/telegram.js +224 -74
- package/dist/telegram.js.map +1 -1
- package/package.json +4 -4
package/dist/analytics.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/analytics.ts"],"names":[],"mappings":";AA0BO,IAAM,gBAAA,GAAmB;AAAA,EAC9B,gBAAA;AAAA,EACA,kBAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,iBAAA;AAAA,EACA,mBAAA;AAAA,EACA,gBAAA;AAAA,EACA,aAAA;AAAA,EACA,mBAAA;AAAA,EACA,gBAAA;AAAA,EACA,gBAAA;AAAA,EACA,kBAAA;AAAA,EACA,aAAA;AAAA,EACA,eAAA;AAAA,EACA,iBAAA;AAAA,EACA,aAAA;AAAA,EACA,cAAA;AAAA,EACA,sBAAA;AAAA,EACA,sBAAA;AAAA,EACA,wBAAA;AAAA,EACA,aAAA;AAAA,EACA;AACF;AAMO,IAAM,aAAA,GAA2C,CAAC,gBAAA,EAAkB,kBAAkB;AAUtF,IAAM,gBAAA,GAAmB;AAwDhC,IAAM,IAAA,GAAO,gEAAA;AACb,IAAM,KAAA,GAAQ,gDAAA;AAGd,IAAM,SAAA,GAAY,wBAAA;AAClB,IAAM,SAAA,GAAY,iEAAA;AAIlB,SAAS,KAAK,CAAA,EAAoB;AAChC,EAAA,OACE,OAAA,CAAQ,KAAK,CAAC,CAAA,IACd,UAAU,IAAA,CAAK,CAAC,CAAA,IA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IAAA,IAAQ,KAAA,CAAM,CAAC,CAAA,OAAQ,KAAA,EAAM;AAC1C;AAKA,eAAsB,iBAAA,CAAkB,YAAY,GAAA,EAAmC;AACrF,EAAA,MAAM,KAAA,GAAQ,KAAA,EAAM,EAAG,OAAA,EAAS,KAAA;AAChC,EAAA,IAAI,CAAC,OAAO,OAAO,MAAA;AACnB,EAAA,IAAI,KAAA;AACJ,EAAA,MAAM,OAAA,GAAU,IAAI,OAAA,CAAmB,CAAC,CAAA,KAAM;AAC5C,IAAA,KAAA,GAAQ,UAAA,CAAW,GAAG,SAAS,CAAA;AAAA,EACjC,CAAC,CAAA;AACD,EAAA,MAAM,KAAK,MAAM,OAAA,CAAQ,KAAK,CAAC,KAAA,EAAO,OAAO,CAAC,CAAA;AAC9C,EAAA,YAAA,CAAa,KAAK,CAAA;AAClB,EAAA,IAAI;AACF,IAAA,OAAO,EAAA,EAAI,iBAAgB,IAAK,KAAA,CAAA;AAAA,EAClC,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,MAAA;AAAA,EACT;AACF;AAGO,SAAS,uBAAA,GAAgC;AAC9C,EAAA,MAAA,CAAO,GAAG,CAAA,GAAI,MAAA;AAChB","file":"analytics.js","sourcesContent":["/**\n * `@takeal/cusfront-sdk/analytics` — one event layer for product analytics.\n *\n * The app calls {@link track} once per event; the layer hands it to every\n * configured system: PostHog everywhere, Yandex Metrica only on public pages\n * and only for the sign-up goals (what happens behind the login reaches\n * Metrica from the server, not from the browser). Every event passes\n * {@link sanitizeProperties} on the way out, PostHog's own autocapture\n * included.\n *\n * Nothing is bundled: PostHog comes from the app's own `posthog-js` (pass\n * `posthog.load`) or from its script on the configured host, Metrica from\n * its tag script. Both load only when `initAnalytics` asks for them.\n *\n * ```ts\n * initAnalytics({ zone: \"public\", posthog: { key, host: \"https://example.com/ingest\" }, metrika: { counterId: 12345678 } });\n * track(\"signup_started\");\n * ```\n */\n\n/** Where the page lives. Decides what is captured and what is masked. */\nexport type AnalyticsZone = \"public\" | \"cabinet\" | \"miniapp\";\n\n/** Every event name the layer accepts. The first two come from the browser\n * on public pages; the rest match the event types of the platform's\n * `analytics_events` view, so a report reads the same names on both sides. */\nexport const ANALYTICS_EVENTS = [\n \"signup_started\",\n \"signup_completed\",\n \"signup\",\n \"login\",\n \"deposit_started\",\n \"deposit_confirmed\",\n \"deposit_failed\",\n \"card_issued\",\n \"card_issue_failed\",\n \"card_activated\",\n \"card_topped_up\",\n \"card_transferred\",\n \"card_frozen\",\n \"card_unfrozen\",\n \"card_terminated\",\n \"txn_cleared\",\n \"txn_declined\",\n \"subscription_started\",\n \"subscription_renewed\",\n \"subscription_cancelled\",\n \"fee_charged\",\n \"refund_issued\",\n] as const;\n\nexport type AnalyticsEvent = (typeof ANALYTICS_EVENTS)[number];\n\n/** Events that also go to Metrica as goals, from public pages only. Deposits,\n * cards and subscriptions reach Metrica from the server with their value. */\nexport const METRIKA_GOALS: readonly AnalyticsEvent[] = [\"signup_started\", \"signup_completed\"];\n\ntype Primitive = string | number | boolean | null | undefined;\nexport type AnalyticsProperties = Record<string, Primitive | Primitive[]>;\n\n/**\n * Mark a block that must never be recorded or autocaptured: card details,\n * balances, the operations history. PostHog honours this class in\n * autocapture and in session recordings.\n */\nexport const NO_CAPTURE_CLASS = \"ph-no-capture\";\n\n/** The subset of the `posthog-js` instance the layer uses. */\nexport interface PostHogLike {\n init(key: string, config: Record<string, unknown>): unknown;\n capture(event: string, properties?: Record<string, unknown>): unknown;\n identify(distinctId: string): unknown;\n reset(): unknown;\n get_distinct_id(): string;\n register(properties: Record<string, unknown>): unknown;\n set_config(config: Record<string, unknown>): unknown;\n startSessionRecording?(): unknown;\n stopSessionRecording?(): unknown;\n}\n\nexport interface PostHogOptions {\n /** Project key (`phc_…`). Write-only, safe in the browser. */\n key: string;\n /** Where events go. Point it at the proxy path on your own domain, e.g.\n * `https://example.com/ingest`. Default `https://eu.i.posthog.com`. */\n host?: string;\n /** PostHog's own app, for links from the toolbar. Default `https://eu.posthog.com`. */\n uiHost?: string;\n /** Where the script comes from when `load` is not given. Default: the\n * `-assets` twin of a PostHog host, or `host` itself for a proxy. */\n assetsHost?: string;\n /** Return the app's own `posthog-js` instance, usually\n * `() => import(\"posthog-js\").then((m) => m.default)` (1.187 or later).\n * Without it the script is loaded from `assetsHost`. */\n load?: () => Promise<PostHogLike>;\n /** Record sessions in the cabinet and the Mini App, masked. Off by\n * default; turn it on only after checking a recording shows no values.\n * Never recorded on public pages. */\n sessionRecording?: boolean;\n}\n\nexport interface MetrikaOptions {\n counterId: number | string;\n /** Tag script address. Default `https://mc.yandex.ru/metrika/tag.js`. */\n scriptUrl?: string;\n}\n\nexport interface AnalyticsOptions {\n zone: AnalyticsZone;\n posthog?: PostHogOptions;\n /** Used on public pages only; ignored in the cabinet and the Mini App. */\n metrika?: MetrikaOptions;\n /** Send the first page view right away. Default `true`; after that call\n * {@link page} on every route change. */\n initialPageview?: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// The filter on the way out\n// ---------------------------------------------------------------------------\n\nconst UUID = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi;\nconst EMAIL = /[^\\s@\"'<>(),;:]+@[^\\s@\"'<>(),;:]+\\.[a-z]{2,}/gi;\n/** A run of digits with phone or card separators: 9 to 19 digits is a phone\n * or a card number, never something to send. */\nconst DIGIT_RUN = /\\+?\\d[\\d\\s().-]{7,}\\d/g;\nconst UUID_ONLY = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n/** A path segment or a query value that is an id: a number, a UUID, a hex\n * string, or a long token of letters and digits. Slugs have dashes and\n * stay, even with a year in them. */\nfunction isId(v: string): boolean {\n return (\n /^\\d+$/.test(v) ||\n UUID_ONLY.test(v) ||\n /^[0-9a-f]{16,}$/i.test(v) ||\n (/^[A-Za-z0-9_]{20,}$/.test(v) && /\\d.*\\d/.test(v) && /[A-Za-z].*[A-Za-z]/.test(v))\n );\n}\nconst PLACEHOLDER = \":id\";\n\n/** Keys whose value is personal whatever it looks like: any key with one of\n * these words... */\nconst PERSONAL_WORDS = new Set([\n \"email\",\n \"mail\",\n \"phone\",\n \"tel\",\n \"telephone\",\n \"mobile\",\n \"msisdn\",\n \"surname\",\n \"patronymic\",\n \"firstname\",\n \"lastname\",\n \"fullname\",\n \"username\",\n \"nickname\",\n]);\n/** ...and `name` alone or after one of these (`first_name`, `holder_name`).\n * `merchant_name` names a company and stays. */\nconst PERSON_NAME_QUALIFIERS = new Set([\n \"first\",\n \"last\",\n \"full\",\n \"user\",\n \"display\",\n \"given\",\n \"family\",\n \"middle\",\n \"nick\",\n \"real\",\n \"holder\",\n \"cardholder\",\n \"customer\",\n \"contact\",\n \"person\",\n \"owner\",\n \"account\",\n \"legal\",\n]);\n/** Query keys that carry secrets or personal data. */\nconst SECRET_QUERY_WORDS = new Set([\n \"token\",\n \"code\",\n \"key\",\n \"secret\",\n \"password\",\n \"pass\",\n \"pwd\",\n \"otp\",\n \"sig\",\n \"signature\",\n \"session\",\n \"sid\",\n \"auth\",\n \"jwt\",\n \"pan\",\n \"cvv\",\n \"cvc\",\n \"iban\",\n]);\n/** Money is not personal: kept as it is. */\nconst MONEY_KEYS = new Set([\n \"amount\",\n \"amount_minor\",\n \"currency\",\n \"value\",\n \"price\",\n \"revenue\",\n \"sum\",\n]);\n\nfunction words(key: string): string[] {\n return key\n .replace(/^\\$+/, \"\")\n .replace(/([a-z])([A-Z])/g, \"$1_$2\")\n .toLowerCase()\n .split(/[^a-z0-9]+/)\n .filter(Boolean);\n}\n\nfunction personalKey(key: string): boolean {\n const w = words(key);\n const joined = w.join(\"\");\n if (joined.includes(\"email\") || joined.includes(\"phone\")) return true;\n if (w.some((x) => PERSONAL_WORDS.has(x)) || PERSONAL_WORDS.has(joined)) return true;\n // PostHog's own `$…` keys are never names of people.\n if (key.startsWith(\"$\")) return false;\n return w.some(\n (x, i) => x === \"name\" && (w.length === 1 || PERSON_NAME_QUALIFIERS.has(w[i - 1] ?? \"\")),\n );\n}\n\nfunction urlKey(key: string): boolean {\n const k = key.replace(/^\\$+/, \"\").toLowerCase();\n return (\n /(^|_)(url|href|pathname|path|referrer|referer)$/.test(k) ||\n k === \"page\" ||\n k.startsWith(\"attr__href\")\n );\n}\n\nfunction digitCount(s: string): number {\n return s.replace(/\\D/g, \"\").length;\n}\n\n/** Text with e-mail addresses, phone and card numbers cut out. */\nfunction redactText(v: string): string {\n return v\n .replace(EMAIL, \"[email]\")\n .replace(DIGIT_RUN, (m) => (digitCount(m) >= 9 && digitCount(m) <= 19 ? \"[number]\" : m));\n}\n\nfunction idSegment(seg: string): string {\n let s = seg;\n try {\n s = decodeURIComponent(seg);\n } catch {\n // Leave a broken escape as it is.\n }\n if (isId(s)) return PLACEHOLDER;\n const replaced = s.replace(UUID, PLACEHOLDER);\n if (replaced !== s) return replaced;\n return redactText(s) === s ? seg : PLACEHOLDER;\n}\n\n/**\n * A page address fit to send: UUIDs, numeric ids and long tokens in the\n * path become `:id`; query parameters that carry secrets or personal data\n * are dropped, ids among their values become `:id`; the fragment is dropped.\n * Campaign tags stay.\n */\nexport function sanitizeUrl(raw: string): string {\n const absolute = /^[a-z][a-z0-9+.-]*:\\/\\//i.test(raw);\n let u: URL;\n try {\n u = new URL(raw, \"http://relative.invalid\");\n } catch {\n return redactText(raw.split(/[?#]/)[0] ?? \"\").replace(UUID, PLACEHOLDER);\n }\n const path = u.pathname\n .split(\"/\")\n .map((seg) => (seg ? idSegment(seg) : seg))\n .join(\"/\");\n const query: string[] = [];\n u.searchParams.forEach((value, key) => {\n const k = words(key);\n if (k.some((w) => SECRET_QUERY_WORDS.has(w)) || personalKey(key)) return;\n if (redactText(value) !== value) return;\n query.push(\n `${encodeURIComponent(key)}=${isId(value) ? PLACEHOLDER : encodeURIComponent(value)}`,\n );\n });\n const search = query.length ? `?${query.join(\"&\")}` : \"\";\n return (absolute ? `${u.protocol}//${u.host}` : \"\") + path + search;\n}\n\nfunction cleanValue(key: string, v: unknown, depth: number): unknown {\n if (v === null || v === undefined || typeof v === \"number\" || typeof v === \"boolean\") return v;\n if (typeof v === \"string\") {\n // Money, and whole ids such as PostHog's session and device ids.\n if (MONEY_KEYS.has(key.toLowerCase()) || UUID_ONLY.test(v)) return v;\n if (urlKey(key) || /^https?:\\/\\//i.test(v)) return sanitizeUrl(v);\n if (key === \"$elements_chain\") {\n return redactText(v).replace(\n /attr__href=\"([^\"]*)\"/g,\n (_, h: string) => `attr__href=\"${sanitizeUrl(h)}\"`,\n );\n }\n const r = redactText(v);\n // A value that was nothing but an address or a number goes entirely.\n return r.replace(/\\[(email|number)\\]/g, \"\").trim() === \"\" && r !== v ? undefined : r;\n }\n if (depth > 5) return undefined;\n if (Array.isArray(v))\n return v.map((x) => cleanValue(key, x, depth + 1)).filter((x) => x !== undefined);\n if (typeof v === \"object\") return sanitizeProperties(v as Record<string, unknown>, depth + 1);\n return undefined;\n}\n\n/**\n * The filter every event passes before it leaves the browser. Drops keys\n * that name personal data (`email`, `phone`, `name`, `first_name`, …) and\n * values that look like an e-mail address, a phone or a card number; page\n * addresses go through {@link sanitizeUrl}. Amounts and currencies pass.\n */\nexport function sanitizeProperties<T extends Record<string, unknown>>(\n props: T,\n depth = 0,\n): Partial<T> {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(props)) {\n if (personalKey(k)) continue;\n const c = cleanValue(k, v, depth);\n if (c !== undefined) out[k] = c;\n }\n return out as Partial<T>;\n}\n\n/** PostHog's `before_send`: the same filter for what PostHog captures by itself. */\nfunction beforeSend<\n E extends {\n properties?: Record<string, unknown>;\n $set?: Record<string, unknown>;\n $set_once?: Record<string, unknown>;\n },\n>(event: E | null): E | null {\n if (!event) return event;\n const out = { ...event };\n if (event.properties) out.properties = sanitizeProperties(event.properties);\n if (event.$set) out.$set = sanitizeProperties(event.$set);\n if (event.$set_once) out.$set_once = sanitizeProperties(event.$set_once);\n return out;\n}\n\n// ---------------------------------------------------------------------------\n// Systems. A new one is a Sink plus a line in `sinksFor`.\n// ---------------------------------------------------------------------------\n\ninterface Sink {\n capture(event: AnalyticsEvent, props: AnalyticsProperties): void;\n page(url: string, referrer: string | undefined): void;\n identify(userId: string): void;\n reset(): void;\n setZone(zone: AnalyticsZone): void;\n}\n\ninterface Win {\n document?: Document;\n location?: Location;\n posthog?: unknown;\n ym?: ((...args: unknown[]) => void) & { a?: unknown[]; l?: number };\n}\n\nconst win = () => globalThis as unknown as Win;\n\nfunction injectScript(src: string, onLoad?: () => void, onError?: () => void): void {\n const doc = win().document;\n if (!doc) return;\n const s = doc.createElement(\"script\");\n s.async = true;\n s.src = src;\n s.crossOrigin = \"anonymous\";\n if (onLoad) s.addEventListener(\"load\", onLoad);\n if (onError) s.addEventListener(\"error\", onError);\n (doc.head ?? doc.documentElement).appendChild(s);\n}\n\nfunction posthogConfig(zone: AnalyticsZone, o: PostHogOptions): Record<string, unknown> {\n const host = (o.host ?? \"https://eu.i.posthog.com\").replace(/\\/+$/, \"\");\n const base: Record<string, unknown> = {\n api_host: host,\n ui_host: o.uiHost ?? \"https://eu.posthog.com\",\n // Profiles for signed-in users only.\n person_profiles: \"identified_only\",\n // Page views go through `page()`, with a cleaned address.\n capture_pageview: false,\n capture_pageleave: true,\n before_send: beforeSend,\n };\n return { ...base, ...zoneConfig(zone, o) };\n}\n\n/** What changes with the zone. Applied at init and on `setAnalyticsZone`. */\nfunction zoneConfig(zone: AnalyticsZone, o: PostHogOptions): Record<string, unknown> {\n if (zone === \"public\") {\n return {\n autocapture: true,\n mask_all_text: false,\n mask_all_element_attributes: false,\n enable_heatmaps: true,\n disable_session_recording: true,\n };\n }\n return {\n // A click is \"the third button in the cards block\", never its label.\n autocapture: { capture_copied_text: false },\n mask_all_text: true,\n mask_all_element_attributes: true,\n enable_heatmaps: false,\n disable_session_recording: !o.sessionRecording,\n session_recording: {\n maskAllInputs: true,\n maskTextSelector: \"*\",\n blockClass: NO_CAPTURE_CLASS,\n },\n };\n}\n\nfunction assetsHost(o: PostHogOptions): string {\n if (o.assetsHost) return o.assetsHost.replace(/\\/+$/, \"\");\n const host = (o.host ?? \"https://eu.i.posthog.com\").replace(/\\/+$/, \"\");\n return host.replace(\".i.posthog.com\", \"-assets.i.posthog.com\");\n}\n\n/** Load posthog-js the way its own snippet does: a placeholder that the\n * script replaces with the instance once it runs. */\nfunction loadPostHogScript(\n o: PostHogOptions,\n config: Record<string, unknown>,\n): Promise<PostHogLike | undefined> {\n return new Promise((resolve) => {\n const w = win();\n if (!w.document) return resolve(undefined);\n const placeholder = Object.assign([] as unknown[], {\n __SV: 1,\n _i: [[o.key, config, \"posthog\"]],\n });\n w.posthog = placeholder;\n injectScript(\n `${assetsHost(o)}/static/array.js`,\n () => {\n const ph = w.posthog;\n const live =\n ph !== placeholder && typeof (ph as PostHogLike | undefined)?.capture === \"function\";\n resolve(live ? (ph as PostHogLike) : undefined);\n },\n () => resolve(undefined),\n );\n });\n}\n\nclass PostHogSink implements Sink {\n readonly ready: Promise<PostHogLike | undefined>;\n\n constructor(\n private readonly o: PostHogOptions,\n zone: AnalyticsZone,\n ) {\n const config = posthogConfig(zone, o);\n this.ready = (\n o.load\n ? o.load().then((ph) => {\n ph.init(o.key, config);\n return ph;\n })\n : loadPostHogScript(o, config)\n )\n .then((ph) => {\n ph?.register({ zone });\n return ph;\n })\n .catch(() => undefined);\n }\n\n private with(fn: (ph: PostHogLike) => void): void {\n void this.ready.then((ph) => ph && fn(ph));\n }\n\n capture(event: AnalyticsEvent, props: AnalyticsProperties): void {\n this.with((ph) => ph.capture(event, props));\n }\n page(url: string, referrer: string | undefined): void {\n const props: Record<string, unknown> = { $current_url: url };\n if (referrer) props.$referrer = referrer;\n this.with((ph) => ph.capture(\"$pageview\", props));\n }\n identify(userId: string): void {\n this.with((ph) => ph.identify(userId));\n }\n reset(): void {\n this.with((ph) => ph.reset());\n }\n setZone(zone: AnalyticsZone): void {\n this.with((ph) => {\n ph.set_config(zoneConfig(zone, this.o));\n ph.register({ zone });\n if (zone === \"public\" || !this.o.sessionRecording) ph.stopSessionRecording?.();\n else ph.startSessionRecording?.();\n });\n }\n}\n\n/** Metrica, public pages only. It never records on its own: no Webvisor, no\n * click map, no automatic page views. It sees exactly what this layer\n * sends, and falls silent when the zone leaves `public`. */\nclass MetrikaSink implements Sink {\n private live = true;\n private readonly id: number;\n\n constructor(o: MetrikaOptions) {\n this.id = Number(o.counterId);\n const w = win();\n if (!w.ym) {\n const ym = ((...args: unknown[]) => {\n (ym.a = ym.a ?? []).push(args);\n }) as NonNullable<Win[\"ym\"]>;\n ym.l = Date.now();\n w.ym = ym;\n injectScript(o.scriptUrl ?? \"https://mc.yandex.ru/metrika/tag.js\");\n }\n this.ym(\"init\", {\n defer: true,\n webvisor: false,\n clickmap: false,\n trackLinks: false,\n accurateTrackBounce: true,\n });\n }\n\n private ym(...args: unknown[]): void {\n if (this.live) win().ym?.(this.id, ...args);\n }\n\n capture(event: AnalyticsEvent, props: AnalyticsProperties): void {\n if (METRIKA_GOALS.includes(event)) this.ym(\"reachGoal\", event, props);\n }\n page(url: string, referrer: string | undefined): void {\n this.ym(\"hit\", url, referrer ? { referer: referrer } : {});\n }\n identify(userId: string): void {\n // The same id the server sends with its conversions.\n this.ym(\"setUserID\", userId);\n }\n reset(): void {}\n setZone(zone: AnalyticsZone): void {\n this.live = zone === \"public\";\n }\n}\n\n// ---------------------------------------------------------------------------\n// State, kept on globalThis: every sub-export bundles its own copy of this\n// file, and they must all talk to one set of systems.\n// ---------------------------------------------------------------------------\n\ninterface State {\n options: AnalyticsOptions;\n zone: AnalyticsZone;\n posthog?: PostHogSink;\n metrika?: MetrikaSink;\n lastPage?: string;\n userId?: string;\n}\n\nconst KEY = Symbol.for(\"takeal.cusfront-sdk.analytics\");\nconst holder = globalThis as unknown as Record<symbol, State | undefined>;\nconst state = (): State | undefined => holder[KEY];\n\nfunction sinks(s: State): Sink[] {\n // Metrica loads the first time the page is public, and never before.\n if (s.zone === \"public\" && s.options.metrika && !s.metrika) {\n s.metrika = new MetrikaSink(s.options.metrika);\n if (s.userId) s.metrika.identify(s.userId);\n }\n return [s.posthog, s.metrika].filter((x): x is PostHogSink | MetrikaSink => !!x);\n}\n\n/**\n * Start analytics for this page. Call once, as early as possible. A second\n * call does nothing; to move between the site and the cabinet in one app,\n * use {@link setAnalyticsZone}.\n */\nexport function initAnalytics(options: AnalyticsOptions): void {\n if (state() || !win().document) return;\n if (options.zone !== \"public\" && win().ym) {\n console.warn(\n \"[analytics] Yandex Metrica is on a page outside the public zone; it must not be.\",\n );\n }\n const s: State = { options, zone: options.zone };\n holder[KEY] = s;\n if (options.posthog?.key) s.posthog = new PostHogSink(options.posthog, options.zone);\n sinks(s);\n if (options.initialPageview !== false) page();\n}\n\n/**\n * The page moved to another zone without a reload (the site and the cabinet\n * in one app). PostHog switches its masking; Metrica falls silent outside\n * public pages. A full page load into the cabinet is safer still: Metrica is\n * then never on the page at all.\n */\nexport function setAnalyticsZone(zone: AnalyticsZone): void {\n const s = state();\n if (!s || s.zone === zone) return;\n s.zone = zone;\n for (const sink of sinks(s)) sink.setZone(zone);\n}\n\n/** Record an event. The name must be one of {@link ANALYTICS_EVENTS}. */\nexport function track(event: AnalyticsEvent, props: AnalyticsProperties = {}): void {\n const s = state();\n if (!s || !(ANALYTICS_EVENTS as readonly string[]).includes(event)) return;\n const clean = sanitizeProperties(props) as AnalyticsProperties;\n for (const sink of sinks(s)) sink.capture(event, clean);\n}\n\n/** A page view. Call it on every route change; the same address twice in a\n * row counts once. Takes the current address when none is given. */\nexport function page(url?: string): void {\n const s = state();\n const w = win();\n const raw = url ?? w.location?.href;\n if (!s || !raw) return;\n const clean = sanitizeUrl(raw);\n if (clean === s.lastPage) return;\n const referrer =\n s.lastPage ?? (w.document?.referrer ? sanitizeUrl(w.document.referrer) : undefined);\n s.lastPage = clean;\n for (const sink of sinks(s)) sink.page(clean, referrer);\n}\n\n/** After sign-in: tie this browser to the user by the platform's user id\n * (`session.user.id`), never by e-mail. Only signed-in users get profiles. */\nexport function identify(userId: string): void {\n const s = state();\n if (!s || !userId) return;\n s.userId = userId;\n for (const sink of sinks(s)) sink.identify(userId);\n}\n\n/** On sign-out: forget the user, so the next person on this device starts\n * as a new visitor. */\nexport function resetAnalytics(): void {\n const s = state();\n if (!s) return;\n s.userId = undefined;\n for (const sink of sinks(s)) sink.reset();\n}\n\n/** PostHog's id for this browser, for `auth.register({ attribution: {\n * posthog_distinct_id } })`. Waits for PostHog to load, `timeoutMs` at\n * most; `undefined` without PostHog. */\nexport async function posthogDistinctId(timeoutMs = 3000): Promise<string | undefined> {\n const ready = state()?.posthog?.ready;\n if (!ready) return undefined;\n let timer: Parameters<typeof clearTimeout>[0];\n const timeout = new Promise<undefined>((r) => {\n timer = setTimeout(r, timeoutMs);\n });\n const ph = await Promise.race([ready, timeout]);\n clearTimeout(timer);\n try {\n return ph?.get_distinct_id() || undefined;\n } catch {\n return undefined;\n }\n}\n\n/** For tests: forget everything `initAnalytics` set up. */\nexport function _resetAnalyticsForTests(): void {\n holder[KEY] = undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/resources/attribution.ts","../src/analytics.ts"],"names":["clean"],"mappings":";AAwPA,IAAM,OAAA,GAAU,sBAAA;AAEhB,SAAS,OAAA,GAA+B;AACtC,EAAA,IAAI;AACF,IAAA,OAAQ,UAAA,CAA0C,YAAA;AAAA,EACpD,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,MAAA;AAAA,EACT;AACF;AAEA,SAAS,MAAA,GAAuB;AAC9B,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,OAAA,EAAQ,EAAG,OAAA,CAAQ,OAAO,CAAA;AACtC,IAAA,MAAM,IAAI,GAAA,GAAO,IAAA,CAAK,KAAA,CAAM,GAAG,IAAqB,EAAC;AACrD,IAAA,OAAO,OAAO,CAAA,KAAM,QAAA,IAAY,CAAA,KAAM,IAAA,GAAO,IAAI,EAAC;AAA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CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,MAAA;AAAA,EACT;AACF;AAGO,SAAS,uBAAA,GAAgC;AAC9C,EAAA,MAAA,CAAO,GAAG,CAAA,GAAI,MAAA;AAChB","file":"analytics.js","sourcesContent":["import type { HttpClient } from \"../http.js\";\n\n/**\n * Attribution resource — `client.attribution.*`: where users come from.\n *\n * Send a touch on page load ({@link AttributionResource.touch}); the\n * platform keeps the visits that bring something new (campaign tags, a\n * click id, a referrer from another site, a Telegram code, the first visit\n * from this browser) under the visitor's anonymous key. Pass the same key\n * to `auth.register({ attribution })` and the new account is credited with\n * those visits. After sign-up, ask \"how did you hear about us\" once\n * ({@link AttributionResource.status}, {@link AttributionResource.answerSurvey}).\n *\n * ```ts\n * const key = anonymousKey();\n * await client.attribution.touch({ anonymous_key: key, ...currentTouch() });\n * // …later, in the sign-up form:\n * await client.auth.register({ email, password, attribution: { anonymous_key: key } });\n * ```\n */\n\n/** A visit as the browser saw it. {@link currentTouch} fills it from the page. */\nexport interface TouchFields {\n /** Full address of the landing page, query included. Tags and click ids\n * are read from it; anything that looks like an e-mail address, a phone\n * number or a secret is dropped on the server. */\n url?: string;\n /** `document.referrer`; leave out or empty for none. */\n referrer?: string;\n /** The code of a Telegram link to the bot or the Mini App. */\n campaign_code?: string;\n /** `web`, `miniapp` or `app`. Taken from the client's platform when left out. */\n platform?: \"web\" | \"miniapp\" | \"app\";\n /** When the visit happened, ISO 8601, for a touch sent later. Defaults to now. */\n occurred_at?: string;\n /** Yandex Metrica client id (`_ym_uid` cookie). */\n metrika_client_id?: string;\n /** Google Analytics client id (from the `_ga` cookie). */\n ga_client_id?: string;\n}\n\nexport interface TouchInput extends TouchFields {\n /** The visitor's anonymous id, see {@link anonymousKey}. */\n anonymous_key: string;\n}\n\nexport interface TouchResult {\n /** `false` when the visit brought nothing new or the visitor already has fifty touches. */\n recorded: boolean;\n}\n\n/** Sent with `auth.register` and `auth.exchangeTelegram`. */\nexport interface SignupAttribution {\n /** The key the touches were sent with. Ignored in the Mini App, where the\n * Telegram id is the key. */\n anonymous_key?: string;\n /** The first touch this browser kept. Used only when none of its touches\n * reached the server (a blocker, a flaky network). */\n first_touch?: TouchFields;\n /** The last touch before sign-up, on the same terms. */\n last_touch?: TouchFields;\n metrika_client_id?: string;\n ga_client_id?: string;\n /** PostHog distinct id, so a report can open the session recording. */\n posthog_distinct_id?: string;\n}\n\nexport type SurveyAnswer =\n \"friend\" | \"telegram_channel\" | \"search\" | \"ads\" | \"review\" | \"other\" | \"skipped\";\n\n/**\n * The visitor's ids at the analytics platforms (TKL-329). The SDK keeps\n * them from the moment the visitor agreed to analytics cookies and sends\n * them with an order, a top-up and a sign-in, so the server can report the\n * payment and the issued card to the platforms after the person has left\n * for the bank or Telegram. See {@link analyticsIds}.\n */\nexport interface AnalyticsIds {\n /** Yandex Metrica's ClientID, from `getClientID`. A string: it does not fit a number. */\n metrika_client_id?: string;\n /** Google Analytics' client id, from the `_ga` cookie: `1234567890.1700000000`. */\n ga_client_id?: string;\n}\n\nexport interface HandoffToken {\n /** Goes into the Mini App link's `startapp` after two underscores. */\n token: string;\n expires_at: string;\n}\n\nexport interface AttributionStatus {\n /** `true` while the app should ask \"how did you hear about us\". */\n survey_pending: boolean;\n /** The answer given, `skipped`, or `null`. */\n survey_answer: SurveyAnswer | null;\n}\n\nexport class AttributionResource {\n constructor(private readonly http: HttpClient) {}\n\n /** Record a visit. No session needed; safe to call on every page load. */\n async touch(input: TouchInput): Promise<TouchResult> {\n return this.http.post<TouchResult>(\"/attribution/touches\", { body: input, skipAuth: true });\n }\n\n /** A one-day token that carries the visitor's analytics ids into the\n * Telegram Mini App, whose sign-in reads it back. Most callers want\n * {@link AttributionResource.telegramStartParam}. Errors: 400 when none of\n * the ids is valid. */\n async handoff(ids: AnalyticsIds): Promise<HandoffToken> {\n return this.http.post<HandoffToken>(\"/attribution/handoff\", { body: ids, skipAuth: true });\n }\n\n /**\n * The `startapp` value for a link from the site to the Mini App: the code\n * as it is, followed by `__<token>` when the visitor has analytics ids, so\n * a payment made in Telegram is still credited to the visit it came from.\n * Without ids, or when the token can't be had, just the code.\n *\n * ```ts\n * const start = await client.attribution.telegramStartParam(\"SPRING\");\n * location.href = `https://t.me/our_bot/app?startapp=${start}`;\n * ```\n */\n async telegramStartParam(code = \"\"): Promise<string> {\n const ids = analyticsIds();\n if (!ids) return code;\n try {\n const { token } = await this.handoff(ids);\n return `${code}__${token}`;\n } catch {\n return code;\n }\n }\n\n /** Send the visitor's analytics ids for the signed-in account, e.g. right\n * after they agreed to analytics cookies in the cabinet. Without an\n * argument the ids this browser holds are sent; nothing is sent when it\n * holds none. */\n async sendAnalyticsIds(ids: AnalyticsIds | undefined = analyticsIds()): Promise<void> {\n if (!ids) return;\n await this.http.post<void>(\"/me/analytics/ids\", { body: ids });\n }\n\n /** Whether to ask the signed-in user how they heard about us. */\n async status(): Promise<AttributionStatus> {\n return this.http.get<AttributionStatus>(\"/me/attribution\");\n }\n\n /** Answer the question once. Send `\"skipped\"` when the user closes it.\n * `otherText` is kept only with `\"other\"`, up to 500 characters.\n * Errors: 400 `validation`, 409 `survey_answered`. */\n async answerSurvey(answer: SurveyAnswer, otherText?: string): Promise<AttributionStatus> {\n const body: { answer: SurveyAnswer; other_text?: string } = { answer };\n if (otherText !== undefined) body.other_text = otherText;\n return this.http.put<AttributionStatus>(\"/me/attribution/survey\", { body });\n }\n}\n\n// ---------------------------------------------------------------------------\n// Browser helpers\n// ---------------------------------------------------------------------------\n\ninterface TelegramGlobal {\n Telegram?: { WebApp?: { initDataUnsafe?: { user?: { id?: number }; start_param?: string } } };\n}\n\nfunction tgWebApp() {\n return (globalThis as unknown as TelegramGlobal).Telegram?.WebApp?.initDataUnsafe;\n}\n\nfunction readCookie(name: string): string | undefined {\n const doc = (globalThis as { document?: Document }).document;\n if (!doc?.cookie) return undefined;\n for (const part of doc.cookie.split(\";\")) {\n const [k, ...v] = part.trim().split(\"=\");\n if (k === name) return decodeURIComponent(v.join(\"=\"));\n }\n return undefined;\n}\n\nexport interface AnonymousKeyOptions {\n /** Cookie and storage name. Default `takeal_anon`. */\n name?: string;\n /** Cookie domain, e.g. `.example.com` to share the key between the site and the app. */\n cookieDomain?: string;\n}\n\nconst KEY_SHAPE = /^[A-Za-z0-9_-]{8,64}$/;\n\n/**\n * The visitor's anonymous key. In the Telegram Mini App it is\n * `tg:<telegram id>`. In a browser it is a random id kept both in a cookie\n * and in `localStorage` for a year: if one of the two is lost it comes back\n * from the other, and the cookie's year is renewed on every call while its\n * value never changes. Returns `undefined` outside a browser.\n */\nexport function anonymousKey(opts: AnonymousKeyOptions = {}): string | undefined {\n const tgId = tgWebApp()?.user?.id;\n if (tgId) return `tg:${tgId}`;\n const g = globalThis as { document?: Document; localStorage?: Storage; crypto?: Crypto };\n if (!g.document) return undefined;\n const name = opts.name ?? \"takeal_anon\";\n let stored: string | undefined;\n try {\n stored = g.localStorage?.getItem(name) ?? undefined;\n } catch {\n stored = undefined;\n }\n const fromCookie = readCookie(name);\n let key = [fromCookie, stored].find((k): k is string => !!k && KEY_SHAPE.test(k));\n if (!key) {\n key =\n g.crypto?.randomUUID?.() ??\n `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 14)}`;\n }\n try {\n g.localStorage?.setItem(name, key);\n } catch {\n // Storage full or blocked: the cookie still holds it.\n }\n const domain = opts.cookieDomain ? `; domain=${opts.cookieDomain}` : \"\";\n g.document.cookie = `${name}=${encodeURIComponent(key)}; max-age=31536000; path=/; SameSite=Lax${domain}`;\n return key;\n}\n\n/** The current page as a touch: address, referrer, the Mini App's start\n * code and the analytics cookies. Empty outside a browser. */\nexport function currentTouch(): TouchFields {\n const g = globalThis as { location?: Location; document?: Document };\n const tg = tgWebApp();\n const out: TouchFields = {};\n if (g.location?.href) out.url = g.location.href;\n if (g.document?.referrer) out.referrer = g.document.referrer;\n if (tg?.start_param) out.campaign_code = tg.start_param;\n if (tg?.user?.id) out.platform = \"miniapp\";\n const ym = readCookie(\"_ym_uid\");\n if (ym) out.metrika_client_id = ym;\n // `_ga` is `GA1.1.<id>.<timestamp>`; the client id is the last two parts.\n const ga = readCookie(\"_ga\")?.split(\".\").slice(-2).join(\".\");\n if (ga) out.ga_client_id = ga;\n return out;\n}\n\n// ---------------------------------------------------------------------------\n// Analytics ids (TKL-329)\n// ---------------------------------------------------------------------------\n\nconst IDS_KEY = \"takeal_analytics_ids\";\n\nfunction storage(): Storage | undefined {\n try {\n return (globalThis as { localStorage?: Storage }).localStorage;\n } catch {\n return undefined;\n }\n}\n\nfunction stored(): AnalyticsIds {\n try {\n const raw = storage()?.getItem(IDS_KEY);\n const v = raw ? (JSON.parse(raw) as AnalyticsIds) : {};\n return typeof v === \"object\" && v !== null ? v : {};\n } catch {\n return {};\n }\n}\n\nfunction clean(ids: AnalyticsIds): AnalyticsIds | undefined {\n const out: AnalyticsIds = {};\n const ym = ids.metrika_client_id?.trim();\n if (ym && /^\\d{1,32}$/.test(ym)) out.metrika_client_id = ym;\n const ga = ids.ga_client_id?.trim();\n if (ga && /^\\d+\\.\\d+$/.test(ga) && ga.length <= 64) out.ga_client_id = ga;\n return out.metrika_client_id || out.ga_client_id ? out : undefined;\n}\n\n/**\n * Keep analytics ids for this browser, on top of the ones kept before. The\n * Metrica sink of `initAnalytics` calls it with `getClientID`'s answer once\n * the visitor agreed to analytics; call it yourself for another platform.\n */\nexport function rememberAnalyticsIds(ids: AnalyticsIds): void {\n const merged = clean({ ...stored(), ...ids });\n if (!merged) return;\n try {\n storage()?.setItem(IDS_KEY, JSON.stringify(merged));\n } catch {\n // Storage full or blocked: the cookies still hold them.\n }\n}\n\n/** Forget the kept analytics ids: the visitor declined analytics. */\nexport function forgetAnalyticsIds(): void {\n try {\n storage()?.removeItem(IDS_KEY);\n } catch {\n // Nothing kept, or nothing to reach.\n }\n}\n\n/**\n * The visitor's analytics ids: the ones kept by {@link rememberAnalyticsIds},\n * and failing those the platforms' own cookies (`_ym_uid`, `_ga`), which\n * exist only once the visitor agreed to analytics. `undefined` when there\n * are none. The site and the cabinet share them when they share the origin.\n */\nexport function analyticsIds(): AnalyticsIds | undefined {\n const kept = stored();\n return clean({\n metrika_client_id: kept.metrika_client_id ?? readCookie(\"_ym_uid\"),\n ga_client_id: kept.ga_client_id ?? readCookie(\"_ga\")?.split(\".\").slice(-2).join(\".\"),\n });\n}\n\n/** `attribution` with the visitor's analytics ids filled in where it has none. */\nexport function withAnalyticsIds(\n attribution: SignupAttribution | undefined,\n): SignupAttribution | undefined {\n const ids = analyticsIds();\n if (!ids) return attribution;\n return {\n ...attribution,\n metrika_client_id: attribution?.metrika_client_id ?? ids.metrika_client_id,\n ga_client_id: attribution?.ga_client_id ?? ids.ga_client_id,\n };\n}\n","/**\n * `@takeal/cusfront-sdk/analytics` — one event layer for product analytics.\n *\n * The app calls {@link track} once per event; the layer hands it to every\n * configured system: PostHog everywhere, Yandex Metrica only on public pages\n * and only for the sign-up goals (what happens behind the login reaches\n * Metrica from the server, not from the browser). Every event passes\n * {@link sanitizeProperties} on the way out, PostHog's own autocapture\n * included.\n *\n * Nothing is bundled: PostHog comes from the app's own `posthog-js` (pass\n * `posthog.load`) or from its script on the configured host, Metrica from\n * its tag script. Both load only when `initAnalytics` asks for them.\n *\n * ```ts\n * initAnalytics({ zone: \"public\", posthog: { key, host: \"https://example.com/ingest\" }, metrika: { counterId: 12345678 } });\n * track(\"signup_started\");\n * ```\n */\n\nimport { rememberAnalyticsIds } from \"./resources/attribution.js\";\n\n/** Where the page lives. Decides what is captured and what is masked. */\nexport type AnalyticsZone = \"public\" | \"cabinet\" | \"miniapp\";\n\n/** Every event name the layer accepts. The first two come from the browser\n * on public pages; the rest match the event types of the platform's\n * `analytics_events` view, so a report reads the same names on both sides. */\nexport const ANALYTICS_EVENTS = [\n \"signup_started\",\n \"signup_completed\",\n \"signup\",\n \"login\",\n \"deposit_started\",\n \"deposit_confirmed\",\n \"deposit_failed\",\n \"card_issued\",\n \"card_issue_failed\",\n \"card_activated\",\n \"card_topped_up\",\n \"card_transferred\",\n \"card_frozen\",\n \"card_unfrozen\",\n \"card_terminated\",\n \"txn_cleared\",\n \"txn_declined\",\n \"subscription_started\",\n \"subscription_renewed\",\n \"subscription_cancelled\",\n \"fee_charged\",\n \"refund_issued\",\n] as const;\n\nexport type AnalyticsEvent = (typeof ANALYTICS_EVENTS)[number];\n\n/** Events that also go to Metrica as goals, from public pages only. Deposits,\n * cards and subscriptions reach Metrica from the server with their value. */\nexport const METRIKA_GOALS: readonly AnalyticsEvent[] = [\"signup_started\", \"signup_completed\"];\n\ntype Primitive = string | number | boolean | null | undefined;\nexport type AnalyticsProperties = Record<string, Primitive | Primitive[]>;\n\n/**\n * Mark a block that must never be recorded or autocaptured: card details,\n * balances, the operations history. PostHog honours this class in\n * autocapture and in session recordings.\n */\nexport const NO_CAPTURE_CLASS = \"ph-no-capture\";\n\n/** The subset of the `posthog-js` instance the layer uses. */\nexport interface PostHogLike {\n init(key: string, config: Record<string, unknown>): unknown;\n capture(event: string, properties?: Record<string, unknown>): unknown;\n identify(distinctId: string): unknown;\n reset(): unknown;\n get_distinct_id(): string;\n register(properties: Record<string, unknown>): unknown;\n set_config(config: Record<string, unknown>): unknown;\n startSessionRecording?(): unknown;\n stopSessionRecording?(): unknown;\n}\n\nexport interface PostHogOptions {\n /** Project key (`phc_…`). Write-only, safe in the browser. */\n key: string;\n /** Where events go. Point it at the proxy path on your own domain, e.g.\n * `https://example.com/ingest`. Default `https://eu.i.posthog.com`. */\n host?: string;\n /** PostHog's own app, for links from the toolbar. Default `https://eu.posthog.com`. */\n uiHost?: string;\n /** Where the script comes from when `load` is not given. Default: the\n * `-assets` twin of a PostHog host, or `host` itself for a proxy. */\n assetsHost?: string;\n /** Return the app's own `posthog-js` instance, usually\n * `() => import(\"posthog-js\").then((m) => m.default)` (1.187 or later).\n * Without it the script is loaded from `assetsHost`. */\n load?: () => Promise<PostHogLike>;\n /** Record sessions in the cabinet and the Mini App, masked. Off by\n * default; turn it on only after checking a recording shows no values.\n * Never recorded on public pages. */\n sessionRecording?: boolean;\n}\n\nexport interface MetrikaOptions {\n counterId: number | string;\n /** Tag script address. Default `https://mc.yandex.ru/metrika/tag.js`. */\n scriptUrl?: string;\n}\n\nexport interface AnalyticsOptions {\n zone: AnalyticsZone;\n posthog?: PostHogOptions;\n /** Used on public pages only; ignored in the cabinet and the Mini App. */\n metrika?: MetrikaOptions;\n /** Send the first page view right away. Default `true`; after that call\n * {@link page} on every route change. */\n initialPageview?: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// The filter on the way out\n// ---------------------------------------------------------------------------\n\nconst UUID = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi;\nconst EMAIL = /[^\\s@\"'<>(),;:]+@[^\\s@\"'<>(),;:]+\\.[a-z]{2,}/gi;\n/** A run of digits with phone or card separators: 9 to 19 digits is a phone\n * or a card number, never something to send. */\nconst DIGIT_RUN = /\\+?\\d[\\d\\s().-]{7,}\\d/g;\nconst UUID_ONLY = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n/** A path segment or a query value that is an id: a number, a UUID, a hex\n * string, or a long token of letters and digits. Slugs have dashes and\n * stay, even with a year in them. */\nfunction isId(v: string): boolean {\n return (\n /^\\d+$/.test(v) ||\n UUID_ONLY.test(v) ||\n /^[0-9a-f]{16,}$/i.test(v) ||\n (/^[A-Za-z0-9_]{20,}$/.test(v) && /\\d.*\\d/.test(v) && /[A-Za-z].*[A-Za-z]/.test(v))\n );\n}\nconst PLACEHOLDER = \":id\";\n\n/** Keys whose value is personal whatever it looks like: any key with one of\n * these words... */\nconst PERSONAL_WORDS = new Set([\n \"email\",\n \"mail\",\n \"phone\",\n \"tel\",\n \"telephone\",\n \"mobile\",\n \"msisdn\",\n \"surname\",\n \"patronymic\",\n \"firstname\",\n \"lastname\",\n \"fullname\",\n \"username\",\n \"nickname\",\n]);\n/** ...and `name` alone or after one of these (`first_name`, `holder_name`).\n * `merchant_name` names a company and stays. */\nconst PERSON_NAME_QUALIFIERS = new Set([\n \"first\",\n \"last\",\n \"full\",\n \"user\",\n \"display\",\n \"given\",\n \"family\",\n \"middle\",\n \"nick\",\n \"real\",\n \"holder\",\n \"cardholder\",\n \"customer\",\n \"contact\",\n \"person\",\n \"owner\",\n \"account\",\n \"legal\",\n]);\n/** Query keys that carry secrets or personal data. */\nconst SECRET_QUERY_WORDS = new Set([\n \"token\",\n \"code\",\n \"key\",\n \"secret\",\n \"password\",\n \"pass\",\n \"pwd\",\n \"otp\",\n \"sig\",\n \"signature\",\n \"session\",\n \"sid\",\n \"auth\",\n \"jwt\",\n \"pan\",\n \"cvv\",\n \"cvc\",\n \"iban\",\n]);\n/** Money is not personal: kept as it is. */\nconst MONEY_KEYS = new Set([\n \"amount\",\n \"amount_minor\",\n \"currency\",\n \"value\",\n \"price\",\n \"revenue\",\n \"sum\",\n]);\n\nfunction words(key: string): string[] {\n return key\n .replace(/^\\$+/, \"\")\n .replace(/([a-z])([A-Z])/g, \"$1_$2\")\n .toLowerCase()\n .split(/[^a-z0-9]+/)\n .filter(Boolean);\n}\n\nfunction personalKey(key: string): boolean {\n const w = words(key);\n const joined = w.join(\"\");\n if (joined.includes(\"email\") || joined.includes(\"phone\")) return true;\n if (w.some((x) => PERSONAL_WORDS.has(x)) || PERSONAL_WORDS.has(joined)) return true;\n // PostHog's own `$…` keys are never names of people.\n if (key.startsWith(\"$\")) return false;\n return w.some(\n (x, i) => x === \"name\" && (w.length === 1 || PERSON_NAME_QUALIFIERS.has(w[i - 1] ?? \"\")),\n );\n}\n\nfunction urlKey(key: string): boolean {\n const k = key.replace(/^\\$+/, \"\").toLowerCase();\n return (\n /(^|_)(url|href|pathname|path|referrer|referer)$/.test(k) ||\n k === \"page\" ||\n k.startsWith(\"attr__href\")\n );\n}\n\nfunction digitCount(s: string): number {\n return s.replace(/\\D/g, \"\").length;\n}\n\n/** Text with e-mail addresses, phone and card numbers cut out. */\nfunction redactText(v: string): string {\n return v\n .replace(EMAIL, \"[email]\")\n .replace(DIGIT_RUN, (m) => (digitCount(m) >= 9 && digitCount(m) <= 19 ? \"[number]\" : m));\n}\n\nfunction idSegment(seg: string): string {\n let s = seg;\n try {\n s = decodeURIComponent(seg);\n } catch {\n // Leave a broken escape as it is.\n }\n if (isId(s)) return PLACEHOLDER;\n const replaced = s.replace(UUID, PLACEHOLDER);\n if (replaced !== s) return replaced;\n return redactText(s) === s ? seg : PLACEHOLDER;\n}\n\n/**\n * A page address fit to send: UUIDs, numeric ids and long tokens in the\n * path become `:id`; query parameters that carry secrets or personal data\n * are dropped, ids among their values become `:id`; the fragment is dropped.\n * Campaign tags stay.\n */\nexport function sanitizeUrl(raw: string): string {\n const absolute = /^[a-z][a-z0-9+.-]*:\\/\\//i.test(raw);\n let u: URL;\n try {\n u = new URL(raw, \"http://relative.invalid\");\n } catch {\n return redactText(raw.split(/[?#]/)[0] ?? \"\").replace(UUID, PLACEHOLDER);\n }\n const path = u.pathname\n .split(\"/\")\n .map((seg) => (seg ? idSegment(seg) : seg))\n .join(\"/\");\n const query: string[] = [];\n u.searchParams.forEach((value, key) => {\n const k = words(key);\n if (k.some((w) => SECRET_QUERY_WORDS.has(w)) || personalKey(key)) return;\n if (redactText(value) !== value) return;\n query.push(\n `${encodeURIComponent(key)}=${isId(value) ? PLACEHOLDER : encodeURIComponent(value)}`,\n );\n });\n const search = query.length ? `?${query.join(\"&\")}` : \"\";\n return (absolute ? `${u.protocol}//${u.host}` : \"\") + path + search;\n}\n\nfunction cleanValue(key: string, v: unknown, depth: number): unknown {\n if (v === null || v === undefined || typeof v === \"number\" || typeof v === \"boolean\") return v;\n if (typeof v === \"string\") {\n // Money, and whole ids such as PostHog's session and device ids.\n if (MONEY_KEYS.has(key.toLowerCase()) || UUID_ONLY.test(v)) return v;\n if (urlKey(key) || /^https?:\\/\\//i.test(v)) return sanitizeUrl(v);\n if (key === \"$elements_chain\") {\n return redactText(v).replace(\n /attr__href=\"([^\"]*)\"/g,\n (_, h: string) => `attr__href=\"${sanitizeUrl(h)}\"`,\n );\n }\n const r = redactText(v);\n // A value that was nothing but an address or a number goes entirely.\n return r.replace(/\\[(email|number)\\]/g, \"\").trim() === \"\" && r !== v ? undefined : r;\n }\n if (depth > 5) return undefined;\n if (Array.isArray(v))\n return v.map((x) => cleanValue(key, x, depth + 1)).filter((x) => x !== undefined);\n if (typeof v === \"object\") return sanitizeProperties(v as Record<string, unknown>, depth + 1);\n return undefined;\n}\n\n/**\n * The filter every event passes before it leaves the browser. Drops keys\n * that name personal data (`email`, `phone`, `name`, `first_name`, …) and\n * values that look like an e-mail address, a phone or a card number; page\n * addresses go through {@link sanitizeUrl}. Amounts and currencies pass.\n */\nexport function sanitizeProperties<T extends Record<string, unknown>>(\n props: T,\n depth = 0,\n): Partial<T> {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(props)) {\n if (personalKey(k)) continue;\n const c = cleanValue(k, v, depth);\n if (c !== undefined) out[k] = c;\n }\n return out as Partial<T>;\n}\n\n/** PostHog's `before_send`: the same filter for what PostHog captures by itself. */\nfunction beforeSend<\n E extends {\n properties?: Record<string, unknown>;\n $set?: Record<string, unknown>;\n $set_once?: Record<string, unknown>;\n },\n>(event: E | null): E | null {\n if (!event) return event;\n const out = { ...event };\n if (event.properties) out.properties = sanitizeProperties(event.properties);\n if (event.$set) out.$set = sanitizeProperties(event.$set);\n if (event.$set_once) out.$set_once = sanitizeProperties(event.$set_once);\n return out;\n}\n\n// ---------------------------------------------------------------------------\n// Systems. A new one is a Sink plus a line in `sinksFor`.\n// ---------------------------------------------------------------------------\n\ninterface Sink {\n capture(event: AnalyticsEvent, props: AnalyticsProperties): void;\n page(url: string, referrer: string | undefined): void;\n identify(userId: string): void;\n reset(): void;\n setZone(zone: AnalyticsZone): void;\n}\n\ninterface Win {\n document?: Document;\n location?: Location;\n posthog?: unknown;\n ym?: ((...args: unknown[]) => void) & { a?: unknown[]; l?: number };\n}\n\nconst win = () => globalThis as unknown as Win;\n\nfunction injectScript(src: string, onLoad?: () => void, onError?: () => void): void {\n const doc = win().document;\n if (!doc) return;\n const s = doc.createElement(\"script\");\n s.async = true;\n s.src = src;\n s.crossOrigin = \"anonymous\";\n if (onLoad) s.addEventListener(\"load\", onLoad);\n if (onError) s.addEventListener(\"error\", onError);\n (doc.head ?? doc.documentElement).appendChild(s);\n}\n\nfunction posthogConfig(zone: AnalyticsZone, o: PostHogOptions): Record<string, unknown> {\n const host = (o.host ?? \"https://eu.i.posthog.com\").replace(/\\/+$/, \"\");\n const base: Record<string, unknown> = {\n api_host: host,\n ui_host: o.uiHost ?? \"https://eu.posthog.com\",\n // Profiles for signed-in users only.\n person_profiles: \"identified_only\",\n // Page views go through `page()`, with a cleaned address.\n capture_pageview: false,\n capture_pageleave: true,\n before_send: beforeSend,\n };\n return { ...base, ...zoneConfig(zone, o) };\n}\n\n/** What changes with the zone. Applied at init and on `setAnalyticsZone`. */\nfunction zoneConfig(zone: AnalyticsZone, o: PostHogOptions): Record<string, unknown> {\n if (zone === \"public\") {\n return {\n autocapture: true,\n mask_all_text: false,\n mask_all_element_attributes: false,\n enable_heatmaps: true,\n disable_session_recording: true,\n };\n }\n return {\n // A click is \"the third button in the cards block\", never its label.\n autocapture: { capture_copied_text: false },\n mask_all_text: true,\n mask_all_element_attributes: true,\n enable_heatmaps: false,\n disable_session_recording: !o.sessionRecording,\n session_recording: {\n maskAllInputs: true,\n maskTextSelector: \"*\",\n blockClass: NO_CAPTURE_CLASS,\n },\n };\n}\n\nfunction assetsHost(o: PostHogOptions): string {\n if (o.assetsHost) return o.assetsHost.replace(/\\/+$/, \"\");\n const host = (o.host ?? \"https://eu.i.posthog.com\").replace(/\\/+$/, \"\");\n return host.replace(\".i.posthog.com\", \"-assets.i.posthog.com\");\n}\n\n/** Load posthog-js the way its own snippet does: a placeholder that the\n * script replaces with the instance once it runs. */\nfunction loadPostHogScript(\n o: PostHogOptions,\n config: Record<string, unknown>,\n): Promise<PostHogLike | undefined> {\n return new Promise((resolve) => {\n const w = win();\n if (!w.document) return resolve(undefined);\n const placeholder = Object.assign([] as unknown[], {\n __SV: 1,\n _i: [[o.key, config, \"posthog\"]],\n });\n w.posthog = placeholder;\n injectScript(\n `${assetsHost(o)}/static/array.js`,\n () => {\n const ph = w.posthog;\n const live =\n ph !== placeholder && typeof (ph as PostHogLike | undefined)?.capture === \"function\";\n resolve(live ? (ph as PostHogLike) : undefined);\n },\n () => resolve(undefined),\n );\n });\n}\n\nclass PostHogSink implements Sink {\n readonly ready: Promise<PostHogLike | undefined>;\n\n constructor(\n private readonly o: PostHogOptions,\n zone: AnalyticsZone,\n ) {\n const config = posthogConfig(zone, o);\n this.ready = (\n o.load\n ? o.load().then((ph) => {\n ph.init(o.key, config);\n return ph;\n })\n : loadPostHogScript(o, config)\n )\n .then((ph) => {\n ph?.register({ zone });\n return ph;\n })\n .catch(() => undefined);\n }\n\n private with(fn: (ph: PostHogLike) => void): void {\n void this.ready.then((ph) => ph && fn(ph));\n }\n\n capture(event: AnalyticsEvent, props: AnalyticsProperties): void {\n this.with((ph) => ph.capture(event, props));\n }\n page(url: string, referrer: string | undefined): void {\n const props: Record<string, unknown> = { $current_url: url };\n if (referrer) props.$referrer = referrer;\n this.with((ph) => ph.capture(\"$pageview\", props));\n }\n identify(userId: string): void {\n this.with((ph) => ph.identify(userId));\n }\n reset(): void {\n this.with((ph) => ph.reset());\n }\n setZone(zone: AnalyticsZone): void {\n this.with((ph) => {\n ph.set_config(zoneConfig(zone, this.o));\n ph.register({ zone });\n if (zone === \"public\" || !this.o.sessionRecording) ph.stopSessionRecording?.();\n else ph.startSessionRecording?.();\n });\n }\n}\n\n/** Metrica, public pages only. It never records on its own: no Webvisor, no\n * click map, no automatic page views. It sees exactly what this layer\n * sends, and falls silent when the zone leaves `public`. */\nclass MetrikaSink implements Sink {\n private live = true;\n private readonly id: number;\n\n constructor(o: MetrikaOptions) {\n this.id = Number(o.counterId);\n const w = win();\n if (!w.ym) {\n const ym = ((...args: unknown[]) => {\n (ym.a = ym.a ?? []).push(args);\n }) as NonNullable<Win[\"ym\"]>;\n ym.l = Date.now();\n w.ym = ym;\n injectScript(o.scriptUrl ?? \"https://mc.yandex.ru/metrika/tag.js\");\n }\n this.ym(\"init\", {\n defer: true,\n webvisor: false,\n clickmap: false,\n trackLinks: false,\n accurateTrackBounce: true,\n });\n // The sink exists only once the visitor agreed to analytics: keep the\n // ClientID for the server's conversions (TKL-329).\n this.ym(\"getClientID\", (id: unknown) => {\n if (id !== undefined && id !== null) rememberAnalyticsIds({ metrika_client_id: String(id) });\n });\n }\n\n private ym(...args: unknown[]): void {\n if (this.live) win().ym?.(this.id, ...args);\n }\n\n capture(event: AnalyticsEvent, props: AnalyticsProperties): void {\n if (METRIKA_GOALS.includes(event)) this.ym(\"reachGoal\", event, props);\n }\n page(url: string, referrer: string | undefined): void {\n this.ym(\"hit\", url, referrer ? { referer: referrer } : {});\n }\n identify(userId: string): void {\n // The same id the server sends with its conversions.\n this.ym(\"setUserID\", userId);\n }\n reset(): void {}\n setZone(zone: AnalyticsZone): void {\n this.live = zone === \"public\";\n }\n}\n\n// ---------------------------------------------------------------------------\n// State, kept on globalThis: every sub-export bundles its own copy of this\n// file, and they must all talk to one set of systems.\n// ---------------------------------------------------------------------------\n\ninterface State {\n options: AnalyticsOptions;\n zone: AnalyticsZone;\n posthog?: PostHogSink;\n metrika?: MetrikaSink;\n lastPage?: string;\n userId?: string;\n}\n\nconst KEY = Symbol.for(\"takeal.cusfront-sdk.analytics\");\nconst holder = globalThis as unknown as Record<symbol, State | undefined>;\nconst state = (): State | undefined => holder[KEY];\n\nfunction sinks(s: State): Sink[] {\n // Metrica loads the first time the page is public, and never before.\n if (s.zone === \"public\" && s.options.metrika && !s.metrika) {\n s.metrika = new MetrikaSink(s.options.metrika);\n if (s.userId) s.metrika.identify(s.userId);\n }\n return [s.posthog, s.metrika].filter((x): x is PostHogSink | MetrikaSink => !!x);\n}\n\n/**\n * Start analytics for this page. Call once, as early as possible. A second\n * call does nothing; to move between the site and the cabinet in one app,\n * use {@link setAnalyticsZone}.\n */\nexport function initAnalytics(options: AnalyticsOptions): void {\n if (state() || !win().document) return;\n if (options.zone !== \"public\" && win().ym) {\n console.warn(\n \"[analytics] Yandex Metrica is on a page outside the public zone; it must not be.\",\n );\n }\n const s: State = { options, zone: options.zone };\n holder[KEY] = s;\n if (options.posthog?.key) s.posthog = new PostHogSink(options.posthog, options.zone);\n sinks(s);\n if (options.initialPageview !== false) page();\n}\n\n/**\n * The page moved to another zone without a reload (the site and the cabinet\n * in one app). PostHog switches its masking; Metrica falls silent outside\n * public pages. A full page load into the cabinet is safer still: Metrica is\n * then never on the page at all.\n */\nexport function setAnalyticsZone(zone: AnalyticsZone): void {\n const s = state();\n if (!s || s.zone === zone) return;\n s.zone = zone;\n for (const sink of sinks(s)) sink.setZone(zone);\n}\n\n/** Record an event. The name must be one of {@link ANALYTICS_EVENTS}. */\nexport function track(event: AnalyticsEvent, props: AnalyticsProperties = {}): void {\n const s = state();\n if (!s || !(ANALYTICS_EVENTS as readonly string[]).includes(event)) return;\n const clean = sanitizeProperties(props) as AnalyticsProperties;\n for (const sink of sinks(s)) sink.capture(event, clean);\n}\n\n/** A page view. Call it on every route change; the same address twice in a\n * row counts once. Takes the current address when none is given. */\nexport function page(url?: string): void {\n const s = state();\n const w = win();\n const raw = url ?? w.location?.href;\n if (!s || !raw) return;\n const clean = sanitizeUrl(raw);\n if (clean === s.lastPage) return;\n const referrer =\n s.lastPage ?? (w.document?.referrer ? sanitizeUrl(w.document.referrer) : undefined);\n s.lastPage = clean;\n for (const sink of sinks(s)) sink.page(clean, referrer);\n}\n\n/** After sign-in: tie this browser to the user by the platform's user id\n * (`session.user.id`), never by e-mail. Only signed-in users get profiles. */\nexport function identify(userId: string): void {\n const s = state();\n if (!s || !userId) return;\n s.userId = userId;\n for (const sink of sinks(s)) sink.identify(userId);\n}\n\n/** On sign-out: forget the user, so the next person on this device starts\n * as a new visitor. */\nexport function resetAnalytics(): void {\n const s = state();\n if (!s) return;\n s.userId = undefined;\n for (const sink of sinks(s)) sink.reset();\n}\n\n/** PostHog's id for this browser, for `auth.register({ attribution: {\n * posthog_distinct_id } })`. Waits for PostHog to load, `timeoutMs` at\n * most; `undefined` without PostHog. */\nexport async function posthogDistinctId(timeoutMs = 3000): Promise<string | undefined> {\n const ready = state()?.posthog?.ready;\n if (!ready) return undefined;\n let timer: Parameters<typeof clearTimeout>[0];\n const timeout = new Promise<undefined>((r) => {\n timer = setTimeout(r, timeoutMs);\n });\n const ph = await Promise.race([ready, timeout]);\n clearTimeout(timer);\n try {\n return ph?.get_distinct_id() || undefined;\n } catch {\n return undefined;\n }\n}\n\n/** For tests: forget everything `initAnalytics` set up. */\nexport function _resetAnalyticsForTests(): void {\n holder[KEY] = undefined;\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Claim } from './resources/claims.js';
|
|
2
2
|
import { ConsentKind, ConsentChannel } from './resources/consents.js';
|
|
3
3
|
import { H as HttpClient } from './http-CL97TjMO.js';
|
|
4
|
+
import { AnalyticsIds } from './resources/attribution.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Structured customer billing details — shared by the deposits and cards
|
|
@@ -369,6 +370,9 @@ interface InitiateDepositInput {
|
|
|
369
370
|
* checks it first.
|
|
370
371
|
*/
|
|
371
372
|
promo_code?: string;
|
|
373
|
+
/** The visitor's analytics ids for the payment's server-side conversions.
|
|
374
|
+
* Leave out to send the ones this browser holds (see `analyticsIds`). */
|
|
375
|
+
analytics_ids?: AnalyticsIds;
|
|
372
376
|
}
|
|
373
377
|
interface CreateDepositRefundInput {
|
|
374
378
|
/** Omit for a full refund of the original confirmed amount; same currency. */
|
|
@@ -413,6 +417,11 @@ declare class DepositsResource {
|
|
|
413
417
|
* API answers 400 `no_quote_needed`).
|
|
414
418
|
*/
|
|
415
419
|
quote(input: CreateQuoteInput): Promise<FundingQuote>;
|
|
420
|
+
/**
|
|
421
|
+
* Start a top-up. 409 `payments_on_hold`: a payment on this account was
|
|
422
|
+
* not accepted and new ones wait until support sorts it out. Show the
|
|
423
|
+
* message as it comes and point the user to support.
|
|
424
|
+
*/
|
|
416
425
|
initiate(input: InitiateDepositInput): Promise<Deposit>;
|
|
417
426
|
/** Fetch one deposit by id — the poll target while a redirect resolves. */
|
|
418
427
|
get(id: string): Promise<Deposit>;
|
|
@@ -462,8 +471,10 @@ type CardType = "credit" | "prepaid" | "gift";
|
|
|
462
471
|
/**
|
|
463
472
|
* Card lifecycle state.
|
|
464
473
|
*
|
|
465
|
-
* - `pending_payment`:
|
|
466
|
-
*
|
|
474
|
+
* - `pending_payment`: an order waiting for its payment, not a card yet.
|
|
475
|
+
* It has no digits and no expiry, and nothing can be done with it:
|
|
476
|
+
* revealing, freezing, closing or renaming it answers 409 `card_pending`.
|
|
477
|
+
* Show it as "waiting for payment", without a way into the card's page.
|
|
467
478
|
* - `pending`: the issuer accepted the order and has not issued the card
|
|
468
479
|
* yet. The price is charged. Show the card as "being issued" with no
|
|
469
480
|
* numbers; it becomes `active` on its own, or `failed` with the price
|
|
@@ -520,10 +531,10 @@ interface CardProductPrice {
|
|
|
520
531
|
/** What the user pays, decimal string, after their subscription discount. */
|
|
521
532
|
amount: string;
|
|
522
533
|
/**
|
|
523
|
-
* ISO 4217 code: the currency the
|
|
524
|
-
*
|
|
525
|
-
*
|
|
526
|
-
*
|
|
534
|
+
* ISO 4217 code: the currency the operator priced the card in, the same
|
|
535
|
+
* before and after sign-in. A card order paid in this currency costs
|
|
536
|
+
* exactly `amount`. It is not necessarily the currency the card is held
|
|
537
|
+
* in (`CardProduct.currency`).
|
|
527
538
|
*/
|
|
528
539
|
currency: string;
|
|
529
540
|
/** Wording for the fee line, e.g. "Card issuance". */
|
|
@@ -532,6 +543,15 @@ interface CardProductPrice {
|
|
|
532
543
|
base_amount: string;
|
|
533
544
|
/** Discount applied, in basis points (1000 = 10%). */
|
|
534
545
|
discount_bps: number;
|
|
546
|
+
/**
|
|
547
|
+
* What issuing costs when paid from the wallet, converted the way that
|
|
548
|
+
* purchase charges it. Only for a signed-in user whose wallet holds another
|
|
549
|
+
* currency than the price; absent otherwise, and when there is no rate.
|
|
550
|
+
*/
|
|
551
|
+
from_wallet?: {
|
|
552
|
+
amount: string;
|
|
553
|
+
currency: string;
|
|
554
|
+
} | null;
|
|
535
555
|
}
|
|
536
556
|
/**
|
|
537
557
|
* A card the user can order, as listed by `GET /me/card-products`. The id is
|
|
@@ -620,7 +640,7 @@ interface Card {
|
|
|
620
640
|
user_id: string;
|
|
621
641
|
card_type: CardType;
|
|
622
642
|
status: CardStatus;
|
|
623
|
-
/** Last four digits of the PAN — safe to display. */
|
|
643
|
+
/** Last four digits of the PAN — safe to display. Null until the card is paid for and issued. */
|
|
624
644
|
last4: string | null;
|
|
625
645
|
expiry_month: number | null;
|
|
626
646
|
expiry_year: number | null;
|
|
@@ -638,10 +658,19 @@ interface Card {
|
|
|
638
658
|
close_blocked: CloseBlockedReason | null;
|
|
639
659
|
/**
|
|
640
660
|
* Top-ups the issuer has accepted and not loaded yet, summed, decimal
|
|
641
|
-
* string in `currency`; `null` when there are none.
|
|
661
|
+
* string in `currency`; `null` when there are none. It counts top-ups from
|
|
662
|
+
* the wallet and top-ups paid straight to the card. Show it next to the
|
|
642
663
|
* balance as money on its way to the card.
|
|
643
664
|
*/
|
|
644
665
|
topups_pending: string | null;
|
|
666
|
+
/**
|
|
667
|
+
* `true` while the card's details are being prepared: the card can be
|
|
668
|
+
* used and topped up, but its number can't be shown yet. Show "Details
|
|
669
|
+
* are being prepared" instead of the reveal button and refresh the card
|
|
670
|
+
* later; it turns `false` on its own, usually within minutes. Absent
|
|
671
|
+
* from platforms before 0.7.6.
|
|
672
|
+
*/
|
|
673
|
+
details_pending?: boolean;
|
|
645
674
|
/**
|
|
646
675
|
* Top-ups the issuer has held for too long, summed, decimal string in
|
|
647
676
|
* `currency`; `null` when there are none. The money is safe and waits for
|
|
@@ -815,6 +844,9 @@ interface CardOrderInput {
|
|
|
815
844
|
consentChannel?: ConsentChannel;
|
|
816
845
|
/** Passed to the payment provider; `return_url` is where the payment page sends the user back. */
|
|
817
846
|
metadata?: Record<string, string>;
|
|
847
|
+
/** The visitor's analytics ids for the order's server-side conversions.
|
|
848
|
+
* Leave out to send the ones this browser holds (see `analyticsIds`). */
|
|
849
|
+
analyticsIds?: AnalyticsIds;
|
|
818
850
|
}
|
|
819
851
|
/** What {@link CardsResource.order} returns: the top-up to pay and its price. */
|
|
820
852
|
interface CardOrder {
|
|
@@ -823,7 +855,7 @@ interface CardOrder {
|
|
|
823
855
|
/** What the user pays, decimal string, in `currency`. */
|
|
824
856
|
amount: string;
|
|
825
857
|
currency: string;
|
|
826
|
-
/** What the payment brings: the card's price,
|
|
858
|
+
/** What the payment brings: the card's price, what goes onto the card and `debt_withheld`, in `card_currency`. A payment in the price's own currency pays the price as it is set; only the rest is converted. */
|
|
827
859
|
card_amount: string;
|
|
828
860
|
card_currency: string;
|
|
829
861
|
/**
|
|
@@ -844,6 +876,13 @@ declare function cardOrderBody(input: CardOrderInput): Record<string, unknown>;
|
|
|
844
876
|
interface CardBalance {
|
|
845
877
|
amount: string;
|
|
846
878
|
currency: string;
|
|
879
|
+
/**
|
|
880
|
+
* From `cards.balance()` only: top-ups the issuer has accepted and not
|
|
881
|
+
* confirmed yet, summed, decimal string in `currency`; `null` when there
|
|
882
|
+
* are none. Not part of `amount`, even when the issuer already shows the
|
|
883
|
+
* money: show it next to the balance as on its way.
|
|
884
|
+
*/
|
|
885
|
+
pending?: string | null;
|
|
847
886
|
}
|
|
848
887
|
/** What a top-up of a card can be right now, from `GET /me/cards/{id}/topup`. */
|
|
849
888
|
interface TopUpTerms {
|
|
@@ -940,16 +979,30 @@ interface RevealCardInput {
|
|
|
940
979
|
password?: string;
|
|
941
980
|
totpCode?: string;
|
|
942
981
|
}
|
|
982
|
+
/**
|
|
983
|
+
* What a reveal gave, so a client can switch on one field:
|
|
984
|
+
*
|
|
985
|
+
* - `numbers`: `pan`, `cvv` and the expiry are filled in;
|
|
986
|
+
* - `page`: the issuer shows the numbers on a page of its own, `reveal_url`
|
|
987
|
+
* is set and `pan` and `cvv` are empty;
|
|
988
|
+
* - `pending`: the card's details are still being prepared, nothing else
|
|
989
|
+
* is filled in. Show "Details are being prepared" and try again in a
|
|
990
|
+
* minute or two; the attempt didn't count against the reveal limit.
|
|
991
|
+
*/
|
|
992
|
+
type RevealState = "numbers" | "page" | "pending";
|
|
943
993
|
/**
|
|
944
994
|
* Full card data from a successful reveal. **Security**: never persist this,
|
|
945
995
|
* keep it in volatile memory only, clear it within `expires_in_seconds`, and
|
|
946
996
|
* never write it to localStorage / logs (the API marks the response no-store).
|
|
947
997
|
*
|
|
998
|
+
* `state` says which of three answers this is (see {@link RevealState}).
|
|
948
999
|
* Some issuers hand out a page that shows the numbers instead of the
|
|
949
|
-
* numbers themselves
|
|
950
|
-
*
|
|
1000
|
+
* numbers themselves; for some cards the details are still being prepared
|
|
1001
|
+
* right after issuance.
|
|
951
1002
|
*/
|
|
952
1003
|
interface RevealedCard {
|
|
1004
|
+
/** Which answer this is; set by the SDK from the fields below. */
|
|
1005
|
+
state: RevealState;
|
|
953
1006
|
/** The card number; empty when `reveal_url` is set. */
|
|
954
1007
|
pan: string;
|
|
955
1008
|
/** The security code; empty when `reveal_url` is set. */
|
|
@@ -976,7 +1029,14 @@ interface RevealedCard {
|
|
|
976
1029
|
billing_address?: BillingAddress;
|
|
977
1030
|
/** Display window before the client should auto-clear the data. */
|
|
978
1031
|
expires_in_seconds: number;
|
|
1032
|
+
/**
|
|
1033
|
+
* `true` when the details are still being prepared (`state: "pending"`).
|
|
1034
|
+
* Absent from platforms before 0.7.6.
|
|
1035
|
+
*/
|
|
1036
|
+
details_pending?: boolean;
|
|
979
1037
|
}
|
|
1038
|
+
/** The three answers of a reveal told apart; see {@link RevealState}. */
|
|
1039
|
+
declare function revealState(r: Omit<RevealedCard, "state">): RevealState;
|
|
980
1040
|
/** Postal address a card is registered at. Which parts exist depends on the country. */
|
|
981
1041
|
interface BillingAddress {
|
|
982
1042
|
line1?: string;
|
|
@@ -1070,8 +1130,10 @@ declare class CardsResource {
|
|
|
1070
1130
|
* `idempotencyKey` returns the same order.
|
|
1071
1131
|
* Errors: 400 `unknown_product` / `method_not_available` / a limit of the
|
|
1072
1132
|
* way of paying, 409 `holder_data_consent_required` (the product has
|
|
1073
|
-
* `holder_data_required` and the user has not agreed to it),
|
|
1074
|
-
*
|
|
1133
|
+
* `holder_data_required` and the user has not agreed to it), 409
|
|
1134
|
+
* `payments_on_hold` (a payment on this account was not accepted and new
|
|
1135
|
+
* ones wait until support sorts it out: show the message and point the
|
|
1136
|
+
* user to support), 503 no funding connector or no exchange rate.
|
|
1075
1137
|
*/
|
|
1076
1138
|
order(input: CardOrderInput & {
|
|
1077
1139
|
idempotencyKey: string;
|
|
@@ -1081,7 +1143,9 @@ declare class CardsResource {
|
|
|
1081
1143
|
* (`is_default` marks the one issued when none is chosen). Each item
|
|
1082
1144
|
* carries its product card (name, tagline, benefits, tile picture),
|
|
1083
1145
|
* artwork, and the issuance price after the caller's subscription
|
|
1084
|
-
* discount, in the
|
|
1146
|
+
* discount, in the currency the operator set it in (`price.from_wallet`
|
|
1147
|
+
* is the same price from the wallet, when that holds another currency).
|
|
1148
|
+
* Pass an item's `id` as
|
|
1085
1149
|
* `productId` to {@link create}.
|
|
1086
1150
|
*/
|
|
1087
1151
|
listProducts(): Promise<CardProduct[]>;
|
|
@@ -1158,9 +1222,13 @@ declare class CardsResource {
|
|
|
1158
1222
|
* keep the result in volatile memory only, never write it to
|
|
1159
1223
|
* localStorage / logs, and clear it within `expires_in_seconds`.
|
|
1160
1224
|
*
|
|
1161
|
-
*
|
|
1162
|
-
* when the issuer shows them on a
|
|
1163
|
-
* frame right away, it is
|
|
1225
|
+
* `state` tells the three answers apart: `numbers`; `page`, with
|
|
1226
|
+
* `reveal_url` and empty `pan` and `cvv` when the issuer shows them on a
|
|
1227
|
+
* page of its own (open that page in a frame right away, it is
|
|
1228
|
+
* short-lived); or `pending` while the card's details are still being
|
|
1229
|
+
* prepared, which doesn't count against the limit. A card says the same
|
|
1230
|
+
* in {@link Card.details_pending}, so there is no need to call this just
|
|
1231
|
+
* to find out.
|
|
1164
1232
|
*
|
|
1165
1233
|
* 403 not your card · 409 `card_locked` · 429 rate-limited · 501 connector
|
|
1166
1234
|
* has no sensitive-data endpoint · 503 `provider_unavailable`.
|
|
@@ -1208,4 +1276,4 @@ declare class CardsResource {
|
|
|
1208
1276
|
terminate(id: string, reason?: string): Promise<Card>;
|
|
1209
1277
|
}
|
|
1210
1278
|
|
|
1211
|
-
export { type Address as A, type BillingAddress as B, type CardProduct as C, type Deposit as D, type DepositStatus as E, FundingOptionsResource as F, type DepositTarget as G, type FeeKind as H, type FunderMode as I, type FundingOption as J, type FundingQuote as K, type InitiateDepositInput as L, type IssuanceBonus as M, type IssueCardInput as N, type MethodTerms as O, type RevealCardInput as P, type
|
|
1279
|
+
export { cardOrderBody as $, type Address as A, type BillingAddress as B, type CardProduct as C, type Deposit as D, type DepositStatus as E, FundingOptionsResource as F, type DepositTarget as G, type FeeKind as H, type FunderMode as I, type FundingOption as J, type FundingQuote as K, type InitiateDepositInput as L, type IssuanceBonus as M, type IssueCardInput as N, type MethodTerms as O, type RevealCardInput as P, type RevealState as Q, type Refund as R, type RevealedCard as S, type SetPinInput as T, type TopUpInput as U, type TopUpResult as V, type TopUpTerms as W, type TransferInput as X, type TransferResult as Y, type UpdateCardInput as Z, revealState as _, type Card as a, cardRequestBody as a0, DepositsResource as b, CardsResource as c, type CardBalance as d, type CardDesignRef as e, type CardForm as f, type CardInTransit as g, type CardLoadStatus as h, type CardOrder as i, type CardOrderError as j, type CardOrderInput as k, type CardProductPrice as l, type CardStatus as m, type CardStatusSource as n, type CardTariff as o, type CardTopUp as p, type CardTopUpStatus as q, type CardTransfer as r, type CardType as s, type Cardholder as t, type CloseBlockedReason as u, type CreateCardInput as v, type CreateDepositRefundInput as w, type CreateQuoteInput as x, type CustomerInfo as y, type DepositMethod as z };
|