Aller au contenu

FrakContextManager

Ce contenu n’est pas encore disponible dans votre langue.

const FrakContextManager: { compress: (context?) => string | undefined; decompress: (context?) => FrakContext | undefined; parse: (args) => FrakContext | null | undefined; remove: (url) => string; replaceUrl: (args) => void; update: (args) => string | null; }

Defined in: context/frakContext.ts:238

Manager for Frak referral context in URLs.

Handles compression, decompression, URL parsing, and browser history updates for both V1 (wallet address) and V2 (anonymous clientId) referral contexts.

compress: (context?) => string | undefined

Compress a Frak context into a URL-safe string.

  • V2 contexts are encoded using a compact binary layout (see encodeFrakContextV2) then base64url-encoded.
  • V1 contexts encode the wallet address as raw bytes (base64url).

FrakContextV1 | FrakContextV2

The context to compress (V1 or V2)

string | undefined

A compressed base64url string, or undefined on failure

decompress: (context?) => FrakContext | undefined

Decompress a base64url string back into a Frak context.

V1 (exactly 20 bytes) and V2 (37, 41, or 57 bytes) are distinguished by their decoded byte length, so there is no ambiguity.

string

The compressed context string

FrakContext | undefined

The decompressed FrakContext, or undefined on failure

parse: (args) => FrakContext | null | undefined

Parse a URL to extract the Frak referral context from the fCtx query parameter.

The key is matched case-insensitively: some link channels (emails, messaging apps) lowercase query-param keys in transit, so fCtx can arrive as fctx.

string

The URL to parse

FrakContext | null | undefined

The parsed FrakContext, or null if absent

remove: (url) => string

Remove the fCtx query parameter from a URL.

string

The URL to strip the context from

string

The cleaned URL string

replaceUrl: (args) => void

Replace the current browser URL with an updated Frak context.

  • If context is non-null, embeds it via update.
  • If context is null, strips the context via remove.

FrakContextV1 | FrakContextV2 | null

Context to set, or null to remove

string

Base URL (defaults to window.location.href)

void

update: (args) => string | null

Add or replace the fCtx query parameter in a URL with the given context.

Standard affiliation params (utm_source, utm_medium, utm_campaign, ref, via, …) are always appended using gap-fill semantics: pre-existing params on the URL are preserved, defaults are derived from the context when applicable, and attribution overrides take precedence when provided.

AttributionParams

Optional attribution overrides. Defaults are applied even when omitted.

FrakContextV1 | FrakContextV2

The context to embed (V1 or V2)

string

The URL to update

string | null

The updated URL string, or null on failure