Skip to content

Commit

Permalink
rename var
Browse files Browse the repository at this point in the history
  • Loading branch information
filfreire committed Aug 5, 2024
1 parent 55cb4eb commit 9e12aa7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions packages/insomnia/src/main/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ export async function trackSegmentEvent(
) {
const settings = await models.settings.getOrCreate();
const userSession = await models.userSession.getOrCreate();
if (!userSession?.hashedUserId) {
userSession.hashedUserId = userSession?.accountId ? hashString(userSession.accountId) : '';
if (!userSession?.hashedAccountId) {
userSession.hashedAccountId = userSession?.accountId ? hashString(userSession.accountId) : '';
}
const allowAnalytics = settings.enableAnalytics || userSession?.hashedUserId;
const allowAnalytics = settings.enableAnalytics || userSession?.hashedAccountId;
if (allowAnalytics) {
try {
const anonymousId = await getDeviceId() ?? '';
Expand All @@ -85,7 +85,7 @@ export async function trackSegmentEvent(
properties,
context,
anonymousId,
userId: userSession?.hashedUserId || '',
userId: userSession?.hashedAccountId || '',
}, error => {
if (error) {
console.warn('[analytics] Error sending segment event', error);
Expand All @@ -100,11 +100,11 @@ export async function trackSegmentEvent(
export async function trackPageView(name: string) {
const settings = await models.settings.getOrCreate();
const userSession = await models.userSession.getOrCreate();
if (!userSession?.hashedUserId) {
userSession.hashedUserId = userSession?.accountId ? hashString(userSession.accountId) : '';
if (!userSession?.hashedAccountId) {
userSession.hashedAccountId = userSession?.accountId ? hashString(userSession.accountId) : '';
}

const allowAnalytics = settings.enableAnalytics || userSession?.hashedUserId;
const allowAnalytics = settings.enableAnalytics || userSession?.hashedAccountId;
if (allowAnalytics) {
try {
const anonymousId = await getDeviceId() ?? '';
Expand All @@ -113,7 +113,7 @@ export async function trackPageView(name: string) {
os: { name: _getOsName(), version: process.getSystemVersion() },
};

analytics.page({ name, context, anonymousId, userId: userSession?.hashedUserId }, error => {
analytics.page({ name, context, anonymousId, userId: userSession?.hashedAccountId }, error => {
if (error) {
console.warn('[analytics] Error sending segment event', error);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/insomnia/src/models/user-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface BaseUserSession {
};

export interface HashedUserSession {
hashedUserId: string;
hashedAccountId: string;
}

export type UserSession = BaseModel & BaseUserSession & HashedUserSession;
Expand Down

0 comments on commit 9e12aa7

Please sign in to comment.