-
Notifications
You must be signed in to change notification settings - Fork 749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Bot State API deprecation warning #348
Add Bot State API deprecation warning #348
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice Nils!!! Just 2 minor comments on the text, the rest looks good to me (though I'm no emulator expert)
private logBotStateApiDepreciationWarning(botId: string, conversationId: string) { | ||
const conversation: Conversation = emulator.conversations.conversationById(botId, conversationId); | ||
if (!conversation.stateApiDepretiationWarningShown) { | ||
log.warn('The Bot State API has been depreciated. Please configure your own Bot State API. For more information see: https://blog.botframework.com/2017/07/21/saving-state-azure-nodejs/') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe "is being" instead of "has been" deprecated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The link should probably be to the documentation here:
C#: https://docs.microsoft.com/en-us/bot-framework/dotnet/bot-builder-dotnet-state-azure-table-storage
Node: https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-state-azure-table-storage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The links look kind of long but I like pointing to the docs. And also we should not make assumptions on whether they use c# or node so probably we need to link both
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created aka.ms URLs for both documentation links, and added ccastro && eanders as co-owners.
- aka.ms/bot-stateapi-dotnet
- aka.ms/bot-stateapi-nodejs
|
@@ -56,14 +58,23 @@ export class BotStateController { | |||
return `${botId || '*'}!${channelId || '*'}!${conversationId || '*'}!${userId || '*'}`; | |||
} | |||
|
|||
private logBotStateApiDepreciationWarning(botId: string, conversationId: string) { | |||
const conversation: Conversation = emulator.conversations.conversationById(botId, conversationId); | |||
if (!conversation.stateApiDepreciationWarningShown) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check for undefined conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
@@ -56,14 +58,23 @@ export class BotStateController { | |||
return `${botId || '*'}!${channelId || '*'}!${conversationId || '*'}!${userId || '*'}`; | |||
} | |||
|
|||
private logBotStateApiDepreciationWarning(botId: string, conversationId: string) { | |||
const conversation: Conversation = emulator.conversations.conversationById(botId, conversationId); | |||
if (!conversation.stateApiDepreciationWarningShown) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does stateApiDepreciationWarningShown
get set to true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
botStateController.ts
L64
private logBotStateApiDepreciationWarning(botId: string, conversationId: string) { | ||
const conversation: Conversation = emulator.conversations.conversationById(botId, conversationId); | ||
if (!conversation.stateApiDepreciationWarningShown) { | ||
log.warn('The Bot State API is being depreciated. Please configure your own Bot State API. For more information: .NET https://aka.ms/bot-stateapi-dotnet | Node.js https://aka.ms/bot-git stateapi-nodejs') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This word should be deprecated
, not depreciated
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The links in the message should be hyperlinked. Example how to do it:
log.warn(log.makeLinkMessage('Read about the Bot Framework authentication change.', 'https://aka.ms/botfxv32authchange'));
Also you can search the codebase for additional examples.
src/server/conversationManager.ts
Outdated
// flag indicating if the user has been shown the | ||
// "please don't use default Bot State API" warning message | ||
// when they try to write bot state data | ||
public stateApiDepreciationWarningShown: boolean = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to stateApiDeprecationWarningShown
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see comments
updated |
changed "depreciated" to "deprecated" in function and variable names |
} else { | ||
if (!conversation.stateApiDeprecationWarningShown) { | ||
conversation.stateApiDeprecationWarningShown = true; | ||
log.warn('The Bot State API is being depreciated. Please configure your own Bot State API. For more information: .NET https://aka.ms/bot-stateapi-dotnet | Node.js https://aka.ms/bot-stateapi-nodejs') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please hyperlink urls in the message (see my other comment for sample code).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
converted to single URL --> https://aka.ms/botframework-state-service
@eanders-ms warning message has been hyperlinked per feedback. |
@nwhitmont, Can you please update the warning with this text:
where
is the hyperlinked part. Thank you! |
private logBotStateApiDeprecationWarning(botId: string, conversationId: string) { | ||
const conversation: Conversation = emulator.conversations.conversationById(botId, conversationId); | ||
if (!conversation) { | ||
log.error('Error loading conversation object'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this line. A missing conversationId
value isn't an error. It is valid when the bot is getting/setting user data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, don't show the warning if you don't have a conversationId.
} | ||
} | ||
|
||
if (!conversation.stateApiDeprecationWarningShown) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code will crash when reading user data. Did you test locally before committing?
conversation.stateApiDeprecationWarningShown = true; | ||
log.warn('Warning: The Bot Framework State API is not recommended for production environments, and may be deprecated in a future release.', | ||
log.makeLinkMessage('Learn how to implement your own storage adapter.', 'https://aka.ms/botframework-state-service')); | ||
if (conversation) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please simplify this to a single line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there aren't any else
statements in this method, what about:
if (conversation && !conversation.stateApiDeprecationWarningShown) {
as opposed to
if (conversation) { if (!conversation.stateApiDeprecationWarningShown) {
@@ -56,14 +58,26 @@ export class BotStateController { | |||
return `${botId || '*'}!${channelId || '*'}!${conversationId || '*'}!${userId || '*'}`; | |||
} | |||
|
|||
private logBotStateApiDeprecationWarning(botId: string, conversationId: string) { | |||
const conversation: Conversation = emulator.conversations.conversationById(botId, conversationId); | |||
if (conversation) { if (!conversation.stateApiDeprecationWarningShown) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry I wasn't more clear. I was asking you to combine the two statements into a single statement:
if (conversation && !conversation.stateApiDeprecationWarningShown) { ...
No description provided.