@hifilabs/pixel 0.0.7 → 0.0.8

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.
@@ -1 +1,20 @@
1
1
  export declare function BalanceAnalytics(): null;
2
+
3
+ // SSR-safe wrapper function type declarations
4
+ export declare const track: (eventName: string, properties?: Record<string, any>) => void;
5
+ export declare const identify: (email: string, traits?: Record<string, any>) => Promise<void>;
6
+ export declare const page: (options?: { title?: string; url?: string }) => void;
7
+ export declare const purchase: (revenue: number, currency?: string, properties?: Record<string, any>) => void;
8
+ export declare const getSessionId: () => string | null;
9
+ export declare const getFanIdHash: () => string | null;
10
+ export declare const getAttribution: () => Record<string, string>;
11
+ export declare const setConsent: (preferences: {
12
+ analytics: boolean;
13
+ marketing: boolean;
14
+ personalization: boolean;
15
+ timestamp: string;
16
+ ip_address?: string;
17
+ user_agent?: string;
18
+ }) => void;
19
+ export declare const getConsent: () => any;
20
+ export declare const hasConsent: (type: 'analytics' | 'marketing' | 'personalization') => boolean;
package/dist/index.esm.js CHANGED
@@ -17,6 +17,89 @@ function BalanceAnalyticsInner() {
17
17
  function BalanceAnalytics() {
18
18
  return /* @__PURE__ */ React.createElement(Suspense, { fallback: null }, /* @__PURE__ */ React.createElement(BalanceAnalyticsInner, null));
19
19
  }
20
+
21
+ // src/index.esm.ts
22
+ var track = (eventName, properties) => {
23
+ if (typeof window === "undefined")
24
+ return;
25
+ if (window.balance) {
26
+ window.balance.track(eventName, properties);
27
+ } else {
28
+ console.warn("[Balance Pixel] track() called before pixel initialized:", eventName);
29
+ }
30
+ };
31
+ var identify = (email, traits) => {
32
+ if (typeof window === "undefined")
33
+ return Promise.resolve();
34
+ if (window.balance) {
35
+ return window.balance.identify(email, traits);
36
+ } else {
37
+ console.warn("[Balance Pixel] identify() called before pixel initialized");
38
+ return Promise.resolve();
39
+ }
40
+ };
41
+ var page = (options) => {
42
+ if (typeof window === "undefined")
43
+ return;
44
+ if (window.balance) {
45
+ window.balance.page(options);
46
+ } else {
47
+ console.warn("[Balance Pixel] page() called before pixel initialized");
48
+ }
49
+ };
50
+ var purchase = (revenue, currency, properties) => {
51
+ if (typeof window === "undefined")
52
+ return;
53
+ if (window.balance) {
54
+ window.balance.purchase(revenue, currency, properties);
55
+ } else {
56
+ console.warn("[Balance Pixel] purchase() called before pixel initialized");
57
+ }
58
+ };
59
+ var getSessionId = () => {
60
+ if (typeof window === "undefined")
61
+ return null;
62
+ return window.balance?.getSessionId() ?? null;
63
+ };
64
+ var getFanIdHash = () => {
65
+ if (typeof window === "undefined")
66
+ return null;
67
+ return window.balance?.getFanIdHash() ?? null;
68
+ };
69
+ var getAttribution = () => {
70
+ if (typeof window === "undefined")
71
+ return {};
72
+ return window.balance?.getAttribution() ?? {};
73
+ };
74
+ var setConsent = (preferences) => {
75
+ if (typeof window === "undefined")
76
+ return;
77
+ if (window.balance) {
78
+ window.balance.setConsent(preferences);
79
+ } else {
80
+ console.warn("[Balance Pixel] setConsent() called before pixel initialized");
81
+ }
82
+ };
83
+ var getConsent = () => {
84
+ if (typeof window === "undefined")
85
+ return null;
86
+ return window.balance?.getConsent() ?? null;
87
+ };
88
+ var hasConsent = (type) => {
89
+ if (typeof window === "undefined")
90
+ return false;
91
+ return window.balance?.hasConsent(type) ?? false;
92
+ };
20
93
  export {
21
- BalanceAnalytics
94
+ BalanceAnalytics,
95
+ getAttribution,
96
+ getConsent,
97
+ getFanIdHash,
98
+ getSessionId,
99
+ hasConsent,
100
+ identify,
101
+ page,
102
+ purchase,
103
+ setConsent,
104
+ track
22
105
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hifilabs/pixel",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "BALANCE Pixel - Lightweight browser tracking script for artist fan analytics",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.esm.js",