@seaverse/track-sdk 0.1.7 → 0.1.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.
package/README.md CHANGED
@@ -21,7 +21,7 @@ npm install @seaverse/track-sdk
21
21
 
22
22
  ## 快速开始
23
23
 
24
- ### 基本使用
24
+ ### 方式 1:npm 包引入(推荐)
25
25
 
26
26
  ```typescript
27
27
  import { TrackClient } from '@seaverse/track-sdk';
@@ -43,6 +43,50 @@ await trackClient.track('button_click', {
43
43
  });
44
44
  ```
45
45
 
46
+ ### 方式 2:浏览器 script 标签引入
47
+
48
+ ```html
49
+ <!DOCTYPE html>
50
+ <html>
51
+ <head>
52
+ <!-- 引入 SDK -->
53
+ <script src="https://unpkg.com/@seaverse/track-sdk/dist/track-sdk.umd.js"></script>
54
+ </head>
55
+ <body>
56
+ <div id="root"></div>
57
+
58
+ <script>
59
+ (function() {
60
+ // 通过全局变量 SeaVerseTrack 访问 SDK
61
+ var TrackClient = SeaVerseTrack.TrackClient;
62
+
63
+ // 创建客户端
64
+ var trackClient = new TrackClient({
65
+ token: 'prod_2f8a9c1b4e3d',
66
+ platform: 'web',
67
+ version: '1.0.0',
68
+ debug: true
69
+ });
70
+
71
+ // 初始化
72
+ trackClient.initialize().then(function() {
73
+ console.log('Track SDK 已初始化');
74
+
75
+ // 手动埋点
76
+ trackClient.track('page_view', {
77
+ page: 'home',
78
+ title: '首页'
79
+ });
80
+ });
81
+
82
+ // 导出到全局,方便后续使用
83
+ window.trackClient = trackClient;
84
+ })();
85
+ </script>
86
+ </body>
87
+ </html>
88
+ ```
89
+
46
90
  ## API 文档
47
91
 
48
92
  ### TrackClient
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var t=require("firebase/app"),e=require("firebase/analytics");function n(t){var e=Object.create(null);return t&&Object.keys(t).forEach(function(n){if("default"!==n){var s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:function(){return t[n]}})}}),e.default=t,Object.freeze(e)}var s,i,r=n(require("sa-sdk-javascript"));function o(t,e){return t-=487,a()[t]}function a(){var t=["SENSORS","1146654tyqhKq","10nlCwks","6YRrjUI","12039401HatPBV","72XvwdCb","10434uhteMd","firebase","44156RUyLGb","sensors","1213328lFGCjJ","583857SmdTeC","367678UKKoWY","1925czWzEC","FIREBASE"];return(a=function(){return t})()}function c(){const t=["https://www.googletagmanager.com/ns.html?id=","640618RtkATm","5771596YgzVZB","undefined","error","3mWjXTI","[GTM] GTM ID is empty, skip injection","noscript","DOMContentLoaded","[GTM] Injected successfully: ","head","insertBefore","1368xVdMEr","from","string","[GoogleTagManager] dataLayer not initialized","[GTM] Injection failed:","push","[GoogleTagManager] Invalid event name:","some","createElement","display","firstChild","7112346RRSoLx","gtm.js?id=","body","dataLayer","script","warn","1180fRRVLg","height","addEventListener","https://www.googletagmanager.com/gtm.js?id=","iframe","log","[GTM] Not in browser environment, skip injection","getElementsByTagName","3049958NkRDxS","visibility","appendChild","5AodEsl","getTime","src","includes","79576OEnzmY","[GTM] Already injected, skip","style","[GoogleTagManager] Error pushing to dataLayer:","async","5539044VErsko","querySelectorAll","1133644CGkfOH","none","parentNode"];return(c=function(){return t})()}function l(){return typeof window!==p(200)&&"undefined"!=typeof document}function p(t,e){t-=187;return c()[t]}function d(t){const e=p,n=document.createElement(e(204)),s=document[e(217)](e(230));s[e(239)]=e(197)+t,s[e(227)]="0",s.width="0",s[e(189)][e(218)]=e(195),s[e(189)][e(235)]="hidden",n[e(236)](s),document[e(222)][e(219)]?document[e(222)][e(208)](n,document[e(222)][e(219)]):document[e(222)].appendChild(n)}function f(t,e=!1){const n=p;if(l())if(t)if(function(t){const e=p;if(!l())return!1;const n=!!window[e(223)],s=document[e(193)](e(224)),i=Array[e(210)](s)[e(216)](n=>n[e(239)][e(240)](e(221)+t));return n&&i}(t))e&&console[n(231)](n(188));else try{(function(t){const e=p;window[e(223)]=window[e(223)]||[],window[e(223)][e(214)]({"gtm.start":(new Date)[e(238)](),event:"gtm.js"});const n=document[e(217)](e(224));n[e(191)]=!0,n[e(239)]=e(229)+t;const s=document[e(233)](e(224))[0];s&&s[e(196)]?s[e(196)][e(208)](n,s):document[e(207)][e(236)](n)})(t),document[n(222)]?d(t):document[n(228)](n(205),()=>{d(t)}),e&&console[n(231)](n(206)+t)}catch(t){console[n(201)](n(213),t)}else e&&console[n(225)](n(203));else e&&console[n(225)](n(232))}!function(){for(var t=o,e=a();;)try{if(582763===-parseInt(t(488))/1+-parseInt(t(489))/2*(-parseInt(t(495))/3)+parseInt(t(487))/4+parseInt(t(490))/5*(-parseInt(t(498))/6)+-parseInt(t(500))/7*(parseInt(t(497))/8)+parseInt(t(493))/9+-parseInt(t(494))/10*(-parseInt(t(496))/11))break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),exports.TrackProvider=void 0,(s=exports.TrackProvider||(exports.TrackProvider={}))[(i=o)(491)]=i(499),s[i(492)]=i(501),function(){const t=p,e=c();for(;;)try{if(864519===-parseInt(t(194))/1+parseInt(t(234))/2*(-parseInt(t(202))/3)+parseInt(t(199))/4*(-parseInt(t(237))/5)+-parseInt(t(220))/6+parseInt(t(192))/7+parseInt(t(187))/8*(-parseInt(t(209))/9)+parseInt(t(226))/10*(parseInt(t(198))/11))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const h=(t,e)=>{const n=p;if(!t||typeof t!==n(211))return void console[n(201)](n(215),t);(t=>{const e=p;if(typeof window!==e(200)&&window[e(223)])try{window[e(223)].push(t),console[e(231)]("[GoogleTagManager] Pushed to dataLayer:",t)}catch(t){console[e(201)](e(190),t)}else console.error(e(212))})({event:t,...e||{}})},u=m;function I(){const t=["18FZZtQY","debug","700bgNZwQ","error","2286tuPkXP","config","initialize","138120PWZQKy","206773GptbWp","gtmId","firebase initialize failed:","150HXAivI","2573968DFuAOj","track","setUserId","initialized","935CxswzO","1415SANPrR","analytics","14468QYfXpR","23632476ouRicX","2639868LReoTB","setUserProperties"];return(I=function(){return t})()}function m(t,e){t-=378;return I()[t]}!function(){const t=m,e=I();for(;;)try{if(942241===-parseInt(t(388))/1*(-parseInt(t(386))/2)+parseInt(t(382))/3+parseInt(t(380))/4*(parseInt(t(378))/5)+-parseInt(t(395))/6*(-parseInt(t(392))/7)+parseInt(t(396))/8*(parseInt(t(384))/9)+-parseInt(t(391))/10*(parseInt(t(400))/11)+-parseInt(t(381))/12)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class w{constructor(t,e,n=!1){const s=m;this[s(379)]=null,this.initialized=!1,this.config=t,this[s(393)]=e,this[s(385)]=n}async[u(390)](){const n=u;if(!this[n(399)])try{const s=t.initializeApp(this[n(389)]);this[n(379)]=e.getAnalytics(s),this[n(393)]&&f(this[n(393)],this[n(385)]),this[n(399)]=!0}catch(t){throw console[n(387)](n(394),t),t}}async[u(397)](t,e){}async[u(398)](t){}async[u(383)](t){}async clearUserId(){}}function k(){const t=["setProfile","config","11294sjMMdj","1978938nmWEDm","initialized","762160ojZOiE","3584zAhxXy","login","sensors sdk init failed:","ajax","sensors sdk clearUserId failed:","sensors sdk setUserProperties failed:","30FsDgRb","?t=","sensors sdk track failed:","showLog","sensors sdk not initialized, skip setUserProperties","sensors","platform","&v=","sensors sdk not initialized, skip setUserId","token","logout","1190484fKqUHH","clearUserId","serverUrl","144FSCrfE","version","autoTrack","track","2341889dLAaZa","warn","setUserProperties","sensors sdk not initialized, skip track","error","init","heatmap","3sRLQwu","29ucSzEm","sensors sdk not found, please install it by running","495642PTzYnZ"];return(k=function(){return t})()}const y=g;function g(t,e){t-=434;return k()[t]}!function(){const t=g,e=k();for(;;)try{if(152940===parseInt(t(455))/1*(-parseInt(t(460))/2)+parseInt(t(454))/3*(-parseInt(t(440))/4)+-parseInt(t(463))/5+-parseInt(t(457))/6+parseInt(t(464))/7*(-parseInt(t(443))/8)+parseInt(t(461))/9+-parseInt(t(470))/10*(-parseInt(t(447))/11))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class v{constructor(t,e,n,s){const i=g;this[i(434)]=null,this[i(462)]=!1,this[i(438)]=t,this[i(435)]=e,this[i(444)]=n,this[i(459)]=s}async initialize(){const t=g;if(!this[t(462)])try{if(!r)throw new Error(t(456));this[t(434)]=r;const e=encodeURIComponent(this[t(438)]),n=encodeURIComponent(this[t(435)]),s=encodeURIComponent(this.version);this[t(434)][t(452)]({server_url:this[t(459)][t(442)]+(t(471)+e+"&p=")+n+t(436)+s,show_log:this[t(459)][t(473)]??!1,heatmap:this[t(459)][t(453)]??{},is_track_single_page:!0,send_type:t(467)}),this[t(462)]=!0,this[t(434)].quick(t(445))}catch(e){throw console.error(t(466),e),e}}async track(t,e){const n=g;if(this[n(462)]&&this.sensors)try{this.sensors[n(446)](t,e??{})}catch(t){console[n(451)](n(472),t)}else console[n(448)](n(450))}async setUserId(t){const e=g;if(this.initialized&&this[e(434)])try{this[e(434)][e(465)](t)}catch(t){console[e(451)]("sensors sdk setUserId failed:",t)}else console[e(448)](e(437))}async[y(449)](t){const e=y;if(this[e(462)]&&this[e(434)])try{this[e(434)][e(458)](t)}catch(t){console[e(451)](e(469),t)}else console.warn(e(474))}async[y(441)](){const t=y;if(this[t(462)]&&this[t(434)])try{this[t(434)][t(439)]()}catch(e){console[t(451)](t(468),e)}}}function z(){var t=["354678dogvAx","btoa","359526ttsFxQ","from","21987130Tpiajt","664182NOyIiu","49xKmsyL","toString","utf-8","379490LZXEay","1100760TSqOmK","4ijpxah","undefined","537210ZXHEiG","atob","base64","48qWMHBu"];return(z=function(){return t})()}function Z(t,e){return t-=153,z()[t]}function b(t){var e=Z;return typeof window!==e(165)&&window.btoa?window[e(154)](t):Buffer.from(t,e(161))[e(160)](e(168))}function M(t){return JSON.parse((e=t,n=Z,"undefined"!=typeof window&&window[n(167)]?window[n(167)](e):Buffer[n(156)](e,n(168))[n(160)](n(161))));var e,n}!function(){for(var t=Z,e=z();;)try{if(291539===-parseInt(t(153))/1+-parseInt(t(158))/2+parseInt(t(163))/3*(-parseInt(t(164))/4)+-parseInt(t(162))/5+parseInt(t(155))/6*(-parseInt(t(159))/7)+-parseInt(t(169))/8*(parseInt(t(166))/9)+parseInt(t(157))/10)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const T=E;function W(){const t=["invalid token: ","384198pYPvQh","324372WilpbA","1340245cvYdnw","152754uuOaag","SENSORS","3PPXWTF","28NhXTrG","eyJhcGlLZXkiOiJBSXphU3lBVVVEam5HdDJKQmdiNVFFYmFFMVFybENvMTdpVWxKWGsiLCJhdXRoRG9tYWluIjoic2VhdmVyc2UtcHJvZHVjdGlvbi5maXJlYmFzZWFwcC5jb20iLCJwcm9qZWN0SWQiOiJzZWF2ZXJzZS1wcm9kdWN0aW9uIiwic3RvcmFnZUJ1Y2tldCI6InNlYXZlcnNlLXByb2R1Y3Rpb24uZmlyZWJhc2VzdG9yYWdlLmFwcCIsIm1lc3NhZ2luZ1NlbmRlcklkIjoiMTAzMzk3MzA4MzE5OCIsImFwcElkIjoiMToxMDMzOTczMDgzMTk4OndlYjo2NmI2ZTNmNmEwZjM2MDkwNmY3NTZmIiwibWVhc3VyZW1lbnRJZCI6IkctN0gySjFTQ05QRCJ9","473216CZJfaY","GTM-MJDRW2W4","eyJzZXJ2ZXJVcmwiOiJodHRwczovL3N2LWFuYWx5dGljcy5zZy5zZWF2ZXJzZS5haS9zYSIsImhlYXRtYXAiOnsiY2xpY2ttYXAiOiJkZWZhdWx0Iiwic2Nyb2xsX25vdGljZV9tYXAiOiJkZWZhdWx0In19","2360610plEQbs","eyJhcGlLZXkiOiJBSXphU3lBVVVEam5HdDJKQmdiNVFFYmFFMVFybENvMTdpVWxKWGsiLCJhdXRoRG9tYWluIjoic2VhdmVyc2UtcHJvZHVjdGlvbi5maXJlYmFzZWFwcC5jb20iLCJwcm9qZWN0SWQiOiJzZWF2ZXJzZS1wcm9kdWN0aW9uIiwic3RvcmFnZUJ1Y2tldCI6InNlYXZlcnNlLXByb2R1Y3Rpb24uZmlyZWJhc2VzdG9yYWdlLmFwcCIsIm1lc3NhZ2luZ1NlbmRlcklkIjoiMTAzMzk3MzA4MzE5OCIsImFwcElkIjoiMToxMDMzOTczMDgzMTk4OndlYjpkMTQ4OGM3MzI0MWIyZWMzNmY3NTZmIiwibWVhc3VyZW1lbnRJZCI6IkctR0gxNk1CQ1NOVyJ9","301116rZpfFW","FIREBASE"];return(W=function(){return t})()}function E(t,e){t-=333;return W()[t]}!function(){const t=E,e=W();for(;;)try{if(227035===parseInt(t(340))/1+-parseInt(t(343))/2+-parseInt(t(348))/3*(-parseInt(t(344))/4)+-parseInt(t(345))/5+parseInt(t(346))/6*(parseInt(t(333))/7)+-parseInt(t(335))/8+parseInt(t(338))/9)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const Y={"MDE5YjUzNTEyMWJhNzc1ZmIwYTQ1MzY3Njg1NzU1MTU=":{providers:[exports.TrackProvider[T(341)],exports.TrackProvider.SENSORS],firebaseConfig:M(T(334)),sensorsConfig:M("eyJzZXJ2ZXJVcmwiOiJodHRwczovL3N2LWFuYWx5dGljcy5zZy5zZWF2ZXJzZS5haS9zYSIsImhlYXRtYXAiOnsiY2xpY2ttYXAiOiJkZWZhdWx0Iiwic2Nyb2xsX25vdGljZV9tYXAiOiJkZWZhdWx0In19"),gtmId:T(336)},"MDE5YjUzNTE3ZmFiN2YxZDkwNjg5OWVhMGQyMWJlZGI=":{providers:[exports.TrackProvider[T(341)],exports.TrackProvider[T(347)]],firebaseConfig:M(T(339)),sensorsConfig:M(T(337))}};const N=R;function R(t,e){t-=143;return J()[t]}function J(){const t=["688465TpRXqg","platform","Must provide a version","firebaseConfig","gtmId","380181RHQacf","log","initializeFirebase","[Track] Clear User ID","FIREBASE"," adapter failed:","token","Track SDK initialized, enabled providers:","version","allSettled","unknown provider: ","20JCPGCX","keys","41433VwwrEk","push","initialize ","debug","platformConfig","initialize","setUserProperties","from","1289510udaYOk","track","Must provide a token","values","Invalid token: ","clearUserId","config","track SDK not initialized, please call initialize() first","warn","initialized","SENSORS","Must provide a platform","4352388KzorHn","1520001jpLeoe","set","50706IgcoHf","trackGTMEvent","validateConfig","providers","setUserId","sensorsConfig","1008JFOLfU","adapters"];return(J=function(){return t})()}!function(){const t=R,e=J();for(;;)try{if(369635===parseInt(t(184))/1+-parseInt(t(143))/2+parseInt(t(171))/3*(parseInt(t(182))/4)+parseInt(t(166))/5+-parseInt(t(155))/6+parseInt(t(156))/7+-parseInt(t(164))/8*(-parseInt(t(158))/9))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class TrackClient{constructor(t){const e=R;this[e(165)]=new Map,this.initialized=!1,this[e(149)]=t,this[e(160)](),this.platformConfig=function(t){const e=T,n=b(t),s=Y[n];if(!s)throw new Error(e(342)+t);return s}(t[e(177)])}[N(160)](){const t=N;if(!this[t(149)][t(177)])throw new Error(t(145));if(!this.config[t(167)])throw new Error(t(154));if(!this[t(149)][t(179)])throw new Error(t(168));if(!(b(this[t(149)].token)in Y))throw new Error(t(147)+this[t(149)][t(177)])}async[N(189)](){const t=N;if(this[t(152)])return;const e=[],n=!1!==this[t(149)][t(173)];for(const s of this[t(188)][t(161)])try{if(s===exports.TrackProvider[t(175)]&&!n){this[t(149)][t(187)]&&console[t(172)]("[Track] Skip Firebase initialization (initializeFirebase = false)");continue}let i;switch(s){case exports.TrackProvider.FIREBASE:i=new w(this[t(188)][t(169)],this[t(188)][t(170)],this[t(149)][t(187)]);break;case exports.TrackProvider[t(153)]:i=new v(this[t(149)][t(177)],this[t(149)][t(167)],this.config[t(179)],this[t(188)][t(163)]);break;default:console[t(151)](t(181)+s);continue}this.adapters[t(157)](s,i),e[t(185)](i[t(189)]())}catch(e){console.error(t(186)+s+t(176),e)}await Promise[t(180)](e),this.initialized=!0,this[t(149)][t(187)]&&console[t(172)](t(178),Array[t(191)](this[t(165)][t(183)]()))}async[N(144)](t,e){const n=N;if(!this[n(152)])return void console.warn(n(150));this[n(149)].debug&&console[n(172)]("[Track] "+t,e);const s=[];for(const i of this[n(165)].values())s[n(185)](i.track(t,e));await Promise.allSettled(s)}async[N(162)](t){const e=N;if(!this[e(152)])return void console[e(151)](e(150));this[e(149)][e(187)]&&console[e(172)]("[Track] Set User ID:",t);const n=[];for(const s of this[e(165)][e(146)]())n.push(s[e(162)](t));await Promise[e(180)](n)}async[N(190)](t){const e=N;if(!this[e(152)])return void console[e(151)](e(150));this[e(149)][e(187)]&&console[e(172)]("[Track] Set User Properties:",t);const n=[];for(const s of this[e(165)][e(146)]())n[e(185)](s[e(190)](t));await Promise[e(180)](n)}async[N(148)](){const t=N;if(!this[t(152)])return void console[t(151)]("track SDK not initialized, please call initialize() first");this[t(149)][t(187)]&&console.log(t(174));const e=[];for(const n of this[t(165)][t(146)]())e[t(185)](n[t(148)]());await Promise[t(180)](e)}getInitializedProviders(){const t=N;return Array[t(191)](this[t(165)][t(183)]())}[N(159)](t,e){h(t,e)}}function j(t,e){return t-=329,S()[t]}function S(){var t=["6196705GwhpAJ","1426217cdUrKE","684760FfrYQM","4448580BvamqL","3871042YoPffK","1989099RgqctH","3322020sfEcMR","6ewsuwv"];return(S=function(){return t})()}!function(){for(var t=j,e=S();;)try{if(986249===parseInt(t(332))/1+-parseInt(t(329))/2+-parseInt(t(336))/3+parseInt(t(334))/4+parseInt(t(331))/5*(parseInt(t(330))/6)+-parseInt(t(335))/7+parseInt(t(333))/8)break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),exports.TrackClient=TrackClient;
1
+ "use strict";var t=require("firebase/app"),e=require("firebase/analytics");function n(t){var e=Object.create(null);return t&&Object.keys(t).forEach(function(n){if("default"!==n){var s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:function(){return t[n]}})}}),e.default=t,Object.freeze(e)}var s,r,i=n(require("sa-sdk-javascript"));function o(){var t=["266630WQEgeg","8084260Gwkmpn","102876MNNirj","9oBUWgH","1086JVxqHO","FIREBASE","firebase","7884527IuLNMS","2708VmpVMI","6904760KdorOo","10HEMeef","1405132wdAqhR"];return(o=function(){return t})()}function a(t,e){return t-=110,o()[t]}function c(){return"undefined"!=typeof window&&typeof document!==d(467)}function p(t){const e=d,n=document[e(468)](e(461)),s=document.createElement(e(464));s[e(428)]=e(431)+t,s[e(427)]="0",s[e(444)]="0",s[e(447)][e(465)]="none",s[e(447)][e(451)]=e(434),n[e(466)](s),document[e(459)][e(424)]?document.body[e(432)](n,document[e(459)][e(424)]):document[e(459)][e(466)](n)}function l(){const t=["getElementsByTagName","[GoogleTagManager] Invalid event name:","[GTM] Not in browser environment, skip injection","parentNode","from","dataLayer","gtm.js","error","push","width","includes","addEventListener","style","gtm.js?id=","1995KNOmbF","[GoogleTagManager] dataLayer not initialized","visibility","940856xGuYiz","1086606MumUOa","querySelectorAll","3IZygjE","5qcHCel","2144836tdPmXG","6162264PJMVLY","body","3097290LwpAZb","noscript","DOMContentLoaded","string","iframe","display","appendChild","undefined","createElement","log","[GTM] Injected successfully: ","[GoogleTagManager] Pushed to dataLayer:","[GoogleTagManager] Error pushing to dataLayer:","https://www.googletagmanager.com/gtm.js?id=","1644ijRnpH","firstChild","11fXFJJJ","[GTM] Already injected, skip","height","src","script","warn","https://www.googletagmanager.com/ns.html?id=","insertBefore","1907678oEzRUS","hidden"];return(l=function(){return t})()}function d(t,e){t-=423;return l()[t]}function f(t,e=!1){const n=d;if(c())if(t)if(function(t){const e=d;if(!c())return!1;const n=!!window.dataLayer,s=document[e(454)]("script"),r=Array[e(439)](s).some(n=>n.src[e(445)](e(448)+t));return n&&r}(t))e&&console[n(469)](n(426));else try{(function(t){const e=d;window[e(440)]=window[e(440)]||[],window[e(440)][e(443)]({"gtm.start":(new Date).getTime(),event:e(441)});const n=document[e(468)](e(429));n.async=!0,n[e(428)]=e(473)+t;const s=document[e(435)]("script")[0];s&&s[e(438)]?s[e(438)][e(432)](n,s):document.head[e(466)](n)})(t),document[n(459)]?p(t):document[n(446)](n(462),()=>{p(t)}),e&&console[n(469)](n(470)+t)}catch(t){console.error("[GTM] Injection failed:",t)}else e&&console[n(430)]("[GTM] GTM ID is empty, skip injection");else e&&console[n(430)](n(437))}!function(){for(var t=a,e=o();;)try{if(916363===parseInt(t(110))/1+-parseInt(t(118))/2*(-parseInt(t(114))/3)+-parseInt(t(121))/4+-parseInt(t(120))/5*(parseInt(t(112))/6)+-parseInt(t(117))/7+-parseInt(t(119))/8*(-parseInt(t(113))/9)+parseInt(t(111))/10)break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),exports.TrackProvider=void 0,(s=exports.TrackProvider||(exports.TrackProvider={}))[(r=a)(115)]=r(116),s.SENSORS="sensors",function(){const t=d,e=l();for(;;)try{if(477298===parseInt(t(452))/1+-parseInt(t(433))/2*(-parseInt(t(455))/3)+-parseInt(t(457))/4*(parseInt(t(456))/5)+parseInt(t(423))/6*(parseInt(t(449))/7)+-parseInt(t(458))/8+parseInt(t(453))/9+-parseInt(t(460))/10*(parseInt(t(425))/11))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const h=(t,e)=>{const n=d;if(!t||typeof t!==n(463))return void console[n(442)](n(436),t);(t=>{const e=d;if("undefined"!=typeof window&&window[e(440)])try{window.dataLayer.push(t),console[e(469)](e(471),t)}catch(t){console[e(442)](e(472),t)}else console[e(442)](e(450))})({event:t,...e||{}})};function u(){const t=["initialize","6865749kKmkXt","firebase initialize failed:","setUserId","535510AyhiXh","267365CMuyqM","54iyPSYI","gtmId","error","203krptMd","config","analytics","135832pDFpNV","1801512AzpHYc","initialized","setUserProperties","debug","181486qSVsrn","2110504syzdMf"];return(u=function(){return t})()}const I=m;function m(t,e){t-=294;return u()[t]}!function(){const t=m,e=u();for(;;)try{if(379838===-parseInt(t(304))/1+parseInt(t(298))/2+parseInt(t(294))/3+-parseInt(t(299))/4+parseInt(t(305))/5*(parseInt(t(306))/6)+parseInt(t(309))/7*(-parseInt(t(312))/8)+parseInt(t(301))/9)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class y{constructor(t,e,n=!1){const s=m;this[s(311)]=null,this[s(295)]=!1,this[s(310)]=t,this[s(307)]=e,this[s(297)]=n}async[I(300)](){const n=I;if(!this[n(295)])try{const s=t.initializeApp(this.config);this[n(311)]=e.getAnalytics(s),this[n(307)]&&f(this[n(307)],this[n(297)]),this[n(295)]=!0}catch(t){throw console[n(308)](n(302),t),t}}async track(t,e){}async[I(303)](t){}async[I(296)](t){}async clearUserId(){}}const k=w;function w(t,e){t-=338;return g()[t]}function g(){const t=["2253844yrthQG","clearUserId","version","track","sensors sdk setUserProperties failed:","serverUrl","quick","192871KPyxAZ","3719914DpAjgF","setUserProperties","token","&p=","init","sensors sdk not initialized, skip setUserProperties","initialize","login","3UpfjGX","14muZHbM","2192624VUbNFK","logout","sensors sdk setUserId failed:","setProfile","error","?t=","config","9nlDcMt","ajax","20390yUPCYp","platform","2317225LepUxm","sensors sdk not initialized, skip track","sensors sdk init failed:","sensors sdk track failed:","6ViKenG","autoTrack","setUserId","6795980OStkob","initialized","heatmap","warn","showLog","sensors"];return(g=function(){return t})()}!function(){const t=w,e=g();for(;;)try{if(728533===-parseInt(t(347))/1*(parseInt(t(379))/2)+-parseInt(t(378))/3*(-parseInt(t(362))/4)+-parseInt(t(349))/5+parseInt(t(353))/6*(parseInt(t(369))/7)+-parseInt(t(338))/8+parseInt(t(345))/9*(parseInt(t(356))/10)+parseInt(t(370))/11)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class v{constructor(t,e,n,s){const r=w;this[r(361)]=null,this[r(357)]=!1,this[r(372)]=t,this[r(348)]=e,this[r(364)]=n,this[r(344)]=s}async[k(376)](){const t=k;if(!this[t(357)])try{if(!i)throw new Error("sensors sdk not found, please install it by running");this[t(361)]=i;const e=encodeURIComponent(this[t(372)]),n=encodeURIComponent(this[t(348)]),s=encodeURIComponent(this[t(364)]);this.sensors[t(374)]({server_url:this[t(344)][t(367)]+(t(343)+e+t(373)+n+"&v=")+s,show_log:this[t(344)][t(360)]??!1,heatmap:this[t(344)][t(358)]??{},is_track_single_page:!0,send_type:t(346)}),this.initialized=!0,this[t(361)][t(368)](t(354))}catch(e){throw console.error(t(351),e),e}}async track(t,e){const n=k;if(this[n(357)]&&this[n(361)])try{this[n(361)][n(365)](t,e??{})}catch(t){console.error(n(352),t)}else console[n(359)](n(350))}async[k(355)](t){const e=k;if(this[e(357)]&&this[e(361)])try{this[e(361)][e(377)](t)}catch(t){console.error(e(340),t)}else console[e(359)]("sensors sdk not initialized, skip setUserId")}async[k(371)](t){const e=k;if(this.initialized&&this[e(361)])try{this[e(361)][e(341)](t)}catch(t){console[e(342)](e(366),t)}else console.warn(e(375))}async[k(363)](){const t=k;if(this.initialized&&this[t(361)])try{this.sensors[t(339)]()}catch(e){console[t(342)]("sensors sdk clearUserId failed:",e)}}}function z(t,e){return t-=301,M()[t]}function M(){var t=["8KZlNgG","base64","3147105DvZkNe","173660koNbLk","parse","undefined","89222sKQnWL","from","188166WnnXcq","btoa","toString","30TqvAiq","110JfgJRr","367647XnXNNB","2143792TTrWUj","4964553EWSvAG","atob","70DWkDbE","utf-8"];return(M=function(){return t})()}function b(t){var e=z;return typeof window!==e(317)&&window.btoa?window[e(302)](t):Buffer[e(319)](t,"utf-8")[e(303)](e(313))}function T(t){var e,n;return JSON[z(316)]((e=t,n=z,typeof window!==n(317)&&window[n(309)]?window.atob(e):Buffer[n(319)](e,"base64").toString(n(311))))}function Z(t,e){t-=498;return N()[t]}function N(){const t=["1DVCTvZ","SENSORS","invalid token: ","11StUIsX","3wRXvUP","11024VcSINT","414085cVJBym","10569792ekicaX","2079842aQcCYy","4316852ceOsfM","12nQouaa","eyJzZXJ2ZXJVcmwiOiJodHRwczovL3N2LWFuYWx5dGljcy5zZy5zZWF2ZXJzZS5haS9zYSIsImhlYXRtYXAiOnsiY2xpY2ttYXAiOiJkZWZhdWx0Iiwic2Nyb2xsX25vdGljZV9tYXAiOiJkZWZhdWx0In19","1911955vqBTOm","79408gWilEy","32AFvNUo","eyJhcGlLZXkiOiJBSXphU3lBVVVEam5HdDJKQmdiNVFFYmFFMVFybENvMTdpVWxKWGsiLCJhdXRoRG9tYWluIjoic2VhdmVyc2UtcHJvZHVjdGlvbi5maXJlYmFzZWFwcC5jb20iLCJwcm9qZWN0SWQiOiJzZWF2ZXJzZS1wcm9kdWN0aW9uIiwic3RvcmFnZUJ1Y2tldCI6InNlYXZlcnNlLXByb2R1Y3Rpb24uZmlyZWJhc2VzdG9yYWdlLmFwcCIsIm1lc3NhZ2luZ1NlbmRlcklkIjoiMTAzMzk3MzA4MzE5OCIsImFwcElkIjoiMToxMDMzOTczMDgzMTk4OndlYjo2NmI2ZTNmNmEwZjM2MDkwNmY3NTZmIiwibWVhc3VyZW1lbnRJZCI6IkctN0gySjFTQ05QRCJ9","2110pslODE","FIREBASE","5598hwjtqo","eyJhcGlLZXkiOiJBSXphU3lBVVVEam5HdDJKQmdiNVFFYmFFMVFybENvMTdpVWxKWGsiLCJhdXRoRG9tYWluIjoic2VhdmVyc2UtcHJvZHVjdGlvbi5maXJlYmFzZWFwcC5jb20iLCJwcm9qZWN0SWQiOiJzZWF2ZXJzZS1wcm9kdWN0aW9uIiwic3RvcmFnZUJ1Y2tldCI6InNlYXZlcnNlLXByb2R1Y3Rpb24uZmlyZWJhc2VzdG9yYWdlLmFwcCIsIm1lc3NhZ2luZ1NlbmRlcklkIjoiMTAzMzk3MzA4MzE5OCIsImFwcElkIjoiMToxMDMzOTczMDgzMTk4OndlYjpkMTQ4OGM3MzI0MWIyZWMzNmY3NTZmIiwibWVhc3VyZW1lbnRJZCI6IkctR0gxNk1CQ1NOVyJ9"];return(N=function(){return t})()}!function(){for(var t=z,e=M();;)try{if(339955===parseInt(t(306))/1+parseInt(t(318))/2*(parseInt(t(304))/3)+-parseInt(t(307))/4+-parseInt(t(314))/5+-parseInt(t(301))/6*(-parseInt(t(310))/7)+-parseInt(t(312))/8*(-parseInt(t(308))/9)+-parseInt(t(315))/10*(parseInt(t(305))/11))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const W=Z;!function(){const t=Z,e=N();for(;;)try{if(677262===parseInt(t(516))/1*(-parseInt(t(504))/2)+parseInt(t(500))/3*(-parseInt(t(505))/4)+-parseInt(t(508))/5*(parseInt(t(506))/6)+-parseInt(t(502))/7*(parseInt(t(510))/8)+parseInt(t(514))/9*(-parseInt(t(512))/10)+parseInt(t(499))/11*(-parseInt(t(503))/12)+parseInt(t(501))/13*(parseInt(t(509))/14))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const J={"MDE5YjUzNTEyMWJhNzc1ZmIwYTQ1MzY3Njg1NzU1MTU=":{providers:[exports.TrackProvider[W(513)],exports.TrackProvider[W(517)]],firebaseConfig:T(W(511)),sensorsConfig:T(W(507)),gtmId:"GTM-MJDRW2W4"},"MDE5YjUzNTE3ZmFiN2YxZDkwNjg5OWVhMGQyMWJlZGI=":{providers:[exports.TrackProvider[W(513)],exports.TrackProvider[W(517)]],firebaseConfig:T(W(515)),sensorsConfig:T(W(507))}};const E=F;function U(){const t=["firebaseConfig","values","2125132WMCwIt","initialize ","[Track] ","adapters","push","935uMKUzJ"," adapter failed:","platformConfig","61566uVbham","track","error","clearUserId","from","debug","log","[Track] Clear User ID","track SDK not initialized, please call initialize() first","config","770640PdAJRY","FIREBASE","validateConfig","set","platform","initialize","206576DnkFZJ","1150758ziXmIu","initialized","455LOzOnL","45352386pEycNg","getInitializedProviders","warn","[Track] Skip Firebase initialization (initializeFirebase = false)","Must provide a token","setUserProperties","Must provide a version","token","setUserId","trackGTMEvent","allSettled","version","unknown provider: ","sensorsConfig","keys","providers","789159WeRfAK"];return(U=function(){return t})()}function F(t,e){t-=266;return U()[t]}!function(){const t=F,e=U();for(;;)try{if(986054===parseInt(t(309))/1+parseInt(t(312))/2+parseInt(t(290))/3+parseInt(t(283))/4+-parseInt(t(270))/5*(-parseInt(t(273))/6)+parseInt(t(292))/7*(parseInt(t(289))/8)+-parseInt(t(293))/9)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class TrackClient{constructor(t){const e=F;this[e(268)]=new Map,this[e(291)]=!1,this.config=t,this[e(285)](),this.platformConfig=function(t){const e=W,n=b(t),s=J[n];if(!s)throw new Error(e(498)+t);return s}(t[e(300)])}[E(285)](){const t=E;if(!this[t(282)][t(300)])throw new Error(t(297));if(!this[t(282)][t(287)])throw new Error("Must provide a platform");if(!this.config[t(304)])throw new Error(t(299));if(!(b(this.config[t(300)])in J))throw new Error("Invalid token: "+this[t(282)][t(300)])}async[E(288)](){const t=E;if(this[t(291)])return;const e=[],n=!1!==this[t(282)].initializeFirebase;for(const s of this.platformConfig[t(308)])try{if(s===exports.TrackProvider[t(284)]&&!n){this[t(282)][t(278)]&&console[t(279)](t(296));continue}let r;switch(s){case exports.TrackProvider.FIREBASE:r=new y(this[t(272)][t(310)],this[t(272)].gtmId,this[t(282)][t(278)]);break;case exports.TrackProvider.SENSORS:r=new v(this[t(282)][t(300)],this[t(282)][t(287)],this.config.version,this.platformConfig[t(306)]);break;default:console.warn(t(305)+s);continue}this[t(268)][t(286)](s,r),e[t(269)](r[t(288)]())}catch(e){console[t(275)](t(266)+s+t(271),e)}await Promise[t(303)](e),this.initialized=!0,this[t(282)][t(278)]&&console[t(279)]("Track SDK initialized, enabled providers:",Array[t(277)](this[t(268)][t(307)]()))}async[E(274)](t,e){const n=E;if(!this.initialized)return void console.warn(n(281));this[n(282)][n(278)]&&console[n(279)](n(267)+t,e);const s=[];for(const r of this[n(268)][n(311)]())s[n(269)](r[n(274)](t,e));await Promise[n(303)](s)}async setUserId(t){const e=E;if(!this.initialized)return void console[e(295)](e(281));this[e(282)][e(278)]&&console[e(279)]("[Track] Set User ID:",t);const n=[];for(const s of this[e(268)][e(311)]())n[e(269)](s[e(301)](t));await Promise[e(303)](n)}async[E(298)](t){const e=E;if(!this[e(291)])return void console[e(295)](e(281));this[e(282)].debug&&console[e(279)]("[Track] Set User Properties:",t);const n=[];for(const s of this[e(268)][e(311)]())n[e(269)](s[e(298)](t));await Promise.allSettled(n)}async[E(276)](){const t=E;if(!this[t(291)])return void console[t(295)](t(281));this[t(282)][t(278)]&&console[t(279)](t(280));const e=[];for(const n of this[t(268)][t(311)]())e.push(n.clearUserId());await Promise[t(303)](e)}[E(294)](){const t=E;return Array[t(277)](this.adapters[t(307)]())}[E(302)](t,e){h(t,e)}}function S(t,e){return t-=152,j()[t]}function j(){var t=["22IJVTPY","8YZfOxx","2393741APrFmu","1590366vQfUYd","197661mNFKsx","485PWrTEH","5820348hkMsgk","21078NFnsaZ","6036DsTmFb","1780zTBUzW","43362TgsWSy","11aVrZAB"];return(j=function(){return t})()}!function(){for(var t=S,e=j();;)try{if(330095===parseInt(t(152))/1+parseInt(t(160))/2*(-parseInt(t(158))/3)+-parseInt(t(156))/4*(-parseInt(t(153))/5)+-parseInt(t(163))/6+parseInt(t(162))/7*(parseInt(t(161))/8)+parseInt(t(155))/9*(-parseInt(t(157))/10)+-parseInt(t(159))/11*(-parseInt(t(154))/12))break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),exports.TrackClient=TrackClient;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{initializeApp as t}from"firebase/app";import{getAnalytics as n}from"firebase/analytics";import*as s from"sa-sdk-javascript";var e,i,r;function o(t,n){return t-=487,a()[t]}function a(){var t=["SENSORS","1146654tyqhKq","10nlCwks","6YRrjUI","12039401HatPBV","72XvwdCb","10434uhteMd","firebase","44156RUyLGb","sensors","1213328lFGCjJ","583857SmdTeC","367678UKKoWY","1925czWzEC","FIREBASE"];return(a=function(){return t})()}function c(){const t=["https://www.googletagmanager.com/ns.html?id=","640618RtkATm","5771596YgzVZB","undefined","error","3mWjXTI","[GTM] GTM ID is empty, skip injection","noscript","DOMContentLoaded","[GTM] Injected successfully: ","head","insertBefore","1368xVdMEr","from","string","[GoogleTagManager] dataLayer not initialized","[GTM] Injection failed:","push","[GoogleTagManager] Invalid event name:","some","createElement","display","firstChild","7112346RRSoLx","gtm.js?id=","body","dataLayer","script","warn","1180fRRVLg","height","addEventListener","https://www.googletagmanager.com/gtm.js?id=","iframe","log","[GTM] Not in browser environment, skip injection","getElementsByTagName","3049958NkRDxS","visibility","appendChild","5AodEsl","getTime","src","includes","79576OEnzmY","[GTM] Already injected, skip","style","[GoogleTagManager] Error pushing to dataLayer:","async","5539044VErsko","querySelectorAll","1133644CGkfOH","none","parentNode"];return(c=function(){return t})()}function l(){return typeof window!==h(200)&&"undefined"!=typeof document}function h(t,n){t-=187;return c()[t]}function p(t){const n=h,s=document.createElement(n(204)),e=document[n(217)](n(230));e[n(239)]=n(197)+t,e[n(227)]="0",e.width="0",e[n(189)][n(218)]=n(195),e[n(189)][n(235)]="hidden",s[n(236)](e),document[n(222)][n(219)]?document[n(222)][n(208)](s,document[n(222)][n(219)]):document[n(222)].appendChild(s)}function f(t,n=!1){const s=h;if(l())if(t)if(function(t){const n=h;if(!l())return!1;const s=!!window[n(223)],e=document[n(193)](n(224)),i=Array[n(210)](e)[n(216)](s=>s[n(239)][n(240)](n(221)+t));return s&&i}(t))n&&console[s(231)](s(188));else try{(function(t){const n=h;window[n(223)]=window[n(223)]||[],window[n(223)][n(214)]({"gtm.start":(new Date)[n(238)](),event:"gtm.js"});const s=document[n(217)](n(224));s[n(191)]=!0,s[n(239)]=n(229)+t;const e=document[n(233)](n(224))[0];e&&e[n(196)]?e[n(196)][n(208)](s,e):document[n(207)][n(236)](s)})(t),document[s(222)]?p(t):document[s(228)](s(205),()=>{p(t)}),n&&console[s(231)](s(206)+t)}catch(t){console[s(201)](s(213),t)}else n&&console[s(225)](s(203));else n&&console[s(225)](s(232))}!function(){for(var t=o,n=a();;)try{if(582763===-parseInt(t(488))/1+-parseInt(t(489))/2*(-parseInt(t(495))/3)+parseInt(t(487))/4+parseInt(t(490))/5*(-parseInt(t(498))/6)+-parseInt(t(500))/7*(parseInt(t(497))/8)+parseInt(t(493))/9+-parseInt(t(494))/10*(-parseInt(t(496))/11))break;n.push(n.shift())}catch(t){n.push(n.shift())}}(),(i=e||(e={}))[(r=o)(491)]=r(499),i[r(492)]=r(501),function(){const t=h,n=c();for(;;)try{if(864519===-parseInt(t(194))/1+parseInt(t(234))/2*(-parseInt(t(202))/3)+parseInt(t(199))/4*(-parseInt(t(237))/5)+-parseInt(t(220))/6+parseInt(t(192))/7+parseInt(t(187))/8*(-parseInt(t(209))/9)+parseInt(t(226))/10*(parseInt(t(198))/11))break;n.push(n.shift())}catch(t){n.push(n.shift())}}();const d=(t,n)=>{const s=h;if(!t||typeof t!==s(211))return void console[s(201)](s(215),t);(t=>{const n=h;if(typeof window!==n(200)&&window[n(223)])try{window[n(223)].push(t),console[n(231)]("[GoogleTagManager] Pushed to dataLayer:",t)}catch(t){console[n(201)](n(190),t)}else console.error(n(212))})({event:t,...n||{}})},u=m;function I(){const t=["18FZZtQY","debug","700bgNZwQ","error","2286tuPkXP","config","initialize","138120PWZQKy","206773GptbWp","gtmId","firebase initialize failed:","150HXAivI","2573968DFuAOj","track","setUserId","initialized","935CxswzO","1415SANPrR","analytics","14468QYfXpR","23632476ouRicX","2639868LReoTB","setUserProperties"];return(I=function(){return t})()}function m(t,n){t-=378;return I()[t]}!function(){const t=m,n=I();for(;;)try{if(942241===-parseInt(t(388))/1*(-parseInt(t(386))/2)+parseInt(t(382))/3+parseInt(t(380))/4*(parseInt(t(378))/5)+-parseInt(t(395))/6*(-parseInt(t(392))/7)+parseInt(t(396))/8*(parseInt(t(384))/9)+-parseInt(t(391))/10*(parseInt(t(400))/11)+-parseInt(t(381))/12)break;n.push(n.shift())}catch(t){n.push(n.shift())}}();class w{constructor(t,n,s=!1){const e=m;this[e(379)]=null,this.initialized=!1,this.config=t,this[e(393)]=n,this[e(385)]=s}async[u(390)](){const s=u;if(!this[s(399)])try{const e=t(this[s(389)]);this[s(379)]=n(e),this[s(393)]&&f(this[s(393)],this[s(385)]),this[s(399)]=!0}catch(t){throw console[s(387)](s(394),t),t}}async[u(397)](t,n){}async[u(398)](t){}async[u(383)](t){}async clearUserId(){}}function y(){const t=["setProfile","config","11294sjMMdj","1978938nmWEDm","initialized","762160ojZOiE","3584zAhxXy","login","sensors sdk init failed:","ajax","sensors sdk clearUserId failed:","sensors sdk setUserProperties failed:","30FsDgRb","?t=","sensors sdk track failed:","showLog","sensors sdk not initialized, skip setUserProperties","sensors","platform","&v=","sensors sdk not initialized, skip setUserId","token","logout","1190484fKqUHH","clearUserId","serverUrl","144FSCrfE","version","autoTrack","track","2341889dLAaZa","warn","setUserProperties","sensors sdk not initialized, skip track","error","init","heatmap","3sRLQwu","29ucSzEm","sensors sdk not found, please install it by running","495642PTzYnZ"];return(y=function(){return t})()}const k=g;function g(t,n){t-=434;return y()[t]}!function(){const t=g,n=y();for(;;)try{if(152940===parseInt(t(455))/1*(-parseInt(t(460))/2)+parseInt(t(454))/3*(-parseInt(t(440))/4)+-parseInt(t(463))/5+-parseInt(t(457))/6+parseInt(t(464))/7*(-parseInt(t(443))/8)+parseInt(t(461))/9+-parseInt(t(470))/10*(-parseInt(t(447))/11))break;n.push(n.shift())}catch(t){n.push(n.shift())}}();class z{constructor(t,n,s,e){const i=g;this[i(434)]=null,this[i(462)]=!1,this[i(438)]=t,this[i(435)]=n,this[i(444)]=s,this[i(459)]=e}async initialize(){const t=g;if(!this[t(462)])try{if(!s)throw new Error(t(456));this[t(434)]=s;const n=encodeURIComponent(this[t(438)]),e=encodeURIComponent(this[t(435)]),i=encodeURIComponent(this.version);this[t(434)][t(452)]({server_url:this[t(459)][t(442)]+(t(471)+n+"&p=")+e+t(436)+i,show_log:this[t(459)][t(473)]??!1,heatmap:this[t(459)][t(453)]??{},is_track_single_page:!0,send_type:t(467)}),this[t(462)]=!0,this[t(434)].quick(t(445))}catch(n){throw console.error(t(466),n),n}}async track(t,n){const s=g;if(this[s(462)]&&this.sensors)try{this.sensors[s(446)](t,n??{})}catch(t){console[s(451)](s(472),t)}else console[s(448)](s(450))}async setUserId(t){const n=g;if(this.initialized&&this[n(434)])try{this[n(434)][n(465)](t)}catch(t){console[n(451)]("sensors sdk setUserId failed:",t)}else console[n(448)](n(437))}async[k(449)](t){const n=k;if(this[n(462)]&&this[n(434)])try{this[n(434)][n(458)](t)}catch(t){console[n(451)](n(469),t)}else console.warn(n(474))}async[k(441)](){const t=k;if(this[t(462)]&&this[t(434)])try{this[t(434)][t(439)]()}catch(n){console[t(451)](t(468),n)}}}function Z(){var t=["354678dogvAx","btoa","359526ttsFxQ","from","21987130Tpiajt","664182NOyIiu","49xKmsyL","toString","utf-8","379490LZXEay","1100760TSqOmK","4ijpxah","undefined","537210ZXHEiG","atob","base64","48qWMHBu"];return(Z=function(){return t})()}function v(t,n){return t-=153,Z()[t]}function M(t){var n=v;return typeof window!==n(165)&&window.btoa?window[n(154)](t):Buffer.from(t,n(161))[n(160)](n(168))}function b(t){return JSON.parse((n=t,s=v,"undefined"!=typeof window&&window[s(167)]?window[s(167)](n):Buffer[s(156)](n,s(168))[s(160)](s(161))));var n,s}!function(){for(var t=v,n=Z();;)try{if(291539===-parseInt(t(153))/1+-parseInt(t(158))/2+parseInt(t(163))/3*(-parseInt(t(164))/4)+-parseInt(t(162))/5+parseInt(t(155))/6*(-parseInt(t(159))/7)+-parseInt(t(169))/8*(parseInt(t(166))/9)+parseInt(t(157))/10)break;n.push(n.shift())}catch(t){n.push(n.shift())}}();const W=Y;function E(){const t=["invalid token: ","384198pYPvQh","324372WilpbA","1340245cvYdnw","152754uuOaag","SENSORS","3PPXWTF","28NhXTrG","eyJhcGlLZXkiOiJBSXphU3lBVVVEam5HdDJKQmdiNVFFYmFFMVFybENvMTdpVWxKWGsiLCJhdXRoRG9tYWluIjoic2VhdmVyc2UtcHJvZHVjdGlvbi5maXJlYmFzZWFwcC5jb20iLCJwcm9qZWN0SWQiOiJzZWF2ZXJzZS1wcm9kdWN0aW9uIiwic3RvcmFnZUJ1Y2tldCI6InNlYXZlcnNlLXByb2R1Y3Rpb24uZmlyZWJhc2VzdG9yYWdlLmFwcCIsIm1lc3NhZ2luZ1NlbmRlcklkIjoiMTAzMzk3MzA4MzE5OCIsImFwcElkIjoiMToxMDMzOTczMDgzMTk4OndlYjo2NmI2ZTNmNmEwZjM2MDkwNmY3NTZmIiwibWVhc3VyZW1lbnRJZCI6IkctN0gySjFTQ05QRCJ9","473216CZJfaY","GTM-MJDRW2W4","eyJzZXJ2ZXJVcmwiOiJodHRwczovL3N2LWFuYWx5dGljcy5zZy5zZWF2ZXJzZS5haS9zYSIsImhlYXRtYXAiOnsiY2xpY2ttYXAiOiJkZWZhdWx0Iiwic2Nyb2xsX25vdGljZV9tYXAiOiJkZWZhdWx0In19","2360610plEQbs","eyJhcGlLZXkiOiJBSXphU3lBVVVEam5HdDJKQmdiNVFFYmFFMVFybENvMTdpVWxKWGsiLCJhdXRoRG9tYWluIjoic2VhdmVyc2UtcHJvZHVjdGlvbi5maXJlYmFzZWFwcC5jb20iLCJwcm9qZWN0SWQiOiJzZWF2ZXJzZS1wcm9kdWN0aW9uIiwic3RvcmFnZUJ1Y2tldCI6InNlYXZlcnNlLXByb2R1Y3Rpb24uZmlyZWJhc2VzdG9yYWdlLmFwcCIsIm1lc3NhZ2luZ1NlbmRlcklkIjoiMTAzMzk3MzA4MzE5OCIsImFwcElkIjoiMToxMDMzOTczMDgzMTk4OndlYjpkMTQ4OGM3MzI0MWIyZWMzNmY3NTZmIiwibWVhc3VyZW1lbnRJZCI6IkctR0gxNk1CQ1NOVyJ9","301116rZpfFW","FIREBASE"];return(E=function(){return t})()}function Y(t,n){t-=333;return E()[t]}!function(){const t=Y,n=E();for(;;)try{if(227035===parseInt(t(340))/1+-parseInt(t(343))/2+-parseInt(t(348))/3*(-parseInt(t(344))/4)+-parseInt(t(345))/5+parseInt(t(346))/6*(parseInt(t(333))/7)+-parseInt(t(335))/8+parseInt(t(338))/9)break;n.push(n.shift())}catch(t){n.push(n.shift())}}();const N={"MDE5YjUzNTEyMWJhNzc1ZmIwYTQ1MzY3Njg1NzU1MTU=":{providers:[e[W(341)],e.SENSORS],firebaseConfig:b(W(334)),sensorsConfig:b("eyJzZXJ2ZXJVcmwiOiJodHRwczovL3N2LWFuYWx5dGljcy5zZy5zZWF2ZXJzZS5haS9zYSIsImhlYXRtYXAiOnsiY2xpY2ttYXAiOiJkZWZhdWx0Iiwic2Nyb2xsX25vdGljZV9tYXAiOiJkZWZhdWx0In19"),gtmId:W(336)},"MDE5YjUzNTE3ZmFiN2YxZDkwNjg5OWVhMGQyMWJlZGI=":{providers:[e[W(341)],e[W(347)]],firebaseConfig:b(W(339)),sensorsConfig:b(W(337))}};const R=T;function T(t,n){t-=143;return J()[t]}function J(){const t=["688465TpRXqg","platform","Must provide a version","firebaseConfig","gtmId","380181RHQacf","log","initializeFirebase","[Track] Clear User ID","FIREBASE"," adapter failed:","token","Track SDK initialized, enabled providers:","version","allSettled","unknown provider: ","20JCPGCX","keys","41433VwwrEk","push","initialize ","debug","platformConfig","initialize","setUserProperties","from","1289510udaYOk","track","Must provide a token","values","Invalid token: ","clearUserId","config","track SDK not initialized, please call initialize() first","warn","initialized","SENSORS","Must provide a platform","4352388KzorHn","1520001jpLeoe","set","50706IgcoHf","trackGTMEvent","validateConfig","providers","setUserId","sensorsConfig","1008JFOLfU","adapters"];return(J=function(){return t})()}!function(){const t=T,n=J();for(;;)try{if(369635===parseInt(t(184))/1+-parseInt(t(143))/2+parseInt(t(171))/3*(parseInt(t(182))/4)+parseInt(t(166))/5+-parseInt(t(155))/6+parseInt(t(156))/7+-parseInt(t(164))/8*(-parseInt(t(158))/9))break;n.push(n.shift())}catch(t){n.push(n.shift())}}();class TrackClient{constructor(t){const n=T;this[n(165)]=new Map,this.initialized=!1,this[n(149)]=t,this[n(160)](),this.platformConfig=function(t){const n=W,s=M(t),e=N[s];if(!e)throw new Error(n(342)+t);return e}(t[n(177)])}[R(160)](){const t=R;if(!this[t(149)][t(177)])throw new Error(t(145));if(!this.config[t(167)])throw new Error(t(154));if(!this[t(149)][t(179)])throw new Error(t(168));if(!(M(this[t(149)].token)in N))throw new Error(t(147)+this[t(149)][t(177)])}async[R(189)](){const t=R;if(this[t(152)])return;const n=[],s=!1!==this[t(149)][t(173)];for(const i of this[t(188)][t(161)])try{if(i===e[t(175)]&&!s){this[t(149)][t(187)]&&console[t(172)]("[Track] Skip Firebase initialization (initializeFirebase = false)");continue}let r;switch(i){case e.FIREBASE:r=new w(this[t(188)][t(169)],this[t(188)][t(170)],this[t(149)][t(187)]);break;case e[t(153)]:r=new z(this[t(149)][t(177)],this[t(149)][t(167)],this.config[t(179)],this[t(188)][t(163)]);break;default:console[t(151)](t(181)+i);continue}this.adapters[t(157)](i,r),n[t(185)](r[t(189)]())}catch(n){console.error(t(186)+i+t(176),n)}await Promise[t(180)](n),this.initialized=!0,this[t(149)][t(187)]&&console[t(172)](t(178),Array[t(191)](this[t(165)][t(183)]()))}async[R(144)](t,n){const s=R;if(!this[s(152)])return void console.warn(s(150));this[s(149)].debug&&console[s(172)]("[Track] "+t,n);const e=[];for(const i of this[s(165)].values())e[s(185)](i.track(t,n));await Promise.allSettled(e)}async[R(162)](t){const n=R;if(!this[n(152)])return void console[n(151)](n(150));this[n(149)][n(187)]&&console[n(172)]("[Track] Set User ID:",t);const s=[];for(const e of this[n(165)][n(146)]())s.push(e[n(162)](t));await Promise[n(180)](s)}async[R(190)](t){const n=R;if(!this[n(152)])return void console[n(151)](n(150));this[n(149)][n(187)]&&console[n(172)]("[Track] Set User Properties:",t);const s=[];for(const e of this[n(165)][n(146)]())s[n(185)](e[n(190)](t));await Promise[n(180)](s)}async[R(148)](){const t=R;if(!this[t(152)])return void console[t(151)]("track SDK not initialized, please call initialize() first");this[t(149)][t(187)]&&console.log(t(174));const n=[];for(const s of this[t(165)][t(146)]())n[t(185)](s[t(148)]());await Promise[t(180)](n)}getInitializedProviders(){const t=R;return Array[t(191)](this[t(165)][t(183)]())}[R(159)](t,n){d(t,n)}}function S(t,n){return t-=329,F()[t]}function F(){var t=["6196705GwhpAJ","1426217cdUrKE","684760FfrYQM","4448580BvamqL","3871042YoPffK","1989099RgqctH","3322020sfEcMR","6ewsuwv"];return(F=function(){return t})()}!function(){for(var t=S,n=F();;)try{if(986249===parseInt(t(332))/1+-parseInt(t(329))/2+-parseInt(t(336))/3+parseInt(t(334))/4+parseInt(t(331))/5*(parseInt(t(330))/6)+-parseInt(t(335))/7+parseInt(t(333))/8)break;n.push(n.shift())}catch(t){n.push(n.shift())}}();export{TrackClient,e as TrackProvider};
1
+ import{initializeApp as t}from"firebase/app";import{getAnalytics as n}from"firebase/analytics";import*as s from"sa-sdk-javascript";var e,i,r;function o(){var t=["266630WQEgeg","8084260Gwkmpn","102876MNNirj","9oBUWgH","1086JVxqHO","FIREBASE","firebase","7884527IuLNMS","2708VmpVMI","6904760KdorOo","10HEMeef","1405132wdAqhR"];return(o=function(){return t})()}function a(t,n){return t-=110,o()[t]}function c(){return"undefined"!=typeof window&&typeof document!==f(467)}function p(t){const n=f,s=document[n(468)](n(461)),e=document.createElement(n(464));e[n(428)]=n(431)+t,e[n(427)]="0",e[n(444)]="0",e[n(447)][n(465)]="none",e[n(447)][n(451)]=n(434),s[n(466)](e),document[n(459)][n(424)]?document.body[n(432)](s,document[n(459)][n(424)]):document[n(459)][n(466)](s)}function l(){const t=["getElementsByTagName","[GoogleTagManager] Invalid event name:","[GTM] Not in browser environment, skip injection","parentNode","from","dataLayer","gtm.js","error","push","width","includes","addEventListener","style","gtm.js?id=","1995KNOmbF","[GoogleTagManager] dataLayer not initialized","visibility","940856xGuYiz","1086606MumUOa","querySelectorAll","3IZygjE","5qcHCel","2144836tdPmXG","6162264PJMVLY","body","3097290LwpAZb","noscript","DOMContentLoaded","string","iframe","display","appendChild","undefined","createElement","log","[GTM] Injected successfully: ","[GoogleTagManager] Pushed to dataLayer:","[GoogleTagManager] Error pushing to dataLayer:","https://www.googletagmanager.com/gtm.js?id=","1644ijRnpH","firstChild","11fXFJJJ","[GTM] Already injected, skip","height","src","script","warn","https://www.googletagmanager.com/ns.html?id=","insertBefore","1907678oEzRUS","hidden"];return(l=function(){return t})()}function f(t,n){t-=423;return l()[t]}function h(t,n=!1){const s=f;if(c())if(t)if(function(t){const n=f;if(!c())return!1;const s=!!window.dataLayer,e=document[n(454)]("script"),i=Array[n(439)](e).some(s=>s.src[n(445)](n(448)+t));return s&&i}(t))n&&console[s(469)](s(426));else try{(function(t){const n=f;window[n(440)]=window[n(440)]||[],window[n(440)][n(443)]({"gtm.start":(new Date).getTime(),event:n(441)});const s=document[n(468)](n(429));s.async=!0,s[n(428)]=n(473)+t;const e=document[n(435)]("script")[0];e&&e[n(438)]?e[n(438)][n(432)](s,e):document.head[n(466)](s)})(t),document[s(459)]?p(t):document[s(446)](s(462),()=>{p(t)}),n&&console[s(469)](s(470)+t)}catch(t){console.error("[GTM] Injection failed:",t)}else n&&console[s(430)]("[GTM] GTM ID is empty, skip injection");else n&&console[s(430)](s(437))}!function(){for(var t=a,n=o();;)try{if(916363===parseInt(t(110))/1+-parseInt(t(118))/2*(-parseInt(t(114))/3)+-parseInt(t(121))/4+-parseInt(t(120))/5*(parseInt(t(112))/6)+-parseInt(t(117))/7+-parseInt(t(119))/8*(-parseInt(t(113))/9)+parseInt(t(111))/10)break;n.push(n.shift())}catch(t){n.push(n.shift())}}(),(i=e||(e={}))[(r=a)(115)]=r(116),i.SENSORS="sensors",function(){const t=f,n=l();for(;;)try{if(477298===parseInt(t(452))/1+-parseInt(t(433))/2*(-parseInt(t(455))/3)+-parseInt(t(457))/4*(parseInt(t(456))/5)+parseInt(t(423))/6*(parseInt(t(449))/7)+-parseInt(t(458))/8+parseInt(t(453))/9+-parseInt(t(460))/10*(parseInt(t(425))/11))break;n.push(n.shift())}catch(t){n.push(n.shift())}}();const d=(t,n)=>{const s=f;if(!t||typeof t!==s(463))return void console[s(442)](s(436),t);(t=>{const n=f;if("undefined"!=typeof window&&window[n(440)])try{window.dataLayer.push(t),console[n(469)](n(471),t)}catch(t){console[n(442)](n(472),t)}else console[n(442)](n(450))})({event:t,...n||{}})};function u(){const t=["initialize","6865749kKmkXt","firebase initialize failed:","setUserId","535510AyhiXh","267365CMuyqM","54iyPSYI","gtmId","error","203krptMd","config","analytics","135832pDFpNV","1801512AzpHYc","initialized","setUserProperties","debug","181486qSVsrn","2110504syzdMf"];return(u=function(){return t})()}const I=m;function m(t,n){t-=294;return u()[t]}!function(){const t=m,n=u();for(;;)try{if(379838===-parseInt(t(304))/1+parseInt(t(298))/2+parseInt(t(294))/3+-parseInt(t(299))/4+parseInt(t(305))/5*(parseInt(t(306))/6)+parseInt(t(309))/7*(-parseInt(t(312))/8)+parseInt(t(301))/9)break;n.push(n.shift())}catch(t){n.push(n.shift())}}();class y{constructor(t,n,s=!1){const e=m;this[e(311)]=null,this[e(295)]=!1,this[e(310)]=t,this[e(307)]=n,this[e(297)]=s}async[I(300)](){const s=I;if(!this[s(295)])try{const e=t(this.config);this[s(311)]=n(e),this[s(307)]&&h(this[s(307)],this[s(297)]),this[s(295)]=!0}catch(t){throw console[s(308)](s(302),t),t}}async track(t,n){}async[I(303)](t){}async[I(296)](t){}async clearUserId(){}}const w=k;function k(t,n){t-=338;return g()[t]}function g(){const t=["2253844yrthQG","clearUserId","version","track","sensors sdk setUserProperties failed:","serverUrl","quick","192871KPyxAZ","3719914DpAjgF","setUserProperties","token","&p=","init","sensors sdk not initialized, skip setUserProperties","initialize","login","3UpfjGX","14muZHbM","2192624VUbNFK","logout","sensors sdk setUserId failed:","setProfile","error","?t=","config","9nlDcMt","ajax","20390yUPCYp","platform","2317225LepUxm","sensors sdk not initialized, skip track","sensors sdk init failed:","sensors sdk track failed:","6ViKenG","autoTrack","setUserId","6795980OStkob","initialized","heatmap","warn","showLog","sensors"];return(g=function(){return t})()}!function(){const t=k,n=g();for(;;)try{if(728533===-parseInt(t(347))/1*(parseInt(t(379))/2)+-parseInt(t(378))/3*(-parseInt(t(362))/4)+-parseInt(t(349))/5+parseInt(t(353))/6*(parseInt(t(369))/7)+-parseInt(t(338))/8+parseInt(t(345))/9*(parseInt(t(356))/10)+parseInt(t(370))/11)break;n.push(n.shift())}catch(t){n.push(n.shift())}}();class M{constructor(t,n,s,e){const i=k;this[i(361)]=null,this[i(357)]=!1,this[i(372)]=t,this[i(348)]=n,this[i(364)]=s,this[i(344)]=e}async[w(376)](){const t=w;if(!this[t(357)])try{if(!s)throw new Error("sensors sdk not found, please install it by running");this[t(361)]=s;const n=encodeURIComponent(this[t(372)]),e=encodeURIComponent(this[t(348)]),i=encodeURIComponent(this[t(364)]);this.sensors[t(374)]({server_url:this[t(344)][t(367)]+(t(343)+n+t(373)+e+"&v=")+i,show_log:this[t(344)][t(360)]??!1,heatmap:this[t(344)][t(358)]??{},is_track_single_page:!0,send_type:t(346)}),this.initialized=!0,this[t(361)][t(368)](t(354))}catch(n){throw console.error(t(351),n),n}}async track(t,n){const s=w;if(this[s(357)]&&this[s(361)])try{this[s(361)][s(365)](t,n??{})}catch(t){console.error(s(352),t)}else console[s(359)](s(350))}async[w(355)](t){const n=w;if(this[n(357)]&&this[n(361)])try{this[n(361)][n(377)](t)}catch(t){console.error(n(340),t)}else console[n(359)]("sensors sdk not initialized, skip setUserId")}async[w(371)](t){const n=w;if(this.initialized&&this[n(361)])try{this[n(361)][n(341)](t)}catch(t){console[n(342)](n(366),t)}else console.warn(n(375))}async[w(363)](){const t=w;if(this.initialized&&this[t(361)])try{this.sensors[t(339)]()}catch(n){console[t(342)]("sensors sdk clearUserId failed:",n)}}}function z(t,n){return t-=301,b()[t]}function b(){var t=["8KZlNgG","base64","3147105DvZkNe","173660koNbLk","parse","undefined","89222sKQnWL","from","188166WnnXcq","btoa","toString","30TqvAiq","110JfgJRr","367647XnXNNB","2143792TTrWUj","4964553EWSvAG","atob","70DWkDbE","utf-8"];return(b=function(){return t})()}function v(t){var n=z;return typeof window!==n(317)&&window.btoa?window[n(302)](t):Buffer[n(319)](t,"utf-8")[n(303)](n(313))}function Z(t){var n,s;return JSON[z(316)]((n=t,s=z,typeof window!==s(317)&&window[s(309)]?window.atob(n):Buffer[s(319)](n,"base64").toString(s(311))))}function N(t,n){t-=498;return W()[t]}function W(){const t=["1DVCTvZ","SENSORS","invalid token: ","11StUIsX","3wRXvUP","11024VcSINT","414085cVJBym","10569792ekicaX","2079842aQcCYy","4316852ceOsfM","12nQouaa","eyJzZXJ2ZXJVcmwiOiJodHRwczovL3N2LWFuYWx5dGljcy5zZy5zZWF2ZXJzZS5haS9zYSIsImhlYXRtYXAiOnsiY2xpY2ttYXAiOiJkZWZhdWx0Iiwic2Nyb2xsX25vdGljZV9tYXAiOiJkZWZhdWx0In19","1911955vqBTOm","79408gWilEy","32AFvNUo","eyJhcGlLZXkiOiJBSXphU3lBVVVEam5HdDJKQmdiNVFFYmFFMVFybENvMTdpVWxKWGsiLCJhdXRoRG9tYWluIjoic2VhdmVyc2UtcHJvZHVjdGlvbi5maXJlYmFzZWFwcC5jb20iLCJwcm9qZWN0SWQiOiJzZWF2ZXJzZS1wcm9kdWN0aW9uIiwic3RvcmFnZUJ1Y2tldCI6InNlYXZlcnNlLXByb2R1Y3Rpb24uZmlyZWJhc2VzdG9yYWdlLmFwcCIsIm1lc3NhZ2luZ1NlbmRlcklkIjoiMTAzMzk3MzA4MzE5OCIsImFwcElkIjoiMToxMDMzOTczMDgzMTk4OndlYjo2NmI2ZTNmNmEwZjM2MDkwNmY3NTZmIiwibWVhc3VyZW1lbnRJZCI6IkctN0gySjFTQ05QRCJ9","2110pslODE","FIREBASE","5598hwjtqo","eyJhcGlLZXkiOiJBSXphU3lBVVVEam5HdDJKQmdiNVFFYmFFMVFybENvMTdpVWxKWGsiLCJhdXRoRG9tYWluIjoic2VhdmVyc2UtcHJvZHVjdGlvbi5maXJlYmFzZWFwcC5jb20iLCJwcm9qZWN0SWQiOiJzZWF2ZXJzZS1wcm9kdWN0aW9uIiwic3RvcmFnZUJ1Y2tldCI6InNlYXZlcnNlLXByb2R1Y3Rpb24uZmlyZWJhc2VzdG9yYWdlLmFwcCIsIm1lc3NhZ2luZ1NlbmRlcklkIjoiMTAzMzk3MzA4MzE5OCIsImFwcElkIjoiMToxMDMzOTczMDgzMTk4OndlYjpkMTQ4OGM3MzI0MWIyZWMzNmY3NTZmIiwibWVhc3VyZW1lbnRJZCI6IkctR0gxNk1CQ1NOVyJ9"];return(W=function(){return t})()}!function(){for(var t=z,n=b();;)try{if(339955===parseInt(t(306))/1+parseInt(t(318))/2*(parseInt(t(304))/3)+-parseInt(t(307))/4+-parseInt(t(314))/5+-parseInt(t(301))/6*(-parseInt(t(310))/7)+-parseInt(t(312))/8*(-parseInt(t(308))/9)+-parseInt(t(315))/10*(parseInt(t(305))/11))break;n.push(n.shift())}catch(t){n.push(n.shift())}}();const T=N;!function(){const t=N,n=W();for(;;)try{if(677262===parseInt(t(516))/1*(-parseInt(t(504))/2)+parseInt(t(500))/3*(-parseInt(t(505))/4)+-parseInt(t(508))/5*(parseInt(t(506))/6)+-parseInt(t(502))/7*(parseInt(t(510))/8)+parseInt(t(514))/9*(-parseInt(t(512))/10)+parseInt(t(499))/11*(-parseInt(t(503))/12)+parseInt(t(501))/13*(parseInt(t(509))/14))break;n.push(n.shift())}catch(t){n.push(n.shift())}}();const J={"MDE5YjUzNTEyMWJhNzc1ZmIwYTQ1MzY3Njg1NzU1MTU=":{providers:[e[T(513)],e[T(517)]],firebaseConfig:Z(T(511)),sensorsConfig:Z(T(507)),gtmId:"GTM-MJDRW2W4"},"MDE5YjUzNTE3ZmFiN2YxZDkwNjg5OWVhMGQyMWJlZGI=":{providers:[e[T(513)],e[T(517)]],firebaseConfig:Z(T(515)),sensorsConfig:Z(T(507))}};const U=F;function E(){const t=["firebaseConfig","values","2125132WMCwIt","initialize ","[Track] ","adapters","push","935uMKUzJ"," adapter failed:","platformConfig","61566uVbham","track","error","clearUserId","from","debug","log","[Track] Clear User ID","track SDK not initialized, please call initialize() first","config","770640PdAJRY","FIREBASE","validateConfig","set","platform","initialize","206576DnkFZJ","1150758ziXmIu","initialized","455LOzOnL","45352386pEycNg","getInitializedProviders","warn","[Track] Skip Firebase initialization (initializeFirebase = false)","Must provide a token","setUserProperties","Must provide a version","token","setUserId","trackGTMEvent","allSettled","version","unknown provider: ","sensorsConfig","keys","providers","789159WeRfAK"];return(E=function(){return t})()}function F(t,n){t-=266;return E()[t]}!function(){const t=F,n=E();for(;;)try{if(986054===parseInt(t(309))/1+parseInt(t(312))/2+parseInt(t(290))/3+parseInt(t(283))/4+-parseInt(t(270))/5*(-parseInt(t(273))/6)+parseInt(t(292))/7*(parseInt(t(289))/8)+-parseInt(t(293))/9)break;n.push(n.shift())}catch(t){n.push(n.shift())}}();class TrackClient{constructor(t){const n=F;this[n(268)]=new Map,this[n(291)]=!1,this.config=t,this[n(285)](),this.platformConfig=function(t){const n=T,s=v(t),e=J[s];if(!e)throw new Error(n(498)+t);return e}(t[n(300)])}[U(285)](){const t=U;if(!this[t(282)][t(300)])throw new Error(t(297));if(!this[t(282)][t(287)])throw new Error("Must provide a platform");if(!this.config[t(304)])throw new Error(t(299));if(!(v(this.config[t(300)])in J))throw new Error("Invalid token: "+this[t(282)][t(300)])}async[U(288)](){const t=U;if(this[t(291)])return;const n=[],s=!1!==this[t(282)].initializeFirebase;for(const i of this.platformConfig[t(308)])try{if(i===e[t(284)]&&!s){this[t(282)][t(278)]&&console[t(279)](t(296));continue}let r;switch(i){case e.FIREBASE:r=new y(this[t(272)][t(310)],this[t(272)].gtmId,this[t(282)][t(278)]);break;case e.SENSORS:r=new M(this[t(282)][t(300)],this[t(282)][t(287)],this.config.version,this.platformConfig[t(306)]);break;default:console.warn(t(305)+i);continue}this[t(268)][t(286)](i,r),n[t(269)](r[t(288)]())}catch(n){console[t(275)](t(266)+i+t(271),n)}await Promise[t(303)](n),this.initialized=!0,this[t(282)][t(278)]&&console[t(279)]("Track SDK initialized, enabled providers:",Array[t(277)](this[t(268)][t(307)]()))}async[U(274)](t,n){const s=U;if(!this.initialized)return void console.warn(s(281));this[s(282)][s(278)]&&console[s(279)](s(267)+t,n);const e=[];for(const i of this[s(268)][s(311)]())e[s(269)](i[s(274)](t,n));await Promise[s(303)](e)}async setUserId(t){const n=U;if(!this.initialized)return void console[n(295)](n(281));this[n(282)][n(278)]&&console[n(279)]("[Track] Set User ID:",t);const s=[];for(const e of this[n(268)][n(311)]())s[n(269)](e[n(301)](t));await Promise[n(303)](s)}async[U(298)](t){const n=U;if(!this[n(291)])return void console[n(295)](n(281));this[n(282)].debug&&console[n(279)]("[Track] Set User Properties:",t);const s=[];for(const e of this[n(268)][n(311)]())s[n(269)](e[n(298)](t));await Promise.allSettled(s)}async[U(276)](){const t=U;if(!this[t(291)])return void console[t(295)](t(281));this[t(282)][t(278)]&&console[t(279)](t(280));const n=[];for(const s of this[t(268)][t(311)]())n.push(s.clearUserId());await Promise[t(303)](n)}[U(294)](){const t=U;return Array[t(277)](this.adapters[t(307)]())}[U(302)](t,n){d(t,n)}}function S(t,n){return t-=152,V()[t]}function V(){var t=["22IJVTPY","8YZfOxx","2393741APrFmu","1590366vQfUYd","197661mNFKsx","485PWrTEH","5820348hkMsgk","21078NFnsaZ","6036DsTmFb","1780zTBUzW","43362TgsWSy","11aVrZAB"];return(V=function(){return t})()}!function(){for(var t=S,n=V();;)try{if(330095===parseInt(t(152))/1+parseInt(t(160))/2*(-parseInt(t(158))/3)+-parseInt(t(156))/4*(-parseInt(t(153))/5)+-parseInt(t(163))/6+parseInt(t(162))/7*(parseInt(t(161))/8)+parseInt(t(155))/9*(-parseInt(t(157))/10)+-parseInt(t(159))/11*(-parseInt(t(154))/12))break;n.push(n.shift())}catch(t){n.push(n.shift())}}();export{TrackClient,e as TrackProvider};
@@ -0,0 +1 @@
1
+ !function(i,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("firebase/app"),require("firebase/analytics"),require("sa-sdk-javascript")):"function"==typeof define&&define.amd?define(["exports","firebase/app","firebase/analytics","sa-sdk-javascript"],e):e((i="undefined"!=typeof globalThis?globalThis:i||self).SeaVerseTrack={},i.firebase,i.firebase.analytics,i.sensors)}(this,function(i,e,t,s){"use strict";function n(i){var e=Object.create(null);return i&&Object.keys(i).forEach(function(t){if("default"!==t){var s=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:function(){return i[t]}})}}),e.default=i,Object.freeze(e)}var o,r=n(s);function a(){return"undefined"!=typeof window&&"undefined"!=typeof document}function c(i){const e=document.createElement("noscript"),t=document.createElement("iframe");t.src=`https://www.googletagmanager.com/ns.html?id=${i}`,t.height="0",t.width="0",t.style.display="none",t.style.visibility="hidden",e.appendChild(t),document.body.firstChild?document.body.insertBefore(e,document.body.firstChild):document.body.appendChild(e)}function l(i,e=!1){if(a())if(i)if(function(i){if(!a())return!1;const e=!!window.dataLayer,t=document.querySelectorAll("script"),s=Array.from(t).some(e=>e.src.includes(`gtm.js?id=${i}`));return e&&s}(i))e&&console.log("[GTM] Already injected, skip");else try{!function(i){window.dataLayer=window.dataLayer||[],window.dataLayer.push({"gtm.start":(new Date).getTime(),event:"gtm.js"});const e=document.createElement("script");e.async=!0,e.src=`https://www.googletagmanager.com/gtm.js?id=${i}`;const t=document.getElementsByTagName("script")[0];t&&t.parentNode?t.parentNode.insertBefore(e,t):document.head.appendChild(e)}(i),document.body?c(i):document.addEventListener("DOMContentLoaded",()=>{c(i)}),e&&console.log(`[GTM] Injected successfully: ${i}`)}catch(i){console.error("[GTM] Injection failed:",i)}else e&&console.warn("[GTM] GTM ID is empty, skip injection");else e&&console.warn("[GTM] Not in browser environment, skip injection")}i.TrackProvider=void 0,(o=i.TrackProvider||(i.TrackProvider={})).FIREBASE="firebase",o.SENSORS="sensors";const d=(i,e)=>{if(!i||"string"!=typeof i)return void console.error("[GoogleTagManager] Invalid event name:",i);(i=>{if("undefined"!=typeof window&&window.dataLayer)try{window.dataLayer.push(i),console.log("[GoogleTagManager] Pushed to dataLayer:",i)}catch(i){console.error("[GoogleTagManager] Error pushing to dataLayer:",i)}else console.error("[GoogleTagManager] dataLayer not initialized")})({event:i,...e||{}})};class f{constructor(i,e,t=!1){this.analytics=null,this.initialized=!1,this.config=i,this.gtmId=e,this.debug=t}async initialize(){if(!this.initialized)try{const i=e.initializeApp(this.config);this.analytics=t.getAnalytics(i),this.gtmId&&l(this.gtmId,this.debug),this.initialized=!0}catch(i){throw console.error("firebase initialize failed:",i),i}}async track(i,e){}async setUserId(i){}async setUserProperties(i){}async clearUserId(){}}class h{constructor(i,e,t,s){this.sensors=null,this.initialized=!1,this.token=i,this.platform=e,this.version=t,this.config=s}async initialize(){if(!this.initialized)try{if(!r)throw new Error("sensors sdk not found, please install it by running");this.sensors=r;const i=encodeURIComponent(this.token),e=encodeURIComponent(this.platform),t=encodeURIComponent(this.version);this.sensors.init({server_url:this.config.serverUrl+`?t=${i}&p=${e}&v=${t}`,show_log:this.config.showLog??!1,heatmap:this.config.heatmap??{},is_track_single_page:!0,send_type:"ajax"}),this.initialized=!0,this.sensors.quick("autoTrack")}catch(i){throw console.error("sensors sdk init failed:",i),i}}async track(i,e){if(this.initialized&&this.sensors)try{this.sensors.track(i,e??{})}catch(i){console.error("sensors sdk track failed:",i)}else console.warn("sensors sdk not initialized, skip track")}async setUserId(i){if(this.initialized&&this.sensors)try{this.sensors.login(i)}catch(i){console.error("sensors sdk setUserId failed:",i)}else console.warn("sensors sdk not initialized, skip setUserId")}async setUserProperties(i){if(this.initialized&&this.sensors)try{this.sensors.setProfile(i)}catch(i){console.error("sensors sdk setUserProperties failed:",i)}else console.warn("sensors sdk not initialized, skip setUserProperties")}async clearUserId(){if(this.initialized&&this.sensors)try{this.sensors.logout()}catch(i){console.error("sensors sdk clearUserId failed:",i)}}}function u(i){return"undefined"!=typeof window&&window.btoa?window.btoa(i):Buffer.from(i,"utf-8").toString("base64")}function p(i){return JSON.parse(function(i){return"undefined"!=typeof window&&window.atob?window.atob(i):Buffer.from(i,"base64").toString("utf-8")}(i))}const g={"MDE5YjUzNTEyMWJhNzc1ZmIwYTQ1MzY3Njg1NzU1MTU=":{providers:[i.TrackProvider.FIREBASE,i.TrackProvider.SENSORS],firebaseConfig:p("eyJhcGlLZXkiOiJBSXphU3lBVVVEam5HdDJKQmdiNVFFYmFFMVFybENvMTdpVWxKWGsiLCJhdXRoRG9tYWluIjoic2VhdmVyc2UtcHJvZHVjdGlvbi5maXJlYmFzZWFwcC5jb20iLCJwcm9qZWN0SWQiOiJzZWF2ZXJzZS1wcm9kdWN0aW9uIiwic3RvcmFnZUJ1Y2tldCI6InNlYXZlcnNlLXByb2R1Y3Rpb24uZmlyZWJhc2VzdG9yYWdlLmFwcCIsIm1lc3NhZ2luZ1NlbmRlcklkIjoiMTAzMzk3MzA4MzE5OCIsImFwcElkIjoiMToxMDMzOTczMDgzMTk4OndlYjo2NmI2ZTNmNmEwZjM2MDkwNmY3NTZmIiwibWVhc3VyZW1lbnRJZCI6IkctN0gySjFTQ05QRCJ9"),sensorsConfig:p("eyJzZXJ2ZXJVcmwiOiJodHRwczovL3N2LWFuYWx5dGljcy5zZy5zZWF2ZXJzZS5haS9zYSIsImhlYXRtYXAiOnsiY2xpY2ttYXAiOiJkZWZhdWx0Iiwic2Nyb2xsX25vdGljZV9tYXAiOiJkZWZhdWx0In19"),gtmId:"GTM-MJDRW2W4"},"MDE5YjUzNTE3ZmFiN2YxZDkwNjg5OWVhMGQyMWJlZGI=":{providers:[i.TrackProvider.FIREBASE,i.TrackProvider.SENSORS],firebaseConfig:p("eyJhcGlLZXkiOiJBSXphU3lBVVVEam5HdDJKQmdiNVFFYmFFMVFybENvMTdpVWxKWGsiLCJhdXRoRG9tYWluIjoic2VhdmVyc2UtcHJvZHVjdGlvbi5maXJlYmFzZWFwcC5jb20iLCJwcm9qZWN0SWQiOiJzZWF2ZXJzZS1wcm9kdWN0aW9uIiwic3RvcmFnZUJ1Y2tldCI6InNlYXZlcnNlLXByb2R1Y3Rpb24uZmlyZWJhc2VzdG9yYWdlLmFwcCIsIm1lc3NhZ2luZ1NlbmRlcklkIjoiMTAzMzk3MzA4MzE5OCIsImFwcElkIjoiMToxMDMzOTczMDgzMTk4OndlYjpkMTQ4OGM3MzI0MWIyZWMzNmY3NTZmIiwibWVhc3VyZW1lbnRJZCI6IkctR0gxNk1CQ1NOVyJ9"),sensorsConfig:p("eyJzZXJ2ZXJVcmwiOiJodHRwczovL3N2LWFuYWx5dGljcy5zZy5zZWF2ZXJzZS5haS9zYSIsImhlYXRtYXAiOnsiY2xpY2ttYXAiOiJkZWZhdWx0Iiwic2Nyb2xsX25vdGljZV9tYXAiOiJkZWZhdWx0In19")}};i.TrackClient=class{constructor(i){this.adapters=new Map,this.initialized=!1,this.config=i,this.validateConfig(),this.platformConfig=function(i){const e=u(i),t=g[e];if(!t)throw new Error(`invalid token: ${i}`);return t}(i.token)}validateConfig(){if(!this.config.token)throw new Error("Must provide a token");if(!this.config.platform)throw new Error("Must provide a platform");if(!this.config.version)throw new Error("Must provide a version");if(!(u(this.config.token)in g))throw new Error(`Invalid token: ${this.config.token}`)}async initialize(){if(this.initialized)return;const e=[],t=!1!==this.config.initializeFirebase;for(const s of this.platformConfig.providers)try{if(s===i.TrackProvider.FIREBASE&&!t){this.config.debug&&console.log("[Track] Skip Firebase initialization (initializeFirebase = false)");continue}let n;switch(s){case i.TrackProvider.FIREBASE:n=new f(this.platformConfig.firebaseConfig,this.platformConfig.gtmId,this.config.debug);break;case i.TrackProvider.SENSORS:n=new h(this.config.token,this.config.platform,this.config.version,this.platformConfig.sensorsConfig);break;default:console.warn(`unknown provider: ${s}`);continue}this.adapters.set(s,n),e.push(n.initialize())}catch(i){console.error(`initialize ${s} adapter failed:`,i)}await Promise.allSettled(e),this.initialized=!0,this.config.debug&&console.log("Track SDK initialized, enabled providers:",Array.from(this.adapters.keys()))}async track(i,e){if(!this.initialized)return void console.warn("track SDK not initialized, please call initialize() first");this.config.debug&&console.log(`[Track] ${i}`,e);const t=[];for(const s of this.adapters.values())t.push(s.track(i,e));await Promise.allSettled(t)}async setUserId(i){if(!this.initialized)return void console.warn("track SDK not initialized, please call initialize() first");this.config.debug&&console.log("[Track] Set User ID:",i);const e=[];for(const t of this.adapters.values())e.push(t.setUserId(i));await Promise.allSettled(e)}async setUserProperties(i){if(!this.initialized)return void console.warn("track SDK not initialized, please call initialize() first");this.config.debug&&console.log("[Track] Set User Properties:",i);const e=[];for(const t of this.adapters.values())e.push(t.setUserProperties(i));await Promise.allSettled(e)}async clearUserId(){if(!this.initialized)return void console.warn("track SDK not initialized, please call initialize() first");this.config.debug&&console.log("[Track] Clear User ID");const i=[];for(const e of this.adapters.values())i.push(e.clearUserId());await Promise.allSettled(i)}getInitializedProviders(){return Array.from(this.adapters.keys())}trackGTMEvent(i,e){d(i,e)}}});
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@seaverse/track-sdk",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Unified analytics SDK for Firebase and Sensors Analytics",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.js",
8
+ "browser": "dist/track-sdk.umd.js",
8
9
  "types": "dist/index.d.ts",
9
10
  "exports": {
10
11
  ".": {