Skip to content

Commit

Permalink
fix: add user ip to growthbook options
Browse files Browse the repository at this point in the history
  • Loading branch information
amam-deriv committed Sep 9, 2024
1 parent d3215c9 commit eac0b13
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export function createAnalyticsInstance(options?: Options) {
device_type: growthbookOptions?.attributes.device_type,
}),
...(growthbookOptions?.attributes?.url && { url: growthbookOptions?.attributes.url }),
...(growthbookOptions?.attributes?.user_ip && { url: growthbookOptions?.attributes.user_ip }),
}
growthbookOptions ??= {}
growthbookOptions.attributes ??= {}
Expand Down Expand Up @@ -97,6 +98,7 @@ export function createAnalyticsInstance(options?: Options) {
url,
domain,
geo_location,
user_ip,
}: TCoreAttributes) => {
if (!_growthbook && !_rudderstack) return

Expand All @@ -116,6 +118,7 @@ export function createAnalyticsInstance(options?: Options) {
is_authorised,
url,
domain,
user_ip,
}
if (user_identity) config.id = user_identity
_growthbook.setAttributes(config)
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type TGrowthbookAttributes = {
domain?: string
utm_content?: string
residence_country?: string
user_ip?: string
}

export type TGrowthbookOptions = Partial<Omit<Context, 'attributes'> & { attributes: TCoreAttributes }>
Expand Down

0 comments on commit eac0b13

Please sign in to comment.