@@ -179,6 +179,190 @@ Type: `Boolean`
179179
180180` LOG_BODY ` is default to true, set to false to remove logging request and response body to Moesif.
181181
182+ ## Update User
183+
184+ ### Update A Single User
185+ Create or update a user profile in Moesif.
186+ The metadata field can be any customer demographic or other info you want to store.
187+ Only the ` user_id ` field is required.
188+ For details, visit the [ Python API Reference] ( https://www.moesif.com/docs/api?python#update-a-user ) .
189+
190+ ``` python
191+ from moesif_aws_lambda.middleware import *
192+
193+ moesif_options = {
194+ ' LOG_BODY' : True ,
195+ ' DEBUG' : True ,
196+ }
197+
198+ # Only user_id is required.
199+ # Campaign object is optional, but useful if you want to track ROI of acquisition channels
200+ # See https://www.moesif.com/docs/api#users for campaign schema
201+ # metadata can be any custom object
202+ user = {
203+ ' user_id' : ' 12345' ,
204+ ' company_id' : ' 67890' , # If set, associate user with a company object
205+ ' campaign' : {
206+ ' utm_source' : ' google' ,
207+ ' utm_medium' : ' cpc' ,
208+ ' utm_campaign' : ' adwords' ,
209+ ' utm_term' : ' api+tooling' ,
210+ ' utm_content' : ' landing'
211+ },
212+ ' metadata' : {
213+ ' email' : ' john@acmeinc.com' ,
214+ ' first_name' : ' John' ,
215+ ' last_name' : ' Doe' ,
216+ ' title' : ' Software Engineer' ,
217+ ' sales_info' : {
218+ ' stage' : ' Customer' ,
219+ ' lifetime_value' : 24000 ,
220+ ' account_owner' : ' mary@contoso.com'
221+ },
222+ }
223+ }
224+
225+ update_user(user, moesif_options)
226+ ```
227+
228+ ### Update Users in Batch
229+ Similar to update_user, but used to update a list of users in one batch.
230+ Only the ` user_id ` field is required.
231+ For details, visit the [ Python API Reference] ( https://www.moesif.com/docs/api?python#update-users-in-batch ) .
232+
233+ ``` python
234+ from moesif_aws_lambda.middleware import *
235+
236+ moesif_options = {
237+ ' LOG_BODY' : True ,
238+ ' DEBUG' : True ,
239+ }
240+
241+ userA = {
242+ ' user_id' : ' 12345' ,
243+ ' company_id' : ' 67890' , # If set, associate user with a company object
244+ ' metadata' : {
245+ ' email' : ' john@acmeinc.com' ,
246+ ' first_name' : ' John' ,
247+ ' last_name' : ' Doe' ,
248+ ' title' : ' Software Engineer' ,
249+ ' sales_info' : {
250+ ' stage' : ' Customer' ,
251+ ' lifetime_value' : 24000 ,
252+ ' account_owner' : ' mary@contoso.com'
253+ },
254+ }
255+ }
256+
257+ userB = {
258+ ' user_id' : ' 54321' ,
259+ ' company_id' : ' 67890' , # If set, associate user with a company object
260+ ' metadata' : {
261+ ' email' : ' mary@acmeinc.com' ,
262+ ' first_name' : ' Mary' ,
263+ ' last_name' : ' Jane' ,
264+ ' title' : ' Software Engineer' ,
265+ ' sales_info' : {
266+ ' stage' : ' Customer' ,
267+ ' lifetime_value' : 48000 ,
268+ ' account_owner' : ' mary@contoso.com'
269+ },
270+ }
271+ }
272+ update_users_batch([userA, userB], moesif_options)
273+ ```
274+
275+ ## Update Company
276+
277+ ### Update A Single Company
278+ Create or update a company profile in Moesif.
279+ The metadata field can be any company demographic or other info you want to store.
280+ Only the ` company_id ` field is required.
281+ For details, visit the [ Python API Reference] ( https://www.moesif.com/docs/api?python#update-a-company ) .
282+
283+ ``` python
284+ from moesif_aws_lambda.middleware import *
285+
286+ moesif_options = {
287+ ' LOG_BODY' : True ,
288+ ' DEBUG' : True ,
289+ }
290+
291+ # Only company_id is required.
292+ # Campaign object is optional, but useful if you want to track ROI of acquisition channels
293+ # See https://www.moesif.com/docs/api#update-a-company for campaign schema
294+ # metadata can be any custom object
295+ company = {
296+ ' company_id' : ' 67890' ,
297+ ' company_domain' : ' acmeinc.com' , # If domain is set, Moesif will enrich your profiles with publicly available info
298+ ' campaign' : {
299+ ' utm_source' : ' google' ,
300+ ' utm_medium' : ' cpc' ,
301+ ' utm_campaign' : ' adwords' ,
302+ ' utm_term' : ' api+tooling' ,
303+ ' utm_content' : ' landing'
304+ },
305+ ' metadata' : {
306+ ' org_name' : ' Acme, Inc' ,
307+ ' plan_name' : ' Free' ,
308+ ' deal_stage' : ' Lead' ,
309+ ' mrr' : 24000 ,
310+ ' demographics' : {
311+ ' alexa_ranking' : 500000 ,
312+ ' employee_count' : 47
313+ },
314+ }
315+ }
316+
317+ update_company(company, moesif_options)
318+ ```
319+
320+ ### Update Companies in Batch
321+ Similar to update_company, but used to update a list of companies in one batch.
322+ Only the ` company_id ` field is required.
323+ For details, visit the [ Python API Reference] ( https://www.moesif.com/docs/api?python#update-companies-in-batch ) .
324+
325+ ``` python
326+ from moesif_aws_lambda.middleware import *
327+
328+ moesif_options = {
329+ ' LOG_BODY' : True ,
330+ ' DEBUG' : True ,
331+ }
332+
333+ companyA = {
334+ ' company_id' : ' 67890' ,
335+ ' company_domain' : ' acmeinc.com' , # If domain is set, Moesif will enrich your profiles with publicly available info
336+ ' metadata' : {
337+ ' org_name' : ' Acme, Inc' ,
338+ ' plan_name' : ' Free' ,
339+ ' deal_stage' : ' Lead' ,
340+ ' mrr' : 24000 ,
341+ ' demographics' : {
342+ ' alexa_ranking' : 500000 ,
343+ ' employee_count' : 47
344+ },
345+ }
346+ }
347+
348+ companyB = {
349+ ' company_id' : ' 09876' ,
350+ ' company_domain' : ' contoso.com' , # If domain is set, Moesif will enrich your profiles with publicly available info
351+ ' metadata' : {
352+ ' org_name' : ' Contoso, Inc' ,
353+ ' plan_name' : ' Free' ,
354+ ' deal_stage' : ' Lead' ,
355+ ' mrr' : 48000 ,
356+ ' demographics' : {
357+ ' alexa_ranking' : 500000 ,
358+ ' employee_count' : 53
359+ },
360+ }
361+ }
362+
363+ update_companies_batch([companyA, companyB], moesif_options)
364+ ```
365+
182366## Examples
183367
184368- [ A complete example is available on GitHub] ( https://github.com/Moesif/moesif-aws-lambda-python-example ) .
0 commit comments