Skip to content

Commit c1f7851

Browse files
feat: support app flows APIs (#446)
* chore: deprecate execution traces APIs Deprecate execution traces in favor of AppFlows APIs. * feat: support app flows * chore: reformat files * docs: update changelog.md * docs: update deprecation notice with APM prefix * refactor: change flow attribute value to nullable * Update CHANGELOG.md Co-authored-by: Ahmed Mahmoud <[email protected]> * Update lib/src/modules/apm.dart Co-authored-by: Ahmed Mahmoud <[email protected]> --------- Co-authored-by: Ahmed Mahmoud <[email protected]>
1 parent a639ab7 commit c1f7851

File tree

10 files changed

+268
-42
lines changed

10 files changed

+268
-42
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66

77
- Adds custom app rating api ([#453](https://github.com/Instabug/Instabug-Flutter/pull/453))
88
- Add `SessionReplay.getSessionReplayLink` API which retrieves the current session's replay link ([#445](hhttps://github.com/Instabug/Instabug-Flutter/pull/445)).
9+
- Add support for App Flows APIs `APM.startFlow`, `APM.endFlow` and `APM.setFlowAttribute` ([#446](https://github.com/Instabug/Instabug-Flutter/pull/446)).
10+
11+
### Deprecated
12+
13+
- Deprecate execution traces APIs `APM.startExecutionTrace`, `APM.setExecutionTraceAttribute`, `APM.endExecutionTrace`, `Trace.setAttribute` and `Trace.end` in favor of the new app flow APIs ([#446](https://github.com/Instabug/Instabug-Flutter/pull/446)).
914

1015
### Changed
1116
- Bump Instabug Android SDK to v13.0.0 ([#455](https://github.com/Instabug/Instabug-Flutter/pull/455)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v13.0.0).

android/src/main/java/com/instabug/flutter/modules/ApmApi.java

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
package com.instabug.flutter.modules;
22

33
import android.util.Log;
4-
54
import androidx.annotation.NonNull;
6-
5+
import androidx.annotation.Nullable;
76
import com.instabug.apm.APM;
87
import com.instabug.apm.model.ExecutionTrace;
98
import com.instabug.apm.networking.APMNetworkLogger;
109
import com.instabug.flutter.generated.ApmPigeon;
1110
import com.instabug.flutter.util.Reflection;
1211
import com.instabug.flutter.util.ThreadManager;
13-
12+
import io.flutter.plugin.common.BinaryMessenger;
1413
import org.json.JSONObject;
1514

1615
import java.lang.reflect.Method;
1716
import java.util.HashMap;
1817
import java.util.Map;
1918

20-
import io.flutter.plugin.common.BinaryMessenger;
21-
2219
public class ApmApi implements ApmPigeon.ApmHostApi {
2320
private final String TAG = ApmApi.class.getName();
2421
private final HashMap<String, ExecutionTrace> traces = new HashMap<>();
@@ -95,6 +92,33 @@ public void run() {
9592
);
9693
}
9794

95+
@Override
96+
public void startFlow(@NonNull String name) {
97+
try {
98+
APM.startFlow(name);
99+
} catch (Exception e) {
100+
e.printStackTrace();
101+
}
102+
}
103+
104+
@Override
105+
public void setFlowAttribute(@NonNull String name, @NonNull String key, @Nullable String value) {
106+
try {
107+
APM.setFlowAttribute(name, key, value);
108+
} catch (Exception e) {
109+
e.printStackTrace();
110+
}
111+
}
112+
113+
@Override
114+
public void endFlow(@NonNull String name) {
115+
try {
116+
APM.endFlow(name);
117+
} catch (Exception e) {
118+
e.printStackTrace();
119+
}
120+
}
121+
98122
@Override
99123
public void setExecutionTraceAttribute(@NonNull String id, @NonNull String key, @NonNull String value) {
100124
try {

android/src/test/java/com/instabug/flutter/ApmApiTest.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,39 @@ public void testEndExecutionTrace() {
148148
verify(mTrace).end();
149149
}
150150

151+
@Test
152+
public void testStartFlow() {
153+
String appFlowName = "appFlowName";
154+
155+
api.startFlow(appFlowName);
156+
157+
mAPM.verify(() -> APM.startFlow(appFlowName));
158+
mAPM.verifyNoMoreInteractions();
159+
}
160+
161+
@Test
162+
public void testEndFlow() {
163+
String appFlowName = "appFlowName";
164+
165+
api.startFlow(appFlowName);
166+
167+
mAPM.verify(() -> APM.startFlow(appFlowName));
168+
mAPM.verifyNoMoreInteractions();
169+
}
170+
171+
@Test
172+
public void testSetFlowAttribute() {
173+
String appFlowName = "appFlowName";
174+
String flowAttributeKey = "attributeKey";
175+
String flowAttributeValue = "attributeValue";
176+
177+
178+
api.setFlowAttribute(appFlowName, flowAttributeKey, flowAttributeValue);
179+
180+
mAPM.verify(() -> APM.setFlowAttribute(appFlowName, flowAttributeKey, flowAttributeValue));
181+
mAPM.verifyNoMoreInteractions();
182+
}
183+
151184
@Test
152185
public void testStartUITrace() {
153186
String name = "login";

example/ios/InstabugTests/ApmApiTests.m

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,35 @@ - (void)testEndExecutionTrace {
114114
OCMVerify([mTrace end]);
115115
}
116116

117+
- (void) testStartFlow {
118+
NSString* appFlowName = @"app-flow-name";
119+
FlutterError *error;
120+
121+
[self.api startFlowName:appFlowName error:&error];
122+
123+
OCMVerify([self.mAPM startFlowWithName:appFlowName]);
124+
}
125+
126+
- (void) testEndFlow {
127+
NSString* appFlowName = @"app-flow-name";
128+
FlutterError *error;
129+
130+
[self.api endFlowName:appFlowName error:&error];
131+
132+
OCMVerify([self.mAPM endFlowWithName:appFlowName]);
133+
}
134+
135+
- (void) testSetFlowAttribute {
136+
NSString* appFlowName = @"app-flow-name";
137+
NSString* attributeKey = @"attribute-key";
138+
NSString* attributeValue = @"attribute-value";
139+
FlutterError *error;
140+
141+
[self.api setFlowAttributeName:appFlowName key:attributeKey value:attributeValue error:&error];
142+
143+
OCMVerify([self.mAPM setAttributeForFlowWithName:appFlowName key:attributeKey value:attributeValue]);
144+
}
145+
117146
- (void)testStartUITrace {
118147
NSString *name = @"login";
119148
FlutterError *error;

example/pubspec.lock

Lines changed: 61 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
# Generated by pub
22
# See https://dart.dev/tools/pub/glossary#lockfile
33
packages:
4+
archive:
5+
dependency: transitive
6+
description:
7+
name: archive
8+
sha256: "80e5141fafcb3361653ce308776cfd7d45e6e9fbb429e14eec571382c0c5fecb"
9+
url: "https://pub.dev"
10+
source: hosted
11+
version: "3.3.2"
412
async:
513
dependency: transitive
614
description:
715
name: async
8-
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
16+
sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0
917
url: "https://pub.dev"
1018
source: hosted
11-
version: "2.11.0"
19+
version: "2.10.0"
1220
boolean_selector:
1321
dependency: transitive
1422
description:
@@ -21,10 +29,10 @@ packages:
2129
dependency: transitive
2230
description:
2331
name: characters
24-
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
32+
sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c
2533
url: "https://pub.dev"
2634
source: hosted
27-
version: "1.3.0"
35+
version: "1.2.1"
2836
clock:
2937
dependency: transitive
3038
description:
@@ -37,10 +45,18 @@ packages:
3745
dependency: transitive
3846
description:
3947
name: collection
40-
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
48+
sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0
4149
url: "https://pub.dev"
4250
source: hosted
43-
version: "1.18.0"
51+
version: "1.17.0"
52+
crypto:
53+
dependency: transitive
54+
description:
55+
name: crypto
56+
sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67
57+
url: "https://pub.dev"
58+
source: hosted
59+
version: "3.0.2"
4460
espresso:
4561
dependency: "direct dev"
4662
description:
@@ -92,46 +108,54 @@ packages:
92108
relative: true
93109
source: path
94110
version: "12.7.0"
111+
js:
112+
dependency: transitive
113+
description:
114+
name: js
115+
sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7"
116+
url: "https://pub.dev"
117+
source: hosted
118+
version: "0.6.5"
95119
matcher:
96120
dependency: transitive
97121
description:
98122
name: matcher
99-
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
123+
sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72"
100124
url: "https://pub.dev"
101125
source: hosted
102-
version: "0.12.16"
126+
version: "0.12.13"
103127
material_color_utilities:
104128
dependency: transitive
105129
description:
106130
name: material_color_utilities
107-
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
131+
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
108132
url: "https://pub.dev"
109133
source: hosted
110-
version: "0.5.0"
134+
version: "0.2.0"
111135
meta:
112136
dependency: transitive
113137
description:
114138
name: meta
115-
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
139+
sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42"
116140
url: "https://pub.dev"
117141
source: hosted
118-
version: "1.10.0"
142+
version: "1.8.0"
119143
path:
120144
dependency: transitive
121145
description:
122146
name: path
123-
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
147+
sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b
124148
url: "https://pub.dev"
125149
source: hosted
126-
version: "1.8.3"
150+
version: "1.8.2"
127151
platform:
128152
dependency: transitive
129153
description:
130154
name: platform
131-
sha256: ae68c7bfcd7383af3629daafb32fb4e8681c7154428da4febcff06200585f102
155+
sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76"
132156
url: "https://pub.dev"
133157
source: hosted
134-
version: "3.1.2"
158+
version: "3.1.0"
135159
process:
136160
dependency: transitive
137161
description:
@@ -149,26 +173,26 @@ packages:
149173
dependency: transitive
150174
description:
151175
name: source_span
152-
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
176+
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
153177
url: "https://pub.dev"
154178
source: hosted
155-
version: "1.10.0"
179+
version: "1.9.1"
156180
stack_trace:
157181
dependency: transitive
158182
description:
159183
name: stack_trace
160-
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
184+
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
161185
url: "https://pub.dev"
162186
source: hosted
163-
version: "1.11.1"
187+
version: "1.11.0"
164188
stream_channel:
165189
dependency: transitive
166190
description:
167191
name: stream_channel
168-
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
192+
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
169193
url: "https://pub.dev"
170194
source: hosted
171-
version: "2.1.2"
195+
version: "2.1.1"
172196
string_scanner:
173197
dependency: transitive
174198
description:
@@ -197,10 +221,18 @@ packages:
197221
dependency: transitive
198222
description:
199223
name: test_api
200-
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
224+
sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206
225+
url: "https://pub.dev"
226+
source: hosted
227+
version: "0.4.16"
228+
typed_data:
229+
dependency: transitive
230+
description:
231+
name: typed_data
232+
sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5"
201233
url: "https://pub.dev"
202234
source: hosted
203-
version: "0.6.1"
235+
version: "1.3.1"
204236
vector_math:
205237
dependency: transitive
206238
description:
@@ -213,26 +245,18 @@ packages:
213245
dependency: transitive
214246
description:
215247
name: vm_service
216-
sha256: c538be99af830f478718b51630ec1b6bee5e74e52c8a802d328d9e71d35d2583
217-
url: "https://pub.dev"
218-
source: hosted
219-
version: "11.10.0"
220-
web:
221-
dependency: transitive
222-
description:
223-
name: web
224-
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
248+
sha256: e7fb6c2282f7631712b69c19d1bff82f3767eea33a2321c14fa59ad67ea391c7
225249
url: "https://pub.dev"
226250
source: hosted
227-
version: "0.3.0"
251+
version: "9.4.0"
228252
webdriver:
229253
dependency: transitive
230254
description:
231255
name: webdriver
232-
sha256: "3c923e918918feeb90c4c9fdf1fe39220fa4c0e8e2c0fffaded174498ef86c49"
256+
sha256: ef67178f0cc7e32c1494645b11639dd1335f1d18814aa8435113a92e9ef9d841
233257
url: "https://pub.dev"
234258
source: hosted
235-
version: "3.0.2"
259+
version: "3.0.1"
236260
sdks:
237-
dart: ">=3.2.0-194.0.dev <4.0.0"
261+
dart: ">=2.18.0 <3.0.0"
238262
flutter: ">=2.10.0"

ios/Classes/Modules/ApmApi.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ - (void)endExecutionTraceId:(NSString *)id error:(FlutterError *_Nullable *_Nonn
5656
}
5757
}
5858

59+
- (void)startFlowName:(nonnull NSString *)name error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
60+
[IBGAPM startFlowWithName:name];
61+
}
62+
63+
- (void)setFlowAttributeName:(nonnull NSString *)name key:(nonnull NSString *)key value:(nullable NSString *)value error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
64+
[IBGAPM setAttributeForFlowWithName:name key:key value:value];
65+
}
66+
67+
- (void)endFlowName:(nonnull NSString *)name error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
68+
[IBGAPM endFlowWithName:name];
69+
}
70+
5971
- (void)startUITraceName:(NSString *)name error:(FlutterError *_Nullable *_Nonnull)error {
6072
[IBGAPM startUITraceWithName:name];
6173
}

0 commit comments

Comments
 (0)