@wxobs/miniprogram-helper
Advanced tools
Comparing version 0.5.3 to 0.5.4
@@ -45,6 +45,6 @@ declare enum PxStatus { | ||
export declare function setAttrs(attrs: Record<string, string>): Promise<void>; | ||
export declare function event(eventName: string, eventProperties?: Record<string, string | number>): boolean; | ||
export declare function setCustomId(uid: string): boolean; | ||
export declare function setCustomProperties(props: Record<string, string | number>): boolean; | ||
export declare function getStatus(): PxStatus; | ||
export declare const event: (name: string, props: Record<string, string | number>) => boolean; | ||
export declare const setCustomId: (uid: string) => boolean; | ||
export declare const setCustomProperties: (props: Record<string, string | number>) => boolean; | ||
export declare function getStatus(): PxStatus | undefined; | ||
export declare function getFeatureFlags(options: IGetFeatureFlagsOptions): Promise<Record<string, IFeatureFlagInfo>>; | ||
@@ -54,5 +54,5 @@ export declare function getFeatureFlagsSync(): Record<string, IFeatureFlagInfo>; | ||
setup: typeof setup; | ||
event: typeof event; | ||
setCustomId: typeof setCustomId; | ||
setCustomProperties: typeof setCustomProperties; | ||
event: (name: string, props: Record<string, string | number>) => boolean; | ||
setCustomId: (uid: string) => boolean; | ||
setCustomProperties: (props: Record<string, string | number>) => boolean; | ||
teardown: typeof teardown; | ||
@@ -59,0 +59,0 @@ setAttrs: typeof setAttrs; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t,o=function(){return o=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},o.apply(this,arguments)};function n(e,t,o,n){return new(o||(o=Promise))((function(r,i){function s(e){try{l(n.next(e))}catch(e){i(e)}}function u(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(s,u)}l((n=n.apply(e,t||[])).next())}))}function r(e,t){var o,n,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(l){return function(u){if(o)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(s=0)),s;)try{if(o=1,n&&(r=2&u[0]?n.return:u[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,u[1])).done)return r;switch(n=0,r&&(u=[2&u[0],r.value]),u[0]){case 0:case 1:r=u;break;case 4:return s.label++,{value:u[1],done:!1};case 5:s.label++,n=u[1],u=[0];continue;case 7:u=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==u[0]&&2!==u[0])){s=0;continue}if(3===u[0]&&(!r||u[1]>r[0]&&u[1]<r[3])){s.label=u[1];break}if(6===u[0]&&s.label<r[1]){s.label=r[1],r=u;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(u);break}r[2]&&s.ops.pop(),s.trys.pop();continue}u=t.call(e,s)}catch(e){u=[6,e],n=0}finally{o=r=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,l])}}}!function(e){e.NotSetup="NotSetup",e.SettingUp="SettingUp",e.WaitingForFirstReport="WaitingForFirstReport",e.Collecting="Collecting",e.TearingDown="TearingDown"}(e||(e={})),function(e){e[e.BOOLEAN=1]="BOOLEAN",e[e.STRING=2]="STRING",e[e.NUMBER=3]="NUMBER",e[e.JSON=4]="JSON"}(t||(t={}));var i,s=new Promise((function(t){var o=setInterval((function(){var n,r;if(void 0===(null===(r=null===(n=wx.cloud)||void 0===n?void 0:n.obs)||void 0===r?void 0:r.getStatus))return t(!0),void clearInterval(o);g()===e.Collecting&&(clearInterval(o),t(!0))}),100)}));function u(e){var t;return n(this,void 0,void 0,(function(){var o,n;return r(this,(function(r){switch(r.label){case 0:return void 0===(null===(t=null===wx||void 0===wx?void 0:wx.cloud)||void 0===t?void 0:t.obs)?[2,{errMsg:"function setup is not supported in this version, please upgrade your wxapplib version\n[体验分析]当前基础库版本过低,不支持体验分析,请升级基础库版本到 2.24.4 或以上"}]:(o=!0,void 0!==(null==e?void 0:e.isWhitelistMaskMode)?o=e.isWhitelistMaskMode:(null==e?void 0:e.maskMode)&&(o="all-mask"===e.maskMode),w(),wx.cloud.obs.asyncSetup?[2,wx.cloud.obs.asyncSetup(Object.assign(e||{},{projectId:null===__wxConfig||void 0===__wxConfig?void 0:__wxConfig.accountInfo.appId,isWhitelistMaskMode:o,newSessionCallback:function(t){var o;null===(o=null==e?void 0:e.newSessionCallback)||void 0===o||o.call(e,t),w()}}))]:[3,1]);case 1:return n=wx.cloud.obs.setup(Object.assign(e||{},{projectId:null===__wxConfig||void 0===__wxConfig?void 0:__wxConfig.accountInfo.appId,isWhitelistMaskMode:o})),[4,new Promise((function(e){return setTimeout(e,1e3)}))];case 2:return r.sent(),[2,n?{sessionId:n}:{errMsg:"setup failed"}]}}))}))}function l(){var t,o;return n(this,void 0,void 0,(function(){return r(this,(function(n){switch(n.label){case 0:if(void 0===(null===(o=null===(t=null===wx||void 0===wx?void 0:wx.cloud)||void 0===t?void 0:t.obs)||void 0===o?void 0:o.teardown))throw new Error("[wxobs]function teardown is not supported in this version, please upgrade your wxapplib version\n[体验分析]当前基础库版本过低,不支持 teardown 函数");return[4,wx.cloud.obs.teardown()];case 1:return n.sent(),s=new Promise((function(t){var o=setInterval((function(){var n,r;if(void 0===(null===(r=null===(n=wx.cloud)||void 0===n?void 0:n.obs)||void 0===r?void 0:r.getStatus))return t(!0),void clearInterval(o);g()===e.Collecting&&(clearInterval(o),t(!0))}),100)})),[2]}}))}))}function a(e){var t,o;return n(this,void 0,void 0,(function(){return r(this,(function(n){switch(n.label){case 0:return[4,s];case 1:return n.sent(),void 0===(null===(o=null===(t=null===wx||void 0===wx?void 0:wx.cloud)||void 0===t?void 0:t.obs)||void 0===o?void 0:o.setAttrs)?(console.error("[wxobs]function setAttrs is not supported in this version, please upgrade your wxapplib version\n[体验分析]当前基础库版本过低,不支持 setAttrs 函数"),[2]):(wx.cloud.obs.setAttrs(e),[2])}}))}))}function c(e){var t,o;return n(this,void 0,void 0,(function(){return r(this,(function(n){switch(n.label){case 0:return[4,s];case 1:return n.sent(),void 0===(null===(o=null===(t=null===wx||void 0===wx?void 0:wx.cloud)||void 0===t?void 0:t.obs)||void 0===o?void 0:o.emitEvent)?(console.error("[wxobs]function emitEvent is not supported in this version, please upgrade your wxapplib version\n[体验分析]当前基础库版本过低,不支持 emitEvent 函数"),[2]):(wx.cloud.obs.emitEvent(e),[2])}}))}))}function v(e,t,o){var n="[wxobs] ".concat(e," 调用错误,");try{if("object"==typeof t&&null!==t){var r=Boolean(t.__cos_only__),i=Object.keys(t);if(r||i.length<=10){for(var s=0;s<i.length;s++){if(i[s].length>50&&!i[s].includes(","))return console.error("".concat(n).concat(i[s]," 属性key过长,需<=50,且不包含','")),!1;var u=t[i[s]];if("string"==typeof u){if(!r&&(u.length>255||u.includes(",")))return console.error("".concat(n).concat(i[s]," 属性 value 不符合规则,长度不能超过 255 且不能包含英文逗号(,),如需包含请先转义")),!1;o["wxobs_props_".concat(i[s],"_string")]=u}else{if(!Number.isSafeInteger(u))return console.error("".concat(n).concat(i[s],"属性value不符合规则")),!1;o["wxobs_props_".concat(i[s],"_int")]="".concat(u)}}return r&&(o.__cos_only__="1"),!0}console.error("".concat(n," 需要少于 10 个属性"))}else console.error("".concat(n," 需要为 Object"))}catch(e){console.error(n,e)}return!1}function d(e,t){if(void 0===t&&(t={}),wx.obs&&_(wx.version.version,"3.4.8")>=0)return wx.obs.event(e,t);var n={};if(v("event",t,n)){if("string"==typeof e&&e.length<=50&&!e.includes(","))return c(o({wxobs_type:"__userob_default_custom_event_emit__",wxobs_primary_event_name:e},n)),!0;console.error("体验分析helper.event调用错误,eventName需要少于50个字符")}return!1}function f(e){return"string"==typeof e&&e.length<=80&&!e.includes(",")?(c({wxobs_type:"__userob_default_custom_id_set__",wxobs_primary_uid:e}),i=e,wx.setStorage({key:"wxobs_cache_uid",data:e}),!0):(console.error("setCustomId调用错误,自定义id必须为字符串且少于80个字符, 当前输入为'".concat(e,"'")),!1)}function p(e){if(!i)return console.error("未setId。无法setProperties"),!1;var t={};return!!v("setCustomProperties",e,t)&&(c(o({wxobs_type:"__userob_default_custom_props_set__",wxobs_primary_uid:i},t)),!0)}function w(){try{var e=wx.getStorageSync("wxobs_cache_uid");e&&f(e)}catch(e){}}function g(){var t,o,n,r,i;return void 0===(null===(o=null===(t=null===wx||void 0===wx?void 0:wx.cloud)||void 0===t?void 0:t.obs)||void 0===o?void 0:o.getStatus)?e.NotSetup:null===(i=null===(r=null===(n=null===wx||void 0===wx?void 0:wx.cloud)||void 0===n?void 0:n.obs)||void 0===r?void 0:r.getStatus)||void 0===i?void 0:i.call(r)}function x(e){return n(this,void 0,void 0,(function(){var n;return r(this,(function(r){switch(r.label){case 0:return wx.obs||console.error("[wxobs] getFeatureFlags is not supported in this version, please upgrade your wxapplib version\n[体验分析]当前基础库版本过低,不支持 getFeatureFlags 函数"),[4,wx.obs.getFeatureFlags(e)];case 1:return n=r.sent(),_(wx.version.version,"3.4.7")<0&&setTimeout((function(){!function(e,n){var r,i,s={};try{for(var u=function(e){var t="function"==typeof Symbol&&Symbol.iterator,o=t&&e[t],n=0;if(o)return o.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e),l=u.next();!l.done;l=u.next()){var a=l.value;if(n[a]){var v="flag_value_".concat(a);n[a].type===t.JSON?s[v]=h(JSON.stringify(n[a].value)):n[a].type===t.STRING?s[v]=h(n[a].value+""):n[a].type===t.NUMBER||n[a].type===t.BOOLEAN?s[v]="".concat(n[a].value):(console.warn("体验分析helper: 收到未知类型的 flag(key ".concat(a,",类型 ").concat(n[a].type,"),将当做 string 处理,请检查是否需要更新 SDK 版本,或反馈官方支持")),s[v]=h(n[a].value+""))}else s["flag_empty_".concat(a)]="1"}}catch(e){r={error:e}}finally{try{l&&!l.done&&(i=u.return)&&i.call(u)}finally{if(r)throw r.error}}c(o({wxobs_type:"feature_flags_received"},s))}(e.flags,n)}),0),[2,n]}}))}))}function b(){return wx.obs||console.error("[wxobs] getFeatureFlagsSync is not supported in this version, please upgrade your wxapplib version\n[体验分析]当前基础库版本过低,不支持 getFeatureFlagsSync 函数"),wx.obs.getFeatureFlagsSync()}function _(e,t){if("string"!=typeof e||"string"!=typeof t)return 0;for(var o=e.split("."),n=t.split("."),r=Math.max(o.length,n.length);o.length<r;)o.push("0");for(;n.length<r;)n.push("0");for(var i=0;i<r;i++){var s=parseInt(o[i],10),u=parseInt(n[i],10);if(s>u)return 1;if(s<u)return-1}return 0}function h(e){for(var t=e.length,o=5381,n=0;n<t;++n)o=(o<<5)+o+e.charCodeAt(n);return String(o)}var y={setup:u,event:d,setCustomId:f,setCustomProperties:p,teardown:l,setAttrs:a,getStatus:g,getFeatureFlags:x,getFeatureFlagsSync:b};exports.default=y,exports.event=d,exports.getFeatureFlags=x,exports.getFeatureFlagsSync=b,exports.getStatus=g,exports.setAttrs=a,exports.setCustomId=f,exports.setCustomProperties=p,exports.setup=u,exports.teardown=l; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t,o,n,r,i,s,u,l=function(){return l=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},l.apply(this,arguments)};function a(e,t,o,n){return new(o||(o=Promise))((function(r,i){function s(e){try{l(n.next(e))}catch(e){i(e)}}function u(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(s,u)}l((n=n.apply(e,t||[])).next())}))}function c(e,t){var o,n,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(l){return function(u){if(o)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(s=0)),s;)try{if(o=1,n&&(r=2&u[0]?n.return:u[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,u[1])).done)return r;switch(n=0,r&&(u=[2&u[0],r.value]),u[0]){case 0:case 1:r=u;break;case 4:return s.label++,{value:u[1],done:!1};case 5:s.label++,n=u[1],u=[0];continue;case 7:u=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==u[0]&&2!==u[0])){s=0;continue}if(3===u[0]&&(!r||u[1]>r[0]&&u[1]<r[3])){s.label=u[1];break}if(6===u[0]&&s.label<r[1]){s.label=r[1],r=u;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(u);break}r[2]&&s.ops.pop(),s.trys.pop();continue}u=t.call(e,s)}catch(e){u=[6,e],n=0}finally{o=r=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,l])}}}!function(e){e.NotSetup="NotSetup",e.SettingUp="SettingUp",e.WaitingForFirstReport="WaitingForFirstReport",e.Collecting="Collecting",e.TearingDown="TearingDown"}(s||(s={})),function(e){e[e.BOOLEAN=1]="BOOLEAN",e[e.STRING=2]="STRING",e[e.NUMBER=3]="NUMBER",e[e.JSON=4]="JSON"}(u||(u={}));var v,d=new Promise((function(e){var t=setInterval((function(){var o,n;if(void 0===(null===(n=null===(o=wx.cloud)||void 0===o?void 0:o.obs)||void 0===n?void 0:n.getStatus))return e(!0),void clearInterval(t);m()===s.Collecting&&(clearInterval(t),e(!0))}),100)}));function p(e){var t;return a(this,void 0,void 0,(function(){var o,n;return c(this,(function(r){switch(r.label){case 0:return void 0===(null===(t=null===wx||void 0===wx?void 0:wx.cloud)||void 0===t?void 0:t.obs)?[2,{errMsg:"function setup is not supported in this version, please upgrade your wxapplib version\n[体验分析]当前基础库版本过低,不支持体验分析,请升级基础库版本到 2.24.4 或以上"}]:(o=!0,void 0!==(null==e?void 0:e.isWhitelistMaskMode)?o=e.isWhitelistMaskMode:(null==e?void 0:e.maskMode)&&(o="all-mask"===e.maskMode),y(),wx.cloud.obs.asyncSetup?[2,wx.cloud.obs.asyncSetup(Object.assign(e||{},{projectId:null===__wxConfig||void 0===__wxConfig?void 0:__wxConfig.accountInfo.appId,isWhitelistMaskMode:o,newSessionCallback:function(t){var o;null===(o=null==e?void 0:e.newSessionCallback)||void 0===o||o.call(e,t),y()}}))]:[3,1]);case 1:return n=wx.cloud.obs.setup(Object.assign(e||{},{projectId:null===__wxConfig||void 0===__wxConfig?void 0:__wxConfig.accountInfo.appId,isWhitelistMaskMode:o})),[4,new Promise((function(e){return setTimeout(e,1e3)}))];case 2:return r.sent(),[2,n?{sessionId:n}:{errMsg:"setup failed"}]}}))}))}function f(){var e,t;return a(this,void 0,void 0,(function(){return c(this,(function(o){switch(o.label){case 0:if(void 0===(null===(t=null===(e=null===wx||void 0===wx?void 0:wx.cloud)||void 0===e?void 0:e.obs)||void 0===t?void 0:t.teardown))throw new Error("[wxobs]function teardown is not supported in this version, please upgrade your wxapplib version\n[体验分析]当前基础库版本过低,不支持 teardown 函数");return[4,wx.cloud.obs.teardown()];case 1:return o.sent(),d=new Promise((function(e){var t=setInterval((function(){var o,n;if(void 0===(null===(n=null===(o=wx.cloud)||void 0===o?void 0:o.obs)||void 0===n?void 0:n.getStatus))return e(!0),void clearInterval(t);m()===s.Collecting&&(clearInterval(t),e(!0))}),100)})),[2]}}))}))}function w(e){var t,o;return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,d];case 1:return n.sent(),void 0===(null===(o=null===(t=null===wx||void 0===wx?void 0:wx.cloud)||void 0===t?void 0:t.obs)||void 0===o?void 0:o.setAttrs)?(console.error("[wxobs]function setAttrs is not supported in this version, please upgrade your wxapplib version\n[体验分析]当前基础库版本过低,不支持 setAttrs 函数"),[2]):(wx.cloud.obs.setAttrs(e),[2])}}))}))}function g(e){var t,o;return a(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,d];case 1:return n.sent(),void 0===(null===(o=null===(t=null===wx||void 0===wx?void 0:wx.cloud)||void 0===t?void 0:t.obs)||void 0===o?void 0:o.emitEvent)?(console.error("[wxobs]function emitEvent is not supported in this version, please upgrade your wxapplib version\n[体验分析]当前基础库版本过低,不支持 emitEvent 函数"),[2]):(wx.cloud.obs.emitEvent(e),[2])}}))}))}function x(e,t,o){var n="[wxobs] ".concat(e," 调用错误,");try{if("object"==typeof t&&null!==t){var r=Boolean(t.__cos_only__),i=Object.keys(t);if(r||i.length<=10){for(var s=0;s<i.length;s++){if(i[s].length>50&&!i[s].includes(","))return console.error("".concat(n).concat(i[s]," 属性key过长,需<=50,且不包含','")),!1;var u=t[i[s]];if("string"==typeof u){if(!r&&(u.length>255||u.includes(",")))return console.error("".concat(n).concat(i[s]," 属性 value 不符合规则,长度不能超过 255 且不能包含英文逗号(,),如需包含请先转义")),!1;o["wxobs_props_".concat(i[s],"_string")]=u}else{if(!Number.isSafeInteger(u))return console.error("".concat(n).concat(i[s],"属性value不符合规则")),!1;o["wxobs_props_".concat(i[s],"_int")]="".concat(u)}}return r&&(o.__cos_only__="1"),!0}console.error("".concat(n," 需要少于 10 个属性"))}else console.error("".concat(n," 需要为 Object"))}catch(e){console.error(n,e)}return!1}var b=null!==(t=null===(e=wx.obs)||void 0===e?void 0:e.event)&&void 0!==t?t:function(e,t){if(void 0===t&&(t={}),wx.obs&&I(wx.version.version,"3.4.8")>=0)return wx.obs.event(e,t);var o={};if(x("event",t,o)){if("string"==typeof e&&e.length<=50&&!e.includes(","))return g(l({wxobs_type:"__userob_default_custom_event_emit__",wxobs_primary_event_name:e},o)),!0;console.error("体验分析helper.event调用错误,eventName需要少于50个字符")}return!1},_=null!==(n=null===(o=wx.obs)||void 0===o?void 0:o.setCustomId)&&void 0!==n?n:function(e){return"string"==typeof e&&e.length<=80&&!e.includes(",")?(g({wxobs_type:"__userob_default_custom_id_set__",wxobs_primary_uid:e}),v=e,wx.setStorage({key:"wxobs_cache_uid",data:e}),!0):(console.error("setCustomId调用错误,自定义id必须为字符串且少于80个字符, 当前输入为'".concat(e,"'")),!1)},h=null!==(i=null===(r=wx.obs)||void 0===r?void 0:r.setCustomProperties)&&void 0!==i?i:function(e){if(!v)return console.error("未setId。无法setProperties"),!1;var t={};return!!x("setCustomProperties",e,t)&&(g(l({wxobs_type:"__userob_default_custom_props_set__",wxobs_primary_uid:v},t)),!0)};function y(){try{var e=wx.getStorageSync("wxobs_cache_uid");e&&_(e)}catch(e){}}function m(){var e,t,o,n,r,i;return void 0!==(null===(t=null===(e=null===wx||void 0===wx?void 0:wx.cloud)||void 0===e?void 0:e.obs)||void 0===t?void 0:t.getStatus)||(null===(o=wx.obs)||void 0===o?void 0:o.getStatus)?null===(i=null===(r=null===(n=null===wx||void 0===wx?void 0:wx.cloud)||void 0===n?void 0:n.obs)||void 0===r?void 0:r.getStatus)||void 0===i?void 0:i.call(r):s.NotSetup}function S(e){return a(this,void 0,void 0,(function(){var t;return c(this,(function(o){switch(o.label){case 0:return wx.obs||console.error("[wxobs] getFeatureFlags is not supported in this version, please upgrade your wxapplib version\n[体验分析]当前基础库版本过低,不支持 getFeatureFlags 函数"),[4,wx.obs.getFeatureFlags(e)];case 1:return t=o.sent(),I(wx.version.version,"3.4.7")<0&&setTimeout((function(){!function(e,t){var o,n,r={};try{for(var i=function(e){var t="function"==typeof Symbol&&Symbol.iterator,o=t&&e[t],n=0;if(o)return o.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e),s=i.next();!s.done;s=i.next()){var a=s.value;if(t[a]){var c="flag_value_".concat(a);t[a].type===u.JSON?r[c]=C(JSON.stringify(t[a].value)):t[a].type===u.STRING?r[c]=C(t[a].value+""):t[a].type===u.NUMBER||t[a].type===u.BOOLEAN?r[c]="".concat(t[a].value):(console.warn("体验分析helper: 收到未知类型的 flag(key ".concat(a,",类型 ").concat(t[a].type,"),将当做 string 处理,请检查是否需要更新 SDK 版本,或反馈官方支持")),r[c]=C(t[a].value+""))}else r["flag_empty_".concat(a)]="1"}}catch(e){o={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}g(l({wxobs_type:"feature_flags_received"},r))}(e.flags,t)}),0),[2,t]}}))}))}function F(){return wx.obs||console.error("[wxobs] getFeatureFlagsSync is not supported in this version, please upgrade your wxapplib version\n[体验分析]当前基础库版本过低,不支持 getFeatureFlagsSync 函数"),wx.obs.getFeatureFlagsSync()}function I(e,t){if("string"!=typeof e||"string"!=typeof t)return 0;for(var o=e.split("."),n=t.split("."),r=Math.max(o.length,n.length);o.length<r;)o.push("0");for(;n.length<r;)n.push("0");for(var i=0;i<r;i++){var s=parseInt(o[i],10),u=parseInt(n[i],10);if(s>u)return 1;if(s<u)return-1}return 0}function C(e){for(var t=e.length,o=5381,n=0;n<t;++n)o=(o<<5)+o+e.charCodeAt(n);return String(o)}var O={setup:p,event:b,setCustomId:_,setCustomProperties:h,teardown:f,setAttrs:w,getStatus:m,getFeatureFlags:S,getFeatureFlagsSync:F};exports.default=O,exports.event=b,exports.getFeatureFlags=S,exports.getFeatureFlagsSync=F,exports.getStatus=m,exports.setAttrs=w,exports.setCustomId=_,exports.setCustomProperties=h,exports.setup=p,exports.teardown=f; |
{ | ||
"name": "@wxobs/miniprogram-helper", | ||
"version": "0.5.3", | ||
"version": "0.5.4", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
13264
101