cjapy 0.2.2.post4__tar.gz → 0.2.3.post1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/PKG-INFO +1 -1
  2. cjapy-0.2.3.post1/cjapy/__version__.py +1 -0
  3. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/cjapy/cjapy.py +106 -0
  4. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/cjapy/requestCreator.py +231 -31
  5. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/cjapy.egg-info/PKG-INFO +1 -1
  6. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/docs/releases.md +5 -1
  7. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/docs/requestCreator.md +45 -1
  8. cjapy-0.2.2.post4/cjapy/__version__.py +0 -1
  9. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/LICENSE +0 -0
  10. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/README.md +0 -0
  11. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/cjapy/__init__.py +0 -0
  12. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/cjapy/config.py +0 -0
  13. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/cjapy/configs.py +0 -0
  14. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/cjapy/connector.py +0 -0
  15. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/cjapy/projects.py +0 -0
  16. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/cjapy/token_provider.py +0 -0
  17. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/cjapy/workspace.py +0 -0
  18. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/cjapy.egg-info/SOURCES.txt +0 -0
  19. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/cjapy.egg-info/dependency_links.txt +0 -0
  20. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/cjapy.egg-info/requires.txt +0 -0
  21. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/cjapy.egg-info/top_level.txt +0 -0
  22. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/docs/authenticating_without_config_json.md +0 -0
  23. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/docs/cja.md +0 -0
  24. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/docs/getting_started.md +0 -0
  25. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/docs/logging.md +0 -0
  26. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/docs/main.md +0 -0
  27. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/docs/projects.md +0 -0
  28. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/docs/workspace.md +0 -0
  29. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/pyproject.toml +0 -0
  30. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/requirements.txt +0 -0
  31. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/setup.cfg +0 -0
  32. {cjapy-0.2.2.post4 → cjapy-0.2.3.post1}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cjapy
3
- Version: 0.2.2.post4
3
+ Version: 0.2.3.post1
4
4
  Summary: Adobe Customer Journey Analytics (CJA) wrapper
5
5
  Home-page: https://github.com/pitchmuc/cjapy
6
6
  Author: Julien Piccini
@@ -0,0 +1 @@
1
+ __version__ = "0.2.3-1"
@@ -7,6 +7,8 @@ from typing import IO, Union, List
7
7
  from collections import defaultdict, deque
8
8
  import time, logging, re
9
9
  from itertools import tee
10
+ from datetime import datetime, timedelta
11
+
10
12
 
11
13
  # Non standard libraries
12
14
  import pandas as pd
@@ -2454,3 +2456,107 @@ class CJA:
2454
2456
  metricFilters="notApplicable",
2455
2457
  )
2456
2458
  return workspace
2459
+
2460
+ def getFreeformTable(
2461
+ self,
2462
+ dimension: str = None,
2463
+ metrics: List[str] = None,
2464
+ dataviewId: str = None,
2465
+ start_date: Union[str, datetime] = None,
2466
+ end_date: Union[str, datetime] = None,
2467
+ top_n: int = 400,
2468
+ filterId: str = None,
2469
+ search: Union[str, List[str]] = None,
2470
+ search_operator: str = "OR",
2471
+ ) -> pd.DataFrame:
2472
+ """
2473
+ Retrieves a freeform table report with the specified parameters.
2474
+
2475
+ Arguments:
2476
+ dimension : REQUIRED : The dimension to include in the report.
2477
+ metrics : REQUIRED : List of metrics to include in the report.
2478
+ dataviewId : REQUIRED : The dataView ID to use for your report.
2479
+ start_date : OPTIONAL : The start date for the report in 'YYYY-MM-DD' format or datetime object (defaults to 30 days ago).
2480
+ end_date : OPTIONAL : The end date for the report in 'YYYY-MM-DD' format or datetime object (defaults to today).
2481
+ top_n : OPTIONAL : Number of top results to return (default 400).
2482
+ filterId : OPTIONAL : The segment ID to filter the report.
2483
+ search : OPTIONAL : A search parameter (string or list of strings) to filter the dimension values.
2484
+ search_operator : OPTIONAL : The logical operator to combine search terms (default is OR).
2485
+
2486
+ Returns:
2487
+ A pandas DataFrame containing the report data.
2488
+ """
2489
+ if dimension is None:
2490
+ raise ValueError("Require at least a dimension")
2491
+ if metrics is None:
2492
+ raise ValueError("Require at least a metric")
2493
+ if dataviewId is None:
2494
+ raise ValueError("Require a Data View ID")
2495
+ def ensure_dimension_prefix(dimension: str) -> str:
2496
+ if not dimension.startswith("variables/"):
2497
+ return f"variables/{dimension}"
2498
+ return dimension
2499
+ def ensure_metric_prefix(metric: str) -> str:
2500
+ if not metric.startswith("metrics/"):
2501
+ return f"metrics/{metric}"
2502
+ return metric
2503
+ def ensure_datetime_format(date: Union[str, datetime], is_start: bool) -> str:
2504
+ if isinstance(date, str):
2505
+ date = datetime.fromisoformat(date)
2506
+ if date.time() == datetime.min.time():
2507
+ if is_start:
2508
+ return date.strftime('%Y-%m-%dT00:00:00.000')
2509
+ else:
2510
+ return date.strftime('%Y-%m-%dT23:59:59.999')
2511
+ return date.strftime('%Y-%m-%dT%H:%M:%S.000')
2512
+ if search_operator not in ["OR", "AND"]:
2513
+ raise ValueError("search_operator must be 'OR' or 'AND'")
2514
+ if start_date is None:
2515
+ start_date = datetime.today() - timedelta(days=30)
2516
+ if end_date is None:
2517
+ end_date = datetime.today()
2518
+ start_date_str = ensure_datetime_format(start_date, is_start=True)
2519
+ end_date_str = ensure_datetime_format(end_date, is_start=False)
2520
+ date_range = f"{start_date_str}/{end_date_str}"
2521
+ dimension = ensure_dimension_prefix(dimension)
2522
+ metrics = [ensure_metric_prefix(metric) for metric in metrics]
2523
+ template = RequestCreator()
2524
+ template.setDataViewId(dataviewId)
2525
+ template.setDimension(dimension)
2526
+ for metric in metrics:
2527
+ template.addMetric(metric)
2528
+ if filterId:
2529
+ template.addGlobalFilter(filterId)
2530
+ template.addGlobalFilter(date_range)
2531
+ if search:
2532
+ if isinstance(search, str):
2533
+ search = [search]
2534
+ search_clause = f" {search_operator} ".join([f"CONTAINS '{term}'" for term in search])
2535
+ template.setSearch(clause=search_clause)
2536
+ if top_n < 50000:
2537
+ limit = top_n
2538
+ n_results = top_n
2539
+ else:
2540
+ limit = 50000
2541
+ n_results = 20
2542
+ request = template.to_dict()
2543
+ response = self.getReport(request=request, limit=limit, n_results=n_results)
2544
+ df = response.dataframe
2545
+ # Drop the itemId column if it exists
2546
+ if 'itemId' in df.columns:
2547
+ df = df.drop(columns=['itemId'])
2548
+
2549
+ # Remove any rows that exceed the requested top_n
2550
+ if len(df) > top_n:
2551
+ df = df.head(top_n)
2552
+
2553
+ # Clean the column names to remove prefixes
2554
+ def clean_column_name(col):
2555
+ if col.startswith("variables/"):
2556
+ return col.replace("variables/", "")
2557
+ elif col.startswith("metrics/"):
2558
+ return col.replace("metrics/", "")
2559
+ return col
2560
+
2561
+ df.columns = [clean_column_name(col) for col in df.columns]
2562
+ return df
@@ -2,6 +2,7 @@ from copy import deepcopy
2
2
  import datetime
3
3
  import json
4
4
  from time import time
5
+ from typing import Union
5
6
 
6
7
 
7
8
  class RequestCreator:
@@ -21,9 +22,20 @@ class RequestCreator:
21
22
  "limit": 20000,
22
23
  "page": 0,
23
24
  "nonesBehavior": "exclude-nones",
25
+ "sampling": None,
26
+ "samplingUpSample": None
24
27
  },
25
28
  "statistics": {"functions": ["col-max", "col-min"]},
26
29
  "dataId": "",
30
+ "identityOverrides": [],
31
+ "capacityMetadata":{
32
+ "associations": [
33
+ {
34
+ "name": "applicationName",
35
+ "value": "cjapy Python Library"
36
+ }
37
+ ]
38
+ }
27
39
  }
28
40
 
29
41
  def __init__(self, request: dict = None) -> None:
@@ -88,18 +100,130 @@ class RequestCreator:
88
100
  def __str__(self):
89
101
  return json.dumps(self.__request, indent=4)
90
102
 
91
- def addMetric(self, metricId: str = None) -> None:
103
+ def addMetric(
104
+ self,
105
+ metricId: str = None,
106
+ attributionModel: str = None,
107
+ lookbackWindow: Union[int, str] = 30,
108
+ lookbackGranularity: str = "day",
109
+ **kwargs
110
+ ) -> None:
92
111
  """
93
112
  Add a metric to the template.
94
113
  Arguments:
95
114
  metricId : REQUIRED : The metric to add
115
+ attributionModel : OPTIONAL : The attribution model to use (e.g., "lastTouch", "firstTouch", "linear", "participation", "sameTouch", "uShaped", "jShaped", "reverseJShaped", "timeDecay", "positionBased", "algorithmic")
116
+ lookbackWindow : OPTIONAL : The lookback window (number of minutes, hours, days, weeks, months, quarters, "session", or "person"). Assumes 30 if not specified.
117
+ lookbackGranularity : OPTIONAL : The granularity of the lookback window (minute, hour, day, week, month, quarter). Defaults to "day".
118
+ **kwargs : Additional model-specific parameters. For "timeDecay" (assumes 1 week): halfLifeNumPeriods, halfLifeGranularity, for "positionBased": firstWeight, middleWeight, lastWeight.
96
119
  """
97
120
  if metricId is None:
98
121
  raise ValueError("Require a metric ID")
122
+
123
+ if attributionModel and attributionModel not in ["lastTouch", "firstTouch", "linear", "participation", "sameTouch", "uShaped", "jShaped", "reverseJShaped", "timeDecay", "positionBased", "algorithmic"]:
124
+ raise ValueError("Invalid attribution model")
125
+
126
+ if attributionModel and lookbackGranularity not in ["minute", "hour", "day", "week", "month", "quarter"]:
127
+ raise ValueError("Invalid lookbackGranularity. Valid values are: 'minute', 'hour', 'day', 'week', 'month', 'quarter'")
128
+
99
129
  columnId = self.__metricCount
100
130
  addMetric = {"columnId": str(columnId), "id": metricId}
101
131
  if columnId == 0:
102
132
  addMetric["sort"] = "desc"
133
+
134
+ if attributionModel:
135
+ # Handle sameTouch separately
136
+ if attributionModel == "sameTouch":
137
+ allocationModel = {
138
+ "func": "allocation-instance"
139
+ }
140
+ else:
141
+ allocationModel = {
142
+ "func": f"allocation-{attributionModel}"
143
+ }
144
+
145
+ # Validate lookback window
146
+ if lookbackWindow is not None and attributionModel != "sameTouch":
147
+ if isinstance(lookbackWindow, int):
148
+ if lookbackWindow <= 0:
149
+ raise ValueError("lookbackWindow must be positive")
150
+
151
+ # Default lookback granularity to days if not specified
152
+ lookbackGranularity = kwargs.get('lookbackGranularity', lookbackGranularity)
153
+
154
+ max_lookback = {
155
+ 'minute': 129600,
156
+ 'hour': 2160,
157
+ 'day': 90,
158
+ 'week': 12,
159
+ 'month': 3,
160
+ 'quarter': 1
161
+ }.get(lookbackGranularity, 90)
162
+
163
+ if lookbackWindow > max_lookback:
164
+ raise ValueError(f"lookbackWindow of {lookbackWindow} exceeds maximum for {lookbackGranularity} granularity")
165
+
166
+ if attributionModel not in ["lastTouch", "firstTouch"] or lookbackWindow != "session":
167
+ allocationModel["lookbackExpiration"] = {
168
+ "func": "allocation-lookbackPeriod",
169
+ "granularity": lookbackGranularity,
170
+ "numPeriods": lookbackWindow
171
+ }
172
+
173
+ addMetric["lookback"] = {
174
+ "func": "min-months",
175
+ "granularity": lookbackGranularity,
176
+ "numPeriods": lookbackWindow
177
+ }
178
+
179
+ if attributionModel in ["lastTouch", "firstTouch"]:
180
+ allocationModel["expiration"] = {
181
+ "context": "visitors",
182
+ "func": "allocation-container"
183
+ }
184
+ else:
185
+ allocationModel["context"] = "visitors"
186
+
187
+ elif lookbackWindow == "session":
188
+ if attributionModel in ["lastTouch", "firstTouch"]:
189
+ allocationModel["expiration"] = {
190
+ "context": "sessions",
191
+ "func": "allocation-container"
192
+ }
193
+ else:
194
+ allocationModel["context"] = "sessions"
195
+ elif lookbackWindow == "person":
196
+ if attributionModel not in ["lastTouch", "firstTouch"]:
197
+ allocationModel["context"] = "visitors"
198
+ else:
199
+ raise ValueError("lookbackWindow must be a positive integer or 'session' or 'person'")
200
+
201
+ if attributionModel in ["lastTouch", "firstTouch"]:
202
+ allocationModel["expiration"] = {
203
+ "context": allocationModel.get("expiration", {}).get("context", "visitors"),
204
+ "func": "allocation-container"
205
+ }
206
+
207
+ if attributionModel == "timeDecay":
208
+ halfLifeNumPeriods = kwargs.get("halfLifeNumPeriods", 1)
209
+ halfLifeGranularity = kwargs.get("halfLifeGranularity", "week")
210
+ if halfLifeNumPeriods is None or halfLifeGranularity not in ["minute", "hour", "day", "week", "month"]:
211
+ raise ValueError("For 'timeDecay', both 'halfLifeNumPeriods' and 'halfLifeGranularity' are required and granularity must be 'minute', 'hour', 'day', 'week', or 'month'")
212
+ allocationModel["halfLifeGranularity"] = halfLifeGranularity
213
+ allocationModel["halfLifeNumPeriods"] = halfLifeNumPeriods
214
+
215
+ if attributionModel == "positionBased":
216
+ firstWeight = kwargs.get("firstWeight")
217
+ middleWeight = kwargs.get("middleWeight")
218
+ lastWeight = kwargs.get("lastWeight")
219
+ if firstWeight is None or middleWeight is None or lastWeight is None:
220
+ raise ValueError("For 'positionBased', 'firstWeight', 'middleWeight', and 'lastWeight' are required")
221
+ allocationModel["firstWeight"] = firstWeight
222
+ allocationModel["middleWeight"] = middleWeight
223
+ allocationModel["lastWeight"] = lastWeight
224
+
225
+ addMetric["allocationModel"] = allocationModel
226
+
103
227
  self.__request["metricContainer"]["metrics"].append(addMetric)
104
228
  self.__metricCount += 1
105
229
 
@@ -243,7 +367,11 @@ class RequestCreator:
243
367
  # raise ValueError("dimensionIds parameters should be used")
244
368
  # if type(dimensionIds) != list:
245
369
  # raise TypeError("dimensionIds should be a list")
246
- # self.__request["dimension"] = dimensionIds
370
+ # if len(dimensionIds)>5:
371
+ # raise ValueError("dimensionIds should not countain more than 5 elements")
372
+ # if 'dimension' in self.__request.keys():
373
+ # del self.__request["dimension"]
374
+ # self.__request["dimensions"] = dimensionIds
247
375
 
248
376
  def removeSearch(self)->None:
249
377
  """
@@ -252,6 +380,20 @@ class RequestCreator:
252
380
  del self.__request["search"]
253
381
  self.search = False
254
382
 
383
+ def setSampling(self, sample: float = None, upsample: bool = False) -> None:
384
+ """
385
+ Set the sampling parameters. Sampling happens at the person level,
386
+ not at the event level to ensure all events for a person are included.
387
+ Upsampling will multiply the sample results to the full scale of the
388
+ original dataset (assuming the sample is representative).
389
+ Arguments:
390
+ sample : OPTIONAL : A float between 0 and 1 indicating the sample rate.
391
+ upsample : OPTIONAL : A boolean indicating whether to upsample (default is False).
392
+ """
393
+ if sample is not None and (sample < 0 or sample > 1):
394
+ raise ValueError("Sample rate must be between 0 and 1.")
395
+ self.__request["settings"]["sampling"] = sample
396
+ self.__request["settings"]["samplingUpSample"] = upsample
255
397
 
256
398
  def setRepeatInstance(self, repeat: bool = True) -> None:
257
399
  """
@@ -280,8 +422,23 @@ class RequestCreator:
280
422
  """
281
423
  if dimension is None:
282
424
  raise ValueError("A dimension must be passed")
425
+ if 'dimensions' in self.__request.keys():
426
+ del self.__request["dimensions"]
283
427
  self.__request["dimension"] = dimension
284
428
 
429
+ def setIdentityOverrides(self, identity_overrides: list) -> None:
430
+ """
431
+ Set the identityOverrides for the request.
432
+ Arguments:
433
+ identity_overrides : REQUIRED : the identityOverrides definition as a list of dictionaries
434
+ """
435
+ if not isinstance(identity_overrides, list):
436
+ raise ValueError("identity_overrides must be a list of dictionaries")
437
+ if not all(isinstance(item, dict) for item in identity_overrides):
438
+ raise ValueError("All items in identity_overrides must be dictionaries")
439
+
440
+ self.__request["identityOverrides"] = identity_overrides
441
+
285
442
  def setDataViewId(self, dataViewId: str = None) -> None:
286
443
  """
287
444
  Set the dataView ID to be used for the reporting.
@@ -292,47 +449,90 @@ class RequestCreator:
292
449
  raise ValueError("A dataView ID must be passed")
293
450
  self.__request["dataId"] = dataViewId
294
451
 
295
- def addGlobalFilter(self, filterId: str = None) -> None:
452
+ def addGlobalFilter(self, filterId: str = None, adHocFilter: dict = None) -> None:
296
453
  """
297
454
  Add a global filter to the report.
298
- NOTE : You need to have a dateRange filter at least in the global report.
455
+ NOTE: You need to have a dateRange filter at least in the global report.
456
+
299
457
  Arguments:
300
- filterId : REQUIRED : The filter to add to the global filter.
301
- example :
458
+ filterId : OPTIONAL : The filter to add to the global filter.
459
+ Example :
302
460
  "s2120430124uf03102jd8021" -> segment
303
461
  "2020-01-01T00:00:00.000/2020-02-01T00:00:00.000" -> dateRange
304
- """
305
- if filterId.startswith("s") and "@AdobeOrg" in filterId:
306
- filterType = "segment"
307
- filter = {
308
- "type": filterType,
309
- "segmentId": filterId,
310
- }
311
- elif filterId.startswith("20") and "/20" in filterId:
312
- filterType = "dateRange"
313
- filter = {
314
- "type": filterType,
315
- "dateRange": filterId,
316
- }
317
- elif ":::" in filterId:
318
- filterType = "breakdown"
319
- dimension, itemId = filterId.split(":::")
320
- filter = {
321
- "type": filterType,
322
- "dimension": dimension,
323
- "itemId": itemId,
324
- }
325
- else: ### case when it is predefined segments like "All_Visits"
326
- filterType = "segment"
462
+ adHocFilter : OPTIONAL : A dictionary representing the ad-hoc filter.
463
+ """
464
+ if not filterId and not adHocFilter:
465
+ raise ValueError("You must supply either a filterId or an adHocFilter.")
466
+ if filterId and adHocFilter:
467
+ raise ValueError("You cannot supply both a filterId and an adHocFilter.")
468
+
469
+ if filterId:
470
+ if filterId.startswith("s") and "@AdobeOrg" in filterId:
471
+ filter = {
472
+ "type": "segment",
473
+ "segmentId": filterId,
474
+ }
475
+ elif filterId.startswith("20") and "/20" in filterId:
476
+ filter = {
477
+ "type": "dateRange",
478
+ "dateRange": filterId,
479
+ }
480
+ elif ":::" in filterId:
481
+ dimension, itemId = filterId.split(":::")
482
+ filter = {
483
+ "type": "breakdown",
484
+ "dimension": dimension,
485
+ "itemId": itemId,
486
+ }
487
+ else:
488
+ filter = {
489
+ "type": "segment",
490
+ "segmentId": filterId,
491
+ }
492
+ else:
327
493
  filter = {
328
- "type": filterType,
329
- "segmentId": filterId,
494
+ "type": "segment",
495
+ "segmentDefinition": adHocFilter
330
496
  }
497
+
331
498
  ### incrementing the count for globalFilter
332
499
  self.__globalFiltersCount += 1
333
500
  ### adding to the globalFilter list
334
501
  self.__request["globalFilters"].append(filter)
335
502
 
503
+ def setDateRange(self, start_date: Union[str], end_date: Union[str]) -> None:
504
+ """
505
+ Set the date range for the request.
506
+ Arguments:
507
+ start_date : REQUIRED : The start date for the report in 'YYYY-MM-DD' format or datetime object.
508
+ end_date : REQUIRED : The end date for the report in 'YYYY-MM-DD' format or datetime object.
509
+ """
510
+ def ensure_datetime_format(date: Union[str], is_start: bool) -> str:
511
+ if isinstance(date, str):
512
+ date = datetime.datetime.fromisoformat(date)
513
+ if date.time() == datetime.datetime.min.time():
514
+ if is_start:
515
+ return date.strftime('%Y-%m-%dT00:00:00.000')
516
+ else:
517
+ return date.strftime('%Y-%m-%dT23:59:59.999')
518
+ return date.strftime('%Y-%m-%dT%H:%M:%S.000')
519
+
520
+ start_date_str = ensure_datetime_format(start_date, is_start=True)
521
+ end_date_str = ensure_datetime_format(end_date, is_start=False)
522
+ date_range = f"{start_date_str}/{end_date_str}"
523
+
524
+ # Update global filters with the new date range
525
+ date_range_filter = {
526
+ "type": "dateRange",
527
+ "dateRange": date_range
528
+ }
529
+
530
+ # Remove any existing dateRange filters before adding the new one
531
+ self.__request["globalFilters"] = [
532
+ f for f in self.__request["globalFilters"] if f["type"] != "dateRange"
533
+ ]
534
+ self.__request["globalFilters"].append(date_range_filter)
535
+
336
536
  def updateDateRange(
337
537
  self,
338
538
  dateRange: str = None,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cjapy
3
- Version: 0.2.2.post4
3
+ Version: 0.2.3.post1
4
4
  Summary: Adobe Customer Journey Analytics (CJA) wrapper
5
5
  Home-page: https://github.com/pitchmuc/cjapy
6
6
  Author: Julien Piccini
@@ -13,7 +13,11 @@ Patch:
13
13
  * Fixing some edge cases of `findComponentUsage`
14
14
  * Adding more parameters for `createDataView` methods
15
15
  * Fixing `updateCalculatedMetric`
16
- * Fixing the `setSearch`
16
+ * Fixing the `setSearch`\
17
+ Patch:
18
+ * adding attribution model possibility to addMetric in `RequestCreator`
19
+ * adding `setDateRange` method in `RequestCreator`
20
+ * supporting adhoc filter in `RequestCreator`
17
21
 
18
22
  ## 0.2.1
19
23
 
@@ -75,6 +75,44 @@ We will review the different methods available via the object.
75
75
 
76
76
  * `addMetric()`
77
77
  Add a metric to the Request.
78
+ Arguments:
79
+ * metricId : REQUIRED : The metric to add
80
+ * attributionModel : OPTIONAL : The attribution model to use (e.g., "lastTouch", "firstTouch", "linear", "participation", "sameTouch", "uShaped", "jShaped", "reverseJShaped", "timeDecay", "positionBased", "algorithmic")
81
+ * lookbackWindow : OPTIONAL : The lookback window (number of minutes, hours, days, weeks, months, quarters, "session", or "person"). Assumes 30 if not specified.
82
+ * lookbackGranularity : OPTIONAL : The granularity of the lookback window (minute, hour, day, week, month, quarter). Defaults to "day".
83
+ * **kwargs : Additional model-specific parameters. For "timeDecay" (assumes 1 week): halfLifeNumPeriods, halfLifeGranularity; for "positionBased": firstWeight, middleWeight, lastWeight.
84
+
85
+ The `addMetric` method also supports various attribution models. For example, the `sameTouch` model is defined without a lookback window, while other models like `lastTouch` and `firstTouch` can have lookback windows and expiration settings. The `timeDecay` model allows specifying half-life periods and granularity, with defaults to 1 week if not provided.
86
+
87
+ Examples:
88
+ ```python
89
+ # Adding a simple metric
90
+ myRequest.addMetric("metrics/orders")
91
+
92
+ # Adding a metric with an attribution model
93
+ myRequest.addMetric("metrics/orders", attributionModel="lastTouch", lookbackWindow=30)
94
+
95
+ # Adding a metric with a custom attribution model
96
+ myRequest.addMetric(
97
+ "metrics/orders",
98
+ attributionModel="timeDecay",
99
+ lookbackWindow=60,
100
+ halfLifeNumPeriods=1,
101
+ halfLifeGranularity="week"
102
+ )
103
+
104
+ # Adding a metric with position-based attribution model
105
+ myRequest.addMetric(
106
+ "metrics/orders",
107
+ attributionModel="positionBased",
108
+ lookbackWindow=30,
109
+ firstWeight=30,
110
+ middleWeight=20,
111
+ lastWeight=50
112
+ )
113
+
114
+ # Adding a metric with sameTouch attribution model
115
+ myRequest.addMetric("metrics/orders", attributionModel="sameTouch")
78
116
 
79
117
  * `addGlobalFilter()`
80
118
  Add a global filter to the report.
@@ -131,6 +169,12 @@ We will review the different methods available via the object.
131
169
  * filterId : REQUIRED : The filter to add.
132
170
  when breakdown, use the following format for the value "dimension:::itemId"
133
171
 
172
+ * `setDateRange()`
173
+ Set the date range for the request.
174
+ Arguments:
175
+ * start_date : REQUIRED : The start date for the report in 'YYYY-MM-DD' format or datetime object.
176
+ * end_date : REQUIRED : The end date for the report in 'YYYY-MM-DD' format or datetime object.
177
+
134
178
  * `updateDateRange()`
135
179
  Update the dateRange filter on the globalFilter list
136
180
  One of the 3 elements specified below is required.
@@ -167,4 +211,4 @@ This can help you derive other dates if needed.
167
211
 
168
212
  ### search
169
213
 
170
- `search` attribute is a boolean defining if search has been set for the dimension.
214
+ `search` attribute is a boolean defining if search has been set for the dimension.
@@ -1 +0,0 @@
1
- __version__ = "0.2.2-4"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes