@google-analytics/data 6.0.0 → 7.0.0

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.
@@ -97,17 +97,26 @@ class BetaAnalyticsDataClient {
97
97
  constructor(opts, gaxInstance) {
98
98
  // Ensure that options include all the required fields.
99
99
  const staticMembers = this.constructor;
100
- if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) {
100
+ if (opts?.universe_domain &&
101
+ opts?.universeDomain &&
102
+ opts?.universe_domain !== opts?.universeDomain) {
101
103
  throw new Error('Please set either universe_domain or universeDomain, but not both.');
102
104
  }
103
- const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined;
104
- this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com';
105
+ const universeDomainEnvVar = typeof process === 'object' && typeof process.env === 'object'
106
+ ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']
107
+ : undefined;
108
+ this._universeDomain =
109
+ opts?.universeDomain ??
110
+ opts?.universe_domain ??
111
+ universeDomainEnvVar ??
112
+ 'googleapis.com';
105
113
  this._servicePath = 'analyticsdata.' + this._universeDomain;
106
114
  const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath;
107
115
  this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint);
108
116
  const port = opts?.port || staticMembers.port;
109
117
  const clientConfig = opts?.clientConfig ?? {};
110
- const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function');
118
+ const fallback = opts?.fallback ??
119
+ (typeof window !== 'undefined' && typeof window?.fetch === 'function');
111
120
  opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
112
121
  // Request numeric enum values if REST transport is used.
113
122
  opts.numericEnums = true;
@@ -136,10 +145,7 @@ class BetaAnalyticsDataClient {
136
145
  this.auth.defaultScopes = staticMembers.scopes;
137
146
  }
138
147
  // Determine the client header string.
139
- const clientHeader = [
140
- `gax/${this._gaxModule.version}`,
141
- `gapic/${version}`,
142
- ];
148
+ const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
143
149
  if (typeof process === 'object' && 'versions' in process) {
144
150
  clientHeader.push(`gl-node/${process.versions.node}`);
145
151
  }
@@ -169,7 +175,7 @@ class BetaAnalyticsDataClient {
169
175
  // (e.g. 50 results at a time, with tokens to get subsequent
170
176
  // pages). Denote the keys used for pagination and results.
171
177
  this.descriptors.page = {
172
- listAudienceExports: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'audienceExports')
178
+ listAudienceExports: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'audienceExports'),
173
179
  };
174
180
  const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos);
175
181
  // This API contains "long-running operations", which return a
@@ -177,17 +183,19 @@ class BetaAnalyticsDataClient {
177
183
  // rather than holding a request open.
178
184
  const lroOptions = {
179
185
  auth: this.auth,
180
- grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined
186
+ grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
181
187
  };
182
188
  if (opts.fallback) {
183
189
  lroOptions.protoJson = protoFilesRoot;
184
190
  lroOptions.httpRules = [];
185
191
  }
186
- this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts);
192
+ this.operationsClient = this._gaxModule
193
+ .lro(lroOptions)
194
+ .operationsClient(opts);
187
195
  const createAudienceExportResponse = protoFilesRoot.lookup('.google.analytics.data.v1beta.AudienceExport');
188
196
  const createAudienceExportMetadata = protoFilesRoot.lookup('.google.analytics.data.v1beta.AudienceExportMetadata');
189
197
  this.descriptors.longrunning = {
190
- createAudienceExport: new this._gaxModule.LongrunningDescriptor(this.operationsClient, createAudienceExportResponse.decode.bind(createAudienceExportResponse), createAudienceExportMetadata.decode.bind(createAudienceExportMetadata))
198
+ createAudienceExport: new this._gaxModule.LongrunningDescriptor(this.operationsClient, createAudienceExportResponse.decode.bind(createAudienceExportResponse), createAudienceExportMetadata.decode.bind(createAudienceExportMetadata)),
191
199
  };
192
200
  // Put together the default options sent with requests.
193
201
  this._defaults = this._gaxGrpc.constructSettings('google.analytics.data.v1beta.BetaAnalyticsData', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
@@ -216,15 +224,27 @@ class BetaAnalyticsDataClient {
216
224
  }
217
225
  // Put together the "service stub" for
218
226
  // google.analytics.data.v1beta.BetaAnalyticsData.
219
- this.betaAnalyticsDataStub = this._gaxGrpc.createStub(this._opts.fallback ?
220
- this._protos.lookupService('google.analytics.data.v1beta.BetaAnalyticsData') :
221
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
222
- this._protos.google.analytics.data.v1beta.BetaAnalyticsData, this._opts, this._providedCustomServicePath);
227
+ this.betaAnalyticsDataStub = this._gaxGrpc.createStub(this._opts.fallback
228
+ ? this._protos.lookupService('google.analytics.data.v1beta.BetaAnalyticsData')
229
+ : // eslint-disable-next-line @typescript-eslint/no-explicit-any
230
+ this._protos.google.analytics.data.v1beta.BetaAnalyticsData, this._opts, this._providedCustomServicePath);
223
231
  // Iterate over each of the methods that the service provides
224
232
  // and create an API call method for each.
225
- const betaAnalyticsDataStubMethods = ['runReport', 'runPivotReport', 'batchRunReports', 'batchRunPivotReports', 'getMetadata', 'runRealtimeReport', 'checkCompatibility', 'createAudienceExport', 'queryAudienceExport', 'getAudienceExport', 'listAudienceExports'];
233
+ const betaAnalyticsDataStubMethods = [
234
+ 'runReport',
235
+ 'runPivotReport',
236
+ 'batchRunReports',
237
+ 'batchRunPivotReports',
238
+ 'getMetadata',
239
+ 'runRealtimeReport',
240
+ 'checkCompatibility',
241
+ 'createAudienceExport',
242
+ 'queryAudienceExport',
243
+ 'getAudienceExport',
244
+ 'listAudienceExports',
245
+ ];
226
246
  for (const methodName of betaAnalyticsDataStubMethods) {
227
- const callPromise = this.betaAnalyticsDataStub.then(stub => (...args) => {
247
+ const callPromise = this.betaAnalyticsDataStub.then((stub) => (...args) => {
228
248
  if (this._terminated) {
229
249
  return Promise.reject('The client has already been closed.');
230
250
  }
@@ -247,7 +267,8 @@ class BetaAnalyticsDataClient {
247
267
  * @returns {string} The DNS address for this service.
248
268
  */
249
269
  static get servicePath() {
250
- if (typeof process === 'object' && typeof process.emitWarning === 'function') {
270
+ if (typeof process === 'object' &&
271
+ typeof process.emitWarning === 'function') {
251
272
  process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning');
252
273
  }
253
274
  return 'analyticsdata.googleapis.com';
@@ -258,7 +279,8 @@ class BetaAnalyticsDataClient {
258
279
  * @returns {string} The DNS address for this service.
259
280
  */
260
281
  static get apiEndpoint() {
261
- if (typeof process === 'object' && typeof process.emitWarning === 'function') {
282
+ if (typeof process === 'object' &&
283
+ typeof process.emitWarning === 'function') {
262
284
  process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning');
263
285
  }
264
286
  return 'analyticsdata.googleapis.com';
@@ -288,7 +310,7 @@ class BetaAnalyticsDataClient {
288
310
  static get scopes() {
289
311
  return [
290
312
  'https://www.googleapis.com/auth/analytics',
291
- 'https://www.googleapis.com/auth/analytics.readonly'
313
+ 'https://www.googleapis.com/auth/analytics.readonly',
292
314
  ];
293
315
  }
294
316
  /**
@@ -315,10 +337,13 @@ class BetaAnalyticsDataClient {
315
337
  options = options || {};
316
338
  options.otherArgs = options.otherArgs || {};
317
339
  options.otherArgs.headers = options.otherArgs.headers || {};
318
- options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
319
- 'property': request.property ?? '',
340
+ options.otherArgs.headers['x-goog-request-params'] =
341
+ this._gaxModule.routingHeader.fromParams({
342
+ property: request.property ?? '',
343
+ });
344
+ this.initialize().catch((err) => {
345
+ throw err;
320
346
  });
321
- this.initialize().catch(err => { throw err; });
322
347
  this._log.info('runReport request %j', request);
323
348
  const wrappedCallback = callback
324
349
  ? (error, response, options, rawResponse) => {
@@ -326,12 +351,16 @@ class BetaAnalyticsDataClient {
326
351
  callback(error, response, options, rawResponse); // We verified callback above.
327
352
  }
328
353
  : undefined;
329
- return this.innerApiCalls.runReport(request, options, wrappedCallback)
354
+ return this.innerApiCalls
355
+ .runReport(request, options, wrappedCallback)
330
356
  ?.then(([response, options, rawResponse]) => {
331
357
  this._log.info('runReport response %j', response);
332
358
  return [response, options, rawResponse];
333
- }).catch((error) => {
334
- if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
359
+ })
360
+ .catch((error) => {
361
+ if (error &&
362
+ 'statusDetails' in error &&
363
+ error.statusDetails instanceof Array) {
335
364
  const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
336
365
  error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
337
366
  }
@@ -351,10 +380,13 @@ class BetaAnalyticsDataClient {
351
380
  options = options || {};
352
381
  options.otherArgs = options.otherArgs || {};
353
382
  options.otherArgs.headers = options.otherArgs.headers || {};
354
- options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
355
- 'property': request.property ?? '',
383
+ options.otherArgs.headers['x-goog-request-params'] =
384
+ this._gaxModule.routingHeader.fromParams({
385
+ property: request.property ?? '',
386
+ });
387
+ this.initialize().catch((err) => {
388
+ throw err;
356
389
  });
357
- this.initialize().catch(err => { throw err; });
358
390
  this._log.info('runPivotReport request %j', request);
359
391
  const wrappedCallback = callback
360
392
  ? (error, response, options, rawResponse) => {
@@ -362,12 +394,16 @@ class BetaAnalyticsDataClient {
362
394
  callback(error, response, options, rawResponse); // We verified callback above.
363
395
  }
364
396
  : undefined;
365
- return this.innerApiCalls.runPivotReport(request, options, wrappedCallback)
397
+ return this.innerApiCalls
398
+ .runPivotReport(request, options, wrappedCallback)
366
399
  ?.then(([response, options, rawResponse]) => {
367
400
  this._log.info('runPivotReport response %j', response);
368
401
  return [response, options, rawResponse];
369
- }).catch((error) => {
370
- if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
402
+ })
403
+ .catch((error) => {
404
+ if (error &&
405
+ 'statusDetails' in error &&
406
+ error.statusDetails instanceof Array) {
371
407
  const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
372
408
  error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
373
409
  }
@@ -387,10 +423,13 @@ class BetaAnalyticsDataClient {
387
423
  options = options || {};
388
424
  options.otherArgs = options.otherArgs || {};
389
425
  options.otherArgs.headers = options.otherArgs.headers || {};
390
- options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
391
- 'property': request.property ?? '',
426
+ options.otherArgs.headers['x-goog-request-params'] =
427
+ this._gaxModule.routingHeader.fromParams({
428
+ property: request.property ?? '',
429
+ });
430
+ this.initialize().catch((err) => {
431
+ throw err;
392
432
  });
393
- this.initialize().catch(err => { throw err; });
394
433
  this._log.info('batchRunReports request %j', request);
395
434
  const wrappedCallback = callback
396
435
  ? (error, response, options, rawResponse) => {
@@ -398,12 +437,16 @@ class BetaAnalyticsDataClient {
398
437
  callback(error, response, options, rawResponse); // We verified callback above.
399
438
  }
400
439
  : undefined;
401
- return this.innerApiCalls.batchRunReports(request, options, wrappedCallback)
440
+ return this.innerApiCalls
441
+ .batchRunReports(request, options, wrappedCallback)
402
442
  ?.then(([response, options, rawResponse]) => {
403
443
  this._log.info('batchRunReports response %j', response);
404
444
  return [response, options, rawResponse];
405
- }).catch((error) => {
406
- if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
445
+ })
446
+ .catch((error) => {
447
+ if (error &&
448
+ 'statusDetails' in error &&
449
+ error.statusDetails instanceof Array) {
407
450
  const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
408
451
  error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
409
452
  }
@@ -423,10 +466,13 @@ class BetaAnalyticsDataClient {
423
466
  options = options || {};
424
467
  options.otherArgs = options.otherArgs || {};
425
468
  options.otherArgs.headers = options.otherArgs.headers || {};
426
- options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
427
- 'property': request.property ?? '',
469
+ options.otherArgs.headers['x-goog-request-params'] =
470
+ this._gaxModule.routingHeader.fromParams({
471
+ property: request.property ?? '',
472
+ });
473
+ this.initialize().catch((err) => {
474
+ throw err;
428
475
  });
429
- this.initialize().catch(err => { throw err; });
430
476
  this._log.info('batchRunPivotReports request %j', request);
431
477
  const wrappedCallback = callback
432
478
  ? (error, response, options, rawResponse) => {
@@ -434,12 +480,16 @@ class BetaAnalyticsDataClient {
434
480
  callback(error, response, options, rawResponse); // We verified callback above.
435
481
  }
436
482
  : undefined;
437
- return this.innerApiCalls.batchRunPivotReports(request, options, wrappedCallback)
483
+ return this.innerApiCalls
484
+ .batchRunPivotReports(request, options, wrappedCallback)
438
485
  ?.then(([response, options, rawResponse]) => {
439
486
  this._log.info('batchRunPivotReports response %j', response);
440
487
  return [response, options, rawResponse];
441
- }).catch((error) => {
442
- if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
488
+ })
489
+ .catch((error) => {
490
+ if (error &&
491
+ 'statusDetails' in error &&
492
+ error.statusDetails instanceof Array) {
443
493
  const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
444
494
  error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
445
495
  }
@@ -459,10 +509,13 @@ class BetaAnalyticsDataClient {
459
509
  options = options || {};
460
510
  options.otherArgs = options.otherArgs || {};
461
511
  options.otherArgs.headers = options.otherArgs.headers || {};
462
- options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
463
- 'name': request.name ?? '',
512
+ options.otherArgs.headers['x-goog-request-params'] =
513
+ this._gaxModule.routingHeader.fromParams({
514
+ name: request.name ?? '',
515
+ });
516
+ this.initialize().catch((err) => {
517
+ throw err;
464
518
  });
465
- this.initialize().catch(err => { throw err; });
466
519
  this._log.info('getMetadata request %j', request);
467
520
  const wrappedCallback = callback
468
521
  ? (error, response, options, rawResponse) => {
@@ -470,12 +523,16 @@ class BetaAnalyticsDataClient {
470
523
  callback(error, response, options, rawResponse); // We verified callback above.
471
524
  }
472
525
  : undefined;
473
- return this.innerApiCalls.getMetadata(request, options, wrappedCallback)
526
+ return this.innerApiCalls
527
+ .getMetadata(request, options, wrappedCallback)
474
528
  ?.then(([response, options, rawResponse]) => {
475
529
  this._log.info('getMetadata response %j', response);
476
530
  return [response, options, rawResponse];
477
- }).catch((error) => {
478
- if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
531
+ })
532
+ .catch((error) => {
533
+ if (error &&
534
+ 'statusDetails' in error &&
535
+ error.statusDetails instanceof Array) {
479
536
  const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
480
537
  error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
481
538
  }
@@ -495,10 +552,13 @@ class BetaAnalyticsDataClient {
495
552
  options = options || {};
496
553
  options.otherArgs = options.otherArgs || {};
497
554
  options.otherArgs.headers = options.otherArgs.headers || {};
498
- options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
499
- 'property': request.property ?? '',
555
+ options.otherArgs.headers['x-goog-request-params'] =
556
+ this._gaxModule.routingHeader.fromParams({
557
+ property: request.property ?? '',
558
+ });
559
+ this.initialize().catch((err) => {
560
+ throw err;
500
561
  });
501
- this.initialize().catch(err => { throw err; });
502
562
  this._log.info('runRealtimeReport request %j', request);
503
563
  const wrappedCallback = callback
504
564
  ? (error, response, options, rawResponse) => {
@@ -506,12 +566,16 @@ class BetaAnalyticsDataClient {
506
566
  callback(error, response, options, rawResponse); // We verified callback above.
507
567
  }
508
568
  : undefined;
509
- return this.innerApiCalls.runRealtimeReport(request, options, wrappedCallback)
569
+ return this.innerApiCalls
570
+ .runRealtimeReport(request, options, wrappedCallback)
510
571
  ?.then(([response, options, rawResponse]) => {
511
572
  this._log.info('runRealtimeReport response %j', response);
512
573
  return [response, options, rawResponse];
513
- }).catch((error) => {
514
- if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
574
+ })
575
+ .catch((error) => {
576
+ if (error &&
577
+ 'statusDetails' in error &&
578
+ error.statusDetails instanceof Array) {
515
579
  const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
516
580
  error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
517
581
  }
@@ -531,10 +595,13 @@ class BetaAnalyticsDataClient {
531
595
  options = options || {};
532
596
  options.otherArgs = options.otherArgs || {};
533
597
  options.otherArgs.headers = options.otherArgs.headers || {};
534
- options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
535
- 'property': request.property ?? '',
598
+ options.otherArgs.headers['x-goog-request-params'] =
599
+ this._gaxModule.routingHeader.fromParams({
600
+ property: request.property ?? '',
601
+ });
602
+ this.initialize().catch((err) => {
603
+ throw err;
536
604
  });
537
- this.initialize().catch(err => { throw err; });
538
605
  this._log.info('checkCompatibility request %j', request);
539
606
  const wrappedCallback = callback
540
607
  ? (error, response, options, rawResponse) => {
@@ -542,12 +609,16 @@ class BetaAnalyticsDataClient {
542
609
  callback(error, response, options, rawResponse); // We verified callback above.
543
610
  }
544
611
  : undefined;
545
- return this.innerApiCalls.checkCompatibility(request, options, wrappedCallback)
612
+ return this.innerApiCalls
613
+ .checkCompatibility(request, options, wrappedCallback)
546
614
  ?.then(([response, options, rawResponse]) => {
547
615
  this._log.info('checkCompatibility response %j', response);
548
616
  return [response, options, rawResponse];
549
- }).catch((error) => {
550
- if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
617
+ })
618
+ .catch((error) => {
619
+ if (error &&
620
+ 'statusDetails' in error &&
621
+ error.statusDetails instanceof Array) {
551
622
  const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
552
623
  error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
553
624
  }
@@ -567,10 +638,13 @@ class BetaAnalyticsDataClient {
567
638
  options = options || {};
568
639
  options.otherArgs = options.otherArgs || {};
569
640
  options.otherArgs.headers = options.otherArgs.headers || {};
570
- options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
571
- 'name': request.name ?? '',
641
+ options.otherArgs.headers['x-goog-request-params'] =
642
+ this._gaxModule.routingHeader.fromParams({
643
+ name: request.name ?? '',
644
+ });
645
+ this.initialize().catch((err) => {
646
+ throw err;
572
647
  });
573
- this.initialize().catch(err => { throw err; });
574
648
  this._log.info('queryAudienceExport request %j', request);
575
649
  const wrappedCallback = callback
576
650
  ? (error, response, options, rawResponse) => {
@@ -578,12 +652,16 @@ class BetaAnalyticsDataClient {
578
652
  callback(error, response, options, rawResponse); // We verified callback above.
579
653
  }
580
654
  : undefined;
581
- return this.innerApiCalls.queryAudienceExport(request, options, wrappedCallback)
655
+ return this.innerApiCalls
656
+ .queryAudienceExport(request, options, wrappedCallback)
582
657
  ?.then(([response, options, rawResponse]) => {
583
658
  this._log.info('queryAudienceExport response %j', response);
584
659
  return [response, options, rawResponse];
585
- }).catch((error) => {
586
- if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
660
+ })
661
+ .catch((error) => {
662
+ if (error &&
663
+ 'statusDetails' in error &&
664
+ error.statusDetails instanceof Array) {
587
665
  const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
588
666
  error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
589
667
  }
@@ -603,10 +681,13 @@ class BetaAnalyticsDataClient {
603
681
  options = options || {};
604
682
  options.otherArgs = options.otherArgs || {};
605
683
  options.otherArgs.headers = options.otherArgs.headers || {};
606
- options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
607
- 'name': request.name ?? '',
684
+ options.otherArgs.headers['x-goog-request-params'] =
685
+ this._gaxModule.routingHeader.fromParams({
686
+ name: request.name ?? '',
687
+ });
688
+ this.initialize().catch((err) => {
689
+ throw err;
608
690
  });
609
- this.initialize().catch(err => { throw err; });
610
691
  this._log.info('getAudienceExport request %j', request);
611
692
  const wrappedCallback = callback
612
693
  ? (error, response, options, rawResponse) => {
@@ -614,12 +695,16 @@ class BetaAnalyticsDataClient {
614
695
  callback(error, response, options, rawResponse); // We verified callback above.
615
696
  }
616
697
  : undefined;
617
- return this.innerApiCalls.getAudienceExport(request, options, wrappedCallback)
698
+ return this.innerApiCalls
699
+ .getAudienceExport(request, options, wrappedCallback)
618
700
  ?.then(([response, options, rawResponse]) => {
619
701
  this._log.info('getAudienceExport response %j', response);
620
702
  return [response, options, rawResponse];
621
- }).catch((error) => {
622
- if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
703
+ })
704
+ .catch((error) => {
705
+ if (error &&
706
+ 'statusDetails' in error &&
707
+ error.statusDetails instanceof Array) {
623
708
  const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
624
709
  error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
625
710
  }
@@ -639,10 +724,13 @@ class BetaAnalyticsDataClient {
639
724
  options = options || {};
640
725
  options.otherArgs = options.otherArgs || {};
641
726
  options.otherArgs.headers = options.otherArgs.headers || {};
642
- options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
643
- 'parent': request.parent ?? '',
727
+ options.otherArgs.headers['x-goog-request-params'] =
728
+ this._gaxModule.routingHeader.fromParams({
729
+ parent: request.parent ?? '',
730
+ });
731
+ this.initialize().catch((err) => {
732
+ throw err;
644
733
  });
645
- this.initialize().catch(err => { throw err; });
646
734
  const wrappedCallback = callback
647
735
  ? (error, response, rawResponse, _) => {
648
736
  this._log.info('createAudienceExport response %j', rawResponse);
@@ -650,7 +738,8 @@ class BetaAnalyticsDataClient {
650
738
  }
651
739
  : undefined;
652
740
  this._log.info('createAudienceExport request %j', request);
653
- return this.innerApiCalls.createAudienceExport(request, options, wrappedCallback)
741
+ return this.innerApiCalls
742
+ .createAudienceExport(request, options, wrappedCallback)
654
743
  ?.then(([response, rawResponse, _]) => {
655
744
  this._log.info('createAudienceExport response %j', rawResponse);
656
745
  return [response, rawResponse, _];
@@ -687,10 +776,13 @@ class BetaAnalyticsDataClient {
687
776
  options = options || {};
688
777
  options.otherArgs = options.otherArgs || {};
689
778
  options.otherArgs.headers = options.otherArgs.headers || {};
690
- options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
691
- 'parent': request.parent ?? '',
779
+ options.otherArgs.headers['x-goog-request-params'] =
780
+ this._gaxModule.routingHeader.fromParams({
781
+ parent: request.parent ?? '',
782
+ });
783
+ this.initialize().catch((err) => {
784
+ throw err;
692
785
  });
693
- this.initialize().catch(err => { throw err; });
694
786
  const wrappedCallback = callback
695
787
  ? (error, values, nextPageRequest, rawResponse) => {
696
788
  this._log.info('listAudienceExports values %j', values);
@@ -739,12 +831,15 @@ class BetaAnalyticsDataClient {
739
831
  options = options || {};
740
832
  options.otherArgs = options.otherArgs || {};
741
833
  options.otherArgs.headers = options.otherArgs.headers || {};
742
- options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
743
- 'parent': request.parent ?? '',
744
- });
834
+ options.otherArgs.headers['x-goog-request-params'] =
835
+ this._gaxModule.routingHeader.fromParams({
836
+ parent: request.parent ?? '',
837
+ });
745
838
  const defaultCallSettings = this._defaults['listAudienceExports'];
746
839
  const callSettings = defaultCallSettings.merge(options);
747
- this.initialize().catch(err => { throw err; });
840
+ this.initialize().catch((err) => {
841
+ throw err;
842
+ });
748
843
  this._log.info('listAudienceExports stream %j', request);
749
844
  return this.descriptors.page.listAudienceExports.createStream(this.innerApiCalls.listAudienceExports, request, callSettings);
750
845
  }
@@ -785,45 +880,48 @@ class BetaAnalyticsDataClient {
785
880
  options = options || {};
786
881
  options.otherArgs = options.otherArgs || {};
787
882
  options.otherArgs.headers = options.otherArgs.headers || {};
788
- options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({
789
- 'parent': request.parent ?? '',
790
- });
883
+ options.otherArgs.headers['x-goog-request-params'] =
884
+ this._gaxModule.routingHeader.fromParams({
885
+ parent: request.parent ?? '',
886
+ });
791
887
  const defaultCallSettings = this._defaults['listAudienceExports'];
792
888
  const callSettings = defaultCallSettings.merge(options);
793
- this.initialize().catch(err => { throw err; });
889
+ this.initialize().catch((err) => {
890
+ throw err;
891
+ });
794
892
  this._log.info('listAudienceExports iterate %j', request);
795
893
  return this.descriptors.page.listAudienceExports.asyncIterate(this.innerApiCalls['listAudienceExports'], request, callSettings);
796
894
  }
797
895
  /**
798
- * Gets the latest state of a long-running operation. Clients can use this
799
- * method to poll the operation result at intervals as recommended by the API
800
- * service.
801
- *
802
- * @param {Object} request - The request object that will be sent.
803
- * @param {string} request.name - The name of the operation resource.
804
- * @param {Object=} options
805
- * Optional parameters. You can override the default settings for this call,
806
- * e.g, timeout, retries, paginations, etc. See {@link
807
- * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions}
808
- * for the details.
809
- * @param {function(?Error, ?Object)=} callback
810
- * The function which will be called with the result of the API call.
811
- *
812
- * The second parameter to the callback is an object representing
813
- * {@link google.longrunning.Operation | google.longrunning.Operation}.
814
- * @return {Promise} - The promise which resolves to an array.
815
- * The first element of the array is an object representing
816
- * {@link google.longrunning.Operation | google.longrunning.Operation}.
817
- * The promise has a method named "cancel" which cancels the ongoing API call.
818
- *
819
- * @example
820
- * ```
821
- * const client = longrunning.operationsClient();
822
- * const name = '';
823
- * const [response] = await client.getOperation({name});
824
- * // doThingsWith(response)
825
- * ```
826
- */
896
+ * Gets the latest state of a long-running operation. Clients can use this
897
+ * method to poll the operation result at intervals as recommended by the API
898
+ * service.
899
+ *
900
+ * @param {Object} request - The request object that will be sent.
901
+ * @param {string} request.name - The name of the operation resource.
902
+ * @param {Object=} options
903
+ * Optional parameters. You can override the default settings for this call,
904
+ * e.g, timeout, retries, paginations, etc. See {@link
905
+ * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions}
906
+ * for the details.
907
+ * @param {function(?Error, ?Object)=} callback
908
+ * The function which will be called with the result of the API call.
909
+ *
910
+ * The second parameter to the callback is an object representing
911
+ * {@link google.longrunning.Operation | google.longrunning.Operation}.
912
+ * @return {Promise} - The promise which resolves to an array.
913
+ * The first element of the array is an object representing
914
+ * {@link google.longrunning.Operation | google.longrunning.Operation}.
915
+ * The promise has a method named "cancel" which cancels the ongoing API call.
916
+ *
917
+ * @example
918
+ * ```
919
+ * const client = longrunning.operationsClient();
920
+ * const name = '';
921
+ * const [response] = await client.getOperation({name});
922
+ * // doThingsWith(response)
923
+ * ```
924
+ */
827
925
  getOperation(request, optionsOrCallback, callback) {
828
926
  let options;
829
927
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -1060,7 +1158,7 @@ class BetaAnalyticsDataClient {
1060
1158
  */
1061
1159
  close() {
1062
1160
  if (this.betaAnalyticsDataStub && !this._terminated) {
1063
- return this.betaAnalyticsDataStub.then(stub => {
1161
+ return this.betaAnalyticsDataStub.then((stub) => {
1064
1162
  this._log.info('ending gRPC channel');
1065
1163
  this._terminated = true;
1066
1164
  stub.close();