프레임워크 통합
SDK에는 프레임워크별 계층이 필요 없습니다. 오토캡처가 History API를 패치하므로 어떤 라우터에서도 경로 변경이 추적됩니다. 페이지당 클라이언트 하나를 만들고, 프레임워크가 다른 것을 공유하는 방식 그대로 공유하세요. 서버에서도 렌더링한다면, 아래 각 스니펫처럼 클라이언트를 브라우저에서만 만드세요.
이 코드 조각들의 키는 콘솔에서 받습니다: API 키 받기
At a glance
- Route tracking
- None needed: autocapture patches the History API, every router is covered
- Pattern
- One
createWebClientper page, shared via your framework - React
@prodantix/react, the one lifecycle that needs an adapter
React
React만이 예외입니다. 그 라이프사이클에는 전용 어댑터가 필요하며, 클라이언트를 딱 한 번 설치하는 provider와 hook이 StrictMode에 안전하게 동작합니다.
Bash
bun add @prodantix/sdk @prodantix/reactVue
JavaScript
// prodantix.js
import { createWebClient } from '@prodantix/sdk/web';
export const prodantixPlugin = {
install(app, options) {
const client = createWebClient(options);
app.provide('prodantix', client);
},
};
// main.js (in a Nuxt app: a .client.js plugin)
app.use(prodantixPlugin, {
apiKey: PRODANTIX_PUBLIC_KEY,
host: 'https://eu.api.prodantix.com',
flagsHost: 'https://api.prodantix.com',
});
// any component
import { inject } from 'vue';
const prodantix = inject('prodantix');
prodantix.capture('order.completed');Svelte
JavaScript
// $lib/prodantix.js
import { browser } from '$app/environment';
import { createWebClient } from '@prodantix/sdk/web';
export const prodantix = browser
? createWebClient({
apiKey: PRODANTIX_PUBLIC_KEY,
host: 'https://eu.api.prodantix.com',
flagsHost: 'https://api.prodantix.com',
})
: null;
// any component
import { prodantix } from '$lib/prodantix';
prodantix?.capture('order.completed');Angular
JavaScript
// prodantix.service.ts (Angular Universal: create only when isPlatformBrowser)
import { Injectable } from '@angular/core';
import { createWebClient } from '@prodantix/sdk/web';
@Injectable({ providedIn: 'root' })
export class ProdantixService {
readonly client = createWebClient({
apiKey: PRODANTIX_PUBLIC_KEY,
host: 'https://eu.api.prodantix.com',
flagsHost: 'https://api.prodantix.com',
});
}
// any component
constructor(private prodantix: ProdantixService) {}
this.prodantix.client.capture('order.completed');