diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1ca8390..59751ae 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,15 @@
+## 0.15.6(2022-5-20)
+1. 修复
+ - 修复特定情形下控制台打印错误日志的问题
+
+## 0.15.5(2022-5-6)
+1. 新增
+ - 新增 `$referrer` 和 `$url_query` 属性采集
+
+## 0.15.4(2022-1-7)
+1. 新增
+ - 新增预置事件增加 `$url` 属性获取完整路径
+
## 0.15.3(2021-11-30)
1. 修复
- 修复百度开发者工具升级后加载 `SDK` 报错的问题
diff --git a/LICENSE b/LICENSE
index d541085..0d8fbcb 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,202 +1,28 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "{}"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright 2015-2020 Sensors Data Inc.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
+软件名称:神策分析 SDK
+版本号:所有版本
+许可协议版本:1.0
+
+1. 商业许可协议(用于商业用途需购买许可)
+任何商业用途必须获得商业许可。
+
+商业许可协议条款:
+
+- 商业用途:任何直接或间接产生收入的用途都需要购买商业许可。
+- 付款条款:在使用本软件用于商业用途之前,您必须支付全额许可费用。具体的付款方式将在双方联系后提供。
+- 商业支持:购买商业许可后,您将获得一年的技术支持和软件更新服务。
+- 禁止再许可:商业用户不得再许可、转售或转让本软件。每份商业许可仅适用于单一实体或公司。
+- 源代码访问:购买商业许可的用户将获得本软件的代码访问权限,并可根据业务需求进行内部修改。但不得公开发布或再分发修改后的版本。
+- 使用范围限制:商业许可仅限于购买者的内部使用,不得与第三方共享或用于为第三方提供服务。任何超出许可范围的使用行为均需额外授权,并可能产生额外费用。
+- 联系信息:如需购买商业许可,请联系 dv@sensorsdata.com。
+- 知识产权声明:本软件的版权归神策网络科技(北京)有限公司所有。购买商业许可仅授予您使用权,所有权仍归属本公司。
+- 终止条款: 如果您未支付相关费用或违反本协议的任何条款,商业许可将自动终止。您必须立即停止所有商业用途,并销毁或删除所有软件副本。
+
+2. 附加授权规则条款
+授权规则条款:
+
+- 功能限制:未经本软件作者的明确书面许可,您不得移除、绕过或规避本软件中的任何功能限制或试用限制。
+- 商标使用:未经授权,您不得在宣传、市场推广或销售产品时使用本软件的名称、商标或品牌标识。任何商标使用必须得到明确的书面许可。
+- 修改条款:本协议的条款可能会不时更新,用户有责任定期检查最新版本。任何重大更改将通过项目主页或电子邮件通知用户。
+
+3. 联系方式
+如需更多信息或申请商业许可,请联系 dv@sensorsdata.com。
diff --git a/README.md b/README.md
index 049eeca..f64636c 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,4 @@
-[](https://www.sensorsdata.cn/)
-
+
[](https://github.com/sensorsdata/sa-sdk-smartprogram/blob/master/LICENSE)
[](https://github.com/sensorsdata/sa-sdk-smartprogram/releases)
@@ -10,6 +9,15 @@
[**神策数据**](https://www.sensorsdata.cn/)
(Sensors Data),隶属于神策网络科技(北京)有限公司,是一家专业的大数据分析服务公司,大数据分析行业开拓者,为客户提供深度用户行为分析平台、以及专业的咨询服务和行业解决方案,致力于帮助客户实现数据驱动。神策数据立足大数据及用户行为分析的技术与实践前沿,业务现已覆盖以互联网、金融、零售快消、高科技、制造等为代表的十多个主要行业、并可支持企业多个职能部门。公司总部在北京,并在上海、深圳、合肥、武汉等地拥有本地化的服务团队,覆盖东区及南区市场;公司拥有专业的服务团队,为客户提供一对一的客户服务。公司在大数据领域积累的核心关键技术,包括在海量数据采集、存储、清洗、分析挖掘、可视化、智能应用、安全与隐私保护等领域。 [**More**](https://www.sensorsdata.cn/about/aboutus.html)
+## 神策埋点 SDK 官网
+如需了解神策埋点 SDK 的更多商业授权信息,请访问[神策埋点 SDK 官网](https://jssdk.debugbox.sensorsdata.cn/)获取更多详细信息。
+
+## 联系我们
+若您有商业合作或产品集成需求,请通过下面的渠道联系我们获取专业服务与支持。
+
+| 加微信号:skycode008,或扫码添加联系人
| 扫码关注「神策埋点 SDK」公众号  |
+| ------ | ------ |
+
## 使用方法
使用方法请参考文档 https://www.sensorsdata.cn/manual/smartprogram_sdk.html
@@ -24,37 +32,13 @@
招聘小程序 SDK 开发工程师,小程序 SDK 技术顾问,简历发送到邮箱 (shengyonggen@sensorsdata.cn)
详情可访问官网https://www.sensorsdata.cn/about/joinus.html
-## 讨论
-
-| 扫码加入神策数据开源社区 QQ 群
群号:785122381 | 扫码加入神策数据开源社区微信群 |
-| ------ | ------ |
-| |  |
-
-## 公众号
-
-| 扫码关注
神策数据开源社区 | 扫码关注
神策数据开源社区服务号 |
-| ------ | ------ |
-| |  |
-
## 新书推荐
-| 《数据驱动:从方法到实践》 | 《Android 全埋点解决方案》 | 《iOS 全埋点解决方案》
+| [《数据驱动:从方法到实践》](https://item.jd.com/12322322.html) | [《Android 全埋点解决方案》](https://item.jd.com/12574672.html) | [《iOS 全埋点解决方案》](https://item.jd.com/12867068.html)
| ------ | ------ | ------ |
-| [](https://item.jd.com/12322322.html) | [](https://item.jd.com/12574672.html) | [](https://item.jd.com/12867068.html)
-## License
-Copyright 2015-2020 Sensors Data Inc.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
+## License
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
+[License 协议](https://github.com/sensorsdata/sa-sdk-smartprogram/blob/master/LICENSE)
diff --git a/package.json b/package.json
index acebac1..f582466 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "sa-sdk-smartprogram",
- "version": "0.15.3",
+ "version": "0.15.6",
"description": "神策百度小程序SDK",
"main": "sensorsdata.min.js",
"scripts": {
diff --git a/sensorsdata.autotrack.min.js b/sensorsdata.autotrack.min.js
index 7416f56..58370fb 100644
--- a/sensorsdata.autotrack.min.js
+++ b/sensorsdata.autotrack.min.js
@@ -1 +1 @@
-"use strict";var sdmp=Object.assign({},swan),sdmp_info={storageName:"sensorsdata2015_baidu",lib_name:"SmartProgram",lib_method:"code",select_utm:!0,data_is_store:"sensors_prepare_data"};sdmp.sdmp_request=swan.request,sdmp.sdmp_getSystemInfo=swan.getSystemInfo,sdmp.sdmp_getNetworkType=swan.getNetworkType,sdmp.sdmp_getStorageSync=swan.getStorageSync,sdmp.sdmp_setStorageSync=swan.setStorageSync,sdmp.sdmp_getAppId=swan.getEnvInfoSync,sdmp.sdmp_getStorage=swan.getStorage;const sa={lib_version:"0.15.3",is_first_launch:!1,_queue:[],getSystemInfoComplete:!1,para:{name:"sensors",server_url:"",max_string_length:500,autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,mpClick:!0},show_log:!1,batch_send:!0},log:function(){if(sa.para.show_log)try{return console.log.apply(console,arguments)}catch(t){console.log(arguments[0])}}},_={};var ArrayProto=Array.prototype,ObjProto=Object.prototype,slice=ArrayProto.slice,toString=ObjProto.toString,hasOwnProperty=ObjProto.hasOwnProperty,nativeForEach=ArrayProto.forEach,nativeIndexOf=ArrayProto.indexOf,nativeIsArray=Array.isArray,breaker={},each=_.each=function(t,e,a){if(null==t)return!1;if(nativeForEach&&t.forEach===nativeForEach)t.forEach(e,a);else if(t.length===+t.length){for(var r=0,s=t.length;r127&&i<2048?String.fromCharCode(i>>6|192,63&i|128):String.fromCharCode(i>>12|224,i>>6&63|128,63&i|128),null!==o&&(a>e&&(n+=t.substring(e,a)),n+=o,e=a=s+1)}return a>e&&(n+=t.substring(e,t.length)),n},_.base64Encode=function(t){var e,a,r,s,n,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,c=0,p="",u=[];if(!t)return t;t=_.utf8Encode(t);do{e=(n=t.charCodeAt(o++)<<16|t.charCodeAt(o++)<<8|t.charCodeAt(o++))>>18&63,a=n>>12&63,r=n>>6&63,s=63&n,u[c++]=i.charAt(e)+i.charAt(a)+i.charAt(r)+i.charAt(s)}while(osa.para.max_string_length?(sa.log("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+t),t.slice(0,sa.para.max_string_length)):t},_.getAppId=function(){var t;if(sdmp.sdmp_getAppId&&(t=sdmp.sdmp_getAppId()),_.isObject(t))return t.appKey},_.setUpperCase=function(t){return _.isString(t)?t.toLocaleUpperCase():t},_.info={currentProps:{},properties:{$lib:sdmp_info.lib_name,$lib_version:String(sa.lib_version)},getSystem:function(){var t=this.properties,e=!0;function a(){e&&(e=!0,sdmp.sdmp_getSystemInfo({success:function(e){t.$model=e.model,t.$screen_width=Number(e.screenWidth),t.$screen_height=Number(e.screenHeight),t.$os=function(t){try{var e=t.toLowerCase();return"ios"===e?"iOS":"android"===e?"Android":t}catch(t){sa.log(t)}}(e.platform),t.$os_version=e.system.indexOf(" ")>-1?e.system.split(" ")[1]:e.system,t.$brand=_.setUpperCase(e.brand),t.$manufacturer=e.brand},complete:function(){var e=_.getAppId(),a=(new Date).getTimezoneOffset();e&&(t.$app_id=e),_.isNumber(a)&&(t.$timezone_offset=a),sa.getSystemInfoComplete=!0,sa.checkIsComplete()}}))}sdmp.sdmp_getNetworkType({success:function(e){t.$network_type=_.setUpperCase(e.networkType),a()},complete:function(){a()}})},setStatusComplete:function(){if(sa.getSystemInfoComplete)return!1;sa.getSystemInfoComplete=!0,sa._queue.length>0&&(_.each(sa._queue,function(t){sa.prepareData.apply(sa,Array.prototype.slice.call(t))}),sa._queue=[])}},_.getIsFirstDay=function(){return"object"==typeof sa.store._state&&"number"==typeof sa.store._state.first_visit_day_time&&sa.store._state.first_visit_day_time>(new Date).getTime()};let store={getUUID:function(){return Date.now()+"-"+Math.floor(1e7*Math.random())+"-"+Math.random().toString(16).replace(".","")+"-"+String(31242*Math.random()).replace(".","").slice(0,8)},setStorage:function(){},getStorage:function(){return sdmp.sdmp_getStorageSync(sdmp_info.storageName)||""},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(t){this.mdata.push(t)},clear:function(t){this.mdata.splice(0,t)}},toState:function(t){"object"==typeof t&&t.distinct_id?this._state=t:this.set("distinct_id",this.getUUID())},getFirstId:function(){return this._state.first_id},getDistinctId:function(){return this._state.distinct_id},getProps:function(){return this._state.props||{}},setProps:function(t,e){var a=this._state.props||{};e?this.set("props",t):(_.extend(a,t),this.set("props",a))},set:function(t,e){var a={};for(var r in"string"==typeof t?a[t]=e:"object"==typeof t&&(a=t),this._state=this._state||{},a)this._state[r]=a[r];this.save()},change:function(t,e){this._state[t]=e},save:function(){sdmp.sdmp_setStorageSync(sdmp_info.storageName,this._state)},init:function(){var t=this.getStorage();if(t)this.toState(t);else{sa.is_first_launch=!0;var e=new Date,a=e.getTime();e.setHours(23),e.setMinutes(59),e.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:a,first_visit_day_time:e.getTime()})}}};sa.store=store;class SendStrategy{constructor(){this.dataHasSend=!0,this.syncStorage=!1,this.is_first_batch_write=!0,this.failTime=0}init(){var t=this;sdmp.sdmp_getStorage({key:sdmp_info.data_is_store,complete:function(e){var a=e.data&&_.isArray(e.data)?e.data:[];sa.store.mem.mdata=a.concat(sa.store.mem.mdata),t.syncStorage=!0}}),this.batchInterval()}onAppHide(){sa.para.batch_send&&this.batchSend()}send(t){if(!sa.para.server_url)return!1;this.dataHasChange=!0,sa.store.mem.getLength()>=500&&(sa.log("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),sa.store.mem.mdata.shift()),sa.log(t),sa.store.mem.add(t),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()}batchWrite(){var t=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){t.batchSend()},1e3)),this.syncStorage&&(sdmp.sdmp_setStorageSync(sdmp_info.data_is_store,sa.store.mem.mdata),this.dataHasChange=!1))}batchInterval(){var t=this;!function e(){setTimeout(function(){t.batchSend(),e()},sa.para.batch_send.send_timeout*Math.pow(2,t.failTime))}(),function e(){setTimeout(function(){t.batchWrite(),e()},500)}()}batchSend(){if(this.dataHasSend){var t,e,a=this,r=sa.store.mem.mdata;if(t=r.length>=100?r.slice(0,100):r,e=t.length,_.isArray(t)&&t.length>0){this.dataHasSend=!1;var s=Date.now();t.forEach(function(t){t._flush_time=s}),t=JSON.stringify(t),t="data_list="+encodeURIComponent(_.base64Encode(t)),sdmp.sdmp_request({url:sa.para.server_url,method:"POST",data:t,dataType:"text",success:function(t){a.batchRemove(e)},fail:function(t){a.sendFail()}})}}}batchRemove(t){this.dataHasSend=!0,this.dataHasChange=!0,sa.store.mem.clear(t),this.batchWrite(),this.failTime=0}sendFail(){this.dataHasSend=!0,this.failTime++}}var sendStrategy=new SendStrategy,mpshow_time=null;sa.setPara=function(t){if(sa.para=_.extend2Lev(sa.para,t),_.isObject(sa.para.register)&&_.extend(_.info.properties,sa.para.register),sa.para.name||(sa.para.name="sensors"),sa.para.server_url){var e={send_timeout:6e3,max_length:6};!0===sa.para.batch_send?sa.para.batch_send=_.extend({},e):_.isObject(sa.para.batch_send)?sa.para.batch_send=_.extend({},e,sa.para.batch_send):sa.para.batch_send=!1}else sa.log("\u8bf7\u4f7f\u7528 setPara() \u65b9\u6cd5\u8bbe\u7f6e server_url \u6570\u636e\u63a5\u6536\u5730\u5740,\u8be6\u60c5\u53ef\u67e5\u770bhttps://www.sensorsdata.cn/manual/mp_sdk_new.html#112-%E5%BC%95%E5%85%A5%E5%B9%B6%E9%85%8D%E7%BD%AE%E5%8F%82%E6%95%B0")},sa.getServerUrl=function(){return sa.para.server_url},sa.prepareData=function(t,e){if(!sa.isComplete)return sa._queue.push(arguments),!1;var a={distinct_id:this.store.getDistinctId(),lib:{$lib:sdmp_info.lib_name,$lib_method:sdmp_info.lib_method,$lib_version:String(sa.lib_version)},properties:{}};_.extend(a,t),_.isObject(t.properties)&&!_.isEmptyObject(t.properties)&&_.extend(a.properties,t.properties),t.type&&"profile"===t.type.slice(0,7)||(a._track_id=Number(String(Math.random()).slice(2,5)+String(Math.random()).slice(2,4)+String(Date.now()).slice(-4)),a.properties=_.extend({},_.info.properties,sa.store.getProps(),_.info.currentProps,a.properties),"object"==typeof sa.store._state&&"number"==typeof sa.store._state.first_visit_day_time&&sa.store._state.first_visit_day_time>(new Date).getTime()?a.properties.$is_first_day=!0:a.properties.$is_first_day=!1),a.properties.$time&&_.isDate(a.properties.$time)?(a.time=1*a.properties.$time,delete a.properties.$time):a.time=1*new Date,_.searchObjDate(a),_.searchObjString(a),sa.para.batch_send?sendStrategy.send(a):sa.send(a,e)},sa.setProfile=function(t,e){sa.prepareData({type:"profile_set",properties:t},e)},sa.setOnceProfile=function(t,e){sa.prepareData({type:"profile_set_once",properties:t},e)},sa.track=function(t,e,a){this.prepareData({type:"track",event:t,properties:e},a)},sa.identify=function(t,e){if("number"==typeof t)t=String(t);else if("string"!=typeof t)return!1;var a=sa.store.getFirstId();!0===e?a?sa.store.set("first_id",t):sa.store.set("distinct_id",t):a?sa.store.change("first_id",t):sa.store.change("distinct_id",t)},sa.trackSignup=function(t,e,a,r){sa.prepareData({original_id:sa.store.getFirstId()||sa.store.getDistinctId(),distinct_id:t,type:"track_signup",event:e,properties:a},r),sa.store.set("distinct_id",t)},sa.registerApp=function(t){_.isObject(t)&&!_.isEmptyObject(t)&&(_.info.currentProps=_.extend(_.info.currentProps,t))},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var t={};_.each(_.info.currentProps,function(e,a){0===a.indexOf("$")&&(t[a]=e)});var e=_.extend(t,{$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay()},_.info.properties);return delete e.$lib,e}return{}},sa.clearAppRegister=function(t){_.isArray(t)&&_.each(_.info.currentProps,function(e,a){_.include(t,a)&&delete _.info.currentProps[a]})},sa.appLaunch=function(t,e,a){e&&_.isObject(e)||(e={});var r={};t&&t.path&&(r.$url_path=_.getPath(t.path));var s=_.setUtm(t,r);sa.is_first_launch?(r.$is_first_time=!0,_.isEmptyObject(s.pre1)||sa.setOnceProfile(s.pre1)):r.$is_first_time=!1,_.isEmptyObject(s.pre2)||sa.registerApp(s.pre2);var n=_.getMPScene(t.scene);n&&(r.$scene=n,sa.registerApp({$latest_scene:r.$scene})),_.extend(r,e),(!a||sa.para.autoTrack&&sa.para.autoTrack.appLaunch)&&sa.track("$MPLaunch",r)},sa.appShow=function(t,e,a){e&&_.isObject(e)||(e={});var r={};mpshow_time=(new Date).getTime(),t&&t.path&&(r.$url_path=_.getPath(t.path));var s=_.setUtm(t,r);_.isEmptyObject(s.pre2)||sa.registerApp(s.pre2);var n=_.getMPScene(t.scene);n&&(r.$scene=n,sa.registerApp({$latest_scene:r.$scene})),_.extend(r,e),(!a||sa.para.autoTrack&&sa.para.autoTrack.appShow)&&sa.track("$MPShow",r)},sa.appHide=function(t,e){t&&_.isObject(t)||(t={});var a=(new Date).getTime(),r={};r.$url_path=_.getCurrentPath(),mpshow_time&&a-mpshow_time>0&&(a-mpshow_time)/36e5<24&&(r.event_duration=(a-mpshow_time)/1e3),_.extend(r,t),(!e||sa.para.autoTrack&&sa.para.autoTrack.appHide)&&sa.track("$MPHide",r),sendStrategy.onAppHide()},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.login=function(t){var e=sa.store.getFirstId(),a=sa.store.getDistinctId();t!==a&&(e?sa.trackSignup(t,"$SignUp"):(sa.store.set("first_id",a),sa.trackSignup(t,"$SignUp")))},sa.logout=function(t){var e=sa.store.getFirstId();e?(sa.store.set("first_id",""),!0===t?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",e)):sa.log("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25")},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state.first_id||sa.store._state.distinct_id;sa.log("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.checkIsComplete=function(){this.isComplete=!1,this.getSystemInfoComplete&&this.hasInit&&(this.isComplete=!0,sa._queue.length>0&&(_.each(sa._queue,function(t){sa.prepareData.apply(sa,Array.prototype.slice.call(t))}),sa._queue=[]))},sa.init=function(){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.para.batch_send&&sendStrategy.init(),sa.checkIsComplete()},sa.initial=function(){this._.info.getSystem(),this.store.init(),_.isObject(this.para.register)&&(_.info.properties=_.extend(_.info.properties,this.para.register))},sa.send=function(t){var e="";t._nocache=(String(Math.random())+String(Math.random())+String(Math.random())).slice(2,15),sa.log(t),t._flush_time=Date.now(),t=JSON.stringify(t),e=-1!==sa.para.server_url.indexOf("?")?sa.para.server_url+"&data="+encodeURIComponent(_.base64Encode(t)):sa.para.server_url+"?data="+encodeURIComponent(_.base64Encode(t));sdmp.sdmp_request({url:e,dataType:"text",method:"GET"})},sa.quick=function(){var t=arguments[0],e=arguments[1],a=arguments[2],r=_.isObject(a)?a:{};"appLaunch"===t||"appShow"===t?e?sa[t](e,r):sa.log("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===t&&(r=_.isObject(e)?e:{},sa[t](r))},sa.pageShow=function(t,e){var a={};a.$url_path=_.getCurrentPath(),_.extend(a,t),(!e||sa.para.autoTrack&&sa.para.autoTrack.pageShow)&&sa.track("$MPViewScreen",a)};var mpHook={data:1,onLoad:1,onShow:1,onReady:1,onHide:1,onUnload:1,onPullDownRefresh:1,onReachBottom:1,onShareAppMessage:1,onPageScroll:1,onResize:1,onTabItemTap:1,onURLQueryChange:1,attached:1,created:1,detached:1,methods:1,properties:1,ready:1,__customConstructor__:1};_.getMethods=function(t){var e=[];for(var a in t)"function"!=typeof t[a]||mpHook[a]||e.push(a);return e},_.isClick=function(t){return!!{tap:1,longpress:1,longtap:1}[t]};var click_proxy=function(t,e){var a=t[e];t[e]=function(){var t=a.apply(this,arguments),e={},r="";if(_.isObject(arguments[0])){_.isObject(arguments[0].event_prop)&&(e=_.extend(e,arguments[0].event_prop));var s=arguments[0].currentTarget||{},n=arguments[0].target||{};if(_.isObject(sa.para.framework)&&_.isObject(sa.para.framework.taro)&&!sa.para.framework.taro.createApp&&n.id&&s.id&&n.id!==s.id)return t;var i=s.dataset||{};r=arguments[0].type,e.$url_path=_.getCurrentPath(),e.$element_id=s.id,e.$element_type=i.type,e.$element_content=i.content,e.$element_name=i.name}if(r&&_.isClick(r)){if(sa.para.preset_events&&sa.para.preset_events.collect_element&&!1===sa.para.preset_events.collect_element(arguments[0]))return t;sa.track("$MPClick",e)}return t}},oldApp=App,oldPage=Page,oldComponent=Component,oldPageAfter=Page.after;App.after({methods:{onLaunch:function(t){t.thisObject[sa.para.name]=sa,sa.appLaunch(t.args,{},!0)},onShow:function(t){sa.appShow(t.args,{},!0)},onHide:function(){sa.appHide({},!0)}}}),Page.after({methods:{onShow:function(){sa.pageShow({},!0)}}}),Page=function(t){var e=sa.para.autoTrack&&sa.para.autoTrack.mpClick&&_.getMethods(t);if(e)for(let a=0,r=e.length;a127&&i<2048?String.fromCharCode(i>>6|192,63&i|128):String.fromCharCode(i>>12|224,i>>6&63|128,63&i|128),null!==o&&(r>t&&(n+=e.substring(t,r)),n+=o,t=r=s+1)}return r>t&&(n+=e.substring(t,e.length)),n},_.base64Encode=function(e){var t,r,a,s,n,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,c=0,p="",u=[];if(!e)return e;e=_.utf8Encode(e);do{t=(n=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,r=n>>12&63,a=n>>6&63,s=63&n,u[c++]=i.charAt(t)+i.charAt(r)+i.charAt(a)+i.charAt(s)}while(osa.para.max_string_length?(sa.log("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,sa.para.max_string_length)):e},_.getAppId=function(){var e;if(sdmp.sdmp_getAppId&&(e=sdmp.sdmp_getAppId()),_.isObject(e))return e.appKey},_.setUpperCase=function(e){return _.isString(e)?e.toLocaleUpperCase():e},_.info={currentProps:{},properties:{$lib:sdmp_info.lib_name,$lib_version:String(sa.lib_version)},getSystem:function(){var e=this.properties,t=!0;function r(){t&&(t=!0,sdmp.sdmp_getSystemInfo({success:function(t){e.$model=t.model,e.$screen_width=Number(t.screenWidth),e.$screen_height=Number(t.screenHeight),e.$os=function(e){try{var t=e.toLowerCase();return"ios"===t?"iOS":"android"===t?"Android":e}catch(e){sa.log(e)}}(t.platform),e.$os_version=t.system.indexOf(" ")>-1?t.system.split(" ")[1]:t.system,e.$brand=_.setUpperCase(t.brand),e.$manufacturer=t.brand},complete:function(){var t=_.getAppId(),r=(new Date).getTimezoneOffset();t&&(e.$app_id=t),_.isNumber(r)&&(e.$timezone_offset=r),sa.getSystemInfoComplete=!0,sa.checkIsComplete()}}))}sdmp.sdmp_getNetworkType({success:function(t){e.$network_type=_.setUpperCase(t.networkType),r()},complete:function(){r()}})},setStatusComplete:function(){if(sa.getSystemInfoComplete)return!1;sa.getSystemInfoComplete=!0,sa._queue.length>0&&(_.each(sa._queue,function(e){sa.prepareData.apply(sa,Array.prototype.slice.call(e))}),sa._queue=[])}},_.getIsFirstDay=function(){return"object"==typeof sa.store._state&&"number"==typeof sa.store._state.first_visit_day_time&&sa.store._state.first_visit_day_time>(new Date).getTime()},_.spliceQuery=function(e){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var t=[];return _.each(e,function(e,r){t.push(r+"="+_.decodeURIComponent(e))}),t.join("&")}return""},_.joinUrl=function(e,t){return!!e&&("\u672a\u53d6\u5230"===e||"\u53d6\u503c\u5f02\u5e38"===e?"\u672a\u53d6\u5230":t?e+"?"+t:e)},_.savePage=function(){var e=_.getCurrentPath(),t=_.getCurrentPageOption(),r=_.spliceQuery(t),a=_.joinUrl(e,r);meta.page_queue.length>=2?(meta.page_queue.shift(),meta.page_queue.push({referrer:a})):meta.page_queue.push({referrer:a})},_.getReferrerPage=function(){var e={referrer:"\u76f4\u63a5\u6253\u5f00"};return meta.page_queue.length>=2&&(e=meta.page_queue[0]),e},_.getAppProps=function(e){var t={$referrer:"\u76f4\u63a5\u6253\u5f00"};e&&e.path&&(t.$url_path=_.getPath(e.path),t.$url_query=_.spliceQuery(e.query),t.$url=_.joinUrl(t.$url_path,t.$url_query),meta.page_queue.length>0&&(t.$referrer=t.$url));return t},_.getPageProps=function(){var e=_.getCurrentPath(),t=_.getCurrentPageOption(),r=_.spliceQuery(t);return{$url_path:e,$url:_.joinUrl(e,r),$url_query:r,$referrer:_.getReferrerPage().referrer}};let store={getUUID:function(){return Date.now()+"-"+Math.floor(1e7*Math.random())+"-"+Math.random().toString(16).replace(".","")+"-"+String(31242*Math.random()).replace(".","").slice(0,8)},setStorage:function(){},getStorage:function(){return sdmp.sdmp_getStorageSync(sdmp_info.storageName)||""},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(e){this.mdata.push(e)},clear:function(e){this.mdata.splice(0,e)}},toState:function(e){"object"==typeof e&&e.distinct_id?this._state=e:this.set("distinct_id",this.getUUID())},getFirstId:function(){return this._state.first_id},getDistinctId:function(){return this._state.distinct_id},getProps:function(){return this._state.props||{}},setProps:function(e,t){var r=this._state.props||{};t?this.set("props",e):(_.extend(r,e),this.set("props",r))},set:function(e,t){var r={};for(var a in"string"==typeof e?r[e]=t:"object"==typeof e&&(r=e),this._state=this._state||{},r)this._state[a]=r[a];this.save()},change:function(e,t){this._state[e]=t},save:function(){sdmp.sdmp_setStorageSync(sdmp_info.storageName,this._state)},init:function(){var e=this.getStorage();if(e)this.toState(e);else{sa.is_first_launch=!0;var t=new Date,r=t.getTime();t.setHours(23),t.setMinutes(59),t.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:r,first_visit_day_time:t.getTime()})}}};sa.store=store;class SendStrategy{constructor(){this.dataHasSend=!0,this.syncStorage=!1,this.is_first_batch_write=!0,this.failTime=0}init(){var e=this;sdmp.sdmp_getStorage({key:sdmp_info.data_is_store,complete:function(t){var r=t.data&&_.isArray(t.data)?t.data:[];sa.store.mem.mdata=r.concat(sa.store.mem.mdata),e.syncStorage=!0}}),this.batchInterval()}onAppHide(){sa.para.batch_send&&this.batchSend()}send(e){if(!sa.para.server_url)return!1;this.dataHasChange=!0,sa.store.mem.getLength()>=500&&(sa.log("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),sa.store.mem.mdata.shift()),sa.log(e),sa.store.mem.add(e),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()}batchWrite(){var e=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){e.batchSend()},1e3)),this.syncStorage&&(sdmp.sdmp_setStorageSync(sdmp_info.data_is_store,sa.store.mem.mdata),this.dataHasChange=!1))}batchInterval(){var e=this;!function t(){setTimeout(function(){e.batchSend(),t()},sa.para.batch_send.send_timeout*Math.pow(2,e.failTime))}(),function t(){setTimeout(function(){e.batchWrite(),t()},500)}()}batchSend(){if(this.dataHasSend){var e,t,r=this,a=sa.store.mem.mdata;if(e=a.length>=100?a.slice(0,100):a,t=e.length,_.isArray(e)&&e.length>0){this.dataHasSend=!1;var s=Date.now();e.forEach(function(e){e._flush_time=s}),e=JSON.stringify(e),e="data_list="+encodeURIComponent(_.base64Encode(e)),sdmp.sdmp_request({url:sa.para.server_url,method:"POST",data:e,dataType:"text",success:function(e){r.batchRemove(t)},fail:function(e){r.sendFail()}})}}}batchRemove(e){this.dataHasSend=!0,this.dataHasChange=!0,sa.store.mem.clear(e),this.batchWrite(),this.failTime=0}sendFail(){this.dataHasSend=!0,this.failTime++}}var sendStrategy=new SendStrategy,mpshow_time=null;sa.setPara=function(e){if(sa.para=_.extend2Lev(sa.para,e),_.isObject(sa.para.register)&&_.extend(_.info.properties,sa.para.register),sa.para.name||(sa.para.name="sensors"),sa.para.server_url){var t={send_timeout:6e3,max_length:6};!0===sa.para.batch_send?sa.para.batch_send=_.extend({},t):_.isObject(sa.para.batch_send)?sa.para.batch_send=_.extend({},t,sa.para.batch_send):sa.para.batch_send=!1}else sa.log("\u8bf7\u4f7f\u7528 setPara() \u65b9\u6cd5\u8bbe\u7f6e server_url \u6570\u636e\u63a5\u6536\u5730\u5740,\u8be6\u60c5\u53ef\u67e5\u770bhttps://www.sensorsdata.cn/manual/mp_sdk_new.html#112-%E5%BC%95%E5%85%A5%E5%B9%B6%E9%85%8D%E7%BD%AE%E5%8F%82%E6%95%B0")},sa.getServerUrl=function(){return sa.para.server_url},sa.prepareData=function(e,t){if(!sa.isComplete)return sa._queue.push(arguments),!1;var r={distinct_id:this.store.getDistinctId(),lib:{$lib:sdmp_info.lib_name,$lib_method:sdmp_info.lib_method,$lib_version:String(sa.lib_version)},properties:{}};_.extend(r,e),_.isObject(e.properties)&&!_.isEmptyObject(e.properties)&&_.extend(r.properties,e.properties),e.type&&"profile"===e.type.slice(0,7)||(r._track_id=Number(String(Math.random()).slice(2,5)+String(Math.random()).slice(2,4)+String(Date.now()).slice(-4)),r.properties=_.extend({},_.info.properties,sa.store.getProps(),_.info.currentProps,r.properties),"object"==typeof sa.store._state&&"number"==typeof sa.store._state.first_visit_day_time&&sa.store._state.first_visit_day_time>(new Date).getTime()?r.properties.$is_first_day=!0:r.properties.$is_first_day=!1),r.properties.$time&&_.isDate(r.properties.$time)?(r.time=1*r.properties.$time,delete r.properties.$time):r.time=1*new Date,_.searchObjDate(r),_.searchObjString(r),sa.para.batch_send?sendStrategy.send(r):sa.send(r,t)},sa.setProfile=function(e,t){sa.prepareData({type:"profile_set",properties:e},t)},sa.setOnceProfile=function(e,t){sa.prepareData({type:"profile_set_once",properties:e},t)},sa.track=function(e,t,r){_.isObject(t)&&!_.isEmptyObject(t)||(t={}),t.$referrer||(t=_.extend(t,_.getPageProps())),this.prepareData({type:"track",event:e,properties:t},r)},sa.identify=function(e,t){if("number"==typeof e)e=String(e);else if("string"!=typeof e)return!1;var r=sa.store.getFirstId();!0===t?r?sa.store.set("first_id",e):sa.store.set("distinct_id",e):r?sa.store.change("first_id",e):sa.store.change("distinct_id",e)},sa.trackSignup=function(e,t,r,a){sa.prepareData({original_id:sa.store.getFirstId()||sa.store.getDistinctId(),distinct_id:e,type:"track_signup",event:t,properties:r},a),sa.store.set("distinct_id",e)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.currentProps=_.extend(_.info.currentProps,e))},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e={};_.each(_.info.currentProps,function(t,r){0===r.indexOf("$")&&(e[r]=t)});var t=_.extend(e,{$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay()},_.info.properties);return delete t.$lib,t}return{}},sa.clearAppRegister=function(e){_.isArray(e)&&_.each(_.info.currentProps,function(t,r){_.include(e,r)&&delete _.info.currentProps[r]})},sa.appLaunch=function(e,t,r){t&&_.isObject(t)||(t={});var a={};_.extend(a,_.getAppProps(e));var s=_.setUtm(e,a);sa.is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(s.pre1)||sa.setOnceProfile(s.pre1)):a.$is_first_time=!1,_.isEmptyObject(s.pre2)||sa.registerApp(s.pre2);var n=_.getMPScene(e.scene);n&&(a.$scene=n,sa.registerApp({$latest_scene:a.$scene})),_.extend(a,t),(!r||sa.para.autoTrack&&sa.para.autoTrack.appLaunch)&&sa.track("$MPLaunch",a)},sa.appShow=function(e,t,r){t&&_.isObject(t)||(t={});var a={};_.extend(a,_.getAppProps(e)),mpshow_time=(new Date).getTime();var s=_.setUtm(e,a);_.isEmptyObject(s.pre2)||sa.registerApp(s.pre2);var n=_.getMPScene(e.scene);n&&(a.$scene=n,sa.registerApp({$latest_scene:a.$scene})),_.extend(a,t),(!r||sa.para.autoTrack&&sa.para.autoTrack.appShow)&&sa.track("$MPShow",a)},sa.appHide=function(e,t){e&&_.isObject(e)||(e={});var r=(new Date).getTime(),a={};_.extend(a,_.getPageProps()),mpshow_time&&r-mpshow_time>0&&(r-mpshow_time)/36e5<24&&(a.event_duration=(r-mpshow_time)/1e3),_.extend(a,e),(!t||sa.para.autoTrack&&sa.para.autoTrack.appHide)&&sa.track("$MPHide",a),sendStrategy.onAppHide()},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.login=function(e){var t=sa.store.getFirstId(),r=sa.store.getDistinctId();e!==r&&(t?sa.trackSignup(e,"$SignUp"):(sa.store.set("first_id",r),sa.trackSignup(e,"$SignUp")))},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set("first_id",""),!0===e?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",t)):sa.log("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25")},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state.first_id||sa.store._state.distinct_id;sa.log("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.checkIsComplete=function(){this.isComplete=!1,this.getSystemInfoComplete&&this.hasInit&&(this.isComplete=!0,sa._queue.length>0&&(_.each(sa._queue,function(e){sa.prepareData.apply(sa,Array.prototype.slice.call(e))}),sa._queue=[]))},sa.init=function(){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.para.batch_send&&sendStrategy.init(),sa.checkIsComplete()},sa.initial=function(){this._.info.getSystem(),this.store.init(),_.isObject(this.para.register)&&(_.info.properties=_.extend(_.info.properties,this.para.register))},sa.send=function(e){var t="";e._nocache=(String(Math.random())+String(Math.random())+String(Math.random())).slice(2,15),sa.log(e),e._flush_time=Date.now(),e=JSON.stringify(e),t=-1!==sa.para.server_url.indexOf("?")?sa.para.server_url+"&data="+encodeURIComponent(_.base64Encode(e)):sa.para.server_url+"?data="+encodeURIComponent(_.base64Encode(e));sdmp.sdmp_request({url:t,dataType:"text",method:"GET"})},sa.quick=function(){var e=arguments[0],t=arguments[1],r=arguments[2],a=_.isObject(r)?r:{};"appLaunch"===e||"appShow"===e?t?sa[e](t,a):sa.log("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(a=_.isObject(t)?t:{},sa[e](a))};{sa.pageShow=function(e,t){var r={};_.savePage(),_.extend(r,_.getPageProps()),_.extend(r,e),(!t||sa.para.autoTrack&&sa.para.autoTrack.pageShow)&&sa.track("$MPViewScreen",r)};var mpHook={data:1,onLoad:1,onShow:1,onReady:1,onHide:1,onUnload:1,onPullDownRefresh:1,onReachBottom:1,onShareAppMessage:1,onPageScroll:1,onResize:1,onTabItemTap:1,onURLQueryChange:1,attached:1,created:1,detached:1,methods:1,properties:1,ready:1,__customConstructor__:1};function clickTrack(e){var t,r={},a={},s=e.currentTarget||{},n=e.target||{};if(_.isObject(sa.para.framework)&&_.isObject(sa.para.framework.taro)&&!sa.para.framework.taro.createApp&&n.id&&s.id&&n.id!==s.id)return!1;var i=s.dataset||{};if(t=e.type,_.extend(r,_.getPageProps()),r.$element_id=s.id,r.$element_type=i.type,r.$element_content=i.content,r.$element_name=i.name,_.isObject(e.event_prop)&&(a=e.event_prop),t&&_.isClick(t)){if(sa.para.preset_events&&sa.para.preset_events.collect_element&&!1===sa.para.preset_events.collect_element(arguments[0]))return!1;r=_.extend(r,a),sa.track("$MPClick",r)}}_.getMethods=function(e){var t=[];for(var r in e)"function"!=typeof e[r]||mpHook[r]||t.push(r);return t},_.isClick=function(e){return!!{tap:1,longpress:1,longtap:1}[e]};var click_proxy=function(e,t){var r=e[t];e[t]=function(){var e=r.apply(this,arguments),t=arguments[0];return _.isObject(t)&&clickTrack(t),e}},oldApp=App,oldPage=Page,oldComponent=Component}var oldPageAfter=Page.after;App.after({methods:{onLaunch:function(e){e.thisObject[sa.para.name]=sa,sa.appLaunch(e.args,{},!0)},onShow:function(e){sa.appShow(e.args,{},!0)},onHide:function(){sa.appHide({},!0)}}}),Page.after({methods:{onShow:function(){sa.pageShow({},!0)}}}),Page=function(e){var t=sa.para.autoTrack&&sa.para.autoTrack.mpClick&&_.getMethods(e);if(t)for(let r=0,a=t.length;r127&&i<2048?String.fromCharCode(i>>6|192,63&i|128):String.fromCharCode(i>>12|224,i>>6&63|128,63&i|128),null!==o&&(r>e&&(n+=t.substring(e,r)),n+=o,e=r=a+1)}return r>e&&(n+=t.substring(e,t.length)),n},_.base64Encode=function(t){var e,r,s,a,n,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,c=0,p="",u=[];if(!t)return t;t=_.utf8Encode(t);do{e=(n=t.charCodeAt(o++)<<16|t.charCodeAt(o++)<<8|t.charCodeAt(o++))>>18&63,r=n>>12&63,s=n>>6&63,a=63&n,u[c++]=i.charAt(e)+i.charAt(r)+i.charAt(s)+i.charAt(a)}while(osa.para.max_string_length?(sa.log("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+t),t.slice(0,sa.para.max_string_length)):t},_.getAppId=function(){var t;if(sdmp.sdmp_getAppId&&(t=sdmp.sdmp_getAppId()),_.isObject(t))return t.appKey},_.setUpperCase=function(t){return _.isString(t)?t.toLocaleUpperCase():t},_.info={currentProps:{},properties:{$lib:sdmp_info.lib_name,$lib_version:String(sa.lib_version)},getSystem:function(){var t=this.properties,e=!0;function r(){e&&(e=!0,sdmp.sdmp_getSystemInfo({success:function(e){t.$model=e.model,t.$screen_width=Number(e.screenWidth),t.$screen_height=Number(e.screenHeight),t.$os=function(t){try{var e=t.toLowerCase();return"ios"===e?"iOS":"android"===e?"Android":t}catch(t){sa.log(t)}}(e.platform),t.$os_version=e.system.indexOf(" ")>-1?e.system.split(" ")[1]:e.system,t.$brand=_.setUpperCase(e.brand),t.$manufacturer=e.brand},complete:function(){var e=_.getAppId(),r=(new Date).getTimezoneOffset();e&&(t.$app_id=e),_.isNumber(r)&&(t.$timezone_offset=r),sa.getSystemInfoComplete=!0,sa.checkIsComplete()}}))}sdmp.sdmp_getNetworkType({success:function(e){t.$network_type=_.setUpperCase(e.networkType),r()},complete:function(){r()}})},setStatusComplete:function(){if(sa.getSystemInfoComplete)return!1;sa.getSystemInfoComplete=!0,sa._queue.length>0&&(_.each(sa._queue,function(t){sa.prepareData.apply(sa,Array.prototype.slice.call(t))}),sa._queue=[])}},_.getIsFirstDay=function(){return"object"==typeof sa.store._state&&"number"==typeof sa.store._state.first_visit_day_time&&sa.store._state.first_visit_day_time>(new Date).getTime()};let store={getUUID:function(){return Date.now()+"-"+Math.floor(1e7*Math.random())+"-"+Math.random().toString(16).replace(".","")+"-"+String(31242*Math.random()).replace(".","").slice(0,8)},setStorage:function(){},getStorage:function(){return sdmp.sdmp_getStorageSync(sdmp_info.storageName)||""},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(t){this.mdata.push(t)},clear:function(t){this.mdata.splice(0,t)}},toState:function(t){"object"==typeof t&&t.distinct_id?this._state=t:this.set("distinct_id",this.getUUID())},getFirstId:function(){return this._state.first_id},getDistinctId:function(){return this._state.distinct_id},getProps:function(){return this._state.props||{}},setProps:function(t,e){var r=this._state.props||{};e?this.set("props",t):(_.extend(r,t),this.set("props",r))},set:function(t,e){var r={};for(var s in"string"==typeof t?r[t]=e:"object"==typeof t&&(r=t),this._state=this._state||{},r)this._state[s]=r[s];this.save()},change:function(t,e){this._state[t]=e},save:function(){sdmp.sdmp_setStorageSync(sdmp_info.storageName,this._state)},init:function(){var t=this.getStorage();if(t)this.toState(t);else{sa.is_first_launch=!0;var e=new Date,r=e.getTime();e.setHours(23),e.setMinutes(59),e.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:r,first_visit_day_time:e.getTime()})}}};sa.store=store;class SendStrategy{constructor(){this.dataHasSend=!0,this.syncStorage=!1,this.is_first_batch_write=!0,this.failTime=0}init(){var t=this;sdmp.sdmp_getStorage({key:sdmp_info.data_is_store,complete:function(e){var r=e.data&&_.isArray(e.data)?e.data:[];sa.store.mem.mdata=r.concat(sa.store.mem.mdata),t.syncStorage=!0}}),this.batchInterval()}onAppHide(){sa.para.batch_send&&this.batchSend()}send(t){if(!sa.para.server_url)return!1;this.dataHasChange=!0,sa.store.mem.getLength()>=500&&(sa.log("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),sa.store.mem.mdata.shift()),sa.log(t),sa.store.mem.add(t),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()}batchWrite(){var t=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){t.batchSend()},1e3)),this.syncStorage&&(sdmp.sdmp_setStorageSync(sdmp_info.data_is_store,sa.store.mem.mdata),this.dataHasChange=!1))}batchInterval(){var t=this;!function e(){setTimeout(function(){t.batchSend(),e()},sa.para.batch_send.send_timeout*Math.pow(2,t.failTime))}(),function e(){setTimeout(function(){t.batchWrite(),e()},500)}()}batchSend(){if(this.dataHasSend){var t,e,r=this,s=sa.store.mem.mdata;if(t=s.length>=100?s.slice(0,100):s,e=t.length,_.isArray(t)&&t.length>0){this.dataHasSend=!1;var a=Date.now();t.forEach(function(t){t._flush_time=a}),t=JSON.stringify(t),t="data_list="+encodeURIComponent(_.base64Encode(t)),sdmp.sdmp_request({url:sa.para.server_url,method:"POST",data:t,dataType:"text",success:function(t){r.batchRemove(e)},fail:function(t){r.sendFail()}})}}}batchRemove(t){this.dataHasSend=!0,this.dataHasChange=!0,sa.store.mem.clear(t),this.batchWrite(),this.failTime=0}sendFail(){this.dataHasSend=!0,this.failTime++}}var sendStrategy=new SendStrategy,mpshow_time=null;sa.setPara=function(t){if(sa.para=_.extend2Lev(sa.para,t),_.isObject(sa.para.register)&&_.extend(_.info.properties,sa.para.register),sa.para.name||(sa.para.name="sensors"),sa.para.server_url){var e={send_timeout:6e3,max_length:6};!0===sa.para.batch_send?sa.para.batch_send=_.extend({},e):_.isObject(sa.para.batch_send)?sa.para.batch_send=_.extend({},e,sa.para.batch_send):sa.para.batch_send=!1}else sa.log("\u8bf7\u4f7f\u7528 setPara() \u65b9\u6cd5\u8bbe\u7f6e server_url \u6570\u636e\u63a5\u6536\u5730\u5740,\u8be6\u60c5\u53ef\u67e5\u770bhttps://www.sensorsdata.cn/manual/mp_sdk_new.html#112-%E5%BC%95%E5%85%A5%E5%B9%B6%E9%85%8D%E7%BD%AE%E5%8F%82%E6%95%B0")},sa.getServerUrl=function(){return sa.para.server_url},sa.prepareData=function(t,e){if(!sa.isComplete)return sa._queue.push(arguments),!1;var r={distinct_id:this.store.getDistinctId(),lib:{$lib:sdmp_info.lib_name,$lib_method:sdmp_info.lib_method,$lib_version:String(sa.lib_version)},properties:{}};_.extend(r,t),_.isObject(t.properties)&&!_.isEmptyObject(t.properties)&&_.extend(r.properties,t.properties),t.type&&"profile"===t.type.slice(0,7)||(r._track_id=Number(String(Math.random()).slice(2,5)+String(Math.random()).slice(2,4)+String(Date.now()).slice(-4)),r.properties=_.extend({},_.info.properties,sa.store.getProps(),_.info.currentProps,r.properties),"object"==typeof sa.store._state&&"number"==typeof sa.store._state.first_visit_day_time&&sa.store._state.first_visit_day_time>(new Date).getTime()?r.properties.$is_first_day=!0:r.properties.$is_first_day=!1),r.properties.$time&&_.isDate(r.properties.$time)?(r.time=1*r.properties.$time,delete r.properties.$time):r.time=1*new Date,_.searchObjDate(r),_.searchObjString(r),sa.para.batch_send?sendStrategy.send(r):sa.send(r,e)},sa.setProfile=function(t,e){sa.prepareData({type:"profile_set",properties:t},e)},sa.setOnceProfile=function(t,e){sa.prepareData({type:"profile_set_once",properties:t},e)},sa.track=function(t,e,r){this.prepareData({type:"track",event:t,properties:e},r)},sa.identify=function(t,e){if("number"==typeof t)t=String(t);else if("string"!=typeof t)return!1;var r=sa.store.getFirstId();!0===e?r?sa.store.set("first_id",t):sa.store.set("distinct_id",t):r?sa.store.change("first_id",t):sa.store.change("distinct_id",t)},sa.trackSignup=function(t,e,r,s){sa.prepareData({original_id:sa.store.getFirstId()||sa.store.getDistinctId(),distinct_id:t,type:"track_signup",event:e,properties:r},s),sa.store.set("distinct_id",t)},sa.registerApp=function(t){_.isObject(t)&&!_.isEmptyObject(t)&&(_.info.currentProps=_.extend(_.info.currentProps,t))},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var t={};_.each(_.info.currentProps,function(e,r){0===r.indexOf("$")&&(t[r]=e)});var e=_.extend(t,{$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay()},_.info.properties);return delete e.$lib,e}return{}},sa.clearAppRegister=function(t){_.isArray(t)&&_.each(_.info.currentProps,function(e,r){_.include(t,r)&&delete _.info.currentProps[r]})},sa.appLaunch=function(t,e,r){e&&_.isObject(e)||(e={});var s={};t&&t.path&&(s.$url_path=_.getPath(t.path));var a=_.setUtm(t,s);sa.is_first_launch?(s.$is_first_time=!0,_.isEmptyObject(a.pre1)||sa.setOnceProfile(a.pre1)):s.$is_first_time=!1,_.isEmptyObject(a.pre2)||sa.registerApp(a.pre2);var n=_.getMPScene(t.scene);n&&(s.$scene=n,sa.registerApp({$latest_scene:s.$scene})),_.extend(s,e),(!r||sa.para.autoTrack&&sa.para.autoTrack.appLaunch)&&sa.track("$MPLaunch",s)},sa.appShow=function(t,e,r){e&&_.isObject(e)||(e={});var s={};mpshow_time=(new Date).getTime(),t&&t.path&&(s.$url_path=_.getPath(t.path));var a=_.setUtm(t,s);_.isEmptyObject(a.pre2)||sa.registerApp(a.pre2);var n=_.getMPScene(t.scene);n&&(s.$scene=n,sa.registerApp({$latest_scene:s.$scene})),_.extend(s,e),(!r||sa.para.autoTrack&&sa.para.autoTrack.appShow)&&sa.track("$MPShow",s)},sa.appHide=function(t,e){t&&_.isObject(t)||(t={});var r=(new Date).getTime(),s={};s.$url_path=_.getCurrentPath(),mpshow_time&&r-mpshow_time>0&&(r-mpshow_time)/36e5<24&&(s.event_duration=(r-mpshow_time)/1e3),_.extend(s,t),(!e||sa.para.autoTrack&&sa.para.autoTrack.appHide)&&sa.track("$MPHide",s),sendStrategy.onAppHide()},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.login=function(t){var e=sa.store.getFirstId(),r=sa.store.getDistinctId();t!==r&&(e?sa.trackSignup(t,"$SignUp"):(sa.store.set("first_id",r),sa.trackSignup(t,"$SignUp")))},sa.logout=function(t){var e=sa.store.getFirstId();e?(sa.store.set("first_id",""),!0===t?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",e)):sa.log("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25")},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state.first_id||sa.store._state.distinct_id;sa.log("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.checkIsComplete=function(){this.isComplete=!1,this.getSystemInfoComplete&&this.hasInit&&(this.isComplete=!0,sa._queue.length>0&&(_.each(sa._queue,function(t){sa.prepareData.apply(sa,Array.prototype.slice.call(t))}),sa._queue=[]))},sa.init=function(){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.para.batch_send&&sendStrategy.init(),sa.checkIsComplete()},sa.initial=function(){this._.info.getSystem(),this.store.init(),_.isObject(this.para.register)&&(_.info.properties=_.extend(_.info.properties,this.para.register))},sa.send=function(t){var e="";t._nocache=(String(Math.random())+String(Math.random())+String(Math.random())).slice(2,15),sa.log(t),t._flush_time=Date.now(),t=JSON.stringify(t),e=-1!==sa.para.server_url.indexOf("?")?sa.para.server_url+"&data="+encodeURIComponent(_.base64Encode(t)):sa.para.server_url+"?data="+encodeURIComponent(_.base64Encode(t));sdmp.sdmp_request({url:e,dataType:"text",method:"GET"})},sa.quick=function(){var t=arguments[0],e=arguments[1],r=arguments[2],s=_.isObject(r)?r:{};"appLaunch"===t||"appShow"===t?e?sa[t](e,s):sa.log("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===t&&(s=_.isObject(e)?e:{},sa[t](s))},sa.initial(),module.exports=sa;
\ No newline at end of file
+"use strict";var sdmp=Object.assign({},swan),sdmp_info={storageName:"sensorsdata2015_baidu",lib_name:"SmartProgram",lib_method:"code",select_utm:!0,data_is_store:"sensors_prepare_data"};sdmp.sdmp_request=swan.request,sdmp.sdmp_getSystemInfo=swan.getSystemInfo,sdmp.sdmp_getNetworkType=swan.getNetworkType,sdmp.sdmp_getStorageSync=swan.getStorageSync,sdmp.sdmp_setStorageSync=swan.setStorageSync,sdmp.sdmp_getAppId=swan.getEnvInfoSync,sdmp.sdmp_getStorage=swan.getStorage;const sa={lib_version:"0.15.6",is_first_launch:!1,_queue:[],getSystemInfoComplete:!1,para:{name:"sensors",server_url:"",max_string_length:500,autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,mpClick:!0},show_log:!1,batch_send:!0},log:function(){if(sa.para.show_log)try{return console.log.apply(console,arguments)}catch(e){console.log(arguments[0])}}},_={};var ArrayProto=Array.prototype,ObjProto=Object.prototype,slice=ArrayProto.slice,toString=ObjProto.toString,hasOwnProperty=ObjProto.hasOwnProperty,nativeForEach=ArrayProto.forEach,nativeIndexOf=ArrayProto.indexOf,nativeIsArray=Array.isArray,breaker={},each=_.each=function(e,t,r){if(null==e)return!1;if(nativeForEach&&e.forEach===nativeForEach)e.forEach(t,r);else if(e.length===+e.length){for(var a=0,s=e.length;a127&&i<2048?String.fromCharCode(i>>6|192,63&i|128):String.fromCharCode(i>>12|224,i>>6&63|128,63&i|128),null!==o&&(r>t&&(n+=e.substring(t,r)),n+=o,t=r=s+1)}return r>t&&(n+=e.substring(t,e.length)),n},_.base64Encode=function(e){var t,r,a,s,n,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,c=0,p="",u=[];if(!e)return e;e=_.utf8Encode(e);do{t=(n=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,r=n>>12&63,a=n>>6&63,s=63&n,u[c++]=i.charAt(t)+i.charAt(r)+i.charAt(a)+i.charAt(s)}while(osa.para.max_string_length?(sa.log("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,sa.para.max_string_length)):e},_.getAppId=function(){var e;if(sdmp.sdmp_getAppId&&(e=sdmp.sdmp_getAppId()),_.isObject(e))return e.appKey},_.setUpperCase=function(e){return _.isString(e)?e.toLocaleUpperCase():e},_.info={currentProps:{},properties:{$lib:sdmp_info.lib_name,$lib_version:String(sa.lib_version)},getSystem:function(){var e=this.properties,t=!0;function r(){t&&(t=!0,sdmp.sdmp_getSystemInfo({success:function(t){e.$model=t.model,e.$screen_width=Number(t.screenWidth),e.$screen_height=Number(t.screenHeight),e.$os=function(e){try{var t=e.toLowerCase();return"ios"===t?"iOS":"android"===t?"Android":e}catch(e){sa.log(e)}}(t.platform),e.$os_version=t.system.indexOf(" ")>-1?t.system.split(" ")[1]:t.system,e.$brand=_.setUpperCase(t.brand),e.$manufacturer=t.brand},complete:function(){var t=_.getAppId(),r=(new Date).getTimezoneOffset();t&&(e.$app_id=t),_.isNumber(r)&&(e.$timezone_offset=r),sa.getSystemInfoComplete=!0,sa.checkIsComplete()}}))}sdmp.sdmp_getNetworkType({success:function(t){e.$network_type=_.setUpperCase(t.networkType),r()},complete:function(){r()}})},setStatusComplete:function(){if(sa.getSystemInfoComplete)return!1;sa.getSystemInfoComplete=!0,sa._queue.length>0&&(_.each(sa._queue,function(e){sa.prepareData.apply(sa,Array.prototype.slice.call(e))}),sa._queue=[])}},_.getIsFirstDay=function(){return"object"==typeof sa.store._state&&"number"==typeof sa.store._state.first_visit_day_time&&sa.store._state.first_visit_day_time>(new Date).getTime()},_.spliceQuery=function(e){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var t=[];return _.each(e,function(e,r){t.push(r+"="+_.decodeURIComponent(e))}),t.join("&")}return""},_.joinUrl=function(e,t){return!!e&&("\u672a\u53d6\u5230"===e||"\u53d6\u503c\u5f02\u5e38"===e?"\u672a\u53d6\u5230":t?e+"?"+t:e)},_.savePage=function(){var e=_.getCurrentPath(),t=_.getCurrentPageOption(),r=_.spliceQuery(t),a=_.joinUrl(e,r);meta.page_queue.length>=2?(meta.page_queue.shift(),meta.page_queue.push({referrer:a})):meta.page_queue.push({referrer:a})},_.getReferrerPage=function(){var e={referrer:"\u76f4\u63a5\u6253\u5f00"};return meta.page_queue.length>=2&&(e=meta.page_queue[0]),e},_.getAppProps=function(e){var t={$referrer:"\u76f4\u63a5\u6253\u5f00"};e&&e.path&&(t.$url_path=_.getPath(e.path),t.$url_query=_.spliceQuery(e.query),t.$url=_.joinUrl(t.$url_path,t.$url_query),meta.page_queue.length>0&&(t.$referrer=t.$url));return t},_.getPageProps=function(){var e=_.getCurrentPath(),t=_.getCurrentPageOption(),r=_.spliceQuery(t);return{$url_path:e,$url:_.joinUrl(e,r),$url_query:r,$referrer:_.getReferrerPage().referrer}};let store={getUUID:function(){return Date.now()+"-"+Math.floor(1e7*Math.random())+"-"+Math.random().toString(16).replace(".","")+"-"+String(31242*Math.random()).replace(".","").slice(0,8)},setStorage:function(){},getStorage:function(){return sdmp.sdmp_getStorageSync(sdmp_info.storageName)||""},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(e){this.mdata.push(e)},clear:function(e){this.mdata.splice(0,e)}},toState:function(e){"object"==typeof e&&e.distinct_id?this._state=e:this.set("distinct_id",this.getUUID())},getFirstId:function(){return this._state.first_id},getDistinctId:function(){return this._state.distinct_id},getProps:function(){return this._state.props||{}},setProps:function(e,t){var r=this._state.props||{};t?this.set("props",e):(_.extend(r,e),this.set("props",r))},set:function(e,t){var r={};for(var a in"string"==typeof e?r[e]=t:"object"==typeof e&&(r=e),this._state=this._state||{},r)this._state[a]=r[a];this.save()},change:function(e,t){this._state[e]=t},save:function(){sdmp.sdmp_setStorageSync(sdmp_info.storageName,this._state)},init:function(){var e=this.getStorage();if(e)this.toState(e);else{sa.is_first_launch=!0;var t=new Date,r=t.getTime();t.setHours(23),t.setMinutes(59),t.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:r,first_visit_day_time:t.getTime()})}}};sa.store=store;class SendStrategy{constructor(){this.dataHasSend=!0,this.syncStorage=!1,this.is_first_batch_write=!0,this.failTime=0}init(){var e=this;sdmp.sdmp_getStorage({key:sdmp_info.data_is_store,complete:function(t){var r=t.data&&_.isArray(t.data)?t.data:[];sa.store.mem.mdata=r.concat(sa.store.mem.mdata),e.syncStorage=!0}}),this.batchInterval()}onAppHide(){sa.para.batch_send&&this.batchSend()}send(e){if(!sa.para.server_url)return!1;this.dataHasChange=!0,sa.store.mem.getLength()>=500&&(sa.log("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),sa.store.mem.mdata.shift()),sa.log(e),sa.store.mem.add(e),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()}batchWrite(){var e=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){e.batchSend()},1e3)),this.syncStorage&&(sdmp.sdmp_setStorageSync(sdmp_info.data_is_store,sa.store.mem.mdata),this.dataHasChange=!1))}batchInterval(){var e=this;!function t(){setTimeout(function(){e.batchSend(),t()},sa.para.batch_send.send_timeout*Math.pow(2,e.failTime))}(),function t(){setTimeout(function(){e.batchWrite(),t()},500)}()}batchSend(){if(this.dataHasSend){var e,t,r=this,a=sa.store.mem.mdata;if(e=a.length>=100?a.slice(0,100):a,t=e.length,_.isArray(e)&&e.length>0){this.dataHasSend=!1;var s=Date.now();e.forEach(function(e){e._flush_time=s}),e=JSON.stringify(e),e="data_list="+encodeURIComponent(_.base64Encode(e)),sdmp.sdmp_request({url:sa.para.server_url,method:"POST",data:e,dataType:"text",success:function(e){r.batchRemove(t)},fail:function(e){r.sendFail()}})}}}batchRemove(e){this.dataHasSend=!0,this.dataHasChange=!0,sa.store.mem.clear(e),this.batchWrite(),this.failTime=0}sendFail(){this.dataHasSend=!0,this.failTime++}}var sendStrategy=new SendStrategy,mpshow_time=null;sa.setPara=function(e){if(sa.para=_.extend2Lev(sa.para,e),_.isObject(sa.para.register)&&_.extend(_.info.properties,sa.para.register),sa.para.name||(sa.para.name="sensors"),sa.para.server_url){var t={send_timeout:6e3,max_length:6};!0===sa.para.batch_send?sa.para.batch_send=_.extend({},t):_.isObject(sa.para.batch_send)?sa.para.batch_send=_.extend({},t,sa.para.batch_send):sa.para.batch_send=!1}else sa.log("\u8bf7\u4f7f\u7528 setPara() \u65b9\u6cd5\u8bbe\u7f6e server_url \u6570\u636e\u63a5\u6536\u5730\u5740,\u8be6\u60c5\u53ef\u67e5\u770bhttps://www.sensorsdata.cn/manual/mp_sdk_new.html#112-%E5%BC%95%E5%85%A5%E5%B9%B6%E9%85%8D%E7%BD%AE%E5%8F%82%E6%95%B0")},sa.getServerUrl=function(){return sa.para.server_url},sa.prepareData=function(e,t){if(!sa.isComplete)return sa._queue.push(arguments),!1;var r={distinct_id:this.store.getDistinctId(),lib:{$lib:sdmp_info.lib_name,$lib_method:sdmp_info.lib_method,$lib_version:String(sa.lib_version)},properties:{}};_.extend(r,e),_.isObject(e.properties)&&!_.isEmptyObject(e.properties)&&_.extend(r.properties,e.properties),e.type&&"profile"===e.type.slice(0,7)||(r._track_id=Number(String(Math.random()).slice(2,5)+String(Math.random()).slice(2,4)+String(Date.now()).slice(-4)),r.properties=_.extend({},_.info.properties,sa.store.getProps(),_.info.currentProps,r.properties),"object"==typeof sa.store._state&&"number"==typeof sa.store._state.first_visit_day_time&&sa.store._state.first_visit_day_time>(new Date).getTime()?r.properties.$is_first_day=!0:r.properties.$is_first_day=!1),r.properties.$time&&_.isDate(r.properties.$time)?(r.time=1*r.properties.$time,delete r.properties.$time):r.time=1*new Date,_.searchObjDate(r),_.searchObjString(r),sa.para.batch_send?sendStrategy.send(r):sa.send(r,t)},sa.setProfile=function(e,t){sa.prepareData({type:"profile_set",properties:e},t)},sa.setOnceProfile=function(e,t){sa.prepareData({type:"profile_set_once",properties:e},t)},sa.track=function(e,t,r){_.isObject(t)&&!_.isEmptyObject(t)||(t={}),t.$referrer||(t=_.extend(t,_.getPageProps())),this.prepareData({type:"track",event:e,properties:t},r)},sa.identify=function(e,t){if("number"==typeof e)e=String(e);else if("string"!=typeof e)return!1;var r=sa.store.getFirstId();!0===t?r?sa.store.set("first_id",e):sa.store.set("distinct_id",e):r?sa.store.change("first_id",e):sa.store.change("distinct_id",e)},sa.trackSignup=function(e,t,r,a){sa.prepareData({original_id:sa.store.getFirstId()||sa.store.getDistinctId(),distinct_id:e,type:"track_signup",event:t,properties:r},a),sa.store.set("distinct_id",e)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.currentProps=_.extend(_.info.currentProps,e))},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e={};_.each(_.info.currentProps,function(t,r){0===r.indexOf("$")&&(e[r]=t)});var t=_.extend(e,{$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay()},_.info.properties);return delete t.$lib,t}return{}},sa.clearAppRegister=function(e){_.isArray(e)&&_.each(_.info.currentProps,function(t,r){_.include(e,r)&&delete _.info.currentProps[r]})},sa.appLaunch=function(e,t,r){t&&_.isObject(t)||(t={});var a={};_.extend(a,_.getAppProps(e));var s=_.setUtm(e,a);sa.is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(s.pre1)||sa.setOnceProfile(s.pre1)):a.$is_first_time=!1,_.isEmptyObject(s.pre2)||sa.registerApp(s.pre2);var n=_.getMPScene(e.scene);n&&(a.$scene=n,sa.registerApp({$latest_scene:a.$scene})),_.extend(a,t),(!r||sa.para.autoTrack&&sa.para.autoTrack.appLaunch)&&sa.track("$MPLaunch",a)},sa.appShow=function(e,t,r){t&&_.isObject(t)||(t={});var a={};_.extend(a,_.getAppProps(e)),mpshow_time=(new Date).getTime();var s=_.setUtm(e,a);_.isEmptyObject(s.pre2)||sa.registerApp(s.pre2);var n=_.getMPScene(e.scene);n&&(a.$scene=n,sa.registerApp({$latest_scene:a.$scene})),_.extend(a,t),(!r||sa.para.autoTrack&&sa.para.autoTrack.appShow)&&sa.track("$MPShow",a)},sa.appHide=function(e,t){e&&_.isObject(e)||(e={});var r=(new Date).getTime(),a={};_.extend(a,_.getPageProps()),mpshow_time&&r-mpshow_time>0&&(r-mpshow_time)/36e5<24&&(a.event_duration=(r-mpshow_time)/1e3),_.extend(a,e),(!t||sa.para.autoTrack&&sa.para.autoTrack.appHide)&&sa.track("$MPHide",a),sendStrategy.onAppHide()},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.login=function(e){var t=sa.store.getFirstId(),r=sa.store.getDistinctId();e!==r&&(t?sa.trackSignup(e,"$SignUp"):(sa.store.set("first_id",r),sa.trackSignup(e,"$SignUp")))},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set("first_id",""),!0===e?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",t)):sa.log("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25")},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state.first_id||sa.store._state.distinct_id;sa.log("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.checkIsComplete=function(){this.isComplete=!1,this.getSystemInfoComplete&&this.hasInit&&(this.isComplete=!0,sa._queue.length>0&&(_.each(sa._queue,function(e){sa.prepareData.apply(sa,Array.prototype.slice.call(e))}),sa._queue=[]))},sa.init=function(){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.para.batch_send&&sendStrategy.init(),sa.checkIsComplete()},sa.initial=function(){this._.info.getSystem(),this.store.init(),_.isObject(this.para.register)&&(_.info.properties=_.extend(_.info.properties,this.para.register))},sa.send=function(e){var t="";e._nocache=(String(Math.random())+String(Math.random())+String(Math.random())).slice(2,15),sa.log(e),e._flush_time=Date.now(),e=JSON.stringify(e),t=-1!==sa.para.server_url.indexOf("?")?sa.para.server_url+"&data="+encodeURIComponent(_.base64Encode(e)):sa.para.server_url+"?data="+encodeURIComponent(_.base64Encode(e));sdmp.sdmp_request({url:t,dataType:"text",method:"GET"})},sa.quick=function(){var e=arguments[0],t=arguments[1],r=arguments[2],a=_.isObject(r)?r:{};"appLaunch"===e||"appShow"===e?t?sa[e](t,a):sa.log("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(a=_.isObject(t)?t:{},sa[e](a))},sa.initial(),module.exports=sa;
\ No newline at end of file