Skip to content

Commit de89794

Browse files
authored
fix: IDFA trigger at configure time (#925)
1 parent 887b23f commit de89794

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

packages/core/src/analytics.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,6 @@ export class SegmentClient {
426426
async process(incomingEvent: SegmentEvent) {
427427
const event = this.applyRawEventData(incomingEvent);
428428

429-
console.log(`Process: ${this.isReady.value}`);
430-
431429
if (this.isReady.value) {
432430
return this.startTimelineProcessing(event);
433431
} else {
@@ -479,9 +477,6 @@ export class SegmentClient {
479477
* @param isReady
480478
*/
481479
private async onReady() {
482-
console.log(
483-
`onReady, pendingEvents=${this.store.pendingEvents.get().length}`
484-
);
485480
// Add all plugins awaiting store
486481
if (this.pluginsToAdd.length > 0 && !this.isAddingPlugins) {
487482
this.isAddingPlugins = true;

packages/core/src/storage/__tests__/sovranStorage.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ describe('sovranStorage', () => {
135135

136136
it('adds/removes pending events', async () => {
137137
const sovran = new SovranStorage({ storeId: 'test' });
138-
console.log(sovran.pendingEvents.get());
139138

140139
// expect(sovran.pendingEvents.get().length).toBe(0);
141140

packages/plugins/plugin-idfa/src/IdfaPlugin.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import {
22
ErrorType,
33
Plugin,
44
PluginType,
5+
SegmentClient,
56
SegmentError,
67
} from '@segment/analytics-react-native';
78
import type { IdfaData } from './types';
89
import { AnalyticsReactNativePluginIdfa } from './AnalyticsReactNativePluginIdfa';
10+
import { Platform } from 'react-native';
911

1012
const { getTrackingAuthorizationStatus } = AnalyticsReactNativePluginIdfa;
1113

@@ -20,10 +22,20 @@ const { getTrackingAuthorizationStatus } = AnalyticsReactNativePluginIdfa;
2022
export class IdfaPlugin extends Plugin {
2123
type = PluginType.enrichment;
2224

25+
private shouldAskPermission = true;
26+
2327
constructor(shouldAskPermission = true) {
2428
super();
29+
this.shouldAskPermission = shouldAskPermission;
30+
}
31+
32+
configure(analytics: SegmentClient): void {
33+
this.analytics = analytics;
34+
if (Platform.OS !== 'ios') {
35+
return;
36+
}
2537

26-
if (shouldAskPermission === true) {
38+
if (this.shouldAskPermission === true) {
2739
this.getTrackingStatus();
2840
}
2941
}

0 commit comments

Comments
 (0)