Repository: Yoctol/bottender
Pull request #557 (2019-12-03 04:00:31)

implement skipLegacyProfile for Telegram and Viber
- rename `skipProfile` to `skipLegacyProfile` and set to true by default
- implement `skipLegacyProfile` for Telegram and Viber

codecov-io: # [Codecov](https://codecov.io/gh/Yoctol/bottender/pull/557?src=pr&el=h1) Report
> Merging [#557](https://codecov.io/gh/Yoctol/bottender/pull/557?src=pr&el=desc) into [master](https://codecov.io/gh/Yoctol/bottender/commit/2177ad62d46f2e632feda47c0d80bac5f438f470?src=pr&el=desc) will **decrease** coverage by `0.02%`.
> The diff coverage is `91.48%`.

[![Impacted file tree graph](https://codecov.io/gh/Yoctol/bottender/pull/557/graphs/tree.svg?width=650&token=JX3EGtxYH3&height=150&src=pr)](https://codecov.io/gh/Yoctol/bottender/pull/557?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #557      +/-   ##
==========================================
- Coverage   82.01%   81.99%   -0.03%     
==========================================
  Files          97       97              
  Lines        3954     3976      +22     
  Branches      949      966      +17     
==========================================
+ Hits         3243     3260      +17     
  Misses        677      677              
- Partials       34       39       +5
```


| [Impacted Files](https://codecov.io/gh/Yoctol/bottender/pull/557?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [packages/bottender/src/messenger/MessengerBot.ts](https://codecov.io/gh/Yoctol/bottender/pull/557/diff?src=pr&el=tree#diff-cGFja2FnZXMvYm90dGVuZGVyL3NyYy9tZXNzZW5nZXIvTWVzc2VuZ2VyQm90LnRz) | `100% <ø> (ø)` | :arrow_up: |
| [packages/bottender/src/line/LineBot.ts](https://codecov.io/gh/Yoctol/bottender/pull/557/diff?src=pr&el=tree#diff-cGFja2FnZXMvYm90dGVuZGVyL3NyYy9saW5lL0xpbmVCb3QudHM=) | `100% <ø> (ø)` | :arrow_up: |
| [packages/bottender/src/slack/SlackBot.ts](https://codecov.io/gh/Yoctol/bottender/pull/557/diff?src=pr&el=tree#diff-cGFja2FnZXMvYm90dGVuZGVyL3NyYy9zbGFjay9TbGFja0JvdC50cw==) | `100% <ø> (ø)` | :arrow_up: |
| [packages/bottender/src/slack/SlackConnector.ts](https://codecov.io/gh/Yoctol/bottender/pull/557/diff?src=pr&el=tree#diff-cGFja2FnZXMvYm90dGVuZGVyL3NyYy9zbGFjay9TbGFja0Nvbm5lY3Rvci50cw==) | `92.15% <100%> (+0.07%)` | :arrow_up: |
| [packages/bottender/src/line/LineConnector.ts](https://codecov.io/gh/Yoctol/bottender/pull/557/diff?src=pr&el=tree#diff-cGFja2FnZXMvYm90dGVuZGVyL3NyYy9saW5lL0xpbmVDb25uZWN0b3IudHM=) | `92.7% <100%> (+0.07%)` | :arrow_up: |
| [...ages/bottender/src/messenger/MessengerConnector.ts](https://codecov.io/gh/Yoctol/bottender/pull/557/diff?src=pr&el=tree#diff-cGFja2FnZXMvYm90dGVuZGVyL3NyYy9tZXNzZW5nZXIvTWVzc2VuZ2VyQ29ubmVjdG9yLnRz) | `91.86% <100%> (-0.76%)` | :arrow_down: |
| [packages/bottender/src/viber/ViberConnector.ts](https://codecov.io/gh/Yoctol/bottender/pull/557/diff?src=pr&el=tree#diff-cGFja2FnZXMvYm90dGVuZGVyL3NyYy92aWJlci9WaWJlckNvbm5lY3Rvci50cw==) | `85.45% <75%> (-2.05%)` | :arrow_down: |
| [...ckages/bottender/src/telegram/TelegramConnector.ts](https://codecov.io/gh/Yoctol/bottender/pull/557/diff?src=pr&el=tree#diff-cGFja2FnZXMvYm90dGVuZGVyL3NyYy90ZWxlZ3JhbS9UZWxlZ3JhbUNvbm5lY3Rvci50cw==) | `96.47% <92.59%> (-2.16%)` | :arrow_down: |
| [packages/create-bottender-app/src/shared/log.ts](https://codecov.io/gh/Yoctol/bottender/pull/557/diff?src=pr&el=tree#diff-cGFja2FnZXMvY3JlYXRlLWJvdHRlbmRlci1hcHAvc3JjL3NoYXJlZC9sb2cudHM=) | `0% <0%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/Yoctol/bottender/pull/557?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/Yoctol/bottender/pull/557?src=pr&el=footer). Last update [2177ad6...9e053b3](https://codecov.io/gh/Yoctol/bottender/pull/557?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/packages/bottender/src/line/LineBot.ts b/packages/bottender/src/line/LineBot.ts
index 59a18bf4..3ea77c48 100644
--- a/packages/bottender/src/line/LineBot.ts
+++ b/packages/bottender/src/line/LineBot.ts
@@ -20,7 +20,7 @@ export default class LineBot extends Bot<
     mapDestinationToAccessToken,
     shouldBatch,
     sendMethod,
-    skipProfile,
+    skipLegacyProfile,
   }: {
     accessToken: string;
     channelSecret: string;
@@ -30,7 +30,7 @@ export default class LineBot extends Bot<
     shouldBatch?: boolean;
     sendMethod?: string;
     origin?: string;
-    skipProfile?: boolean;
+    skipLegacyProfile?: boolean;
   }) {
     const connector = new LineConnector({
       accessToken,
@@ -39,7 +39,7 @@ export default class LineBot extends Bot<
       shouldBatch,
       sendMethod,
       origin,
-      skipProfile,
+      skipLegacyProfile,
     });
     super({ connector, sessionStore, sync });
   }
diff --git a/packages/bottender/src/line/LineConnector.ts b/packages/bottender/src/line/LineConnector.ts
index 25506a1f..62e5492a 100644
--- a/packages/bottender/src/line/LineConnector.ts
+++ b/packages/bottender/src/line/LineConnector.ts
@@ -20,7 +20,7 @@ type CommonConstructorOptions = {
   mapDestinationToAccessToken?: (destination: string) => Promise<string>;
   shouldBatch?: boolean;
   sendMethod?: string;
-  skipProfile?: boolean;
+  skipLegacyProfile?: boolean;
 };
 
 type ConstructorOptionsWithoutClient = {
@@ -43,7 +43,7 @@ export default class LineConnector
 
   _channelSecret: string;
 
-  _skipProfile: boolean;
+  _skipLegacyProfile: boolean;
 
   _mapDestinationToAccessToken:
     | ((destination: string) => Promise<string>)
@@ -58,7 +58,7 @@ export default class LineConnector
       mapDestinationToAccessToken,
       shouldBatch,
       sendMethod,
-      skipProfile,
+      skipLegacyProfile,
     } = options;
     if ('client' in options) {
       this._client = options.client;
@@ -85,8 +85,8 @@ export default class LineConnector
     );
     this._sendMethod = sendMethod || 'reply';
 
-    // FIXME: maybe set this default value as true
-    this._skipProfile = typeof skipProfile === 'boolean' ? skipProfile : false;
+    this._skipLegacyProfile =
+      typeof skipLegacyProfile === 'boolean' ? skipLegacyProfile : true;
   }
 
   _isWebhookVerifyEvent(event: LineRawEvent): boolean {
@@ -140,7 +140,7 @@ export default class LineConnector
       let user = null;
 
       if (source.userId) {
-        user = this._skipProfile
+        user = this._skipLegacyProfile
           ? {
               id: source.userId,
               _updatedAt: new Date().toISOString(),
@@ -176,7 +176,7 @@ export default class LineConnector
       let user = null;
 
       if (source.userId) {
-        user = this._skipProfile
+        user = this._skipLegacyProfile
           ? {
               id: source.userId,
               _updatedAt: new Date().toISOString(),
@@ -210,7 +210,7 @@ export default class LineConnector
       };
     } else if (source.type === 'user') {
       if (!session.user) {
-        const user = this._skipProfile
+        const user = this._skipLegacyProfile
           ? {}
           : await this._client.getUserProfile(source.userId);
 
diff --git a/packages/bottender/src/messenger/MessengerBot.ts b/packages/bottender/src/messenger/MessengerBot.ts
index e495ecd7..73cd822c 100644
--- a/packages/bottender/src/messenger/MessengerBot.ts
+++ b/packages/bottender/src/messenger/MessengerBot.ts
@@ -22,7 +22,7 @@ export default class MessengerBot extends Bot<
     batchConfig,
     origin,
     skipAppSecretProof,
-    skipProfile,
+    skipLegacyProfile,
   }: {
     accessToken: string;
     appId: string;
@@ -34,7 +34,7 @@ export default class MessengerBot extends Bot<
     batchConfig?: Record<string, any>;
     origin?: string;
     skipAppSecretProof?: boolean;
-    skipProfile?: boolean;
+    skipLegacyProfile?: boolean;
   }) {
     const connector = new MessengerConnector({
       accessToken,
@@ -45,7 +45,7 @@ export default class MessengerBot extends Bot<
       batchConfig,
       origin,
       skipAppSecretProof,
-      skipProfile,
+      skipLegacyProfile,
     });
     super({ connector, sessionStore, sync });
   }
diff --git a/packages/bottender/src/messenger/MessengerConnector.ts b/packages/bottender/src/messenger/MessengerConnector.ts
index fcddbe4b..c2e34e92 100644
--- a/packages/bottender/src/messenger/MessengerConnector.ts
+++ b/packages/bottender/src/messenger/MessengerConnector.ts
@@ -81,7 +81,7 @@ type CommonConstructorOptions = {
   appSecret: string;
   verifyToken?: string;
   batchConfig?: Record<string, any>;
-  skipProfile?: boolean;
+  skipLegacyProfile?: boolean;
   mapPageToAccessToken?: (pageId: string) => Promise<string>;
 };
 
@@ -107,7 +107,7 @@ export default class MessengerConnector
 
   _appSecret: string;
 
-  _skipProfile: boolean;
+  _skipLegacyProfile: boolean;
 
   _mapPageToAccessToken: ((pageId: string) => Promise<string>) | null = null;
 
@@ -125,7 +125,7 @@ export default class MessengerConnector
       verifyToken,
       batchConfig,
 
-      skipProfile,
+      skipLegacyProfile,
     } = options;
 
     if ('client' in options) {
@@ -146,8 +146,8 @@ export default class MessengerConnector
     this._mapPageToAccessToken = mapPageToAccessToken || null;
     this._verifyToken = verifyToken || shortid.generate();
 
-    // FIXME: maybe set this default value as true
-    this._skipProfile = typeof skipProfile === 'boolean' ? skipProfile : false;
+    this._skipLegacyProfile =
+      typeof skipLegacyProfile === 'boolean' ? skipLegacyProfile : true;
 
     this._batchConfig = batchConfig || null;
     if (this._batchConfig) {
@@ -273,7 +273,7 @@ export default class MessengerConnector
       }
 
       // FIXME: refine user
-      if (this._skipProfile) {
+      if (this._skipLegacyProfile) {
         session.user = {
           _updatedAt: new Date().toISOString(),
           id: senderId,
diff --git a/packages/bottender/src/slack/SlackBot.ts b/packages/bottender/src/slack/SlackBot.ts
index 29ba7554..fdfa9dfe 100644
--- a/packages/bottender/src/slack/SlackBot.ts
+++ b/packages/bottender/src/slack/SlackBot.ts
@@ -20,20 +20,20 @@ export default class SlackBot extends Bot<
     sync,
     verificationToken,
     origin,
-    skipProfile,
+    skipLegacyProfile,
   }: {
     accessToken: string;
     sessionStore: SessionStore;
     sync?: boolean;
     verificationToken?: string;
     origin?: string;
-    skipProfile?: boolean | null;
+    skipLegacyProfile?: boolean | null;
   }) {
     const connector = new SlackConnector({
       accessToken,
       verificationToken,
       origin,
-      skipProfile,
+      skipLegacyProfile,
     });
     super({ connector, sessionStore, sync });
     this._accessToken = accessToken;
diff --git a/packages/bottender/src/slack/SlackConnector.ts b/packages/bottender/src/slack/SlackConnector.ts
index ca6ac5c5..3624ecbc 100644
--- a/packages/bottender/src/slack/SlackConnector.ts
+++ b/packages/bottender/src/slack/SlackConnector.ts
@@ -37,7 +37,7 @@ type EventsAPIBody = {
 export type SlackRequestBody = EventsAPIBody | { payload: string };
 
 type CommonConstructorOptions = {
-  skipProfile?: boolean | null;
+  skipLegacyProfile?: boolean | null;
   verificationToken?: string;
 };
 
@@ -60,10 +60,10 @@ export default class SlackConnector
 
   _verificationToken: string;
 
-  _skipProfile: boolean;
+  _skipLegacyProfile: boolean;
 
   constructor(options: ConstructorOptions) {
-    const { verificationToken, skipProfile } = options;
+    const { verificationToken, skipLegacyProfile } = options;
     if ('client' in options) {
       this._client = options.client;
     } else {
@@ -76,8 +76,8 @@ export default class SlackConnector
 
     this._verificationToken = verificationToken || '';
 
-    // FIXME: maybe set this default value as true
-    this._skipProfile = typeof skipProfile === 'boolean' ? skipProfile : false;
+    this._skipLegacyProfile =
+      typeof skipLegacyProfile === 'boolean' ? skipLegacyProfile : true;
 
     if (!this._verificationToken) {
       warning(
@@ -181,7 +181,7 @@ export default class SlackConnector
       return;
     }
 
-    if (this._skipProfile) {
+    if (this._skipLegacyProfile) {
       session.user = {
         id: senderId,
         _updatedAt: new Date().toISOString(),
diff --git a/packages/bottender/src/telegram/TelegramConnector.ts b/packages/bottender/src/telegram/TelegramConnector.ts
index 61e08772..f2015390 100644
--- a/packages/bottender/src/telegram/TelegramConnector.ts
+++ b/packages/bottender/src/telegram/TelegramConnector.ts
@@ -14,10 +14,12 @@ export type TelegramRequestBody = TelegramRawEvent;
 type ConstructorOptionsWithoutClient = {
   accessToken: string;
   origin?: string;
+  skipLegacyProfile?: boolean;
 };
 
 type ConstructorOptionsWithClient = {
   client: TelegramClient;
+  skipLegacyProfile?: boolean;
 };
 
 type ConstructorOptions =
@@ -28,7 +30,10 @@ export default class TelegramConnector
   implements Connector<TelegramRequestBody, TelegramClient> {
   _client: TelegramClient;
 
+  _skipLegacyProfile: boolean;
+
   constructor(options: ConstructorOptions) {
+    const { skipLegacyProfile } = options;
     if ('client' in options) {
       this._client = options.client;
     } else {
@@ -39,6 +44,9 @@ export default class TelegramConnector
         origin,
       });
     }
+
+    this._skipLegacyProfile =
+      typeof skipLegacyProfile === 'boolean' ? skipLegacyProfile : true;
   }
 
   _getRawEventFromRequest(body: TelegramRequestBody): TelegramRawEvent {
@@ -91,12 +99,21 @@ export default class TelegramConnector
     session: Session,
     body: TelegramRequestBody
   ): Promise<void> {
+    let channel;
     if (body.channelPost) {
-      session.channel = body.channelPost.chat;
+      channel = body.channelPost.chat;
     } else if (body.editedChannelPost) {
-      session.channel = body.editedChannelPost.chat;
+      channel = body.editedChannelPost.chat;
     }
-    if (session.channel) {
+
+    if (channel) {
+      if (this._skipLegacyProfile) {
+        session.channel = {
+          id: channel.id,
+        };
+      } else {
+        session.channel = channel;
+      }
       session.channel._updatedAt = new Date().toISOString();
       Object.freeze(session.channel);
     }
@@ -107,18 +124,26 @@ export default class TelegramConnector
       value: session.channel,
     });
 
+    let group;
     if (body.message && body.message.chat.type === 'group') {
-      session.group = body.message.chat;
+      group = body.message.chat;
     } else if (body.editedMessage && body.editedMessage.chat.type === 'group') {
-      session.group = body.editedMessage.chat;
+      group = body.editedMessage.chat;
     } else if (
       body.callbackQuery &&
       body.callbackQuery.message &&
       body.callbackQuery.message.chat.type === 'group'
     ) {
-      session.group = body.callbackQuery.message.chat;
-    }
-    if (session.group) {
+      group = body.callbackQuery.message.chat;
+    }
+    if (group) {
+      if (this._skipLegacyProfile) {
+        session.group = {
+          id: group.id,
+        };
+      } else {
+        session.group = group;
+      }
       session.group._updatedAt = new Date().toISOString();
       Object.freeze(session.group);
     }
@@ -129,23 +154,31 @@ export default class TelegramConnector
       value: session.group,
     });
 
+    let user;
     if (body.message) {
-      session.user = body.message.from;
+      user = body.message.from;
     } else if (body.editedMessage) {
-      session.user = body.editedMessage.from;
+      user = body.editedMessage.from;
     } else if (body.inlineQuery) {
-      session.user = body.inlineQuery.from;
+      user = body.inlineQuery.from;
     } else if (body.chosenInlineResult) {
-      session.user = body.chosenInlineResult.from;
+      user = body.chosenInlineResult.from;
     } else if (body.callbackQuery) {
-      session.user = body.callbackQuery.from;
+      user = body.callbackQuery.from;
     } else if (body.shippingQuery) {
-      session.user = body.shippingQuery.from;
+      user = body.shippingQuery.from;
     } else if (body.preCheckoutQuery) {
-      session.user = body.preCheckoutQuery.from;
+      user = body.preCheckoutQuery.from;
     }
 
-    if (session.user) {
+    if (user) {
+      if (this._skipLegacyProfile) {
+        session.user = {
+          id: user.id,
+        };
+      } else {
+        session.user = user;
+      }
       session.user._updatedAt = new Date().toISOString();
       Object.freeze(session.user);
     }
diff --git a/packages/bottender/src/viber/ViberConnector.ts b/packages/bottender/src/viber/ViberConnector.ts
index 0f52a046..2a82b290 100644
--- a/packages/bottender/src/viber/ViberConnector.ts
+++ b/packages/bottender/src/viber/ViberConnector.ts
@@ -17,10 +17,12 @@ type ConstructorOptionsWithoutClient = {
   accessToken: string;
   sender: ViberTypes.Sender;
   origin?: string;
+  skipLegacyProfile?: boolean;
 };
 
 type ConstructorOptionsWithClient = {
   client: ViberClient;
+  skipLegacyProfile?: boolean;
 };
 
 type ConstructorOptions =
@@ -33,7 +35,10 @@ export default class ViberConnector
 
   _client: ViberClient;
 
+  _skipLegacyProfile: boolean;
+
   constructor(options: ConstructorOptions) {
+    const { skipLegacyProfile } = options;
     if ('client' in options) {
       this._client = options.client;
     } else {
@@ -50,6 +55,8 @@ export default class ViberConnector
     }
 
     this._accessToken = this._client.accessToken;
+    this._skipLegacyProfile =
+      typeof skipLegacyProfile === 'boolean' ? skipLegacyProfile : true;
   }
 
   _getRawEventFromRequest(body: ViberRequestBody): ViberRawEvent {
@@ -104,7 +111,14 @@ export default class ViberConnector
         break;
     }
 
-    if (Object.keys(addedDiff(session.user || {}, user as any)).length > 0) {
+    if (this._skipLegacyProfile) {
+      session.user = {
+        _updatedAt: new Date().toISOString(),
+        id: (user || {}).id,
+      };
+    } else if (
+      Object.keys(addedDiff(session.user || {}, user as any)).length > 0
+    ) {
       session.user = {
         ...session.user,
         ...user,


Test patch:
diff --git a/packages/bottender/src/line/__tests__/LineConnector.spec.ts b/packages/bottender/src/line/__tests__/LineConnector.spec.ts
index a4ebb3cf..8f64f043 100644
--- a/packages/bottender/src/line/__tests__/LineConnector.spec.ts
+++ b/packages/bottender/src/line/__tests__/LineConnector.spec.ts
@@ -82,7 +82,7 @@ const webhookVerifyRequest = {
   },
 };
 
-function setup({ sendMethod, skipProfile } = {}) {
+function setup({ sendMethod, skipLegacyProfile } = {}) {
   const mockLineAPIClient = {
     getUserProfile: jest.fn(),
     isValidSignature: jest.fn(),
@@ -99,7 +99,7 @@ function setup({ sendMethod, skipProfile } = {}) {
       accessToken: ACCESS_TOKEN,
       channelSecret: CHANNEL_SECRET,
       sendMethod,
-      skipProfile,
+      skipLegacyProfile,
     }),
   };
 }
@@ -209,7 +209,9 @@ describe('#getUniqueSessionKey', () => {
 
 describe('#updateSession', () => {
   it('update session with data needed', async () => {
-    const { connector, mockLineAPIClient } = setup();
+    const { connector, mockLineAPIClient } = setup({
+      skipLegacyProfile: false,
+    });
     const user = {
       id: 'U206d25c2ea6bd87c17655609a1c37cb8',
       displayName: 'LINE taro',
@@ -242,7 +244,9 @@ describe('#updateSession', () => {
   });
 
   it('update session if session.user exists', async () => {
-    const { connector, mockLineAPIClient } = setup();
+    const { connector, mockLineAPIClient } = setup({
+      skipLegacyProfile: false,
+    });
     const user = {
       id: 'U206d25c2ea6bd87c17655609a1c37cb8',
       displayName: 'LINE taro',
@@ -271,7 +275,9 @@ describe('#updateSession', () => {
   });
 
   it('update session with group type message', async () => {
-    const { connector, mockLineAPIClient } = setup();
+    const { connector, mockLineAPIClient } = setup({
+      skipLegacyProfile: false,
+    });
     const body = {
       events: [
         {
@@ -343,7 +349,9 @@ describe('#updateSession', () => {
   });
 
   it('update session with group type event without userId', async () => {
-    const { connector, mockLineAPIClient } = setup();
+    const { connector, mockLineAPIClient } = setup({
+      skipLegacyProfile: false,
+    });
     const body = {
       events: [
         {
@@ -398,7 +406,9 @@ describe('#updateSession', () => {
   });
 
   it('update session with room type message', async () => {
-    const { connector, mockLineAPIClient } = setup();
+    const { connector, mockLineAPIClient } = setup({
+      skipLegacyProfile: false,
+    });
     const body = {
       events: [
         {
@@ -470,7 +480,9 @@ describe('#updateSession', () => {
   });
 
   it('update session with room type event without userId', async () => {
-    const { connector, mockLineAPIClient } = setup();
+    const { connector, mockLineAPIClient } = setup({
+      skipLegacyProfile: false,
+    });
     const body = {
       events: [
         {
@@ -525,7 +537,9 @@ describe('#updateSession', () => {
   });
 
   it('update session with other type message', async () => {
-    const { connector } = setup();
+    const { connector } = setup({
+      skipLegacyProfile: false,
+    });
     const body = {
       events: [
         {
@@ -559,8 +573,8 @@ describe('#updateSession', () => {
     });
   });
 
-  it('update userId without calling any api while skipProfile setted true', async () => {
-    const { connector, mockLineAPIClient } = setup({ skipProfile: true });
+  it('update userId without calling any api while skipLegacyProfile set to true', async () => {
+    const { connector, mockLineAPIClient } = setup();
     const session = {};
 
     await connector.updateSession(session, request.body);
diff --git a/packages/bottender/src/messenger/__tests__/MessengerConnector.spec.ts b/packages/bottender/src/messenger/__tests__/MessengerConnector.spec.ts
index b2b446da..04c715fc 100644
--- a/packages/bottender/src/messenger/__tests__/MessengerConnector.spec.ts
+++ b/packages/bottender/src/messenger/__tests__/MessengerConnector.spec.ts
@@ -163,15 +163,13 @@ const webhookTestRequest = {
   },
 };
 
-function setup(
-  { accessToken, appSecret, mapPageToAccessToken, verifyToken, skipProfile } = {
-    accessToken: ACCESS_TOKEN,
-    appSecret: APP_SECRET,
-    mapPageToAccessToken: jest.fn(),
-    verifyToken: '1qaz2wsx',
-    skipProfile: false,
-  }
-) {
+function setup({
+  accessToken = ACCESS_TOKEN,
+  appSecret = APP_SECRET,
+  mapPageToAccessToken = jest.fn(),
+  verifyToken = '1qaz2wsx',
+  skipLegacyProfile = true,
+} = {}) {
   const mockGraphAPIClient = {
     getUserProfile: jest.fn(),
   };
@@ -184,7 +182,7 @@ function setup(
       appSecret,
       mapPageToAccessToken,
       verifyToken,
-      skipProfile,
+      skipLegacyProfile,
     }),
   };
 }
@@ -266,7 +264,9 @@ describe('#getUniqueSessionKey', () => {
 
 describe('#updateSession', () => {
   it('update session with data needed', async () => {
-    const { connector, mockGraphAPIClient } = setup();
+    const { connector, mockGraphAPIClient } = setup({
+      skipLegacyProfile: false,
+    });
     const user = {
       id: '1412611362105802',
       firstName: 'firstName',
@@ -298,7 +298,9 @@ describe('#updateSession', () => {
   });
 
   it('update session when profilePic expired', async () => {
-    const { connector, mockGraphAPIClient } = setup();
+    const { connector, mockGraphAPIClient } = setup({
+      skipLegacyProfile: false,
+    });
     const user = {
       id: '1412611362105802',
       firstName: 'firstName',
@@ -334,7 +336,9 @@ describe('#updateSession', () => {
   });
 
   it('update session when expired date is invalid', async () => {
-    const { connector, mockGraphAPIClient } = setup();
+    const { connector, mockGraphAPIClient } = setup({
+      skipLegacyProfile: false,
+    });
     const user = {
       id: '1412611362105802',
       firstName: 'firstName',
@@ -370,7 +374,9 @@ describe('#updateSession', () => {
   });
 
   it('update session when something wrong', async () => {
-    const { connector, mockGraphAPIClient } = setup();
+    const { connector, mockGraphAPIClient } = setup({
+      skipLegacyProfile: false,
+    });
     const user = {
       id: '1412611362105802',
       firstName: 'firstName',
@@ -406,7 +412,9 @@ describe('#updateSession', () => {
   });
 
   it('update session when getUserProfile() failed', async () => {
-    const { connector, mockGraphAPIClient } = setup();
+    const { connector, mockGraphAPIClient } = setup({
+      skipLegacyProfile: false,
+    });
     const error = new Error('fail');
 
     mockGraphAPIClient.getUserProfile.mockRejectedValue(error);
@@ -435,9 +443,9 @@ describe('#updateSession', () => {
     expect(console.error).toBeCalledWith(error);
   });
 
-  it(`update session without gettiing user's profile when skipProfile setted true`, async () => {
+  it(`update session without getting user's profile when skipLegacyProfile set to true`, async () => {
     const { connector, mockGraphAPIClient } = setup({
-      skipProfile: true,
+      skipLegacyProfile: true,
     });
 
     const session = {};
diff --git a/packages/bottender/src/slack/__tests__/SlackConnector.spec.ts b/packages/bottender/src/slack/__tests__/SlackConnector.spec.ts
index 19647578..0d326ae8 100644
--- a/packages/bottender/src/slack/__tests__/SlackConnector.spec.ts
+++ b/packages/bottender/src/slack/__tests__/SlackConnector.spec.ts
@@ -112,7 +112,7 @@ const RtmMessage = {
 
 function setup({
   verificationToken = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx',
-  skipProfile,
+  skipLegacyProfile,
 } = {}) {
   const mockSlackOAuthClient = {
     getUserInfo: jest.fn(),
@@ -126,7 +126,7 @@ function setup({
     connector: new SlackConnector({
       accessToken,
       verificationToken,
-      skipProfile,
+      skipLegacyProfile,
     }),
     mockSlackOAuthClient,
   };
@@ -188,7 +188,9 @@ describe('#getUniqueSessionKey', () => {
 
 describe('#updateSession', () => {
   it('update session with data needed', async () => {
-    const { connector, mockSlackOAuthClient } = setup();
+    const { connector, mockSlackOAuthClient } = setup({
+      skipLegacyProfile: false,
+    });
 
     const user = {
       id: 'U13A00000',
@@ -229,7 +231,9 @@ describe('#updateSession', () => {
   });
 
   it('not update session if it is bot event request', async () => {
-    const { connector, mockSlackOAuthClient } = setup();
+    const { connector, mockSlackOAuthClient } = setup({
+      skipLegacyProfile: false,
+    });
 
     const session = {};
 
@@ -243,7 +247,9 @@ describe('#updateSession', () => {
   });
 
   it('not update session if no senderId in body', async () => {
-    const { connector, mockSlackOAuthClient } = setup();
+    const { connector, mockSlackOAuthClient } = setup({
+      skipLegacyProfile: false,
+    });
 
     const session = {};
     const body = {
@@ -273,7 +279,9 @@ describe('#updateSession', () => {
   });
 
   it('update session with data needed when receiving interactive message request', async () => {
-    const { connector, mockSlackOAuthClient } = setup();
+    const { connector, mockSlackOAuthClient } = setup({
+      skipLegacyProfile: false,
+    });
 
     const user = {
       id: 'U056K3CN1',
@@ -313,8 +321,8 @@ describe('#updateSession', () => {
     });
   });
 
-  it('update session without calling apis while skipProfile setted true', async () => {
-    const { connector, mockSlackOAuthClient } = setup({ skipProfile: true });
+  it('update session without calling apis while skipLegacyProfile set true', async () => {
+    const { connector, mockSlackOAuthClient } = setup();
 
     const session = {};
 
diff --git a/packages/bottender/src/telegram/__tests__/TelegramConnector.spec.ts b/packages/bottender/src/telegram/__tests__/TelegramConnector.spec.ts
index cc080936..6ca71c38 100644
--- a/packages/bottender/src/telegram/__tests__/TelegramConnector.spec.ts
+++ b/packages/bottender/src/telegram/__tests__/TelegramConnector.spec.ts
@@ -293,7 +293,10 @@ function setup() {
   TelegramClient.connect.mockReturnValue(mockTelegramClient);
   return {
     mockTelegramClient,
-    connector: new TelegramConnector({ accessToken: ACCESS_TOKEN }),
+    connector: new TelegramConnector({
+      accessToken: ACCESS_TOKEN,
+      skipLegacyProfile: false,
+    }),
   };
 }
 
diff --git a/packages/bottender/src/viber/__tests__/ViberConnector.spec.ts b/packages/bottender/src/viber/__tests__/ViberConnector.spec.ts
index ca0a276b..d3bcdc27 100644
--- a/packages/bottender/src/viber/__tests__/ViberConnector.spec.ts
+++ b/packages/bottender/src/viber/__tests__/ViberConnector.spec.ts
@@ -114,6 +114,7 @@ function setup() {
     connector: new ViberConnector({
       accessToken: ACCESS_TOKEN,
       sender: { name: 'sender' },
+      skipLegacyProfile: false,
     }),
   };
 }