Skip to content

Commit 771b834

Browse files
authored
Merge pull request #701 from mindbox-cloud/release/2.15.0
Release 2.15.0
2 parents 50e8ba8 + 6fbc622 commit 771b834

146 files changed

Lines changed: 8997 additions & 970 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/distribute-manual.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@ name: Distribute PushOk (manual)
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
app_ref:
7+
description: "GitLab App branch (Optional)"
8+
required: false
9+
default: ""
510

611
jobs:
712
call-reusable:
813
uses: ./.github/workflows/distribute-reusable.yml
914
with:
1015
branch: ${{ github.ref_name }}
11-
secrets: inherit
16+
app_ref: ${{ inputs.app_ref }}
17+
secrets: inherit

.github/workflows/distribute-reusable.yml

Lines changed: 186 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ on:
66
branch:
77
required: true
88
type: string
9+
app_ref:
10+
required: false
11+
type: string
12+
default: ""
13+
secrets:
14+
GITLAB_TRIGGER_TOKEN:
15+
required: true
916

1017
jobs:
1118
distribution:
@@ -16,16 +23,187 @@ jobs:
1623
with:
1724
ref: ${{ inputs.branch }}
1825
submodules: recursive
26+
fetch-depth: 3
1927

2028
- name: Get last 3 commit messages
29+
shell: bash
2130
run: |
22-
commits=$(git log -3 --pretty=format:"%s")
23-
echo "commits=$commits" >> $GITHUB_ENV
31+
set -euo pipefail
32+
commits="$(git log -3 --pretty=format:"%s")"
33+
echo "commits<<EOF" >> "$GITHUB_ENV"
34+
echo "$commits" >> "$GITHUB_ENV"
35+
echo "EOF" >> "$GITHUB_ENV"
2436
25-
- name: Trigger build & send to FAD
37+
- name: Debug payload that will be sent to GitLab
38+
shell: bash
39+
env:
40+
SOURCE_BRANCH: ${{ inputs.branch }}
41+
APP_REF_OVERRIDE: ${{ inputs.app_ref }}
42+
DEFAULT_APP_REF: develop
43+
INPUT_COMMITS: ${{ env.commits }}
2644
run: |
27-
curl --location 'https://mindbox.gitlab.yandexcloud.net/api/v4/projects/900/trigger/pipeline' \
28-
--form 'token="${{ secrets.GITLAB_TRIGGER_TOKEN }}"' \
29-
--form 'ref="develop"' \
30-
--form "variables[INPUT_BRANCH]=\"${{ inputs.branch }}\"" \
31-
--form "variables[INPUT_COMMITS]=\"${{ env.commits }}\""
45+
set -euo pipefail
46+
47+
# Trim override so " " becomes empty
48+
APP_REF_OVERRIDE="$(printf '%s' "${APP_REF_OVERRIDE:-}" | xargs)"
49+
50+
echo "---- DEBUG (GitHub -> GitLab trigger payload) ----"
51+
echo "SDK branch (INPUT_BRANCH): $SOURCE_BRANCH"
52+
echo "Manual App ref override: ${APP_REF_OVERRIDE:-<empty>}"
53+
echo "Default App ref: $DEFAULT_APP_REF"
54+
echo ""
55+
echo "RAW INPUT_COMMITS (cat -A):"
56+
printf '%s' "${INPUT_COMMITS:-}" | cat -A
57+
echo ""
58+
echo "RAW INPUT_COMMITS (printf %q):"
59+
printf '%q\n' "${INPUT_COMMITS:-}"
60+
echo "--------------------------------------------------"
61+
62+
- name: Trigger build & send to FAD (override strict; else same->develop)
63+
env:
64+
GITLAB_HOST: mindbox.gitlab.yandexcloud.net
65+
APP_PROJECT_ID: "900"
66+
DEFAULT_APP_REF: develop
67+
68+
SOURCE_BRANCH: ${{ inputs.branch }}
69+
APP_REF_OVERRIDE: ${{ inputs.app_ref }}
70+
71+
GITLAB_TRIGGER_TOKEN: ${{ secrets.GITLAB_TRIGGER_TOKEN }}
72+
INPUT_COMMITS: ${{ env.commits }}
73+
shell: bash
74+
run: |
75+
set -euo pipefail
76+
77+
# Trim override so " " becomes empty
78+
APP_REF_OVERRIDE="$(printf '%s' "${APP_REF_OVERRIDE:-}" | xargs)"
79+
80+
# Normalize commits:
81+
# - convert CRLF -> LF
82+
# - if commits accidentally contain literal "\n", expand them to real newlines
83+
normalize_commits() {
84+
local raw="${1:-}"
85+
# CRLF -> LF
86+
raw="$(printf '%s' "$raw" | tr -d '\r')"
87+
88+
# If it contains literal "\n" (backslash+n), expand escapes
89+
if [[ "$raw" == *"\\n"* ]]; then
90+
raw="$(printf '%b' "$raw")"
91+
fi
92+
93+
printf '%s' "$raw"
94+
}
95+
96+
COMMITS_TO_SEND="$(normalize_commits "${INPUT_COMMITS:-}")"
97+
98+
echo "SDK branch (INPUT_BRANCH): $SOURCE_BRANCH"
99+
echo "Manual App ref override: ${APP_REF_OVERRIDE:-<empty>}"
100+
echo "Default App ref: $DEFAULT_APP_REF"
101+
echo ""
102+
echo "COMMITS_TO_SEND preview (cat -A):"
103+
printf '%s' "$COMMITS_TO_SEND" | cat -A
104+
echo ""
105+
106+
trigger_pipeline() {
107+
local ref="$1"
108+
local tmp_body
109+
tmp_body="$(mktemp)"
110+
111+
local code
112+
code="$(curl -sS -o "$tmp_body" -w '%{http_code}' --location \
113+
--retry 3 --retry-all-errors --retry-delay 2 \
114+
"https://${GITLAB_HOST}/api/v4/projects/${APP_PROJECT_ID}/trigger/pipeline" \
115+
--form "token=${GITLAB_TRIGGER_TOKEN}" \
116+
--form "ref=${ref}" \
117+
--form "variables[INPUT_BRANCH]=${SOURCE_BRANCH}" \
118+
--form "variables[INPUT_COMMITS]=${COMMITS_TO_SEND}")"
119+
120+
local body
121+
body="$(cat "$tmp_body" 2>/dev/null || true)"
122+
rm -f "$tmp_body"
123+
124+
echo "Trigger HTTP: $code (ref=$ref)"
125+
echo "Response body:"
126+
echo "$body"
127+
128+
if [[ "$code" == "200" || "$code" == "201" ]]; then
129+
local web_url
130+
web_url="$(
131+
printf '%s\n' "$body" |
132+
grep -o '"web_url":"[^"]*"' |
133+
head -n 1 |
134+
cut -d'"' -f4
135+
)"
136+
if [[ -n "${web_url:-}" ]]; then
137+
echo "Pipeline URL: $web_url"
138+
fi
139+
return 0
140+
fi
141+
142+
if [[ "$code" == "401" || "$code" == "403" ]]; then
143+
echo "Auth error (HTTP $code). Check that GITLAB_TRIGGER_TOKEN is valid and has access to project ${APP_PROJECT_ID}."
144+
return 1
145+
fi
146+
147+
# Missing ref: GitLab returns 400 + "Reference not found"
148+
if [[ "$code" == "400" || "$code" == "404" ]]; then
149+
if [[ "$body" == *"Reference not found"* ]]; then
150+
return 2
151+
fi
152+
153+
echo "Got HTTP $code but it's NOT 'Reference not found'."
154+
echo "This can happen if pipelines are blocked for triggers by workflow:rules or job rules when CI_PIPELINE_SOURCE == 'trigger'."
155+
echo "Check the target repo .gitlab-ci.yml rules/workflow:rules."
156+
return 1
157+
fi
158+
159+
if [[ "$code" =~ ^5[0-9][0-9]$ ]]; then
160+
echo "Server error (HTTP $code). GitLab/proxy might be temporarily unavailable."
161+
return 1
162+
fi
163+
164+
echo "Unexpected HTTP status: $code"
165+
return 1
166+
}
167+
168+
# If override is provided: try ONLY override; if missing ref -> fail
169+
if [[ -n "$APP_REF_OVERRIDE" ]]; then
170+
echo "Override provided -> trying ONLY App ref: $APP_REF_OVERRIDE"
171+
trigger_pipeline "$APP_REF_OVERRIDE" || rc=$?
172+
rc="${rc:-0}"
173+
174+
if [[ "$rc" == "0" ]]; then
175+
echo "Triggered on override ref."
176+
exit 0
177+
fi
178+
179+
if [[ "$rc" == "2" ]]; then
180+
echo "ERROR: App ref not found: $APP_REF_OVERRIDE (GitLab returned 'Reference not found')"
181+
exit 1
182+
fi
183+
184+
echo "Trigger failed for reasons other than missing ref."
185+
exit 1
186+
fi
187+
188+
# No override: same branch -> fallback develop
189+
desired_ref="$SOURCE_BRANCH"
190+
fallback_ref="$DEFAULT_APP_REF"
191+
192+
echo "No override -> trying App ref: $desired_ref"
193+
trigger_pipeline "$desired_ref" || rc=$?
194+
rc="${rc:-0}"
195+
196+
if [[ "$rc" == "0" ]]; then
197+
echo "Triggered on same branch."
198+
exit 0
199+
fi
200+
201+
if [[ "$rc" == "2" ]]; then
202+
echo "Same branch not found. Falling back to: $fallback_ref"
203+
trigger_pipeline "$fallback_ref"
204+
echo "Triggered on fallback ref."
205+
exit 0
206+
fi
207+
208+
echo "Trigger failed for reasons other than missing ref."
209+
exit 1

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/cloud.mindbox/mobile-sdk/badge.svg)](https://central.sonatype.com/artifact/cloud.mindbox/mobile-sdk)
1+
[![Maven Central](https://img.shields.io/maven-central/v/cloud.mindbox/mobile-sdk?label=Maven%20Central)](https://central.sonatype.com/artifact/cloud.mindbox/mobile-sdk)
22

33
# Mindbox SDK for Android
44

example/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ dependencies {
9292
implementation 'com.google.code.gson:gson:2.11.0'
9393

9494
//Mindbox
95-
implementation 'cloud.mindbox:mobile-sdk:2.14.5'
95+
implementation 'cloud.mindbox:mobile-sdk:2.15.0'
9696
implementation 'cloud.mindbox:mindbox-firebase'
9797
implementation 'cloud.mindbox:mindbox-huawei'
9898
implementation 'cloud.mindbox:mindbox-rustore'

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ android.enableJetifier=true
2020
# Kotlin code style for this project: "official" or "obsolete":
2121
kotlin.code.style=official
2222
# SDK version property
23-
SDK_VERSION_NAME=2.14.5
23+
SDK_VERSION_NAME=2.15.0
2424
USE_LOCAL_MINDBOX_COMMON=true
2525
android.nonTransitiveRClass=false
2626
kotlin.mpp.androidGradlePluginCompatibility.nowarn=true

sdk/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
66
<uses-permission android:name="android.permission.INTERNET" />
77
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
8+
<uses-permission android:name="android.permission.VIBRATE" />
89

910
<uses-sdk tools:overrideLibrary="io.mockk, io.mockk.proxy.android" />
1011
<application>

sdk/src/main/java/cloud/mindbox/mobile_sdk/Extensions.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import cloud.mindbox.mobile_sdk.Mindbox.logE
2222
import cloud.mindbox.mobile_sdk.Mindbox.logW
2323
import cloud.mindbox.mobile_sdk.inapp.domain.models.InApp
2424
import cloud.mindbox.mobile_sdk.inapp.domain.models.InAppType
25+
import cloud.mindbox.mobile_sdk.inapp.domain.models.Layer
2526
import cloud.mindbox.mobile_sdk.logger.MindboxLoggerImpl
2627
import cloud.mindbox.mobile_sdk.pushes.PushNotificationManager.EXTRA_UNIQ_PUSH_BUTTON_KEY
2728
import cloud.mindbox.mobile_sdk.pushes.PushNotificationManager.EXTRA_UNIQ_PUSH_KEY
@@ -299,3 +300,19 @@ internal fun List<InApp>.sortByPriority(): List<InApp> {
299300
internal inline fun <T> Queue<T>.pollIf(predicate: (T) -> Boolean): T? {
300301
return peek()?.takeIf(predicate)?.let { poll() }
301302
}
303+
304+
internal fun InAppType.getImageUrl(): String? {
305+
return when (this) {
306+
is InAppType.WebView -> this.layers
307+
is InAppType.ModalWindow -> this.layers
308+
is InAppType.Snackbar -> this.layers
309+
}
310+
.filterIsInstance<Layer.ImageLayer>()
311+
.firstOrNull()
312+
?.source
313+
?.let { source ->
314+
when (source) {
315+
is Layer.ImageLayer.Source.UrlSource -> source.url
316+
}
317+
}
318+
}

sdk/src/main/java/cloud/mindbox/mobile_sdk/Mindbox.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public object Mindbox : MindboxLog {
9494
private lateinit var lifecycleManager: LifecycleManager
9595

9696
private val userVisitManager: UserVisitManager by mindboxInject { userVisitManager }
97+
private val timeProvider by mindboxInject { timeProvider }
9798

9899
internal var pushServiceHandlers: List<PushServiceHandler> = listOf()
99100

@@ -1244,6 +1245,11 @@ public object Mindbox : MindboxLog {
12441245
MindboxPreferences.isNotificationEnabled = isNotificationEnabled
12451246
MindboxPreferences.instanceId = instanceId
12461247

1248+
if (MindboxPreferences.firstInitializationTime == null) {
1249+
MindboxPreferences.firstInitializationTime = timeProvider.currentTimestamp()
1250+
.convertToIso8601String()
1251+
}
1252+
12471253
MindboxEventManager.appInstalled(context, initData, configuration.shouldCreateCustomer)
12481254

12491255
deliverDeviceUuid(deviceUuid)
@@ -1358,7 +1364,9 @@ public object Mindbox : MindboxLog {
13581364
requestUrl = requestUrl,
13591365
sdkVersionNumeric = Constants.SDK_VERSION_NUMERIC
13601366
)
1361-
1367+
if (source != null || requestUrl != null) {
1368+
sessionStorageManager.lastTrackVisitData = trackVisitData
1369+
}
13621370
MindboxEventManager.appStarted(applicationContext, trackVisitData)
13631371
}
13641372
}

0 commit comments

Comments
 (0)