Skip to content
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

Merged
merged 16 commits into from
Nov 30, 2017

Conversation

nwhitmont
Copy link
Contributor

No description provided.

@nwhitmont nwhitmont added the Enhancement New feature or request to evolve an additional feature label Nov 17, 2017
@nwhitmont nwhitmont self-assigned this Nov 17, 2017
Copy link
Member

@carlosscastro carlosscastro left a 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/')
Copy link
Member

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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

Copy link
Contributor Author

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

@nwhitmont
Copy link
Contributor Author

@carlosscastro @eanders-ms

  • Warning text updated.
  • docs links replaced with aka.ms URLs

@@ -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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check for undefined conversation

Copy link
Contributor Author

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Copy link
Contributor Author

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')
Copy link
Contributor

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.

Copy link
Contributor

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.

// 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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to stateApiDeprecationWarningShown

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

@eanders-ms eanders-ms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see comments

@danmarshall danmarshall changed the title Add Bot State API depreciation warning Add Bot State API deprecation warning Nov 17, 2017
@nwhitmont nwhitmont removed the request for review from tomlm November 17, 2017 22:33
@nwhitmont
Copy link
Contributor Author

updated

@nwhitmont
Copy link
Contributor Author

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')
Copy link
Contributor

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Copy link
Contributor Author

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 eanders-ms removed the Enhancement New feature or request to evolve an additional feature label Nov 28, 2017
@nwhitmont
Copy link
Contributor Author

@eanders-ms warning message has been hyperlinked per feedback.

@eanders-ms
Copy link
Contributor

@nwhitmont, Can you please update the warning with this text:

Warning: The Bot Framework State API is not recommended for production environments, and may be deprecated in a future release. Learn how to implement your own storage adapter.

where

Learn how to implement your own storage adapter.

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');
Copy link
Contributor

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.

Copy link
Contributor

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) {
Copy link
Contributor

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

@stevengum stevengum Nov 30, 2017

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) {
Copy link
Contributor

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) { ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants