From a971498e43ccce543c97f98b499cec0371327880 Mon Sep 17 00:00:00 2001 From: Sunita Prajapati <> Date: Tue, 22 Oct 2024 12:10:53 +0530 Subject: [PATCH 1/3] fix: to show 'Queue restoration timeout' only once --- packages/core/src/plugins/QueueFlushingPlugin.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/core/src/plugins/QueueFlushingPlugin.ts b/packages/core/src/plugins/QueueFlushingPlugin.ts index 49279366..4ca749aa 100644 --- a/packages/core/src/plugins/QueueFlushingPlugin.ts +++ b/packages/core/src/plugins/QueueFlushingPlugin.ts @@ -84,15 +84,15 @@ export class QueueFlushingPlugin extends UtilityPlugin { } } catch (e) { // If the queue is not restored before the timeout, we will notify but not block flushing events - this.analytics?.reportInternalError( - new SegmentError( - ErrorType.InitializationError, - 'Queue restoration timeout', - e - ) - ); - if (this.timeoutWarned === false) { + this.analytics?.reportInternalError( + new SegmentError( + ErrorType.InitializationError, + 'Queue restoration timeout', + e + ) + ); + this.analytics?.logger.warn( 'Flush triggered but queue restoration and settings loading not complete. Flush will be retried.', e From 867e52afb8239eed5d7112a36d74e34d9aed6e9f Mon Sep 17 00:00:00 2001 From: Sunita Prajapati <> Date: Wed, 23 Oct 2024 12:08:08 +0530 Subject: [PATCH 2/3] fix: advertising id being sent for Android application installed events --- .../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<void> { 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 919b65d5fc5d6dd20054a64776fdd78a9695368b Mon Sep 17 00:00:00 2001 From: Sunita Prajapati <> Date: Mon, 28 Oct 2024 11:42:54 +0530 Subject: [PATCH 3/3] chore: add privacy manifest file to core package --- .../project.pbxproj | 22 +----- packages/core/ios/PrivacyInfo.xcprivacy | 70 +++++++++++++++++++ 2 files changed, 73 insertions(+), 19 deletions(-) create mode 100644 packages/core/ios/PrivacyInfo.xcprivacy diff --git a/packages/core/ios/AnalyticsReactNative.xcodeproj/project.pbxproj b/packages/core/ios/AnalyticsReactNative.xcodeproj/project.pbxproj index 9fc6613f..62ed7dac 100644 --- a/packages/core/ios/AnalyticsReactNative.xcodeproj/project.pbxproj +++ b/packages/core/ios/AnalyticsReactNative.xcodeproj/project.pbxproj @@ -7,11 +7,7 @@ objects = { /* Begin PBXBuildFile section */ - - - F4FF95D7245B92E800C19C63 /* AnalyticsReactNative.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FF95D6245B92E800C19C63 /* AnalyticsReactNative.swift */; }; - - 5E555C0D2413F4C50049A1A2 /* AnalyticsReactNative.mm in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* AnalyticsReactNative.mm */; }; + F4FF95D7245B92E800C19C63 /* AnalyticsReactNative.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FF95D6245B92E800C19C63 /* AnalyticsReactNative.swift */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -28,12 +24,10 @@ /* Begin PBXFileReference section */ 134814201AA4EA6300B7C361 /* libAnalyticsReactNative.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAnalyticsReactNative.a; sourceTree = BUILT_PRODUCTS_DIR; }; - - B3E7B5891CC2AC0600A0062D /* AnalyticsReactNative.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AnalyticsReactNative.m; sourceTree = "<group>"; }; F4FF95D5245B92E700C19C63 /* AnalyticsReactNative-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AnalyticsReactNative-Bridging-Header.h"; sourceTree = "<group>"; }; F4FF95D6245B92E800C19C63 /* AnalyticsReactNative.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsReactNative.swift; sourceTree = "<group>"; }; - + F615F88C2CCF5F4C007645FE /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -58,12 +52,10 @@ 58B511D21A9E6C8500147676 = { isa = PBXGroup; children = ( - - + F615F88C2CCF5F4C007645FE /* PrivacyInfo.xcprivacy */, F4FF95D6245B92E800C19C63 /* AnalyticsReactNative.swift */, B3E7B5891CC2AC0600A0062D /* AnalyticsReactNative.m */, F4FF95D5245B92E700C19C63 /* AnalyticsReactNative-Bridging-Header.h */, - 134814211AA4EA7D00B7C361 /* Products */, ); sourceTree = "<group>"; @@ -125,11 +117,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - - F4FF95D7245B92E800C19C63 /* AnalyticsReactNative.swift in Sources */, - B3E7B58A1CC2AC0600A0062D /* AnalyticsReactNative.m in Sources */, - ); runOnlyForDeploymentPostprocessing = 0; }; @@ -242,11 +230,9 @@ OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = AnalyticsReactNative; SKIP_INSTALL = YES; - SWIFT_OBJC_BRIDGING_HEADER = "AnalyticsReactNative-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; - }; name = Debug; }; @@ -263,10 +249,8 @@ OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = AnalyticsReactNative; SKIP_INSTALL = YES; - SWIFT_OBJC_BRIDGING_HEADER = "AnalyticsReactNative-Bridging-Header.h"; SWIFT_VERSION = 5.0; - }; name = Release; }; diff --git a/packages/core/ios/PrivacyInfo.xcprivacy b/packages/core/ios/PrivacyInfo.xcprivacy new file mode 100644 index 00000000..c8fd0beb --- /dev/null +++ b/packages/core/ios/PrivacyInfo.xcprivacy @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>NSPrivacyTracking</key> + <false/> + <key>NSPrivacyCollectedDataTypes</key> + <array> + <dict> + <key>NSPrivacyCollectedDataType</key> + <string>NSPrivacyCollectedDataTypeDeviceID</string> + <key>NSPrivacyCollectedDataTypeLinked</key> + <true/> + <key>NSPrivacyCollectedDataTypeTracking</key> + <false/> + <key>NSPrivacyCollectedDataTypePurposes</key> + <array> + <string></string> + </array> + </dict> + <dict> + <key>NSPrivacyCollectedDataType</key> + <string>App Name</string> + <key>NSPrivacyCollectedDataTypeLinked</key> + <false/> + <key>NSPrivacyCollectedDataTypeTracking</key> + <false/> + <key>NSPrivacyCollectedDataTypePurposes</key> + <array> + <string>NSPrivacyCollectedDataTypePurposeDeveloperAdvertising</string> + </array> + </dict> + <dict> + <key>NSPrivacyCollectedDataType</key> + <string>App Version</string> + <key>NSPrivacyCollectedDataTypeLinked</key> + <false/> + <key>NSPrivacyCollectedDataTypeTracking</key> + <false/> + <key>NSPrivacyCollectedDataTypePurposes</key> + <array> + <string>NSPrivacyCollectedDataTypePurposeDeveloperAdvertising</string> + </array> + </dict> + <dict> + <key>NSPrivacyCollectedDataType</key> + <string>NSPrivacyCollectedDataTypeAdvertisingData</string> + <key>NSPrivacyCollectedDataTypeLinked</key> + <false/> + <key>NSPrivacyCollectedDataTypeTracking</key> + <false/> + <key>NSPrivacyCollectedDataTypePurposes</key> + <array> + <string>NSPrivacyCollectedDataTypePurposeDeveloperAdvertising</string> + </array> + </dict> + </array> + <key>NSPrivacyAccessedAPITypes</key> + <array> + <dict> + <key>NSPrivacyAccessedAPIType</key> + <string>NSPrivacyAccessedAPICategoryUserDefaults</string> + <key>NSPrivacyAccessedAPITypeReasons</key> + <array> + <string>1C8F.1</string> + </array> + </dict> + </array> +</dict> +</plist> \ No newline at end of file