This repository was archived by the owner on Mar 27, 2024. It is now read-only.
File tree 4 files changed +15
-9
lines changed
4 files changed +15
-9
lines changed Original file line number Diff line number Diff line change 1
1
module . exports = {
2
2
semi : true ,
3
- // trailingComma: 'all',
4
3
singleQuote : true ,
5
4
tabWidth : 2
6
5
} ;
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ interface IPageFeatureGetter {
15
15
16
16
// TODO: we need to give a way to consumers to ensure this does not
17
17
// run multiple times on a single page load.
18
- const run = async ( config : IConfig ) => {
18
+ const run = async ( config : IConfig ) : Promise < void > => {
19
19
const { pageFeatureGetters } = config ;
20
20
const pageFeatures = await getPageFeatures ( pageFeatureGetters ) ;
21
21
viewStore . insert ( pageFeatures ) ;
@@ -29,6 +29,7 @@ const run = async (config: IConfig) => {
29
29
id : audience . id ,
30
30
matchedAt : timeStampInSecs ( ) ,
31
31
expiresAt : timeStampInSecs ( ) + audience . ttl ,
32
+ matchedOnCurrentPageView : true ,
32
33
matched : engine . check ( audience . conditions , viewStore . pageViews ) ,
33
34
} ;
34
35
} )
@@ -37,11 +38,11 @@ const run = async (config: IConfig) => {
37
38
audienceStore . setMatchedAudiences ( matchedAudiences ) ;
38
39
} ;
39
40
40
- const stats = ( ) => {
41
- return { } ;
41
+ const getMatchedAudiences = ( ) => {
42
+ return audienceStore . matchedAudiences ;
42
43
} ;
43
44
44
45
export const edkt = {
45
46
run,
46
- stats ,
47
+ getMatchedAudiences ,
47
48
} ;
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ interface IMatchedAudience {
10
10
id : string ;
11
11
matchedAt : number ;
12
12
expiresAt : number ;
13
+ matchedOnCurrentPageView : boolean ;
13
14
}
14
15
15
16
// TODO: share the types.
@@ -26,9 +27,14 @@ class AudienceStore {
26
27
_load ( ) {
27
28
const audiences : IMatchedAudience [ ] =
28
29
storage . get ( StorageKeys . MATCHED_AUDIENCES ) || [ ] ;
29
- const unExpiredAudiences = audiences . filter (
30
- ( audience ) => audience . expiresAt > timeStampInSecs ( )
31
- ) ;
30
+ const unExpiredAudiences = audiences
31
+ . filter ( ( audience ) => audience . expiresAt > timeStampInSecs ( ) )
32
+ . map ( ( audience ) => {
33
+ return {
34
+ ...audience ,
35
+ matchedOnCurrentPageView : false ,
36
+ } ;
37
+ } ) ;
32
38
const unExpiredAudienceIds = unExpiredAudiences . map (
33
39
( audience ) => audience . id
34
40
) ;
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ const get = (key: string) => {
11
11
}
12
12
} ;
13
13
14
- const set = ( key : string , value : object ) => {
14
+ const set = ( key : string , value : any ) => {
15
15
try {
16
16
const serialized = JSON . stringify ( value ) ;
17
17
localStorage . setItem ( key , serialized ) ;
You can’t perform that action at this time.
0 commit comments