Skip to content

Commit e1dc0c5

Browse files
committed
Send internal status to CSS
1 parent a988a0d commit e1dc0c5

File tree

4 files changed

+32
-19
lines changed

4 files changed

+32
-19
lines changed

content-scope-scripts/content-scope-scripts-impl/src/main/java/com/duckduckgo/contentscopescripts/impl/RealContentScopeScripts.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package com.duckduckgo.contentscopescripts.impl
1818

1919
import com.duckduckgo.app.privacy.db.UserAllowListRepository
2020
import com.duckduckgo.appbuildconfig.api.AppBuildConfig
21+
import com.duckduckgo.appbuildconfig.api.isInternalBuild
2122
import com.duckduckgo.common.utils.plugins.PluginPoint
2223
import com.duckduckgo.contentscopescripts.api.ContentScopeConfigPlugin
2324
import com.duckduckgo.di.scopes.AppScope
@@ -200,7 +201,7 @@ class RealContentScopeScripts @Inject constructor(
200201
}
201202

202203
private fun getVersionNumberKeyValuePair() = "\"versionNumber\":${appBuildConfig.versionCode}"
203-
private fun getPlatformKeyValuePair() = "\"platform\":{\"name\":\"android\"}"
204+
private fun getPlatformKeyValuePair() = "\"platform\":{\"name\":\"android\",\"internal\":${appBuildConfig.isInternalBuild()}}"
204205
private fun getLanguageKeyValuePair() = "\"locale\":\"${Locale.getDefault().language}\""
205206
private fun getDesktopModeKeyValuePair(isDesktopMode: Boolean) = "\"desktopModeEnabled\":$isDesktopMode"
206207
private fun getSessionKeyValuePair() = "\"sessionKey\":\"${fingerprintProtectionManager.getSeed()}\""

content-scope-scripts/content-scope-scripts-impl/src/main/java/com/duckduckgo/contentscopescripts/impl/RealWebViewCompatContentScopeScripts.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package com.duckduckgo.contentscopescripts.impl
1818

1919
import com.duckduckgo.app.privacy.db.UserAllowListRepository
2020
import com.duckduckgo.appbuildconfig.api.AppBuildConfig
21+
import com.duckduckgo.appbuildconfig.api.isInternalBuild
2122
import com.duckduckgo.common.utils.DispatcherProvider
2223
import com.duckduckgo.common.utils.plugins.PluginPoint
2324
import com.duckduckgo.contentscopescripts.api.ContentScopeConfigPlugin
@@ -203,7 +204,7 @@ class RealWebViewCompatContentScopeScripts @Inject constructor(
203204
}
204205

205206
private fun getVersionNumberKeyValuePair() = "\"versionNumber\":${appBuildConfig.versionCode}"
206-
private fun getPlatformKeyValuePair() = "\"platform\":{\"name\":\"android\"}"
207+
private fun getPlatformKeyValuePair() = "\"platform\":{\"name\":\"android\",\"internal\":${appBuildConfig.isInternalBuild()}}"
207208
private fun getLanguageKeyValuePair() = "\"locale\":\"${Locale.getDefault().language}\""
208209
private fun getDesktopModeKeyValuePair(isDesktopMode: Boolean) = "\"desktopModeEnabled\":$isDesktopMode"
209210
private fun getSessionKeyValuePair() = "\"sessionKey\":\"${fingerprintProtectionManager.getSeed()}\""

content-scope-scripts/content-scope-scripts-impl/src/test/java/com/duckduckgo/contentscopescripts/impl/RealContentScopeScriptsTest.kt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package com.duckduckgo.contentscopescripts.impl
1919
import android.annotation.SuppressLint
2020
import com.duckduckgo.app.privacy.db.UserAllowListRepository
2121
import com.duckduckgo.appbuildconfig.api.AppBuildConfig
22+
import com.duckduckgo.appbuildconfig.api.BuildFlavor
2223
import com.duckduckgo.common.utils.plugins.PluginPoint
2324
import com.duckduckgo.contentscopescripts.api.ContentScopeConfigPlugin
2425
import com.duckduckgo.feature.toggles.api.FakeFeatureToggleFactory
@@ -71,6 +72,7 @@ class RealContentScopeScriptsTest {
7172
whenever(mockUserAllowListRepository.domainsInUserAllowList()).thenReturn(listOf(exampleUrl))
7273
whenever(mockContentScopeJsReader.getContentScopeJS()).thenReturn(contentScopeJS)
7374
whenever(mockAppBuildConfig.versionCode).thenReturn(versionCode)
75+
whenever(mockAppBuildConfig.flavor).thenReturn(BuildFlavor.INTERNAL)
7476
whenever(mockUnprotectedTemporary.unprotectedTemporaryExceptions)
7577
.thenReturn(listOf(unprotectedTemporaryException, unprotectedTemporaryException2))
7678
whenever(mockFingerprintProtectionManager.getSeed()).thenReturn(sessionKey)
@@ -101,7 +103,8 @@ class RealContentScopeScriptsTest {
101103
"\"unprotectedTemporary\":\\[" +
102104
"\\{\"domain\":\"example\\.com\",\"reason\":\"reason\"\\}," +
103105
"\\{\"domain\":\"foo\\.com\",\"reason\":\"reason2\"\\}\\]\\}, \\[\"foo\\.com\"\\], " +
104-
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\},\"locale\":\"en\"," +
106+
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234," +
107+
"\"platform\":\\{\"name\":\"android\",\"internal\":true\\},\"locale\":\"en\"," +
105108
"\"sessionKey\":\"5678\",\"desktopModeEnabled\":false," +
106109
"\"messageSecret\":\"([\\da-f]{32})\"," +
107110
"\"messageCallback\":\"([\\da-f]{32})\"," +
@@ -128,7 +131,8 @@ class RealContentScopeScriptsTest {
128131
"\"unprotectedTemporary\":\\[" +
129132
"\\{\"domain\":\"example\\.com\",\"reason\":\"reason\"\\}," +
130133
"\\{\"domain\":\"foo\\.com\",\"reason\":\"reason2\"\\}\\]\\}, \\[\"example\\.com\"\\], " +
131-
"\\{\"globalPrivacyControlValue\":false,\"currentCohorts\":\\[\\],\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\}," +
134+
"\\{\"globalPrivacyControlValue\":false,\"currentCohorts\":\\[\\],\"versionNumber\":1234," +
135+
"\"platform\":\\{\"name\":\"android\",\"internal\":true\\}," +
132136
"\"locale\":\"en\",\"sessionKey\":\"5678\"," +
133137
"\"desktopModeEnabled\":false,\"messageSecret\":\"([\\da-f]{32})\"," +
134138
"\"messageCallback\":\"([\\da-f]{32})\"," +
@@ -155,7 +159,7 @@ class RealContentScopeScriptsTest {
155159
"\\{\"domain\":\"example\\.com\",\"reason\":\"reason\"\\}," +
156160
"\\{\"domain\":\"foo\\.com\",\"reason\":\"reason2\"\\}\\]\\}, \\[\"example\\.com\"\\], " +
157161
"\\{\"globalPrivacyControlValue\":true,\"currentCohorts\":\\[\\],\"versionNumber\":1234," +
158-
"\"platform\":\\{\"name\":\"android\"\\},\"locale\":\"en\"," +
162+
"\"platform\":\\{\"name\":\"android\",\"internal\":true\\},\"locale\":\"en\"," +
159163
"\"sessionKey\":\"5678\"," +
160164
"\"desktopModeEnabled\":false,\"messageSecret\":\"([\\da-f]{32})\"," +
161165
"\"messageCallback\":\"([\\da-f]{32})\"," +
@@ -182,7 +186,7 @@ class RealContentScopeScriptsTest {
182186
"\"config2\":\\{\"state\":\"disabled\"\\}\\}," +
183187
"\"unprotectedTemporary\":\\[" +
184188
"\\{\"domain\":\"example\\.com\",\"reason\":\"reason\"\\}\\]\\}, \\[\"example\\.com\"\\], " +
185-
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\}," +
189+
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\",\"internal\":true\\}," +
186190
"\"locale\":\"en\",\"sessionKey\":\"5678\"," +
187191
"\"desktopModeEnabled\":false," +
188192
"\"messageSecret\":\"([\\da-f]{32})\"," +
@@ -210,7 +214,8 @@ class RealContentScopeScriptsTest {
210214
"\"unprotectedTemporary\":\\[" +
211215
"\\{\"domain\":\"example\\.com\",\"reason\":\"reason\"\\}," +
212216
"\\{\"domain\":\"foo\\.com\",\"reason\":\"reason2\"\\}\\]\\}, \\[\"example\\.com\"\\], " +
213-
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\},\"locale\":\"en\"," +
217+
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234," +
218+
"\"platform\":\\{\"name\":\"android\",\"internal\":true\\},\"locale\":\"en\"," +
214219
"\"sessionKey\":\"5678\",\"desktopModeEnabled\":true," +
215220
"\"messageSecret\":\"([\\da-f]{32})\"," +
216221
"\"messageCallback\":\"([\\da-f]{32})\"," +
@@ -235,7 +240,7 @@ class RealContentScopeScriptsTest {
235240
"\\{\"domain\":\"example\\.com\",\"reason\":\"reason\"\\}," +
236241
"\\{\"domain\":\"foo\\.com\",\"reason\":\"reason2\"\\}\\]\\}, \\[\"example\\.com\"\\], " +
237242
"\\{\"currentCohorts\":\\[\\{\"cohort\":\"control\",\"feature\":\"contentScopeExperiments\",\"subfeature\":\"test\"}]," +
238-
"\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\}," +
243+
"\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\",\"internal\":true\\}," +
239244
"\"locale\":\"en\",\"sessionKey\":\"5678\"," +
240245
"\"desktopModeEnabled\":false,\"messageSecret\":\"([\\da-f]{32})\"," +
241246
"\"messageCallback\":\"([\\da-f]{32})\"," +
@@ -268,7 +273,7 @@ class RealContentScopeScriptsTest {
268273
"\\{\"currentCohorts\":\\[" +
269274
"\\{\"cohort\":\"treatment\",\"feature\":\"contentScopeExperiments\",\"subfeature\":\"test\"}," +
270275
"\\{\"cohort\":\"control\",\"feature\":\"contentScopeExperiments\",\"subfeature\":\"bloops\"}\\]," +
271-
"\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\}," +
276+
"\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\",\"internal\":true\\}," +
272277
"\"locale\":\"en\",\"sessionKey\":\"5678\"," +
273278
"\"desktopModeEnabled\":false,\"messageSecret\":\"([\\da-f]{32})\"," +
274279
"\"messageCallback\":\"([\\da-f]{32})\"," +
@@ -347,7 +352,7 @@ class RealContentScopeScriptsTest {
347352
"\\{\"domain\":\"foo\\.com\",\"reason\":\"reason2\"\\}\\]\\}, \\[\"example\\.com\"\\], " +
348353
"\\{\"currentCohorts\":\\[" +
349354
"\\{\"cohort\":\"treatment\",\"feature\":\"contentScopeExperiments\",\"subfeature\":\"test\"}\\]," +
350-
"\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\}," +
355+
"\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\",\"internal\":true\\}," +
351356
"\"locale\":\"en\",\"sessionKey\":\"5678\"," +
352357
"\"desktopModeEnabled\":false,\"messageSecret\":\"([\\da-f]{32})\"," +
353358
"\"messageCallback\":\"([\\da-f]{32})\"," +
@@ -409,7 +414,7 @@ class RealContentScopeScriptsTest {
409414
"\"unprotectedTemporary\":\\[" +
410415
"\\{\"domain\":\"example\\.com\",\"reason\":\"reason\"\\}," +
411416
"\\{\"domain\":\"foo\\.com\",\"reason\":\"reason2\"\\}\\]\\}, \\[\"example\\.com\"\\], " +
412-
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\},\"locale\":\"en\"," +
417+
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\",\"internal\":true\\},\"locale\":\"en\"," +
413418
"\"sessionKey\":\"5678\",\"desktopModeEnabled\":false," +
414419
"\"messageSecret\":\"([\\da-f]{32})\"," +
415420
"\"messageCallback\":\"([\\da-f]{32})\"," +

content-scope-scripts/content-scope-scripts-impl/src/test/java/com/duckduckgo/contentscopescripts/impl/RealWebViewCompatContentScopeScriptsTest.kt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package com.duckduckgo.contentscopescripts.impl
1919
import android.annotation.SuppressLint
2020
import com.duckduckgo.app.privacy.db.UserAllowListRepository
2121
import com.duckduckgo.appbuildconfig.api.AppBuildConfig
22+
import com.duckduckgo.appbuildconfig.api.BuildFlavor.INTERNAL
2223
import com.duckduckgo.common.test.CoroutineTestRule
2324
import com.duckduckgo.common.utils.plugins.PluginPoint
2425
import com.duckduckgo.contentscopescripts.api.ContentScopeConfigPlugin
@@ -78,6 +79,7 @@ class RealWebViewCompatContentScopeScriptsTest {
7879
whenever(mockUserAllowListRepository.domainsInUserAllowList()).thenReturn(listOf(exampleUrl))
7980
whenever(mockContentScopeJsReader.getContentScopeJS()).thenReturn(contentScopeJS)
8081
whenever(mockAppBuildConfig.versionCode).thenReturn(versionCode)
82+
whenever(mockAppBuildConfig.flavor).thenReturn(INTERNAL)
8183
whenever(mockUnprotectedTemporary.unprotectedTemporaryExceptions)
8284
.thenReturn(listOf(unprotectedTemporaryException, unprotectedTemporaryException2))
8385
whenever(mockFingerprintProtectionManager.getSeed()).thenReturn(sessionKey)
@@ -108,7 +110,8 @@ class RealWebViewCompatContentScopeScriptsTest {
108110
"\"unprotectedTemporary\":\\[" +
109111
"\\{\"domain\":\"example\\.com\",\"reason\":\"reason\"\\}," +
110112
"\\{\"domain\":\"foo\\.com\",\"reason\":\"reason2\"\\}\\]\\}, \\[\"foo\\.com\"\\], " +
111-
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\},\"locale\":\"en\"," +
113+
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234," +
114+
"\"platform\":\\{\"name\":\"android\",\"internal\":true\\},\"locale\":\"en\"," +
112115
"\"sessionKey\":\"5678\",\"desktopModeEnabled\":false," +
113116
"\"messageSecret\":\"([\\da-f]{32})\"," +
114117
"\"messageCallback\":\"([\\da-f]{32})\"," +
@@ -135,7 +138,8 @@ class RealWebViewCompatContentScopeScriptsTest {
135138
"\"unprotectedTemporary\":\\[" +
136139
"\\{\"domain\":\"example\\.com\",\"reason\":\"reason\"\\}," +
137140
"\\{\"domain\":\"foo\\.com\",\"reason\":\"reason2\"\\}\\]\\}, \\[\"example\\.com\"\\], " +
138-
"\\{\"globalPrivacyControlValue\":false,\"currentCohorts\":\\[\\],\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\}," +
141+
"\\{\"globalPrivacyControlValue\":false,\"currentCohorts\":\\[\\],\"versionNumber\":1234," +
142+
"\"platform\":\\{\"name\":\"android\",\"internal\":true\\}," +
139143
"\"locale\":\"en\",\"sessionKey\":\"5678\"," +
140144
"\"desktopModeEnabled\":false,\"messageSecret\":\"([\\da-f]{32})\"," +
141145
"\"messageCallback\":\"([\\da-f]{32})\"," +
@@ -162,7 +166,7 @@ class RealWebViewCompatContentScopeScriptsTest {
162166
"\\{\"domain\":\"example\\.com\",\"reason\":\"reason\"\\}," +
163167
"\\{\"domain\":\"foo\\.com\",\"reason\":\"reason2\"\\}\\]\\}, \\[\"example\\.com\"\\], " +
164168
"\\{\"globalPrivacyControlValue\":true,\"currentCohorts\":\\[\\],\"versionNumber\":1234," +
165-
"\"platform\":\\{\"name\":\"android\"\\},\"locale\":\"en\"," +
169+
"\"platform\":\\{\"name\":\"android\",\"internal\":true\\},\"locale\":\"en\"," +
166170
"\"sessionKey\":\"5678\"," +
167171
"\"desktopModeEnabled\":false,\"messageSecret\":\"([\\da-f]{32})\"," +
168172
"\"messageCallback\":\"([\\da-f]{32})\"," +
@@ -189,7 +193,8 @@ class RealWebViewCompatContentScopeScriptsTest {
189193
"\"config2\":\\{\"state\":\"disabled\"\\}\\}," +
190194
"\"unprotectedTemporary\":\\[" +
191195
"\\{\"domain\":\"example\\.com\",\"reason\":\"reason\"\\}\\]\\}, \\[\"example\\.com\"\\], " +
192-
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\}," +
196+
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234," +
197+
"\"platform\":\\{\"name\":\"android\",\"internal\":true\\}," +
193198
"\"locale\":\"en\",\"sessionKey\":\"5678\"," +
194199
"\"desktopModeEnabled\":false," +
195200
"\"messageSecret\":\"([\\da-f]{32})\"," +
@@ -218,7 +223,7 @@ class RealWebViewCompatContentScopeScriptsTest {
218223
"\\{\"domain\":\"example\\.com\",\"reason\":\"reason\"\\}," +
219224
"\\{\"domain\":\"foo\\.com\",\"reason\":\"reason2\"\\}\\]\\}, \\[\"example\\.com\"\\], " +
220225
"\\{\"currentCohorts\":\\[\\{\"cohort\":\"control\",\"feature\":\"contentScopeExperiments\",\"subfeature\":\"test\"}]," +
221-
"\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\}," +
226+
"\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\",\"internal\":true\\}," +
222227
"\"locale\":\"en\",\"sessionKey\":\"5678\"," +
223228
"\"desktopModeEnabled\":false,\"messageSecret\":\"([\\da-f]{32})\"," +
224229
"\"messageCallback\":\"([\\da-f]{32})\"," +
@@ -251,7 +256,7 @@ class RealWebViewCompatContentScopeScriptsTest {
251256
"\\{\"currentCohorts\":\\[" +
252257
"\\{\"cohort\":\"treatment\",\"feature\":\"contentScopeExperiments\",\"subfeature\":\"test\"}," +
253258
"\\{\"cohort\":\"control\",\"feature\":\"contentScopeExperiments\",\"subfeature\":\"bloops\"}\\]," +
254-
"\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\}," +
259+
"\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\",\"internal\":true\\}," +
255260
"\"locale\":\"en\",\"sessionKey\":\"5678\"," +
256261
"\"desktopModeEnabled\":false,\"messageSecret\":\"([\\da-f]{32})\"," +
257262
"\"messageCallback\":\"([\\da-f]{32})\"," +
@@ -337,7 +342,7 @@ class RealWebViewCompatContentScopeScriptsTest {
337342
"\\{\"domain\":\"foo\\.com\",\"reason\":\"reason2\"\\}\\]\\}, \\[\"example\\.com\"\\], " +
338343
"\\{\"currentCohorts\":\\[" +
339344
"\\{\"cohort\":\"treatment\",\"feature\":\"contentScopeExperiments\",\"subfeature\":\"test\"}\\]," +
340-
"\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\}," +
345+
"\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\",\"internal\":true\\}," +
341346
"\"locale\":\"en\",\"sessionKey\":\"5678\"," +
342347
"\"desktopModeEnabled\":false,\"messageSecret\":\"([\\da-f]{32})\"," +
343348
"\"messageCallback\":\"([\\da-f]{32})\"," +
@@ -399,7 +404,8 @@ class RealWebViewCompatContentScopeScriptsTest {
399404
"\"unprotectedTemporary\":\\[" +
400405
"\\{\"domain\":\"example\\.com\",\"reason\":\"reason\"\\}," +
401406
"\\{\"domain\":\"foo\\.com\",\"reason\":\"reason2\"\\}\\]\\}, \\[\"example\\.com\"\\], " +
402-
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\},\"locale\":\"en\"," +
407+
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234," +
408+
"\"platform\":\\{\"name\":\"android\",\"internal\":true\\},\"locale\":\"en\"," +
403409
"\"sessionKey\":\"5678\",\"desktopModeEnabled\":false," +
404410
"\"messageSecret\":\"([\\da-f]{32})\"," +
405411
"\"messageCallback\":\"([\\da-f]{32})\"," +

0 commit comments

Comments
 (0)