FrakContextManager
Ce contenu n’est pas encore disponible dans votre langue.
constFrakContextManager: {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.
Type Declaration
Section titled “Type Declaration”compress
Section titled “compress”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).
Parameters
Section titled “Parameters”context?
Section titled “context?”FrakContextV1 | FrakContextV2
The context to compress (V1 or V2)
Returns
Section titled “Returns”string | undefined
A compressed base64url string, or undefined on failure
decompress
Section titled “decompress”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.
Parameters
Section titled “Parameters”context?
Section titled “context?”string
The compressed context string
Returns
Section titled “Returns”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.
Parameters
Section titled “Parameters”string
The URL to parse
Returns
Section titled “Returns”FrakContext | null | undefined
The parsed FrakContext, or null if absent
remove
Section titled “remove”remove: (
url) =>string
Remove the fCtx query parameter from a URL.
Parameters
Section titled “Parameters”string
The URL to strip the context from
Returns
Section titled “Returns”string
The cleaned URL string
replaceUrl
Section titled “replaceUrl”replaceUrl: (
args) =>void
Replace the current browser URL with an updated Frak context.
- If
contextis non-null, embeds it via update. - If
contextis null, strips the context via remove.
Parameters
Section titled “Parameters”context
Section titled “context”FrakContextV1 | FrakContextV2 | null
Context to set, or null to remove
string
Base URL (defaults to window.location.href)
Returns
Section titled “Returns”void
update
Section titled “update”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.
Parameters
Section titled “Parameters”attribution?
Section titled “attribution?”Optional attribution overrides. Defaults are applied even when omitted.
context
Section titled “context”FrakContextV1 | FrakContextV2
The context to embed (V1 or V2)
string
The URL to update
Returns
Section titled “Returns”string | null
The updated URL string, or null on failure