serverless / components

The Serverless Framework's new infrastructure provisioning technology — Build, compose, & deploy serverless apps in seconds...
https://www.serverless.com
Apache License 2.0
2.31k stars 181 forks source link

commercial promotion and China user indentify code snippet #1030

Closed Owisky closed 2 years ago

Owisky commented 2 years ago

Description

why Chinese users are different , even needed to distinguish in src code?

Additional Data

components/src/cli/utils.js:

const isChinaUser = () => {
  let result;
  if (
    process.env.SERVERLESS_PLATFORM_VENDOR === 'tencent' ||
    process.env.SLS_GEO_LOCATION === 'cn'
  ) {
    result = true;
  } else if (process.env.SERVERLESS_PLATFORM_VENDOR === 'aws') {
    result = false;
  } else {
    result = new Intl.DateTimeFormat('en', { timeZoneName: 'long' })
      .format()
      .includes('China Standard Time');
  }

  return result;
};
ole3021 commented 2 years ago

@Owisky There is no discrimination here, The logic you see here is used to auto separate users that use AWS and Tencent Provider, and for users from China Tencent is the default provider.

We decide to make Tencent as the default provider in China as we cooperate with Tencent closely to provide the best experience for most users from China, and user may easily switch back to AWS if they wish by set SERVERLESS_PLATFORM_VENDOR to aws or SLS_GEO_LOCATION to anywhere else than cn.

We need to know if a user is from China, then we will show CLI context in Chinese to make it easier for users from China use the CLI and understand help info we want to tell users.

Technically, we have have different architecture on AWS and Tencent, as the infrastructure is different, so we have different CLI (Framework CLI and Component CLI) to help user using serverless, to make user has the best experience, we nested the components CLI in the Framework CLI , they all will be triggered by commands serverless or sls, with geo location info we can easily find the correct CLI for all Serverless users.

We worked a lot to improve the experience of users from China, not only the Chinese content, but also the user scenarios that China users preferred (eg: easy deploy WEB framework app to serverless, like Express, Flask, ThinkPHP).

Hope this give you a clear idea why we check geo location and vendor info in our code, please let me know if you have future questions.

Owisky commented 2 years ago

very understood, sorry for the inconsiderate expression.

ole3021 commented 2 years ago

No worries, Thx for understanding.

you can find out more what we build Serverless in China here : https://cn.serverless.com also you can leave any questions in Chinese in our Chinese Discussion Forum : https://github.com/serverless/serverless-tencent/discussions