From e57dea508cb2d62ca315c6627a0096a999e89a21 Mon Sep 17 00:00:00 2001 From: thesunita <31236585+thesunita@users.noreply.github.com> Date: Wed, 23 Oct 2024 14:24:28 +0530 Subject: [PATCH 1/3] fix: advertising id being sent for Android application installed events using analytics-react-native-plugin-advertsing-id (#1015) * fix: to show 'Queue restoration timeout' only once * fix: advertising id being sent for Android application installed events --------- Co-authored-by: Sunita Prajapati <> --- .../src/AdvertisingIdPlugin.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/plugins/plugin-advertising-id/src/AdvertisingIdPlugin.ts b/packages/plugins/plugin-advertising-id/src/AdvertisingIdPlugin.ts index 612fcba1..b16c28af 100644 --- a/packages/plugins/plugin-advertising-id/src/AdvertisingIdPlugin.ts +++ b/packages/plugins/plugin-advertising-id/src/AdvertisingIdPlugin.ts @@ -5,6 +5,7 @@ import { getNativeModule, ErrorType, SegmentError, + SegmentEvent } from '@segment/analytics-react-native'; import { Platform, NativeModule } from 'react-native'; @@ -15,6 +16,8 @@ type AdvertisingIDNativeModule = NativeModule & { export class AdvertisingIdPlugin extends Plugin { type = PluginType.enrichment; + queuedEvents: SegmentEvent[] = []; + advertisingId?: string = undefined; configure(analytics: SegmentClient): void { if (Platform.OS !== 'android') { @@ -34,6 +37,7 @@ export class AdvertisingIdPlugin extends Plugin { 'LimitAdTrackingEnabled (Google Play Services) is enabled' ); } else { + this.advertisingId = id void this.setContext(id); } }) @@ -48,6 +52,16 @@ export class AdvertisingIdPlugin extends Plugin { }); } + execute(event: SegmentEvent){ + + if (this.advertisingId === undefined) { + this.queuedEvents.push(event); + }else{ + return event; + } + return; + } + async setContext(id: string): Promise { try { await this.analytics?.context.set({ @@ -56,6 +70,7 @@ export class AdvertisingIdPlugin extends Plugin { adTrackingEnabled: true, }, }); + this.sendQueued(); } catch (error) { const message = 'AdvertisingID failed to set context'; this.analytics?.reportInternalError( @@ -64,4 +79,11 @@ export class AdvertisingIdPlugin extends Plugin { this.analytics?.logger.warn(`${message}: ${JSON.stringify(error)}`); } } + + sendQueued() { + this.queuedEvents.forEach(event => { + void this.analytics?.process(event); + }); + this.queuedEvents = []; + } } From d4d926f857f79ca53b51ef825f8b5162c563698d Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 23 Oct 2024 09:14:45 +0000 Subject: [PATCH 2/3] chore(release): 2.20.2 [skip ci] --- packages/core/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/package.json b/packages/core/package.json index 2152aebf..b1667be2 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@segment/analytics-react-native", - "version": "2.20.1", + "version": "2.20.2", "description": "The hassle-free way to add Segment analytics to your React-Native app.", "keywords": [ "segment", From 04abe37879e87f7b0112fc5d31b0e1d028e0af35 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 23 Oct 2024 09:15:18 +0000 Subject: [PATCH 3/3] chore(release): 1.3.2 [skip ci] ### Dependencies * **@segment/analytics-react-native:** upgraded to 2.20.2 --- packages/plugins/plugin-advertising-id/CHANGELOG.md | 4 ++++ packages/plugins/plugin-advertising-id/package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/plugins/plugin-advertising-id/CHANGELOG.md b/packages/plugins/plugin-advertising-id/CHANGELOG.md index 4574afb0..fb7b986e 100644 --- a/packages/plugins/plugin-advertising-id/CHANGELOG.md +++ b/packages/plugins/plugin-advertising-id/CHANGELOG.md @@ -1,5 +1,9 @@ ### Dependencies +* **@segment/analytics-react-native:** upgraded to 2.20.2 + +### Dependencies + * **@segment/analytics-react-native:** upgraded to 2.19.0 * **@segment/sovran-react-native:** upgraded to 1.1.1 diff --git a/packages/plugins/plugin-advertising-id/package.json b/packages/plugins/plugin-advertising-id/package.json index 2a3851d1..4331246c 100644 --- a/packages/plugins/plugin-advertising-id/package.json +++ b/packages/plugins/plugin-advertising-id/package.json @@ -1,6 +1,6 @@ { "name": "@segment/analytics-react-native-plugin-advertising-id", - "version": "1.3.1", + "version": "1.3.2", "description": "The hassle-free way to add Segment analytics to your React-Native app.", "main": "lib/commonjs/index", "scripts": {