• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

snowplow / snowplow-android-tracker / #1055

pending completion
#1055

push

github-actions

mscwilson
Merge branch 'release/5.0.0-beta.1' into next

214 of 214 new or added lines in 18 files covered. (100.0%)

3599 of 4680 relevant lines covered (76.9%)

0.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.89
/snowplow-tracker/src/main/java/com/snowplowanalytics/core/statemachine/DeepLinkStateMachine.kt
1
/*
2
 * Copyright (c) 2015-2023 Snowplow Analytics Ltd. All rights reserved.
3
 *
4
 * This program is licensed to you under the Apache License Version 2.0,
5
 * and you may not use this file except in compliance with the Apache License Version 2.0.
6
 * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
7
 *
8
 * Unless required by applicable law or agreed to in writing,
9
 * software distributed under the Apache License Version 2.0 is distributed on an
10
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
 * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
12
 */
13
package com.snowplowanalytics.core.statemachine
14

15
import com.snowplowanalytics.core.constants.TrackerConstants
16
import com.snowplowanalytics.snowplow.entity.DeepLink
17
import com.snowplowanalytics.snowplow.event.DeepLinkReceived
18
import com.snowplowanalytics.snowplow.event.Event
19
import com.snowplowanalytics.snowplow.payload.SelfDescribingJson
20
import com.snowplowanalytics.snowplow.tracker.InspectableEvent
21
import kotlin.collections.ArrayList
22

23
class DeepLinkStateMachine : StateMachineInterface {
1✔
24
    /*
25
     States: Init, DeepLinkReceived, ReadyForOutput
26
     Events: DL (DeepLinkReceived), SV (ScreenView)
27
     Transitions:
28
      - Init (DL) DeepLinkReceived
29
      - DeepLinkReceived (SV) ReadyForOutput
30
      - ReadyForOutput (DL) DeepLinkReceived
31
      - ReadyForOutput (SV) Init
32
     Entity Generation:
33
      - ReadyForOutput
34
      */
35

36
    override val identifier: String
37
        get() = ID
1✔
38

39
    override val subscribedEventSchemasForTransitions: List<String>
40
        get() = listOf(DeepLinkReceived.schema, TrackerConstants.SCHEMA_SCREEN_VIEW)
1✔
41

42
    override val subscribedEventSchemasForEntitiesGeneration: List<String> 
43
        get() = listOf(TrackerConstants.SCHEMA_SCREEN_VIEW)
1✔
44

45
    override val subscribedEventSchemasForPayloadUpdating: List<String>
46
        get() = ArrayList()
1✔
47

48
    override val subscribedEventSchemasForAfterTrackCallback: List<String>
49
        get() = emptyList()
1✔
50

51
    override fun transition(event: Event, state: State?): State? {
52
        // - Init (DL) DeepLinkReceived
53
        // - ReadyForOutput (DL) DeepLinkReceived
54
        return if (event is DeepLinkReceived) {
1✔
55
            DeepLinkState(event.url, event.referrer)
1✔
56
        } else {
57
            // - Init (SV) Init
58
            if (state == null) {
1✔
59
                return null
1✔
60
            }
61
            // - ReadyForOutput (SV) Init
62
            val dlState = state as? DeepLinkState
1✔
63
            if (dlState?.readyForOutput == true) {
1✔
64
                return null
1✔
65
            }
66
            // - DeepLinkReceived (SV) ReadyForOutput
67
            val currentState = dlState?.let { DeepLinkState(it.url, it.referrer) }
1✔
68
            currentState?.readyForOutput = true
1✔
69
            currentState
1✔
70
        }
71
    }
72

73
    override fun entities(event: InspectableEvent, state: State?): List<SelfDescribingJson>? {
74
        if (state == null) { return null }
1✔
75

76
        val deepLinkState = state as? DeepLinkState
1✔
77
        if (deepLinkState?.readyForOutput == false) {
1✔
78
            return null
×
79
        }
80
        val entity = deepLinkState?.let { DeepLink(it.url).referrer(it.referrer) }
1✔
81
        return entity?.let { listOf<SelfDescribingJson>(entity) }
1✔
82
    }
83

84
    override fun payloadValues(event: InspectableEvent, state: State?): Map<String, Any>? {
85
        return null
×
86
    }
87

88
    override fun afterTrack(event: InspectableEvent) {
89
    }
×
90

91
    companion object {
1✔
92
        val ID: String
93
            get() = "DeepLinkContext"
1✔
94
    }
95
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc