Class: Appwrite::Analytics
- Defined in:
- lib/appwrite/services/analytics.rb
Instance Method Summary collapse
-
#create_annotation(property_id:, annotation_id:, date:, content:) ⇒ AnalyticsAnnotation
Create an annotation that marks a point in time on an analytics property's charts.
-
#create_event(property_id:, name:, url:, domain: nil, referrer: nil, screen_width: nil, session_hash: nil, scroll_depth: nil, engagement_time: nil, props: nil, user_id: nil, ip: nil, user_agent: nil, interactive: nil) ⇒ Object
Send a tracking event from a browser, native app, or server-side SDK.
-
#create_property(property_id:, name:, domain: nil, enabled: nil, allowed_origins: nil, identify_users: nil, type: nil) ⇒ AnalyticsProperty
Create a new analytics property to track a website or application.
-
#delete_annotation(property_id:, annotation_id:) ⇒ Object
Delete an analytics annotation.
-
#delete_property(property_id:) ⇒ Object
Delete an analytics property along with every event and session collected for it.
-
#get_annotation(property_id:, annotation_id:) ⇒ AnalyticsAnnotation
Get an analytics annotation by ID.
-
#get_property(property_id:) ⇒ AnalyticsProperty
Get an analytics property by ID.
-
#initialize(client) ⇒ Analytics
constructor
A new instance of Analytics.
-
#list_annotations(property_id:, queries: nil, total: nil) ⇒ AnalyticsAnnotationList
List the annotations of an analytics property.
-
#list_metrics(property_id:, queries: nil, interval: nil, dimensions: nil, prop_key: nil, date_range: nil, start_at: nil, end_at: nil, limit: nil, total: nil) ⇒ AnalyticsMetricList
Read analytics metrics (visitors, sessions, pageviews, events, bounceRate, …) for a property over a date range.
-
#list_properties(queries: nil, search: nil, total: nil) ⇒ AnalyticsPropertyList
List analytics properties for the current project.
-
#update_annotation(property_id:, annotation_id:, date: nil, content: nil) ⇒ AnalyticsAnnotation
Update an analytics annotation.
-
#update_property(property_id:, name: nil, domain: nil, enabled: nil, allowed_origins: nil, identify_users: nil, type: nil) ⇒ AnalyticsProperty
Update an analytics property.
Constructor Details
#initialize(client) ⇒ Analytics
Returns a new instance of Analytics.
5 6 7 |
# File 'lib/appwrite/services/analytics.rb', line 5 def initialize(client) @client = client end |
Instance Method Details
#create_annotation(property_id:, annotation_id:, date:, content:) ⇒ AnalyticsAnnotation
Create an annotation that marks a point in time on an analytics property's charts.
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
# File 'lib/appwrite/services/analytics.rb', line 261 def create_annotation( property_id:, annotation_id:, date:, content: ) if property_id.nil? || property_id == '' raise Appwrite::Exception.new('Missing required parameter: "propertyId"') end if annotation_id.nil? raise Appwrite::Exception.new('Missing required parameter: "annotationId"') end if date.nil? raise Appwrite::Exception.new('Missing required parameter: "date"') end if content.nil? raise Appwrite::Exception.new('Missing required parameter: "content"') end api_path = '/analytics/properties/{propertyId}/annotations' .gsub('{propertyId}', @client.encode_path(property_id)) api_params = { annotationId: annotation_id, date: date, content: content, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } @client.call( method: 'POST', path: api_path, headers: api_headers, params: api_params, response_type: Models::AnalyticsAnnotation ) end |
#create_event(property_id:, name:, url:, domain: nil, referrer: nil, screen_width: nil, session_hash: nil, scroll_depth: nil, engagement_time: nil, props: nil, user_id: nil, ip: nil, user_agent: nil, interactive: nil) ⇒ Object
Send a tracking event from a browser, native app, or server-side SDK.
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 |
# File 'lib/appwrite/services/analytics.rb', line 448 def create_event( property_id:, name:, url:, domain: nil, referrer: nil, screen_width: nil, session_hash: nil, scroll_depth: nil, engagement_time: nil, props: nil, user_id: nil, ip: nil, user_agent: nil, interactive: nil ) if property_id.nil? || property_id == '' raise Appwrite::Exception.new('Missing required parameter: "propertyId"') end if name.nil? raise Appwrite::Exception.new('Missing required parameter: "name"') end if url.nil? raise Appwrite::Exception.new('Missing required parameter: "url"') end api_path = '/analytics/properties/{propertyId}/events' .gsub('{propertyId}', @client.encode_path(property_id)) api_params = { name: name, url: url, domain: domain, referrer: referrer, screenWidth: screen_width, sessionHash: session_hash, scrollDepth: scroll_depth, engagementTime: engagement_time, props: props, userId: user_id, ip: ip, userAgent: user_agent, interactive: interactive, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } @client.call( method: 'POST', path: api_path, headers: api_headers, params: api_params, ) end |
#create_property(property_id:, name:, domain: nil, enabled: nil, allowed_origins: nil, identify_users: nil, type: nil) ⇒ AnalyticsProperty
Create a new analytics property to track a website or application.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/appwrite/services/analytics.rb', line 54 def create_property( property_id:, name:, domain: nil, enabled: nil, allowed_origins: nil, identify_users: nil, type: nil ) if property_id.nil? raise Appwrite::Exception.new('Missing required parameter: "propertyId"') end if name.nil? raise Appwrite::Exception.new('Missing required parameter: "name"') end api_path = '/analytics/properties' api_params = { propertyId: property_id, name: name, domain: domain, enabled: enabled, allowedOrigins: allowed_origins, identifyUsers: identify_users, type: type, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } @client.call( method: 'POST', path: api_path, headers: api_headers, params: api_params, response_type: Models::AnalyticsProperty ) end |
#delete_annotation(property_id:, annotation_id:) ⇒ Object
Delete an analytics annotation.
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 |
# File 'lib/appwrite/services/analytics.rb', line 398 def delete_annotation( property_id:, annotation_id: ) if property_id.nil? || property_id == '' raise Appwrite::Exception.new('Missing required parameter: "propertyId"') end if annotation_id.nil? || annotation_id == '' raise Appwrite::Exception.new('Missing required parameter: "annotationId"') end api_path = '/analytics/properties/{propertyId}/annotations/{annotationId}' .gsub('{propertyId}', @client.encode_path(property_id)) .gsub('{annotationId}', @client.encode_path(annotation_id)) api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } @client.call( method: 'DELETE', path: api_path, headers: api_headers, params: api_params, ) end |
#delete_property(property_id:) ⇒ Object
Delete an analytics property along with every event and session collected for it. This cannot be undone.
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/appwrite/services/analytics.rb', line 187 def delete_property( property_id: ) if property_id.nil? || property_id == '' raise Appwrite::Exception.new('Missing required parameter: "propertyId"') end api_path = '/analytics/properties/{propertyId}' .gsub('{propertyId}', @client.encode_path(property_id)) api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } @client.call( method: 'DELETE', path: api_path, headers: api_headers, params: api_params, ) end |
#get_annotation(property_id:, annotation_id:) ⇒ AnalyticsAnnotation
Get an analytics annotation by ID.
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
# File 'lib/appwrite/services/analytics.rb', line 313 def get_annotation( property_id:, annotation_id: ) if property_id.nil? || property_id == '' raise Appwrite::Exception.new('Missing required parameter: "propertyId"') end if annotation_id.nil? || annotation_id == '' raise Appwrite::Exception.new('Missing required parameter: "annotationId"') end api_path = '/analytics/properties/{propertyId}/annotations/{annotationId}' .gsub('{propertyId}', @client.encode_path(property_id)) .gsub('{annotationId}', @client.encode_path(annotation_id)) api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "accept": 'application/json', } @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, response_type: Models::AnalyticsAnnotation ) end |
#get_property(property_id:) ⇒ AnalyticsProperty
Get an analytics property by ID.
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/appwrite/services/analytics.rb', line 103 def get_property( property_id: ) if property_id.nil? || property_id == '' raise Appwrite::Exception.new('Missing required parameter: "propertyId"') end api_path = '/analytics/properties/{propertyId}' .gsub('{propertyId}', @client.encode_path(property_id)) api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "accept": 'application/json', } @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, response_type: Models::AnalyticsProperty ) end |
#list_annotations(property_id:, queries: nil, total: nil) ⇒ AnalyticsAnnotationList
List the annotations of an analytics property. Filter on date to fetch
the annotations inside a chart's time range.
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'lib/appwrite/services/analytics.rb', line 221 def list_annotations( property_id:, queries: nil, total: nil ) if property_id.nil? || property_id == '' raise Appwrite::Exception.new('Missing required parameter: "propertyId"') end api_path = '/analytics/properties/{propertyId}/annotations' .gsub('{propertyId}', @client.encode_path(property_id)) api_params = { queries: queries, total: total, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "accept": 'application/json', } @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, response_type: Models::AnalyticsAnnotationList ) end |
#list_metrics(property_id:, queries: nil, interval: nil, dimensions: nil, prop_key: nil, date_range: nil, start_at: nil, end_at: nil, limit: nil, total: nil) ⇒ AnalyticsMetricList
Read analytics metrics (visitors, sessions, pageviews, events, bounceRate, …) for a property over a date range.
Three response shapes, chosen by dimensions[] and interval:
- Neither: one row aggregating the whole window, with
valueanddatenull. Only this shape carriesvisits,bounceRate,visitDuration,viewsPerVisit,scrollDepthandengagementTime. dimensions[]: one row per dimension value, ranked by visitors, withvalueset anddatenull.interval: one row per time bucket in chronological order, withdateset andvaluenull.
pageviews is carried by the flat aggregate and by interval, but not by
a breakdown.
userId and users cover identified traffic only: events sent with an API
key's userId, or from a signed-in session on a property with
identifyUsers on. A userId breakdown leaves out anonymous events;
returned values are the project's user IDs.
Custom event props: dimensions[]=props ranks the prop keys seen in the
window, and adding propKey ranks the values of that one key. queries[]
filters on a prop's value with the props.<key> attribute, e.g.
equal("props.plan", ["pro"]).
Combining dimensions[] with interval is not supported yet. queries[]
filters the underlying events using standard Utopia query syntax.
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 |
# File 'lib/appwrite/services/analytics.rb', line 549 def list_metrics( property_id:, queries: nil, interval: nil, dimensions: nil, prop_key: nil, date_range: nil, start_at: nil, end_at: nil, limit: nil, total: nil ) if property_id.nil? || property_id == '' raise Appwrite::Exception.new('Missing required parameter: "propertyId"') end api_path = '/analytics/properties/{propertyId}/metrics' .gsub('{propertyId}', @client.encode_path(property_id)) api_params = { queries: queries, interval: interval, dimensions: dimensions, propKey: prop_key, dateRange: date_range, startAt: start_at, endAt: end_at, limit: limit, total: total, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "accept": 'application/json', } @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, response_type: Models::AnalyticsMetricList ) end |
#list_properties(queries: nil, search: nil, total: nil) ⇒ AnalyticsPropertyList
List analytics properties for the current project.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/appwrite/services/analytics.rb', line 16 def list_properties( queries: nil, search: nil, total: nil ) api_path = '/analytics/properties' api_params = { queries: queries, search: search, total: total, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "accept": 'application/json', } @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, response_type: Models::AnalyticsPropertyList ) end |
#update_annotation(property_id:, annotation_id:, date: nil, content: nil) ⇒ AnalyticsAnnotation
Update an analytics annotation. Only the attributes you pass are changed; omitted attributes keep their current value.
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
# File 'lib/appwrite/services/analytics.rb', line 354 def update_annotation( property_id:, annotation_id:, date: nil, content: nil ) if property_id.nil? || property_id == '' raise Appwrite::Exception.new('Missing required parameter: "propertyId"') end if annotation_id.nil? || annotation_id == '' raise Appwrite::Exception.new('Missing required parameter: "annotationId"') end api_path = '/analytics/properties/{propertyId}/annotations/{annotationId}' .gsub('{propertyId}', @client.encode_path(property_id)) .gsub('{annotationId}', @client.encode_path(annotation_id)) api_params = { date: date, content: content, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } @client.call( method: 'PATCH', path: api_path, headers: api_headers, params: api_params, response_type: Models::AnalyticsAnnotation ) end |
#update_property(property_id:, name: nil, domain: nil, enabled: nil, allowed_origins: nil, identify_users: nil, type: nil) ⇒ AnalyticsProperty
Update an analytics property. Only the attributes you pass are changed; omitted attributes keep their current value.
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/appwrite/services/analytics.rb', line 141 def update_property( property_id:, name: nil, domain: nil, enabled: nil, allowed_origins: nil, identify_users: nil, type: nil ) if property_id.nil? || property_id == '' raise Appwrite::Exception.new('Missing required parameter: "propertyId"') end api_path = '/analytics/properties/{propertyId}' .gsub('{propertyId}', @client.encode_path(property_id)) api_params = { name: name, domain: domain, enabled: enabled, allowedOrigins: allowed_origins, identifyUsers: identify_users, type: type, } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } @client.call( method: 'PATCH', path: api_path, headers: api_headers, params: api_params, response_type: Models::AnalyticsProperty ) end |