@affiliateo/web 1.5.2 → 1.6.1

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/dist/index.d.ts CHANGED
@@ -1,28 +1,2 @@
1
- /**
2
- * @affiliateo/web — Affiliate attribution and session tracking for web apps.
3
- *
4
- * React usage:
5
- * ```tsx
6
- * import { AffiliateoProvider } from '@affiliateo/web';
7
- *
8
- * export default function App() {
9
- * return (
10
- * <AffiliateoProvider campaignId="YOUR_CAMPAIGN_ID">
11
- * <YourApp />
12
- * </AffiliateoProvider>
13
- * );
14
- * }
15
- * ```
16
- *
17
- * Server-side (pass ref to Stripe checkout):
18
- * ```ts
19
- * import { getMetadata } from '@affiliateo/web';
20
- *
21
- * const session = await stripe.checkout.sessions.create({
22
- * metadata: getMetadata(req),
23
- * });
24
- * ```
25
- */
26
1
  export { AffiliateoProvider, useAffiliateRef } from './provider';
27
- export { getMetadata } from './metadata';
28
2
  export type { AffiliateoConfig, AffiliateoContextValue } from './types';
package/dist/index.js CHANGED
@@ -1,27 +1,2 @@
1
- /**
2
- * @affiliateo/web — Affiliate attribution and session tracking for web apps.
3
- *
4
- * React usage:
5
- * ```tsx
6
- * import { AffiliateoProvider } from '@affiliateo/web';
7
- *
8
- * export default function App() {
9
- * return (
10
- * <AffiliateoProvider campaignId="YOUR_CAMPAIGN_ID">
11
- * <YourApp />
12
- * </AffiliateoProvider>
13
- * );
14
- * }
15
- * ```
16
- *
17
- * Server-side (pass ref to Stripe checkout):
18
- * ```ts
19
- * import { getMetadata } from '@affiliateo/web';
20
- *
21
- * const session = await stripe.checkout.sessions.create({
22
- * metadata: getMetadata(req),
23
- * });
24
- * ```
25
- */
1
+ 'use client';
26
2
  export { AffiliateoProvider, useAffiliateRef } from './provider';
27
- export { getMetadata } from './metadata';
package/dist/provider.js CHANGED
@@ -85,17 +85,20 @@ export function AffiliateoProvider({ campaignId, apiUrl, children, }) {
85
85
  screen_width: window.innerWidth,
86
86
  };
87
87
  const data = JSON.stringify(payload);
88
- if (navigator.sendBeacon) {
89
- navigator.sendBeacon(`${apiBase}/api/v1/web/event`, new Blob([data], { type: 'application/json' }));
90
- }
91
- else {
92
- fetch(`${apiBase}/api/v1/web/event`, {
93
- method: 'POST',
94
- headers: { 'Content-Type': 'application/json' },
95
- body: data,
96
- keepalive: true,
97
- }).catch(() => { });
98
- }
88
+ // Always use fetch so we can see responses in DevTools Network tab
89
+ fetch(`${apiBase}/api/v1/web/event`, {
90
+ method: 'POST',
91
+ headers: { 'Content-Type': 'application/json' },
92
+ body: data,
93
+ keepalive: true,
94
+ }).then(async (r) => {
95
+ if (!r.ok) {
96
+ const text = await r.text().catch(() => '');
97
+ console.error(`[Affiliateo] Event failed (${r.status}):`, text);
98
+ }
99
+ }).catch((err) => {
100
+ console.error('[Affiliateo] Event send error:', err);
101
+ });
99
102
  }
100
103
  // Send pageview on mount (first load or page navigation)
101
104
  if (!sentRef.current) {
@@ -0,0 +1 @@
1
+ export { getMetadata } from './metadata';
package/dist/server.js ADDED
@@ -0,0 +1 @@
1
+ export { getMetadata } from './metadata';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@affiliateo/web",
3
- "version": "1.5.2",
3
+ "version": "1.6.1",
4
4
  "description": "Affiliateo web SDK — affiliate attribution and session tracking for web apps",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -10,6 +10,11 @@
10
10
  "types": "./dist/index.d.ts",
11
11
  "import": "./dist/index.js",
12
12
  "require": "./dist/index.js"
13
+ },
14
+ "./server": {
15
+ "types": "./dist/server.d.ts",
16
+ "import": "./dist/server.js",
17
+ "require": "./dist/server.js"
13
18
  }
14
19
  },
15
20
  "scripts": {