Skip to content

Commit 28ecfb6

Browse files
authored
Fix: add conditional to queue restoration error reporting (#999)
* fix: add check to limit console warnings for queue restore * chore: remove dev team * feat: add message for success if warning was sent * fix: fix Segmentclient import * fix: reset timeoutWarned to true on resolved promise
1 parent c1a0957 commit 28ecfb6

File tree

4 files changed

+41
-12
lines changed

4 files changed

+41
-12
lines changed

examples/AnalyticsReactNativeExample/ios/AnalyticsReactNativeExample.xcodeproj/project.pbxproj

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,11 @@
602602
"-DFOLLY_MOBILE=1",
603603
"-DFOLLY_USE_LIBCPP=1",
604604
);
605-
OTHER_LDFLAGS = "$(inherited)";
605+
OTHER_LDFLAGS = (
606+
"$(inherited)",
607+
"-Wl",
608+
"-ld_classic",
609+
);
606610
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
607611
SDKROOT = iphoneos;
608612
};
@@ -672,7 +676,11 @@
672676
"-DFOLLY_MOBILE=1",
673677
"-DFOLLY_USE_LIBCPP=1",
674678
);
675-
OTHER_LDFLAGS = "$(inherited)";
679+
OTHER_LDFLAGS = (
680+
"$(inherited)",
681+
"-Wl",
682+
"-ld_classic",
683+
);
676684
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
677685
SDKROOT = iphoneos;
678686
VALIDATE_PRODUCT = YES;

examples/AnalyticsReactNativeExample/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ PODS:
499499
- RNScreens (3.27.0):
500500
- RCT-Folly (= 2021.07.22.00)
501501
- React-Core
502-
- segment-analytics-react-native (2.19.3):
502+
- segment-analytics-react-native (2.19.4):
503503
- React-Core
504504
- sovran-react-native
505505
- SocketRocket (0.6.1)
@@ -752,7 +752,7 @@ SPEC CHECKSUMS:
752752
RNCMaskedView: 0e1bc4bfa8365eba5fbbb71e07fbdc0555249489
753753
RNGestureHandler: 32a01c29ecc9bb0b5bf7bc0a33547f61b4dc2741
754754
RNScreens: 3c2d122f5e08c192e254c510b212306da97d2581
755-
segment-analytics-react-native: a803de6a9406f7b18928d352962c2f49663a0869
755+
segment-analytics-react-native: 49ce29a68e86b38c084f1ce07b0c128273d169f9
756756
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
757757
sovran-react-native: 5f02bd2d111ffe226d00c7b0435290eae6f10934
758758
Yoga: eddf2bbe4a896454c248a8f23b4355891eb720a6

examples/E2E/ios/Podfile.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -499,11 +499,11 @@ PODS:
499499
- RNScreens (3.27.0):
500500
- RCT-Folly (= 2021.07.22.00)
501501
- React-Core
502-
- segment-analytics-react-native (2.19.2):
502+
- segment-analytics-react-native (2.19.4):
503503
- React-Core
504504
- sovran-react-native
505505
- SocketRocket (0.6.1)
506-
- sovran-react-native (1.1.1):
506+
- sovran-react-native (1.1.2):
507507
- React-Core
508508
- Yoga (1.14.0)
509509
- YogaKit (1.18.1):
@@ -752,12 +752,12 @@ SPEC CHECKSUMS:
752752
RNCMaskedView: 0e1bc4bfa8365eba5fbbb71e07fbdc0555249489
753753
RNGestureHandler: 32a01c29ecc9bb0b5bf7bc0a33547f61b4dc2741
754754
RNScreens: 3c2d122f5e08c192e254c510b212306da97d2581
755-
segment-analytics-react-native: 962494a9edbe3f6c5829e3b471484c85c304601c
755+
segment-analytics-react-native: 49ce29a68e86b38c084f1ce07b0c128273d169f9
756756
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
757-
sovran-react-native: e6a9c963a8a6b9ebc3563394c39c30f33ab1453f
757+
sovran-react-native: 5f02bd2d111ffe226d00c7b0435290eae6f10934
758758
Yoga: eddf2bbe4a896454c248a8f23b4355891eb720a6
759759
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
760760

761761
PODFILE CHECKSUM: 9d352ca8db1e31a063d2585ed47fdadabf87fe90
762762

763-
COCOAPODS: 1.15.2
763+
COCOAPODS: 1.11.3

packages/core/src/plugins/QueueFlushingPlugin.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { defaultConfig } from '../constants';
44
import { UtilityPlugin } from '../plugin';
55
import { PluginType, SegmentEvent } from '../types';
66
import { createPromise } from '../util';
7-
7+
import { ErrorType, SegmentError } from '../errors';
88
/**
99
* This plugin manages a queue where all events get added to after timeline processing.
1010
* It takes a onFlush callback to trigger any action particular to your destination sending events.
@@ -20,6 +20,7 @@ export class QueueFlushingPlugin extends UtilityPlugin {
2020
private onFlush: (events: SegmentEvent[]) => Promise<void>;
2121
private isRestoredResolve: () => void;
2222
private isRestored: Promise<void>;
23+
private timeoutWarned = false;
2324

2425
/**
2526
* @param onFlush callback to execute when the queue is flushed (either by reaching the limit or manually) e.g. code to upload events to your destination
@@ -75,12 +76,32 @@ export class QueueFlushingPlugin extends UtilityPlugin {
7576
// Wait for the queue to be restored
7677
try {
7778
await this.isRestored;
79+
80+
if (this.timeoutWarned === true) {
81+
this.analytics?.logger.info('Flush triggered successfully.');
82+
83+
this.timeoutWarned = false;
84+
}
7885
} catch (e) {
7986
// If the queue is not restored before the timeout, we will notify but not block flushing events
80-
console.info(
81-
'Flush triggered but queue restoration and settings loading not complete. Flush will be retried.'
87+
this.analytics?.reportInternalError(
88+
new SegmentError(
89+
ErrorType.InitializationError,
90+
'Queue restoration timeout',
91+
e
92+
)
8293
);
94+
95+
if (this.timeoutWarned === false) {
96+
this.analytics?.logger.warn(
97+
'Flush triggered but queue restoration and settings loading not complete. Flush will be retried.',
98+
e
99+
);
100+
101+
this.timeoutWarned = true;
102+
}
83103
}
104+
84105
const events = (await this.queueStore?.getState(true))?.events ?? [];
85106
if (!this.isPendingUpload) {
86107
try {

0 commit comments

Comments
 (0)