@open-condo/miniapp-utils
Version:
A set of helper functions / components / hooks used to build new condo apps fast
30 lines (28 loc) • 1.58 kB
text/typescript
type Rewrite = {
source: string;
destination: string;
};
/**
* Gets posthog endpoint based on its domain and requested path.
* Used to support both cloud and self-hosted instances, which differs in set of endpoints.
* See example below for detailed explanation:
* @example
* getPosthogPath('https://eu.i.posthog.com', ['static', 'something']) // https://eu-assets.i.posthog.com/something
* getPosthogPath('https://eu.i.posthog.com', ['other', 'path']) // https://eu.i.posthog.com/other/path
* getPosthogPath('https://ph.self-hosted.com', ['static', 'something']) // https://ph.self-hosted.com/static/something
* getPosthogPath('https://ph.self-hosted.com', ['other', 'path']) // https://ph.self-hosted.com/other/path
*/
declare function getPosthogEndpoint(posthogDomain: string, requestedPath: Array<string>): string;
/**
* Generates Next.js rewrites based on PostHog domain,
* so that PostHog can run in cloud and self-hosted versions without any ad blocker restrictions
* @example
* generateRewrites('https://eu.i.posthog.com', '/api/posthog')
* generateRewrites('https://posthog.my.domain.com', '/api/posthog')
* generateRewrites(process.env.NEXT_PUBLIC_POSTHOG_HOST, '/api/posthog')
*
* @deprecated This util is not used in condo applications and will be removed in next major upgrade,
* since it requires knowing postHogDomain during build time. Consider setting up http proxy on API route instead
*/
declare function generateRewrites(postHogDomain: string, routeEndpoint: string): Array<Rewrite>;
export { generateRewrites, getPosthogEndpoint };