-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add app_set_id, idfa and idfv support (#458)
* fix: do not fetch advertising Id if adid tracking is disabled (#424) * fix: do not fetch advertising Id if adid tracking is disabled * fix: ios compilation * fix: add app_set_id, idfa and idfv support
- Loading branch information
1 parent
8f4ea01
commit 00c6cac
Showing
13 changed files
with
107 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Types } from '@amplitude/analytics-react-native'; | ||
import ReactNativeIdfaAaid from '@sparkfabrik/react-native-idfa-aaid'; | ||
|
||
export default class IdfaPlugin implements Types.BeforePlugin { | ||
name = 'idfa'; | ||
type = 'before' as const; | ||
idfa: string | null = null; | ||
|
||
async setup(_config: Types.Config): Promise<undefined> { | ||
try { | ||
const info = await ReactNativeIdfaAaid.getAdvertisingInfo(); | ||
this.idfa = info.id; | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
return undefined; | ||
} | ||
|
||
async execute(context: Types.Event): Promise<Types.Event> { | ||
if (this.idfa) { | ||
context.idfa = this.idfa; | ||
} | ||
return context; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,8 @@ describe('context', () => { | |
osName: false, | ||
osVersion: false, | ||
platform: false, | ||
appSetId: false, | ||
idfv: false, | ||
}, | ||
userId: '[email protected]', | ||
}); | ||
|
@@ -92,6 +94,9 @@ describe('context', () => { | |
expect(firstContextEvent.os_version).toBeUndefined(); | ||
expect(firstContextEvent.language).toBeUndefined(); | ||
expect(firstContextEvent.ip).toBeUndefined(); | ||
expect(firstContextEvent.adid).toBeUndefined(); | ||
expect(firstContextEvent.android_app_set_id).toBeUndefined(); | ||
expect(firstContextEvent.idfv).toBeUndefined(); | ||
expect(firstContextEvent.device_id).toEqual('deviceId'); | ||
expect(firstContextEvent.session_id).toEqual(1); | ||
expect(firstContextEvent.user_id).toEqual('[email protected]'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters