1

Here is what I did:

  1. Cloned HMS AnalyticsKit Demo for Javascript - https://github.com/HMS-Core/hms-analytics-demo-javascript.git in Germany Frankfurt AWS EC2
  2. cd hms-analytics-demo-javascript/hmsanalyticskitdemo/
  3. npm install
  4. npm run dev
  5. Use Chrome browser and visit http://x.x.x.x:8080 (EC2), complete the quiz and post score
  6. Inspect Console - https://ibb.co/TKDm586. There is no CORS or 401 error.

This is what I find in hms-analytics-demo-javascript/hmsanalyticskitdemo/src/main.js:

var agConnectConfig = 
{
    "agcgw":{
      "backurl": "https://lfagcgwtest01.hwcloudtest.cn:15602",
      "url": "https://lfagcgwtest01cn.hwcloudtest.cn:18062"
    },
    "client":{
        "cp_id":"4130086000000637176",
        "product_id":"258913027873047688",
        "client_id":"401147640282098944",
        "client_secret":"ABA91A52EF1FAB651F57AF091CEC149EECAFB01757DF1224FC384D2173828480",
        "app_id":"98751101985125555",
        "api_key":"CgB6e3x9zs8IL+Frjllsf9DoteK4Taz7jAseM9P+ikVZBJhHu87FpdEpqq0CimpayCrJgUrkUnV2RM86fyFiD4FE"
    },
    "service":{
        "analytics":{
            "collector_url":"habackup.hwcloudtest.cn:31405,datacollector-drcn.dt.dbankcloud.cn",
            "resource_id":"p1",
            "channel_id":""
        },
        "cloudstorage":{
            "storage_url":"https://agc-storage-drcn.platform.dbankcloud.cn"
        },
        "ml":{
            "mlservice_url":"ml-api-drcn.ai.dbankcloud.com,ml-api-drcn.ai.dbankcloud.cn"
        }
    },
    "region":"CN",
    "configuration_version":"1.0"
};

Then I change it to my own agconnect-services.json (note that I changed cp_id, product_id, client_id, client_secret, app_id, package_name, api_key. My data storage location is Germany):

var agConnectConfig =
{
    "agcgw":{
        "backurl":"connect-dre.dbankcloud.cn",
        "url":"connect-dre.hispace.hicloud.com"
    },
    "client":{
        "cp_id":"890001000000000000",
        "product_id":"736430070000000000",
        "client_id":"451560030000000000",
        "client_secret":"5950F0F77523D1C95914089A046DED446E09A02036D8AAAAAAAAAAAAAAAAAAAA",
        "app_id":"100000000",
        "package_name":"com.aaaa.aa.aaaaaaa",
        "api_key":"CgB6e3x9LNm1WQuE1uhjpEI6kdQD7xD23LfdkttRcakwi404NmcxlOBVUslatUnb5dJzXXXXXXXXXXXXXXXXXXXX"
    },
    "service":{
        "analytics":{
            "collector_url":"datacollector-dre.dt.hicloud.com,datacollector-dre.dt.dbankcloud.cn",
            "resource_id":"p1",
            "channel_id":""
        },
        "cloudstorage":{
            "storage_url":"https://ops-dre.agcstorage.link"
        },
        "ml":{
            "mlservice_url":"ml-api-dre.ai.dbankcloud.com,ml-api-dre.ai.dbankcloud.cn"
        }
    },
    "region":"DE",
    "configuration_version":"1.0"
}

I repeated step 5, I saw CORS errors - https://ibb.co/HHQvMVL

POST https://datacollector-dre.dt.hicloud.com/webv3 net::ERR_FAILED

If I turn on CORS plugin on Chrome, I saw 401 errors - https://ibb.co/9tXMrHS

POST https://datacollector-dre.dt.hicloud.com/webv3 401

I see no analytics in my app > analytics > real-time overview console.

Is there something wrong with my steps? Could this is be API/server issue?

Thanks.

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
wchw
  • 65
  • 7
  • I have compared both https://developer.huawei.com/consumer/en/doc/development/HMSCore-Library-V5/javascript-sdk-download-nmp-0000001050825675-V5 and npm installed node_modules/@hmscore/analytics-web. All scripts are identical with one exception, the download lib has web/openness/HiAnalytics.js. This file is not included in the demo code. What is this file for? And where should I place it? – wchw Oct 09 '20 at 19:29

1 Answers1

0

Your integration procedures are correct. The problem is that the latest version of SDK should be integrated.

The earlier version of the JavaScript SDK has an authentication failure issue, which causes the fault to run the demo. You are advised to download the latest SDK 5.0.4.300 which rectified the authentication failure issue, and perform the verification.

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
  • Per my prior comment, the download lib has web/openness/HiAnalytics.js. This file is not included in the demo code or npm installed @hmscore/analytics-web. What is this file for, and where should I place it? – wchw Oct 12 '20 at 07:23
  • 1
    I have updated package.json to change "@hmscore/analytics-web": "^5.0.2-303" to "@hmscore/analytics-web": "^5.0.4-300", it is working now, thanks. – wchw Oct 12 '20 at 07:44