@smpx/koa-request 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/Request.js +19 -5
  2. package/package.json +1 -1
package/Request.js CHANGED
@@ -654,11 +654,16 @@ class Request {
654
654
  let [os, appVersion, installId] = infoStr.split(separator);
655
655
  os = os.toLowerCase();
656
656
 
657
- const appInfo = {
658
- os,
659
- appVersion,
660
- installId,
661
- };
657
+ const appInfo = {};
658
+ if (os) {
659
+ appInfo.os = os;
660
+ }
661
+ if (appVersion) {
662
+ appInfo.appVersion = appVersion;
663
+ }
664
+ if (installId) {
665
+ appInfo.installId = installId;
666
+ }
662
667
 
663
668
  if (this.appPlatforms().has(os)) {
664
669
  appInfo.appType = 'app';
@@ -760,6 +765,8 @@ class Request {
760
765
  else if (!appInfo.deviceType) {
761
766
  appInfo.deviceType = this._getDeviceType();
762
767
  }
768
+
769
+ return appInfo;
763
770
  }
764
771
 
765
772
  /*
@@ -834,6 +841,13 @@ class Request {
834
841
  return false;
835
842
  }
836
843
 
844
+ platform() {
845
+ if (this.isApp()) return 'mobile_app';
846
+ if (this.isMobile()) return 'mobile_web';
847
+ if (this.isAPI()) return 'api';
848
+ return 'desktop';
849
+ }
850
+
837
851
  /**
838
852
  * @typedef {Object} UTMObject
839
853
  * @property {string} source
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smpx/koa-request",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Handle basic tasks for koajs",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",