@seaverse/track-sdk 0.1.6 → 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 +45 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/track-sdk.umd.js +1 -0
- package/package.json +2 -1
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 s(t){var e=Object.create(null);return t&&Object.keys(t).forEach(function(s){if("default"!==s){var n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:function(){return t[s]}})}}),e.default=t,Object.freeze(e)}var n,r=s(require("sa-sdk-javascript"));function i(t,e){return t-=430,o()[t]}function o(){var t=["12glWDsv","FIREBASE","2001590tQDYCx","819981fHKBSZ","91862EZzuxl","1985224OWTheH","1OEGyTL","14mZUTpM","1197891rdCOBi","418630aTPpkc","765344vvtCBA"];return(o=function(){return t})()}function a(){const t=["https://www.googletagmanager.com/ns.html?id=","warn","4xbjJJX","height","[GoogleTagManager] Pushed to dataLayer:","gtm.js?id=","[GoogleTagManager] Error pushing to dataLayer:","style","head","[GTM] Already injected, skip","string","parentNode","push","dataLayer","3632CIaSpN","1205405xJWWIc","21140KuVZpu","from","[GTM] Not in browser environment, skip injection","appendChild","body","[GoogleTagManager] Invalid event name:","firstChild","424IAhoXb","width","some","script","visibility","244473xnDKEm","[GTM] Injection failed:","noscript","src","[GoogleTagManager] dataLayer not initialized","none","log","76GDmEdj","iframe","createElement","includes","126720BJWxam","display","async","1582461jKHBqD","insertBefore","error","2364774HORbGx","querySelectorAll","undefined","https://www.googletagmanager.com/gtm.js?id="];return(a=function(){return t})()}function c(){const t=d;return typeof window!==t(270)&&typeof document!==t(270)}function d(t,e){t-=233;return a()[t]}function l(t){const e=d,s=document[e(260)](e(253)),n=document[e(260)](e(259));n[e(254)]=e(272)+t,n[e(275)]="0",n[e(247)]="0",n[e(279)][e(263)]=e(256),n[e(279)][e(250)]="hidden",s[e(242)](n),document[e(243)].firstChild?document.body[e(266)](s,document.body[e(245)]):document[e(243)].appendChild(s)}function p(t,e=!1){const s=d;if(c())if(t)if(function(t){const e=d;if(!c())return!1;const s=!!window[e(236)],n=document[e(269)](e(249)),r=Array[e(240)](n)[e(248)](s=>s.src[e(261)](e(277)+t));return s&&r}(t))e&&console.log(s(281));else try{(function(t){const e=d;window[e(236)]=window[e(236)]||[],window.dataLayer[e(235)]({"gtm.start":(new Date).getTime(),event:"gtm.js"});const s=document[e(260)](e(249));s[e(264)]=!0,s[e(254)]=e(271)+t;const n=document.getElementsByTagName(e(249))[0];n&&n.parentNode?n[e(234)][e(266)](s,n):document[e(280)][e(242)](s)})(t),document[s(243)]?l(t):document.addEventListener("DOMContentLoaded",()=>{l(t)}),e&&console[s(257)]("[GTM] Injected successfully: "+t)}catch(t){console.error(s(252),t)}else e&&console[s(273)]("[GTM] GTM ID is empty, skip injection");else e&&console.warn(s(241))}!function(){for(var t=i,e=o();;)try{if(324898===-parseInt(t(440))/1*(parseInt(t(438))/2)+parseInt(t(431))/3+-parseInt(t(439))/4+-parseInt(t(432))/5*(-parseInt(t(434))/6)+parseInt(t(430))/7*(parseInt(t(433))/8)+-parseInt(t(437))/9+parseInt(t(436))/10)break;e.push(e.shift())}catch(t){e.push(e.shift())}}(),exports.TrackProvider=void 0,(n=exports.TrackProvider||(exports.TrackProvider={}))[i(435)]="firebase",n.SENSORS="sensors",function(){const t=d,e=a();for(;;)try{if(230124===-parseInt(t(237))/1*(parseInt(t(258))/2)+-parseInt(t(251))/3*(-parseInt(t(274))/4)+parseInt(t(238))/5+parseInt(t(268))/6+-parseInt(t(239))/7*(parseInt(t(246))/8)+-parseInt(t(265))/9+-parseInt(t(262))/10)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const h=(t,e)=>{const s=d;if(!t||typeof t!==s(233))return void console[s(267)](s(244),t);(t=>{const e=d;if(typeof window!==e(270)&&window[e(236)])try{window[e(236)][e(235)](t),console[e(257)](e(276),t)}catch(t){console[e(267)](e(278),t)}else console[e(267)](e(255))})({event:t,...e||{}})};function f(){const t=["analytics","453663omFosI","18003952UYuKDR","setUserProperties","2445528ZmyCvO","track","error","setUserId","initialized","794442kDpdKe","507678TuOpzE","6049392PYPqjo","config","2332420yUpIMI","gtmId","firebase initialize failed:","debug","35bhxuhs"];return(f=function(){return t})()}const u=I;function I(t,e){t-=200;return f()[t]}!function(){const t=I,e=f();for(;;)try{if(788670===-parseInt(t(202))/1+-parseInt(t(205))/2+-parseInt(t(211))/3+parseInt(t(212))/4+-parseInt(t(214))/5+parseInt(t(210))/6*(-parseInt(t(200))/7)+parseInt(t(203))/8)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class m{constructor(t,e,s=!1){const n=I;this[n(201)]=null,this[n(209)]=!1,this[n(213)]=t,this.gtmId=e,this.debug=s}async initialize(){const s=I;if(!this[s(209)])try{this[s(215)]&&p(this.gtmId,this[s(217)]);const n=t.initializeApp(this[s(213)]);this[s(201)]=e.getAnalytics(n),this[s(209)]=!0}catch(t){throw console[s(207)](s(216),t),t}}async[u(206)](t,e){}async[u(208)](t){}async[u(204)](t){}async clearUserId(){}}const y=k;function w(){const t=["setProfile","initialize","4495DSdori","logout","21679875fnXuwx","showLog","4563352xMCRdN","sensors","heatmap","ajax","sensors sdk not initialized, skip track","sensors sdk not initialized, skip setUserProperties","clearUserId","3619504CBhIgy","1292949BCqOLp","900272coWgmd","platform","track","sensors sdk not initialized, skip setUserId","6594RrCyli","?t=","warn","26600mxdgzq","setUserId","token","sensors sdk not found, please install it by running","setUserProperties","init","error","sensors sdk setUserProperties failed:","config","sensors sdk init failed:","sensors sdk setUserId failed:","84SlKwzo","sensors sdk track failed:","initialized","&v="];return(w=function(){return t})()}function k(t,e){t-=491;return w()[t]}!function(){const t=k,e=w();for(;;)try{if(577902===-parseInt(t(503))/1*(-parseInt(t(514))/2)+-parseInt(t(495))/3+parseInt(t(496))/4+parseInt(t(520))/5*(parseInt(t(500))/6)+parseInt(t(494))/7+parseInt(t(524))/8+-parseInt(t(522))/9)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class g{constructor(t,e,s,n){const r=k;this[r(525)]=null,this[r(516)]=!1,this[r(505)]=t,this[r(497)]=e,this.version=s,this[r(511)]=n}async[y(519)](){const t=y;if(!this[t(516)])try{if(!r)throw new Error(t(506));this[t(525)]=r;const e=encodeURIComponent(this[t(505)]),s=encodeURIComponent(this[t(497)]),n=encodeURIComponent(this.version);this[t(525)][t(508)]({server_url:this[t(511)].serverUrl+(t(501)+e+"&p=")+s+t(517)+n,show_log:this[t(511)][t(523)]??!1,heatmap:this[t(511)][t(526)]??{},is_track_single_page:!0,send_type:t(527)}),this[t(516)]=!0,this.sensors.quick("autoTrack")}catch(e){throw console[t(509)](t(512),e),e}}async[y(498)](t,e){const s=y;if(this[s(516)]&&this[s(525)])try{this[s(525)][s(498)](t,e??{})}catch(t){console.error(s(515),t)}else console[s(502)](s(491))}async[y(504)](t){const e=y;if(this[e(516)]&&this[e(525)])try{this[e(525)].login(t)}catch(t){console.error(e(513),t)}else console.warn(e(499))}async[y(507)](t){const e=y;if(this[e(516)]&&this.sensors)try{this.sensors[e(518)](t)}catch(t){console.error(e(510),t)}else console[e(502)](e(492))}async[y(493)](){const t=y;if(this[t(516)]&&this.sensors)try{this[t(525)][t(521)]()}catch(e){console[t(509)]("sensors sdk clearUserId failed:",e)}}}function v(){var t=["6868253TXhhuJ","undefined","2506398PcueeQ","btoa","base64","78Rfmzmi","2261528ZmKvmc","toString","utf-8","1128filLbp","11036870JPqymD","15oVqSsu","atob","823668vZiTtf","14913yXtXDF","17939jbHTYV"];return(v=function(){return t})()}function b(t,e){return t-=261,v()[t]}function z(t){var e=b;return"undefined"!=typeof window&&window[e(261)]?window[e(261)](t):Buffer.from(t,e(266))[e(265)]("base64")}function Z(t){return JSON.parse((e=t,s=b,typeof window!==s(275)&&window.atob?window[s(270)](e):Buffer.from(e,s(262)).toString(s(266))));var e,s}!function(){for(var t=b,e=v();;)try{if(642505===parseInt(t(273))/1*(parseInt(t(263))/2)+parseInt(t(271))/3+parseInt(t(264))/4+parseInt(t(269))/5*(-parseInt(t(276))/6)+-parseInt(t(274))/7+parseInt(t(267))/8*(parseInt(t(272))/9)+parseInt(t(268))/10)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const T=N;!function(){const t=N,e=W();for(;;)try{if(359557===-parseInt(t(173))/1*(parseInt(t(175))/2)+parseInt(t(172))/3+-parseInt(t(165))/4*(-parseInt(t(171))/5)+-parseInt(t(161))/6+parseInt(t(170))/7+parseInt(t(164))/8+-parseInt(t(166))/9*(-parseInt(t(163))/10))break;e.push(e.shift())}catch(t){e.push(e.shift())}}();const M={"MDE5YjUzNTEyMWJhNzc1ZmIwYTQ1MzY3Njg1NzU1MTU=":{providers:[exports.TrackProvider.FIREBASE,exports.TrackProvider.SENSORS],firebaseConfig:Z(T(162)),sensorsConfig:Z(T(176)),gtmId:T(169)},"MDE5YjUzNTE3ZmFiN2YxZDkwNjg5OWVhMGQyMWJlZGI=":{providers:[exports.TrackProvider[T(174)],exports.TrackProvider.SENSORS],firebaseConfig:Z(T(168)),sensorsConfig:Z("eyJzZXJ2ZXJVcmwiOiJodHRwczovL3N2LWFuYWx5dGljcy5zZy5zZWF2ZXJzZS5haS9zYSIsImhlYXRtYXAiOnsiY2xpY2ttYXAiOiJkZWZhdWx0Iiwic2Nyb2xsX25vdGljZV9tYXAiOiJkZWZhdWx0In19")}};function W(){const t=["8840ebUioO","466232VocMFV","8GBTfbx","9VfVDQN","invalid token: ","eyJhcGlLZXkiOiJBSXphU3lBVVVEam5HdDJKQmdiNVFFYmFFMVFybENvMTdpVWxKWGsiLCJhdXRoRG9tYWluIjoic2VhdmVyc2UtcHJvZHVjdGlvbi5maXJlYmFzZWFwcC5jb20iLCJwcm9qZWN0SWQiOiJzZWF2ZXJzZS1wcm9kdWN0aW9uIiwic3RvcmFnZUJ1Y2tldCI6InNlYXZlcnNlLXByb2R1Y3Rpb24uZmlyZWJhc2VzdG9yYWdlLmFwcCIsIm1lc3NhZ2luZ1NlbmRlcklkIjoiMTAzMzk3MzA4MzE5OCIsImFwcElkIjoiMToxMDMzOTczMDgzMTk4OndlYjpkMTQ4OGM3MzI0MWIyZWMzNmY3NTZmIiwibWVhc3VyZW1lbnRJZCI6IkctR0gxNk1CQ1NOVyJ9","GTM-MJDRW2W4","3985310KDTNbZ","402455mGOINX","1727022HgsBAD","2bLBHIk","FIREBASE","561186kqojIS","eyJzZXJ2ZXJVcmwiOiJodHRwczovL3N2LWFuYWx5dGljcy5zZy5zZWF2ZXJzZS5haS9zYSIsImhlYXRtYXAiOnsiY2xpY2ttYXAiOiJkZWZhdWx0Iiwic2Nyb2xsX25vdGljZV9tYXAiOiJkZWZhdWx0In19","2666436CUieRQ","eyJhcGlLZXkiOiJBSXphU3lBVVVEam5HdDJKQmdiNVFFYmFFMVFybENvMTdpVWxKWGsiLCJhdXRoRG9tYWluIjoic2VhdmVyc2UtcHJvZHVjdGlvbi5maXJlYmFzZWFwcC5jb20iLCJwcm9qZWN0SWQiOiJzZWF2ZXJzZS1wcm9kdWN0aW9uIiwic3RvcmFnZUJ1Y2tldCI6InNlYXZlcnNlLXByb2R1Y3Rpb24uZmlyZWJhc2VzdG9yYWdlLmFwcCIsIm1lc3NhZ2luZ1NlbmRlcklkIjoiMTAzMzk3MzA4MzE5OCIsImFwcElkIjoiMToxMDMzOTczMDgzMTk4OndlYjo2NmI2ZTNmNmEwZjM2MDkwNmY3NTZmIiwibWVhc3VyZW1lbnRJZCI6IkctN0gySjFTQ05QRCJ9"];return(W=function(){return t})()}function N(t,e){t-=161;return W()[t]}const J=S;function S(t,e){t-=384;return C()[t]}function C(){const t=["Must provide a token","1105356abWdOV","keys","providers","token","15sCKKDt","132036ddNKyX","253aKLiKm","[Track] Clear User ID","trackGTMEvent","warn","allSettled","[Track] Set User ID:","4057713AafXPB","Must provide a platform","Track SDK initialized, enabled providers:","unknown provider: ","adapters","config","debug","15319vFlWyN","setUserId","log","8nghjzf","17610905LVahoh","set","firebaseConfig","initialized","10KLEqge","track SDK not initialized, please call initialize() first","70XhMhPV","initialize","[Track] Set User Properties:","initialize ","clearUserId","version","platformConfig","FIREBASE","validateConfig","track","from","getInitializedProviders","push","554444JFFIWm","setUserProperties","5789wyxboT","platform","error","Invalid token: ","values","10jyWoWP"];return(C=function(){return t})()}!function(){const t=S,e=C();for(;;)try{if(461766===parseInt(t(414))/1*(-parseInt(t(424))/2)+parseInt(t(399))/3*(-parseInt(t(386))/4)+-parseInt(t(422))/5*(parseInt(t(395))/6)+parseInt(t(388))/7*(parseInt(t(417))/8)+-parseInt(t(407))/9*(-parseInt(t(393))/10)+-parseInt(t(401))/11*(-parseInt(t(400))/12)+parseInt(t(418))/13)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class TrackClient{constructor(t){const e=S;this[e(411)]=new Map,this[e(421)]=!1,this.config=t,this[e(432)](),this[e(430)]=function(t){const e=T,s=z(t),n=M[s];if(!n)throw new Error(e(167)+t);return n}(t[e(398)])}[J(432)](){const t=J;if(!this[t(412)].token)throw new Error(t(394));if(!this[t(412)].platform)throw new Error(t(408));if(!this[t(412)][t(429)])throw new Error("Must provide a version");if(!(z(this[t(412)].token)in M))throw new Error(t(391)+this[t(412)][t(398)])}async initialize(){const t=J;if(this[t(421)])return;const e=[],s=!1!==this[t(412)].initializeFirebase;for(const n of this[t(430)][t(397)])try{if(n===exports.TrackProvider[t(431)]&&!s){this.config.debug&&console[t(416)]("[Track] Skip Firebase initialization (initializeFirebase = false)");continue}let r;switch(n){case exports.TrackProvider[t(431)]:r=new m(this[t(430)][t(420)],this[t(430)].gtmId,this[t(412)].debug);break;case exports.TrackProvider.SENSORS:r=new g(this[t(412)][t(398)],this[t(412)][t(389)],this[t(412)][t(429)],this.platformConfig.sensorsConfig);break;default:console.warn(t(410)+n);continue}this[t(411)][t(419)](n,r),e[t(385)](r[t(425)]())}catch(e){console[t(390)](t(427)+n+" adapter failed:",e)}await Promise[t(405)](e),this[t(421)]=!0,this[t(412)][t(413)]&&console.log(t(409),Array[t(434)](this[t(411)].keys()))}async track(t,e){const s=J;if(!this.initialized)return void console[s(404)](s(423));this[s(412)][s(413)]&&console[s(416)]("[Track] "+t,e);const n=[];for(const r of this[s(411)].values())n[s(385)](r[s(433)](t,e));await Promise[s(405)](n)}async[J(415)](t){const e=J;if(!this.initialized)return void console.warn(e(423));this[e(412)].debug&&console.log(e(406),t);const s=[];for(const n of this[e(411)][e(392)]())s[e(385)](n[e(415)](t));await Promise.allSettled(s)}async setUserProperties(t){const e=J;if(!this.initialized)return void console[e(404)](e(423));this[e(412)][e(413)]&&console[e(416)](e(426),t);const s=[];for(const n of this[e(411)][e(392)]())s[e(385)](n[e(387)](t));await Promise[e(405)](s)}async[J(428)](){const t=J;if(!this[t(421)])return void console[t(404)](t(423));this.config[t(413)]&&console[t(416)](t(402));const e=[];for(const s of this[t(411)][t(392)]())e.push(s[t(428)]());await Promise[t(405)](e)}[J(384)](){const t=J;return Array[t(434)](this.adapters[t(396)]())}[J(403)](t,e){h(t,e)}}function j(t,e){return t-=484,F()[t]}function F(){var t=["500234qOoZBl","2964096smBwTo","38520QCxcbo","72Idntpy","823JmCXqa","1626819UNLiSY","576FFWSdF","2715860VimdSk","760FUqSYE","1043312OysbDu"];return(F=function(){return t})()}!function(){for(var t=j,e=F();;)try{if(350169===parseInt(t(487))/1*(parseInt(t(491))/2)+-parseInt(t(488))/3+-parseInt(t(492))/4+-parseInt(t(490))/5+parseInt(t(484))/6+parseInt(t(493))/7*(parseInt(t(486))/8)+parseInt(t(489))/9*(parseInt(t(485))/10))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 s}from"firebase/analytics";import*as n from"sa-sdk-javascript";var e,i;function r(t,s){return t-=430,o()[t]}function o(){var t=["12glWDsv","FIREBASE","2001590tQDYCx","819981fHKBSZ","91862EZzuxl","1985224OWTheH","1OEGyTL","14mZUTpM","1197891rdCOBi","418630aTPpkc","765344vvtCBA"];return(o=function(){return t})()}function a(){const t=["https://www.googletagmanager.com/ns.html?id=","warn","4xbjJJX","height","[GoogleTagManager] Pushed to dataLayer:","gtm.js?id=","[GoogleTagManager] Error pushing to dataLayer:","style","head","[GTM] Already injected, skip","string","parentNode","push","dataLayer","3632CIaSpN","1205405xJWWIc","21140KuVZpu","from","[GTM] Not in browser environment, skip injection","appendChild","body","[GoogleTagManager] Invalid event name:","firstChild","424IAhoXb","width","some","script","visibility","244473xnDKEm","[GTM] Injection failed:","noscript","src","[GoogleTagManager] dataLayer not initialized","none","log","76GDmEdj","iframe","createElement","includes","126720BJWxam","display","async","1582461jKHBqD","insertBefore","error","2364774HORbGx","querySelectorAll","undefined","https://www.googletagmanager.com/gtm.js?id="];return(a=function(){return t})()}function c(){const t=l;return typeof window!==t(270)&&typeof document!==t(270)}function l(t,s){t-=233;return a()[t]}function h(t){const s=l,n=document[s(260)](s(253)),e=document[s(260)](s(259));e[s(254)]=s(272)+t,e[s(275)]="0",e[s(247)]="0",e[s(279)][s(263)]=s(256),e[s(279)][s(250)]="hidden",n[s(242)](e),document[s(243)].firstChild?document.body[s(266)](n,document.body[s(245)]):document[s(243)].appendChild(n)}function d(t,s=!1){const n=l;if(c())if(t)if(function(t){const s=l;if(!c())return!1;const n=!!window[s(236)],e=document[s(269)](s(249)),i=Array[s(240)](e)[s(248)](n=>n.src[s(261)](s(277)+t));return n&&i}(t))s&&console.log(n(281));else try{(function(t){const s=l;window[s(236)]=window[s(236)]||[],window.dataLayer[s(235)]({"gtm.start":(new Date).getTime(),event:"gtm.js"});const n=document[s(260)](s(249));n[s(264)]=!0,n[s(254)]=s(271)+t;const e=document.getElementsByTagName(s(249))[0];e&&e.parentNode?e[s(234)][s(266)](n,e):document[s(280)][s(242)](n)})(t),document[n(243)]?h(t):document.addEventListener("DOMContentLoaded",()=>{h(t)}),s&&console[n(257)]("[GTM] Injected successfully: "+t)}catch(t){console.error(n(252),t)}else s&&console[n(273)]("[GTM] GTM ID is empty, skip injection");else s&&console.warn(n(241))}!function(){for(var t=r,s=o();;)try{if(324898===-parseInt(t(440))/1*(parseInt(t(438))/2)+parseInt(t(431))/3+-parseInt(t(439))/4+-parseInt(t(432))/5*(-parseInt(t(434))/6)+parseInt(t(430))/7*(parseInt(t(433))/8)+-parseInt(t(437))/9+parseInt(t(436))/10)break;s.push(s.shift())}catch(t){s.push(s.shift())}}(),(i=e||(e={}))[r(435)]="firebase",i.SENSORS="sensors",function(){const t=l,s=a();for(;;)try{if(230124===-parseInt(t(237))/1*(parseInt(t(258))/2)+-parseInt(t(251))/3*(-parseInt(t(274))/4)+parseInt(t(238))/5+parseInt(t(268))/6+-parseInt(t(239))/7*(parseInt(t(246))/8)+-parseInt(t(265))/9+-parseInt(t(262))/10)break;s.push(s.shift())}catch(t){s.push(s.shift())}}();const p=(t,s)=>{const n=l;if(!t||typeof t!==n(233))return void console[n(267)](n(244),t);(t=>{const s=l;if(typeof window!==s(270)&&window[s(236)])try{window[s(236)][s(235)](t),console[s(257)](s(276),t)}catch(t){console[s(267)](s(278),t)}else console[s(267)](s(255))})({event:t,...s||{}})};function f(){const t=["analytics","453663omFosI","18003952UYuKDR","setUserProperties","2445528ZmyCvO","track","error","setUserId","initialized","794442kDpdKe","507678TuOpzE","6049392PYPqjo","config","2332420yUpIMI","gtmId","firebase initialize failed:","debug","35bhxuhs"];return(f=function(){return t})()}const u=I;function I(t,s){t-=200;return f()[t]}!function(){const t=I,s=f();for(;;)try{if(788670===-parseInt(t(202))/1+-parseInt(t(205))/2+-parseInt(t(211))/3+parseInt(t(212))/4+-parseInt(t(214))/5+parseInt(t(210))/6*(-parseInt(t(200))/7)+parseInt(t(203))/8)break;s.push(s.shift())}catch(t){s.push(s.shift())}}();class m{constructor(t,s,n=!1){const e=I;this[e(201)]=null,this[e(209)]=!1,this[e(213)]=t,this.gtmId=s,this.debug=n}async initialize(){const n=I;if(!this[n(209)])try{this[n(215)]&&d(this.gtmId,this[n(217)]);const e=t(this[n(213)]);this[n(201)]=s(e),this[n(209)]=!0}catch(t){throw console[n(207)](n(216),t),t}}async[u(206)](t,s){}async[u(208)](t){}async[u(204)](t){}async clearUserId(){}}const y=g;function w(){const t=["setProfile","initialize","4495DSdori","logout","21679875fnXuwx","showLog","4563352xMCRdN","sensors","heatmap","ajax","sensors sdk not initialized, skip track","sensors sdk not initialized, skip setUserProperties","clearUserId","3619504CBhIgy","1292949BCqOLp","900272coWgmd","platform","track","sensors sdk not initialized, skip setUserId","6594RrCyli","?t=","warn","26600mxdgzq","setUserId","token","sensors sdk not found, please install it by running","setUserProperties","init","error","sensors sdk setUserProperties failed:","config","sensors sdk init failed:","sensors sdk setUserId failed:","84SlKwzo","sensors sdk track failed:","initialized","&v="];return(w=function(){return t})()}function g(t,s){t-=491;return w()[t]}!function(){const t=g,s=w();for(;;)try{if(577902===-parseInt(t(503))/1*(-parseInt(t(514))/2)+-parseInt(t(495))/3+parseInt(t(496))/4+parseInt(t(520))/5*(parseInt(t(500))/6)+parseInt(t(494))/7+parseInt(t(524))/8+-parseInt(t(522))/9)break;s.push(s.shift())}catch(t){s.push(s.shift())}}();class k{constructor(t,s,n,e){const i=g;this[i(525)]=null,this[i(516)]=!1,this[i(505)]=t,this[i(497)]=s,this.version=n,this[i(511)]=e}async[y(519)](){const t=y;if(!this[t(516)])try{if(!n)throw new Error(t(506));this[t(525)]=n;const s=encodeURIComponent(this[t(505)]),e=encodeURIComponent(this[t(497)]),i=encodeURIComponent(this.version);this[t(525)][t(508)]({server_url:this[t(511)].serverUrl+(t(501)+s+"&p=")+e+t(517)+i,show_log:this[t(511)][t(523)]??!1,heatmap:this[t(511)][t(526)]??{},is_track_single_page:!0,send_type:t(527)}),this[t(516)]=!0,this.sensors.quick("autoTrack")}catch(s){throw console[t(509)](t(512),s),s}}async[y(498)](t,s){const n=y;if(this[n(516)]&&this[n(525)])try{this[n(525)][n(498)](t,s??{})}catch(t){console.error(n(515),t)}else console[n(502)](n(491))}async[y(504)](t){const s=y;if(this[s(516)]&&this[s(525)])try{this[s(525)].login(t)}catch(t){console.error(s(513),t)}else console.warn(s(499))}async[y(507)](t){const s=y;if(this[s(516)]&&this.sensors)try{this.sensors[s(518)](t)}catch(t){console.error(s(510),t)}else console[s(502)](s(492))}async[y(493)](){const t=y;if(this[t(516)]&&this.sensors)try{this[t(525)][t(521)]()}catch(s){console[t(509)]("sensors sdk clearUserId failed:",s)}}}function b(){var t=["6868253TXhhuJ","undefined","2506398PcueeQ","btoa","base64","78Rfmzmi","2261528ZmKvmc","toString","utf-8","1128filLbp","11036870JPqymD","15oVqSsu","atob","823668vZiTtf","14913yXtXDF","17939jbHTYV"];return(b=function(){return t})()}function z(t,s){return t-=261,b()[t]}function Z(t){var s=z;return"undefined"!=typeof window&&window[s(261)]?window[s(261)](t):Buffer.from(t,s(266))[s(265)]("base64")}function v(t){return JSON.parse((s=t,n=z,typeof window!==n(275)&&window.atob?window[n(270)](s):Buffer.from(s,n(262)).toString(n(266))));var s,n}!function(){for(var t=z,s=b();;)try{if(642505===parseInt(t(273))/1*(parseInt(t(263))/2)+parseInt(t(271))/3+parseInt(t(264))/4+parseInt(t(269))/5*(-parseInt(t(276))/6)+-parseInt(t(274))/7+parseInt(t(267))/8*(parseInt(t(272))/9)+parseInt(t(268))/10)break;s.push(s.shift())}catch(t){s.push(s.shift())}}();const M=J;!function(){const t=J,s=N();for(;;)try{if(359557===-parseInt(t(173))/1*(parseInt(t(175))/2)+parseInt(t(172))/3+-parseInt(t(165))/4*(-parseInt(t(171))/5)+-parseInt(t(161))/6+parseInt(t(170))/7+parseInt(t(164))/8+-parseInt(t(166))/9*(-parseInt(t(163))/10))break;s.push(s.shift())}catch(t){s.push(s.shift())}}();const W={"MDE5YjUzNTEyMWJhNzc1ZmIwYTQ1MzY3Njg1NzU1MTU=":{providers:[e.FIREBASE,e.SENSORS],firebaseConfig:v(M(162)),sensorsConfig:v(M(176)),gtmId:M(169)},"MDE5YjUzNTE3ZmFiN2YxZDkwNjg5OWVhMGQyMWJlZGI=":{providers:[e[M(174)],e.SENSORS],firebaseConfig:v(M(168)),sensorsConfig:v("eyJzZXJ2ZXJVcmwiOiJodHRwczovL3N2LWFuYWx5dGljcy5zZy5zZWF2ZXJzZS5haS9zYSIsImhlYXRtYXAiOnsiY2xpY2ttYXAiOiJkZWZhdWx0Iiwic2Nyb2xsX25vdGljZV9tYXAiOiJkZWZhdWx0In19")}};function N(){const t=["8840ebUioO","466232VocMFV","8GBTfbx","9VfVDQN","invalid token: ","eyJhcGlLZXkiOiJBSXphU3lBVVVEam5HdDJKQmdiNVFFYmFFMVFybENvMTdpVWxKWGsiLCJhdXRoRG9tYWluIjoic2VhdmVyc2UtcHJvZHVjdGlvbi5maXJlYmFzZWFwcC5jb20iLCJwcm9qZWN0SWQiOiJzZWF2ZXJzZS1wcm9kdWN0aW9uIiwic3RvcmFnZUJ1Y2tldCI6InNlYXZlcnNlLXByb2R1Y3Rpb24uZmlyZWJhc2VzdG9yYWdlLmFwcCIsIm1lc3NhZ2luZ1NlbmRlcklkIjoiMTAzMzk3MzA4MzE5OCIsImFwcElkIjoiMToxMDMzOTczMDgzMTk4OndlYjpkMTQ4OGM3MzI0MWIyZWMzNmY3NTZmIiwibWVhc3VyZW1lbnRJZCI6IkctR0gxNk1CQ1NOVyJ9","GTM-MJDRW2W4","3985310KDTNbZ","402455mGOINX","1727022HgsBAD","2bLBHIk","FIREBASE","561186kqojIS","eyJzZXJ2ZXJVcmwiOiJodHRwczovL3N2LWFuYWx5dGljcy5zZy5zZWF2ZXJzZS5haS9zYSIsImhlYXRtYXAiOnsiY2xpY2ttYXAiOiJkZWZhdWx0Iiwic2Nyb2xsX25vdGljZV9tYXAiOiJkZWZhdWx0In19","2666436CUieRQ","eyJhcGlLZXkiOiJBSXphU3lBVVVEam5HdDJKQmdiNVFFYmFFMVFybENvMTdpVWxKWGsiLCJhdXRoRG9tYWluIjoic2VhdmVyc2UtcHJvZHVjdGlvbi5maXJlYmFzZWFwcC5jb20iLCJwcm9qZWN0SWQiOiJzZWF2ZXJzZS1wcm9kdWN0aW9uIiwic3RvcmFnZUJ1Y2tldCI6InNlYXZlcnNlLXByb2R1Y3Rpb24uZmlyZWJhc2VzdG9yYWdlLmFwcCIsIm1lc3NhZ2luZ1NlbmRlcklkIjoiMTAzMzk3MzA4MzE5OCIsImFwcElkIjoiMToxMDMzOTczMDgzMTk4OndlYjo2NmI2ZTNmNmEwZjM2MDkwNmY3NTZmIiwibWVhc3VyZW1lbnRJZCI6IkctN0gySjFTQ05QRCJ9"];return(N=function(){return t})()}function J(t,s){t-=161;return N()[t]}const T=S;function S(t,s){t-=384;return C()[t]}function C(){const t=["Must provide a token","1105356abWdOV","keys","providers","token","15sCKKDt","132036ddNKyX","253aKLiKm","[Track] Clear User ID","trackGTMEvent","warn","allSettled","[Track] Set User ID:","4057713AafXPB","Must provide a platform","Track SDK initialized, enabled providers:","unknown provider: ","adapters","config","debug","15319vFlWyN","setUserId","log","8nghjzf","17610905LVahoh","set","firebaseConfig","initialized","10KLEqge","track SDK not initialized, please call initialize() first","70XhMhPV","initialize","[Track] Set User Properties:","initialize ","clearUserId","version","platformConfig","FIREBASE","validateConfig","track","from","getInitializedProviders","push","554444JFFIWm","setUserProperties","5789wyxboT","platform","error","Invalid token: ","values","10jyWoWP"];return(C=function(){return t})()}!function(){const t=S,s=C();for(;;)try{if(461766===parseInt(t(414))/1*(-parseInt(t(424))/2)+parseInt(t(399))/3*(-parseInt(t(386))/4)+-parseInt(t(422))/5*(parseInt(t(395))/6)+parseInt(t(388))/7*(parseInt(t(417))/8)+-parseInt(t(407))/9*(-parseInt(t(393))/10)+-parseInt(t(401))/11*(-parseInt(t(400))/12)+parseInt(t(418))/13)break;s.push(s.shift())}catch(t){s.push(s.shift())}}();class TrackClient{constructor(t){const s=S;this[s(411)]=new Map,this[s(421)]=!1,this.config=t,this[s(432)](),this[s(430)]=function(t){const s=M,n=Z(t),e=W[n];if(!e)throw new Error(s(167)+t);return e}(t[s(398)])}[T(432)](){const t=T;if(!this[t(412)].token)throw new Error(t(394));if(!this[t(412)].platform)throw new Error(t(408));if(!this[t(412)][t(429)])throw new Error("Must provide a version");if(!(Z(this[t(412)].token)in W))throw new Error(t(391)+this[t(412)][t(398)])}async initialize(){const t=T;if(this[t(421)])return;const s=[],n=!1!==this[t(412)].initializeFirebase;for(const i of this[t(430)][t(397)])try{if(i===e[t(431)]&&!n){this.config.debug&&console[t(416)]("[Track] Skip Firebase initialization (initializeFirebase = false)");continue}let r;switch(i){case e[t(431)]:r=new m(this[t(430)][t(420)],this[t(430)].gtmId,this[t(412)].debug);break;case e.SENSORS:r=new k(this[t(412)][t(398)],this[t(412)][t(389)],this[t(412)][t(429)],this.platformConfig.sensorsConfig);break;default:console.warn(t(410)+i);continue}this[t(411)][t(419)](i,r),s[t(385)](r[t(425)]())}catch(s){console[t(390)](t(427)+i+" adapter failed:",s)}await Promise[t(405)](s),this[t(421)]=!0,this[t(412)][t(413)]&&console.log(t(409),Array[t(434)](this[t(411)].keys()))}async track(t,s){const n=T;if(!this.initialized)return void console[n(404)](n(423));this[n(412)][n(413)]&&console[n(416)]("[Track] "+t,s);const e=[];for(const i of this[n(411)].values())e[n(385)](i[n(433)](t,s));await Promise[n(405)](e)}async[T(415)](t){const s=T;if(!this.initialized)return void console.warn(s(423));this[s(412)].debug&&console.log(s(406),t);const n=[];for(const e of this[s(411)][s(392)]())n[s(385)](e[s(415)](t));await Promise.allSettled(n)}async setUserProperties(t){const s=T;if(!this.initialized)return void console[s(404)](s(423));this[s(412)][s(413)]&&console[s(416)](s(426),t);const n=[];for(const e of this[s(411)][s(392)]())n[s(385)](e[s(387)](t));await Promise[s(405)](n)}async[T(428)](){const t=T;if(!this[t(421)])return void console[t(404)](t(423));this.config[t(413)]&&console[t(416)](t(402));const s=[];for(const n of this[t(411)][t(392)]())s.push(n[t(428)]());await Promise[t(405)](s)}[T(384)](){const t=T;return Array[t(434)](this.adapters[t(396)]())}[T(403)](t,s){p(t,s)}}function F(t,s){return t-=484,Y()[t]}function Y(){var t=["500234qOoZBl","2964096smBwTo","38520QCxcbo","72Idntpy","823JmCXqa","1626819UNLiSY","576FFWSdF","2715860VimdSk","760FUqSYE","1043312OysbDu"];return(Y=function(){return t})()}!function(){for(var t=F,s=Y();;)try{if(350169===parseInt(t(487))/1*(parseInt(t(491))/2)+-parseInt(t(488))/3+-parseInt(t(492))/4+-parseInt(t(490))/5+parseInt(t(484))/6+parseInt(t(493))/7*(parseInt(t(486))/8)+parseInt(t(489))/9*(parseInt(t(485))/10))break;s.push(s.shift())}catch(t){s.push(s.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.
|
|
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
|
".": {
|