Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Analytics opt in for posthog #6936

Merged
merged 83 commits into from
Dec 5, 2021
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
fdd8215
Make pseudonymousAnalyticsOptIn the new analytics opt in flag
novocaine Sep 15, 2021
b136599
Note that we send an Analytics ID
novocaine Sep 15, 2021
a90e49e
Remove "anonymous" term.
novocaine Sep 15, 2021
0178bcc
Toast shows explanation about re-opt-in if necessary
novocaine Sep 16, 2021
1942963
Merge remote-tracking branch 'origin' into analytics-pseudo-opt-in
novocaine Sep 16, 2021
e9f0741
stash wip
novocaine Sep 29, 2021
7def9c2
Merge remote-tracking branch 'origin' into analytics-pseudo-opt-in
novocaine Oct 13, 2021
ff0726d
fix lint
novocaine Oct 13, 2021
3547e91
Fix settings controller/level
novocaine Oct 13, 2021
c3b200b
Listen only to events from account data sync
novocaine Oct 13, 2021
d9ce993
fix toast on startup
novocaine Oct 13, 2021
6bd3c57
Toast display relies on sync events
novocaine Oct 14, 2021
d9baaca
Merge remote-tracking branch 'origin' into analytics-pseudo-opt-in
novocaine Oct 14, 2021
79c26bd
Fix toast behaviour
novocaine Oct 14, 2021
9e0f4a7
Pass flag into showToast so its up to date
novocaine Oct 14, 2021
fa19b8a
Explicitly check if showPrompt is true as well as waiting for events
novocaine Oct 14, 2021
a9fe002
slightly clarify comment
novocaine Oct 14, 2021
b85a44e
Revert to enabling old analytics off old flag
novocaine Oct 14, 2021
76978a4
Add comment
novocaine Oct 14, 2021
cd287fa
Fix lint
novocaine Oct 14, 2021
4216807
Preserve existing analytics libraries
novocaine Oct 14, 2021
5612223
Add ability to customise the analytics owner
novocaine Oct 14, 2021
3cea363
Don't stop listening - flag can flip true/false during init
novocaine Oct 14, 2021
4e0a973
fix type lint
novocaine Oct 14, 2021
5caf52b
fix imports
novocaine Oct 14, 2021
3021333
Make analyticsOwner orthogonal from posthog
novocaine Oct 14, 2021
f42d8b2
Update src/Analytics.tsx
Oct 14, 2021
fbc38b3
Explicitly state private readonly
novocaine Oct 15, 2021
17b86d6
Use SettingsStore.watchSetting rather than on acountData
novocaine Oct 15, 2021
5464742
camelcase
novocaine Oct 15, 2021
38044a8
Add noreferrer noopener
novocaine Oct 15, 2021
ec76c88
Use watchSetting to handle race condition
novocaine Oct 15, 2021
f620f89
Preserve old toast unless posthog is enabled
novocaine Oct 15, 2021
d2ea642
Prefences doesn't switch to using posthog config unless posthog is sw…
novocaine Oct 18, 2021
7e1630f
Link to cookie policy from analytis page
novocaine Oct 18, 2021
c6a627b
Merge remote-tracking branch 'origin' into analytics-pseudo-opt-in
novocaine Oct 18, 2021
2f5ab38
Reformat translated strings using concat
novocaine Oct 18, 2021
fd8d79c
Translate cookie policy link
novocaine Oct 18, 2021
b93c2a1
Reinstate listed data sent as part of analytics
novocaine Oct 18, 2021
eba44d9
denote XXX
novocaine Oct 18, 2021
571f986
convert accountData watcher to use SettingsStore
novocaine Oct 18, 2021
67fd6c5
fix camelCase
novocaine Oct 18, 2021
ec6d829
Update wording according to review
novocaine Oct 21, 2021
26b537e
Update wording in preferences to be consistent with toast
novocaine Oct 21, 2021
f35dfb4
Explicitly link to more information
novocaine Oct 21, 2021
40b1179
Make labels in analytics table wider so the modal isn't so high
novocaine Oct 21, 2021
0070fd1
Disable analytics on logout
novocaine Oct 21, 2021
9667d0e
don't wrap line unnecessarily
novocaine Oct 22, 2021
f155482
remove *typographic* quotation marks
novocaine Oct 22, 2021
0a1cb02
i18n
novocaine Oct 22, 2021
c950db5
Move analytics settings to im.vector.analytics
novocaine Oct 26, 2021
af11ff7
remove showPseudonymousAnalyticsPrompt
novocaine Oct 29, 2021
e75ccaa
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
novocaine Oct 29, 2021
becb105
Cleanup
novocaine Oct 29, 2021
dbeaadd
Update copy
novocaine Oct 29, 2021
7c68aaa
Create new analytics Learn More dialog, hook it up to the toast
novocaine Nov 17, 2021
3cb2c23
Fix all copy, style the dialog
novocaine Nov 18, 2021
14f5523
Merge remote-tracking branch 'origin' into analytics-pseudo-opt-in
novocaine Nov 18, 2021
3c40684
fix whitespace
novocaine Nov 18, 2021
d9fedf6
$accent-color -> $accent
novocaine Nov 18, 2021
a550b66
Fix another $accent, and don't mark privacyPolicyUrl as optional
novocaine Nov 18, 2021
c256f72
_tBold breaks i18n static parsing
novocaine Nov 18, 2021
72ad384
Update e2e tests
novocaine Nov 18, 2021
432c980
Show new learn more from analytics
novocaine Nov 19, 2021
ec9c6ba
Remove analytics ID from old analytics details, which is shown for no…
novocaine Nov 19, 2021
18a0654
Remove period from link title
novocaine Nov 19, 2021
269e786
Fix analytics toast not working for non-posthog
novocaine Nov 19, 2021
98d156f
Fix privacyPolicyUrl variable name
novocaine Nov 25, 2021
dfd360c
Tweak padding and margin per design's request
novocaine Nov 25, 2021
806545b
Add copyright
novocaine Nov 25, 2021
ed1c2b5
Change indent
novocaine Nov 25, 2021
73db237
use Action enums
novocaine Nov 25, 2021
6628dbf
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
novocaine Nov 25, 2021
196d0d2
Update styling for toast buttons to be identical
novocaine Nov 29, 2021
01c9574
Update copy
novocaine Nov 29, 2021
0adedfc
i18n
novocaine Nov 29, 2021
560494f
Put cookie link back in old toast
novocaine Nov 29, 2021
dab34a7
Update src/PosthogAnalytics.ts
Nov 30, 2021
1264c57
Update src/PosthogAnalytics.ts
Nov 30, 2021
9eb010d
Add comments indicating no payload
novocaine Nov 30, 2021
5bfafa7
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
novocaine Dec 2, 2021
1017e71
fix botched merge commit
novocaine Dec 2, 2021
2a34286
use $font-weight-semi-bold
novocaine Dec 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions res/css/views/toasts/_AnalyticsToast.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ limitations under the License.
*/

.mx_AnalyticsToast {
.mx_AccessibleButton_kind_danger {
background: none;
color: $accent;
.mx_AccessibleButton_kind_danger_outline {
background-color: $accent;
color: #ffffff;
border: 1px solid $accent;
font-weight: 600;
}

.mx_AccessibleButton_kind_primary {
background: $accent;
background-color: $accent;
color: #ffffff;
border: 1px solid $accent;
font-weight: 600;
Copy link
Member

Choose a reason for hiding this comment

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

we have $font-semi-bold for this

}
}
4 changes: 2 additions & 2 deletions src/PosthogAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,11 @@ export class PosthogAnalytics {
// Update this.anonymity based on the user's analytics opt-in settings
const anonymity = pseudonymousOptIn ? Anonymity.Pseudonymous : Anonymity.Disabled;
this.setAnonymity(anonymity);
if (anonymity == Anonymity.Pseudonymous) {
if (anonymity === Anonymity.Pseudonymous) {
await this.identifyUser(MatrixClientPeg.get(), PosthogAnalytics.getRandomAnalyticsId);
}

if (anonymity != Anonymity.Disabled) {
if (anonymity !== Anonymity.Disabled) {
await PosthogAnalytics.instance.updatePlatformSuperProperties();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const AnalyticsLearnMoreDialog: React.FC<IProps> = ({
) }
</div>
<ul className="mx_AnalyticsLearnMore_bullets">
<li>{ _t("We <Bold>don't</Bold> record or profile any personal data",
<li>{ _t("We <Bold>don't</Bold> record or profile any account data",
{}, { "Bold": (sub) => <b>{ sub }</b> }) }</li>
<li>{ _t("We <Bold>don't</Bold> share information with third parties",
{}, { "Bold": (sub) => <b>{ sub }</b> }) }</li>
Expand Down
4 changes: 4 additions & 0 deletions src/dispatcher/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,22 +206,26 @@ export enum Action {

/**
* The user accepted pseudonymous analytics (i.e. posthog) from the toast
* Payload: none
*/
PseudonymousAnalyticsAccept = "pseudonymous_analytics_accept",

/**
* The user rejected pseudonymous analytics (i.e. posthog) from the toast
* Payload: none
*/
PseudonymousAnalyticsReject = "pseudonymous_analytics_reject",

/**
* The user accepted anonymous analytics (i.e. matomo, pre-posthog) from the toast
* (this action and its handler can be removed once posthog is rolled out)
* Payload: none
*/
AnonymousAnalyticsAccept = "anonymous_analytics_accept",

/**
* The user rejected anonymous analytics (i.e. matomo, pre-posthog) from the toast
* Payload: none
*/
AnonymousAnalyticsReject = "anonymous_analytics_reject"
}
4 changes: 2 additions & 2 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@
"Enable": "Enable",
"That's fine": "That's fine",
"Stop": "Stop",
"Send <UsageDataLink>anonymous usage data</UsageDataLink> which helps us improve %(brand)s. ": "Send <UsageDataLink>anonymous usage data</UsageDataLink> which helps us improve %(brand)s. ",
"Send <UsageDataLink>anonymous usage data</UsageDataLink> which helps us improve %(brand)s. This will use a <PolicyLink>cookie</PolicyLink>.": "Send <UsageDataLink>anonymous usage data</UsageDataLink> which helps us improve %(brand)s. This will use a <PolicyLink>cookie</PolicyLink>.",
"Help improve %(analyticsOwner)s": "Help improve %(analyticsOwner)s",
"You previously consented to share anonymous usage data with us. We're updating how that works.": "You previously consented to share anonymous usage data with us. We're updating how that works.",
"Learn more": "Learn more",
Expand Down Expand Up @@ -2292,7 +2292,7 @@
"Use an identity server to invite by email. Manage in <settings>Settings</settings>.": "Use an identity server to invite by email. Manage in <settings>Settings</settings>.",
"You can read all our terms <PrivacyPolicyUrl>here</PrivacyPolicyUrl>": "You can read all our terms <PrivacyPolicyUrl>here</PrivacyPolicyUrl>",
"Help us identify issues and improve Element by sharing anonymous usage data. To understand how people use multiple devices, we'll generate a random identifier, shared by your devices.": "Help us identify issues and improve Element by sharing anonymous usage data. To understand how people use multiple devices, we'll generate a random identifier, shared by your devices.",
"We <Bold>don't</Bold> record or profile any personal data": "We <Bold>don't</Bold> record or profile any personal data",
"We <Bold>don't</Bold> record or profile any account data": "We <Bold>don't</Bold> record or profile any account data",
"We <Bold>don't</Bold> share information with third parties": "We <Bold>don't</Bold> share information with third parties",
"You can turn this off anytime in settings": "You can turn this off anytime in settings",
"The following users may not exist": "The following users may not exist",
Expand Down
7 changes: 6 additions & 1 deletion src/toasts/AnalyticsToast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,20 @@ const TOAST_KEY = "analytics";
const getAnonymousDescription = (): ReactNode => {
// get toast description for anonymous tracking (the previous scheme pre-posthog)
const brand = SdkConfig.get().brand;
const cookiePolicyUrl = SdkConfig.get().piwik?.policyUrl;
return _t(
"Send <UsageDataLink>anonymous usage data</UsageDataLink> which helps us improve %(brand)s. ",
"Send <UsageDataLink>anonymous usage data</UsageDataLink> which helps us improve %(brand)s. " +
"This will use a <PolicyLink>cookie</PolicyLink>.",
{
brand,
},
{
"UsageDataLink": (sub) => (
<AccessibleButton kind="link" onClick={onUsageDataClicked}>{ sub }</AccessibleButton>
),
"PolicyLink": (sub) => cookiePolicyUrl ? (
<a target="_blank" href={cookiePolicyUrl}>{ sub }</a>
) : sub,
},
);
};
Expand Down
2 changes: 2 additions & 0 deletions test/end-to-end-tests/src/scenarios/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = async function toastScenarios(alice, bob) {

alice.log.step(`accepts analytics toast`);
await acceptToast(alice, "Help improve Element");
await rejectToast(alice, "Testing small changes");
alice.log.done();

alice.log.step(`checks no remaining toasts`);
Expand All @@ -40,6 +41,7 @@ module.exports = async function toastScenarios(alice, bob) {

bob.log.step(`reject analytics toast`);
await rejectToast(bob, "Help improve Element");
await rejectToast(bob, "Testing small changes");
bob.log.done();

bob.log.step(`checks no remaining toasts`);
Expand Down