Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aaomega

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aaomega - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

108

Omega.js
import om from './trackEvent'
exports.omegaBehavior = Behavior({
const info = []
function pushInfo (p) {
if (info.length > 10) {
info.pop()
}
info.push(p)
}
exports.myBehavior = Behavior({
behaviors: [],

@@ -16,2 +25,6 @@ properties: {

created () {
wx.onError((e) => {
console.log(e, 'e ===>')
om.trackEvent('OMGWXPageError', e, info);
})
console.log('created===>')

@@ -26,7 +39,10 @@ this.setData({

om.trackEvent('OMGWXPageAttached');
pushInfo('attached')
},
ready () {
console.log('ready===>')
let res = wx.getPerformance()
console.log('ready===>', res)
// console.log(Date.now() - this.data.ts, 'ts ===>')
om.trackEvent('OMGWXPageReady', { time: Date.now() - this.data.ts });
},

@@ -36,6 +52,7 @@ detached () {

om.trackEvent('OMGWXPageDetached');
pushInfo('detached')
},
error () {
error (e) {
console.log('error===>')
om.trackEvent('OMGWXPageError');
om.trackEvent('OMGWXPageError', e, info);
}

@@ -46,8 +63,11 @@ },

console.log('show===>')
pushInfo('show')
},
hide () {
console.log('hide===>')
pushInfo('hide')
},
resize () {
console.log('resize===>')
pushInfo('resize')
}

@@ -62,2 +82,80 @@ },

exports.trackEvent = om.trackEvent
function trackEvent (eventid, eventlabel, attrs) {
console.log(eventid, eventlabel, attrs)
// wx.request('/api/omega', {
// eventid, eventlabel, attrs
// })
}
exports.trackEvent = trackEvent
exports.performance = performance
function performance(Omega, wx) {
if (!Omega || !wx) {
return;
}
try {
let info = {}; // 维度数据
wx.getSystemInfo({
success(res) {
const {
SDKVersion,
benchmarkLevel,
brand,
model,
platform,
version
} = res;
info = {
SDKVersion,
benchmarkLevel,
brand,
model
};
}
}); // 应用版本
const accountInfo = wx.getAccountInfoSync ? wx.getAccountInfoSync() : {};
if (accountInfo.miniProgram) {
info.appVersion = accountInfo.version;
} // 网络
wx.getNetworkType({
success(res) {
info.networkType = res.networkType;
}
}); // 性能数据
const performance = wx.getPerformance();
let _first = false;
const observer = performance.createObserver(entryList => {
const entreis = entryList.getEntries();
let attrs = {};
let totalDuration = 0;
for (let item of entreis) {
const {
duration,
name
} = item;
attrs[name + '_duration'] = Math.abs(duration);
totalDuration = totalDuration + Math.abs(duration);
}
attrs['total_duration'] = totalDuration;
attrs = Object.assign({}, attrs, info);
Omega.trackEvent(!_first ? 'tech_performance_init' : 'tech_performance_run', attrs);
_first = true;
});
observer.observe({
entryTypes: ['render', 'script', 'navigation']
});
} catch (e) {}
}

2

package.json
{
"name": "aaomega",
"version": "1.0.1",
"version": "1.0.2",
"description": "3. Example app.mpx ```html <script> // 在app中不管使不使用,都必须要在app.mpx中先引入Omega import Omega from 'omega'; // app.js App({ onLaunch: function () { Omega.setConfig({ appId: 'wx7292c1899397867c', uniqueId: 'XXXXXXXXXXXXXXXX' }); // Your code ... } }); </script> ``` page.mpx ```html <script> import Omega from 'omega';",

@@ -5,0 +5,0 @@ "main": "Omega.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc