Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: integrate core package into experiment sdk #16

Merged
merged 81 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
c181d36
initial impl; need update logic, tests, deployment
bgiori Nov 18, 2021
0de477c
fix export, add test files
bgiori Nov 18, 2021
cc25e5a
add basic test case
bgiori Nov 18, 2021
1c8b8d9
fix lint, add update user properties logic; TODO Tests
bgiori Nov 19, 2021
ace689b
complete tests
bgiori Nov 22, 2021
ecda2d4
add amplitude-js as dev dependencies and clean up redeclared any
bgiori Nov 22, 2021
f3fbbfc
core instances be stored in global var
bgiori Nov 23, 2021
8e8638d
commented code for consumer/producer
bgiori Nov 29, 2021
0f40f3c
remove provider consumer
bgiori Nov 29, 2021
623b499
feat: integrate experiment and analytics with initWithAmplitude
bgiori Nov 29, 2021
fda7083
rename factory method
bgiori Nov 29, 2021
c8bd5af
update comment
bgiori Nov 29, 2021
2b7ba13
update test
bgiori Nov 29, 2021
27bc678
update tests
bgiori Nov 29, 2021
b0c2a90
use static init
bgiori Nov 30, 2021
b1073c7
Merge branch 'core' into experiment-core
bgiori Nov 30, 2021
189282b
update core
bgiori Nov 30, 2021
363aa5f
fix build
bgiori Nov 30, 2021
6c24e30
minor change
bgiori Nov 30, 2021
9bb2b92
update rollup
bgiori Nov 30, 2021
a90cd88
remove unecessary dev deps
bgiori Dec 1, 2021
3c6af81
Merge branch 'core' into experiment-core
bgiori Dec 6, 2021
fbd0f17
1.4.0-alpha.0
bgiori Dec 6, 2021
60d1e9f
use real core dependency
bgiori Dec 6, 2021
c52e337
fix crash in initWithAmplitude
bgiori Dec 6, 2021
1ff84d4
only track exposure changes or once per session
bgiori Dec 7, 2021
c816699
await ready when adding user context from core user provider
bgiori Dec 7, 2021
2df2a81
await context in doFetch
bgiori Dec 7, 2021
a8f02f1
merge provided and explicit user properties
bgiori Dec 7, 2021
2558e50
1.4.0-alpha.3
bgiori Dec 7, 2021
ff60d84
copy user properties when editing identity to call listener
bgiori Dec 8, 2021
a45e394
Merge branch 'core' into experiment-core
bgiori Dec 8, 2021
b3c0897
0.0.2
bgiori Dec 8, 2021
a4ea20f
Merge branch 'core' into experiment-core
bgiori Dec 8, 2021
c585cb9
update core dependency
bgiori Dec 8, 2021
c8069d0
1.4.0-alpha.4
bgiori Dec 8, 2021
88888dd
1.4.0-alpha.5
bgiori Dec 8, 2021
91f6987
0.0.3
bgiori Dec 8, 2021
7396960
Merge branch 'core' into experiment-core
bgiori Dec 8, 2021
8fb0ebe
alpha 5
bgiori Dec 8, 2021
e6e9e52
alpha 6
bgiori Dec 8, 2021
40bcd30
track unsets to not spam useless identify calls
bgiori Dec 10, 2021
4932cb0
fix tests
bgiori Dec 10, 2021
baa3e3e
add test for unset only called once
bgiori Dec 13, 2021
ca7f2ff
fix core tests
bgiori Dec 13, 2021
5f5bd92
Merge branch 'core' into experiment-core
bgiori Dec 13, 2021
e46e8e8
remove debug from client
bgiori Dec 13, 2021
cedabf5
alpha 8
bgiori Dec 13, 2021
cb0f42c
use @deprecated comment
bgiori Dec 13, 2021
5f04d68
add max queue size
bgiori Dec 13, 2021
7c7af70
support multiple instances; alpha 9
bgiori Dec 14, 2021
c522ed2
add app context provider to core
bgiori Dec 17, 2021
d521caf
Merge branch 'core' into experiment-core
bgiori Dec 17, 2021
512cf73
default user provider
bgiori Dec 20, 2021
cf214a1
1.0.0-alpha.0
bgiori Dec 20, 2021
72d4e0f
Merge branch 'core' into experiment-core
bgiori Dec 20, 2021
8428bad
remove unused function causing problems
bgiori Dec 20, 2021
0b1a206
1.0.0-alpha.10
bgiori Dec 20, 2021
c9ffcc7
remove non-idempotent id operations
bgiori Jan 10, 2022
a2e5230
Merge branch 'core' into experiment-core
bgiori Jan 10, 2022
ae3b908
use session analytics provider by default; config for auto cset
bgiori Jan 12, 2022
c4790ee
remove core changes
bgiori Jan 13, 2022
c23a82b
yarn lock
bgiori Jan 13, 2022
c3cf38b
Merge branch 'main' into experiment-core
bgiori Jan 14, 2022
beeb3ff
fix test
bgiori Jan 14, 2022
7f95ece
Merge branch 'main' into experiment-core
bgiori Jan 20, 2022
66995db
add auto fetch on id change config
bgiori Jan 21, 2022
2ca3eca
add timeout to waiting on identity
bgiori Jan 21, 2022
c294ffa
Merge branch 'main' into experiment-core
bgiori Jan 24, 2022
f80788f
fix comments; todos
bgiori Jan 24, 2022
6ad9f25
update factory comment for integration
bgiori Jan 24, 2022
449f3da
use v1 of core
bgiori Jan 26, 2022
8b14a61
remove delays
bgiori Jan 26, 2022
da429a6
Merge branch 'main' into experiment-core
bgiori Jan 26, 2022
112a0f6
revert package.version to 1.3.4
bgiori Jan 26, 2022
32511bb
add exposure method to manually track exposures
bgiori Jan 26, 2022
12ad959
add exposure function to client itface
bgiori Jan 26, 2022
1e406eb
fix lint
bgiori Jan 26, 2022
03d3fd0
add method to stub
bgiori Jan 26, 2022
a5884be
fix lint
bgiori Jan 26, 2022
48644a1
try to fix build for node v10
bgiori Jan 26, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,8 @@
"tslib": "^2.0.1",
"typedoc": "^0.20.32",
"typescript": "^3.9.7"
},
"resolutions": {
"@testing-library/dom": "7.26.0"
}
}
7 changes: 6 additions & 1 deletion packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@
"homepage": "https://github.com/amplitude/experiment-js-client#readme",
"dependencies": {
"base64-js": "1.5.1",
"unfetch": "4.1.0"
"unfetch": "4.1.0",
"@amplitude/amplitude-core": "1.0.0"
},
"devDependencies": {
"@types/amplitude-js": "^8.0.2",
"amplitude-js": "^8.12.0"
},
"gitHead": "0a910f04a64dafcf37b68be45ed7dca58fdd6acf"
}
35 changes: 35 additions & 0 deletions packages/browser/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ export interface ExperimentConfig {
*/
debug?: boolean;

/**
* The name of the instance being initialized. Used for initializing separate
* instances of experiment or linking the experiment SDK to a specific
* instance of the amplitude analytics SDK.
*/
instanceName?: string;

/**
* The default fallback variant for all {@link ExperimentClient.variant}
* calls.
Expand Down Expand Up @@ -50,6 +57,28 @@ export interface ExperimentConfig {
*/
retryFetchOnFailure?: boolean;

/**
* If true, automatically tracks exposure events though the
* `ExperimentAnalyticsProvider`. If no analytics provider is set, this
* option does nothing.
*/
automaticClientSideExposureTracking?: boolean;

/**
* This config only matters if you are using the amplitude analytics SDK
* integration initialized by calling
* `Experiment.initializeWithAmplitudeAnalytics()`.
*
* If true, the `ExperimentClient` will automatically fetch variants when the
* user's identity changes. The user's identity includes user_id, device_id
* and any user properties which are `set`, `unset` or `clearAll`ed via a call
* to `identify()`.
*
* Note: Non-idempotent identify operations `setOnce`, `add`, `append`, and
* `prepend` are not counted towards the user identity changing.
*/
automaticFetchOnAmplitudeIdentityChange?: boolean;

/**
* Sets a user provider that will inject identity information into the user
* for {@link fetch()} requests. The user provider will only set user fields
Expand All @@ -72,12 +101,15 @@ export interface ExperimentConfig {
| **Option** | **Default** |
|------------------|-----------------------------------|
| **debug** | `false` |
| **instanceName** | `$default_instance` |
| **fallbackVariant** | `null` |
| **initialVariants** | `null` |
| **source** | `Source.LocalStorage` |
| **serverUrl** | `"https://api.lab.amplitude.com"` |
| **assignmentTimeoutMillis** | `10000` |
| **retryFailedAssignment** | `true` |
| **automaticClientSideExposureTracking** | `true` |
| **automaticFetchOnAmplitudeIdentityChange** | `false` |
| **userProvider** | `null` |
| **analyticsProvider** | `null` |

Expand All @@ -86,12 +118,15 @@ export interface ExperimentConfig {
*/
export const Defaults: ExperimentConfig = {
debug: false,
instanceName: '$default_instance',
fallbackVariant: {},
initialVariants: {},
source: Source.LocalStorage,
serverUrl: 'https://api.lab.amplitude.com',
fetchTimeoutMillis: 10000,
retryFetchOnFailure: true,
automaticClientSideExposureTracking: true,
automaticFetchOnAmplitudeIdentityChange: false,
userProvider: null,
analyticsProvider: null,
};
Loading