Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions sdk/others/isInChina.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
const { DataReport } = require('../others/dataReport')

class IsInChina {
async inChina() {
inChina() {
try {
new DataReport().report({ name: 'DetectChinaUser' })
} catch (e) {}

const result =
process.env.SLS_GEO_LOCATION === 'cn' ||
new Intl.DateTimeFormat('en', { timeZoneName: 'long' })
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 { IsInChina: result }
}
Expand Down