Skip to content

Commit

Permalink
feat: make the id param optional in GB setAttribute (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-hosseini-deriv authored Sep 3, 2024
1 parent 4e22280 commit 8c8c8a3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/analytics.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Growthbook, GrowthbookConfigs } from './growthbook'
import { RudderStack } from './rudderstack'
import { TCoreAttributes, TEvents, TGrowthbookOptions } from './types'
import { TCoreAttributes, TEvents, TGrowthbookAttributes, TGrowthbookOptions } from './types'

type Options = {
growthbookKey?: string
Expand Down Expand Up @@ -83,8 +83,7 @@ export function createAnalyticsInstance(options?: Options) {

// Check if we have Growthbook instance
if (_growthbook) {
_growthbook.setAttributes({
id: user_identity || getId(),
const config: TGrowthbookAttributes = {
country,
residence_country,
user_language,
Expand All @@ -96,7 +95,9 @@ export function createAnalyticsInstance(options?: Options) {
is_authorised,
url,
domain,
})
}
if (user_identity) config.id = user_identity
_growthbook.setAttributes(config)
}

core_data = {
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Context } from '@growthbook/growthbook'

export type TGrowthbookAttributes = {
id: string
id?: string
country?: string
user_language?: string
device_language?: string
Expand Down

0 comments on commit 8c8c8a3

Please sign in to comment.