From a8c213edf36a1c98cfc75d25eed3552b4f10a617 Mon Sep 17 00:00:00 2001 From: Sylvain Maucourt Date: Thu, 20 May 2021 11:59:14 +0200 Subject: [PATCH 1/5] proposal --- README.md | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8990ee3..4d2885d 100644 --- a/README.md +++ b/README.md @@ -328,7 +328,13 @@ Generated every time a new location is detected "application_name":"herow", "application_version":"3.3.0", "subtype":"CONTEXT", - "ua":"Mozilla/5.0 (iPhone12,1; CPU iPhone OS 14_3 like Mac OS X) FxiOS/3.3.0b518" + "ua":"Mozilla/5.0 (iPhone12,1; CPU iPhone OS 14_3 like Mac OS X) FxiOS/3.3.0b518", + "moments": { + "home": 0.56, + "office": 0.03, + "shopping": 0.02, + "other": 0.23 + } } } ``` @@ -373,7 +379,13 @@ Generated when "tracking mode" is enabled "application_name":"herow", "application_version":"3.3.0", "subtype":"CONTEXT_REALTIME", - "ua":"Mozilla/5.0 (iPhone12,1; CPU iPhone OS 14_3 like Mac OS X) FxiOS/3.3.0b518" + "ua":"Mozilla/5.0 (iPhone12,1; CPU iPhone OS 14_3 like Mac OS X) FxiOS/3.3.0b518", + "moments": { + "home": 0.56, + "office": 0.03, + "shopping": 0.02, + "other": 0.23 + } } } ``` @@ -408,6 +420,12 @@ Sent when a entering zone is detected. "distance":34.90530795095254, "radius":300.0, "confidence":0.456 + }, + "moments": { + "home": 0.56, + "office": 0.03, + "shopping": 0.02, + "other": 0.23 } } } @@ -443,6 +461,12 @@ Sent when a exiting zone is detected. "distance":34.90530795095254, "radius":300.0, "confidence":0.456 + }, + "moments": { + "home": 0.56, + "office": 0.03, + "shopping": 0.02, + "other": 0.23 } } } @@ -512,7 +536,13 @@ Sent when a notification is displayed. "confidence":0.456 }, "campaign_id": "6009ff7c89bfa239ecce712e", - "techno_hash": "1qnn4irqfmghs" + "techno_hash": "1qnn4irqfmghs", + "moments": { + "home": 0.56, + "office": 0.03, + "shopping": 0.02, + "other": 0.23 + } } } ``` From 12d8c263a30dd858aacc43f8c70a81f174d21359 Mon Sep 17 00:00:00 2001 From: Sylvain Maucourt Date: Tue, 25 Jan 2022 11:12:14 +0100 Subject: [PATCH 2/5] Update README.md --- README.md | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/README.md b/README.md index 4d2885d..f39350d 100644 --- a/README.md +++ b/README.md @@ -420,12 +420,6 @@ Sent when a entering zone is detected. "distance":34.90530795095254, "radius":300.0, "confidence":0.456 - }, - "moments": { - "home": 0.56, - "office": 0.03, - "shopping": 0.02, - "other": 0.23 } } } @@ -461,12 +455,6 @@ Sent when a exiting zone is detected. "distance":34.90530795095254, "radius":300.0, "confidence":0.456 - }, - "moments": { - "home": 0.56, - "office": 0.03, - "shopping": 0.02, - "other": 0.23 } } } @@ -536,13 +524,7 @@ Sent when a notification is displayed. "confidence":0.456 }, "campaign_id": "6009ff7c89bfa239ecce712e", - "techno_hash": "1qnn4irqfmghs", - "moments": { - "home": 0.56, - "office": 0.03, - "shopping": 0.02, - "other": 0.23 - } + "techno_hash": "1qnn4irqfmghs" } } ``` From 8830a71b1a09921e7ced0d5cfe9da86ede4148eb Mon Sep 17 00:00:00 2001 From: Sylvain Maucourt Date: Tue, 25 Jan 2022 11:13:17 +0100 Subject: [PATCH 3/5] moments are available only during CONTEXT From a3c3a85a75c5108430b8e9dcf57b04365b2b3833 Mon Sep 17 00:00:00 2001 From: Sylvain Maucourt Date: Tue, 25 Jan 2022 11:22:49 +0100 Subject: [PATCH 4/5] predictions proposal --- userinfo.json | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/userinfo.json b/userinfo.json index 2917134..34a42a7 100644 --- a/userinfo.json +++ b/userinfo.json @@ -1,7 +1,38 @@ { - "customId": "my-custom-id", - "adId": "adIdon10charsAndMore", - "optins": [ - { "type": "USER_DATA", "value": true } - ] + "location": { + "status": "WHILE_IN_USE", + "precision": "FINE" + }, + "offset": 3600000, + "lang": "en", + "adId": "28C89993-E2AB-45A4-B097-81BAE7BA7750", + "optins": [{ + "type": "USER_DATA", + "value": true + }], + "predictions": { + "tags": [{ + "tag": "Convenience Store", + "pattern": { + "monday_late_afternoon": 0.13, + "tuesday_evening": 0.6 + } + }, + { + "tag": "Intermarche Contact", + "pattern": { + "monday_morning": 0.85, + "friday_evening": 0.12 + } + }], + "zones": [{ + "id": "3f7e5b9dfa6df282b7bffe43557b1bdb", + "pattern": { + "thursday_early_morning": 0.37, + "thursday_late_afternoon": 0.62 + } + }] + }, + "customId": "Damien", + "adStatus": true } From 4c5e18d58667748a7286e247a4e0697fc9cfecf8 Mon Sep 17 00:00:00 2001 From: Sylvain Maucourt Date: Mon, 31 Jan 2022 13:26:01 +0100 Subject: [PATCH 5/5] implementation done :+1: --- log_context.json | 8 ++- routes/information.js | 146 ++++++++++++++++++++++++++++++++++++++++-- routes/logs.js | 1 + userinfo.json | 4 +- 4 files changed, 150 insertions(+), 9 deletions(-) diff --git a/log_context.json b/log_context.json index 013598f..965bc25 100644 --- a/log_context.json +++ b/log_context.json @@ -34,6 +34,12 @@ "application_name":"herow", "application_version":"3.3.0", "subtype":"CONTEXT", - "ua":"Mozilla/5.0 (iPhone12,1; CPU iPhone OS 14_3 like Mac OS X) FxiOS/3.3.0b518" + "ua":"Mozilla/5.0 (iPhone12,1; CPU iPhone OS 14_3 like Mac OS X) FxiOS/3.3.0b518", + "moments": { + "home": 0.56, + "office": 0.03, + "shopping": 0.02, + "other": 0.23 + } } } \ No newline at end of file diff --git a/routes/information.js b/routes/information.js index 53f7839..6fb46ce 100644 --- a/routes/information.js +++ b/routes/information.js @@ -13,21 +13,155 @@ module.exports = async function (fastify, options) { properties: { adId: { type: 'string', minLength: 10 }, customId: { type: 'string' }, - optins: { type: 'array', + optins: { + type: 'array', minItems: 1, maxItems: 1, - items: { type: 'object', - properties: { + items: { + type: 'object', + properties: { type: { type: 'string', enum: [ 'USER_DATA' ] }, value: { type: 'boolean' } - } - } + } + } }, - location: { type: 'object', + location: { + type: 'object', properties: { status: { type: 'string', enum: [ 'ALWAYS', 'WHILE_IN_USE', 'NOT_DETERMINED', 'DENIED' ] }, precision: { type: 'string', enum: [ 'FINE', 'COARSE' ] } } + }, + predictions: { + type: 'object', + properties: { + tags: { + type: 'array', + items: { + type: 'object', + properties: { + tag: { type: 'string', minLength: 2 }, + pattern: { + type: 'object', + properties: { + monday_early_morning: { type: 'number' }, + monday_late_morning: { type: 'number' }, + monday_lunch_time: { type: 'number' }, + monday_early_afternoon: { type: 'number' }, + monday_late_afternoon: { type: 'number' }, + monday_evening: { type: 'number' }, + monday_night: { type: 'number' }, + tuesday_early_morning: { type: 'number' }, + tuesday_late_morning: { type: 'number' }, + tuesday_lunch_time: { type: 'number' }, + tuesday_early_afternoon: { type: 'number' }, + tuesday_late_afternoon: { type: 'number' }, + tuesday_evening: { type: 'number' }, + tuesday_night: { type: 'number' }, + wednesday_early_morning: { type: 'number' }, + wednesday_late_morning: { type: 'number' }, + wednesday_lunch_time: { type: 'number' }, + wednesday_early_afternoon: { type: 'number' }, + wednesday_late_afternoon: { type: 'number' }, + wednesday_evening: { type: 'number' }, + wednesday_night: { type: 'number' }, + thursday_early_morning: { type: 'number' }, + thursday_late_morning: { type: 'number' }, + thursday_lunch_time: { type: 'number' }, + thursday_early_afternoon: { type: 'number' }, + thursday_late_afternoon: { type: 'number' }, + thursday_evening: { type: 'number' }, + thursday_night: { type: 'number' }, + friday_early_morning: { type: 'number' }, + friday_late_morning: { type: 'number' }, + friday_lunch_time: { type: 'number' }, + friday_early_afternoon: { type: 'number' }, + friday_late_afternoon: { type: 'number' }, + friday_evening: { type: 'number' }, + friday_night: { type: 'number' }, + saturday_early_morning: { type: 'number' }, + saturday_late_morning: { type: 'number' }, + saturday_lunch_time: { type: 'number' }, + saturday_early_afternoon: { type: 'number' }, + saturday_late_afternoon: { type: 'number' }, + saturday_evening: { type: 'number' }, + saturday_night: { type: 'number' }, + sunday_early_morning: { type: 'number' }, + sunday_late_morning: { type: 'number' }, + sunday_lunch_time: { type: 'number' }, + sunday_early_afternoon: { type: 'number' }, + sunday_late_afternoon: { type: 'number' }, + sunday_evening: { type: 'number' }, + sunday_night: { type: 'number' }, + } + } + } + } + }, + zones: { + type: 'array', + items: { + type: 'object', + properties: { + id: { type: 'string', minLength: 2 }, + pattern: { + type: 'object', + properties: { + monday_early_morning: { type: 'number' }, + monday_late_morning: { type: 'number' }, + monday_lunch_time: { type: 'number' }, + monday_early_afternoon: { type: 'number' }, + monday_late_afternoon: { type: 'number' }, + monday_evening: { type: 'number' }, + monday_night: { type: 'number' }, + tuesday_early_morning: { type: 'number' }, + tuesday_late_morning: { type: 'number' }, + tuesday_lunch_time: { type: 'number' }, + tuesday_early_afternoon: { type: 'number' }, + tuesday_late_afternoon: { type: 'number' }, + tuesday_evening: { type: 'number' }, + tuesday_night: { type: 'number' }, + wednesday_early_morning: { type: 'number' }, + wednesday_late_morning: { type: 'number' }, + wednesday_lunch_time: { type: 'number' }, + wednesday_early_afternoon: { type: 'number' }, + wednesday_late_afternoon: { type: 'number' }, + wednesday_evening: { type: 'number' }, + wednesday_night: { type: 'number' }, + thursday_early_morning: { type: 'number' }, + thursday_late_morning: { type: 'number' }, + thursday_lunch_time: { type: 'number' }, + thursday_early_afternoon: { type: 'number' }, + thursday_late_afternoon: { type: 'number' }, + thursday_evening: { type: 'number' }, + thursday_night: { type: 'number' }, + friday_early_morning: { type: 'number' }, + friday_late_morning: { type: 'number' }, + friday_lunch_time: { type: 'number' }, + friday_early_afternoon: { type: 'number' }, + friday_late_afternoon: { type: 'number' }, + friday_evening: { type: 'number' }, + friday_night: { type: 'number' }, + saturday_early_morning: { type: 'number' }, + saturday_late_morning: { type: 'number' }, + saturday_lunch_time: { type: 'number' }, + saturday_early_afternoon: { type: 'number' }, + saturday_late_afternoon: { type: 'number' }, + saturday_evening: { type: 'number' }, + saturday_night: { type: 'number' }, + sunday_early_morning: { type: 'number' }, + sunday_late_morning: { type: 'number' }, + sunday_lunch_time: { type: 'number' }, + sunday_early_afternoon: { type: 'number' }, + sunday_late_afternoon: { type: 'number' }, + sunday_evening: { type: 'number' }, + sunday_night: { type: 'number' }, + } + } + } + } + } + } } } }, diff --git a/routes/logs.js b/routes/logs.js index 147a86a..b21984d 100644 --- a/routes/logs.js +++ b/routes/logs.js @@ -41,6 +41,7 @@ module.exports = async function (fastify, options) { req.body.data.custom_id = userinfo_json?.customId req.body.data.location_status = userinfo_json?.location?.status req.body.data.location_precision = userinfo_json?.location?.precision + req.body.data.predictions = userinfo_json?.predictions await fastify.kafka.send({ topic: process.env.KAFKA_TOPIC || 'stat-logs', diff --git a/userinfo.json b/userinfo.json index 34a42a7..c9f3c98 100644 --- a/userinfo.json +++ b/userinfo.json @@ -21,7 +21,7 @@ { "tag": "Intermarche Contact", "pattern": { - "monday_morning": 0.85, + "monday_early_morning": 0.85, "friday_evening": 0.12 } }], @@ -35,4 +35,4 @@ }, "customId": "Damien", "adStatus": true -} +} \ No newline at end of file