@affiliateo/web 1.3.0 → 1.4.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.
@@ -17,4 +17,5 @@ export declare function getMetadata(req: {
17
17
  }): {
18
18
  affiliateo_visitor_id?: string;
19
19
  affiliateo_ref?: string;
20
+ campaign_id?: string;
20
21
  };
package/dist/metadata.js CHANGED
@@ -11,10 +11,13 @@ export function getMetadata(req) {
11
11
  if (req.cookies && typeof req.cookies === 'object' && 'get' in req.cookies && typeof req.cookies.get === 'function') {
12
12
  const visitorId = req.cookies.get('affiliateo_visitor_id');
13
13
  const ref = req.cookies.get('affiliateo_ref');
14
+ const campaignId = req.cookies.get('affiliateo_campaign_id');
14
15
  if (visitorId?.value)
15
16
  metadata.affiliateo_visitor_id = visitorId.value;
16
17
  if (ref?.value)
17
18
  metadata.affiliateo_ref = ref.value;
19
+ if (campaignId?.value)
20
+ metadata.campaign_id = campaignId.value;
18
21
  return metadata;
19
22
  }
20
23
  // Try plain object cookies (Express, Pages Router, etc.)
@@ -24,6 +27,8 @@ export function getMetadata(req) {
24
27
  metadata.affiliateo_visitor_id = cookies.affiliateo_visitor_id;
25
28
  if (cookies.affiliateo_ref)
26
29
  metadata.affiliateo_ref = cookies.affiliateo_ref;
30
+ if (cookies.affiliateo_campaign_id)
31
+ metadata.campaign_id = cookies.affiliateo_campaign_id;
27
32
  return metadata;
28
33
  }
29
34
  // Fallback: parse cookie header manually
@@ -36,6 +41,8 @@ export function getMetadata(req) {
36
41
  metadata.affiliateo_visitor_id = cookies.affiliateo_visitor_id;
37
42
  if (cookies.affiliateo_ref)
38
43
  metadata.affiliateo_ref = cookies.affiliateo_ref;
44
+ if (cookies.affiliateo_campaign_id)
45
+ metadata.campaign_id = cookies.affiliateo_campaign_id;
39
46
  }
40
47
  return metadata;
41
48
  }
package/dist/provider.js CHANGED
@@ -55,6 +55,7 @@ export function AffiliateoProvider({ campaignId, apiUrl, children, }) {
55
55
  vid = uuid();
56
56
  }
57
57
  setCookie('affiliateo_visitor_id', vid, 365);
58
+ setCookie('affiliateo_campaign_id', campaignIdRef.current, 365);
58
59
  visitorIdRef.current = vid;
59
60
  // Read ref from URL params
60
61
  const params = new URLSearchParams(window.location.search);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@affiliateo/web",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
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",