8000 Fix Telemetry Logger attachments (#1888) · jayryanj/botbuilder-python@16f55f8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 16f55f8

Browse files
iKnowRamaxelsrz
andauthored
Fix Telemetry Logger attachments (microsoft#1888)
* Fix Telemetry Logger attachments * ran black & pylint * fix build errors * fix black formatting build error * fix pylint import order Co-authored-by: Axel Suárez <axsuarez@microsoft.com>
1 parent e90f08c commit 16f55f8

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

libraries/botbuilder-core/botbuilder/core/telemetry_logger_middleware.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# Licensed under the MIT License.
33
"""Middleware Component for logging Activity messages."""
44
from typing import Awaitable, Callable, List, Dict
5+
from jsonpickle import encode
6+
57
from botbuilder.schema import Activity, ConversationReference, ActivityTypes
68
from botbuilder.schema.teams import TeamsChannelData, TeamInfo
79
from botframework.connector import Channels
@@ -33,7 +35,7 @@ def telemetry_client(self) -> BotTelemetryClient:
3335

3436
@property
3537
def log_personal_information(self) -> bool:
36-
""" Gets a value indicating whether determines whether to log personal
38+
"""Gets a value indicating whether determines whether to log personal
3739
information that came from the user."""
3840
return self._log_personal_information
3941

@@ -217,10 +219,10 @@ async def fill_send_event_properties(
217219

218220
# Use the LogPersonalInformation flag to toggle logging PII data, text and user name are common examples
219221
if self.log_personal_information:
220-
if activity.attachments and activity.attachments.strip():
221-
properties[
222-
TelemetryConstants.ATTACHMENTS_PROPERTY
223-
] = activity.attachments
222+
if activity.attachments and len(activity.attachments) > 0:
223+
properties[TelemetryConstants.ATTACHMENTS_PROPERTY] = encode(
224+
activity.attachments
225+
)
224226
if activity.from_property.name and activity.from_property.name.strip():
225227
properties[
226228
TelemetryConstants.FROM_NAME_PROPERTY

0 commit comments

Comments
 (0)
0