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

User country info #982

Merged
merged 4 commits into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
ChaoticTempest marked this conversation as resolved.
Show resolved Hide resolved

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