@liff/analytics
Advanced tools
Comparing version 2.21.2 to 2.21.3
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("@liff/consts"),i=require("@liff/logger"),r=require("@liff/util"),s=require("@liff/store"),n=require("@liff/get-version"),o=require("@liff/is-logged-in"),u=require("@liff/get-profile");function a(){return e.__awaiter(this,void 0,void 0,(function(){var t,r;return e.__generator(this,(function(e){switch(e.label){case 0:if(!o.isLoggedIn())return[3,6];e.label=1;case 1:return e.trys.push([1,5,,6]),(t=s.getDecodedIDToken())&&t.sub?[2,t.sub]:[3,2];case 2:return[4,u.getProfile()];case 3:if((r=e.sent())&&r.userId)return[2,r.userId];e.label=4;case 4:return[3,6];case 5:return e.sent(),i.logger.debug("can't retrieve Mid/Uid because of something wrong"),[3,6];case 6:return[2]}}))}))}function f(){return e.__awaiter(this,void 0,void 0,(function(){var t;return e.__generator(this,(function(e){switch(e.label){case 0:return[4,a()];case 1:return(t=e.sent())&&"u"===t.substring(0,1)?[2,t]:[2]}}))}))}var c=function(){function u(){this.utsExtra={isLiffSuccessful:!1,isLoggedIn:!1,id:"",version:""},this.injected=!1}return Object.defineProperty(u,"CUSTOMPLACEID_INIT",{get:function(){return"liff.init"},enumerable:!1,configurable:!0}),Object.defineProperty(u,"CUSTOMTYPE",{get:function(){return"liffSdk"},enumerable:!1,configurable:!0}),Object.defineProperty(u,"GENERAL_UTS_ID",{get:function(){return"liff_general"},enumerable:!1,configurable:!0}),Object.defineProperty(u,"GENERAL_APP_NAME",{get:function(){return"LIFF General"},enumerable:!1,configurable:!0}),Object.defineProperty(u,"LiffUtsLoginStatus",{get:function(){return{isLoggedIn:1,isLiffSuccessful:2}},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"name",{get:function(){return"analytics"},enumerable:!1,configurable:!0}),u.prototype.install=function(e){var t=e.liff,i=e.internalHooks;this.liffCore=t,i.init.beforeFinished(this.beforeInitFinished.bind(this)),i.init.beforeSuccess(this.beforeInitSuccess.bind(this)),i.init.error(this.initError.bind(this))},u.prototype.changeRatioToUTSFormat=function(e){if(e&&Number.isFinite(e))return Math.round(100*e)},u.prototype.setExtra=function(){var e=this.utsExtra,t=e.isLiffSuccessful,i=e.isLoggedIn,r=e.id,s=e.version,n=(i?u.LiffUtsLoginStatus.isLoggedIn:0)|(t?u.LiffUtsLoginStatus.isLiffSuccessful:0);this.uts.setExtra("liff",{id:r,loginStatus:n,version:s})},u.prototype.assignUtsExtra=function(e){Object.assign(this.utsExtra,e)},u.prototype.setVersion=function(e){this.assignUtsExtra({version:e}),i.logger.debug("[LIFFUTS][SDK version] ".concat(e)),this.setExtra()},u.prototype.setLiffId=function(e){this.assignUtsExtra({id:e}),i.logger.debug("[LIFFUTS][LIFFID] ".concat(e)),this.setExtra()},u.prototype.setIsLoggedIn=function(e){this.assignUtsExtra({isLoggedIn:e}),i.logger.debug("[LIFFUTS][isLoggedIn] ".concat(e)),this.setExtra()},u.prototype.sendLiffInit=function(){i.logger.debug("[LIFFUTS][sendCustom] liff.init"),this.uts.sendCustom({type:u.CUSTOMTYPE,params:{placeId:u.CUSTOMPLACEID_INIT}})},u.prototype.setIsLiffSuccessful=function(e){this.assignUtsExtra({isLiffSuccessful:e}),i.logger.debug("[LIFFUTS][isLiffInitSuccessful] ".concat(e)),this.setExtra()},u.prototype.prepareReferrer=function(e){var i={};Object.keys(e).forEach((function(r){if(t.UTS_REFERRER_QUERY.includes(r)){var s=e[r];"string"==typeof s&&s&&(i[r.replace(/^liff\.ref\./,"")]=s)}})),Object.keys(i).length>0&&(this.referrer=i)},u.prototype.beforeInitFinished=function(){return e.__awaiter(this,void 0,void 0,(function(){var t,a,c,l,g,d,p,h,b,I,L,E,S;return e.__generator(this,(function(v){switch(v.label){case 0:if(t=r.qs.parse(window.location.search),this.prepareReferrer(t),a=s.getContext(),!(c=null==a?void 0:a.utsTracking))return[2];if("auto"!==(l=c.mode)&&"force"!==l)return[3,6];i.logger.debug("[LIFFUTS] ".concat((new Date).toUTCString())),g=s.getConfig(),d=g.liffId,p=g.analytics,v.label=1;case 1:return v.trys.push([1,3,,4]),h=this,[4,new Promise((function(e,t){var i=window.uts,r=document.createElement("script");r.type="text/javascript",r.src="https://static.line-scdn.net/uts/edge/4.1.0/uts.js",r.onload=function(){var t=window.uts;e(t),window.uts=i},r.onerror=function(e){t(e)},document.getElementsByTagName("head")[0].appendChild(r)}))];case 2:return h.uts=v.sent(),[3,4];case 3:return b=v.sent(),i.logger.debug("[LIFFUTS] cannot load UTS, reason: ".concat(b)),[2];case 4:return I=void 0,L=void 0,"force"===l?(I={utsId:u.GENERAL_UTS_ID,appName:u.GENERAL_APP_NAME,appEnv:"release"},L={endpoint:"https://uts-front.line-apps.com",sampleRate:this.changeRatioToUTSFormat(c.sendRatio),version:"current"}):(I=e.__assign(e.__assign({},null==p?void 0:p.context),{utsId:(null==p?void 0:p.context.utsId)||u.GENERAL_UTS_ID,appName:(null==p?void 0:p.context.appName)||u.GENERAL_APP_NAME,appEnv:(null==p?void 0:p.context.appEnv)||"release"}),L=e.__assign(e.__assign({endpoint:"https://uts-front.line-apps.com"},null==p?void 0:p.options),{sampleRate:this.changeRatioToUTSFormat(c.sendRatio),version:"current"})),this.uts.init(I,L),[4,f()];case 5:(E=v.sent())&&(i.logger.debug("[LIFFUTS][mid] ".concat(E)),this.uts.setMid(E)),(null==a?void 0:a.tid)&&(i.logger.debug("[LIFFUTS][tid] ".concat(a.tid)),this.uts.setTid(a.tid)),this.referrer&&(i.logger.debug("liff.ref.referrer",this.referrer),this.uts.setSessionParams(this.referrer)),d&&this.setLiffId(d),this.setIsLoggedIn(o.isLoggedIn()),this.setVersion(n.getVersion()),S=r.removeCredential(location.href),i.logger.debug("[LIFFUTS][url] ".concat(S)),this.uts.setUrl(S),this.liffCore.analytics=this.uts,this.injected=!0,v.label=6;case 6:return[2]}}))}))},u.prototype.beforeInitSuccess=function(){return this.injected&&(this.setIsLiffSuccessful(!0),this.sendLiffInit()),Promise.resolve()},u.prototype.initError=function(){return this.injected&&(this.setIsLiffSuccessful(!1),this.sendLiffInit()),Promise.resolve()},u}();exports.AnalyticsModule=c,exports.sendShareTargetPicker=function(e){i.logger.debug("[LIFFUTS][sendCustom] liff.shareTargetPicker"),e.sendCustom({type:"liffSdk",params:{placeId:"liff.shareTargetPicker"}})}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("@liff/consts"),i=require("@liff/logger"),s=require("@liff/util"),r=require("@liff/store"),n=require("@liff/get-version"),o=require("@liff/is-logged-in"),u=require("@liff/get-profile");function a(){return e.__awaiter(this,void 0,void 0,(function(){var t,s;return e.__generator(this,(function(e){switch(e.label){case 0:if(!o.isLoggedIn())return[3,6];e.label=1;case 1:return e.trys.push([1,5,,6]),(t=r.getDecodedIDToken())&&t.sub?[2,t.sub]:[3,2];case 2:return[4,u.getProfile()];case 3:if((s=e.sent())&&s.userId)return[2,s.userId];e.label=4;case 4:return[3,6];case 5:return e.sent(),i.logger.debug("can't retrieve Mid/Uid because of something wrong"),[3,6];case 6:return[2]}}))}))}function f(){return e.__awaiter(this,void 0,void 0,(function(){var t;return e.__generator(this,(function(e){switch(e.label){case 0:return[4,a()];case 1:return(t=e.sent())&&"u"===t.substring(0,1)?[2,t]:[2]}}))}))}var c=function(){function u(){this.utsExtra={isLiffSuccessful:!1,isLoggedIn:!1,id:"",version:""},this.injected=!1}return Object.defineProperty(u,"CUSTOMPLACEID_INIT",{get:function(){return"liff.init"},enumerable:!1,configurable:!0}),Object.defineProperty(u,"CUSTOMTYPE",{get:function(){return"liffSdk"},enumerable:!1,configurable:!0}),Object.defineProperty(u,"LiffUtsLoginStatus",{get:function(){return{isLoggedIn:1,isLiffSuccessful:2}},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"name",{get:function(){return"analytics"},enumerable:!1,configurable:!0}),u.prototype.install=function(e){var t=e.liff,i=e.internalHooks;this.liffCore=t,i.init.beforeFinished(this.beforeInitFinished.bind(this)),i.init.beforeSuccess(this.beforeInitSuccess.bind(this)),i.init.error(this.initError.bind(this))},u.prototype.changeRatioToUTSFormat=function(e){if(e&&Number.isFinite(e))return Math.round(100*e)},u.prototype.setExtra=function(){var e,t=this.utsExtra,i=t.isLiffSuccessful,s=t.isLoggedIn,r=t.id,n=t.version,o=(s?u.LiffUtsLoginStatus.isLoggedIn:0)|(i?u.LiffUtsLoginStatus.isLiffSuccessful:0);null===(e=this.uts)||void 0===e||e.setExtra("liff",{id:r,loginStatus:o,version:n})},u.prototype.assignUtsExtra=function(e){Object.assign(this.utsExtra,e)},u.prototype.setVersion=function(e){this.assignUtsExtra({version:e}),i.logger.debug("[LIFFUTS][SDK version] ".concat(e)),this.setExtra()},u.prototype.setLiffId=function(e){this.assignUtsExtra({id:e}),i.logger.debug("[LIFFUTS][LIFFID] ".concat(e)),this.setExtra()},u.prototype.setIsLoggedIn=function(e){this.assignUtsExtra({isLoggedIn:e}),i.logger.debug("[LIFFUTS][isLoggedIn] ".concat(e)),this.setExtra()},u.prototype.sendLiffInit=function(){var e;i.logger.debug("[LIFFUTS][sendCustom] liff.init"),null===(e=this.uts)||void 0===e||e.sendCustom({type:u.CUSTOMTYPE,params:{placeId:u.CUSTOMPLACEID_INIT}})},u.prototype.setIsLiffSuccessful=function(e){this.assignUtsExtra({isLiffSuccessful:e}),i.logger.debug("[LIFFUTS][isLiffInitSuccessful] ".concat(e)),this.setExtra()},u.prototype.prepareReferrer=function(e){var i={};Object.keys(e).forEach((function(s){if(t.UTS_REFERRER_QUERY.includes(s)){var r=e[s];"string"==typeof r&&r&&(i[s.replace(/^liff\.ref\./,"")]=r)}})),Object.keys(i).length>0&&(this.referrer=i)},u.prototype.beforeInitFinished=function(){return e.__awaiter(this,void 0,void 0,(function(){var t,u,a,c,g,l,d,h,p,I,b,L;return e.__generator(this,(function(S){switch(S.label){case 0:if(t=s.qs.parse(window.location.search),this.prepareReferrer(t),u=r.getContext(),!(a=null==u?void 0:u.utsTracking))return[2];if(c=r.getConfig(),g=c.liffId,l=c.analytics,"auto"!==a.mode||!l)return[3,6];i.logger.debug("[LIFFUTS] ".concat((new Date).toUTCString())),S.label=1;case 1:return S.trys.push([1,3,,4]),d=this,[4,new Promise((function(e,t){var i=window.uts,s=document.createElement("script");s.type="text/javascript",s.src="https://static.line-scdn.net/uts/edge/4.1.0/uts.js",s.onload=function(){var t=window.uts;e(t),window.uts=i},s.onerror=function(e){t(e)},document.getElementsByTagName("head")[0].appendChild(s)}))];case 2:return d.uts=S.sent(),[3,4];case 3:return h=S.sent(),i.logger.debug("[LIFFUTS] cannot load UTS, reason: ".concat(h)),[2];case 4:return p=e.__assign(e.__assign({},l.context),{utsId:l.context.utsId,appName:l.context.appName,appEnv:l.context.appEnv||"release"}),I=e.__assign(e.__assign({endpoint:"https://uts-front.line-apps.com"},l.options),{sampleRate:this.changeRatioToUTSFormat(a.sendRatio),version:"current"}),this.uts.init(p,I),[4,f()];case 5:(b=S.sent())&&(i.logger.debug("[LIFFUTS][mid] ".concat(b)),this.uts.setMid(b)),(null==u?void 0:u.tid)&&(i.logger.debug("[LIFFUTS][tid] ".concat(u.tid)),this.uts.setTid(u.tid)),this.referrer&&(i.logger.debug("liff.ref.referrer",this.referrer),this.uts.setSessionParams(this.referrer)),g&&this.setLiffId(g),this.setIsLoggedIn(o.isLoggedIn()),this.setVersion(n.getVersion()),L=s.removeCredential(location.href),i.logger.debug("[LIFFUTS][url] ".concat(L)),this.uts.setUrl(L),this.liffCore.analytics=this.uts,this.injected=!0,S.label=6;case 6:return[2]}}))}))},u.prototype.beforeInitSuccess=function(){return this.injected&&(this.setIsLiffSuccessful(!0),this.sendLiffInit()),Promise.resolve()},u.prototype.initError=function(){return this.injected&&(this.setIsLiffSuccessful(!1),this.sendLiffInit()),Promise.resolve()},u}();exports.AnalyticsModule=c,exports.sendShareTargetPicker=function(e){i.logger.debug("[LIFFUTS][sendCustom] liff.shareTargetPicker"),e.sendCustom({type:"liffSdk",params:{placeId:"liff.shareTargetPicker"}})}; |
@@ -12,6 +12,4 @@ import { LiffUTS } from '@liff/types'; | ||
private static get CUSTOMTYPE(); | ||
private static get GENERAL_UTS_ID(); | ||
private static get GENERAL_APP_NAME(); | ||
private static get LiffUtsLoginStatus(); | ||
private uts; | ||
private uts?; | ||
private utsExtra; | ||
@@ -18,0 +16,0 @@ private referrer; |
@@ -1,1 +0,1 @@ | ||
import{__awaiter as t,__generator as e,__assign as i}from"tslib";import{UTS_REFERRER_QUERY as s}from"@liff/consts";import{logger as n}from"@liff/logger";import{removeCredential as r,qs as o}from"@liff/util";import{getDecodedIDToken as f,getContext as u,getConfig as a}from"@liff/store";import{getVersion as c}from"@liff/get-version";import{isLoggedIn as l}from"@liff/is-logged-in";import{getProfile as d}from"@liff/get-profile";function p(){return t(this,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!l())return[3,6];e.label=1;case 1:return e.trys.push([1,5,,6]),(t=f())&&t.sub?[2,t.sub]:[3,2];case 2:return[4,d()];case 3:if((i=e.sent())&&i.userId)return[2,i.userId];e.label=4;case 4:return[3,6];case 5:return e.sent(),n.debug("can't retrieve Mid/Uid because of something wrong"),[3,6];case 6:return[2]}}))}))}function h(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,p()];case 1:return(t=e.sent())&&"u"===t.substring(0,1)?[2,t]:[2]}}))}))}var g=function(){function f(){this.utsExtra={isLiffSuccessful:!1,isLoggedIn:!1,id:"",version:""},this.injected=!1}return Object.defineProperty(f,"CUSTOMPLACEID_INIT",{get:function(){return"liff.init"},enumerable:!1,configurable:!0}),Object.defineProperty(f,"CUSTOMTYPE",{get:function(){return"liffSdk"},enumerable:!1,configurable:!0}),Object.defineProperty(f,"GENERAL_UTS_ID",{get:function(){return"liff_general"},enumerable:!1,configurable:!0}),Object.defineProperty(f,"GENERAL_APP_NAME",{get:function(){return"LIFF General"},enumerable:!1,configurable:!0}),Object.defineProperty(f,"LiffUtsLoginStatus",{get:function(){return{isLoggedIn:1,isLiffSuccessful:2}},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"name",{get:function(){return"analytics"},enumerable:!1,configurable:!0}),f.prototype.install=function(t){var e=t.liff,i=t.internalHooks;this.liffCore=e,i.init.beforeFinished(this.beforeInitFinished.bind(this)),i.init.beforeSuccess(this.beforeInitSuccess.bind(this)),i.init.error(this.initError.bind(this))},f.prototype.changeRatioToUTSFormat=function(t){if(t&&Number.isFinite(t))return Math.round(100*t)},f.prototype.setExtra=function(){var t=this.utsExtra,e=t.isLiffSuccessful,i=t.isLoggedIn,s=t.id,n=t.version,r=(i?f.LiffUtsLoginStatus.isLoggedIn:0)|(e?f.LiffUtsLoginStatus.isLiffSuccessful:0);this.uts.setExtra("liff",{id:s,loginStatus:r,version:n})},f.prototype.assignUtsExtra=function(t){Object.assign(this.utsExtra,t)},f.prototype.setVersion=function(t){this.assignUtsExtra({version:t}),n.debug("[LIFFUTS][SDK version] ".concat(t)),this.setExtra()},f.prototype.setLiffId=function(t){this.assignUtsExtra({id:t}),n.debug("[LIFFUTS][LIFFID] ".concat(t)),this.setExtra()},f.prototype.setIsLoggedIn=function(t){this.assignUtsExtra({isLoggedIn:t}),n.debug("[LIFFUTS][isLoggedIn] ".concat(t)),this.setExtra()},f.prototype.sendLiffInit=function(){n.debug("[LIFFUTS][sendCustom] liff.init"),this.uts.sendCustom({type:f.CUSTOMTYPE,params:{placeId:f.CUSTOMPLACEID_INIT}})},f.prototype.setIsLiffSuccessful=function(t){this.assignUtsExtra({isLiffSuccessful:t}),n.debug("[LIFFUTS][isLiffInitSuccessful] ".concat(t)),this.setExtra()},f.prototype.prepareReferrer=function(t){var e={};Object.keys(t).forEach((function(i){if(s.includes(i)){var n=t[i];"string"==typeof n&&n&&(e[i.replace(/^liff\.ref\./,"")]=n)}})),Object.keys(e).length>0&&(this.referrer=e)},f.prototype.beforeInitFinished=function(){return t(this,void 0,void 0,(function(){var t,s,d,p,g,b,I,m,L,S,E,v,T;return e(this,(function(e){switch(e.label){case 0:if(t=o.parse(window.location.search),this.prepareReferrer(t),s=u(),!(d=null==s?void 0:s.utsTracking))return[2];if("auto"!==(p=d.mode)&&"force"!==p)return[3,6];n.debug("[LIFFUTS] ".concat((new Date).toUTCString())),g=a(),b=g.liffId,I=g.analytics,e.label=1;case 1:return e.trys.push([1,3,,4]),m=this,[4,new Promise((function(t,e){var i=window.uts,s=document.createElement("script");s.type="text/javascript",s.src="https://static.line-scdn.net/uts/edge/4.1.0/uts.js",s.onload=function(){var e=window.uts;t(e),window.uts=i},s.onerror=function(t){e(t)},document.getElementsByTagName("head")[0].appendChild(s)}))];case 2:return m.uts=e.sent(),[3,4];case 3:return L=e.sent(),n.debug("[LIFFUTS] cannot load UTS, reason: ".concat(L)),[2];case 4:return S=void 0,E=void 0,"force"===p?(S={utsId:f.GENERAL_UTS_ID,appName:f.GENERAL_APP_NAME,appEnv:"release"},E={endpoint:"https://uts-front.line-apps.com",sampleRate:this.changeRatioToUTSFormat(d.sendRatio),version:"current"}):(S=i(i({},null==I?void 0:I.context),{utsId:(null==I?void 0:I.context.utsId)||f.GENERAL_UTS_ID,appName:(null==I?void 0:I.context.appName)||f.GENERAL_APP_NAME,appEnv:(null==I?void 0:I.context.appEnv)||"release"}),E=i(i({endpoint:"https://uts-front.line-apps.com"},null==I?void 0:I.options),{sampleRate:this.changeRatioToUTSFormat(d.sendRatio),version:"current"})),this.uts.init(S,E),[4,h()];case 5:(v=e.sent())&&(n.debug("[LIFFUTS][mid] ".concat(v)),this.uts.setMid(v)),(null==s?void 0:s.tid)&&(n.debug("[LIFFUTS][tid] ".concat(s.tid)),this.uts.setTid(s.tid)),this.referrer&&(n.debug("liff.ref.referrer",this.referrer),this.uts.setSessionParams(this.referrer)),b&&this.setLiffId(b),this.setIsLoggedIn(l()),this.setVersion(c()),T=r(location.href),n.debug("[LIFFUTS][url] ".concat(T)),this.uts.setUrl(T),this.liffCore.analytics=this.uts,this.injected=!0,e.label=6;case 6:return[2]}}))}))},f.prototype.beforeInitSuccess=function(){return this.injected&&(this.setIsLiffSuccessful(!0),this.sendLiffInit()),Promise.resolve()},f.prototype.initError=function(){return this.injected&&(this.setIsLiffSuccessful(!1),this.sendLiffInit()),Promise.resolve()},f}(),b=function(t){n.debug("[LIFFUTS][sendCustom] liff.shareTargetPicker"),t.sendCustom({type:"liffSdk",params:{placeId:"liff.shareTargetPicker"}})};export{g as AnalyticsModule,b as sendShareTargetPicker}; | ||
import{__awaiter as t,__generator as e,__assign as i}from"tslib";import{UTS_REFERRER_QUERY as s}from"@liff/consts";import{logger as n}from"@liff/logger";import{removeCredential as r,qs as o}from"@liff/util";import{getDecodedIDToken as f,getContext as u,getConfig as c}from"@liff/store";import{getVersion as a}from"@liff/get-version";import{isLoggedIn as d}from"@liff/is-logged-in";import{getProfile as l}from"@liff/get-profile";function p(){return t(this,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!d())return[3,6];e.label=1;case 1:return e.trys.push([1,5,,6]),(t=f())&&t.sub?[2,t.sub]:[3,2];case 2:return[4,l()];case 3:if((i=e.sent())&&i.userId)return[2,i.userId];e.label=4;case 4:return[3,6];case 5:return e.sent(),n.debug("can't retrieve Mid/Uid because of something wrong"),[3,6];case 6:return[2]}}))}))}function h(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,p()];case 1:return(t=e.sent())&&"u"===t.substring(0,1)?[2,t]:[2]}}))}))}var g=function(){function f(){this.utsExtra={isLiffSuccessful:!1,isLoggedIn:!1,id:"",version:""},this.injected=!1}return Object.defineProperty(f,"CUSTOMPLACEID_INIT",{get:function(){return"liff.init"},enumerable:!1,configurable:!0}),Object.defineProperty(f,"CUSTOMTYPE",{get:function(){return"liffSdk"},enumerable:!1,configurable:!0}),Object.defineProperty(f,"LiffUtsLoginStatus",{get:function(){return{isLoggedIn:1,isLiffSuccessful:2}},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"name",{get:function(){return"analytics"},enumerable:!1,configurable:!0}),f.prototype.install=function(t){var e=t.liff,i=t.internalHooks;this.liffCore=e,i.init.beforeFinished(this.beforeInitFinished.bind(this)),i.init.beforeSuccess(this.beforeInitSuccess.bind(this)),i.init.error(this.initError.bind(this))},f.prototype.changeRatioToUTSFormat=function(t){if(t&&Number.isFinite(t))return Math.round(100*t)},f.prototype.setExtra=function(){var t,e=this.utsExtra,i=e.isLiffSuccessful,s=e.isLoggedIn,n=e.id,r=e.version,o=(s?f.LiffUtsLoginStatus.isLoggedIn:0)|(i?f.LiffUtsLoginStatus.isLiffSuccessful:0);null===(t=this.uts)||void 0===t||t.setExtra("liff",{id:n,loginStatus:o,version:r})},f.prototype.assignUtsExtra=function(t){Object.assign(this.utsExtra,t)},f.prototype.setVersion=function(t){this.assignUtsExtra({version:t}),n.debug("[LIFFUTS][SDK version] ".concat(t)),this.setExtra()},f.prototype.setLiffId=function(t){this.assignUtsExtra({id:t}),n.debug("[LIFFUTS][LIFFID] ".concat(t)),this.setExtra()},f.prototype.setIsLoggedIn=function(t){this.assignUtsExtra({isLoggedIn:t}),n.debug("[LIFFUTS][isLoggedIn] ".concat(t)),this.setExtra()},f.prototype.sendLiffInit=function(){var t;n.debug("[LIFFUTS][sendCustom] liff.init"),null===(t=this.uts)||void 0===t||t.sendCustom({type:f.CUSTOMTYPE,params:{placeId:f.CUSTOMPLACEID_INIT}})},f.prototype.setIsLiffSuccessful=function(t){this.assignUtsExtra({isLiffSuccessful:t}),n.debug("[LIFFUTS][isLiffInitSuccessful] ".concat(t)),this.setExtra()},f.prototype.prepareReferrer=function(t){var e={};Object.keys(t).forEach((function(i){if(s.includes(i)){var n=t[i];"string"==typeof n&&n&&(e[i.replace(/^liff\.ref\./,"")]=n)}})),Object.keys(e).length>0&&(this.referrer=e)},f.prototype.beforeInitFinished=function(){return t(this,void 0,void 0,(function(){var t,s,f,l,p,g,b,I,m,L,S,v;return e(this,(function(e){switch(e.label){case 0:if(t=o.parse(window.location.search),this.prepareReferrer(t),s=u(),!(f=null==s?void 0:s.utsTracking))return[2];if(l=c(),p=l.liffId,g=l.analytics,"auto"!==f.mode||!g)return[3,6];n.debug("[LIFFUTS] ".concat((new Date).toUTCString())),e.label=1;case 1:return e.trys.push([1,3,,4]),b=this,[4,new Promise((function(t,e){var i=window.uts,s=document.createElement("script");s.type="text/javascript",s.src="https://static.line-scdn.net/uts/edge/4.1.0/uts.js",s.onload=function(){var e=window.uts;t(e),window.uts=i},s.onerror=function(t){e(t)},document.getElementsByTagName("head")[0].appendChild(s)}))];case 2:return b.uts=e.sent(),[3,4];case 3:return I=e.sent(),n.debug("[LIFFUTS] cannot load UTS, reason: ".concat(I)),[2];case 4:return m=i(i({},g.context),{utsId:g.context.utsId,appName:g.context.appName,appEnv:g.context.appEnv||"release"}),L=i(i({endpoint:"https://uts-front.line-apps.com"},g.options),{sampleRate:this.changeRatioToUTSFormat(f.sendRatio),version:"current"}),this.uts.init(m,L),[4,h()];case 5:(S=e.sent())&&(n.debug("[LIFFUTS][mid] ".concat(S)),this.uts.setMid(S)),(null==s?void 0:s.tid)&&(n.debug("[LIFFUTS][tid] ".concat(s.tid)),this.uts.setTid(s.tid)),this.referrer&&(n.debug("liff.ref.referrer",this.referrer),this.uts.setSessionParams(this.referrer)),p&&this.setLiffId(p),this.setIsLoggedIn(d()),this.setVersion(a()),v=r(location.href),n.debug("[LIFFUTS][url] ".concat(v)),this.uts.setUrl(v),this.liffCore.analytics=this.uts,this.injected=!0,e.label=6;case 6:return[2]}}))}))},f.prototype.beforeInitSuccess=function(){return this.injected&&(this.setIsLiffSuccessful(!0),this.sendLiffInit()),Promise.resolve()},f.prototype.initError=function(){return this.injected&&(this.setIsLiffSuccessful(!1),this.sendLiffInit()),Promise.resolve()},f}(),b=function(t){n.debug("[LIFFUTS][sendCustom] liff.shareTargetPicker"),t.sendCustom({type:"liffSdk",params:{placeId:"liff.shareTargetPicker"}})};export{g as AnalyticsModule,b as sendShareTargetPicker}; |
{ | ||
"name": "@liff/analytics", | ||
"version": "2.21.2", | ||
"version": "2.21.3", | ||
"description": "@liff/analytics", | ||
@@ -34,13 +34,13 @@ "license": "SEE LICENSE IN README.md", | ||
"dependencies": { | ||
"@liff/consts": "2.21.2", | ||
"@liff/get-profile": "2.21.2", | ||
"@liff/get-version": "2.21.2", | ||
"@liff/is-logged-in": "2.21.2", | ||
"@liff/logger": "2.21.2", | ||
"@liff/store": "2.21.2", | ||
"@liff/types": "2.21.2", | ||
"@liff/use": "2.21.2", | ||
"@liff/util": "2.21.2" | ||
"@liff/consts": "2.21.3", | ||
"@liff/get-profile": "2.21.3", | ||
"@liff/get-version": "2.21.3", | ||
"@liff/is-logged-in": "2.21.3", | ||
"@liff/logger": "2.21.3", | ||
"@liff/store": "2.21.3", | ||
"@liff/types": "2.21.3", | ||
"@liff/use": "2.21.3", | ||
"@liff/util": "2.21.3" | ||
}, | ||
"gitHead": "b43eee22bc2c90b85e9919820c557cc15fb9712c" | ||
"gitHead": "2fadf770c3e9a1ed908698005a965b4310db6a69" | ||
} |
13719
85
+ Added@liff/consts@2.21.3(transitive)
+ Added@liff/get-profile@2.21.3(transitive)
+ Added@liff/get-version@2.21.3(transitive)
+ Added@liff/hooks@2.21.3(transitive)
+ Added@liff/is-in-client@2.21.3(transitive)
+ Added@liff/is-logged-in@2.21.3(transitive)
+ Added@liff/logger@2.21.3(transitive)
+ Added@liff/server-api@2.21.3(transitive)
+ Added@liff/store@2.21.3(transitive)
+ Added@liff/types@2.21.3(transitive)
+ Added@liff/use@2.21.3(transitive)
+ Added@liff/util@2.21.3(transitive)
- Removed@liff/consts@2.21.2(transitive)
- Removed@liff/get-profile@2.21.2(transitive)
- Removed@liff/get-version@2.21.2(transitive)
- Removed@liff/hooks@2.21.2(transitive)
- Removed@liff/is-in-client@2.21.2(transitive)
- Removed@liff/is-logged-in@2.21.2(transitive)
- Removed@liff/logger@2.21.2(transitive)
- Removed@liff/server-api@2.21.2(transitive)
- Removed@liff/store@2.21.2(transitive)
- Removed@liff/types@2.21.2(transitive)
- Removed@liff/use@2.21.2(transitive)
- Removed@liff/util@2.21.2(transitive)
Updated@liff/consts@2.21.3
Updated@liff/get-profile@2.21.3
Updated@liff/get-version@2.21.3
Updated@liff/is-logged-in@2.21.3
Updated@liff/logger@2.21.3
Updated@liff/store@2.21.3
Updated@liff/types@2.21.3
Updated@liff/use@2.21.3
Updated@liff/util@2.21.3