@@ -21,48 +21,13 @@ pip install moesif_aws_lambda
21
21
22
22
## How to use
23
23
24
- The following shows how import the module and use:
25
-
26
- ### 1. Import the module:
24
+ ### 1. Add middleware to your Lambda application.
27
25
28
26
``` python
29
27
from moesif_aws_lambda.middleware import MoesifLogger
30
- import os
31
-
32
- # Moesif Application Id
33
- os.environ[" MOESIF_APPLICATION_ID" ] = " Your Moesif Application Id"
34
-
35
- def identify_user (event , context ):
36
- return ' my_user_id'
37
-
38
- def identify_company (event , context ):
39
- return ' my_company_id'
40
-
41
- def get_api_version (event , context ):
42
- return ' 1.0.0'
43
-
44
- def get_session_token (event , context ):
45
- return ' 23jdf0owekfmcn4u3qypxg09w4d8ayrcdx8nu2ng]s98y18cx98q3yhwmnhcfx43f'
46
-
47
- def get_metadata (event , context ):
48
- return { ' foo' : ' aws lambda' , ' bar' : ' aws lambda metadata' , }
49
-
50
- def mask_event (eventmodel ):
51
- return eventmodel
52
-
53
- def should_skip (event , context ):
54
- return " /" in event[' path' ]
55
28
56
29
moesif_options = {
57
- ' GET_METADATA' : get_metadata,
58
- ' IDENTIFY_USER' : identify_user,
59
- ' IDENTIFY_COMPANY' : identify_company,
60
- ' GET_SESSION_TOKEN' : get_session_token,
61
- ' GET_API_VERSION' : get_api_version,
62
- ' MASK_EVENT_MODEL' : mask_event,
63
- ' SKIP' : should_skip,
64
- ' LOG_BODY' : True ,
65
- ' DEBUG' : True
30
+ ' LOG_BODY' : True
66
31
}
67
32
68
33
@MoesifLogger (moesif_options)
@@ -79,8 +44,10 @@ def lambda_handler(event, context):
79
44
}
80
45
```
81
46
82
- ### 2. Enter Moesif Application Id
83
- Your Moesif Application Id can be found in the [ _ Moesif Portal_ ] ( https://www.moesif.com/ ) .
47
+ ### 2. Set MOESIF_APPLICATION_ID environment variable
48
+
49
+ Add a new environment variable with the name ` MOESIF_APPLICATION_ID ` and the value being your Moesif application id,
50
+ which can be found in the [ _ Moesif Portal_ ] ( https://www.moesif.com/ ) .
84
51
After signing up for a Moesif account, your Moesif Application Id will be displayed during the onboarding steps.
85
52
86
53
You can always find your Moesif Application Id at any time by logging
@@ -124,7 +91,7 @@ individual customers and the companies their a part of.
124
91
``` python
125
92
def identify_company (event , context ):
126
93
# your code here, must return a string
127
- return ' my_company_id '
94
+ return ' 7890 '
128
95
}
129
96
```
130
97
@@ -139,7 +106,7 @@ session token (i.e. such as an API key).
139
106
``` python
140
107
def get_session_token (event , context ):
141
108
# your code here, must return a string.
142
- return ' 23jdf0owekfmcn4u3qypxg09w4d8ayrcdx8nu2ng]s98y18cx98q3yhwmnhcfx43f '
109
+ return ' XXXXXXXXX '
143
110
```
144
111
145
112
#### __ ` GET_API_VERSION ` __
0 commit comments