@affiliateo/web 1.1.5 → 1.2.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@affiliateo/web",
3
- "version": "1.1.5",
3
+ "version": "1.2.0",
4
4
  "description": "Affiliateo web SDK — affiliate attribution and session tracking for web apps",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
package/src/index.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * export default function App() {
9
9
  * return (
10
- * <AffiliateoProvider siteId="YOUR_SITE_ID">
10
+ * <AffiliateoProvider campaignId="YOUR_CAMPAIGN_ID">
11
11
  * <YourApp />
12
12
  * </AffiliateoProvider>
13
13
  * );
package/src/provider.tsx CHANGED
@@ -42,7 +42,7 @@ export function useAffiliateRef(): AffiliateoContextValue {
42
42
  }
43
43
 
44
44
  export function AffiliateoProvider({
45
- siteId,
45
+ campaignId,
46
46
  apiUrl,
47
47
  children,
48
48
  }: AffiliateoConfig & { children: React.ReactNode }) {
@@ -52,7 +52,7 @@ export function AffiliateoProvider({
52
52
  })
53
53
 
54
54
  const apiBase = (apiUrl || DEFAULT_API_URL).replace(/\/$/, '')
55
- const siteIdRef = useRef(siteId)
55
+ const campaignIdRef = useRef(campaignId)
56
56
  const visitorIdRef = useRef<string | null>(null)
57
57
  const refRef = useRef<string | null>(null)
58
58
  const sentRef = useRef(false)
@@ -82,7 +82,7 @@ export function AffiliateoProvider({
82
82
  function send(type: string) {
83
83
  const payload = {
84
84
  type,
85
- site_id: siteIdRef.current,
85
+ campaign_id: campaignIdRef.current,
86
86
  visitor_id: visitorIdRef.current,
87
87
  url: window.location.href,
88
88
  path: window.location.pathname,
@@ -96,9 +96,9 @@ export function AffiliateoProvider({
96
96
  }
97
97
  const data = JSON.stringify(payload)
98
98
  if (navigator.sendBeacon) {
99
- navigator.sendBeacon(`${apiBase}/api/v1/event`, new Blob([data], { type: 'application/json' }))
99
+ navigator.sendBeacon(`${apiBase}/api/v1/web/event`, new Blob([data], { type: 'application/json' }))
100
100
  } else {
101
- fetch(`${apiBase}/api/v1/event`, {
101
+ fetch(`${apiBase}/api/v1/web/event`, {
102
102
  method: 'POST',
103
103
  headers: { 'Content-Type': 'application/json' },
104
104
  body: data,
@@ -137,7 +137,7 @@ export function AffiliateoProvider({
137
137
  document.removeEventListener('visibilitychange', onVisibilityChange)
138
138
  window.removeEventListener('beforeunload', onLeave)
139
139
  }
140
- }, [siteId, apiBase])
140
+ }, [campaignId, apiBase])
141
141
 
142
142
  return (
143
143
  <AffiliateoContext.Provider value={state}>
package/src/types.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export interface AffiliateoConfig {
2
- siteId: string
2
+ campaignId: string
3
3
  /** Base URL for the API. Defaults to https://affiliateo.com */
4
4
  apiUrl?: string
5
5
  }