Skip to content

Commit

Permalink
finish master account
Browse files Browse the repository at this point in the history
  • Loading branch information
icerove committed Dec 10, 2020
1 parent 0d4a586 commit e7d4104
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions commands/create-account.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { KeyPair } = require('near-api-js');
const inspectResponse = require('../utils/inspect-response');
// Top-level account (TLA) is testnet for foo.alice.testnet
const TLA_MIN_LENGTH = 32;
const eventtracking = require('../utils/eventtracking');

const createAccountCommand = {
command: 'create-account <accountId>',
Expand Down Expand Up @@ -74,6 +75,7 @@ const createAccountCommandDeprecated = {
async function createAccount(options) {
// NOTE: initialBalance is passed as part of config here, parsed in middleware/initial-balance
// periods are disallowed in top-level accounts and can only be used for subaccounts
await eventtracking.askForConsentIfNeeded(options, options.masterAccount);
const splitAccount = options.accountId.split('.');

const splitMaster = options.masterAccount.split('.');
Expand Down
11 changes: 6 additions & 5 deletions utils/eventtracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,14 @@ const getIdTrackingConsent = async () => {
}
};

const askForId = async (options) => {
const askForId = async (options, masterAccount) => {
const shellSettings = settings.getShellSettings();
const accountID = masterAccount ? masterAccount : options.accountId;
if(shouldTrackID(shellSettings)){
const id = isGitPod() ? getGitPodUserHash() : shellSettings[TRACKING_SESSION_ID_KEY];
await Promise.all([
mixpanel.alias(options.accountId, id),
mixpanel.people.set(id, {account_id: options.accountId})
mixpanel.alias(accountID, id),
mixpanel.people.set(id, {account_id: accountID})
]);
} else if(shouldNotTrackID(shellSettings)){
return;
Expand All @@ -173,7 +174,7 @@ const askForId = async (options) => {
}
};

const askForConsentIfNeeded = async (options) => {
const askForConsentIfNeeded = async (options, masterAccount) => {
const shellSettings = settings.getShellSettings();
// if the appropriate option is not in settings, ask now and save settings.
if (!(TRACKING_ENABLED_KEY in shellSettings)) {
Expand All @@ -189,7 +190,7 @@ const askForConsentIfNeeded = async (options) => {
await track(module.exports.EVENT_ID_TRACKING_OPT_IN, {}, options);
}
}
await askForId(options);
await askForId(options, masterAccount);
};

const trackDeployedContract = async () => {
Expand Down

0 comments on commit e7d4104

Please sign in to comment.