Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
User country info (#982)
Browse files Browse the repository at this point in the history
* user country info added
  • Loading branch information
volovyks authored May 26, 2022
1 parent 80cab7e commit 25afdc0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Binary file added main.wasm
Binary file not shown.
17 changes: 14 additions & 3 deletions utils/eventtracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,18 @@ const track = async (eventType, eventProperties, options) => {
const id = getMixpanelID(shellSettings);
await Promise.all([
mixpanel.alias(accountID, id),
mixpanel.people.set(id, {account_id: accountID})
mixpanel.people.set(id, { account_id: accountID })
]);
}

const user_country = await getUserCountry();

const mixPanelProperties = {
distinct_id: getMixpanelID(shellSettings),
near_cli_version,
user_country,
os: process.platform,
network_id: options.networkId === 'default' ? 'testnet': options.networkId,
network_id: options.networkId === 'default' ? 'testnet' : options.networkId,
node_url: options.nodeUrl,
wallet_url: options.walletUrl,
is_gitpod: isGitPod(),
Expand All @@ -82,10 +85,18 @@ const track = async (eventType, eventProperties, options) => {
}
};

async function getUserCountry() {
return fetch('https://ipinfo.io/json').then(
(response) => response.json()
).then(
(jsonResponse) => jsonResponse.country
).catch(error => console.log(`Failed to get the country due to: ${error}`));
}

const getEventTrackingConsent = async () => {
return askYesNoQuestion(
chalk`Please help us to collect data on near-cli usage to improve developer experience. ` +
chalk`\nWe will never send private information. We collect which commands are run with attributes and your account ID.` +
chalk`\nWe will never send private information. We collect which commands are run with attributes, your account ID, and your country` +
chalk`\nNote that your account ID and all associated on-chain transactions are already being recorded on public blockchain. ` +
chalk`\n\n{bold.yellow Would you like to opt in (y/n)? }`);
};
Expand Down

0 comments on commit 25afdc0

Please sign in to comment.