@affiliateo/web 1.5.1 → 1.5.2

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.
Files changed (2) hide show
  1. package/dist/provider.js +11 -4
  2. package/package.json +1 -1
package/dist/provider.js CHANGED
@@ -14,7 +14,8 @@ function setCookie(name, value, days) {
14
14
  return;
15
15
  const dt = new Date();
16
16
  dt.setTime(dt.getTime() + days * 864e5);
17
- document.cookie = `${name}=${value};expires=${dt.toUTCString()};path=/;SameSite=Lax`;
17
+ const secure = window.location.protocol === 'https:' ? ';Secure' : '';
18
+ document.cookie = `${name}=${value};expires=${dt.toUTCString()};path=/;SameSite=Lax${secure}`;
18
19
  }
19
20
  // Generate UUID
20
21
  function uuid() {
@@ -52,17 +53,23 @@ export function AffiliateoProvider({ campaignId, apiUrl, children, }) {
52
53
  if (!vid) {
53
54
  vid = uuid();
54
55
  }
55
- setCookie('affiliateo_visitor_id', vid, 365);
56
- setCookie('affiliateo_campaign_id', campaignIdRef.current, 365);
56
+ setCookie('affiliateo_visitor_id', vid, 90);
57
+ setCookie('affiliateo_campaign_id', campaignIdRef.current, 90);
57
58
  // Read ref from URL params
58
59
  const params = new URLSearchParams(window.location.search);
59
60
  const ref = params.get('ref') || params.get('via') || params.get('source') || getCookie('affiliateo_ref') || null;
60
61
  if (ref) {
61
- setCookie('affiliateo_ref', ref, 365);
62
+ setCookie('affiliateo_ref', ref, 90);
62
63
  }
63
64
  setState({ refCode: ref, visitorId: vid });
65
+ // Throttle: max 1 pageview per second
66
+ let lastSendTime = 0;
64
67
  // Send pageview
65
68
  function sendPageview() {
69
+ const now = Date.now();
70
+ if (now - lastSendTime < 1000)
71
+ return;
72
+ lastSendTime = now;
66
73
  const payload = {
67
74
  type: 'pageview',
68
75
  campaign_id: campaignIdRef.current,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@affiliateo/web",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
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",