Skip to content

Commit 237ba16

Browse files
authored
fix: do not render HTML content (#196)
* fix: do not render HTML content * fix: address feedback
1 parent afa47e7 commit 237ba16

18 files changed

+97
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## Next
22

3+
- fix: don't render HTML content ([#196](https://github.com/PostHog/posthog-flutter/pull/196))
4+
35
## 5.3.0
46

57
- chore: update languageVersion and apiVersion from 1.6 to 1.8 on Android to be compatible with Kotlin 2.2 ([#193](https://github.com/PostHog/posthog-flutter/pull/193))

ios/Classes/PostHogDisplaySurvey+Dict.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
"question": question.question,
1515
"isOptional": question.isOptional,
1616
]
17+
1718
if let desc = question.questionDescription {
1819
questionDict["questionDescription"] = desc
20+
questionDict["questionDescriptionContentType"] = question.questionDescriptionContentType.rawValue
1921
}
2022
if let buttonText = question.buttonText {
2123
questionDict["buttonText"] = buttonText
@@ -84,6 +86,7 @@
8486
}
8587
if let thankYouMessageDescription = appearance.thankYouMessageDescription {
8688
appearanceDict["thankYouMessageDescription"] = thankYouMessageDescription
89+
appearanceDict["thankYouMessageDescriptionContentType"] = appearance.thankYouMessageDescriptionContentType?.rawValue
8790
}
8891
if let thankYouMessageCloseButtonText = appearance.thankYouMessageCloseButtonText {
8992
appearanceDict["thankYouMessageCloseButtonText"] = thankYouMessageCloseButtonText

ios/posthog_flutter.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ Postog flutter plugin
2121
s.ios.dependency 'Flutter'
2222
s.osx.dependency 'FlutterMacOS'
2323

24-
# ~> Version 3.29.0 up to, but not including, 4.0.0
25-
s.dependency 'PostHog', '~> 3.29'
24+
# ~> Version 3.30.1 up to, but not including, 4.0.0
25+
s.dependency 'PostHog', '>= 3.30.1', '< 4.0.0'
2626

2727
s.ios.deployment_target = '13.0'
2828
# PH iOS SDK 3.0.0 requires >= 10.15

lib/src/surveys/models/posthog_display_choice_question.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class PostHogDisplayChoiceQuestion extends PostHogDisplaySurveyQuestion {
1212
this.hasOpenChoice = false,
1313
this.shuffleOptions = false,
1414
super.description,
15+
super.descriptionContentType,
1516
super.optional,
1617
super.buttonText,
1718
}) : super(

lib/src/surveys/models/posthog_display_link_question.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class PostHogDisplayLinkQuestion extends PostHogDisplaySurveyQuestion {
99
required super.question,
1010
required this.link,
1111
super.description,
12+
super.descriptionContentType,
1213
super.optional,
1314
super.buttonText,
1415
}) : super(

lib/src/surveys/models/posthog_display_open_question.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class PostHogDisplayOpenQuestion extends PostHogDisplaySurveyQuestion {
88
const PostHogDisplayOpenQuestion({
99
required super.question,
1010
super.description,
11+
super.descriptionContentType,
1112
super.optional,
1213
super.buttonText,
1314
}) : super(

lib/src/surveys/models/posthog_display_rating_question.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class PostHogDisplayRatingQuestion extends PostHogDisplaySurveyQuestion {
1414
required this.lowerBoundLabel,
1515
required this.upperBoundLabel,
1616
super.description,
17+
super.descriptionContentType,
1718
super.optional,
1819
super.buttonText,
1920
}) : super(

lib/src/surveys/models/posthog_display_survey.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'posthog_display_link_question.dart';
66
import 'posthog_display_rating_question.dart';
77
import 'posthog_display_choice_question.dart';
88
import 'posthog_display_survey_appearance.dart';
9+
import 'posthog_display_survey_text_content_type.dart';
910

1011
/// Main survey model containing metadata and questions
1112
@immutable
@@ -18,6 +19,12 @@ class PostHogDisplaySurvey {
1819
final question = q['question'] as String;
1920
final optional = q['isOptional'] as bool;
2021
final questionDescription = q['questionDescription'] as String?;
22+
// Extract content type values with fallback to text (1)
23+
final questionContentTypeRaw =
24+
q['questionDescriptionContentType'] as int? ?? 1;
25+
final questionDescriptionContentType =
26+
PostHogDisplaySurveyTextContentType.fromInt(questionContentTypeRaw);
27+
2128
final buttonText = q['buttonText'] as String?;
2229

2330
switch (type) {
@@ -26,6 +33,7 @@ class PostHogDisplaySurvey {
2633
question: question,
2734
link: q['link'] as String,
2835
description: questionDescription,
36+
descriptionContentType: questionDescriptionContentType,
2937
optional: optional,
3038
buttonText: buttonText,
3139
);
@@ -39,6 +47,7 @@ class PostHogDisplaySurvey {
3947
lowerBoundLabel: q['lowerBoundLabel'] as String,
4048
upperBoundLabel: q['upperBoundLabel'] as String,
4149
description: questionDescription,
50+
descriptionContentType: questionDescriptionContentType,
4251
optional: optional,
4352
buttonText: buttonText,
4453
);
@@ -51,6 +60,7 @@ class PostHogDisplaySurvey {
5160
hasOpenChoice: q['hasOpenChoice'] as bool,
5261
shuffleOptions: q['shuffleOptions'] as bool,
5362
description: questionDescription,
63+
descriptionContentType: questionDescriptionContentType,
5464
optional: optional,
5565
buttonText: buttonText,
5666
);
@@ -59,6 +69,7 @@ class PostHogDisplaySurvey {
5969
return PostHogDisplayOpenQuestion(
6070
question: question,
6171
description: questionDescription,
72+
descriptionContentType: questionDescriptionContentType,
6273
optional: optional,
6374
buttonText: buttonText,
6475
);
@@ -68,6 +79,13 @@ class PostHogDisplaySurvey {
6879
PostHogDisplaySurveyAppearance? appearance;
6980
if (dict['appearance'] != null) {
7081
final a = Map<String, dynamic>.from(dict['appearance'] as Map);
82+
83+
// Extract thank you message content type with fallback to text (1)
84+
final thankYouContentTypeRaw =
85+
a['thankYouMessageDescriptionContentType'] as int? ?? 1;
86+
final thankYouMessageDescriptionContentType =
87+
PostHogDisplaySurveyTextContentType.fromInt(thankYouContentTypeRaw);
88+
7189
appearance = PostHogDisplaySurveyAppearance(
7290
fontFamily: a['fontFamily'] as String?,
7391
backgroundColor: a['backgroundColor'] as String?,
@@ -82,6 +100,8 @@ class PostHogDisplaySurvey {
82100
displayThankYouMessage: a['displayThankYouMessage'] as bool? ?? true,
83101
thankYouMessageHeader: a['thankYouMessageHeader'] as String?,
84102
thankYouMessageDescription: a['thankYouMessageDescription'] as String?,
103+
thankYouMessageDescriptionContentType:
104+
thankYouMessageDescriptionContentType,
85105
thankYouMessageCloseButtonText:
86106
a['thankYouMessageCloseButtonText'] as String?,
87107
);

lib/src/surveys/models/posthog_display_survey_appearance.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/foundation.dart';
2+
import 'posthog_display_survey_text_content_type.dart';
23

34
/// Appearance configuration for surveys
45
@immutable
@@ -17,6 +18,7 @@ class PostHogDisplaySurveyAppearance {
1718
this.displayThankYouMessage = true,
1819
this.thankYouMessageHeader,
1920
this.thankYouMessageDescription,
21+
this.thankYouMessageDescriptionContentType,
2022
this.thankYouMessageCloseButtonText,
2123
});
2224

@@ -33,5 +35,7 @@ class PostHogDisplaySurveyAppearance {
3335
final bool displayThankYouMessage;
3436
final String? thankYouMessageHeader;
3537
final String? thankYouMessageDescription;
38+
final PostHogDisplaySurveyTextContentType?
39+
thankYouMessageDescriptionContentType;
3640
final String? thankYouMessageCloseButtonText;
3741
}

lib/src/surveys/models/posthog_display_survey_question.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/foundation.dart';
22
import 'posthog_survey_question_type.dart';
3+
import 'posthog_display_survey_text_content_type.dart';
34

45
/// Base class for all survey questions
56
@immutable
@@ -8,13 +9,15 @@ abstract class PostHogDisplaySurveyQuestion {
89
required this.type,
910
required this.question,
1011
this.description,
12+
this.descriptionContentType = PostHogDisplaySurveyTextContentType.text,
1113
this.optional = false,
1214
this.buttonText,
1315
});
1416

1517
final PostHogSurveyQuestionType type;
1618
final String question;
1719
final String? description;
20+
final PostHogDisplaySurveyTextContentType descriptionContentType;
1821
final bool optional;
1922
final String? buttonText;
2023
}

0 commit comments

Comments
 (0)